use of com.runwaysdk.business.graph.VertexObject in project geoprism-registry by terraframe.
the class VertexGeoObjectQuery method getSingleResult.
public ServerGeoObjectIF getSingleResult() {
GraphQuery<VertexObject> query = this.getQuery();
VertexObject vertex = query.getSingleResult();
if (vertex != null) {
return new VertexServerGeoObject(type, vertex, this.date);
}
return null;
}
use of com.runwaysdk.business.graph.VertexObject in project geoprism-registry by terraframe.
the class SearchService method search.
public List<ServerGeoObjectIF> search(String text, Date date, Long limit) {
String suffix = this.getSuffix();
RolePermissionService service = new RolePermissionService();
MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(PACKAGE + "." + VERTEX_PREFIX + suffix);
MdAttributeDAOIF code = mdVertex.definesAttribute(CODE);
MdAttributeDAOIF startDate = mdVertex.definesAttribute(START_DATE);
MdAttributeDAOIF endDate = mdVertex.definesAttribute(END_DATE);
MdAttributeDAOIF label = mdVertex.definesAttribute(LABEL);
MdAttributeDAOIF vertexType = mdVertex.definesAttribute(VERTEX_TYPE);
MdEdgeDAOIF mdEdge = MdEdgeDAO.getMdEdgeDAO(PACKAGE + "." + EDGE_PREFIX + suffix);
String attributeName = label.getValue(MdAttributeTextInfo.NAME);
String className = mdVertex.getDBClassName();
String indexName = className + "." + attributeName;
StringBuilder statement = new StringBuilder();
statement.append("SELECT EXPAND(out('" + mdEdge.getDBClassName() + "'))");
statement.append(" FROM " + mdVertex.getDBClassName());
if (text != null) {
String regex = "([+\\-!\\(\\){}\\[\\]^\"~*?:\\\\]|[&\\|]{2})";
String escapedText = text.replaceAll(regex, "\\\\\\\\$1").trim();
statement.append(" WHERE (SEARCH_INDEX(\"" + indexName + "\", \"+" + label.getColumnName() + ":" + escapedText + "*\") = true");
statement.append(" OR :code = " + code.getColumnName() + ")");
} else {
statement.append(" WHERE " + code.getColumnName() + " IS NOT NULL");
}
if (date != null) {
statement.append(" AND :date BETWEEN " + startDate.getColumnName() + " AND " + endDate.getColumnName());
}
if (!service.isSRA() && service.hasSessionUser()) {
statement.append(" AND " + vertexType.getColumnName() + " IN ( :vertexTypes )");
}
statement.append(" ORDER BY " + label.getColumnName() + " DESC");
if (limit != null) {
statement.append(" LIMIT " + limit);
}
List<ServerGeoObjectIF> list = new LinkedList<ServerGeoObjectIF>();
GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(statement.toString());
if (text != null) {
query.setParameter("code", text);
}
if (date != null) {
query.setParameter("date", date);
}
if (!service.isSRA() && service.hasSessionUser()) {
List<String> vertexTypes = new GeoObjectPermissionService().getMandateTypes(service.getOrganization());
query.setParameter("vertexTypes", vertexTypes);
}
List<VertexObject> results = query.getResults();
for (VertexObject result : results) {
MdVertexDAOIF mdVertexType = (MdVertexDAOIF) result.getMdClass();
ServerGeoObjectType type = ServerGeoObjectType.get(mdVertexType);
list.add(new VertexServerGeoObject(type, result, date));
}
return list;
}
use of com.runwaysdk.business.graph.VertexObject in project geoprism-registry by terraframe.
the class TestGeoObjectInfo method deleteInTrans.
// @Transaction
// private void deleteInTrans()
// {
// if (this.testDataSet.debugMode >= 1)
// {
// System.out.println("Deleting TestGeoObjectInfo [" + this.getCode() + "].");
// }
//
// ServerGeoObjectIF serverGO = this.getServerObject();
//
// if (serverGO != null)
// {
// serverGO.delete();
// }
//
// this.children.clear();
//
// this.business = null;
// this.geoEntity = null;
// }
//
// private ServerGeoObjectIF getServerObject()
// {
//
// }
@Transaction
private void deleteInTrans() {
// geoEntity it nulls out the reference in the table.
if (this.getGeoObjectType() != null && this.getGeoObjectType().getUniversal() != null) {
QueryFactory qf = new QueryFactory();
BusinessQuery bq = qf.businessQuery(this.getGeoObjectType().getUniversal().getMdBusiness().definesType());
bq.WHERE(bq.aCharacter(DefaultAttribute.CODE.getName()).EQ(this.getCode()));
OIterator<? extends Business> bit = bq.getIterator();
try {
while (bit.hasNext()) {
Business biz = bit.next();
biz.delete();
}
} finally {
bit.close();
}
}
TestDataSet.deleteGeoEntity(this.getCode());
// if (this.serverGO instanceof CompositeServerGeoObject)
// {
// ((CompositeServerGeoObject)this.serverGO).getVertex().getVertex().delete();
// }
// else if (this.serverGO instanceof VertexServerGeoObject)
// {
// ((VertexServerGeoObject)this.serverGO).getVertex().delete();
// }
ServerGeoObjectType serverGOTT = this.geoObjectType.getServerObject();
if (serverGOTT != null) {
VertexObject vertex = VertexServerGeoObject.getVertexByCode(serverGOTT, this.getCode());
if (vertex != null) {
vertex.delete();
}
}
this.children.clear();
this.isNew = true;
}
Aggregations