Search in sources :

Example 26 with GraphQuery

use of com.runwaysdk.business.graph.GraphQuery in project geoprism-registry by terraframe.

the class SearchService method remove.

// @Transaction
public void remove(String code) {
    // String suffix = this.getSuffix();
    // 
    // MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(PACKAGE + "." +
    // VERTEX_PREFIX + suffix);
    // MdAttributeDAOIF mdCode = mdVertex.definesAttribute(CODE);
    // 
    // StringBuilder statement = new StringBuilder();
    // statement.append("DELETE VERTEX " + mdVertex.getDBClassName());
    // statement.append(" WHERE " + mdCode.getColumnName() + " = :code");
    // 
    // Map<String, Object> parameters = new HashMap<String, Object>();
    // parameters.put("code", code);
    // 
    // GraphDBService service = GraphDBService.getInstance();
    // GraphRequest request = service.getGraphDBRequest();
    // 
    // service.command(request, statement.toString(), parameters);
    String suffix = this.getSuffix();
    MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(PACKAGE + "." + VERTEX_PREFIX + suffix);
    MdAttributeDAOIF mdCode = mdVertex.definesAttribute(CODE);
    StringBuilder statement = new StringBuilder();
    statement.append("SELECT FROM " + mdVertex.getDBClassName());
    statement.append(" WHERE :code = " + mdCode.getColumnName());
    GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(statement.toString());
    query.setParameter("code", code);
    List<VertexObject> results = query.getResults();
    for (VertexObject result : results) {
        result.delete();
    }
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) VertexObject(com.runwaysdk.business.graph.VertexObject) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Example 27 with GraphQuery

use of com.runwaysdk.business.graph.GraphQuery in project geoprism-registry by terraframe.

the class ExternalSystem method getExternalSystemsForOrg.

public static List<ExternalSystem> getExternalSystemsForOrg(Integer pageNumber, Integer pageSize) {
    List<Organization> organizations = Organization.getUserAdminOrganizations();
    if (organizations.size() > 0) {
        final MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(ExternalSystem.CLASS);
        MdAttributeDAOIF oAttribute = mdVertex.definesAttribute(ExternalSystem.ORGANIZATION);
        StringBuilder builder = new StringBuilder();
        builder.append("SELECT FROM " + mdVertex.getDBClassName());
        for (int i = 0; i < organizations.size(); i++) {
            if (i == 0) {
                builder.append(" WHERE " + oAttribute.getColumnName() + " = :org" + i);
            } else {
                builder.append(" OR " + oAttribute.getColumnName() + " = :org" + i);
            }
        }
        builder.append(" ORDER BY id");
        builder.append(" SKIP " + ((pageNumber - 1) * pageSize) + " LIMIT " + pageSize);
        final GraphQuery<ExternalSystem> query = new GraphQuery<ExternalSystem>(builder.toString());
        for (int i = 0; i < organizations.size(); i++) {
            Organization organization = organizations.get(i);
            query.setParameter("org" + i, organization.getOid());
        }
        return query.getResults();
    }
    return new LinkedList<ExternalSystem>();
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) Organization(net.geoprism.registry.Organization) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) GraphQuery(com.runwaysdk.business.graph.GraphQuery) LinkedList(java.util.LinkedList)

Example 28 with GraphQuery

use of com.runwaysdk.business.graph.GraphQuery in project geoprism-registry by terraframe.

the class ExternalSystem method getByExternalSystemId.

public static ExternalSystem getByExternalSystemId(String id) {
    final MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(ExternalSystem.CLASS);
    MdAttributeDAOIF attribute = mdVertex.definesAttribute(ExternalSystem.ID);
    StringBuilder builder = new StringBuilder();
    builder.append("SELECT FROM " + mdVertex.getDBClassName());
    builder.append(" WHERE " + attribute.getColumnName() + " = :id");
    final GraphQuery<ExternalSystem> query = new GraphQuery<ExternalSystem>(builder.toString());
    query.setParameter("id", id);
    ExternalSystem es = query.getSingleResult();
    if (es == null) {
        net.geoprism.registry.DataNotFoundException ex = new net.geoprism.registry.DataNotFoundException();
        ex.setDataIdentifier(id);
        ex.setTypeLabel(mdVertex.getDisplayLabel(Session.getCurrentLocale()));
        ex.setAttributeLabel(attribute.getDisplayLabel(Session.getCurrentLocale()));
        throw ex;
    }
    return es;
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Example 29 with GraphQuery

use of com.runwaysdk.business.graph.GraphQuery in project geoprism-registry by terraframe.

the class ExternalSystem method getForOrganization.

public static List<ExternalSystem> getForOrganization(Organization organization) {
    final MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(ExternalSystem.CLASS);
    MdAttributeDAOIF oAttribute = mdVertex.definesAttribute(ExternalSystem.ORGANIZATION);
    StringBuilder builder = new StringBuilder();
    builder.append("SELECT FROM " + mdVertex.getDBClassName());
    builder.append(" WHERE " + oAttribute.getColumnName() + " = :org");
    builder.append(" ORDER BY id");
    final GraphQuery<ExternalSystem> query = new GraphQuery<ExternalSystem>(builder.toString());
    query.setParameter("org", organization.getOid());
    return query.getResults();
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Example 30 with GraphQuery

use of com.runwaysdk.business.graph.GraphQuery in project geoprism-registry by terraframe.

the class ExternalSystem method getCount.

public static long getCount() {
    List<Organization> organizations = Organization.getUserAdminOrganizations();
    if (organizations.size() > 0) {
        final MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(ExternalSystem.CLASS);
        MdAttributeDAOIF oAttribute = mdVertex.definesAttribute(ExternalSystem.ORGANIZATION);
        StringBuilder builder = new StringBuilder();
        builder.append("SELECT COUNT(*) FROM " + mdVertex.getDBClassName());
        for (int i = 0; i < organizations.size(); i++) {
            if (i == 0) {
                builder.append(" WHERE " + oAttribute.getColumnName() + " = :org" + i);
            } else {
                builder.append(" OR " + oAttribute.getColumnName() + " = :org" + i);
            }
        }
        final GraphQuery<Long> query = new GraphQuery<Long>(builder.toString());
        for (int i = 0; i < organizations.size(); i++) {
            Organization organization = organizations.get(i);
            query.setParameter("org" + i, organization.getOid());
        }
        return query.getSingleResult();
    }
    return 0L;
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) Organization(net.geoprism.registry.Organization) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Aggregations

GraphQuery (com.runwaysdk.business.graph.GraphQuery)55 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)34 VertexObject (com.runwaysdk.business.graph.VertexObject)29 MdAttributeDAOIF (com.runwaysdk.dataaccess.MdAttributeDAOIF)23 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)17 EdgeObject (com.runwaysdk.business.graph.EdgeObject)16 LineString (com.vividsolutions.jts.geom.LineString)11 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)11 LinkedList (java.util.LinkedList)11 JsonObject (com.google.gson.JsonObject)10 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)9 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)9 HashedMap (org.apache.commons.collections4.map.HashedMap)8 JsonArray (com.google.gson.JsonArray)7 MdEdgeDAOIF (com.runwaysdk.dataaccess.MdEdgeDAOIF)7 List (java.util.List)7 Page (net.geoprism.registry.view.Page)7 AbstractClassification (com.runwaysdk.system.AbstractClassification)6 HashMap (java.util.HashMap)6 Collectors (java.util.stream.Collectors)6