コード例 #1
0
  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;
  }