use of org.apache.ws.commons.schema.XmlSchemaType in project tdi-studio-se by Talend.
the class AllTypeDialog method buileParameterFromTypes.
private void buileParameterFromTypes(String paraType, ParameterInfo parameter) {
for (int i = 0; i < allXmlSchemaType.size(); i++) {
XmlSchemaType type = allXmlSchemaType.get(i);
String typeName = type.getName();
if (paraType.equals(typeName)) {
if (type instanceof XmlSchemaComplexType) {
XmlSchemaComplexType xmlSchemaComplexType = (XmlSchemaComplexType) type;
XmlSchemaParticle xmlSchemaParticle = xmlSchemaComplexType.getParticle();
XmlSchemaObjectCollection xmlSchemaObjectCollection = null;
if (xmlSchemaParticle == null && xmlSchemaComplexType.getContentModel() != null) {
Object obj = xmlSchemaComplexType.getContentModel().getContent();
if (obj instanceof XmlSchemaComplexContentExtension) {
XmlSchemaComplexContentExtension xscce = (XmlSchemaComplexContentExtension) obj;
if (xscce.getBaseTypeName() != null) {
buileParameterFromTypes(xscce.getBaseTypeName().getLocalPart(), parameter);
}
if (xscce != null) {
xmlSchemaParticle = xscce.getParticle();
}
if (xmlSchemaParticle instanceof XmlSchemaGroupBase) {
XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase) xmlSchemaParticle;
xmlSchemaObjectCollection = xmlSchemaGroupBase.getItems();
}
} else if (obj instanceof XmlSchemaComplexContentRestriction) {
XmlSchemaComplexContentRestriction xsccr = (XmlSchemaComplexContentRestriction) obj;
xmlSchemaObjectCollection = xsccr.getAttributes();
}
} else if (xmlSchemaParticle instanceof XmlSchemaGroupBase) {
XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase) xmlSchemaParticle;
xmlSchemaObjectCollection = xmlSchemaGroupBase.getItems();
}
if (xmlSchemaObjectCollection != null && xmlSchemaObjectCollection.getCount() > 0) {
buildParameterFromCollection(xmlSchemaObjectCollection, parameter);
}
} else if (type instanceof XmlSchemaSimpleType) {
}
break;
}
}
}
use of org.apache.ws.commons.schema.XmlSchemaType in project tdi-studio-se by Talend.
the class ComponentBuilderTest method testBuildParameterFromTypes.
@Test
public void testBuildParameterFromTypes() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, NoSuchMethodException, InvocationTargetException, WSDLException {
ParameterInfo parameter = new ParameterInfo();
String name = "parameter";
String nameSpace = "http://parameter";
parameter.setName(name);
parameter.setNameSpace(nameSpace);
ComponentBuilder cb = new ComponentBuilder();
Field field = cb.getClass().getDeclaredField("allXmlSchemaType");
field.setAccessible(true);
List<XmlSchemaType> allXmlSchemaType = (List<XmlSchemaType>) field.get(cb);
XmlSchema first = new XmlSchema();
first.setId("first");
XmlSchemaSimpleType xsst = new XmlSchemaSimpleType(first);
xsst.setId("first");
xsst.setName("first");
xsst.setSourceURI("http://first");
XmlSchema two = new XmlSchema();
two.setId("two");
two.setTargetNamespace(nameSpace);
String nameSpaceTwo = "http://parameter";
XmlSchemaComplexType xsc = new XmlSchemaComplexType(two);
XmlSchemaSequence xmlSchemaSequence = new XmlSchemaSequence();
xmlSchemaSequence.setId("sequence");
XmlSchemaElement xmlSchemaElement = new XmlSchemaElement();
xmlSchemaElement.setSourceURI(nameSpaceTwo);
xmlSchemaElement.setQName(new QName(nameSpaceTwo, "parameter"));
xmlSchemaElement.setName(name);
xmlSchemaSequence.getItems().add(xmlSchemaElement);
xsc.setParticle(xmlSchemaSequence);
xsc.setId("two");
xsc.setName("parameter");
XmlSchemaComplexContent contentModel = new XmlSchemaComplexContent();
XmlSchemaComplexContentExtension xmlSchemaContent = new XmlSchemaComplexContentExtension();
xmlSchemaContent.setId("two");
xmlSchemaContent.setBaseTypeName(new QName(nameSpace, "two"));
xmlSchemaContent.setSourceURI(nameSpaceTwo);
contentModel.setSourceURI(nameSpace);
contentModel.setContent(xmlSchemaContent);
xsc.setContentModel(contentModel);
allXmlSchemaType.add(xsst);
allXmlSchemaType.add(xsc);
Method m = cb.getClass().getDeclaredMethod("buileParameterFromTypes", new Class[] { String.class, String.class, ParameterInfo.class, int.class });
m.setAccessible(true);
m.invoke(cb, nameSpace, name, parameter, 5);
ParameterInfo parameterInfo = parameter.getParameterInfos().get(0);
Assert.assertNotNull(parameterInfo);
Assert.assertEquals(nameSpace, parameterInfo.getNameSpace());
}
use of org.apache.ws.commons.schema.XmlSchemaType in project tdi-studio-se by Talend.
the class AllTypeDialog method initComplexType.
private void initComplexType() {
for (XmlSchemaType xmlSchemaType : allXmlSchemaType) {
if (xmlSchemaType instanceof XmlSchemaComplexType) {
XmlSchemaComplexType complexType = (XmlSchemaComplexType) xmlSchemaType;
String label = COMPLEXTYPE + complexType.getName();
labelAndNameSpaceMap.put(label, complexType.getQName().toString());
}
}
}
use of org.apache.ws.commons.schema.XmlSchemaType in project tdi-studio-se by Talend.
the class AllTypeDialog method initSimpleType.
private void initSimpleType() throws WSDLException, URISyntaxException {
String url = URLValue;
XmlSchemaCollection schemaCollection = new XmlSchemaCollection();
WSDLFactory wsdlFactory = WSDLFactory.newInstance();
WSDLReader newWSDLReader = wsdlFactory.newWSDLReader();
newWSDLReader.setFeature(com.ibm.wsdl.Constants.FEATURE_VERBOSE, false);
URI wsdlURI = new URI(url);
Definition definition = newWSDLReader.readWSDL(url);
java.util.List<ExtensibilityElement> extensibilityElements = definition.getTypes().getExtensibilityElements();
String tmpTNName = "";
int tmpCount = 0;
for (ExtensibilityElement el : extensibilityElements) {
if (el instanceof Schema) {
Schema schema = (Schema) el;
// for bug 8674
// set base uri for relative path in schemaLocation.
schemaCollection.setBaseUri(schema.getDocumentBaseURI());
if (schema.getElement().getAttributeNode("targetNamespace") == null) {
tmpTNName = schema.getDocumentBaseURI() + "#type" + tmpCount;
schemaCollection.read(schema.getElement(), tmpTNName);
tmpCount++;
} else {
schemaCollection.read(schema.getElement());
}
}
}
Map namespaces = definition.getNamespaces();
// System.out.println(namespaces);
XmlSchema[] schemas = schemaCollection.getXmlSchemas();
java.util.List<String> labelList = new ArrayList<String>();
for (int i = 0; i < schemas.length; i++) {
XmlSchema schema = schemas[i];
XmlSchemaObjectTable types = schema.getSchemaTypes();
Iterator it = types.getValues();
while (it.hasNext()) {
XmlSchemaType type = (XmlSchemaType) it.next();
if (type instanceof XmlSchemaSimpleType) {
XmlSchemaSimpleType t = (XmlSchemaSimpleType) type;
String label = "simpletype:" + t.getName();
if (!labelList.contains(label)) {
labelList.add(label);
labelAndNameSpaceMap.put(label, t.getQName().toString());
}
}
}
}
allXMLSimpleTypeName = new String[labelList.size()];
for (int i = 0; i < labelList.size(); i++) {
allXMLSimpleTypeName[i] = labelList.get(i);
}
}
use of org.apache.ws.commons.schema.XmlSchemaType in project ddf by codice.
the class FeatureMetacardType method processXmlSchema.
private void processXmlSchema(XmlSchema schema) {
Map<QName, XmlSchemaElement> elements = schema.getElements();
Iterator<XmlSchemaElement> xmlSchemaElementIterator = elements.values().iterator();
while (xmlSchemaElementIterator.hasNext()) {
Object o = xmlSchemaElementIterator.next();
XmlSchemaElement element = (XmlSchemaElement) o;
XmlSchemaType schemaType = element.getSchemaType();
if (schemaType instanceof XmlSchemaComplexType) {
processComplexType(element);
} else if (schemaType instanceof XmlSchemaSimpleType) {
processSimpleType(element);
}
}
}
Aggregations