Skip to content
Permalink
Browse files

find-show update

find-show update - increased search depth
  • Loading branch information...
SysIntAu committed Nov 26, 2018
1 parent b11a63c commit 5acc65808e9183d775a44f977c1f512947647adb
Showing with 45 additions and 59 deletions.
  1. +1 −0 build.bat
  2. +11 −0 src/main/java/org/dpdirect/dpmgmt/DPDirect.java
  3. +33 −59 src/main/java/org/dpdirect/schema/SchemaHelper.java
@@ -0,0 +1 @@
cmd /k mvn clean install -e -U
@@ -139,6 +139,14 @@ public static void main(String... args) {
dpSession.sampleOperation(arg1.replace("find=", ""));
System.exit(0);
}
if (arg1.equalsIgnoreCase("show")) {
dpSession.sampleOperation(args[1]);
System.exit(0);
}
if (arg1.contains("show=")) {
dpSession.sampleOperation(arg1.replace("show=", ""));
System.exit(0);
}

for (int i = 0; i < args.length; i++) {
String option = (String) args[i];
@@ -258,6 +266,9 @@ public static void consoleMode(DPDirect dpSession) {
if (operationName.equalsIgnoreCase("find")
&& newArgs[1] != null) {
dpSession.sampleOperation(newArgs[1]);
} else if (operationName.equalsIgnoreCase("show")
&& newArgs[1] != null) {
dpSession.sampleOperation(newArgs[1]);
} else if (operationName.equalsIgnoreCase("help")) {
if (newArgs.length > 1
&& Constants.USAGE_HELP_ANT.equals(newArgs[1])) {
@@ -401,26 +401,16 @@ public boolean nodeExists(String aNodeName) {
* @param elementDeclaration XSElementDeclaration : the root element
*/
private void findReference(XSElementDeclaration elementDeclaration) {
String elemName = elementDeclaration.getName();
String thisContext = elemName;
XSTypeDefinition typeDefinition = elementDeclaration.getTypeDefinition();
XSTypeDefinition typeDefinition = elementDeclaration.getTypeDefinition();
String typeDefName = typeDefinition.getName();
String thisContext = elementDeclaration.getName();
if (null != typeDefinition) {
String typeDefName = typeDefinition.getName();
currentNodeNames.clear();
currentNodeNames.add(elementDeclaration.getName());
if (typeDefinition instanceof XSComplexTypeDefinition) {
addToSchemaMap(elemName, typeDefName);
if (null != typeDefName) {
thisContext = typeDefName;
}
XSParticle particle = ((XSComplexTypeDefinition) typeDefinition).getParticle();
currentNodeNames.clear();
if (typeDefinition instanceof XSComplexTypeDefinition) {
XSParticle particle = ((XSComplexTypeDefinition) typeDefinition).getParticle();
findReferenceInParticle(thisContext, particle);
}
else {
addToSchemaMap(elemName, typeDefName);
if (null != typeDefName) {
thisContext = typeDefName;
}
} else {
addToSchemaMap(thisContext, typeDefName);
}
}
}
@@ -432,33 +422,24 @@ private void findReference(XSElementDeclaration elementDeclaration) {
* @param context the context.
* @param elementDeclaration the element declaration.
*/
private void findElementReference(String context,
XSElementDeclaration elementDeclaration) {
private void findElementReference(String context, XSElementDeclaration elementDeclaration) {
XSTypeDefinition typeDefinition = elementDeclaration.getTypeDefinition();
if (null != typeDefinition) {
String typeDefName = typeDefinition.getName();
String typeDefName = typeDefinition.getName();
String elementName = elementDeclaration.getName();
addToSchemaMap(context, elementName);
if (!(currentNodeNames.contains(elementName))) {
currentNodeNames.add(elementName);
}
if (typeDefinition instanceof XSComplexTypeDefinition) {
addToSchemaMap(context, typeDefName);
if (null != typeDefName) {
context = typeDefName;
}
XSParticle particle = ((XSComplexTypeDefinition) typeDefinition).getParticle();
if (currentNodeNames.contains(typeDefName)) {
/* circular reference */
// currentNodeNames.add(typeDefName);
// findReferenceInParticle(context, particle);
if (null != particle) {
findReferenceInParticle(elementName, particle);
} else {
addToSchemaMap(elementName, typeDefName);
}
else {
currentNodeNames.add(typeDefName);
findReferenceInParticle(context, particle);
}
}
else {
addToSchemaMap(context, typeDefName);
if (null != typeDefName) {
context = typeDefName;
}
currentNodeNames.add(typeDefName);
} else { // add to keyset
addToSchemaMap(elementName, typeDefName);
}
}
}
@@ -470,8 +451,7 @@ private void findElementReference(String context,
* @param context the context.
* @param particle the particle.
*/
private void findReferenceInParticle(String context,
XSParticle particle) {
private void findReferenceInParticle(String context, XSParticle particle) {
if (null != particle) {
XSTerm term = particle.getTerm();
if (term instanceof XSModelGroup) {
@@ -484,25 +464,19 @@ private void findReferenceInParticle(String context,
}
}
else if (term instanceof XSElementDeclaration) {
String tName = term.getName();
addToSchemaMap(context, tName);
context = tName;
if (currentNodeNames.contains(tName)) {
// cyclic reference
currentNodeNames.add(tName);
findElementReference(context, (XSElementDeclaration) term);
}
else {
currentNodeNames.add(tName);
findElementReference(context, (XSElementDeclaration) term);
findElementReference(context, (XSElementDeclaration) term);
}
else { // XSWildcard
String termName = term.getName();
if (termName != null) {
addToSchemaMap(context, termName);
if (!(currentNodeNames.contains(termName))) {
currentNodeNames.add(termName);
}
} else {
addToSchemaMap(context, "XSWildcard");
}
}
// else { // XSWildcard
// String tName = term.getName();
// if (tName != null) {
// addToSchemaTable(aContext, tName);
// }
// }
}
}

0 comments on commit 5acc658

Please sign in to comment.
You can’t perform that action at this time.