use of com.runwaysdk.dataaccess.MdAttributeDAOIF in project geoprism-registry by terraframe.
the class PatchLastUpdateDate method getCount.
public long getCount() {
MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(GeoVertex.CLASS);
MdAttributeDAOIF mdAttribute = mdVertex.definesAttribute(GeoVertex.LASTUPDATEDATE);
MdAttributeDAOIF createDate = mdVertex.definesAttribute(GeoVertex.CREATEDATE);
StringBuilder builder = new StringBuilder();
builder.append("SELECT COUNT(*) FROM " + mdVertex.getDBClassName());
builder.append(" WHERE " + mdAttribute.getColumnName() + " IS NULL");
builder.append(" OR " + createDate.getColumnName() + " IS NULL");
final GraphQuery<Long> query = new GraphQuery<Long>(builder.toString());
return query.getSingleResult();
}
use of com.runwaysdk.dataaccess.MdAttributeDAOIF in project geoprism-registry by terraframe.
the class GeoObjectJsonExporter method count.
public Long count() {
MdVertexDAOIF mdVertex = got.getMdVertex();
MdAttributeDAOIF mdAttribute = MdAttributeDAO.getByKey(GeoVertex.CLASS + "." + GeoVertex.LASTUPDATEDATE);
StringBuilder statement = new StringBuilder();
statement.append("SELECT COUNT(*) FROM " + mdVertex.getDBClassName());
if (this.since != null) {
statement.append(" WHERE " + mdAttribute.getColumnName() + " >= :lastUpdateDate");
}
statement.append(" ORDER BY " + mdAttribute.getColumnName() + ", oid ASC");
GraphQuery<Long> query = new GraphQuery<Long>(statement.toString());
if (this.since != null) {
query.setParameter("lastUpdateDate", this.since);
}
return query.getSingleResult();
}
use of com.runwaysdk.dataaccess.MdAttributeDAOIF in project geoprism-registry by terraframe.
the class BusinessObject method get.
public static BusinessObject get(BusinessType type, String attributeName, Object value) {
MdVertexDAOIF mdVertex = type.getMdVertexDAO();
MdAttributeDAOIF mdAttribute = mdVertex.definesAttribute(attributeName);
StringBuilder statement = new StringBuilder();
statement.append("SELECT FROM " + mdVertex.getDBClassName());
statement.append(" WHERE " + mdAttribute.getColumnName() + " = :" + attributeName);
GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(statement.toString());
query.setParameter(attributeName, value);
VertexObject result = query.getSingleResult();
if (result != null) {
return new BusinessObject(result, type);
}
return null;
}
use of com.runwaysdk.dataaccess.MdAttributeDAOIF in project geoprism-registry by terraframe.
the class SearchService method search.
public List<ServerGeoObjectIF> search(String text, Date date, Long limit) {
String suffix = this.getSuffix();
RolePermissionService service = new RolePermissionService();
MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(PACKAGE + "." + VERTEX_PREFIX + suffix);
MdAttributeDAOIF code = mdVertex.definesAttribute(CODE);
MdAttributeDAOIF startDate = mdVertex.definesAttribute(START_DATE);
MdAttributeDAOIF endDate = mdVertex.definesAttribute(END_DATE);
MdAttributeDAOIF label = mdVertex.definesAttribute(LABEL);
MdAttributeDAOIF vertexType = mdVertex.definesAttribute(VERTEX_TYPE);
MdEdgeDAOIF mdEdge = MdEdgeDAO.getMdEdgeDAO(PACKAGE + "." + EDGE_PREFIX + suffix);
String attributeName = label.getValue(MdAttributeTextInfo.NAME);
String className = mdVertex.getDBClassName();
String indexName = className + "." + attributeName;
StringBuilder statement = new StringBuilder();
statement.append("SELECT EXPAND(out('" + mdEdge.getDBClassName() + "'))");
statement.append(" FROM " + mdVertex.getDBClassName());
if (text != null) {
String regex = "([+\\-!\\(\\){}\\[\\]^\"~*?:\\\\]|[&\\|]{2})";
String escapedText = text.replaceAll(regex, "\\\\\\\\$1").trim();
statement.append(" WHERE (SEARCH_INDEX(\"" + indexName + "\", \"+" + label.getColumnName() + ":" + escapedText + "*\") = true");
statement.append(" OR :code = " + code.getColumnName() + ")");
} else {
statement.append(" WHERE " + code.getColumnName() + " IS NOT NULL");
}
if (date != null) {
statement.append(" AND :date BETWEEN " + startDate.getColumnName() + " AND " + endDate.getColumnName());
}
if (!service.isSRA() && service.hasSessionUser()) {
statement.append(" AND " + vertexType.getColumnName() + " IN ( :vertexTypes )");
}
statement.append(" ORDER BY " + label.getColumnName() + " DESC");
if (limit != null) {
statement.append(" LIMIT " + limit);
}
List<ServerGeoObjectIF> list = new LinkedList<ServerGeoObjectIF>();
GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(statement.toString());
if (text != null) {
query.setParameter("code", text);
}
if (date != null) {
query.setParameter("date", date);
}
if (!service.isSRA() && service.hasSessionUser()) {
List<String> vertexTypes = new GeoObjectPermissionService().getMandateTypes(service.getOrganization());
query.setParameter("vertexTypes", vertexTypes);
}
List<VertexObject> results = query.getResults();
for (VertexObject result : results) {
MdVertexDAOIF mdVertexType = (MdVertexDAOIF) result.getMdClass();
ServerGeoObjectType type = ServerGeoObjectType.get(mdVertexType);
list.add(new VertexServerGeoObject(type, result, date));
}
return list;
}
use of com.runwaysdk.dataaccess.MdAttributeDAOIF in project geoprism-registry by terraframe.
the class HistoricalRow method getCount.
public static Long getCount(ServerGeoObjectType type, Date startDate, Date endDate) {
MdVertexDAOIF transitionVertex = MdVertexDAO.getMdVertexDAO(Transition.CLASS);
MdAttributeDAOIF eventAttribute = transitionVertex.definesAttribute(Transition.EVENT);
MdVertexDAOIF eventVertex = MdVertexDAO.getMdVertexDAO(TransitionEvent.CLASS);
MdAttributeDAOIF beforeTypeCode = eventVertex.definesAttribute(TransitionEvent.BEFORETYPECODE);
MdAttributeDAOIF afterTypeCode = eventVertex.definesAttribute(TransitionEvent.AFTERTYPECODE);
MdAttributeDAOIF eventDate = eventVertex.definesAttribute(TransitionEvent.EVENTDATE);
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 COUNT(*)");
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");
GraphQuery<Long> query = new GraphQuery<Long>(statement.toString());
query.setParameter("typeCode", codes);
query.setParameter("startDate", startDate);
query.setParameter("endDate", endDate);
return query.getSingleResult();
}
Aggregations