use of org.apache.ws.commons.schema.XmlSchemaSimpleType in project ddf by codice.
the class FeatureMetacardTypeTest method testfeatureMetacardTypeFindFloatProperties.
@Test
public void testfeatureMetacardTypeFindFloatProperties() {
XmlSchema schema = new XmlSchema();
XmlSchemaElement floatElement = new XmlSchemaElement(schema, true);
floatElement.setSchemaType(new XmlSchemaSimpleType(schema, false));
floatElement.setSchemaTypeName(Constants.XSD_FLOAT);
floatElement.setName(ELEMENT_NAME_1);
schema.getElements().put(new QName(ELEMENT_NAME_1), floatElement);
FeatureMetacardType featureMetacardType = new FeatureMetacardType(schema, FEATURE_TYPE, NON_QUERYABLE_PROPS, Wfs10Constants.GML_NAMESPACE);
assertAttributeDescriptor(featureMetacardType, ELEMENT_NAME_1, BasicTypes.FLOAT_TYPE);
}
use of org.apache.ws.commons.schema.XmlSchemaSimpleType in project ddf by codice.
the class FeatureMetacardType method processXmlSchemaParticle.
private void processXmlSchemaParticle(XmlSchemaParticle particle) {
XmlSchemaSequence schemaSequence;
if (particle instanceof XmlSchemaSequence) {
schemaSequence = (XmlSchemaSequence) particle;
List<XmlSchemaSequenceMember> schemaObjectCollection = schemaSequence.getItems();
Iterator<XmlSchemaSequenceMember> iterator = schemaObjectCollection.iterator();
while (iterator.hasNext()) {
Object element = iterator.next();
if (element instanceof XmlSchemaElement) {
XmlSchemaElement innerElement = ((XmlSchemaElement) element);
XmlSchemaType innerEleType = innerElement.getSchemaType();
if (innerEleType instanceof XmlSchemaComplexType) {
processComplexType(innerElement);
} else if (innerEleType instanceof XmlSchemaSimpleType) {
processSimpleType(innerElement);
} else if (innerEleType == null) {
// Check if this is the GML location Property
processGmlType(innerElement);
}
}
}
}
}
use of org.apache.ws.commons.schema.XmlSchemaSimpleType in project ddf by codice.
the class TestGenericFeatureConverter method buildSchemaElement.
private XmlSchemaElement buildSchemaElement(String elementName, XmlSchema schema, QName typeName) {
XmlSchemaElement element = new XmlSchemaElement(schema, true);
element.setSchemaType(new XmlSchemaSimpleType(schema, false));
element.setSchemaTypeName(typeName);
element.setName(elementName);
return element;
}
use of org.apache.ws.commons.schema.XmlSchemaSimpleType 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.XmlSchemaSimpleType in project tdi-studio-se by Talend.
the class AllTypeDialog method buildParameterFromCollection.
private void buildParameterFromCollection(XmlSchemaObjectCollection xmlSchemaObjectCollection, ParameterInfo parameter) {
// XmlSchemaSequence xmlSchemaSequence = (XmlSchemaSequence) xmlSchemaParticle;
// XmlSchemaObjectCollection xmlSchemaObjectCollection = xmlSchemaSequence.getItems();
int count = xmlSchemaObjectCollection.getCount();
for (int j = 0; j < count; j++) {
XmlSchemaObject xmlSchemaObject = xmlSchemaObjectCollection.getItem(j);
if (xmlSchemaObject instanceof XmlSchemaGroupBase) {
XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase) xmlSchemaObject;
XmlSchemaObjectCollection items = xmlSchemaGroupBase.getItems();
if (items != null) {
buildParameterFromCollection(items, parameter);
}
} else if (xmlSchemaObject instanceof XmlSchemaAny) {
ParameterInfo parameterSon = new ParameterInfo();
parameterSon.setName("_content_");
parameterSon.setParent(parameter);
parameter.getParameterInfos().add(parameterSon);
} else if (xmlSchemaObject instanceof XmlSchemaElement) {
XmlSchemaElement xmlSchemaElement = (XmlSchemaElement) xmlSchemaObject;
String elementName = xmlSchemaElement.getName();
ParameterInfo parameterSon = new ParameterInfo();
parameterSon.setName(elementName);
parameterSon.setParent(parameter);
Long min = xmlSchemaElement.getMinOccurs();
Long max = xmlSchemaElement.getMaxOccurs();
if (max - min > 1) {
parameterSon.setArraySize(-1);
parameterSon.setIndex("*");
}
parameter.getParameterInfos().add(parameterSon);
if (xmlSchemaElement.getSchemaTypeName() != null) {
String elementTypeName = xmlSchemaElement.getSchemaTypeName().getLocalPart();
if (elementTypeName != null && elementTypeName.equals("anyType")) {
parameterSon.setName(xmlSchemaElement.getName() + ":anyType");
}
parameterSon.setType(elementTypeName);
if (!WsdlTypeUtil.isJavaBasicType(elementTypeName)) {
buileParameterFromTypes(elementTypeName, parameterSon);
}
} else if (xmlSchemaElement.getSchemaType() != null) {
if (xmlSchemaElement.getSchemaType() instanceof XmlSchemaComplexType) {
XmlSchemaComplexType xmlElementComplexType = (XmlSchemaComplexType) xmlSchemaElement.getSchemaType();
XmlSchemaParticle xmlSchemaParticle = xmlElementComplexType.getParticle();
if (xmlSchemaParticle instanceof XmlSchemaGroupBase) {
XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase) xmlSchemaParticle;
XmlSchemaObjectCollection childCollection = xmlSchemaGroupBase.getItems();
if (childCollection != null) {
buildParameterFromCollection(childCollection, parameterSon);
}
} else if (xmlSchemaElement.getSchemaTypeName() != null) {
String paraTypeName = xmlSchemaElement.getSchemaTypeName().getLocalPart();
if (paraTypeName != null) {
parameter.setType(paraTypeName);
buileParameterFromTypes(paraTypeName, parameterSon);
}
}
} else if (xmlSchemaElement.getSchemaType() instanceof XmlSchemaSimpleType) {
XmlSchemaSimpleType xmlSchemaSimpleType = (XmlSchemaSimpleType) xmlSchemaElement.getSchemaType();
String typeName = xmlSchemaSimpleType.getName();
if (typeName != null && typeName.equals("anyType")) {
ParameterInfo pSon = new ParameterInfo();
pSon.setName(xmlSchemaElement.getName() + "(anyType)");
pSon.setParent(parameter);
parameter.getParameterInfos().add(pSon);
}
parameter.setType(typeName);
}
} else if (xmlSchemaElement.getRefName() != null) {
String elementTypeName = xmlSchemaElement.getRefName().getLocalPart();
if (!WsdlTypeUtil.isJavaBasicType(elementTypeName)) {
buildParameterFromElements(elementTypeName, parameterSon);
}
}
} else if (xmlSchemaObject instanceof XmlSchemaAttribute) {
XmlSchemaAttribute xmlSchemaAttribute = (XmlSchemaAttribute) xmlSchemaObject;
String elementName = xmlSchemaAttribute.getName();
ParameterInfo parameterSon = new ParameterInfo();
parameterSon.setName(elementName);
parameterSon.setParent(parameter);
parameter.getParameterInfos().add(parameterSon);
if (xmlSchemaAttribute.getSchemaTypeName() != null) {
String elementTypeName = xmlSchemaAttribute.getSchemaTypeName().getLocalPart();
parameterSon.setType(elementTypeName);
if (!WsdlTypeUtil.isJavaBasicType(elementTypeName)) {
buileParameterFromTypes(elementTypeName, parameterSon);
}
} else if (xmlSchemaAttribute.getRefName() != null) {
String refName = xmlSchemaAttribute.getRefName().getLocalPart();
parameterSon.setType(refName);
}
}
}
}
Aggregations