Search in sources :

Example 11 with VertexServerGeoObject

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

the class DHIS2AttributeMapping method writeCustomAttributes.

public void writeCustomAttributes(JsonArray attributeValues, VertexServerGeoObject serverGo, DHIS2SyncConfig dhis2Config, DHIS2SyncLevel syncLevel, String lastUpdateDate, String createDate) {
    if (this.isCustomAttribute()) {
        ServerGeoObjectType got = syncLevel.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;
        }
        JsonObject av = new JsonObject();
        av.addProperty("lastUpdated", lastUpdateDate);
        av.addProperty("created", createDate);
        this.writeAttributeValue(attr, "value", value, av);
        JsonObject joAttr = new JsonObject();
        joAttr.addProperty("id", this.getExternalId());
        av.add("attribute", joAttr);
        attributeValues.add(av);
    }
}
Also used : ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) JsonObject(com.google.gson.JsonObject) JsonObject(com.google.gson.JsonObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject)

Example 12 with VertexServerGeoObject

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

the class GeoObjectJsonExporter method query.

public List<VertexServerGeoObject> query() {
    MdVertexDAOIF mdVertex = got.getMdVertex();
    MdAttributeDAOIF mdAttribute = MdAttributeDAO.getByKey(GeoVertex.CLASS + "." + GeoVertex.LASTUPDATEDATE);
    StringBuilder statement = new StringBuilder();
    statement.append("SELECT FROM " + mdVertex.getDBClassName());
    if (this.since != null) {
        statement.append(" WHERE " + mdAttribute.getColumnName() + " >= :lastUpdateDate");
    }
    statement.append(" ORDER BY " + mdAttribute.getColumnName() + ", oid ASC");
    if (this.pageSize != null && this.pageNumber != null && this.pageSize != -1 && this.pageNumber != -1) {
        statement.append(" SKIP " + ((pageNumber - 1) * pageSize) + " LIMIT " + this.pageSize);
    }
    GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(statement.toString());
    if (this.since != null) {
        query.setParameter("lastUpdateDate", this.since);
    }
    List<VertexObject> vObjects = query.getResults();
    List<VertexServerGeoObject> response = new LinkedList<VertexServerGeoObject>();
    for (VertexObject vObject : vObjects) {
        VertexServerGeoObject vSGO = new VertexServerGeoObject(got, vObject);
        vSGO.setDate(ValueOverTime.INFINITY_END_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 13 with VertexServerGeoObject

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

the class GeoObjectJsonExporter method export.

/*
   * This code is necessary if doing a DHIS2 export. But it's not used anymore
   * because the DHIS2 exporter does it's own serialization now.
   * 
   * TODO : Abstraction is leaking here. Maybe pass in a config object which
   * contains this extra stuff we need?
   */
// public void setDHIS2Facade(DHIS2Facade dhis2)
// {
// this.dhis2 = dhis2;
// }
// 
// public void setSyncLevel(SyncLevel syncLevel)
// {
// this.syncLevel = syncLevel;
// }
public JsonObject export() throws IOException {
    JsonObject jo = new JsonObject();
    JsonArray results = new JsonArray();
    this.total = this.count();
    List<VertexServerGeoObject> objects = this.query();
    for (VertexServerGeoObject object : objects) {
        results.add(this.exportObject(object));
    }
    jo.add("results", results);
    JsonObject page = new JsonObject();
    page.addProperty("pageSize", this.pageSize);
    page.addProperty("pageNumber", this.pageNumber);
    page.addProperty("total", this.count());
    jo.add("page", page);
    return jo;
}
Also used : JsonArray(com.google.gson.JsonArray) JsonObject(com.google.gson.JsonObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject)

Example 14 with VertexServerGeoObject

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

the class ServerGeoObjectService method doesGeoObjectExistAtRange.

@Request(RequestType.SESSION)
public JsonObject doesGeoObjectExistAtRange(String sessionId, Date startDate, Date endDate, String typeCode, String code) {
    VertexServerGeoObject vsgo = (VertexServerGeoObject) new ServerGeoObjectService().getGeoObjectByCode(code, typeCode);
    JsonObject jo = new JsonObject();
    jo.addProperty("exists", vsgo.existsAtRange(startDate, endDate));
    jo.addProperty("invalid", vsgo.getInvalid());
    return jo;
}
Also used : JsonObject(com.google.gson.JsonObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) Request(com.runwaysdk.session.Request) ChangeRequest(net.geoprism.registry.action.ChangeRequest)

Example 15 with VertexServerGeoObject

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

the class BusinessObject method setGeoObject.

public void setGeoObject(ServerGeoObjectIF geoObject) {
    if (geoObject instanceof VertexServerGeoObject) {
        VertexObject geoVertex = ((VertexServerGeoObject) geoObject).getVertex();
        this.vertex.setValue(BusinessType.GEO_OBJECT, geoVertex);
    }
}
Also used : VertexObject(com.runwaysdk.business.graph.VertexObject) 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