Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
15d02d8
Add function to get git HEAD hash
mtvaught-ibm Oct 18, 2019
974fd43
Get the current commit hash from common-mrw
mtvaught-ibm Oct 18, 2019
fe6c4d6
Can filter fields in the attribute table using a search bar
Oct 23, 2019
ec3406b
test file for hash update
Oct 25, 2019
c81446c
Added search bar and search text
Oct 25, 2019
21dd15c
Can now search tree for first target matching the search text
Oct 29, 2019
2407016
Added 'search all' functionality
Oct 29, 2019
8409895
Added code to get commit hash from existing common-mrw folder
Nov 1, 2019
b3c2e04
Merge branch 'part-versions' of https://github.ibm.com/jumpstart-2019…
Nov 1, 2019
8a0ad9f
Changed placement of hash output
Nov 1, 2019
edf6187
Target.java read in git hash version from existing MRW
Nov 1, 2019
3ecc4ea
Fix issues with search function. Add check boxes for future use
Timberlon Nov 1, 2019
dd26914
Merge branch 'searchFeature' into part-versions
Nov 4, 2019
fd08446
Added functionality to checkboxes, can now search by attribute name, …
Nov 4, 2019
eda2b40
Added wildcard functionality where user can use quotation marks to se…
Nov 4, 2019
73b5e80
Reopen selected item in tree after switching tabs
Timberlon Nov 6, 2019
d18f10e
Remove _xyz
Timberlon Nov 6, 2019
cd08555
Remove unnecessary includes, add comments
Timberlon Nov 7, 2019
4484563
Ctrl-f leads user to search tab
Nov 7, 2019
19be0d8
added comments and updated directions for search
Nov 7, 2019
551cb50
fixed puncuation issue with directions
Nov 7, 2019
24e0575
fixed bugs with ctrl-f functionality
Nov 7, 2019
1d2311b
fixed bug in atribute table filter
Nov 7, 2019
4e5eaee
Fixed bug that stopped searchFeature from working when checking a new…
Nov 8, 2019
1191b82
Removed unneccesary imports
Nov 8, 2019
9b3070c
Fix bug where items would get searched twice if name + some other val…
Timberlon Nov 8, 2019
96e81e5
Fix empty attribute table when switching tabs
Timberlon Nov 8, 2019
d6e5134
Show git-commit of common-mrw where target instance is from
Nov 8, 2019
7d32349
Shows number of search results found
Nov 8, 2019
bd6e8fa
Merge pull request #2 from jumpstart-2019-serverwiz/searchFeature
Nov 8, 2019
af2a140
Update MainDialog.java
Nov 8, 2019
5e65d28
Merge in search features from master
Nov 8, 2019
993dc2d
Removed system print command
Nov 8, 2019
96f3685
Merge pull request #3 from jumpstart-2019-serverwiz/part-versions
Nov 8, 2019
b797586
Change commit hash to text instead of label
Nov 8, 2019
fb94487
Merge branch 'part-versions'
Nov 8, 2019
63931af
Fix commit hash text field on linux
mtvaught-ibm Nov 8, 2019
f718d44
Fixed UI issue where combo and attribute table search text are cut of…
Nov 12, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions src/com/ibm/ServerWizard2/controller/TargetWizardController.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,24 @@
import java.util.TreeMap;
import java.util.Vector;

import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.status.StatusLogger;
import org.eclipse.swt.widgets.TreeItem;

import com.ibm.ServerWizard2.ServerWizard2;
import com.ibm.ServerWizard2.model.Connection;
import com.ibm.ServerWizard2.model.Field;
import com.ibm.ServerWizard2.model.SystemModel;
import com.ibm.ServerWizard2.model.Target;
import com.ibm.ServerWizard2.utility.Github;
//import com.ibm.ServerWizard2.utility.Github;
import com.ibm.ServerWizard2.utility.GithubRepository;
import com.ibm.ServerWizard2.utility.ServerwizMessageDialog;
import com.ibm.ServerWizard2.view.LogViewerDialog;
import com.ibm.ServerWizard2.view.MainDialog;

import com.ibm.ServerWizard2.utility.ServerwizMessageDialog;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.status.StatusLogger;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.swt.widgets.TreeItem;

public class TargetWizardController {
private SystemModel model;
Expand Down Expand Up @@ -54,13 +57,26 @@ public void init() {
try {
String libraryLocation = ServerWizard2.GIT_LOCATION + File.separator + this.LIBRARY_NAME;
File chk = new File(libraryLocation);
String libraryCommitHash = "";

if (!chk.exists()) {
ServerWizard2.LOGGER.info("XML library does not exist so cloning: "+libraryLocation);
StatusLogger.getLogger().setLevel(Level.FATAL);
GithubRepository git = new GithubRepository(ServerWizard2.DEFAULT_REMOTE_URL, ServerWizard2.GIT_LOCATION, false);
git.cloneRepository();
libraryCommitHash = git.getHash();
} else {
try {
Git repo = Git.open(chk);
ObjectId head = repo.getRepository().resolve(Constants.HEAD);
RevCommit commit = repo.log().add(head).setMaxCount(1).call().iterator().next();
libraryCommitHash = commit.getName();
repo.close();
} catch (Exception e1) {
ServerWizard2.LOGGER.severe(e1.getMessage());
}
}
model.loadLibrary(libraryLocation);
model.loadLibrary(libraryLocation, libraryCommitHash);
this.initModel();

//Check if there are additional libraries to be cloned
Expand Down
17 changes: 13 additions & 4 deletions src/com/ibm/ServerWizard2/model/SystemModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import org.xml.sax.SAXException;

import com.ibm.ServerWizard2.ServerWizard2;
import com.ibm.ServerWizard2.utility.Github;
import com.ibm.ServerWizard2.utility.GithubRepository;
//import com.ibm.ServerWizard2.utility.Github;
//import com.ibm.ServerWizard2.utility.GithubRepository;
import com.ibm.ServerWizard2.utility.ServerwizMessageDialog;
import com.ibm.ServerWizard2.view.ErrataViewer;

Expand Down Expand Up @@ -210,7 +210,12 @@ private NodeList isXMLValid(Document document, String tag) {
}
return null;
}

public void loadLibrary(String path) throws Exception {
this.loadLibrary(path, "");
}

public void loadLibrary(String path, String commitHash) throws Exception {
if (this.loadedLibraries.containsKey(path)) {
ServerWizard2.LOGGER.info("Library already loaded: "+path);
return;
Expand Down Expand Up @@ -262,7 +267,7 @@ public void loadLibrary(String path) throws Exception {
} else {
for (File file : filesList) {
if (file.isFile() && file.getAbsolutePath().endsWith(".xml")) {
this.loadTargets(file.getPath());
this.loadTargets(file.getPath(), commitHash);
}
}
}
Expand Down Expand Up @@ -718,7 +723,7 @@ public void loadAttributes(String fileName) throws SAXException,
}
}

public void loadTargets(String filename) throws Exception {
public void loadTargets(String filename, String commitHash) throws Exception {
ServerWizard2.LOGGER.info("Loading Part: " + filename);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Expand All @@ -735,6 +740,10 @@ public void loadTargets(String filename) throws Exception {
} else {
target = new Target(tmodel);
}
if(!commitHash.isEmpty())
{
target.setLibraryCommitHash(commitHash);
}
target.readTargetXML(t, targetModels, attributes);
addParentAttributes(target, target);
if (target.isRoot()) {
Expand Down
45 changes: 31 additions & 14 deletions src/com/ibm/ServerWizard2/model/Target.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ public class Target implements Comparable<Target>, java.io.Serializable {

private String name = "";
private String type = "";
private String libraryCommitHash = "";
private int position = -1;
public String parent = ""; // says which parent to inherit attributes from

private Vector<String> parentType = new Vector<String>();
private TreeMap<String, Attribute> attributes = new TreeMap<String, Attribute>();
private Vector<String> children = new Vector<String>();
Expand All @@ -40,6 +41,7 @@ public Target(Target s) {
this.hidden = s.hidden;
this.root = s.root;
this.parentType.addAll(s.parentType);
this.libraryCommitHash = s.getLibraryCommitHash();

for (Map.Entry<String, Attribute> entry : s.getAttributes().entrySet()) {
String key = new String(entry.getKey());
Expand Down Expand Up @@ -144,7 +146,7 @@ public Vector<String> getParentType() {
}
public void addParentType(String parent_type) {
this.parentType.add(parent_type);
}
}
public void setType(String type) {
this.type = type;
}
Expand All @@ -156,7 +158,7 @@ public String getType() {
public String getIdPrefix() {
String s[] = type.split("-");
if (s.length == 1) { return this.name; }

if (s[1].equals("processor")) {
s[1] = "proc";
}
Expand All @@ -168,7 +170,7 @@ public String getIdPrefix() {
public TreeMap<String, Attribute> getAttributes() {
return attributes;
}

public void deepCopyAttributes(HashMap<String,Target> model,HashMap<String,Target> instances) {
ServerWizard2.LOGGER.info("Defaulting attributes for: "+this.getName());
Target source = model.get(this.getName());
Expand All @@ -185,7 +187,7 @@ public void deepCopyAttributes(HashMap<String,Target> model,HashMap<String,Targe
child.deepCopyAttributes(model, instances);
}
}

public boolean attributeExists(String attribute) {
if (attributes.get(attribute) == null) {
return false;
Expand All @@ -198,7 +200,7 @@ public String getAttribute(String attribute) {
}
return attributes.get(attribute).getValue().getValue();
}

void copyAttributesFromParent(Target s) {
for (Map.Entry<String, Attribute> entry : s.getAttributes().entrySet()) {
String key = entry.getKey();
Expand Down Expand Up @@ -253,8 +255,8 @@ Boolean isOverrideGroup() {
Boolean isOverride() {
return (this.getAttribute("MRW_TYPE").equals("TARGET_OVERRIDE"));
}


private void setAttributeValue(String attr, String value) {
Attribute attribute = this.attributes.get(attr);
if (attribute == null) {
Expand Down Expand Up @@ -376,6 +378,9 @@ public void readModelXML(Element target, HashMap<String, Attribute> attrMap) {
public void readInstanceXML(Element t, TreeMap<String, Target> targetModels) throws Exception {
name = SystemModel.getElement(t, "instance_name");
type = SystemModel.getElement(t, "type");

// Expects SystemModel.getElement() to return empty string if element is not found
libraryCommitHash = SystemModel.getElement(t, "common_mrw_git_hash_version");
String rootStr = SystemModel.getElement(t, "is_root");
if (rootStr.equals("true")) { this.root = true; }

Expand All @@ -387,7 +392,7 @@ public void readInstanceXML(Element t, TreeMap<String, Target> targetModels) thr
setPosition(tmpPos);
}
}

NodeList childList = t.getElementsByTagName("child_id");
for (int j = 0; j < childList.getLength(); ++j) {
Element attr = (Element) childList.item(j);
Expand Down Expand Up @@ -434,6 +439,9 @@ public void writeInstanceXML(Writer out,HashMap<String,Target> targetLookup,Hash
out.write("<targetInstance>\n");
out.write("\t<id>" + this.getName() + "</id>\n");
out.write("\t<type>" + this.getType() + "</type>\n");
if (!this.getLibraryCommitHash().isEmpty()) {
out.write("\t<common_mrw_git_hash_version>" + this.getLibraryCommitHash() + "</common_mrw_git_hash_version>\n");
}
String rootStr = "false";
if (this.isRoot()) { rootStr = "true"; }
out.write("\t<is_root>" + rootStr + "</is_root>\n");
Expand All @@ -442,7 +450,6 @@ public void writeInstanceXML(Writer out,HashMap<String,Target> targetLookup,Hash
} else {
out.write("\t<instance_name>" + this.getIdPrefix() + "</instance_name>\n");
}

out.write("\t<position>" + getPosition() + "</position>\n");
//write children
for (String childStr : this.children) {
Expand Down Expand Up @@ -471,7 +478,7 @@ public void writeInstanceXML(Writer out,HashMap<String,Target> targetLookup,Hash
child.writeInstanceXML(out, targetLookup, targetWritten);
}
}

// New format
public void readTargetXML(Element t, TreeMap<String, Target> targetModels, HashMap<String, Attribute> attributeModels) throws Exception {
name = SystemModel.getElement(t, "instance_name");
Expand All @@ -489,7 +496,7 @@ public void readTargetXML(Element t, TreeMap<String, Target> targetModels, HashM
for (int i = 0; i < parentList.getLength(); i++) {
Element e = (Element) parentList.item(i);
parentType.add(e.getChildNodes().item(0).getNodeValue());
}
}

NodeList childList = t.getElementsByTagName("child_id");
for (int j = 0; j < childList.getLength(); ++j) {
Expand Down Expand Up @@ -529,7 +536,7 @@ public void readTargetXML(Element t, TreeMap<String, Target> targetModels, HashM
conn.readInstanceXML(bus);
busses.get(busTarget).add(conn);
}
}
}
public void writeTargetXML(Writer out,HashMap<String,Target> targetLookup, HashMap<String,Boolean>targetWritten) throws Exception {
if (targetWritten.containsKey(this.getName())) {
return;
Expand All @@ -552,7 +559,7 @@ public void writeTargetXML(Writer out,HashMap<String,Target> targetLookup, HashM
for (String p_type : this.parentType) {
out.write("\t<parent_type>" + p_type + "</parent_type>\n");
}

//write children
for (String childStr : this.children) {
out.write("\t<child_id>"+childStr+"</child_id>\n");
Expand Down Expand Up @@ -580,4 +587,14 @@ public void writeTargetXML(Writer out,HashMap<String,Target> targetLookup, HashM
child.writeTargetXML(out, targetLookup, targetWritten);
}
}

public void setLibraryCommitHash(String commitHashParm)
{
this.libraryCommitHash = commitHashParm;
}

public String getLibraryCommitHash()
{
return this.libraryCommitHash;
}
}
25 changes: 22 additions & 3 deletions src/com/ibm/ServerWizard2/utility/GithubRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.io.PrintWriter;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;

import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.RebaseResult;
Expand All @@ -15,7 +16,10 @@
import org.eclipse.jgit.transport.RefSpec;
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
import org.eclipse.jgit.util.FS;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Constants;

import com.ibm.ServerWizard2.ServerWizard2;
import com.ibm.ServerWizard2.view.PasswordPrompt;
Expand All @@ -28,7 +32,7 @@ public class GithubRepository implements Comparable<GithubRepository> {
private boolean passwordValidated = false;
private Shell shell = null;
private UsernamePasswordCredentialsProvider credentials;

private boolean cloned;
private final RefSpec refSpec = new RefSpec("+refs/heads/*:refs/remotes/origin/*");

Expand Down Expand Up @@ -183,7 +187,22 @@ public org.eclipse.jgit.api.Status status() {
}
return status;
}


public String getHash()
{
String rtn = "";
try {
Git repo = Git.open(this.getRootDirectory());
ObjectId head = repo.getRepository().resolve(Constants.HEAD);
RevCommit commit = repo.log().add(head).setMaxCount(1).call().iterator().next();
rtn = commit.getName();
repo.close();
} catch (Exception e1) {
ServerWizard2.LOGGER.severe(e1.getMessage());
}
return rtn;
}

// The chained exceptions from jgit don't explain error
// Need to dive down to root cause and make better error message.
public void betterError(Exception e) throws Exception {
Expand Down Expand Up @@ -238,7 +257,7 @@ public boolean equals(Object o) {
return false;
}
Throwable getCause(Throwable e) {
Throwable cause = null;
Throwable cause = null;
Throwable result = e;

while(null != (cause = result.getCause()) && (result != cause) ) {
Expand Down
51 changes: 51 additions & 0 deletions src/com/ibm/ServerWizard2/view/AttributeTableFilter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.ibm.ServerWizard2.view;

import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;

import com.ibm.ServerWizard2.model.Field;

public class AttributeTableFilter extends ViewerFilter {

private String searchString;

void setSearchText(String s) {
if(s.length() > 1 && s.startsWith("\"") && s.endsWith("\"")) {
this.searchString = s.substring(1, s.length() - 1);
}
else {
this.searchString = ".*" + s + ".*";
}

}

@Override
public boolean select(Viewer viewer,
Object parentElement,
Object element) {
// TODO Auto-generated method stub
if(searchString == null || searchString.isEmpty()) {
return true;
}

Field field = (Field) element;
if(field.attributeName.toLowerCase().matches(searchString)) {
return true;
}
if(field.name.toLowerCase().matches(searchString)) {
return true;
}
if(field.value.toLowerCase().matches(searchString)) {
return true;
}
if(field.desc.toLowerCase().matches(searchString)) {
return true;
}
if(field.group.toLowerCase().matches(searchString)) {
return true;
}

return false;
}

}
Loading