public static boolean checkOrganizationWhatElement( DigestType digest, String entityID, String codespace, String code, String label, String value) { boolean ok = false; XmlObject[] entities = digest.selectChildren( OrganizationType.type.getName().getNamespaceURI(), ORGANIZATION_THING_TYPE); if (entities.length > 0) { EntityType entity = null; for (XmlObject obj : entities) { if (((EntityType) obj).getId().equals(entityID)) { entity = (EntityType) obj; } } if (entity != null) { // XmlObject event = events[0]; ok = EMDigestHelper.objectHasWhatType(codespace, code, label, value, entity); } } return ok; }
public static boolean checkLocationGMLPoint(DigestType digest, String pos) { boolean foundPointLocation = false; List<LocationType> locationElements = EMDigestHelper.getLocationElements(digest); for (LocationType location : locationElements) { XmlObject[] geoLocations = location.selectChildren( gov.ucore.ucore.x20.GeoLocationType.type.getName().getNamespaceURI(), "GeoLocation"); if (geoLocations != null && geoLocations.length > 0) { for (XmlObject object : geoLocations) { GeoLocationType geo = (GeoLocationType) object; XmlObject[] UcorePoint = geo.selectChildren( gov.ucore.ucore.x20.PointType.type.getName().getNamespaceURI(), "Point"); if (UcorePoint.length > 0) { gov.ucore.ucore.x20.PointType point = (gov.ucore.ucore.x20.PointType) UcorePoint[0]; if (point.getPoint().getPos().getStringValue().equals(pos)) { foundPointLocation = true; } } } } } return foundPointLocation; }
public static boolean checkEventWhatElement( DigestType digest, String eventID, String codespace, String code, String label, String value) { boolean ok = false; XmlObject[] events = digest.selectChildren(EventType.type.getName().getNamespaceURI(), EVENT_THING_TYPE); if (events.length > 0) { EventType event = null; for (XmlObject obj : events) { if (((EventType) obj).getId().equals(eventID)) { event = (EventType) obj; } } if (event != null) { // XmlObject event = events[0]; ok = EMDigestHelper.objectHasWhatType(codespace, code, label, value, event); } } return ok; }
public static boolean hasAHasDestinationOfElement(DigestType digest, String entityID) { boolean found = false; XmlObject[] hasDestinationOfs = digest.selectChildren( EntityLocationRelationshipType.type.getName().getNamespaceURI(), HAS_DESTINATION_TYPE); if (hasDestinationOfs.length > 0) { for (XmlObject object : hasDestinationOfs) { EntityLocationRelationshipType hasDestinationOf = (EntityLocationRelationshipType) object; if (hasDestinationOf.getLocationRef().getRef().size() > 0 && hasDestinationOf.getLocationRef().getRef().size() > 0) { String entityRef = (String) hasDestinationOf.getEntityRef().getRef().get(0); String locationRef = (String) hasDestinationOf.getLocationRef().getRef().get(0); List<LocationType> locationElements = EMDigestHelper.getLocationElements(digest); for (LocationType location : locationElements) { if (entityRef.equals(entityID) && locationRef.equals(location.getId())) { found = true; break; } } if (found) break; } } } return found; }
public static boolean checkLocationAddresses(DigestType digest) { boolean foundPointLocation = false; List<LocationType> locationElements = EMDigestHelper.getLocationElements(digest); for (LocationType location : locationElements) { XmlObject[] addresses = location.selectChildren( gov.ucore.ucore.x20.PhysicalAddressType.type.getName().getNamespaceURI(), "PhysicalAddress"); if (addresses != null && addresses.length > 0) { for (XmlObject object : addresses) { PhysicalAddressType address = (PhysicalAddressType) object; if (address.getPostalAddress() != null) { if (address.getPostalAddress().getCountryCode() != null && address.getPostalAddress().getCountryCode().getQualifier() != null && address.getPostalAddress().getCountryCode().getValue() != null && address.getPostalAddress().getState() != null && address.getPostalAddress().getCity() != null && address.getPostalAddress().getPostalCode() != null && address.getPostalAddress().sizeOfStreetArray() > 0) { foundPointLocation = true; } } } } } return foundPointLocation; }
public static boolean checkLocationGMLCircle(DigestType digest, String radius, String UOM) { boolean foundCircle = false; List<LocationType> locationElements = EMDigestHelper.getLocationElements(digest); for (LocationType location : locationElements) { XmlObject[] geoLocations = location.selectChildren( gov.ucore.ucore.x20.GeoLocationType.type.getName().getNamespaceURI(), "GeoLocation"); if (geoLocations != null && geoLocations.length > 0) { for (XmlObject object : geoLocations) { GeoLocationType geo = (GeoLocationType) object; XmlObject[] ucoreCircles = geo.selectChildren( CircleByCenterPointType.type.getName().getNamespaceURI(), "CircleByCenterPoint"); if (ucoreCircles.length > 0) { // TODO: should check point value and UOM CircleByCenterPointType circle = (CircleByCenterPointType) ucoreCircles[0]; if (circle.getCircleByCenterPoint().getRadius().getStringValue().equals(radius) && circle.getCircleByCenterPoint().getRadius().getUom().equals(UOM) && circle.getCircleByCenterPoint().getNumArc() != null) { foundCircle = true; } } } } } return foundCircle; }
public static EventType getEventElementFromDigest(DigestType digest, Map<String, String> codes) { XmlObject object = null; XmlObject[] events = digest.selectChildren(EventType.type.getName().getNamespaceURI(), EVENT_THING_TYPE); for (XmlObject obj : events) { boolean found = false; for (String codespace : codes.keySet()) { if (EMDigestHelper.objectHasWhatType(codespace, codes.get(codespace), null, null, obj)) { object = obj; found = true; break; } } if (found) break; } return (EventType) object; }
public static boolean checkLocationGMLPolygon(DigestType digest, List<String> points) { boolean foundPolygon = false; List<LocationType> locationElements = EMDigestHelper.getLocationElements(digest); for (LocationType location : locationElements) { XmlObject[] geoLocations = location.selectChildren( gov.ucore.ucore.x20.GeoLocationType.type.getName().getNamespaceURI(), "GeoLocation"); if (geoLocations != null && geoLocations.length > 0) { for (XmlObject object : geoLocations) { GeoLocationType geo = (GeoLocationType) object; XmlObject[] ucorePolygons = geo.selectChildren( gov.ucore.ucore.x20.PointType.type.getName().getNamespaceURI(), "Polygon"); if (ucorePolygons.length > 0) { for (XmlObject poly : ucorePolygons) { if (poly instanceof PolygonType) { net.opengis.gml.x32.PolygonType polygon = ((PolygonType) poly).getPolygon(); if (polygon.getExterior() != null && polygon.getExterior().getAbstractRing() != null) { if (polygon.getExterior().getAbstractRing() instanceof net.opengis.gml.x32.LinearRingType) { net.opengis.gml.x32.LinearRingType linearRing = (net.opengis.gml.x32.LinearRingType) polygon.getExterior().getAbstractRing(); if (linearRing.sizeOfPosArray() == points.size()) { foundPolygon = true; // TODO: check the values } } } } } } } } } return foundPolygon; }