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