コード例 #1
0
  public OntClass asOntClass(OntModel owlModel, Model pmlModel) {
    // int col = cmpOpCol(testNumber);

    Individual elem =
        owlModel.createIndividual(Ontology.EPA.NS + elementName, Ontology.Element(owlModel));
    OntClass elemRestrict =
        owlModel.createHasValueRestriction(null, Ontology.hasElement(owlModel), elem);
    // OntClass testRestrict =
    // owlModel.createClass(Ontology.EPA.NS+"EPA-"+elementName+"-test-"+testNumber);
    Literal test = owlModel.createTypedLiteral(testNumber);
    OntClass testRestrict =
        owlModel.createHasValueRestriction(null, Ontology.hasTestNumber(owlModel), test);
    Resource x =
        owlModel.createResource(
            Ontology.EPA.NS + "EPA-" + elementName + "-Threshold-" + testNumber);
    String op = null;
    switch (cmpType) {
      case 0:
        op = "minInclusive";
        break;
      case 1:
        op = "minExclusive";
        break;
      case 3:
        op = "maxExclusive";
        break;
      case 4:
        op = "maxInclusive";
        break;
      default:
        System.err.println("unknown cmp type");
    }
    x.addLiteral(owlModel.createProperty(XSD.getURI() + op), Double.parseDouble(cmpValue));
    RDFList withRestrict = owlModel.createList(new RDFNode[] {x});
    Resource y = owlModel.createResource(RDFS.Datatype);
    y.addProperty(OWL2.withRestrictions, withRestrict);
    y.addProperty(OWL2.onDatatype, XSD.xdouble);
    OntClass valueRestrict =
        owlModel.createSomeValuesFromRestriction(null, Ontology.hasValue(owlModel), y);
    RDFNode[] components = new RDFNode[4];
    components[0] = Ontology.FacilityMeasurement(owlModel);
    components[2] = valueRestrict;
    components[3] = elemRestrict;
    components[1] = testRestrict;
    RDFList intersect = owlModel.createList(components);
    OntClass self =
        owlModel.createIntersectionClass(
            Ontology.EPA.NS + "EPA-Excessive-" + elementName + "-Measurement-" + testNumber,
            intersect);
    self.addProperty(RDFS.subClassOf, Ontology.Violation(owlModel));

    return self;
  }