Search in sources :

Example 51 with VertexObject

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;
}
Also used : VertexObject(com.runwaysdk.business.graph.VertexObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject)

Example 52 with VertexObject

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;
}
Also used : RolePermissionService(net.geoprism.registry.permission.RolePermissionService) MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) MdEdgeDAOIF(com.runwaysdk.dataaccess.MdEdgeDAOIF) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) VertexObject(com.runwaysdk.business.graph.VertexObject) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) LinkedList(java.util.LinkedList) GeoObjectPermissionService(net.geoprism.registry.permission.GeoObjectPermissionService) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Example 53 with VertexObject

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;
}
Also used : BusinessQuery(com.runwaysdk.business.BusinessQuery) QueryFactory(com.runwaysdk.query.QueryFactory) VertexObject(com.runwaysdk.business.graph.VertexObject) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Business(com.runwaysdk.business.Business) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Aggregations

VertexObject (com.runwaysdk.business.graph.VertexObject)53 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)29 GraphQuery (com.runwaysdk.business.graph.GraphQuery)28 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)23 EdgeObject (com.runwaysdk.business.graph.EdgeObject)20 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)18 LinkedList (java.util.LinkedList)10 ValueOverTime (com.runwaysdk.dataaccess.graph.attributes.ValueOverTime)9 MdAttributeDAOIF (com.runwaysdk.dataaccess.MdAttributeDAOIF)8 Date (java.util.Date)8 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)7 AbstractClassification (com.runwaysdk.system.AbstractClassification)7 HashedMap (org.apache.commons.collections4.map.HashedMap)7 JsonObject (com.google.gson.JsonObject)6 List (java.util.List)6 AttributeClassificationType (org.commongeoregistry.adapter.metadata.AttributeClassificationType)6 JsonArray (com.google.gson.JsonArray)5 MdEdgeDAOIF (com.runwaysdk.dataaccess.MdEdgeDAOIF)5 LineString (com.vividsolutions.jts.geom.LineString)5 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)5