Search in sources :

Example 1 with VertexObject

use of com.runwaysdk.business.graph.VertexObject 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 2 with VertexObject

use of com.runwaysdk.business.graph.VertexObject 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)

Example 3 with VertexObject

use of com.runwaysdk.business.graph.VertexObject in project geoprism-registry by terraframe.

the class PatchExistsAndInvalidInstanceData method getInstanceData.

private List<VertexServerGeoObject> getInstanceData(ServerGeoObjectType type, MdGraphClassDAOIF mdClass) {
    StringBuilder statement = new StringBuilder();
    statement.append("SELECT FROM " + mdClass.getDBClassName());
    GraphQuery<VertexObject> vertexQuery = new GraphQuery<VertexObject>(statement.toString(), new HashMap<String, Object>());
    List<VertexServerGeoObject> list = new LinkedList<VertexServerGeoObject>();
    List<VertexObject> results = vertexQuery.getResults();
    for (VertexObject result : results) {
        list.add(new VertexServerGeoObject(type, result, today));
    }
    return list;
}
Also used : VertexObject(com.runwaysdk.business.graph.VertexObject) VertexObject(com.runwaysdk.business.graph.VertexObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) GraphQuery(com.runwaysdk.business.graph.GraphQuery) LinkedList(java.util.LinkedList)

Example 4 with VertexObject

use of com.runwaysdk.business.graph.VertexObject in project geoprism-registry by terraframe.

the class PatchLastUpdateDate method doIt.

@Transaction
private void doIt() {
    Date date = new Date();
    MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(GeoVertex.CLASS);
    MdAttributeDAOIF mdAttribute = mdVertex.definesAttribute(GeoVertex.LASTUPDATEDATE);
    MdAttributeDAOIF createDate = mdVertex.definesAttribute(GeoVertex.CREATEDATE);
    long pageSize = 1000;
    long count = 0;
    do {
        StringBuilder builder = new StringBuilder();
        builder.append("SELECT FROM " + mdVertex.getDBClassName());
        builder.append(" WHERE " + mdAttribute.getColumnName() + " IS NULL");
        builder.append(" OR " + createDate.getColumnName() + " IS NULL");
        builder.append(" ORDER BY oid");
        builder.append(" SKIP " + 0 + " LIMIT " + pageSize);
        GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(builder.toString());
        List<VertexObject> results = query.getResults();
        for (VertexObject result : results) {
            result.setValue(GeoVertex.LASTUPDATEDATE, date);
            result.setValue(GeoVertex.CREATEDATE, date);
            result.apply();
        }
        count = this.getCount();
    } while (count > 0);
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) VertexObject(com.runwaysdk.business.graph.VertexObject) GraphQuery(com.runwaysdk.business.graph.GraphQuery) Date(java.util.Date) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 5 with VertexObject

use of com.runwaysdk.business.graph.VertexObject in project geoprism-registry by terraframe.

the class VertexGeoObjectStrategy method constructFromGeoObjectOverTime.

@Override
public VertexServerGeoObject constructFromGeoObjectOverTime(GeoObjectOverTime goTime, boolean isNew) {
    if (!isNew) {
        VertexObject vertex = VertexServerGeoObject.getVertex(type, goTime.getUid());
        if (vertex == null) {
            InvalidRegistryIdException ex = new InvalidRegistryIdException();
            ex.setRegistryId(goTime.getUid());
            throw ex;
        }
        return new VertexServerGeoObject(type, vertex);
    } else {
        if (!RegistryIdService.getInstance().isIssuedId(goTime.getUid())) {
            InvalidRegistryIdException ex = new InvalidRegistryIdException();
            ex.setRegistryId(goTime.getUid());
            throw ex;
        }
        VertexObject vertex = VertexServerGeoObject.newInstance(type);
        return new VertexServerGeoObject(type, vertex);
    }
}
Also used : InvalidRegistryIdException(net.geoprism.registry.InvalidRegistryIdException) VertexObject(com.runwaysdk.business.graph.VertexObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject)

Aggregations

VertexObject (com.runwaysdk.business.graph.VertexObject)53 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)29 GraphQuery (com.runwaysdk.business.graph.GraphQuery)28 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)23 EdgeObject (com.runwaysdk.business.graph.EdgeObject)20 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)18 LinkedList (java.util.LinkedList)10 ValueOverTime (com.runwaysdk.dataaccess.graph.attributes.ValueOverTime)9 MdAttributeDAOIF (com.runwaysdk.dataaccess.MdAttributeDAOIF)8 Date (java.util.Date)8 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)7 AbstractClassification (com.runwaysdk.system.AbstractClassification)7 HashedMap (org.apache.commons.collections4.map.HashedMap)7 JsonObject (com.google.gson.JsonObject)6 List (java.util.List)6 AttributeClassificationType (org.commongeoregistry.adapter.metadata.AttributeClassificationType)6 JsonArray (com.google.gson.JsonArray)5 MdEdgeDAOIF (com.runwaysdk.dataaccess.MdEdgeDAOIF)5 LineString (com.vividsolutions.jts.geom.LineString)5 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)5