Пример #1
0
  /**
   * Answer the lowest common ancestor of two classes in a given ontology. This is the class that is
   * farthest from the root concept (defaulting to <code>owl:Thing</code> which is a super-class of
   * both <code>u</code> and <code>v</code>. The algorithm is based on <a
   * href="http://en.wikipedia.org/wiki/Tarjan's_off-line_least_common_ancestors_algorithm">Tarjan's
   * off-line LCA</a>. The current implementation expects that the given model:
   *
   * <ul>
   *   <li>is transitively closed over the <code>subClassOf</code> relation
   *   <li>can cheaply determine <em>direct sub-class</em> relations
   * </ul>
   *
   * <p>Both of these conditions are true of the built-in Jena OWL reasoners, such as {@link
   * OntModelSpec#OWL_MEM_MICRO_RULE_INF}, and external DL reasoners such as Pellet.
   *
   * @param m The ontology model being queried to find the LCA, which should conform to the reasoner
   *     capabilities described above
   * @param u An ontology class
   * @param v An ontology class
   * @return The LCA of <code>u</code> and <code>v</code>
   * @exception JenaException if the language profile of the given model does not define a top
   *     concept (e.g. <code>owl:Thing</code>)
   */
  public static OntClass getLCA(OntModel m, OntClass u, OntClass v) {
    Resource root = m.getProfile().THING();
    if (root == null) {
      throw new JenaException(
          "The given OntModel has a language profile that does not define a generic root class (such as owl:Thing)");
    }

    root = root.inModel(m);
    return getLCA(m, root.as(OntClass.class), u, v);
  }
Пример #2
0
  /**
   * Answer a list of the named hierarchy roots of a given {@link OntModel}. This will be similar to
   * the results of {@link OntModel#listHierarchyRootClasses()}, with the added constraint that
   * every member of the returned iterator will be a named class, not an anonymous class expression.
   * The named root classes are calculated from the root classes, by recursively replacing every
   * anonymous class with its direct sub-classes. Thus it can be seen that the values in the list
   * consists of the shallowest fringe of named classes in the hierarchy.
   *
   * @param m An ontology model
   * @return A list of classes whose members are the named root classes of the class hierarchy in
   *     <code>m</code>
   */
  public static List<OntClass> namedHierarchyRoots(OntModel m) {
    List<OntClass> nhr = new ArrayList<OntClass>(); // named roots
    List<OntClass> ahr = new ArrayList<OntClass>(); // anon roots

    // do the initial partition of the root classes
    partitionByNamed(m.listHierarchyRootClasses(), nhr, ahr);

    // now push the fringe down until we have only named classes
    while (!ahr.isEmpty()) {
      OntClass c = ahr.remove(0);
      partitionByNamed(c.listSubClasses(true), nhr, ahr);
    }

    return nhr;
  }
/**
 * Vocabulary definitions
 *
 * @author Christopher Haines ([email protected])
 */
public class WorkflowOntology {
  /** The ontology model that holds the vocabulary terms */
  private static OntModel m_model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, null);

  /** The namespace of the vocabulary as a string */
  public static final String NS = "http://vivoweb.org/ontology/harvesterWorkflow#";

  /**
   * The namespace of the vocabulary as a string
   *
   * @return {@link #NS}
   * @see #NS
   */
  public static String getURI() {
    return NS;
  }

  /** The namespace of the vocabulary as a resource */
  public static final Resource NAMESPACE = m_model.createResource(NS);

  /** retractionsModel */
  public static final ObjectProperty retractionsModel =
      m_model.createObjectProperty(NS + "retractionsModel");

  /** processorMethod */
  public static final ObjectProperty processorMethod =
      m_model.createObjectProperty(NS + "processorMethod");

  /** originalPropertyOf */
  public static final ObjectProperty originalPropertyOf =
      m_model.createObjectProperty(NS + "originalPropertyOf");

  /** firstStepOf */
  public static final ObjectProperty firstStepOf = m_model.createObjectProperty(NS + "firstStepOf");

  /** additionsModel */
  public static final ObjectProperty additionsModel =
      m_model.createObjectProperty(NS + "additionsModel");

  /** originalProperty */
  public static final ObjectProperty originalProperty =
      m_model.createObjectProperty(NS + "originalProperty");

  /** newPropertyOf */
  public static final ObjectProperty newPropertyOf =
      m_model.createObjectProperty(NS + "newPropertyOf");

  /** processorClassOf */
  public static final ObjectProperty processorClassOf =
      m_model.createObjectProperty(NS + "processorClassOf");

  /** retractionsModelOf */
  public static final ObjectProperty retractionsModelOf =
      m_model.createObjectProperty(NS + "retractionsModelOf");

  /** firstStep */
  public static final ObjectProperty firstStep = m_model.createObjectProperty(NS + "firstStep");

  /** modelToAdd */
  public static final ObjectProperty modelToAdd = m_model.createObjectProperty(NS + "modelToAdd");

  /** modelToSubtract */
  public static final ObjectProperty modelToSubtract =
      m_model.createObjectProperty(NS + "modelToSubtract");

  /** smushedOnInAction */
  public static final ObjectProperty smushedOnInAction =
      m_model.createObjectProperty(NS + "smushedOnInAction");

  /** actionOf */
  public static final ObjectProperty actionOf = m_model.createObjectProperty(NS + "actionOf");

  /** newProperty */
  public static final ObjectProperty newProperty = m_model.createObjectProperty(NS + "newProperty");

  /** splitRegex */
  public static final ObjectProperty splitRegex = m_model.createObjectProperty(NS + "splitRegex");

  /** processorClass */
  public static final ObjectProperty processorClass =
      m_model.createObjectProperty(NS + "processorClass");

  /** sourceModelFor */
  public static final ObjectProperty sourceModelFor =
      m_model.createObjectProperty(NS + "sourceModelFor");

  /** destinationModelFor */
  public static final ObjectProperty destinationModelFor =
      m_model.createObjectProperty(NS + "destinationModelFor");

  /** splitRegexOf */
  public static final ObjectProperty splitRegexOf =
      m_model.createObjectProperty(NS + "splitRegexOf");

  /** trimValueFor */
  public static final ObjectProperty trimValueFor =
      m_model.createObjectProperty(NS + "trimValueFor");

  /** uriPrefix */
  public static final ObjectProperty uriPrefix = m_model.createObjectProperty(NS + "uriPrefix");

  /** action */
  public static final ObjectProperty action = m_model.createObjectProperty(NS + "action");

  /** destinationModel */
  public static final ObjectProperty destinationModel =
      m_model.createObjectProperty(NS + "destinationModel");

  /** processorMethodOf */
  public static final ObjectProperty processorMethodOf =
      m_model.createObjectProperty(NS + "processorMethodOf");

  /** sourceModel */
  public static final ObjectProperty sourceModel = m_model.createObjectProperty(NS + "sourceModel");

  /** uriPrefixForAction */
  public static final ObjectProperty uriPrefixForAction =
      m_model.createObjectProperty(NS + "uriPrefixForAction");

  /** smushOnProperty */
  public static final ObjectProperty smushOnProperty =
      m_model.createObjectProperty(NS + "smushOnProperty");

  /** sparqlQuery */
  public static final ObjectProperty sparqlQuery = m_model.createObjectProperty(NS + "sparqlQuery");

  /** previousStep */
  public static final ObjectProperty previousStep =
      m_model.createObjectProperty(NS + "previousStep");

  /** addedInAction */
  public static final ObjectProperty addedInAction =
      m_model.createObjectProperty(NS + "addedInAction");

  /** subtractedInAction */
  public static final ObjectProperty subtractedInAction =
      m_model.createObjectProperty(NS + "subtractedInAction");

  /** nextStep */
  public static final ObjectProperty nextStep = m_model.createObjectProperty(NS + "nextStep");

  /** trim */
  public static final ObjectProperty trim = m_model.createObjectProperty(NS + "trim");

  /** additionsModelOf */
  public static final ObjectProperty additionsModelOf =
      m_model.createObjectProperty(NS + "additionsModelOf");

  /** applyChangesDirectlyToSource */
  public static final DatatypeProperty applyChangesDirectlyToSource =
      m_model.createDatatypeProperty(NS + "applyChangesDirectlyToSource");

  /** jenaConnectConfig */
  public static final DatatypeProperty jenaConnectConfig =
      m_model.createDatatypeProperty(NS + "jenaConnectConfig");

  /** literalValue */
  public static final DatatypeProperty literalValue =
      m_model.createDatatypeProperty(NS + "literalValue");

  /** variableName */
  public static final DatatypeProperty variableName =
      m_model.createDatatypeProperty(NS + "variableName");

  /** Action */
  public static final OntClass Action = m_model.createClass(NS + "Action");

  /** ProcessPropertyValueStringsAction */
  public static final OntClass ProcessPropertyValueStringsAction =
      m_model.createClass(NS + "ProcessPropertyValueStringsAction");

  /** Workflow */
  public static final OntClass Workflow = m_model.createClass(NS + "Workflow");

  /** WorkflowStep */
  public static final OntClass WorkflowStep = m_model.createClass(NS + "WorkflowStep");

  /** Value */
  public static final OntClass Value = m_model.createClass(NS + "Value");

  /** SPARQLCONSTRUCTAction */
  public static final OntClass SPARQLCONSTRUCTAction =
      m_model.createClass(NS + "SPARQLCONSTRUCTAction");

  /** Model */
  public static final OntClass Model = m_model.createClass(NS + "Model");

  /** Literal */
  public static final OntClass Literal = m_model.createClass(NS + "Literal");

  /** CreateModelAction */
  public static final OntClass CreateModelAction = m_model.createClass(NS + "CreateModelAction");

  /** AddModelAction */
  public static final OntClass AddModelAction = m_model.createClass(NS + "AddModelAction");

  /** SubtractModelAction */
  public static final OntClass SubtractModelAction =
      m_model.createClass(NS + "SubtractModelAction");

  /** SplitPropertyValuesAction */
  public static final OntClass SplitPropertyValuesAction =
      m_model.createClass(NS + "SplitPropertyValuesAction");

  /** NameBlankNodesAction */
  public static final OntClass NameBlankNodesAction =
      m_model.createClass(NS + "NameBlankNodesAction");

  /** Variable */
  public static final OntClass Variable = m_model.createClass(NS + "Variable");

  /** ClearModelAction */
  public static final OntClass ClearModelAction = m_model.createClass(NS + "ClearModelAction");

  /** PropertyValueProcessingAction */
  public static final OntClass PropertyValueProcessingAction =
      m_model.createClass(NS + "PropertyValueProcessingAction");

  /** SmushResourcesAction */
  public static final OntClass SmushResourcesAction =
      m_model.createClass(NS + "SmushResourcesAction");
}
Пример #4
0
/**
 * Vocabulary definitions from
 * /home/myrtill/Hackystat_linkedData/mysqlProva/workspace/hackystat-linked-service-data/src/org/hackystat/linkedservicedata/vocabularies/voID.rdf
 *
 * @author Auto-generated by schemagen on 20 Aug 2009 19:14
 */
public class VoIDVocab {
  /** The ontology model that holds the vocabulary terms */
  private static OntModel m_model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, null);

  /** The namespace of the vocabulary as a string */
  public static final String NS = "http://rdfs.org/ns/void#";

  /**
   * The namespace of the vocabulary as a string
   *
   * @see #NS
   */
  public static String getURI() {
    return NS;
  }

  /** The namespace of the vocabulary as a resource */
  public static final Resource NAMESPACE = m_model.createResource(NS);

  // Vocabulary properties
  ///////////////////////////

  /** Announcement of an RDF dump of the dataset. */
  public static final OntProperty DATA_DUMP =
      m_model.createOntProperty("http://rdfs.org/ns/void#dataDump");

  public static final OntProperty EXAMPLE_RESOURCE =
      m_model.createOntProperty("http://rdfs.org/ns/void#exampleResource");

  public static final OntProperty FEATURE =
      m_model.createOntProperty("http://rdfs.org/ns/void#feature");

  public static final OntProperty LINK_PREDICATE =
      m_model.createOntProperty("http://rdfs.org/ns/void#linkPredicate");

  /** The sink target of an interlinking */
  public static final OntProperty OBJECTS_TARGET =
      m_model.createOntProperty("http://rdfs.org/ns/void#objectsTarget");

  public static final OntProperty SPARQL_ENDPOINT =
      m_model.createOntProperty("http://rdfs.org/ns/void#sparqlEndpoint");

  public static final OntProperty STAT_ITEM =
      m_model.createOntProperty("http://rdfs.org/ns/void#statItem");

  /** The source target of an interlinking */
  public static final OntProperty SUBJECTS_TARGET =
      m_model.createOntProperty("http://rdfs.org/ns/void#subjectsTarget");

  public static final OntProperty SUBSET =
      m_model.createOntProperty("http://rdfs.org/ns/void#subset");

  public static final OntProperty TARGET =
      m_model.createOntProperty("http://rdfs.org/ns/void#target");

  /** Defines a simple URI look-up protocol for accessing a dataset. */
  public static final OntProperty URI_LOOKUP_ENDPOINT =
      m_model.createOntProperty("http://rdfs.org/ns/void#uriLookupEndpoint");

  /** Defines a regular expression pattern matching URIs in the dataset. */
  public static final OntProperty URI_REGEX_PATTERN =
      m_model.createOntProperty("http://rdfs.org/ns/void#uriRegexPattern");

  /** A vocabulary that is used in the dataset. */
  public static final OntProperty VOCABULARY =
      m_model.createOntProperty("http://rdfs.org/ns/void#vocabulary");

  // Vocabulary classes
  ///////////////////////////
  public static final OntClass DATASET = m_model.createClass("http://rdfs.org/ns/void#Dataset");
}