📄 jawetypes.java
字号:
l, controller, properties); extAttribTypes.put("Participant", l); // Tool EAs l = new ArrayList(); loadTypes(ExtendedAttribute.class, "ExtendedAttributeType.Tool", l, controller, properties); extAttribTypes.put("Tool", l); // Transition EAs l = new ArrayList(); loadTypes(ExtendedAttribute.class, "ExtendedAttributeType.Transition", l, controller, properties); extAttribTypes.put("Transition", l); // TypeDeclaration EAs l = new ArrayList(); loadTypes(ExtendedAttribute.class, "ExtendedAttributeType.TypeDeclaration", l, controller, properties); extAttribTypes.put("TypeDeclaration", l); // WorkflowProcess EAs l = new ArrayList(); loadTypes(ExtendedAttribute.class, "ExtendedAttributeType.WorkflowProcess", l, controller, properties); extAttribTypes.put("WorkflowProcess", l); loadTypes(ExternalPackage.class, "ExternalPackageType", externalPackageTypes, controller, properties); loadTypes(FormalParameter.class, "FormalParameterType", formalParameterTypes, controller, properties); loadTypes(Member.class, "MemberType", memberTypes, controller, properties); loadTypes(Namespace.class, "NamespaceType", namespaceTypes, controller, properties); loadTypes(Package.class, "PackageType", packageTypes, controller, properties); loadTypes(Participant.class, "ParticipantType", participantTypes, controller, properties); loadTypes(Responsible.class, "ResponsibleType", responsibleTypes, controller, properties); loadTypes(Tool.class, "ToolType", toolTypes, controller, properties); loadTypes(Transitions.class, "TransitionType", transitionTypes, controller, properties); loadTypes(TypeDeclaration.class, "TypeDeclarationType", typeDeclarationTypes, controller, properties); loadTypes(WorkflowProcess.class, "WorkflowProcessType", workflowProcessTypes, controller, properties); loadCollections(properties, controller); } protected Document parseDocument(String toParse, boolean isFile) { Document doc = null; // Create a Xerces DOM Parser DOMParser parser = new DOMParser(); // Parse the Document and traverse the DOM try { parser.setFeature("http://apache.org/xml/features/continue-after-fatal-error", true); if (isFile) { // System.err.println("Parsing from file"); File f = new File(toParse); if (!f.isAbsolute()) { toParse = getCurrentConfigFolder() + "/" + toParse; f = new File(toParse); } if (!f.exists()) { return null; } parser.parse(new InputSource(new FileInputStream(f))); } else { // System.err.println("Parsing from stream"); parser.parse(new InputSource(new StringReader(toParse))); } doc = parser.getDocument(); } catch (Exception ex) { ex.printStackTrace(); System.err.println("Fatal error while parsing document"); doc = null; } return doc; } protected XMLElement createTemplateElement(Document doc) throws Exception { Element elem = doc.getDocumentElement(); String elName = elem.getNodeName(); elName = "org.enhydra.shark.xpdl.elements." + elName; XMLElement el = null; if (!elName.endsWith("Package")) { el = (XMLElement) Class.forName(elName).getConstructors()[0].newInstance(new Object[] { null }); } else { el = new Package(); } if (el instanceof XMLComplexElement) { JaWEManager.getInstance() .getXPDLHandler() .getXPDLRepositoryHandler() .fromXML(doc.getDocumentElement(), (XMLComplexElement) el); } else if (el instanceof XMLSimpleElement) { JaWEManager.getInstance() .getXPDLHandler() .getXPDLRepositoryHandler() .fromXML(doc.getDocumentElement(), (XMLSimpleElement) el); } return el; } protected void toString(XMLElement el) { if (el instanceof Activity) { Activity act = (Activity) el; String str = "\n\tId=" + act.getId(); str += "\n\tName=" + act.getName(); str += "\n\tType=" + act.getActivityType(); Tools ts = act.getActivityTypes() .getImplementation() .getImplementationTypes() .getTools(); if (ts.size() > 0) { Tool t = (Tool) ts.get(0); str += "\n\tToolId=" + t.getId(); Iterator it = t.getActualParameters().toElements().iterator(); int i = 1; while (it.hasNext()) { ActualParameter ap = (ActualParameter) it.next(); str += "\n\t Ap" + (i++) + "=" + ap.toValue(); } } System.err.println("Activity data for " + act + " is:" + str); } else { if (el instanceof XMLSimpleElement) { System.err.println("\n\tElement type=" + el.toName()); } else if (el instanceof XMLComplexElement) { List attributes = ((XMLComplexElement) el).getXMLAttributes(); String str = "\n\tElement type=" + el.toName(); for (int i = 0; i < attributes.size(); i++) { XMLAttribute attr = (XMLAttribute) attributes.get(i); str += "\n\t " + i + ". attribute [" + attr.toName() + "," + attr.toValue() + "]"; } List elems = ((XMLComplexElement) el).getXMLElements(); for (int i = 0; i < elems.size(); i++) { XMLElement attr = (XMLElement) elems.get(i); if (attr instanceof XMLSimpleElement) { str += "\n\t " + i + ". simple el [" + attr.toName() + "," + attr.toValue() + "]"; } else { toString(attr); } } System.err.println(str); } else if (el instanceof XMLCollection) { String str = "\n\tElement type=" + el.toName(); List elems = ((XMLCollection) el).toElements(); for (int i = 0; i < elems.size(); i++) { XMLElement attr = (XMLElement) elems.get(i); if (attr instanceof XMLAttribute) { str += "\n\t " + i + ". attribute [" + attr.toName() + "," + attr.toValue() + "]"; } if (attr instanceof XMLSimpleElement) { str += "\n\t " + i + ". simple el [" + attr.toName() + "," + attr.toValue() + "]"; } else { toString(attr); } } System.err.println(str); } } } protected String getCurrentConfigFolder() { String currentConfig = JaWEConstants.JAWE_USER_HOME + "/templates"; String cch = System.getProperty(JaWEConstants.JAWE_CURRENT_CONFIG_HOME); if (cch != null) { currentConfig = cch + "/templates"; } return currentConfig; } public JaWEType compareToTemplate(XMLElement el) { String type = JaWEEAHandler.getJaWEType(el); if (type != null) { JaWEType jt = getType(type); if (jt != null) { if (!fullTemplateCheckForNonStandardTypes || compareToTemplate(el, el, getTemplateElement(type))) { return jt; } } } return null; } protected boolean compareToTemplate(XMLElement topEl, XMLElement el, XMLElement tmplEl) { // System.err.println("BTR - Checking el "+el+" with tmpl el "+tmplEl); boolean ret = true; System.out.println("Checking against template"); if (tmplEl.getClass() == el.getClass()) { if (el instanceof XMLSimpleElement && !tmplEl.isEmpty()) { ret = el.toValue().equals(tmplEl.toValue()); } else if (el instanceof XMLAttribute) { boolean checkIt = true; if ((el.toName().equals("Id") || el.toName().equals("Name")) && el.getParent() == topEl && !(el instanceof ExtendedAttribute)) { checkIt = false; } else if (el.toName().equals("Value")) { checkIt = false; } if (checkIt) { XMLAttribute attrEl = (XMLAttribute) el; XMLAttribute attrTmplEl = (XMLAttribute) tmplEl; ret = (attrEl.getChoices() == null ? attrTmplEl.getChoices() == null : attrEl.getChoices() .equals(attrTmplEl.getChoices())); if (ret && !tmplEl.isEmpty()) { ret = el.toValue().equals(tmplEl.toValue()); } } // System.err.println("SE OR XMLA: ret="+ret); } else if (el instanceof XMLComplexElement) { if (!tmplEl.toValue().equals("") && !tmplEl.toValue().equals(el.toValue())) { ret = false; // System.err.println("CMPLXEL: different values"); } else { XMLComplexElement cmplxEl = (XMLComplexElement) el; Iterator it = ((XMLComplexElement) tmplEl).toElementMap() .entrySet() .iterator(); while (it.hasNext()) { Map.Entry me = (Map.Entry) it.next(); String subElName = (String) me.getKey(); XMLElement subEl = (XMLElement) me.getValue(); if (!subEl.isEmpty()) { if (!compareToTemplate(topEl, cmplxEl.get(subElName), subEl)) { ret = false; // System.err.println("CMPLXEL: different values for subEl // "+subEl); break; } } } } } else if (el instanceof XMLCollection) { if (!tmplEl.toValue().equals("") && !tmplEl.toValue().equals(el.toValue())) { ret = false; // System.err.println("COLL: different values"); } else { XMLCollection col = (XMLCollection) el; List cels = ((XMLCollection) tmplEl).toElements(); for (int i = 0; i < cels.size(); i++) { XMLElement tcel = (XMLElement) cels.get(i); if (tcel instanceof ActualParameter || tcel instanceof FormalParameter) { if (!compareToTemplate(topEl, col.get(i), tcel)) { ret = false; // System.err.println("COLL: can't find col el "+cel+", // val="+cel.toValue()+" in col at place "+i); break; } } else { boolean btt = false; for (int j = 0; j < col.size(); j++) { XMLElement e = (XMLElement) col.get(j); if (compareToTemplate(topEl, e, tcel)) { btt = true; break; } } if (!btt) { ret = btt; } } } } } else if (el instanceof XMLComplexChoice) { XMLElement tmplChsn = ((XMLComplexChoice) tmplEl).getChoosen(); XMLElement elChsn = ((XMLComplexChoice) el).getChoosen(); ret = compareToTemplate(topEl, elChsn, tmplChsn); // System.err.println("CMPLCHC: ret="+ret); } } else { ret = false; // System.err.println("Different Java classes"); } // System.err.println("Final ret="+ret); return ret; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -