Search in sources :

Example 6 with MdEdgeDAOIF

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

the class VertexLookupRestriction method restrict.

@Override
public void restrict(StringBuilder statement, Map<String, Object> parameters) {
    statement.append(",where: (displayLabel_cot CONTAINS (");
    if (this.date != null) {
        statement.append(":date BETWEEN startDate AND endDate AND ");
    }
    statement.append(localize("value") + ".toLowerCase() LIKE '%' + :text + '%') AND invalid=false)");
    if (this.date != null) {
        parameters.put("date", this.date);
    }
    if (text != null) {
        parameters.put("text", this.text.toLowerCase());
    } else {
        parameters.put("text", this.text);
    }
    if (this.parentCode != null && this.hierarchyType != null) {
        MdEdgeDAOIF mdEdge = this.hierarchyType.getMdEdge();
        statement.append("}.in('" + mdEdge.getDBClassName() + "'){where: (code=:code), while: ($depth < 1)");
        parameters.put("code", this.parentCode);
    }
}
Also used : MdEdgeDAOIF(com.runwaysdk.dataaccess.MdEdgeDAOIF)

Example 7 with MdEdgeDAOIF

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

the class SearchService method deleteSearchTable.

@Transaction
public void deleteSearchTable() {
    String suffix = this.getSuffix();
    MdEdgeDAOIF mdEdge = MdEdgeDAO.getMdEdgeDAO(PACKAGE + "." + EDGE_PREFIX + suffix);
    mdEdge.getBusinessDAO().delete();
    MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(PACKAGE + "." + VERTEX_PREFIX + suffix);
    mdVertex.getBusinessDAO().delete();
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) MdEdgeDAOIF(com.runwaysdk.dataaccess.MdEdgeDAOIF) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 8 with MdEdgeDAOIF

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

the class SearchService method insert.

// @Transaction
public void insert(VertexServerGeoObject object) {
    this.remove(object.getCode());
    String suffix = this.getSuffix();
    MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(PACKAGE + "." + VERTEX_PREFIX + suffix);
    MdEdgeDAOIF mdEdge = MdEdgeDAO.getMdEdgeDAO(PACKAGE + "." + EDGE_PREFIX + suffix);
    ValueOverTimeCollection vots = object.getValuesOverTime(DefaultAttribute.DISPLAY_LABEL.getName());
    for (ValueOverTime vot : vots) {
        VertexObjectDAOIF value = (VertexObjectDAOIF) vot.getValue();
        Set<String> attributeNames = LocalizationService.getLocaleNames();
        for (String attributeName : attributeNames) {
            String label = value.getObjectValue(attributeName);
            if (label != null && label.length() > 0) {
                VertexObject vertex = new VertexObject(mdVertex.definesType());
                vertex.setValue(START_DATE, vot.getStartDate());
                vertex.setValue(END_DATE, vot.getEndDate());
                vertex.setValue(CODE, object.getCode());
                vertex.setValue(LABEL, label);
                vertex.setValue(VERTEX_TYPE, object.getType().getCode());
                vertex.apply();
                vertex.addChild(object.getVertex(), mdEdge).apply();
            }
        }
    }
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) MdEdgeDAOIF(com.runwaysdk.dataaccess.MdEdgeDAOIF) VertexObjectDAOIF(com.runwaysdk.dataaccess.graph.VertexObjectDAOIF) VertexObject(com.runwaysdk.business.graph.VertexObject) ValueOverTimeCollection(com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection)

Example 9 with MdEdgeDAOIF

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

the class ListType method getRestriction.

public BasicVertexRestriction getRestriction(ServerGeoObjectType type, Date forDate) {
    String filterJson = this.getFilterJson();
    if (filterJson != null && filterJson.length() > 0) {
        JsonArray filters = JsonParser.parseString(filterJson).getAsJsonArray();
        CompositeRestriction restriction = new CompositeRestriction();
        for (int i = 0; i < filters.size(); i++) {
            JsonObject filter = filters.get(i).getAsJsonObject();
            String attributeName = filter.get("attribute").getAsString();
            String operation = filter.get("operation").getAsString();
            AttributeType attributeType = type.getAttribute(attributeName).get();
            MdAttributeDAOIF mdAttribute = type.getMdVertex().definesAttribute(attributeName);
            if (attributeType instanceof AttributeDateType) {
                String value = filter.get("value").getAsString();
                Date date = GeoRegistryUtil.parseDate(value, false);
                restriction.add(new AttributeValueRestriction(mdAttribute, operation, date, forDate));
            } else if (attributeType instanceof AttributeBooleanType) {
                String value = filter.get("value").getAsString();
                Boolean bVal = Boolean.valueOf(value);
                restriction.add(new AttributeValueRestriction(mdAttribute, operation, bVal, forDate));
            } else if (attributeType instanceof AttributeTermType) {
                String code = filter.get("value").getAsString();
                Term root = ((AttributeTermType) attributeType).getRootTerm();
                String parent = TermConverter.buildClassifierKeyFromTermCode(root.getCode());
                String classifierKey = Classifier.buildKey(parent, code);
                Classifier classifier = Classifier.getByKey(classifierKey);
                restriction.add(new AttributeValueRestriction(mdAttribute, operation, classifier.getOid(), forDate));
            } else if (attributeType instanceof AttributeClassificationType) {
                JsonObject object = filter.get("value").getAsJsonObject();
                Term term = Term.fromJSON(object);
                MdClassificationDAOIF mdClassification = ((MdAttributeClassificationDAOIF) mdAttribute).getMdClassificationDAOIF();
                MdEdgeDAOIF mdEdge = mdClassification.getReferenceMdEdgeDAO();
                ClassificationType classificationType = new ClassificationType(mdClassification);
                Classification classification = Classification.get(classificationType, term.getCode());
                restriction.add(new AttributeValueRestriction(mdAttribute, operation, classification.getVertex().getRID(), forDate));
            } else {
                String value = filter.get("value").getAsString();
                restriction.add(new AttributeValueRestriction(mdAttribute, operation, value, forDate));
            }
        }
        if (restriction.getRestrictions().size() > 0) {
            return restriction;
        }
    }
    return null;
}
Also used : CompositeRestriction(net.geoprism.registry.query.graph.CompositeRestriction) MdEdgeDAOIF(com.runwaysdk.dataaccess.MdEdgeDAOIF) JsonObject(com.google.gson.JsonObject) Term(org.commongeoregistry.adapter.Term) Classifier(net.geoprism.ontology.Classifier) AttributeClassificationType(org.commongeoregistry.adapter.metadata.AttributeClassificationType) ClassificationType(net.geoprism.registry.model.ClassificationType) AttributeClassificationType(org.commongeoregistry.adapter.metadata.AttributeClassificationType) Date(java.util.Date) AttributeDateType(org.commongeoregistry.adapter.metadata.AttributeDateType) AttributeValueRestriction(net.geoprism.registry.query.graph.AttributeValueRestriction) JsonArray(com.google.gson.JsonArray) MdClassificationDAOIF(com.runwaysdk.dataaccess.MdClassificationDAOIF) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) Classification(net.geoprism.registry.model.Classification) AttributeBooleanType(org.commongeoregistry.adapter.metadata.AttributeBooleanType) AttributeTermType(org.commongeoregistry.adapter.metadata.AttributeTermType)

Example 10 with MdEdgeDAOIF

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

the class ExternalSystem method getReferencedDataCount.

public long getReferencedDataCount() {
    final MdEdgeDAOIF mdEdge = MdEdgeDAO.getMdEdgeDAO(GeoVertex.EXTERNAL_ID);
    StringBuilder builder = new StringBuilder();
    builder.append("SELECT COUNT(*) FROM " + mdEdge.getDBClassName());
    builder.append(" WHERE out = :system");
    final GraphQuery<Long> query = new GraphQuery<Long>(builder.toString());
    query.setParameter("system", this.getRID());
    return query.getSingleResult();
}
Also used : MdEdgeDAOIF(com.runwaysdk.dataaccess.MdEdgeDAOIF) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Aggregations

MdEdgeDAOIF (com.runwaysdk.dataaccess.MdEdgeDAOIF)15 GraphQuery (com.runwaysdk.business.graph.GraphQuery)7 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)7 EdgeObject (com.runwaysdk.business.graph.EdgeObject)5 VertexObject (com.runwaysdk.business.graph.VertexObject)5 LineString (com.vividsolutions.jts.geom.LineString)4 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)4 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)4 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)4 GraphObject (com.runwaysdk.business.graph.GraphObject)3 MultiPoint (com.vividsolutions.jts.geom.MultiPoint)3 Point (com.vividsolutions.jts.geom.Point)3 MdAttributeDAOIF (com.runwaysdk.dataaccess.MdAttributeDAOIF)2 MdClassificationDAOIF (com.runwaysdk.dataaccess.MdClassificationDAOIF)2 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)2 Request (com.runwaysdk.session.Request)2 Date (java.util.Date)2 AbstractServerGeoObject (net.geoprism.registry.model.AbstractServerGeoObject)2 HashedMap (org.apache.commons.collections4.map.HashedMap)2 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)2