Search in sources :

Example 6 with ClassificationType

use of net.geoprism.registry.model.ClassificationType in project geoprism-registry by terraframe.

the class ClassificationService method getChildren.

@Request(RequestType.SESSION)
public JsonObject getChildren(String sessionId, String classificationCode, String code, Integer pageSize, Integer pageNumber) {
    ClassificationType type = ClassificationType.getByCode(classificationCode);
    if (code != null) {
        Classification parent = Classification.get(type, code);
        return parent.getChildren(pageSize, pageNumber).toJSON();
    }
    Classification root = type.getRoot();
    List<Classification> roots = new LinkedList<Classification>();
    if (root != null) {
        roots.add(root);
    }
    return new Page<Classification>(roots.size(), pageNumber, pageSize, roots).toJSON();
}
Also used : Classification(net.geoprism.registry.model.Classification) ClassificationType(net.geoprism.registry.model.ClassificationType) LinkedList(java.util.LinkedList) Request(com.runwaysdk.session.Request)

Example 7 with ClassificationType

use of net.geoprism.registry.model.ClassificationType in project geoprism-registry by terraframe.

the class ClassificationService method addChild.

@Request(RequestType.SESSION)
public void addChild(String sessionId, String classificationCode, String parentCode, String childCode) {
    ClassificationType type = ClassificationType.getByCode(classificationCode);
    Classification parent = Classification.get(type, parentCode);
    Classification child = Classification.get(type, childCode);
    parent.addChild(child);
}
Also used : Classification(net.geoprism.registry.model.Classification) ClassificationType(net.geoprism.registry.model.ClassificationType) Request(com.runwaysdk.session.Request)

Example 8 with ClassificationType

use of net.geoprism.registry.model.ClassificationType in project geoprism-registry by terraframe.

the class ClassificationTypeTest method testCreate.

@Test
@Request
public void testCreate() {
    String code = "TEST_PROG";
    String label = "Test Prog";
    String description = "Test Description";
    ClassificationType type = ClassificationType.apply(createMock(code, label, description));
    try {
        Assert.assertEquals(code, type.getCode());
        Assert.assertEquals(label, type.getDisplayLabel().getValue());
        Assert.assertNotNull(type.getMdVertex());
    } finally {
        type.delete();
    }
}
Also used : ClassificationType(net.geoprism.registry.model.ClassificationType) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 9 with ClassificationType

use of net.geoprism.registry.model.ClassificationType in project geoprism-registry by terraframe.

the class ClassificationTypeTest method testRemove.

@Test
@Request
public void testRemove() {
    ClassificationType type = ClassificationType.apply(createMock());
    type.delete();
    try {
        ClassificationType.getByCode(type.getCode());
        Assert.fail("Able to get type which should have been deleted");
    } catch (DataNotFoundException ex) {
    // Expected
    }
}
Also used : DataNotFoundException(com.runwaysdk.dataaccess.cache.DataNotFoundException) ClassificationType(net.geoprism.registry.model.ClassificationType) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 10 with ClassificationType

use of net.geoprism.registry.model.ClassificationType 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)

Aggregations

ClassificationType (net.geoprism.registry.model.ClassificationType)19 Classification (net.geoprism.registry.model.Classification)14 Request (com.runwaysdk.session.Request)13 JsonObject (com.google.gson.JsonObject)6 AttributeClassificationType (org.commongeoregistry.adapter.metadata.AttributeClassificationType)5 AttributeTermType (org.commongeoregistry.adapter.metadata.AttributeTermType)5 Classifier (net.geoprism.ontology.Classifier)4 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)4 Test (org.junit.Test)4 MdClassificationDAOIF (com.runwaysdk.dataaccess.MdClassificationDAOIF)3 List (java.util.List)3 Term (org.commongeoregistry.adapter.Term)3 DefaultAttribute (org.commongeoregistry.adapter.constants.DefaultAttribute)3 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)3 JsonArray (com.google.gson.JsonArray)2 EdgeObject (com.runwaysdk.business.graph.EdgeObject)2 GraphObject (com.runwaysdk.business.graph.GraphObject)2 VertexObject (com.runwaysdk.business.graph.VertexObject)2 AbstractClassification (com.runwaysdk.system.AbstractClassification)2 LineString (com.vividsolutions.jts.geom.LineString)2