Search in sources :

Example 86 with QueryFactory

use of com.runwaysdk.query.QueryFactory in project geoprism-registry by terraframe.

the class ListTypeVersion method bbox.

public JsonArray bbox(String uid) {
    MdBusinessDAOIF mdBusiness = MdBusinessDAO.get(this.getMdBusinessOid());
    String tableName = mdBusiness.getTableName();
    // collect all the views and extend the bounding box
    ValueQuery union = new ValueQuery(new QueryFactory());
    union.SELECT(union.aSQLClob(GeoserverFacade.GEOM_COLUMN, GeoserverFacade.GEOM_COLUMN, GeoserverFacade.GEOM_COLUMN));
    union.FROM(tableName, tableName);
    if (uid != null && uid.length() > 0) {
        MdAttributeConcreteDAOIF attribute = mdBusiness.definesAttribute(DefaultAttribute.UID.getName());
        String columName = attribute.getColumnName();
        union.WHERE(union.aSQLCharacter(columName, columName).EQ(uid));
    }
    ValueQuery collected = new ValueQuery(union.getQueryFactory());
    collected.SELECT(collected.aSQLAggregateClob("collected", "st_collect(" + GeoserverFacade.GEOM_COLUMN + ")", "collected"));
    collected.FROM("(" + union.getSQL() + ")", "unioned");
    ValueQuery outer = new ValueQuery(union.getQueryFactory());
    outer.SELECT(union.aSQLAggregateDouble("minx", "st_xmin(collected)"), union.aSQLAggregateDouble("miny", "st_ymin(collected)"), union.aSQLAggregateDouble("maxx", "st_xmax(collected)"), union.aSQLAggregateDouble("maxy", "st_ymax(collected)"));
    outer.FROM("(" + collected.getSQL() + ")", "collected");
    try (OIterator<? extends ValueObject> iter = outer.getIterator()) {
        ValueObject o = iter.next();
        try {
            JsonArray bboxArr = new JsonArray();
            bboxArr.add(Double.parseDouble(o.getValue("minx")));
            bboxArr.add(Double.parseDouble(o.getValue("miny")));
            bboxArr.add(Double.parseDouble(o.getValue("maxx")));
            bboxArr.add(Double.parseDouble(o.getValue("maxy")));
            return bboxArr;
        } catch (JSONException ex) {
            throw new ProgrammingErrorException(ex);
        }
    } catch (Exception e) {
        return null;
    // throw new NoLayerDataException();
    }
}
Also used : ValueQuery(com.runwaysdk.query.ValueQuery) JsonArray(com.google.gson.JsonArray) MdBusinessDAOIF(com.runwaysdk.dataaccess.MdBusinessDAOIF) QueryFactory(com.runwaysdk.query.QueryFactory) JSONException(org.json.JSONException) MdAttributeMultiLineString(com.runwaysdk.system.gis.metadata.MdAttributeMultiLineString) MdAttributeLineString(com.runwaysdk.system.gis.metadata.MdAttributeLineString) ValueObject(com.runwaysdk.dataaccess.ValueObject) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) JSONException(org.json.JSONException) IOException(java.io.IOException) DataNotFoundException(com.runwaysdk.dataaccess.cache.DataNotFoundException) ParseException(java.text.ParseException) UnsupportedOperationException(com.amazonaws.services.kms.model.UnsupportedOperationException) FileNotFoundException(java.io.FileNotFoundException) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) MdAttributeConcreteDAOIF(com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF)

Example 87 with QueryFactory

use of com.runwaysdk.query.QueryFactory in project geoprism-registry by terraframe.

the class ListTypeVersion method buildQuery.

public BusinessQuery buildQuery(String filterJson) {
    MdBusinessDAOIF mdBusiness = MdBusinessDAO.get(this.getMdBusinessOid());
    BusinessQuery query = new QueryFactory().businessQuery(mdBusiness.definesType());
    Map<MdAttributeConcreteDAOIF, Condition> conditionMap = this.buildQueryConditionsFromFilter(filterJson, null, query, mdBusiness);
    for (Condition condition : conditionMap.values()) {
        query.WHERE(condition);
    }
    return query;
}
Also used : BusinessQuery(com.runwaysdk.business.BusinessQuery) Condition(com.runwaysdk.query.Condition) BasicCondition(com.runwaysdk.query.BasicCondition) MdBusinessDAOIF(com.runwaysdk.dataaccess.MdBusinessDAOIF) QueryFactory(com.runwaysdk.query.QueryFactory) MdAttributeConcreteDAOIF(com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF)

Example 88 with QueryFactory

use of com.runwaysdk.query.QueryFactory in project geoprism-registry by terraframe.

the class ListTypeVersion method values.

public JsonArray values(String value, String attributeName, JsonObject criteria) {
    ValueQuery vQuery = new ValueQuery(new QueryFactory());
    BusinessQuery query = new ListTypeVersionPageQuery(this, criteria, true, false).getQuery(vQuery);
    DateFormat filterFormat = new SimpleDateFormat(GeoObjectImportConfiguration.DATE_FORMAT);
    filterFormat.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
    JsonArray results = new JsonArray();
    vQuery.SELECT_DISTINCT(query.get(attributeName, "label"));
    vQuery.FROM(query);
    if (value != null && value.length() > 0) {
        vQuery.WHERE(F.UPPER(query.aCharacter(attributeName)).LIKEi("%" + value.toUpperCase() + "%"));
    }
    try (OIterator<ValueObject> it = vQuery.getIterator(100, 1)) {
        while (it.hasNext()) {
            ValueObject vObject = it.next();
            results.add(vObject.getValue("label"));
        // JsonObject result = new JsonObject();
        // result.addProperty("label", vObject.getValue("label"));
        // result.addProperty("value", vObject.getValue("value"));
        // 
        // results.add(result);
        }
    }
    return results;
}
Also used : ValueQuery(com.runwaysdk.query.ValueQuery) BusinessQuery(com.runwaysdk.business.BusinessQuery) JsonArray(com.google.gson.JsonArray) QueryFactory(com.runwaysdk.query.QueryFactory) ListTypeVersionPageQuery(net.geoprism.registry.query.ListTypeVersionPageQuery) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) ValueObject(com.runwaysdk.dataaccess.ValueObject) SimpleDateFormat(java.text.SimpleDateFormat)

Example 89 with QueryFactory

use of com.runwaysdk.query.QueryFactory in project geoprism-registry by terraframe.

the class MasterList method create.

@Transaction
public static MasterList create(JsonObject object) {
    MasterList list = MasterList.fromJSON(object);
    if (Session.getCurrentSession() != null && Session.getCurrentSession().getUser() != null) {
        list.enforceActorHasPermission(Operation.CREATE);
    }
    if (list.getIsMaster() != null && list.getIsMaster()) {
        Universal universal = list.getUniversal();
        MasterListQuery query = new MasterListQuery(new QueryFactory());
        query.WHERE(query.getUniversal().EQ(universal));
        query.AND(query.getOrganization().EQ(list.getOrganization()));
        query.AND(query.getIsMaster().EQ(true));
        if (!list.isNew()) {
            query.AND(query.getOid().NE(list.getOid()));
        }
        if (query.getCount() > 0) {
            DuplicateMasterListException ex = new DuplicateMasterListException();
            ex.setGeoObjectType(universal.getDisplayLabel().getValue());
            throw ex;
        }
    }
    list.apply();
    return list;
}
Also used : Universal(com.runwaysdk.system.gis.geo.Universal) QueryFactory(com.runwaysdk.query.QueryFactory) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 90 with QueryFactory

use of com.runwaysdk.query.QueryFactory in project geoprism-registry by terraframe.

the class MasterList method getJobs.

public List<MasterListJob> getJobs() {
    MasterListJobQuery query = new MasterListJobQuery(new QueryFactory());
    query.WHERE(query.getMasterList().EQ(this));
    try (OIterator<? extends MasterListJob> it = query.getIterator()) {
        return new LinkedList<MasterListJob>(it.getAll());
    }
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) MasterListJobQuery(net.geoprism.registry.etl.MasterListJobQuery) LinkedList(java.util.LinkedList)

Aggregations

QueryFactory (com.runwaysdk.query.QueryFactory)158 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)37 LinkedList (java.util.LinkedList)35 Request (com.runwaysdk.session.Request)31 JsonArray (com.google.gson.JsonArray)19 JsonObject (com.google.gson.JsonObject)19 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)19 SimpleDateFormat (java.text.SimpleDateFormat)15 List (java.util.List)14 Date (java.util.Date)13 ChangeRequest (net.geoprism.registry.action.ChangeRequest)13 OIterator (com.runwaysdk.query.OIterator)12 Universal (com.runwaysdk.system.gis.geo.Universal)12 ChangeRequestQuery (net.geoprism.registry.action.ChangeRequestQuery)12 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)11 BusinessQuery (com.runwaysdk.business.BusinessQuery)10 Session (com.runwaysdk.session.Session)10 GeoprismUser (net.geoprism.GeoprismUser)10 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)9 MdBusinessDAOIF (com.runwaysdk.dataaccess.MdBusinessDAOIF)8