/** * Name of core base trait, defaulting to authority name. * * @return */ protected String getBaseTraitName() { return getAuthorityId(); }
public IConcept createIdentity(String id, String authorityId) { /* * check and if necessary, create the trait in our ontology. TODO we should cache * all the info related to the ID so that online search is minimized. For now we * don't do anything online anyway. */ String cId = getAuthorityId() + "_" + sanitizeID(id); IOntology o = getOntology(); IConcept ret = o.getConcept(cId); if (ret == null) { ArrayList<IAxiom> ax = new ArrayList<>(); ax.add(Axiom.ClassAssertion(cId)); ax.add(Axiom.SubClass(getBaseTrait(id).toString(), cId)); ax.add(Axiom .AnnotationAssertion(cId, NS.AUTHORITY_ID_PROPERTY, getAuthorityId())); /* * TODO get descriptor, add label and other metadata to identify the * authority. */ o.define(ax); ret = o.getConcept(cId); } return ret; }
IConcept ret = getOntology().getConcept(getBaseTraitName()); if (ret == null) { ArrayList<IAxiom> ax = new ArrayList<>(); ax.add(Axiom.ClassAssertion(getBaseTraitName())); getOntology().define(ax); ret = getOntology().getConcept(getBaseTraitName());
protected BaseAuthority(Authority definition) { this.definition = definition; for (String p : definition.getInitialProperties()) { Knowledge.createProperty(p, getOntology()); } for (String c : definition.getInitialConcepts()) { Knowledge.createConcept(c, getOntology()); } }
@Override public IConcept getIdentity(String id, String authorityId) throws KlabValidationException { // TODO Auto-generated method stub IConcept ret = null; AuthorityConcept desc = descriptors.get(authorityId + "." + id); if (desc != null) { return ontology.getConcept(desc.getId()); } desc = getConcept(authorityId, id); if (desc != null) { /* * TODO turn it into a concept and stick it in the ontology */ descriptors.put(authorityId + "." + id, desc); } return ret; }
protected IOntology getOntology() { if (ontology == null) { ontology = KLAB.KM.requireOntology(getAuthorityId().toLowerCase()); } return ontology; }
@Override public String validateCoreConcept(IKnowledge knowledge, String id) { if (!knowledge.is(KLAB.c(NS.CORE_IDENTITY_TRAIT))) { return "Concepts identified by the " + getAuthorityId() + " authority must be identities"; } return null; }