Search in sources :

Example 31 with VertexObject

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

the class CRAttributePatch method patchAllGos.

private void patchAllGos() {
    for (Universal uni : getUniversals()) {
        MdGeoVertexDAO mdVertex = GeoVertexType.getMdGeoVertex(uni.getUniversalId());
        List<? extends MdAttributeDAOIF> attributes = mdVertex.getAllDefinedMdAttributes();
        String[] skipAttrs = new String[] { DefaultAttribute.UID.getName(), "uuid", DefaultAttribute.CODE.getName(), DefaultAttribute.CREATE_DATE.getName(), DefaultAttribute.LAST_UPDATE_DATE.getName(), DefaultAttribute.SEQUENCE.getName(), DefaultAttribute.TYPE.getName(), MdAttributeConcreteInfo.OID, MdAttributeConcreteInfo.SEQUENCE };
        StringBuilder statement = new StringBuilder();
        statement.append("SELECT FROM " + mdVertex.getDBClassName());
        GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(statement.toString());
        List<VertexObject> results = query.getResults();
        logger.info("Updating [" + results.size() + "] objects on table [" + mdVertex.getDBClassName() + "].");
        for (VertexObject vo : query.getResults()) {
            for (MdAttributeDAOIF attr : attributes) {
                if (!ArrayUtils.contains(skipAttrs, attr.definesAttribute())) {
                    ValueOverTimeCollection col = vo.getValuesOverTime(attr.definesAttribute());
                    for (ValueOverTime vot : col) {
                        vot.setOid(UUID.randomUUID().toString());
                    }
                }
            }
            vo.apply();
        }
    }
}
Also used : Universal(com.runwaysdk.system.gis.geo.Universal) VertexObject(com.runwaysdk.business.graph.VertexObject) ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) ValueOverTimeCollection(com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection) MdGeoVertexDAO(com.runwaysdk.gis.dataaccess.metadata.graph.MdGeoVertexDAO) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Example 32 with VertexObject

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

the class SearchTablePatch method createRecords.

@Transaction
public void createRecords(SearchService service) {
    MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(GeoVertex.CLASS);
    long pageSize = 1000;
    long skip = 0;
    int count = 0;
    do {
        StringBuilder builder = new StringBuilder();
        builder.append("SELECT FROM " + mdVertex.getDBClassName());
        builder.append(" ORDER BY oid");
        builder.append(" SKIP " + skip + " LIMIT " + pageSize);
        GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(builder.toString());
        List<VertexObject> results = query.getResults();
        for (VertexObject result : results) {
            ServerGeoObjectType type = ServerGeoObjectType.get((MdVertexDAOIF) result.getMdClass());
            service.insert(new VertexServerGeoObject(type, result));
        }
        skip += pageSize;
        count = results.size();
    } while (count > 0);
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) 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) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 33 with VertexObject

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

the class VertexGeoObjectStrategy method constructFromGeoObject.

@Override
public VertexServerGeoObject constructFromGeoObject(GeoObject geoObject, boolean isNew) {
    if (!isNew) {
        VertexObject vertex = VertexServerGeoObject.getVertex(type, geoObject.getUid());
        if (vertex == null) {
            InvalidRegistryIdException ex = new InvalidRegistryIdException();
            ex.setRegistryId(geoObject.getUid());
            throw ex;
        }
        return new VertexServerGeoObject(type, vertex);
    } else {
        if (!RegistryIdService.getInstance().isIssuedId(geoObject.getUid())) {
            InvalidRegistryIdException ex = new InvalidRegistryIdException();
            ex.setRegistryId(geoObject.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)

Example 34 with VertexObject

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

the class BusinessObjectImporter method setClassificationValue.

protected void setClassificationValue(BusinessObject entity, AttributeType attributeType, String attributeName, Object value) {
    if (!this.configuration.isExclusion(attributeName, value.toString())) {
        try {
            BusinessType type = this.configuration.getType();
            MdVertexDAOIF mdBusiness = type.getMdVertexDAO();
            MdAttributeClassificationDAOIF mdAttribute = (MdAttributeClassificationDAOIF) mdBusiness.definesAttribute(attributeName);
            VertexObject classifier = AbstractClassification.findMatchingClassification(value.toString().trim(), mdAttribute);
            if (classifier == null) {
                throw new UnknownTermException(value.toString().trim(), attributeType);
            } else {
                entity.setValue(attributeName, classifier.getOid());
            }
        } catch (UnknownTermException e) {
            TermValueException ex = new TermValueException();
            ex.setAttributeLabel(e.getAttribute().getLabel().getValue());
            ex.setCode(e.getCode());
            throw e;
        }
    }
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) TermValueException(net.geoprism.registry.io.TermValueException) VertexObject(com.runwaysdk.business.graph.VertexObject) BusinessType(net.geoprism.registry.BusinessType) MdAttributeClassificationDAOIF(com.runwaysdk.dataaccess.MdAttributeClassificationDAOIF) UnknownTermException(org.commongeoregistry.adapter.dataaccess.UnknownTermException)

Example 35 with VertexObject

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

the class ServerGeoObjectService method build.

public ServerGeoObjectIF build(ServerGeoObjectType type, String runwayId) {
    ServerGeoObjectStrategyIF strategy = this.getStrategy(type);
    VertexObject vertex = VertexObject.get(type.getMdVertex(), runwayId);
    return strategy.constructFromDB(vertex);
}
Also used : VertexObject(com.runwaysdk.business.graph.VertexObject) ServerGeoObjectStrategyIF(net.geoprism.registry.conversion.ServerGeoObjectStrategyIF)

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