コード例 #1
0
  /**
   * Adds Object Properties to the current Individual, and adds corresponding predicate to the list
   * (parallel arraylists)
   */
  public void addObjectPropertiesByPredicateType(String predicateURI, OWLNamedIndividual ind) {
    OWLObjectProperty objectProp =
        PROVGraph.manager.getOWLDataFactory().getOWLObjectProperty(IRI.create(predicateURI));
    NodeSet<OWLNamedIndividual> owlObjectIndividuals =
        PROVGraph.reasoner.getObjectPropertyValues(ind, objectProp);
    System.out.println(predicateURI + " Nodes: " + owlObjectIndividuals.getNodes().size());

    for (Node<OWLNamedIndividual> owlSameInd : owlObjectIndividuals) {
      OWLNamedIndividual currInd = owlSameInd.getRepresentativeElement();

      if (currInd != null) {
        String owlIndURI = currInd.toStringID();
        System.out.println("owlIndURI: " + owlIndURI);

        // if the target individual has been previously created, point to that PROVIndividual object
        if (PROVGraph.individualsHM.containsKey(owlIndURI)) {
          PROVIndividual targetProvInd =
              PROVGraph.individualsHM.get(owlSameInd.getRepresentativeElement().toStringID());

          OPconnectionObjectInds.add(targetProvInd);
          OPconnections.add(predicateURI);
        } else // otherwise create a new object with the URI, and add it to the pool of collected
               // PROVIndividuals
        {
          PROVIndividual targetProvInd =
              new PROVIndividual(owlSameInd.getRepresentativeElement().toStringID());
          PROVGraph.individualsHM.put(targetProvInd.uri, targetProvInd);

          OPconnectionObjectInds.add(targetProvInd);
          OPconnections.add(predicateURI);
        }
      } else {
        PROVIndividual anonProvInd = new PROVIndividual("Anonymous Individual " + (++anonIndsCntr));
        // **anonProvInd.uri not unique
        PROVGraph.individualsHM.put(anonProvInd.uri, anonProvInd);

        OPconnectionObjectInds.add(anonProvInd);
        OPconnections.add(predicateURI);
      }
    }
  }