use of javax.xml.bind.JAXBElement in project ddf by codice.
the class RegistryPackageConverter method parseRegistryObjectList.
private static void parseRegistryObjectList(RegistryObjectListType registryObjects, MetacardImpl metacard) throws RegistryConversionException {
Map<String, Set<String>> associations = new HashMap<>();
Map<String, RegistryObjectType> registryIds = new HashMap<>();
List<OrganizationType> orgs = new ArrayList<>();
List<PersonType> contacts = new ArrayList<>();
String nodeId = "";
for (JAXBElement identifiable : registryObjects.getIdentifiable()) {
RegistryObjectType registryObject = (RegistryObjectType) identifiable.getValue();
registryIds.put(registryObject.getId(), registryObject);
if (registryObject instanceof ExtrinsicObjectType && RegistryConstants.REGISTRY_NODE_OBJECT_TYPE.equals(registryObject.getObjectType())) {
nodeId = registryObject.getId();
parseNodeExtrinsicObject(registryObject, metacard);
} else if (registryObject instanceof ServiceType && RegistryConstants.REGISTRY_SERVICE_OBJECT_TYPE.equals(registryObject.getObjectType())) {
parseRegistryService((ServiceType) registryObject, metacard);
} else if (registryObject instanceof OrganizationType) {
orgs.add((OrganizationType) registryObject);
} else if (registryObject instanceof PersonType) {
contacts.add((PersonType) registryObject);
} else if (registryObject instanceof AssociationType1) {
AssociationType1 association = (AssociationType1) registryObject;
if (associations.containsKey(association.getSourceObject())) {
associations.get(association.getSourceObject()).add(association.getTargetObject());
} else {
associations.put(association.getSourceObject(), new HashSet<>(Collections.singleton(association.getTargetObject())));
}
}
}
boolean orgFound = false;
boolean contactFound = false;
if (associations.get(nodeId) != null) {
Set<String> nodeAssociations = associations.get(nodeId);
RegistryObjectType ro;
for (String id : nodeAssociations) {
ro = registryIds.get(id);
if (!orgFound && ro != null && ro instanceof OrganizationType) {
parseRegistryOrganization((OrganizationType) ro, metacard);
orgFound = true;
} else if (!contactFound && ro != null && ro instanceof PersonType) {
parseRegistryPerson((PersonType) ro, metacard);
contactFound = true;
}
}
}
if (!orgFound && !orgs.isEmpty()) {
parseRegistryOrganization(orgs.get(0), metacard);
}
if (!contactFound && !contacts.isEmpty()) {
parseRegistryPerson(contacts.get(0), metacard);
}
}
use of javax.xml.bind.JAXBElement in project ddf by codice.
the class TestWfs10JTStoGML200Converter method testMultiPolygonTypeToJAXB.
@Test
public void testMultiPolygonTypeToJAXB() throws JAXBException, SAXException, IOException, ParseException, NullPointerException {
String multiPolygonGML = Wfs10JTStoGML200Converter.convertGeometryToGML(getGeometryFromWkt(MULTIPOLYGON));
MultiPolygonType multiPolygonType = (MultiPolygonType) Wfs10JTStoGML200Converter.convertGMLToGeometryType(multiPolygonGML, Wfs10Constants.MULTI_POLYGON);
JAXBElement<MultiPolygonType> multiPolygonTypeJAXBElement = (JAXBElement<MultiPolygonType>) Wfs10JTStoGML200Converter.convertGeometryTypeToJAXB(multiPolygonType);
JAXB.marshal(multiPolygonTypeJAXBElement, writer);
String xml = writer.toString();
Diff diff = XMLUnit.compareXML(xml, MULTIPOLYGON_GML);
assertTrue(XMLUNIT_SIMILAR, diff.similar());
assertThat(diff.similar(), is(Boolean.TRUE));
assertThat(diff.identical(), is(Boolean.FALSE));
}
use of javax.xml.bind.JAXBElement in project ddf by codice.
the class TestWfs10JTStoGML200Converter method testGMLToMultiPolygonType.
@Test
public void testGMLToMultiPolygonType() throws JAXBException, SAXException, IOException, ParseException, NullPointerException {
String multiPolygonGML = Wfs10JTStoGML200Converter.convertGeometryToGML(getGeometryFromWkt(MULTIPOLYGON));
MultiPolygonType multiPolygonType = (MultiPolygonType) Wfs10JTStoGML200Converter.convertGMLToGeometryType(multiPolygonGML, Wfs10Constants.MULTI_POLYGON);
multiPolygonType.getJAXBElementName();
List<JAXBElement<? extends GeometryAssociationType>> geometryMembers = multiPolygonType.getGeometryMember();
assertThat(geometryMembers.size() == 2, is(Boolean.TRUE));
PolygonMemberType polygonMemberType1 = (PolygonMemberType) geometryMembers.get(0).getValue();
String coords1 = extractPolygonMemberCoordinates(polygonMemberType1);
assertThat(MULTIPOLYGON_COORDS1.equals(coords1), is(Boolean.TRUE));
PolygonMemberType polygonMemberType2 = (PolygonMemberType) geometryMembers.get(0).getValue();
String coords2 = extractPolygonMemberCoordinates(polygonMemberType2);
assertThat(MULTIPOLYGON_COORDS2.equals(coords2), is(Boolean.TRUE));
}
use of javax.xml.bind.JAXBElement in project ddf by codice.
the class TestWfs10JTStoGML200Converter method testGeometryCollectionTypeToJAXB.
@Test
public void testGeometryCollectionTypeToJAXB() throws JAXBException, SAXException, IOException, ParseException, NullPointerException {
String geometryCollectionGML = Wfs10JTStoGML200Converter.convertGeometryToGML(getGeometryFromWkt(GEOMETRYCOLLECTION)).replaceAll("\n", "");
GeometryCollectionType geometryCollectionType = (GeometryCollectionType) Wfs10JTStoGML200Converter.convertGMLToGeometryType(geometryCollectionGML, Wfs10Constants.GEOMETRY_COLLECTION);
JAXBElement<GeometryCollectionType> geometryCollectionTypeJAXBElement = (JAXBElement<GeometryCollectionType>) Wfs10JTStoGML200Converter.convertGeometryTypeToJAXB(geometryCollectionType);
JAXB.marshal(geometryCollectionTypeJAXBElement, writer);
String xml = writer.toString().replaceAll("\n", "");
Diff diff = XMLUnit.compareXML(xml, GEOMETRYCOLLECTION_NS1);
assertTrue(XMLUNIT_SIMILAR, diff.similar());
assertThat(diff.similar(), is(Boolean.TRUE));
assertThat(diff.identical(), is(Boolean.TRUE));
}
use of javax.xml.bind.JAXBElement in project ddf by codice.
the class TestWfs10JTStoGML200Converter method testPolygonTypeToJAXB.
@Test
public void testPolygonTypeToJAXB() throws JAXBException, SAXException, IOException, ParseException, NullPointerException {
Polygon polygon = (Polygon) getGeometryFromWkt(POLYGON);
assertThat(polygon == null, is(Boolean.FALSE));
String polygonGML = Wfs10JTStoGML200Converter.convertGeometryToGML(polygon);
PolygonType polygonType = (PolygonType) Wfs10JTStoGML200Converter.convertGMLToGeometryType(polygonGML, Wfs10Constants.POLYGON);
assertThat(null != polygonType, is(Boolean.TRUE));
JAXBElement<PolygonType> polygonTypeJAXBElement = (JAXBElement<PolygonType>) Wfs10JTStoGML200Converter.convertGeometryTypeToJAXB(polygonType);
assertThat(polygonTypeJAXBElement.getName().getLocalPart().equals(Wfs10Constants.POLYGON.getLocalPart()), is(Boolean.TRUE));
assertThat(polygonTypeJAXBElement.getDeclaredType() == PolygonType.class, is(Boolean.TRUE));
JAXB.marshal(polygonTypeJAXBElement, writer);
String xml = writer.toString();
Diff diff = XMLUnit.compareXML(xml, POLYGON_GML);
assertTrue(XMLUNIT_SIMILAR, diff.similar());
assertThat(diff.similar(), is(Boolean.TRUE));
assertThat(diff.identical(), is(Boolean.FALSE));
}
Aggregations