Skip to content
This repository has been archived by the owner on Nov 22, 2019. It is now read-only.

Commit

Permalink
Adds path to schema nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
mdrillin committed Jun 25, 2018
1 parent 04d6dbf commit 05e093c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
Expand Up @@ -46,6 +46,11 @@ public class RestSchemaNode implements KRestEntity {
*/
public static final String TYPE_LABEL = "type";

/**
* Label for type
*/
public static final String PATH_LABEL = "path";

/**
* Label for queryable
*/
Expand All @@ -64,6 +69,8 @@ public class RestSchemaNode implements KRestEntity {

private String type;

private String path;

private boolean queryable = false;

/**
Expand Down Expand Up @@ -113,6 +120,14 @@ public void setType(String type) {
this.type = type;
}

public String getPath() {
return path;
}

public void setPath(String path) {
this.path = path;
}

public boolean isQueryable() {
return queryable;
}
Expand Down
Expand Up @@ -1506,6 +1506,8 @@ private List<RestSchemaNode> generateConnectionSchema(final UnitOfWork uow, fina
String name = getSegmentName(segments[segments.length-1]);
RestSchemaNode node = new RestSchemaNode(connectionName, name, type);
node.setQueryable(true);
String path = createSchemaNodePath(segments.length-1, segments);
node.setPath(path);
parentNode.addChild(node);
}
}
Expand Down Expand Up @@ -1540,6 +1542,8 @@ private RestSchemaNode getLeafNodeParent(String connectionName, List<RestSchemaN
// No match - create a new node
if(matchNode == null) {
matchNode = new RestSchemaNode(connectionName, name, type);
String path = createSchemaNodePath(i,segments);
matchNode.setPath(path);
currentNodes.add(matchNode);
}
// Set parent for next iteration
Expand All @@ -1558,6 +1562,8 @@ private RestSchemaNode getLeafNodeParent(String connectionName, List<RestSchemaN
// No match - create a new node
if(matchNode == null) {
matchNode = new RestSchemaNode(connectionName, name, type);
String path = createSchemaNodePath(i,segments);
matchNode.setPath(path);
parentNode.addChild(matchNode);
}
// Set next parent if not last level
Expand All @@ -1569,6 +1575,27 @@ private RestSchemaNode getLeafNodeParent(String connectionName, List<RestSchemaN
return parentNode;
}

/**
* Generate the path for the node, given the segments and the position within the segments
* @param iPosn the index position within the segments
* @param segments the array of segments
* @return the node path (segment0/segment1/etc)
*/
private String createSchemaNodePath(int iPosn, String[] segments) {
StringBuilder sb = new StringBuilder();
if(segments!=null && segments.length > 0) {
for (int i = 0; i < segments.length; i++) {
if(i < iPosn) {
sb.append(segments[i]+"/");
} else {
sb.append(segments[i]);
break;
}
}
}
return sb.toString();
}

/**
* Searches the supplied list for node with matching name and type. Does NOT search children or parents of supplied nodes.
* @param connectionName the connection name
Expand Down
Expand Up @@ -2004,11 +2004,9 @@ public Response refreshPreviewVdb( final @Context HttpHeaders headers,

// Get the current workspace connection VDB names
List<String> connectionVdbNames = new ArrayList<String>();
KomodoObject[] allVdbObjs = wMgr.getChildrenOfType(uow, VdbLexicon.Vdb.VIRTUAL_DATABASE);
for( KomodoObject kObj: allVdbObjs) {
if(kObj.getName(uow).endsWith("btlconn")) {
connectionVdbNames.add(kObj.getName(uow));
}
KomodoObject[] connVdbObjs = wMgr.getChildrenOfType(uow, VdbLexicon.Vdb.VIRTUAL_DATABASE, "*btlconn");
for( KomodoObject kObj: connVdbObjs) {
connectionVdbNames.add(kObj.getName(uow));
}

// Add import for connectionVdb if it is missing
Expand Down

0 comments on commit 05e093c

Please sign in to comment.