Search in sources :

Example 16 with MdAttributeDAOIF

use of com.runwaysdk.dataaccess.MdAttributeDAOIF 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 17 with MdAttributeDAOIF

use of com.runwaysdk.dataaccess.MdAttributeDAOIF 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 18 with MdAttributeDAOIF

use of com.runwaysdk.dataaccess.MdAttributeDAOIF 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 19 with MdAttributeDAOIF

use of com.runwaysdk.dataaccess.MdAttributeDAOIF 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)

Example 20 with MdAttributeDAOIF

use of com.runwaysdk.dataaccess.MdAttributeDAOIF in project geoprism-registry by terraframe.

the class Transition method removeAll.

@Transaction
public static void removeAll(ServerGeoObjectType type) {
    MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(Transition.CLASS);
    MdAttributeDAOIF sourceAttribute = mdVertex.definesAttribute(Transition.SOURCE);
    MdAttributeDAOIF targetAttribute = mdVertex.definesAttribute(Transition.TARGET);
    StringBuilder statement = new StringBuilder();
    statement.append("SELECT FROM " + mdVertex.getDBClassName());
    statement.append(" WHERE " + sourceAttribute.getColumnName() + ".@class = :vertexClass");
    statement.append(" OR " + targetAttribute.getColumnName() + ".@class = :vertexClass");
    GraphQuery<Transition> query = new GraphQuery<Transition>(statement.toString());
    query.setParameter("vertexClass", type.getMdVertex().getDBClassName());
    List<Transition> results = query.getResults();
    results.forEach(event -> event.delete());
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) GraphQuery(com.runwaysdk.business.graph.GraphQuery) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Aggregations

MdAttributeDAOIF (com.runwaysdk.dataaccess.MdAttributeDAOIF)32 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)24 GraphQuery (com.runwaysdk.business.graph.GraphQuery)23 VertexObject (com.runwaysdk.business.graph.VertexObject)9 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)9 JsonObject (com.google.gson.JsonObject)7 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)7 LinkedList (java.util.LinkedList)7 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)7 Date (java.util.Date)5 JsonArray (com.google.gson.JsonArray)4 HashMap (java.util.HashMap)4 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)4 MdVertexDAO (com.runwaysdk.dataaccess.metadata.graph.MdVertexDAO)3 Page (net.geoprism.registry.view.Page)3 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)3 GsonBuilder (com.google.gson.GsonBuilder)2 MdAttributeTermDAOIF (com.runwaysdk.dataaccess.MdAttributeTermDAOIF)2 MdEdgeDAOIF (com.runwaysdk.dataaccess.MdEdgeDAOIF)2 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)2