Example #1
0
  public OWLNamedIndividual assertPropertyChain(
      KnowledgeHelper kh, String path, OWLNamedIndividual srcVar, String modelNS) {
    StringTokenizer tok = new StringTokenizer(path, ".");
    List<String> chain = new ArrayList<String>(tok.countTokens());
    while (tok.hasMoreTokens()) {
      chain.add(tok.nextToken());
    }
    Collections.reverse(chain);

    OWLNamedIndividual current = srcVar;
    for (int j = 0; j < chain.size(); j++) {
      String prop = chain.get(j);
      OWLNamedIndividual propCode = asIndividual(modelNS + prop);
      kh.insert(assertObjectProperty("ops:propCode", current, propCode));
      kh.insert(assertDataProperty("skos-ext:code", propCode, modelNS + prop));
      kh.insert(assertType(current, "ops:DomainPropertyExpression"));

      if (j != chain.size() - 1) {
        OWLNamedIndividual expr = asIndividual("tns:PropertyExpr_" + System.identityHashCode(prop));
        kh.insert(assertObjectProperty("ops:source", current, expr));
        current = expr;
      }
    }
    return current;
  }
Example #2
0
 public OWLNamedIndividual assertExpression(KnowledgeHelper kh, String op, Object root) {
   OWLNamedIndividual expr = asExpressionIndividual(op, root);
   OWLNamedIndividual opCode = asIndividual("ops:Op_" + op);
   kh.insert(assertObjectProperty("ops:opCode", expr, opCode));
   kh.insert(assertDataProperty("skos-ext:code", opCode, op));
   String actualOp = mapOperation(op);
   if (actualOp != null) {
     kh.insert(assertType(expr, determineNamespace(actualOp) + actualOp + "Expression"));
   }
   return expr;
 }
Example #3
0
 public void assertNullSafeDataProperty(
     KnowledgeHelper drools, String property, OWLNamedIndividual src, String tgt, String type) {
   if (!"null".equals(tgt)) {
     if (type.startsWith("xsd:")) {
       // hack: using the short form
       type = IRI.create("http://www.w3.org/2001/XMLSchema#" + type.substring(4)).toString();
     } else {
       System.out.println("Unkokwn type");
     }
     drools.insert(assertTypedDataProperty(property, src, tgt, type));
   }
 }
Example #4
0
  public void assertCD(KnowledgeHelper kh, String property, OWLNamedIndividual src, Object code) {
    OWLNamedIndividual cd = asIndividual(code);
    kh.insert(assertObjectProperty(property, src, cd));
    kh.insert(assertType(cd, "skos-ext:ConceptCode"));

    String codeVal = extractStringProperty("getCode", code);
    if (codeVal != null) {
      kh.insert(assertDataProperty("skos-ext:code", cd, codeVal));
    }
    String codeSystem = extractStringProperty("getCodeSystem", code);
    if (codeSystem != null) {
      kh.insert(assertDataProperty("skos-ext:codeSystem", cd, codeSystem));
    }
    String codeSystemName = extractStringProperty("getCodeSystemName", code);
    if (codeSystemName != null) {
      kh.insert(assertDataProperty("skos-ext:codeSystemName", cd, codeSystemName));
    }
    String text = extractStringProperty("getOriginalText", code);
    if (text != null) {
      kh.insert(assertDataProperty("skos-ext:label", cd, text));
    }
  }