use of oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType in project ddf by codice.
the class RegistryObjectListWebConverter method convert.
/**
* This method creates a Map<String, Object> representation of the RegistryObjectListType provided.
* The following keys will be added to the map (Taken from EbrimConstants):
* <p>
* ASSOCIATION_KEY = "Association";
* EXTRINSIC_OBJECT_KEY = "ExtrinsicObject";
* ORGANIZATION_KEY = "Organization";
* PERSON_KEY = "Person";
* SERVICE_KEY = "Service";
* <p>
* <p>
* Uses:
* AssociationWebConverter
* ExtrinsicObjectWebConverter
* OrganizationWebConverter
* PersonWebConverter
* ServiceWebConverter
*
* @param registryObjectList the RegistryObjectListType to be converted into a map, null returns empty Map
* @return Map<String, Object> representation of the RegistryObjectListType provided
*/
public Map<String, Object> convert(RegistryObjectListType registryObjectList) {
Map<String, Object> registryObjectListMap = new HashMap<>();
if (registryObjectList == null) {
return registryObjectListMap;
}
List<Map<String, Object>> associations = new ArrayList<>();
List<Map<String, Object>> extrinsicObjects = new ArrayList<>();
List<Map<String, Object>> organizations = new ArrayList<>();
List<Map<String, Object>> people = new ArrayList<>();
List<Map<String, Object>> services = new ArrayList<>();
AssociationWebConverter associationConverter = new AssociationWebConverter();
ExtrinsicObjectWebConverter extrinsicObjectConverter = new ExtrinsicObjectWebConverter();
OrganizationWebConverter organizationConverter = new OrganizationWebConverter();
PersonWebConverter personConverter = new PersonWebConverter();
ServiceWebConverter serviceConverter = new ServiceWebConverter();
for (JAXBElement<? extends IdentifiableType> identifiable : registryObjectList.getIdentifiable()) {
RegistryObjectType registryObject = (RegistryObjectType) identifiable.getValue();
Map<String, Object> identifiableMap;
if (registryObject instanceof ExtrinsicObjectType) {
identifiableMap = extrinsicObjectConverter.convert((ExtrinsicObjectType) registryObject);
if (MapUtils.isNotEmpty(identifiableMap)) {
extrinsicObjects.add(identifiableMap);
}
} else if (registryObject instanceof ServiceType) {
identifiableMap = serviceConverter.convert((ServiceType) registryObject);
if (MapUtils.isNotEmpty(identifiableMap)) {
services.add(identifiableMap);
}
} else if (registryObject instanceof OrganizationType) {
identifiableMap = organizationConverter.convert((OrganizationType) registryObject);
if (MapUtils.isNotEmpty(identifiableMap)) {
organizations.add(identifiableMap);
}
} else if (registryObject instanceof PersonType) {
identifiableMap = personConverter.convert((PersonType) registryObject);
if (MapUtils.isNotEmpty(identifiableMap)) {
people.add(identifiableMap);
}
} else if (registryObject instanceof AssociationType1) {
identifiableMap = associationConverter.convert((AssociationType1) registryObject);
if (MapUtils.isNotEmpty(identifiableMap)) {
associations.add(identifiableMap);
}
}
}
webMapHelper.putIfNotEmpty(registryObjectListMap, ASSOCIATION_KEY, associations);
webMapHelper.putIfNotEmpty(registryObjectListMap, EXTRINSIC_OBJECT_KEY, extrinsicObjects);
webMapHelper.putIfNotEmpty(registryObjectListMap, ORGANIZATION_KEY, organizations);
webMapHelper.putIfNotEmpty(registryObjectListMap, PERSON_KEY, people);
webMapHelper.putIfNotEmpty(registryObjectListMap, SERVICE_KEY, services);
return registryObjectListMap;
}
use of oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType in project ddf by codice.
the class RegistryPackageWebConverterTest method getFirstExtrinsicObject.
private ExtrinsicObjectType getFirstExtrinsicObject() {
ExtrinsicObjectType extrinsicObject = RIM_FACTORY.createExtrinsicObjectType();
// set default values
extrinsicObject.setMimeType(extrinsicObject.getMimeType());
extrinsicObject.setIsOpaque(extrinsicObject.isIsOpaque());
extrinsicObject.setId("urn:registry:node");
extrinsicObject.setObjectType("urn:registry:federation:node");
extrinsicObject.getSlot().add(stHelper.create("liveDate", "2015-11-01T06:15:30-07:00", "xs:dateTime"));
extrinsicObject.getSlot().add(stHelper.create("dataStartDate", "2015-11-01T13:15:30Z", "xs:dateTime"));
extrinsicObject.getSlot().add(stHelper.create("dataEndDate", "2015-12-01T23:01:40Z", "xs:dateTime"));
extrinsicObject.getSlot().add(stHelper.create("lastUpdated", "2016-01-26T17:16:34.996Z", "xs:dateTime"));
extrinsicObject.getSlot().add(stHelper.create("links", "https://some/link/to/my/repo", "xs:string"));
SlotType1 locationSlot = stHelper.create("location", (String) null, "urn:ogc:def:dataType:ISO-19107:2003:GM_Point");
PointType point = GML_FACTORY.createPointType();
point.setSrsDimension(BigInteger.valueOf(2));
point.setSrsName("urn:ogc:def:crs:EPSG::4326");
DirectPositionType directPosition = GML_FACTORY.createDirectPositionType();
directPosition.getValue().add(112.267472);
directPosition.getValue().add(33.467944);
point.setPos(directPosition);
ValueListType valueList = WRS_FACTORY.createValueListType();
AnyValueType anyValue = WRS_FACTORY.createAnyValueType();
anyValue.getContent().add(GML_FACTORY.createPoint(point));
valueList.getAnyValue().add(anyValue);
locationSlot.setValueList(RIM_FACTORY.createValueList(valueList));
extrinsicObject.getSlot().add(locationSlot);
SlotType1 boundsSlot = stHelper.create("bounds", (String) null, "urn:ogc:def:dataType:ISO-19107:2003:GM_Envelope");
EnvelopeType bounds = GML_FACTORY.createEnvelopeType();
bounds.setSrsName("urn:ogc:def:crs:EPSG::4326");
directPosition = GML_FACTORY.createDirectPositionType();
directPosition.getValue().add(112.267472);
directPosition.getValue().add(33.467944);
bounds.setUpperCorner(directPosition);
directPosition = GML_FACTORY.createDirectPositionType();
directPosition.getValue().add(110.267472);
directPosition.getValue().add(30.467944);
bounds.setLowerCorner(directPosition);
valueList = WRS_FACTORY.createValueListType();
anyValue = WRS_FACTORY.createAnyValueType();
anyValue.getContent().add(GML_FACTORY.createEnvelope(bounds));
valueList.getAnyValue().add(anyValue);
boundsSlot.setValueList(RIM_FACTORY.createValueList(valueList));
extrinsicObject.getSlot().add(boundsSlot);
extrinsicObject.getSlot().add(stHelper.create("region", "USA", "urn:ogc:def:ebRIM-ClassificationScheme:UNSD:GlobalRegions"));
List<String> values = new ArrayList<>();
values.add("youtube");
values.add("myCamera");
extrinsicObject.getSlot().add(stHelper.create("inputDataSources", values, "xs:string"));
values = new ArrayList<>();
values.add("video");
values.add("sensor");
extrinsicObject.getSlot().add(stHelper.create("dataTypes", values, "xs:string"));
extrinsicObject.getSlot().add(stHelper.create("securityLevel", "role=guest", "xs:string"));
extrinsicObject.setName(istHelper.create("Node Name"));
extrinsicObject.setDescription(istHelper.create("A little something describing this node in less than 1024 characters"));
extrinsicObject.setVersionInfo(getVersionInfo("2.9.x"));
ClassificationType classification = RIM_FACTORY.createClassificationType();
classification.setId("urn:classification:id0");
classification.setClassifiedObject("classifiedObjectId");
extrinsicObject.getClassification().add(classification);
return extrinsicObject;
}
use of oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType in project ddf by codice.
the class RegistryPackageTypeHelper method populateLists.
private void populateLists() {
serviceBindings.clear();
services.clear();
extrinsicObjects.clear();
organizations.clear();
persons.clear();
associations.clear();
if (registryPackageType == null) {
return;
}
if (registryPackageType.isSetRegistryObjectList()) {
RegistryObjectListType registryObjectList = registryPackageType.getRegistryObjectList();
for (JAXBElement<? extends IdentifiableType> identifiableType : registryObjectList.getIdentifiable()) {
RegistryObjectType registryObject = (RegistryObjectType) identifiableType.getValue();
if (registryObject instanceof ExtrinsicObjectType) {
extrinsicObjects.add((ExtrinsicObjectType) registryObject);
} else if (registryObject instanceof ServiceType) {
ServiceType service = (ServiceType) registryObject;
services.add(service);
serviceBindings.addAll(service.getServiceBinding());
} else if (registryObject instanceof OrganizationType) {
organizations.add((OrganizationType) registryObject);
} else if (registryObject instanceof PersonType) {
persons.add((PersonType) registryObject);
} else if (registryObject instanceof AssociationType1) {
associations.add((AssociationType1) registryObject);
}
}
}
}
use of oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType in project ddf by codice.
the class RegistryPackageWebConverterTest method getSecondExtrinsicObject.
private ExtrinsicObjectType getSecondExtrinsicObject() {
ExtrinsicObjectType extrinsicObject = RIM_FACTORY.createExtrinsicObjectType();
// set default values
extrinsicObject.setMimeType(extrinsicObject.getMimeType());
extrinsicObject.setIsOpaque(extrinsicObject.isIsOpaque());
extrinsicObject.setId("urn:content:collection:id0");
extrinsicObject.setObjectType("urn:registry:content:collection");
extrinsicObject.getSlot().add(stHelper.create("types", "sensor", "xs:string"));
List<String> values = new ArrayList<>();
values.add("application/pdf");
values.add("application/msword");
extrinsicObject.getSlot().add(stHelper.create("mimeTypes", values, "xs:string"));
extrinsicObject.getSlot().add(stHelper.create("recordCount", "1234", "xs:long"));
extrinsicObject.getSlot().add(stHelper.create("startDate", "2015-11-01T13:15:30Z", "xs:dateTime"));
extrinsicObject.getSlot().add(stHelper.create("endDate", "2015-12-01T23:01:40Z", "xs:dateTime"));
extrinsicObject.getSlot().add(stHelper.create("lastUpdated", "2016-01-26T17:16:34.996Z", "xs:dateTime"));
extrinsicObject.getSlot().add(stHelper.create("region", "Arizona", "urn:ogc:def:ebRIM-ClassificationScheme:UNSD:GlobalRegions"));
extrinsicObject.setName(istHelper.create("Collection Name"));
extrinsicObject.setDescription(istHelper.create("A little something describing this collection in less than 1024 characters"));
return extrinsicObject;
}
use of oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType 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);
}
}
Aggregations