Search in sources :

Example 6 with VertexServerGeoObject

use of net.geoprism.registry.model.graph.VertexServerGeoObject 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 7 with VertexServerGeoObject

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

the class PatchExistsAndInvalidInstanceData method patchInstanceData.

private void patchInstanceData() {
    List<Universal> unis = PatchExistsAndInvalid.getUniversals();
    int applied = 0;
    for (Universal uni : unis) {
        ServerGeoObjectType type = new ServerGeoObjectTypeConverter().build(uni);
        MdGraphClassDAOIF mdClass = type.getMdVertex();
        List<VertexServerGeoObject> data = getInstanceData(type, mdClass);
        int current = 0;
        final int size = data.size();
        logger.info("Starting to patch instance data for type [" + mdClass.getDBClassName() + "] with count [" + size + "] ");
        for (VertexServerGeoObject go : data) {
            ValueOverTime defaultExists = go.buildDefaultExists();
            if (defaultExists != null) {
                go.setValue(DefaultAttribute.EXISTS.getName(), Boolean.TRUE, defaultExists.getStartDate(), defaultExists.getEndDate());
                go.setValue(DefaultAttribute.INVALID.getName(), false);
                // This apply method is mega slow due to the SearchService so we're going to just bypass it
                // go.apply(false);
                go.getVertex().setValue(GeoVertex.LASTUPDATEDATE, new Date());
                go.getVertex().apply();
                applied++;
            }
            if (current % 100 == 0) {
                logger.info("Finished record " + current + " of " + size);
            }
            current++;
        }
    }
    logger.info("Applied " + applied + " records across " + unis.size() + " types.");
}
Also used : ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) Universal(com.runwaysdk.system.gis.geo.Universal) ServerGeoObjectTypeConverter(net.geoprism.registry.conversion.ServerGeoObjectTypeConverter) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) MdGraphClassDAOIF(com.runwaysdk.dataaccess.MdGraphClassDAOIF) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) Date(java.util.Date)

Example 8 with VertexServerGeoObject

use of net.geoprism.registry.model.graph.VertexServerGeoObject 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)

Example 9 with VertexServerGeoObject

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

the class DHIS2SynchronizationManager method query.

private List<VertexServerGeoObject> query(ServerGeoObjectType got, long skip, long pageSize) {
    MdVertexDAOIF mdVertex = got.getMdVertex();
    MdAttributeDAOIF mdAttribute = MdAttributeDAO.getByKey(GeoVertex.CLASS + "." + GeoVertex.LASTUPDATEDATE);
    StringBuilder statement = new StringBuilder();
    statement.append("SELECT FROM " + mdVertex.getDBClassName());
    statement.append(" ORDER BY " + mdAttribute.getColumnName() + ", oid ASC");
    statement.append(" SKIP " + skip + " LIMIT " + pageSize);
    GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(statement.toString());
    List<VertexObject> vObjects = query.getResults();
    List<VertexServerGeoObject> response = new LinkedList<VertexServerGeoObject>();
    for (VertexObject vObject : vObjects) {
        VertexServerGeoObject vSGO = new VertexServerGeoObject(got, vObject);
        vSGO.setDate(this.date);
        response.add(vSGO);
    }
    return response;
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) VertexObject(com.runwaysdk.business.graph.VertexObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) GraphQuery(com.runwaysdk.business.graph.GraphQuery) LinkedList(java.util.LinkedList)

Example 10 with VertexServerGeoObject

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

the class DHIS2AttributeMapping method writeStandardAttributes.

public void writeStandardAttributes(VertexServerGeoObject serverGo, JsonObject jo, DHIS2SyncConfig dhis2Config, DHIS2SyncLevel level) {
    if (this.isStandardAttribute()) {
        ServerGeoObjectType got = level.getGeoObjectType();
        AttributeType attr = got.getAttribute(this.getCgrAttrName()).get();
        Object value = serverGo.getValue(attr.getName());
        if (value == null || (value instanceof String && ((String) value).length() == 0)) {
            return;
        }
        this.writeAttributeValue(attr, this.dhis2AttrName, value, jo);
    }
}
Also used : ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) JsonObject(com.google.gson.JsonObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject)

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