Search in sources :

Example 61 with MdVertexDAOIF

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

the class HistoricalRow method getHistoricalReport.

public static Page<HistoricalRow> getHistoricalReport(ServerGeoObjectType type, Date startDate, Date endDate, Integer pageSize, Integer pageNumber) {
    MdVertexDAOIF transitionVertex = MdVertexDAO.getMdVertexDAO(Transition.CLASS);
    MdAttributeDAOIF eventAttribute = transitionVertex.definesAttribute(Transition.EVENT);
    MdAttributeDAOIF sourceAttribute = transitionVertex.definesAttribute(Transition.SOURCE);
    MdAttributeDAOIF targetAttribute = transitionVertex.definesAttribute(Transition.TARGET);
    MdAttributeDAOIF transitionAttribute = transitionVertex.definesAttribute(Transition.TRANSITIONTYPE);
    MdVertexDAOIF eventVertex = MdVertexDAO.getMdVertexDAO(TransitionEvent.CLASS);
    MdAttributeDAOIF eventId = eventVertex.definesAttribute(TransitionEvent.EVENTID);
    MdAttributeDAOIF beforeTypeCode = eventVertex.definesAttribute(TransitionEvent.BEFORETYPECODE);
    MdAttributeDAOIF afterTypeCode = eventVertex.definesAttribute(TransitionEvent.AFTERTYPECODE);
    MdAttributeDAOIF eventDate = eventVertex.definesAttribute(TransitionEvent.EVENTDATE);
    MdAttributeDAOIF description = eventVertex.definesAttribute(TransitionEvent.DESCRIPTION);
    List<ServerGeoObjectType> types = new LinkedList<ServerGeoObjectType>();
    types.add(type);
    types.addAll(type.getSubtypes());
    List<String> codes = types.stream().map(t -> t.getCode()).distinct().collect(Collectors.toList());
    StringBuilder statement = new StringBuilder();
    statement.append("SELECT " + eventAttribute.getColumnName() + "." + eventId.getColumnName() + " AS " + HistoricalRow.EVENT_ID);
    statement.append(", " + eventAttribute.getColumnName() + "." + eventDate.getColumnName() + " AS " + HistoricalRow.EVENT_DATE);
    statement.append(", " + transitionAttribute.getColumnName() + " AS " + HistoricalRow.EVENT_TYPE);
    statement.append(", " + eventAttribute.getColumnName() + "." + description.getColumnName() + " AS " + HistoricalRow.DESCRIPTION);
    statement.append(", " + eventAttribute.getColumnName() + "." + beforeTypeCode.getColumnName() + " AS " + HistoricalRow.BEFORE_TYPE);
    statement.append(", " + sourceAttribute.getColumnName() + ".code AS " + HistoricalRow.BEFORE_CODE);
    statement.append(", " + sourceAttribute.getColumnName() + ".displayLabel_cot AS " + HistoricalRow.BEFORE_LABEL);
    statement.append(", " + eventAttribute.getColumnName() + "." + afterTypeCode.getColumnName() + " AS " + HistoricalRow.AFTER_TYPE);
    statement.append(", " + targetAttribute.getColumnName() + ".code AS " + HistoricalRow.AFTER_CODE);
    statement.append(", " + targetAttribute.getColumnName() + ".displayLabel_cot AS " + HistoricalRow.AFTER_LABEL);
    statement.append(" FROM " + transitionVertex.getDBClassName());
    statement.append(" WHERE ( " + eventAttribute.getColumnName() + "." + beforeTypeCode.getColumnName() + " IN :typeCode");
    statement.append(" OR " + eventAttribute.getColumnName() + "." + afterTypeCode.getColumnName() + " IN :typeCode )");
    statement.append(" AND " + eventAttribute.getColumnName() + "." + eventDate.getColumnName() + " BETWEEN :startDate AND :endDate");
    statement.append(" ORDER BY " + eventAttribute.getColumnName() + "." + eventDate.getColumnName() + " DESC");
    statement.append(", " + eventAttribute.getColumnName() + "." + eventId.getColumnName());
    statement.append(", " + sourceAttribute.getColumnName() + ".code");
    statement.append(", " + targetAttribute.getColumnName() + ".code");
    if (pageNumber != null && pageSize != null) {
        statement.append(" SKIP " + ((pageNumber - 1) * pageSize) + " LIMIT " + pageSize);
    }
    GraphQuery<Map<String, Object>> query = new GraphQuery<Map<String, Object>>(statement.toString());
    query.setParameter("typeCode", codes);
    query.setParameter("startDate", startDate);
    query.setParameter("endDate", endDate);
    Long count = getCount(type, startDate, endDate);
    List<HistoricalRow> results = query.getRawResults().stream().map(list -> HistoricalRow.parse(list)).collect(Collectors.toList());
    return new Page<HistoricalRow>(count, pageNumber, pageSize, results);
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) Transition(net.geoprism.registry.graph.transition.Transition) JsonObject(com.google.gson.JsonObject) TransitionEvent(net.geoprism.registry.graph.transition.TransitionEvent) Date(java.util.Date) GraphQuery(com.runwaysdk.business.graph.GraphQuery) LocalizationFacade(net.geoprism.localization.LocalizationFacade) IOException(java.io.IOException) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Collectors(java.util.stream.Collectors) GsonBuilder(com.google.gson.GsonBuilder) MdVertexDAO(com.runwaysdk.dataaccess.metadata.graph.MdVertexDAO) JsonElement(com.google.gson.JsonElement) MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) List(java.util.List) HistoricalReportExcelExporter(net.geoprism.registry.excel.HistoricalReportExcelExporter) LocalizedValueConverter(net.geoprism.registry.conversion.LocalizedValueConverter) Map(java.util.Map) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) SeverGeoObjectJsonAdapters(net.geoprism.registry.etl.export.SeverGeoObjectJsonAdapters) LinkedList(java.util.LinkedList) InputStream(java.io.InputStream) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) LinkedList(java.util.LinkedList) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) JsonObject(com.google.gson.JsonObject) Map(java.util.Map) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Example 62 with MdVertexDAOIF

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

the class AttributeTypeServiceTest method checkAttribute.

// @Request
// private VertexObject createRootClassification(MdClassificationDAO
// mdClassification)
// {
// MdVertexDAOIF mdVertexDAO = mdClassification.getReferenceMdVertexDAO();
// 
// VertexObject classification = (VertexObject)
// VertexObject.instantiate(VertexObjectDAO.newInstance(mdVertexDAO));
// classification.setEmbeddedValue(VertexObject.DISPLAYLABEL,
// MdAttributeLocalInfo.DEFAULT_LOCALE, "test");
// // classification.setCode()
// }
/*
   * Utility methods
   */
@Request
private MdAttributeDAOIF checkAttribute(String geoObjectTypeCode, String attributeName) {
    ServerGeoObjectType type = ServerGeoObjectType.get(geoObjectTypeCode);
    MdVertexDAOIF mdVertex = type.getMdVertex();
    return mdVertex.definesAttribute(attributeName);
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Request(com.runwaysdk.session.Request)

Aggregations

MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)62 GraphQuery (com.runwaysdk.business.graph.GraphQuery)34 VertexObject (com.runwaysdk.business.graph.VertexObject)30 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)26 MdAttributeDAOIF (com.runwaysdk.dataaccess.MdAttributeDAOIF)24 EdgeObject (com.runwaysdk.business.graph.EdgeObject)16 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)12 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)11 Date (java.util.Date)10 LinkedList (java.util.LinkedList)9 ValueOverTime (com.runwaysdk.dataaccess.graph.attributes.ValueOverTime)8 JsonObject (com.google.gson.JsonObject)7 MdEdgeDAOIF (com.runwaysdk.dataaccess.MdEdgeDAOIF)7 HashedMap (org.apache.commons.collections4.map.HashedMap)7 HashMap (java.util.HashMap)5 TreeSet (java.util.TreeSet)5 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)5 GraphObject (com.runwaysdk.business.graph.GraphObject)4 MdVertexDAO (com.runwaysdk.dataaccess.metadata.graph.MdVertexDAO)4 LineString (com.vividsolutions.jts.geom.LineString)4