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);
}
}
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;
}
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;
}
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;
}
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);
}
}
Aggregations