Search in sources :

Example 61 with XmlSchemaComplexType

use of org.apache.ws.commons.schema.XmlSchemaComplexType in project convertigo by convertigo.

the class ReadXMLStep method getXmlSchemaObject.

@Override
public XmlSchemaElement getXmlSchemaObject(XmlSchemaCollection collection, XmlSchema schema) {
    XmlSchemaElement element = (XmlSchemaElement) super.getXmlSchemaObject(collection, schema);
    File file = getFile();
    if (file != null && file.exists() && file.length() <= 10000000) {
        try {
            Document doc = XMLUtils.parseDOM(file);
            if (!hasXmlRoot(doc)) {
                Element xmlRoot = doc.getDocumentElement();
                Element newRoot = doc.createElement("document");
                doc.replaceChild(newRoot, xmlRoot);
                newRoot.appendChild(xmlRoot);
            }
            XmlSchemaElement elt = XmlSchemaUtils.extractXmlSchemaElement(doc, schema, this);
            if (element != null) {
                XmlSchemaComplexType cType = XmlSchemaUtils.makeDynamic(this, new XmlSchemaComplexType(schema));
                element.setType(cType);
                XmlSchemaSequence sequence = XmlSchemaUtils.makeDynamic(this, new XmlSchemaSequence());
                cType.setParticle(sequence);
                sequence.getItems().add(elt);
            } else {
                element = elt;
            }
        } catch (Exception e) {
            Engine.logBeans.info("Failed to load the xml file " + file.getAbsolutePath(), e);
        }
    }
    if (element == null) {
        element = (XmlSchemaElement) super.getXmlSchemaObject(collection, schema);
    }
    return element;
}
Also used : XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) Element(org.w3c.dom.Element) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) Document(org.w3c.dom.Document) File(java.io.File) EngineException(com.twinsoft.convertigo.engine.EngineException)

Example 62 with XmlSchemaComplexType

use of org.apache.ws.commons.schema.XmlSchemaComplexType in project convertigo by convertigo.

the class SchemaViewLabelDecorator method decorateText.

public String decorateText(String text, Object element) {
    String decoratedText = text;
    if (element != null) {
        if (element instanceof XmlSchemaObject) {
            XmlSchemaObject xso = (XmlSchemaObject) element;
            XmlSchemaType type = null;
            String value = null;
            if (element instanceof XmlSchemaElement) {
                type = SchemaMeta.getType(xso, ((XmlSchemaElement) element).getSchemaTypeName());
            } else if (element instanceof XmlSchemaAttribute) {
                XmlSchemaAttribute attr = (XmlSchemaAttribute) element;
                type = SchemaMeta.getType(xso, attr.getSchemaTypeName());
                value = attr.getDefaultValue();
                value = value == null ? attr.getFixedValue() : "default:" + value;
            } else if (element instanceof XmlSchemaSimpleContentExtension) {
                type = SchemaMeta.getType(xso, ((XmlSchemaSimpleContentExtension) element).getBaseTypeName());
            } else if (element instanceof XmlSchemaSimpleTypeRestriction) {
                type = SchemaMeta.getType(xso, ((XmlSchemaSimpleTypeRestriction) element).getBaseTypeName());
            } else if (element instanceof XmlSchemaEnumerationFacet) {
                XmlSchemaEnumerationFacet enumerationFacet = (XmlSchemaEnumerationFacet) element;
                decoratedText += " [" + enumerationFacet.getValue() + "]";
            }
            if (value != null) {
                decoratedText += " {" + value + "}";
            }
            if (type != null && type instanceof XmlSchemaSimpleType) {
                decoratedText += " [" + SchemaMeta.getPrefix(type) + ":" + type.getName() + "]";
            }
            int size = SchemaMeta.getReferencedDatabaseObjects(xso).size();
            if (size > 1 || size >= 0 && element instanceof XmlSchemaComplexType && ((XmlSchemaComplexType) element).getName() != null) {
                decoratedText += " (" + size + ")";
            }
            String prefix = SchemaMeta.getPrefix(xso);
            if (prefix != null) {
                decoratedText = prefix + ":" + decoratedText;
            }
        }
    }
    return decoratedText;
}
Also used : XmlSchemaSimpleContentExtension(org.apache.ws.commons.schema.XmlSchemaSimpleContentExtension) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) XmlSchemaSimpleTypeRestriction(org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaAttribute(org.apache.ws.commons.schema.XmlSchemaAttribute) XmlSchemaEnumerationFacet(org.apache.ws.commons.schema.XmlSchemaEnumerationFacet) Point(org.eclipse.swt.graphics.Point)

Example 63 with XmlSchemaComplexType

use of org.apache.ws.commons.schema.XmlSchemaComplexType in project convertigo by convertigo.

the class LDAPAuthenticationStep method getXmlSchemaObject.

@Override
public XmlSchemaElement getXmlSchemaObject(XmlSchemaCollection collection, XmlSchema schema) {
    XmlSchemaElement element = (XmlSchemaElement) super.getXmlSchemaObject(collection, schema);
    XmlSchemaComplexType cType = XmlSchemaUtils.makeDynamic(this, new XmlSchemaComplexType(schema));
    element.setType(cType);
    XmlSchemaSequence sequence = XmlSchemaUtils.makeDynamic(this, new XmlSchemaSequence());
    cType.setParticle(sequence);
    XmlSchemaElement subElement = XmlSchemaUtils.makeDynamic(this, new XmlSchemaElement());
    sequence.getItems().add(subElement);
    subElement.setName("rdn");
    subElement.setMinOccurs(0);
    subElement.setMaxOccurs(Long.MAX_VALUE);
    cType = XmlSchemaUtils.makeDynamic(this, new XmlSchemaComplexType(schema));
    subElement.setType(cType);
    XmlSchemaSimpleContent sContent = XmlSchemaUtils.makeDynamic(this, new XmlSchemaSimpleContent());
    cType.setContentModel(sContent);
    XmlSchemaSimpleContentExtension sContentExt = XmlSchemaUtils.makeDynamic(this, new XmlSchemaSimpleContentExtension());
    sContent.setContent(sContentExt);
    sContentExt.setBaseTypeName(Constants.XSD_STRING);
    XmlSchemaAttribute attr = XmlSchemaUtils.makeDynamic(this, new XmlSchemaAttribute());
    attr.setName("name");
    attr.setSchemaTypeName(Constants.XSD_STRING);
    sContentExt.getAttributes().add(attr);
    subElement = XmlSchemaUtils.makeDynamic(this, new XmlSchemaElement());
    sequence.getItems().add(subElement);
    subElement.setName("attribute");
    subElement.setMinOccurs(0);
    subElement.setMaxOccurs(Long.MAX_VALUE);
    cType = XmlSchemaUtils.makeDynamic(this, new XmlSchemaComplexType(schema));
    subElement.setType(cType);
    sContent = XmlSchemaUtils.makeDynamic(this, new XmlSchemaSimpleContent());
    cType.setContentModel(sContent);
    sContentExt = XmlSchemaUtils.makeDynamic(this, new XmlSchemaSimpleContentExtension());
    sContent.setContent(sContentExt);
    sContentExt.setBaseTypeName(Constants.XSD_STRING);
    attr = XmlSchemaUtils.makeDynamic(this, new XmlSchemaAttribute());
    attr.setName("name");
    attr.setSchemaTypeName(Constants.XSD_STRING);
    sContentExt.getAttributes().add(attr);
    subElement = XmlSchemaUtils.makeDynamic(this, new XmlSchemaElement());
    sequence.getItems().add(subElement);
    subElement.setName("userDn");
    subElement.setMinOccurs(0);
    subElement.setMaxOccurs(1);
    subElement.setSchemaTypeName(Constants.XSD_STRING);
    subElement = XmlSchemaUtils.makeDynamic(this, new XmlSchemaElement());
    sequence.getItems().add(subElement);
    subElement.setName("authenticatedUserID");
    subElement.setMinOccurs(0);
    subElement.setMaxOccurs(1);
    subElement.setSchemaTypeName(Constants.XSD_STRING);
    /*
		cType = XmlSchemaUtils.makeDynamic(this, new XmlSchemaComplexType(schema));
		subElement.setType(cType);
		
		attr = XmlSchemaUtils.makeDynamic(this, new XmlSchemaAttribute());
		attr.setName("name");
		attr.setSchemaTypeName(Constants.XSD_STRING);
		cType.getAttributes().add(attr);
		
		sequence = XmlSchemaUtils.makeDynamic(this, new XmlSchemaSequence());
		sequence.setMinOccurs(0);
		sequence.setMaxOccurs(Long.MAX_VALUE);
		cType.setParticle(sequence);
		
		subElement = XmlSchemaUtils.makeDynamic(this, new XmlSchemaElement());
		sequence.getItems().add(subElement);
		subElement.setName("value");
		subElement.setSchemaTypeName(Constants.XSD_STRING);
		*/
    return element;
}
Also used : XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) XmlSchemaSimpleContentExtension(org.apache.ws.commons.schema.XmlSchemaSimpleContentExtension) XmlSchemaSimpleContent(org.apache.ws.commons.schema.XmlSchemaSimpleContent) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) XmlSchemaAttribute(org.apache.ws.commons.schema.XmlSchemaAttribute)

Example 64 with XmlSchemaComplexType

use of org.apache.ws.commons.schema.XmlSchemaComplexType in project convertigo by convertigo.

the class ListDirStep method getXmlSchemaObject.

@Override
public XmlSchemaElement getXmlSchemaObject(XmlSchemaCollection collection, XmlSchema schema) {
    XmlSchemaElement element = (XmlSchemaElement) super.getXmlSchemaObject(collection, schema);
    XmlSchemaComplexType cType = XmlSchemaUtils.makeDynamic(this, new XmlSchemaComplexType(schema));
    element.setType(cType);
    XmlSchemaSequence sequence = XmlSchemaUtils.makeDynamic(this, new XmlSchemaSequence());
    cType.setParticle(sequence);
    XmlSchemaElement elt = XmlSchemaUtils.makeDynamic(this, new XmlSchemaElement());
    sequence.getItems().add(elt);
    elt.setName("file");
    elt.setMinOccurs(0);
    elt.setMaxOccurs(Long.MAX_VALUE);
    cType = XmlSchemaUtils.makeDynamic(this, new XmlSchemaComplexType(schema));
    elt.setType(cType);
    XmlSchemaSimpleContent sContent = XmlSchemaUtils.makeDynamic(this, new XmlSchemaSimpleContent());
    cType.setContentModel(sContent);
    XmlSchemaSimpleContentExtension sContentExt = XmlSchemaUtils.makeDynamic(this, new XmlSchemaSimpleContentExtension());
    sContent.setContent(sContentExt);
    sContentExt.setBaseTypeName(Constants.XSD_STRING);
    XmlSchemaAttribute attr = XmlSchemaUtils.makeDynamic(this, new XmlSchemaAttribute());
    attr.setName("lastModified");
    attr.setSchemaTypeName(Constants.XSD_NONNEGATIVEINTEGER);
    sContentExt.getAttributes().add(attr);
    attr = XmlSchemaUtils.makeDynamic(this, new XmlSchemaAttribute());
    attr.setName("size");
    attr.setSchemaTypeName(Constants.XSD_NONNEGATIVEINTEGER);
    sContentExt.getAttributes().add(attr);
    return element;
}
Also used : XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) XmlSchemaSimpleContentExtension(org.apache.ws.commons.schema.XmlSchemaSimpleContentExtension) XmlSchemaSimpleContent(org.apache.ws.commons.schema.XmlSchemaSimpleContent) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) XmlSchemaAttribute(org.apache.ws.commons.schema.XmlSchemaAttribute)

Example 65 with XmlSchemaComplexType

use of org.apache.ws.commons.schema.XmlSchemaComplexType in project convertigo by convertigo.

the class PushNotificationStep method getXmlSchemaObject.

@Override
public XmlSchemaElement getXmlSchemaObject(XmlSchemaCollection collection, XmlSchema schema) {
    XmlSchemaElement element = (XmlSchemaElement) super.getXmlSchemaObject(collection, schema);
    XmlSchemaComplexType cType = XmlSchemaUtils.makeDynamic(this, new XmlSchemaComplexType(schema));
    element.setType(cType);
    XmlSchemaSequence sequence = XmlSchemaUtils.makeDynamic(this, new XmlSchemaSequence());
    cType.setParticle(sequence);
    XmlSchemaElement errorMessage = XmlSchemaUtils.makeDynamic(this, new XmlSchemaElement());
    sequence.getItems().add(errorMessage);
    errorMessage.setName("errorMessage");
    errorMessage.setMinOccurs(0);
    errorMessage.setMaxOccurs(1);
    errorMessage.setSchemaTypeName(Constants.XSD_STRING);
    /**
     * create devices complextype tag
     */
    XmlSchemaElement devices = XmlSchemaUtils.makeDynamic(this, new XmlSchemaElement());
    sequence.getItems().add(devices);
    devices.setName("devices");
    devices.setMinOccurs(0);
    devices.setMaxOccurs(1);
    cType = XmlSchemaUtils.makeDynamic(this, new XmlSchemaComplexType(schema));
    devices.setType(cType);
    sequence = XmlSchemaUtils.makeDynamic(this, new XmlSchemaSequence());
    cType.setParticle(sequence);
    /**
     * create device simple type tag
     */
    XmlSchemaElement elt = XmlSchemaUtils.makeDynamic(this, new XmlSchemaElement());
    sequence.getItems().add(elt);
    elt.setName("device");
    elt.setMinOccurs(1);
    elt.setMaxOccurs(Long.MAX_VALUE);
    cType = XmlSchemaUtils.makeDynamic(this, new XmlSchemaComplexType(schema));
    elt.setType(cType);
    /**
     */
    XmlSchemaSimpleContent sContent = XmlSchemaUtils.makeDynamic(this, new XmlSchemaSimpleContent());
    cType.setContentModel(sContent);
    XmlSchemaSimpleContentExtension sContentExt = XmlSchemaUtils.makeDynamic(this, new XmlSchemaSimpleContentExtension());
    sContent.setContent(sContentExt);
    sContentExt.setBaseTypeName(Constants.XSD_STRING);
    /**
     * create all device attributes
     */
    XmlSchemaAttribute attr = XmlSchemaUtils.makeDynamic(this, new XmlSchemaAttribute());
    attr.setName("plugIn");
    attr.setSchemaTypeName(Constants.XSD_STRING);
    sContentExt.getAttributes().add(attr);
    attr = XmlSchemaUtils.makeDynamic(this, new XmlSchemaAttribute());
    attr.setName("regId");
    attr.setSchemaTypeName(Constants.XSD_STRING);
    sContentExt.getAttributes().add(attr);
    attr = XmlSchemaUtils.makeDynamic(this, new XmlSchemaAttribute());
    attr.setName("messageId");
    attr.setSchemaTypeName(Constants.XSD_STRING);
    sContentExt.getAttributes().add(attr);
    attr = XmlSchemaUtils.makeDynamic(this, new XmlSchemaAttribute());
    attr.setName("canonicalRegId");
    attr.setSchemaTypeName(Constants.XSD_STRING);
    sContentExt.getAttributes().add(attr);
    attr = XmlSchemaUtils.makeDynamic(this, new XmlSchemaAttribute());
    attr.setName("errorType");
    attr.setSchemaTypeName(Constants.XSD_STRING);
    sContentExt.getAttributes().add(attr);
    return element;
}
Also used : XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) XmlSchemaSimpleContentExtension(org.apache.ws.commons.schema.XmlSchemaSimpleContentExtension) XmlSchemaSimpleContent(org.apache.ws.commons.schema.XmlSchemaSimpleContent) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) XmlSchemaAttribute(org.apache.ws.commons.schema.XmlSchemaAttribute)

Aggregations

XmlSchemaComplexType (org.apache.ws.commons.schema.XmlSchemaComplexType)136 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)101 XmlSchemaSequence (org.apache.ws.commons.schema.XmlSchemaSequence)71 QName (javax.xml.namespace.QName)59 XmlSchemaSimpleType (org.apache.ws.commons.schema.XmlSchemaSimpleType)33 XmlSchema (org.apache.ws.commons.schema.XmlSchema)32 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)31 XmlSchemaAttribute (org.apache.ws.commons.schema.XmlSchemaAttribute)23 XmlSchemaObject (org.apache.ws.commons.schema.XmlSchemaObject)20 XmlSchemaObjectCollection (org.apache.ws.commons.schema.XmlSchemaObjectCollection)18 Test (org.junit.Test)18 XmlSchemaParticle (org.apache.ws.commons.schema.XmlSchemaParticle)16 XmlSchemaComplexContentExtension (org.apache.ws.commons.schema.XmlSchemaComplexContentExtension)15 ArrayList (java.util.ArrayList)13 XmlSchemaGroupBase (org.apache.ws.commons.schema.XmlSchemaGroupBase)12 XmlSchemaSequenceMember (org.apache.ws.commons.schema.XmlSchemaSequenceMember)12 XmlSchemaSimpleContentExtension (org.apache.ws.commons.schema.XmlSchemaSimpleContentExtension)12 XmlSchemaComplexContentRestriction (org.apache.ws.commons.schema.XmlSchemaComplexContentRestriction)8 FeatureMetacardType (org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType)8 ParameterInfo (org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo)8