use of com.runwaysdk.business.BusinessQuery in project geoprism-registry by terraframe.
the class MasterListShapefileExporter method features.
public FeatureCollection<SimpleFeatureType, SimpleFeature> features(SimpleFeatureType featureType) {
List<SimpleFeature> features = new ArrayList<SimpleFeature>();
SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);
BusinessQuery query = this.version.buildQuery(this.filterJson);
query.ORDER_BY_DESC(query.aCharacter(DefaultAttribute.CODE.getName()));
OIterator<Business> objects = query.getIterator();
try {
while (objects.hasNext()) {
Business row = objects.next();
builder.set(GEOM, row.getObjectValue(RegistryConstants.GEOMETRY_ATTRIBUTE_NAME));
for (MdAttributeConcreteDAOIF mdAttribute : mdAttributes) {
String attributeName = mdAttribute.definesAttribute();
Object value = row.getObjectValue(attributeName);
if (value != null) {
builder.set(this.getColumnName(attributeName), value);
}
}
SimpleFeature feature = builder.buildFeature(row.getValue(DefaultAttribute.CODE.getName()));
features.add(feature);
}
} finally {
objects.close();
}
return new ListFeatureCollection(featureType, features);
}
use of com.runwaysdk.business.BusinessQuery 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;
}
use of com.runwaysdk.business.BusinessQuery 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;
}
use of com.runwaysdk.business.BusinessQuery in project geoprism-registry by terraframe.
the class MasterListVersion 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;
}
use of com.runwaysdk.business.BusinessQuery in project geoprism-registry by terraframe.
the class MasterListVersion method data.
public JsonObject data(Integer pageNumber, Integer pageSize, String filterJson, String sort, Boolean includeGeometries) {
if (includeGeometries == null) {
includeGeometries = Boolean.FALSE;
}
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
format.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
NumberFormat numberFormat = NumberFormat.getInstance(Session.getCurrentLocale());
JsonArray results = new JsonArray();
MdBusinessDAOIF mdBusiness = MdBusinessDAO.get(this.getMdBusinessOid());
List<? extends MdAttributeConcreteDAOIF> mdAttributes = mdBusiness.definesAttributes();
BusinessQuery query = this.buildQuery(filterJson);
if (sort != null && sort.length() > 0) {
JsonObject jObject = JsonParser.parseString(sort).getAsJsonObject();
String attribute = jObject.get("attribute").getAsString();
String order = jObject.get("order").getAsString();
if (order.equalsIgnoreCase("DESC")) {
query.ORDER_BY_DESC(query.getS(attribute));
} else {
query.ORDER_BY_ASC(query.getS(attribute));
}
if (!attribute.equals(DefaultAttribute.CODE.getName())) {
query.ORDER_BY_ASC(query.aCharacter(DefaultAttribute.CODE.getName()));
}
}
try (OIterator<Business> iterator = query.getIterator(pageSize, pageNumber)) {
while (iterator.hasNext()) {
Business row = iterator.next();
JsonObject object = new JsonObject();
MdAttributeConcreteDAOIF mdGeometry = mdBusiness.definesAttribute(RegistryConstants.GEOMETRY_ATTRIBUTE_NAME);
if (includeGeometries) {
Geometry geom = (Geometry) row.getObjectValue(mdGeometry.definesAttribute());
if (geom != null) {
GeoJSONWriter gw = new GeoJSONWriter();
org.wololo.geojson.Geometry gJSON = gw.write(geom);
JsonObject geojson = JsonParser.parseString(gJSON.toString()).getAsJsonObject();
object.add("geometry", geojson);
}
}
object.addProperty(ORIGINAL_OID, row.getValue(ORIGINAL_OID));
for (MdAttributeConcreteDAOIF mdAttribute : mdAttributes) {
if (this.isValid(mdAttribute)) {
String attributeName = mdAttribute.definesAttribute();
Object value = row.getObjectValue(attributeName);
if (value != null) {
if (value instanceof Double) {
object.addProperty(mdAttribute.definesAttribute(), numberFormat.format((Double) value));
} else if (value instanceof Number) {
object.addProperty(mdAttribute.definesAttribute(), (Number) value);
} else if (value instanceof Boolean) {
object.addProperty(mdAttribute.definesAttribute(), (Boolean) value);
} else if (value instanceof String) {
object.addProperty(mdAttribute.definesAttribute(), (String) value);
} else if (value instanceof Character) {
object.addProperty(mdAttribute.definesAttribute(), (Character) value);
} else if (value instanceof Date) {
object.addProperty(mdAttribute.definesAttribute(), format.format((Date) value));
}
}
}
}
results.add(object);
}
}
JsonObject page = new JsonObject();
page.addProperty("pageNumber", pageNumber);
page.addProperty("pageSize", pageSize);
page.addProperty("filter", filterJson);
page.addProperty("count", query.getCount());
page.add("results", results);
return page;
}
Aggregations