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);
}
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);
}
Aggregations