use of com.runwaysdk.dataaccess.MdVertexDAOIF in project geoprism-registry by terraframe.
the class AbstractGraphPageQuery method getPage.
public Page<T> getPage() {
int pageSize = 10;
int pageNumber = 1;
Long count = this.getCount();
final MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(this.type);
StringBuilder statement = new StringBuilder();
statement.append("SELECT ");
this.addSelectAttributes(mdVertex, statement);
statement.append(" FROM " + mdVertex.getDBClassName() + "");
Map<String, Object> parameters = new HashMap<String, Object>();
if (criteria.has("filters")) {
JsonObject filters = criteria.get("filters").getAsJsonObject();
this.addCriteria(mdVertex, filters, statement, parameters);
}
if (criteria.has("sortField") && criteria.has("sortOrder")) {
String field = criteria.get("sortField").getAsString();
SortOrder order = criteria.get("sortOrder").getAsInt() == 1 ? SortOrder.ASC : SortOrder.DESC;
MdAttributeDAOIF mdAttribute = mdVertex.definesAttribute(field);
statement.append(" ORDER BY " + this.getColumnName(mdAttribute) + " " + order.name());
} else if (criteria.has("multiSortMeta")) {
JsonArray sorts = criteria.get("multiSortMeta").getAsJsonArray();
for (int i = 0; i < sorts.size(); i++) {
JsonObject sort = sorts.get(i).getAsJsonObject();
String field = sort.get("field").getAsString();
SortOrder order = sort.get("order").getAsInt() == 1 ? SortOrder.ASC : SortOrder.DESC;
MdAttributeDAOIF mdAttribute = mdVertex.definesAttribute(field);
if (i == 0) {
statement.append(" ORDER BY " + this.getColumnName(mdAttribute) + " " + order.name());
} else {
statement.append(", " + this.getColumnName(mdAttribute) + " " + order.name());
}
}
}
if (criteria.has("first") && criteria.has("rows")) {
int first = criteria.get("first").getAsInt();
int rows = criteria.get("rows").getAsInt();
statement.append(" SKIP " + first + " LIMIT " + rows);
pageNumber = (first / rows) + 1;
}
final GraphQuery<K> query = new GraphQuery<K>(statement.toString(), parameters);
return new Page<T>(count, pageNumber, pageSize, this.getResults(query));
}
use of com.runwaysdk.dataaccess.MdVertexDAOIF in project geoprism-registry by terraframe.
the class LocationService method getGeoObjects.
// @Request(RequestType.SESSION)
// public LocationInformation getLocationInformation(String sessionId, String code, String typeCode, Date date, String childTypeCode, String hierarchyCode)
// {
// LocationInformation information = new LocationInformation();
//
// ServerGeoObjectIF go = this.service.getGeoObjectByCode(code, typeCode);
// go.setDate(date);
//
// ServerGeoObjectType type = go.getType();
// List<ServerHierarchyType> hierarchies = type.getHierarchies();
//
// ServerHierarchyType hierarchy = null;
//
// if (hierarchyCode == null || hierarchyCode.length() == 0)
// {
// hierarchy = hierarchies.get(0);
// }
// else
// {
// hierarchy = ServerHierarchyType.get(hierarchyCode);
// }
//
// List<ServerGeoObjectType> childTypes = type.getChildren(hierarchy);
// ServerGeoObjectType childType = null;
//
// if (childTypes.size() > 0)
// {
// /*
// * If a typeCode is given and it is an option based on the hierarchy than
// * use that type otherwise use the first type code
// */
// childType = childTypes.get(0);
//
// if (childTypeCode != null && childTypeCode.length() > 0)
// {
// for (ServerGeoObjectType child : childTypes)
// {
// if (child.getCode().equals(childTypeCode))
// {
// childType = child;
// }
// }
// }
// }
//
// if (childType != null)
// {
// information.setChildType(childType.getType());
//
// List<VertexServerGeoObject> children = this.getGeoObjects(go.getCode(), childType.getCode(), hierarchy.getCode(), date);
//
// for (VertexServerGeoObject child : children)
// {
// information.addChild(child.toGeoObject());
// }
// }
//
// information.setChildTypes(childTypes);
// information.setHierarchies(hierarchies);
// information.setHierarchy(hierarchy.getCode());
// information.setEntity(go.toGeoObject());
//
// return information;
// }
// @Request(RequestType.SESSION)
// public JsonObject getChildrenGeoJson(String sessionId, String typeCode,
// String parentId, String hierarchyCode)
// {
// List<VertexServerGeoObject> children = parentId != null ?
// this.getGeoObjects(typeCode, parentId, hierarchyCode) :
// this.getGeoObjects(typeCode);
//
// return children;
// }
private List<VertexServerGeoObject> getGeoObjects(String typeCode, Date date) {
ServerGeoObjectType type = ServerGeoObjectType.get(typeCode);
MdVertexDAOIF mdVertex = type.getMdVertex();
StringBuilder statement = new StringBuilder();
statement.append("SELECT FROM " + mdVertex.getDBClassName());
statement.append(" ORDER BY code");
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(type, vObject);
vSGO.setDate(date);
response.add(vSGO);
}
return response;
}
use of com.runwaysdk.dataaccess.MdVertexDAOIF in project geoprism-registry by terraframe.
the class SearchService method clear.
@Transaction
public void clear() {
String suffix = this.getSuffix();
MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(PACKAGE + "." + VERTEX_PREFIX + suffix);
StringBuilder statement = new StringBuilder();
statement.append("DELETE VERTEX " + mdVertex.getDBClassName());
GraphDBService service = GraphDBService.getInstance();
GraphRequest request = service.getGraphDBRequest();
service.command(request, statement.toString(), new HashMap<>());
}
use of com.runwaysdk.dataaccess.MdVertexDAOIF in project geoprism-registry by terraframe.
the class SearchService method deleteSearchTable.
@Transaction
public void deleteSearchTable() {
String suffix = this.getSuffix();
MdEdgeDAOIF mdEdge = MdEdgeDAO.getMdEdgeDAO(PACKAGE + "." + EDGE_PREFIX + suffix);
mdEdge.getBusinessDAO().delete();
MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(PACKAGE + "." + VERTEX_PREFIX + suffix);
mdVertex.getBusinessDAO().delete();
}
use of com.runwaysdk.dataaccess.MdVertexDAOIF in project geoprism-registry by terraframe.
the class SearchService method clear.
// @Transaction
public void clear(String vertexType) {
String suffix = this.getSuffix();
MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(PACKAGE + "." + VERTEX_PREFIX + suffix);
MdAttributeDAOIF mdVertexType = mdVertex.definesAttribute(VERTEX_TYPE);
StringBuilder statement = new StringBuilder();
statement.append("DELETE VERTEX " + mdVertex.getDBClassName());
statement.append(" WHERE " + mdVertexType.getColumnName() + " = :vertexType");
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("vertexType", vertexType);
GraphDBService service = GraphDBService.getInstance();
GraphRequest request = service.getGraphDBRequest();
GraphRequest ddlRequest = service.getDDLGraphDBRequest();
service.ddlCommand(request, ddlRequest, statement.toString(), parameters);
}
Aggregations