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