use of org.apache.ws.commons.schema.XmlSchema in project tdi-studio-se by Talend.
the class ComponentBuilder method collectAllXmlSchemaType.
/**
* DOC gcui Comment method "collectAllXmlSchemaType".
*/
private void collectAllXmlSchemaType() {
for (int i = 0; i < wsdlTypes.size(); i++) {
XmlSchema xmlSchema = (wsdlTypes.elementAt(i));
if (xmlSchema == null) {
continue;
}
XmlSchemaObjectTable xmlSchemaObjectTable = xmlSchema.getSchemaTypes();
Iterator typesItr = xmlSchemaObjectTable.getValues();
while (typesItr.hasNext()) {
XmlSchemaType xmlSchemaType = (XmlSchemaType) typesItr.next();
allXmlSchemaType.add(xmlSchemaType);
}
}
}
use of org.apache.ws.commons.schema.XmlSchema 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.XmlSchema 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.XmlSchema in project ddf by codice.
the class WfsSource method buildFeatureFilters.
private void buildFeatureFilters(List<FeatureTypeType> featureTypes, FilterCapabilities filterCapabilities) throws SecurityServiceException {
Wfs wfs = factory.getClient();
if (filterCapabilities == null) {
return;
}
// Use local Map for metacardtype registrations and once they are populated with latest
// MetacardTypes, then do actual registration
Map<String, MetacardTypeRegistration> mcTypeRegs = new HashMap<String, MetacardTypeRegistration>();
this.featureTypeFilters.clear();
for (FeatureTypeType featureTypeType : featureTypes) {
String ftSimpleName = featureTypeType.getName().getLocalPart();
if (StringUtils.isNotBlank(forcedFeatureType) && !StringUtils.equals(forcedFeatureType, ftSimpleName)) {
continue;
}
if (mcTypeRegs.containsKey(ftSimpleName)) {
LOGGER.debug("WfsSource {}: MetacardType {} is already registered - skipping to next metacard type", getId(), ftSimpleName);
continue;
}
LOGGER.debug("ftName: {}", ftSimpleName);
try {
XmlSchema schema = wfs.describeFeatureType(new DescribeFeatureTypeRequest(featureTypeType.getName()));
if (schema == null) {
// Some WFS 2.0.0 DescribeFeatureRequests return inconsistent results when
// the `:` character is encoded in the URL, ie Prefix:SomeFeature is encoded to
// Prefix%3ASomeFeature. To avoid this issue, we will make a call without the prefix
// if the previous call does not work.
schema = wfs.describeFeatureType(new DescribeFeatureTypeRequest(new QName(featureTypeType.getName().getNamespaceURI(), featureTypeType.getName().getLocalPart(), "")));
}
if (schema != null) {
// Update local map with enough info to create actual MetacardType registrations
// later
MetacardTypeRegistration registration = createFeatureMetacardTypeRegistration(featureTypeType, ftSimpleName, schema);
mcTypeRegs.put(ftSimpleName, registration);
FeatureMetacardType featureMetacardType = registration.getFtMetacard();
lookupFeatureConverter(ftSimpleName, featureMetacardType);
MetacardMapper metacardAttributeToFeaturePropertyMapper = lookupMetacardAttributeToFeaturePropertyMapper(featureMetacardType.getFeatureType());
this.featureTypeFilters.put(featureMetacardType.getFeatureType(), new WfsFilterDelegate(featureMetacardType, filterCapabilities, registration.getSrs(), metacardAttributeToFeaturePropertyMapper, coordinateOrder));
}
} catch (WfsException | IllegalArgumentException wfse) {
LOGGER.debug(WFS_ERROR_MESSAGE, wfse);
} catch (WebApplicationException wae) {
LOGGER.debug(handleWebApplicationException(wae), wae);
}
}
registerFeatureMetacardTypes(mcTypeRegs);
if (featureTypeFilters.isEmpty()) {
LOGGER.debug("Wfs Source {}: No Feature Type schemas validated.", getId());
}
LOGGER.debug("Wfs Source {}: Number of validated Features = {}", getId(), featureTypeFilters.size());
updateSupportedSpatialOperators(filterCapabilities.getSpatialCapabilities().getSpatialOperators());
}
use of org.apache.ws.commons.schema.XmlSchema in project ddf by codice.
the class FeatureMetacardTypeTest method testfeatureMetacardTypeFindDateProperties.
@Test
public void testfeatureMetacardTypeFindDateProperties() {
XmlSchema schema = new XmlSchema();
XmlSchemaElement dateElement = new XmlSchemaElement(schema, true);
dateElement.setSchemaType(new XmlSchemaSimpleType(schema, false));
dateElement.setSchemaTypeName(Constants.XSD_DATE);
dateElement.setName(ELEMENT_NAME_1);
XmlSchemaElement dateTimeElement = new XmlSchemaElement(schema, true);
dateTimeElement.setSchemaType(new XmlSchemaSimpleType(schema, false));
dateTimeElement.setSchemaTypeName(Constants.XSD_DATETIME);
dateTimeElement.setName(ELEMENT_NAME_2);
schema.getElements().put(new QName(ELEMENT_NAME_1), dateElement);
schema.getElements().put(new QName(ELEMENT_NAME_2), dateTimeElement);
FeatureMetacardType featureMetacardType = new FeatureMetacardType(schema, FEATURE_TYPE, NON_QUERYABLE_PROPS, Wfs10Constants.GML_NAMESPACE);
assertAttributeDescriptor(featureMetacardType, ELEMENT_NAME_1, BasicTypes.DATE_TYPE);
assertAttributeDescriptor(featureMetacardType, ELEMENT_NAME_2, BasicTypes.DATE_TYPE);
}
Aggregations