public Instance getInstance(Identifier id, Concept concept) { reasoner.deRegisterOntology((IRI) (state.getIdentifier())); try { reasoner.registerOntology(state); } catch (InconsistencyException e) { logger.warn("Ontology registration failed.", e); } Set<Instance> instances = reasoner.getInstances((IRI) state.getIdentifier(), concept); Instance instance = null; for (Instance i : instances) if (i.getIdentifier().equals(id)) instance = i; for (Entry<Molecule, Axiom> e : axioms.entrySet()) { if (e.getKey() instanceof AttributeValueMolecule) { AttributeValueMolecule avm = (AttributeValueMolecule) e.getKey(); Axiom axiom = e.getValue(); if (avm.getLeftParameter().equals(instance.getIdentifier())) { try { instance.addAttributeValue((IRI) avm.getAttribute(), (Value) avm.getRightParameter()); } catch (Exception e2) { logger.warn("Failed to pseudo-reason.", e2); } } } } return instance; }
public boolean isOut(Instance instance) { if (instance.getIdentifier() instanceof UnnumberedAnonymousID) return false; for (Out mode : signature.listOutModes()) { if (reasoner.isMemberOf((IRI) state.getIdentifier(), instance, mode.getConcept())) return true; } return false; }
public void initializeWithControlState() { Concept controlState = factory.createConcept(factory.createIRI(OASM_NAMESPACE + "controlState")); Instance controlStateInstance = factory.createInstance(factory.createIRI(OASM_NAMESPACE + "cs")); try { controlStateInstance.addConcept(controlState); state.addInstance(controlStateInstance); AttributeValueMolecule avm = leFactory.createAttributeValue( factory.createIRI(OASM_NAMESPACE + "cs"), factory.createIRI(OASM_NAMESPACE + "value"), factory.createIRI(OASM_NAMESPACE + "initial")); add(avm); } catch (SynchronisationException e) { logger.warn("Failure during insertion of control state.", e); } catch (InvalidModelException e) { logger.warn("Failure during insertion of control state.", e); } }