/** * @return the enumeration which restricts the content of this complex type or an empty list in * case the content is not restricted by an enumeration. */ public Collection<String> getEnumerations() { Collection<String> enumerations = new ArrayList<String>(); for (XSFacet declaredFacet : simpleType.getDeclaredFacets()) { if (declaredFacet.getName().equals(DATATYPE_ENUMERATION)) { enumerations.add(declaredFacet.getValue().value); } } return enumerations; }
/** Creates the ExecutableTask from the Schema tree. */ private void createResult(XSSchema schema) { execTask = new ExecutableTask(); // Get the "task" xs:element. XSElementDecl task = schema.getElementDecl("task"); // We know it's an xs:complexType. XSComplexType taskType = task.getType().asComplexType(); // Get the xs:sequence of elements of the anonymous xs:complexType. // A model group can be xs:all, xs:choice or xs:sequence. XSParticle taskParticle = taskType.getContentType().asParticle(); XSModelGroup taskSequence = taskParticle.getTerm().asModelGroup(); // Get the direct children in the xs:sequence. XSParticle taskElemParticles[] = taskSequence.getChildren(); for (XSParticle taskElemParticle : taskElemParticles) { XSElementDecl taskElem = taskElemParticle.getTerm().asElementDecl(); if (taskElem.getName().equals("execInfo")) { // Displayable info for the UI. // We have the "execInfo" element. ExecutableInfo execInfo = new ExecutableInfo(); // We know it's an xs:complexType. XSComplexType infoType = taskElem.getType().asComplexType(); XSParticle infoParticle = infoType.getContentType().asParticle(); XSModelGroup infoSequence = infoParticle.getTerm().asModelGroup(); XSParticle infoElemParticles[] = infoSequence.getChildren(); for (XSParticle infoElemParticle : infoElemParticles) { XSElementDecl infoElem = infoElemParticle.getTerm().asElementDecl(); XSSimpleType simpleType = infoElem.getType().asSimpleType(); XSRestrictionSimpleType restrictionSimple = simpleType.asRestriction(); XSFacet facet = restrictionSimple.getDeclaredFacets().iterator().next(); switch (infoElem.getName()) { case "name": execInfo.setExecName(facet.getValue().toString()); break; case "type": execInfo.setExecType(facet.getValue().toString()); break; case "description": execInfo.setExecDescription(facet.getValue().toString()); break; } } execTask.setExecInfo(execInfo); } else { XSType taskElemType = taskElem.getType(); if (taskElemType.isSimpleType()) { // We do not check constraints. They will be validated later. ExecutableParameter param = new ExecutableParameter(); param.setParamName(taskElem.getName()); execTask.addParameter(param); } else if (taskElemType.isComplexType()) { // Refers to inputFile and outputFile. // No need to check these since they are always the same. } } } }