Search in sources :

Example 26 with Classifier

use of net.geoprism.ontology.Classifier in project geoprism-registry by terraframe.

the class RegistryService method createTerm.

/**
 * Creates a new {@link Term} object and makes it a child of the term with the
 * given code.
 *
 * @param sessionId
 * @param parentTemCode
 *          The code of the parent [@link Term}.
 * @param termJSON
 *          JSON of the term object.
 *
 * @return Newly created {@link Term} object.
 */
@Request(RequestType.SESSION)
public Term createTerm(String sessionId, String parentTermCode, String termJSON) {
    JsonObject termJSONobj = JsonParser.parseString(termJSON).getAsJsonObject();
    LocalizedValue label = LocalizedValue.fromJSON(termJSONobj.get(Term.JSON_LOCALIZED_LABEL).getAsJsonObject());
    Term term = new Term(termJSONobj.get(Term.JSON_CODE).getAsString(), label, new LocalizedValue(""));
    Classifier classifier = TermConverter.createClassifierFromTerm(parentTermCode, term);
    TermConverter termBuilder = new TermConverter(classifier.getKeyName());
    Term returnTerm = termBuilder.build();
    List<MdAttributeConcrete> mdAttrList = this.findRootClassifier(classifier);
    this.refreshAttributeTermTypeInCache(mdAttrList);
    return returnTerm;
}
Also used : LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) JsonObject(com.google.gson.JsonObject) MdAttributeMultiTerm(com.runwaysdk.system.metadata.MdAttributeMultiTerm) MdAttributeTerm(com.runwaysdk.system.metadata.MdAttributeTerm) Term(org.commongeoregistry.adapter.Term) Classifier(net.geoprism.ontology.Classifier) MdAttributeConcrete(com.runwaysdk.system.metadata.MdAttributeConcrete) TermConverter(net.geoprism.registry.conversion.TermConverter) Request(com.runwaysdk.session.Request) OAuthClientRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest)

Example 27 with Classifier

use of net.geoprism.ontology.Classifier in project geoprism-registry by terraframe.

the class XMLImporter method createTermOptions.

private void createTermOptions(Element attributeNode, Term root) {
    NodeList attributeList = attributeNode.getElementsByTagName("option");
    for (int i = 0; i < attributeList.getLength(); i++) {
        Node nNode = attributeList.item(i);
        if (nNode.getNodeType() == Node.ELEMENT_NODE) {
            Element elem = (Element) nNode;
            String code = elem.getAttribute("code");
            LocalizedValue label = this.getLabel(elem);
            LocalizedValue description = this.getDescription(elem);
            Term term = new Term(code, label, description);
            Classifier classifier = TermConverter.createClassifierFromTerm(root.getCode(), term);
            TermConverter termBuilder = new TermConverter(classifier.getKeyName());
            termBuilder.build();
        }
    }
}
Also used : LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) ServerElement(net.geoprism.registry.model.ServerElement) Element(org.w3c.dom.Element) Term(org.commongeoregistry.adapter.Term) Classifier(net.geoprism.ontology.Classifier) TermConverter(net.geoprism.registry.conversion.TermConverter)

Example 28 with Classifier

use of net.geoprism.ontology.Classifier in project geoprism-registry by terraframe.

the class AttributeTypeServiceTest method buildClassAttributeClassifierTree.

@Transaction
private Classifier buildClassAttributeClassifierTree(String className, String attributeName) {
    Classifier rootTestClassifier = Classifier.getRoot();
    String classifierId = TermConverter.buildRootClassClassifierId(className);
    Classifier classTerm = this.createClassifier(classifierId, "Test Type");
    classTerm.addLink(rootTestClassifier, ClassifierIsARelationship.CLASS).apply();
    String attributeKey = classifierId + "_" + attributeName;
    Classifier attributeTerm = this.createClassifier(attributeKey, "Attribute Test Root");
    attributeTerm.addLink(classTerm, ClassifierIsARelationship.CLASS).apply();
    Classifier attributeValueTerm1 = this.createClassifier(attributeKey + "_Value1", "Attribute Value 1");
    attributeValueTerm1.addLink(attributeTerm, ClassifierIsARelationship.CLASS).apply();
    Classifier attributeValueTerm2 = this.createClassifier(attributeKey + "_Value2", "Attribute Value 2");
    attributeValueTerm2.addLink(attributeTerm, ClassifierIsARelationship.CLASS).apply();
    Classifier attributeValueTerm3 = this.createClassifier(attributeKey + "_Value3", "Attribute Value 3");
    attributeValueTerm3.addLink(attributeTerm, ClassifierIsARelationship.CLASS).apply();
    return classTerm;
}
Also used : Classifier(net.geoprism.ontology.Classifier) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Aggregations

Classifier (net.geoprism.ontology.Classifier)28 Term (org.commongeoregistry.adapter.Term)14 AttributeTermType (org.commongeoregistry.adapter.metadata.AttributeTermType)11 AttributeClassificationType (org.commongeoregistry.adapter.metadata.AttributeClassificationType)9 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)9 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)8 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)7 Classification (net.geoprism.registry.model.Classification)7 JsonObject (com.google.gson.JsonObject)6 VertexObject (com.runwaysdk.business.graph.VertexObject)5 DataNotFoundException (com.runwaysdk.dataaccess.cache.DataNotFoundException)5 MdAttributeTermDAOIF (com.runwaysdk.dataaccess.MdAttributeTermDAOIF)4 Request (com.runwaysdk.session.Request)4 MdAttributeConcrete (com.runwaysdk.system.metadata.MdAttributeConcrete)4 MdAttributeTerm (com.runwaysdk.system.metadata.MdAttributeTerm)4 TermValueException (net.geoprism.registry.io.TermValueException)4 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)4 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)4 UnknownTermException (org.commongeoregistry.adapter.dataaccess.UnknownTermException)4 EdgeObject (com.runwaysdk.business.graph.EdgeObject)3