Search in sources :

Example 1 with VertexServerGeoObject

use of net.geoprism.registry.model.graph.VertexServerGeoObject in project geoprism-registry by terraframe.

the class ListTypeVersion method publish.

private void publish(ListType listType, ServerGeoObjectType type, ServerGeoObjectIF go, Business business, Collection<AttributeType> attributes, Map<ServerHierarchyType, List<ServerGeoObjectType>> ancestorMap, Set<ServerHierarchyType> hierarchiesOfSubTypes, Collection<Locale> locales) {
    VertexServerGeoObject vertexGo = (VertexServerGeoObject) go;
    business.setValue(RegistryConstants.GEOMETRY_ATTRIBUTE_NAME, go.getGeometry());
    for (AttributeType attribute : attributes) {
        String name = attribute.getName();
        business.setValue(ORIGINAL_OID, go.getRunwayId());
        if (this.isValid(attribute)) {
            Object value = go.getValue(name, this.getForDate());
            if (value != null) {
                if (value instanceof LocalizedValue && ((LocalizedValue) value).isNull()) {
                    continue;
                }
                if (attribute instanceof AttributeTermType) {
                    Classifier classifier = (Classifier) value;
                    Term term = ((AttributeTermType) attribute).getTermByCode(classifier.getClassifierId()).get();
                    LocalizedValue label = term.getLabel();
                    this.setValue(business, name, term.getCode());
                    this.setValue(business, name + DEFAULT_LOCALE, label.getValue(LocalizedValue.DEFAULT_LOCALE));
                    for (Locale locale : locales) {
                        this.setValue(business, name + locale.toString(), label.getValue(locale));
                    }
                } else if (attribute instanceof AttributeClassificationType) {
                    String classificationTypeCode = ((AttributeClassificationType) attribute).getClassificationType();
                    ClassificationType classificationType = ClassificationType.getByCode(classificationTypeCode);
                    Classification classification = Classification.getByOid(classificationType, (String) value);
                    LocalizedValue label = classification.getDisplayLabel();
                    this.setValue(business, name, classification.getCode());
                    this.setValue(business, name + DEFAULT_LOCALE, label.getValue(LocalizedValue.DEFAULT_LOCALE));
                    for (Locale locale : locales) {
                        this.setValue(business, name + locale.toString(), label.getValue(locale));
                    }
                } else if (attribute instanceof AttributeLocalType) {
                    LocalizedValue label = (LocalizedValue) value;
                    String defaultLocale = label.getValue(LocalizedValue.DEFAULT_LOCALE);
                    if (defaultLocale == null) {
                        defaultLocale = "";
                    }
                    this.setValue(business, name + DEFAULT_LOCALE, defaultLocale);
                    for (Locale locale : locales) {
                        String localeValue = label.getValue(locale);
                        if (localeValue == null) {
                            localeValue = "";
                        }
                        this.setValue(business, name + locale.toString(), localeValue);
                    }
                } else {
                    this.setValue(business, name, value);
                }
            }
        }
    }
    Set<Entry<ServerHierarchyType, List<ServerGeoObjectType>>> entries = ancestorMap.entrySet();
    for (Entry<ServerHierarchyType, List<ServerGeoObjectType>> entry : entries) {
        ServerHierarchyType hierarchy = entry.getKey();
        Map<String, LocationInfo> map = vertexGo.getAncestorMap(hierarchy, entry.getValue());
        Set<Entry<String, LocationInfo>> locations = map.entrySet();
        for (Entry<String, LocationInfo> location : locations) {
            String pCode = location.getKey();
            LocationInfo vObject = location.getValue();
            if (vObject != null) {
                String attributeName = hierarchy.getCode().toLowerCase() + pCode.toLowerCase();
                this.setValue(business, attributeName, vObject.getCode());
                this.setValue(business, attributeName + DEFAULT_LOCALE, vObject.getLabel());
                for (Locale locale : locales) {
                    this.setValue(business, attributeName + locale.toString(), vObject.getLabel(locale));
                }
            }
        }
    }
    for (ServerHierarchyType hierarchy : hierarchiesOfSubTypes) {
        ServerParentTreeNode node = go.getParentsForHierarchy(hierarchy, false, this.getForDate());
        List<ServerParentTreeNode> parents = node.getParents();
        if (parents.size() > 0) {
            ServerParentTreeNode parent = parents.get(0);
            String attributeName = hierarchy.getCode().toLowerCase();
            ServerGeoObjectIF geoObject = parent.getGeoObject();
            LocalizedValue label = geoObject.getDisplayLabel();
            this.setValue(business, attributeName, geoObject.getCode());
            this.setValue(business, attributeName + DEFAULT_LOCALE, label.getValue(DEFAULT_LOCALE));
            for (Locale locale : locales) {
                this.setValue(business, attributeName + locale.toString(), label.getValue(locale));
            }
        }
    }
    if (type.getGeometryType().equals(GeometryType.MULTIPOINT) || type.getGeometryType().equals(GeometryType.POINT) && listType.getIncludeLatLong()) {
        Geometry geom = vertexGo.getGeometry();
        if (geom instanceof MultiPoint) {
            MultiPoint mp = (MultiPoint) geom;
            Coordinate[] coords = mp.getCoordinates();
            Coordinate firstCoord = coords[0];
            this.setValue(business, "latitude", String.valueOf(firstCoord.y));
            this.setValue(business, "longitude", String.valueOf(firstCoord.x));
        } else if (geom instanceof Point) {
            Point point = (Point) geom;
            Coordinate firstCoord = point.getCoordinate();
            this.setValue(business, "latitude", String.valueOf(firstCoord.y));
            this.setValue(business, "longitude", String.valueOf(firstCoord.x));
        }
    }
    business.apply();
}
Also used : Locale(java.util.Locale) MultiPoint(com.vividsolutions.jts.geom.MultiPoint) MdAttributeMultiPoint(com.runwaysdk.system.gis.metadata.MdAttributeMultiPoint) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerParentTreeNode(net.geoprism.registry.model.ServerParentTreeNode) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) MdAttributeMultiLineString(com.runwaysdk.system.gis.metadata.MdAttributeMultiLineString) MdAttributeLineString(com.runwaysdk.system.gis.metadata.MdAttributeLineString) Classifier(net.geoprism.ontology.Classifier) Entry(java.util.Map.Entry) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) Classification(net.geoprism.registry.model.Classification) List(java.util.List) LinkedList(java.util.LinkedList) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Term(org.commongeoregistry.adapter.Term) MultiPoint(com.vividsolutions.jts.geom.MultiPoint) MdAttributePoint(com.runwaysdk.system.gis.metadata.MdAttributePoint) MdAttributeMultiPoint(com.runwaysdk.system.gis.metadata.MdAttributeMultiPoint) Point(com.vividsolutions.jts.geom.Point) AttributeClassificationType(org.commongeoregistry.adapter.metadata.AttributeClassificationType) ClassificationType(net.geoprism.registry.model.ClassificationType) AttributeClassificationType(org.commongeoregistry.adapter.metadata.AttributeClassificationType) LocationInfo(net.geoprism.registry.model.LocationInfo) Geometry(com.vividsolutions.jts.geom.Geometry) MdAttributeGeometry(com.runwaysdk.system.gis.metadata.MdAttributeGeometry) AttributeLocalType(org.commongeoregistry.adapter.metadata.AttributeLocalType) Coordinate(com.vividsolutions.jts.geom.Coordinate) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) JsonObject(com.google.gson.JsonObject) ValueObject(com.runwaysdk.dataaccess.ValueObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) AttributeTermType(org.commongeoregistry.adapter.metadata.AttributeTermType)

Example 2 with VertexServerGeoObject

use of net.geoprism.registry.model.graph.VertexServerGeoObject in project geoprism-registry by terraframe.

the class MasterListVersion method publish.

private void publish(ServerGeoObjectIF go, Business business, Collection<AttributeType> attributes, Map<ServerHierarchyType, List<ServerGeoObjectType>> ancestorMap, Set<ServerHierarchyType> hierarchiesOfSubTypes, Collection<Locale> locales) {
    VertexServerGeoObject vertexGo = (VertexServerGeoObject) go;
    boolean hasData = false;
    business.setValue(RegistryConstants.GEOMETRY_ATTRIBUTE_NAME, go.getGeometry());
    for (AttributeType attribute : attributes) {
        String name = attribute.getName();
        business.setValue(ORIGINAL_OID, go.getRunwayId());
        if (this.isValid(attribute)) {
            Object value = go.getValue(name, this.getForDate());
            if (value != null) {
                if (value instanceof LocalizedValue && ((LocalizedValue) value).isNull()) {
                    continue;
                }
                if (!name.equals(DefaultAttribute.CODE.getName()) && !name.equals(DefaultAttribute.INVALID.getName()) && attribute.isChangeOverTime() && (!name.equals(DefaultAttribute.EXISTS.getName()) || (value instanceof Boolean && ((Boolean) value)))) {
                    hasData = true;
                }
                if (attribute instanceof AttributeTermType) {
                    Classifier classifier = (Classifier) value;
                    Term term = ((AttributeTermType) attribute).getTermByCode(classifier.getClassifierId()).get();
                    LocalizedValue label = term.getLabel();
                    this.setValue(business, name, term.getCode());
                    this.setValue(business, name + DEFAULT_LOCALE, label.getValue(LocalizedValue.DEFAULT_LOCALE));
                    for (Locale locale : locales) {
                        this.setValue(business, name + locale.toString(), label.getValue(locale));
                    }
                } else if (attribute instanceof AttributeClassificationType) {
                    String classificationType = ((AttributeClassificationType) attribute).getClassificationType();
                    MdClassificationDAOIF mdClassificationDAO = MdClassificationDAO.getMdClassificationDAO(classificationType);
                    MdVertexDAOIF mdVertexDAO = mdClassificationDAO.getReferenceMdVertexDAO();
                    VertexObject classification = VertexObject.get(mdVertexDAO, (String) value);
                    LocalizedValue label = LocalizedValueConverter.convert(classification.getEmbeddedComponent(AbstractClassification.DISPLAYLABEL));
                    this.setValue(business, name, classification.getObjectValue(AbstractClassification.CODE));
                    this.setValue(business, name + DEFAULT_LOCALE, label.getValue(LocalizedValue.DEFAULT_LOCALE));
                    for (Locale locale : locales) {
                        this.setValue(business, name + locale.toString(), label.getValue(locale));
                    }
                } else if (attribute instanceof AttributeLocalType) {
                    LocalizedValue label = (LocalizedValue) value;
                    String defaultLocale = label.getValue(LocalizedValue.DEFAULT_LOCALE);
                    if (defaultLocale == null) {
                        defaultLocale = "";
                    }
                    this.setValue(business, name + DEFAULT_LOCALE, defaultLocale);
                    for (Locale locale : locales) {
                        String localeValue = label.getValue(locale);
                        if (localeValue == null) {
                            localeValue = "";
                        }
                        this.setValue(business, name + locale.toString(), localeValue);
                    }
                } else {
                    this.setValue(business, name, value);
                }
            }
        }
    }
    if (hasData) {
        Set<Entry<ServerHierarchyType, List<ServerGeoObjectType>>> entries = ancestorMap.entrySet();
        for (Entry<ServerHierarchyType, List<ServerGeoObjectType>> entry : entries) {
            ServerHierarchyType hierarchy = entry.getKey();
            Map<String, LocationInfo> map = vertexGo.getAncestorMap(hierarchy, entry.getValue());
            Set<Entry<String, LocationInfo>> locations = map.entrySet();
            for (Entry<String, LocationInfo> location : locations) {
                String pCode = location.getKey();
                LocationInfo vObject = location.getValue();
                if (vObject != null) {
                    String attributeName = hierarchy.getCode().toLowerCase() + pCode.toLowerCase();
                    this.setValue(business, attributeName, vObject.getCode());
                    this.setValue(business, attributeName + DEFAULT_LOCALE, vObject.getLabel());
                    for (Locale locale : locales) {
                        this.setValue(business, attributeName + locale.toString(), vObject.getLabel(locale));
                    }
                }
            }
        }
        for (ServerHierarchyType hierarchy : hierarchiesOfSubTypes) {
            ServerParentTreeNode node = go.getParentsForHierarchy(hierarchy, false, this.getForDate());
            List<ServerParentTreeNode> parents = node.getParents();
            if (parents.size() > 0) {
                ServerParentTreeNode parent = parents.get(0);
                String attributeName = hierarchy.getCode().toLowerCase();
                ServerGeoObjectIF geoObject = parent.getGeoObject();
                LocalizedValue label = geoObject.getDisplayLabel();
                this.setValue(business, attributeName, geoObject.getCode());
                this.setValue(business, attributeName + DEFAULT_LOCALE, label.getValue(DEFAULT_LOCALE));
                for (Locale locale : locales) {
                    this.setValue(business, attributeName + locale.toString(), label.getValue(locale));
                }
            }
        }
        business.apply();
    }
}
Also used : Locale(java.util.Locale) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerParentTreeNode(net.geoprism.registry.model.ServerParentTreeNode) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) MdAttributeMultiLineString(com.runwaysdk.system.gis.metadata.MdAttributeMultiLineString) MdAttributeLineString(com.runwaysdk.system.gis.metadata.MdAttributeLineString) Classifier(net.geoprism.ontology.Classifier) MdClassificationDAOIF(com.runwaysdk.dataaccess.MdClassificationDAOIF) Entry(java.util.Map.Entry) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) List(java.util.List) LinkedList(java.util.LinkedList) MdAttributeBoolean(com.runwaysdk.system.metadata.MdAttributeBoolean) AttributeBoolean(com.runwaysdk.query.AttributeBoolean) MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) VertexObject(com.runwaysdk.business.graph.VertexObject) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Term(org.commongeoregistry.adapter.Term) AttributeClassificationType(org.commongeoregistry.adapter.metadata.AttributeClassificationType) LocationInfo(net.geoprism.registry.model.LocationInfo) AttributeLocalType(org.commongeoregistry.adapter.metadata.AttributeLocalType) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) VertexObject(com.runwaysdk.business.graph.VertexObject) JsonObject(com.google.gson.JsonObject) ValueObject(com.runwaysdk.dataaccess.ValueObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) AttributeTermType(org.commongeoregistry.adapter.metadata.AttributeTermType)

Example 3 with VertexServerGeoObject

use of net.geoprism.registry.model.graph.VertexServerGeoObject in project geoprism-registry by terraframe.

the class GeoVertexSynonym method createSynonym.

@Transaction
public static JSONObject createSynonym(String typeCode, String code, String label) {
    ServerGeoObjectType type = ServerGeoObjectType.get(typeCode);
    VertexGeoObjectStrategy strategy = new VertexGeoObjectStrategy(type);
    VertexServerGeoObject object = strategy.getGeoObjectByCode(code);
    final String oid = object.addSynonym(label);
    JSONObject jObject = new JSONObject();
    jObject.put("synonymId", oid);
    jObject.put("label", object.getDisplayLabel().getValue());
    // jObject.put("ancestors", object.getA new
    // JSONArray(GeoEntityUtil.getAncestorsAsJSON(code)));
    JSONObject response = new JSONObject(jObject);
    response.put("vOid", oid);
    return response;
}
Also used : VertexGeoObjectStrategy(net.geoprism.registry.conversion.VertexGeoObjectStrategy) JSONObject(org.json.JSONObject) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 4 with VertexServerGeoObject

use of net.geoprism.registry.model.graph.VertexServerGeoObject in project geoprism-registry by terraframe.

the class Transition method apply.

public static Transition apply(TransitionEvent event, int order, JsonObject object) {
    Transition transition = (object.has("isNew") && object.get("isNew").getAsBoolean()) ? new Transition() : Transition.get(object.get(OID).getAsString());
    transition.setTransitionType(object.get(Transition.TRANSITIONTYPE).getAsString());
    transition.setImpact(object.get(Transition.IMPACT).getAsString());
    if (transition.isNew()) {
        transition.setValue(Transition.EVENT, event);
    }
    String sourceCode = object.get("sourceCode").getAsString();
    String sourceType = object.get("sourceType").getAsString();
    String targetCode = object.get("targetCode").getAsString();
    String targetType = object.get("targetType").getAsString();
    VertexServerGeoObject source = new VertexGeoObjectStrategy(ServerGeoObjectType.get(sourceType)).getGeoObjectByCode(sourceCode);
    VertexServerGeoObject target = new VertexGeoObjectStrategy(ServerGeoObjectType.get(targetType)).getGeoObjectByCode(targetCode);
    transition.apply(event, order, source, target);
    return transition;
}
Also used : VertexGeoObjectStrategy(net.geoprism.registry.conversion.VertexGeoObjectStrategy) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject)

Example 5 with VertexServerGeoObject

use of net.geoprism.registry.model.graph.VertexServerGeoObject in project geoprism-registry by terraframe.

the class Transition method getVertex.

private VertexServerGeoObject getVertex(String attributeName) {
    MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(Transition.CLASS);
    MdAttributeDAOIF mdAttribute = mdVertex.definesAttribute(attributeName);
    StringBuilder statement = new StringBuilder();
    statement.append("SELECT expand(" + mdAttribute.getColumnName() + ")");
    statement.append(" FROM :parent");
    GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(statement.toString());
    query.setParameter("parent", this.getRID());
    VertexObject vertex = query.getSingleResult();
    MdVertexDAOIF geoVertex = (MdVertexDAOIF) vertex.getMdClass();
    ServerGeoObjectType type = ServerGeoObjectType.get(geoVertex);
    return new VertexServerGeoObject(type, vertex);
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) VertexObject(com.runwaysdk.business.graph.VertexObject) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Aggregations

VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)51 VertexObject (com.runwaysdk.business.graph.VertexObject)20 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)19 JsonObject (com.google.gson.JsonObject)18 Request (com.runwaysdk.session.Request)13 Date (java.util.Date)12 LinkedList (java.util.LinkedList)11 ChangeRequest (net.geoprism.registry.action.ChangeRequest)11 JsonArray (com.google.gson.JsonArray)10 ValueOverTime (com.runwaysdk.dataaccess.graph.attributes.ValueOverTime)10 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)10 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)9 GraphQuery (com.runwaysdk.business.graph.GraphQuery)8 UpdateAttributeAction (net.geoprism.registry.action.geoobject.UpdateAttributeAction)8 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)8 QueryFactory (com.runwaysdk.query.QueryFactory)6 SimpleDateFormat (java.text.SimpleDateFormat)6 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)6 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)6 MdAttributeDAOIF (com.runwaysdk.dataaccess.MdAttributeDAOIF)5