Search in sources :

Example 31 with OWLClass

use of org.semanticweb.owlapi.model.OWLClass in project osp-validator by open-simulation-platform.

the class VE_AngularMechanicalPort_1 method getInvalidObjects.

@Override
protected List<AngularMechanicalPort> getInvalidObjects() {
    OWLClass validationErrorClass = context.owl.dataFactory.getOWLClass(VE_AngularMechanicalPort_1, context.owl.prefixManager);
    Set<OWLNamedIndividual> invalidIndividuals = context.invalidIndividuals.get(validationErrorClass);
    return invalidIndividuals.stream().map(individual -> (AngularMechanicalPort) context.variableGroups.get(individual)).collect(Collectors.toList());
}
Also used : List(java.util.List) OWLNamedIndividual(org.semanticweb.owlapi.model.OWLNamedIndividual) VE_AngularMechanicalPort_1(com.opensimulationplatform.gen.owl.model.OntologyClasses.VE_AngularMechanicalPort_1) Set(java.util.Set) ValidationError(com.opensimulationplatform.core.validation.ValidationError) AngularMechanicalPort(com.opensimulationplatform.core.model.modeldescription.variablegroup.angularmechanicalport.AngularMechanicalPort) Collectors(java.util.stream.Collectors) OWLClass(org.semanticweb.owlapi.model.OWLClass) OWLNamedIndividual(org.semanticweb.owlapi.model.OWLNamedIndividual) OWLClass(org.semanticweb.owlapi.model.OWLClass) AngularMechanicalPort(com.opensimulationplatform.core.model.modeldescription.variablegroup.angularmechanicalport.AngularMechanicalPort)

Example 32 with OWLClass

use of org.semanticweb.owlapi.model.OWLClass in project osp-validator by open-simulation-platform.

the class VE_Charge_1 method getInvalidObjects.

@Override
protected List<Charge> getInvalidObjects() {
    OWLClass validationErrorClass = context.owl.dataFactory.getOWLClass(VE_Charge_1, context.owl.prefixManager);
    Set<OWLNamedIndividual> invalidIndividuals = context.invalidIndividuals.get(validationErrorClass);
    return invalidIndividuals.stream().map(individual -> (Charge) context.variableGroups.get(individual)).collect(Collectors.toList());
}
Also used : Charge(com.opensimulationplatform.core.model.modeldescription.variablegroup.charge.Charge) List(java.util.List) OWLNamedIndividual(org.semanticweb.owlapi.model.OWLNamedIndividual) Set(java.util.Set) VE_Charge_1(com.opensimulationplatform.gen.owl.model.OntologyClasses.VE_Charge_1) ValidationError(com.opensimulationplatform.core.validation.ValidationError) Collectors(java.util.stream.Collectors) OWLClass(org.semanticweb.owlapi.model.OWLClass) OWLNamedIndividual(org.semanticweb.owlapi.model.OWLNamedIndividual) Charge(com.opensimulationplatform.core.model.modeldescription.variablegroup.charge.Charge) OWLClass(org.semanticweb.owlapi.model.OWLClass)

Example 33 with OWLClass

use of org.semanticweb.owlapi.model.OWLClass in project osp-validator by open-simulation-platform.

the class VE_Charge_2 method getInvalidObjects.

@Override
protected List<Charge> getInvalidObjects() {
    OWLClass validationErrorClass = context.owl.dataFactory.getOWLClass(VE_Charge_2, context.owl.prefixManager);
    Set<OWLNamedIndividual> invalidIndividuals = context.invalidIndividuals.get(validationErrorClass);
    return invalidIndividuals.stream().map(individual -> (Charge) context.variableGroups.get(individual)).collect(Collectors.toList());
}
Also used : Charge(com.opensimulationplatform.core.model.modeldescription.variablegroup.charge.Charge) List(java.util.List) OWLNamedIndividual(org.semanticweb.owlapi.model.OWLNamedIndividual) Set(java.util.Set) VE_Charge_2(com.opensimulationplatform.gen.owl.model.OntologyClasses.VE_Charge_2) ValidationError(com.opensimulationplatform.core.validation.ValidationError) Collectors(java.util.stream.Collectors) OWLClass(org.semanticweb.owlapi.model.OWLClass) OWLNamedIndividual(org.semanticweb.owlapi.model.OWLNamedIndividual) Charge(com.opensimulationplatform.core.model.modeldescription.variablegroup.charge.Charge) OWLClass(org.semanticweb.owlapi.model.OWLClass)

Example 34 with OWLClass

use of org.semanticweb.owlapi.model.OWLClass in project onto-viewer by edmcouncil.

the class OwlDataHandler method handleInheritedAxioms.

// /**
// * This method is used to handle Inherited Axioms
// *
// * @param ontology Paramter which loaded ontology.
// * @param clazz Clazz are all properties of Inherited Axioms.
// * @return Class and properties of Inherited Axioms.
// */
private OwlDetailsProperties<PropertyValue> handleInheritedAxioms(OWLOntology ontology, OWLClass clazz) {
    OwlDetailsProperties<PropertyValue> result = new OwlDetailsProperties<>();
    String subClassOfKey = ViewerIdentifierFactory.createId(ViewerIdentifierFactory.Type.axiom, "SubClassOf");
    String equivalentClassKey = ViewerIdentifierFactory.createId(ViewerIdentifierFactory.Type.axiom, "EquivalentClasses");
    String key = ViewerIdentifierFactory.createId(ViewerIdentifierFactory.Type.function, OwlType.ANONYMOUS_ANCESTOR.name().toLowerCase());
    Set<OWLClassExpression> alreadySeen = new HashSet<>();
    Set<OWLClass> rset = owlUtils.getSuperClasses(clazz, ontology, alreadySeen);
    Map<IRI, Set<OwlAxiomPropertyValue>> values = new HashMap<>();
    rset.stream().forEachOrdered((c) -> {
        OwlDetailsProperties<PropertyValue> handleAxioms = handleAxioms(c, ontology);
        for (Map.Entry<String, List<PropertyValue>> entry : handleAxioms.getProperties().entrySet()) {
            if (entry.getKey().equals(subClassOfKey) || entry.getKey().equals(equivalentClassKey)) {
                for (PropertyValue propertyValue : entry.getValue()) {
                    if (propertyValue.getType() != OwlType.TAXONOMY) {
                        if (entry.getKey().equals(equivalentClassKey)) {
                            OwlAxiomPropertyValue opv = (OwlAxiomPropertyValue) propertyValue;
                            String val = opv.getValue();
                            String[] value = val.split(" ");
                            value[0] = value[1] = "";
                            val = String.join(" ", value);
                            opv.setValue(val);
                        }
                        OwlAxiomPropertyValue opv = (OwlAxiomPropertyValue) propertyValue;
                        Set<OwlAxiomPropertyValue> owlAxiomPropertyValues = values.getOrDefault(c.getIRI(), new LinkedHashSet<>());
                        owlAxiomPropertyValues.add(opv);
                        values.put(c.getIRI(), owlAxiomPropertyValues);
                    }
                }
            }
        }
    });
    StringBuilder sb = new StringBuilder();
    for (Map.Entry<IRI, Set<OwlAxiomPropertyValue>> entry : values.entrySet()) {
        OwlAxiomPropertyValue opv = new OwlAxiomPropertyValue();
        sb.append("%arg00%").append(" <br />");
        int i = 0;
        for (OwlAxiomPropertyValue owlAxiomPropertyValue : entry.getValue()) {
            i++;
            sb.append("- ").append(owlAxiomPropertyValue.getValue());
            if (i < entry.getValue().size()) {
                sb.append("<br />");
            }
            for (Map.Entry<String, OwlAxiomPropertyEntity> mapping : owlAxiomPropertyValue.getEntityMaping().entrySet()) {
                opv.addEntityValues(mapping.getKey(), mapping.getValue());
            }
        }
        OwlAxiomPropertyEntity prop = new OwlAxiomPropertyEntity();
        prop.setIri(entry.getKey().toString());
        prop.setLabel(labelProvider.getLabelOrDefaultFragment(entry.getKey()));
        opv.addEntityValues("%arg00%", prop);
        opv.setValue(sb.toString());
        opv.setType(OwlType.AXIOM);
        sb = new StringBuilder();
        String fullRenderedString = parseRenderedString(opv);
        opv.setFullRenderedString(fullRenderedString);
        result.addProperty(key, opv);
    }
    result.sortPropertiesInAlphabeticalOrder();
    return result;
}
Also used : IRI(org.semanticweb.owlapi.model.IRI) Set(java.util.Set) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) HashMap(java.util.HashMap) OwlAxiomPropertyEntity(org.edmcouncil.spec.ontoviewer.core.model.property.OwlAxiomPropertyEntity) OwlDetailsProperties(org.edmcouncil.spec.ontoviewer.core.model.property.OwlDetailsProperties) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) OwlAxiomPropertyValue(org.edmcouncil.spec.ontoviewer.core.model.property.OwlAxiomPropertyValue) OwlAxiomPropertyValue(org.edmcouncil.spec.ontoviewer.core.model.property.OwlAxiomPropertyValue) PropertyValue(org.edmcouncil.spec.ontoviewer.core.model.PropertyValue) OWLClassExpression(org.semanticweb.owlapi.model.OWLClassExpression) OWLClass(org.semanticweb.owlapi.model.OWLClass) Map(java.util.Map) HashMap(java.util.HashMap)

Example 35 with OWLClass

use of org.semanticweb.owlapi.model.OWLClass in project onto-viewer by edmcouncil.

the class IndividualDataHandler method handleClassIndividuals.

/**
 * Handle all individual for OWLClass given on parameter.
 *
 * @param ontology
 * @param clazz
 * @return
 */
public OwlDetailsProperties<PropertyValue> handleClassIndividuals(OWLOntology ontology, OWLClass clazz) {
    OwlDetailsProperties<PropertyValue> result = new OwlDetailsProperties<>();
    Set<OWLNamedIndividual> listOfIndividuals = ontology.importsClosure().flatMap(currentOntology -> getInstancesByClass(currentOntology, clazz).stream()).collect(Collectors.toSet());
    for (OWLNamedIndividual namedIndividual : listOfIndividuals) {
        OwlListElementIndividualProperty s = new OwlListElementIndividualProperty();
        s.setType(OwlType.INSTANCES);
        String label = labelExtractor.getLabelOrDefaultFragment(namedIndividual);
        s.setValue(new PairImpl(label, namedIndividual.getIRI().toString()));
        result.addProperty(instanceKey, s);
        namedIndividual.getEntityType();
    }
    return result;
}
Also used : Logger(org.slf4j.Logger) OWLNamedIndividual(org.semanticweb.owlapi.model.OWLNamedIndividual) OwlType(org.edmcouncil.spec.ontoviewer.core.model.OwlType) LoggerFactory(org.slf4j.LoggerFactory) Set(java.util.Set) OwlDetailsProperties(org.edmcouncil.spec.ontoviewer.core.model.property.OwlDetailsProperties) Collectors(java.util.stream.Collectors) PairImpl(org.edmcouncil.spec.ontoviewer.configloader.configuration.model.PairImpl) HashSet(java.util.HashSet) OWLOntology(org.semanticweb.owlapi.model.OWLOntology) Component(org.springframework.stereotype.Component) PropertyValue(org.edmcouncil.spec.ontoviewer.core.model.PropertyValue) OwlListElementIndividualProperty(org.edmcouncil.spec.ontoviewer.core.model.property.OwlListElementIndividualProperty) ViewerIdentifierFactory(org.edmcouncil.spec.ontoviewer.core.ontology.factory.ViewerIdentifierFactory) OWLClass(org.semanticweb.owlapi.model.OWLClass) LabelProvider(org.edmcouncil.spec.ontoviewer.core.ontology.data.label.LabelProvider) OwlListElementIndividualProperty(org.edmcouncil.spec.ontoviewer.core.model.property.OwlListElementIndividualProperty) OWLNamedIndividual(org.semanticweb.owlapi.model.OWLNamedIndividual) PropertyValue(org.edmcouncil.spec.ontoviewer.core.model.PropertyValue) PairImpl(org.edmcouncil.spec.ontoviewer.configloader.configuration.model.PairImpl) OwlDetailsProperties(org.edmcouncil.spec.ontoviewer.core.model.property.OwlDetailsProperties)

Aggregations

OWLClass (org.semanticweb.owlapi.model.OWLClass)163 OWLNamedIndividual (org.semanticweb.owlapi.model.OWLNamedIndividual)85 Set (java.util.Set)64 Collectors (java.util.stream.Collectors)62 List (java.util.List)59 ValidationError (com.opensimulationplatform.core.validation.ValidationError)53 OWLOntology (org.semanticweb.owlapi.model.OWLOntology)29 OWLDataFactory (org.semanticweb.owlapi.model.OWLDataFactory)20 OWLOntologyManager (org.semanticweb.owlapi.model.OWLOntologyManager)20 OWLOntologyCreationException (org.semanticweb.owlapi.model.OWLOntologyCreationException)18 IRI (org.semanticweb.owlapi.model.IRI)17 HashSet (java.util.HashSet)16 OWLAxiom (org.semanticweb.owlapi.model.OWLAxiom)16 OWLObjectProperty (org.semanticweb.owlapi.model.OWLObjectProperty)14 OWLAnnotation (org.semanticweb.owlapi.model.OWLAnnotation)13 OWLDataProperty (org.semanticweb.owlapi.model.OWLDataProperty)13 OWLAnnotationProperty (org.semanticweb.owlapi.model.OWLAnnotationProperty)11 ArrayList (java.util.ArrayList)10 Test (org.junit.Test)9 OWLAnnotationAssertionAxiom (org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom)8