public Collection<OWLNamedIndividual> getIndividuals(OWLClass owlClass) { Set<OWLNamedIndividual> individuals = new HashSet<OWLNamedIndividual>(); for (OWLIndividual i : owlClass.getIndividuals(ontology)) { if (!i.isAnonymous()) { individuals.add(i.asOWLNamedIndividual()); } } return individuals; }
public ArrayList<String> getAssertedIndividualAll(String belongingClassName) { openOntology(false); ArrayList<String> individualNames = new ArrayList<String>(); // get all individuals from all subclasses of the selected class ArrayList<String> allSubclassNames = getAssertedSubclassNamesAll(belongingClassName, true); allSubclassNames = getTrimmedList(allSubclassNames); for (String currentSubclassName : allSubclassNames) { IRI currentSubclassURI = IRI.create(ontology.getOntologyID() + "#" + currentSubclassName); OWLClass currentSubclass = factory.getOWLClass(currentSubclassURI); if (currentSubclass != null) { // debug and check what is the difference between individuals in signature // and individuals. Set<OWLNamedIndividual> namedIndividualSet = currentSubclass.getIndividualsInSignature(); Set<OWLIndividual> individualSet = currentSubclass.getIndividuals(ontology); for (OWLIndividual individual : individualSet) { individualNames.add(individual.toString()); } } } closeOntology(); return individualNames; }
/** * Inverse of Individual.getType */ public Collection<Individual> getIsTypeOf() { return convertI(cl().getIndividuals(onto)); }
/** * Get the list of scopes to activate on startup * * @param config * @return */ public static String[] getScopesToActivate(OWLOntology config) { Set<OWLIndividual> scopes = cScope.getIndividuals(config); List<String> result = new ArrayList<String>(); boolean doActivate = false; for (OWLIndividual iScope : scopes) { Set<OWLLiteral> activate = iScope.getDataPropertyValues( activateOnStart, config); Iterator<OWLLiteral> it = activate.iterator(); while (it.hasNext() && !doActivate) { OWLLiteral l = it.next(); doActivate |= Boolean.parseBoolean(l.getLiteral()); } if (iScope.isNamed() && doActivate) result.add(((OWLNamedIndividual) iScope).getIRI().toString()); } return result.toArray(EMPTY_IRI_ARRAY); }
/** * Get the list of scopes to activate on startup * * @param config * @return */ public static String[] getScopesToActivate(OWLOntology config) { Set<OWLIndividual> scopes = cScope.getIndividuals(config); List<String> result = new ArrayList<String>(); boolean doActivate = false; for (OWLIndividual iScope : scopes) { Set<OWLLiteral> activate = iScope.getDataPropertyValues(activateOnStart, config); Iterator<OWLLiteral> it = activate.iterator(); while (it.hasNext() && !doActivate) { OWLLiteral l = it.next(); doActivate |= Boolean.parseBoolean(l.getLiteral()); } if (iScope.isNamed() && doActivate) result.add(((OWLNamedIndividual) iScope).getIRI().toString()); } return result.toArray(EMPTY_IRI_ARRAY); }
/** * Get the list of scopes to activate on startup * * @param config * @return */ public static String[] getScopesToActivate(OWLOntology config) { Set<OWLIndividual> scopes = cScope.getIndividuals(config); List<String> result = new ArrayList<String>(); boolean doActivate = false; for (OWLIndividual iScope : scopes) { Set<OWLLiteral> activate = iScope.getDataPropertyValues(activateOnStart, config); Iterator<OWLLiteral> it = activate.iterator(); while (it.hasNext() && !doActivate) { OWLLiteral l = it.next(); doActivate |= Boolean.parseBoolean(l.getLiteral()); } if (iScope.isNamed() && doActivate) result.add(((OWLNamedIndividual) iScope).getIRI().toString()); } return result.toArray(EMPTY_IRI_ARRAY); }
private Set<GraphArc> findOutgoingIndividualRelationships(OWLEntity entityOfInterest, boolean mustBeVisible) { Set<GraphArc> incomingInstanceRels = new HashSet<GraphArc>(); if (!(entityOfInterest instanceof OWLClass)) return incomingInstanceRels; if(!filterManager.isArcTypeVisible(DIRECT_INDIVIDUAL_SLOT_TYPE)) return incomingInstanceRels; OWLClass owlClass = (OWLClass) entityOfInterest; for(OWLIndividual individual : owlClass.getIndividuals(owlOntology)) { if(individual instanceof OWLNamedIndividual) { OWLNamedIndividual namedIndividual = (OWLNamedIndividual)individual; if(isDisplayableNode(namedIndividual, mustBeVisible)) { String relType = DIRECT_INDIVIDUAL_SLOT_TYPE; GraphArc arc = createArc(owlClass, namedIndividual, relType); incomingInstanceRels.add(arc); } } } return incomingInstanceRels; }
/** * To get all the instances of Scope in this configuration * * @param config * @return */ public static String[] getScopes(OWLOntology config) { Set<OWLIndividual> scopes = cScope.getIndividuals(config); List<String> result = new ArrayList<String>(); for (OWLIndividual iScope : scopes) { for (OWLClassExpression sce : iScope.getTypes(config)) { if (sce.containsConjunct(cScope)) { if (iScope.isNamed()) { result.add(((OWLNamedIndividual) iScope).getIRI() .toString()); } } } } return result.toArray(EMPTY_IRI_ARRAY); }
/** * Utility method to get all the values of a property from a Library subject * * @param ontology * @param individualIRI * @param op * @return */ private static String[] getLibraryObjectPropertyValues(OWLOntology ontology, String individualIRI, OWLObjectProperty op) { Set<OWLIndividual> scopes = cLibrary.getIndividuals(ontology); List<String> result = new ArrayList<String>(); for (OWLIndividual iLibrary : scopes) { if (iLibrary.isNamed()) { if (((OWLNamedIndividual) iLibrary).getIRI().toString().equals(individualIRI)) { Set<OWLIndividual> values = iLibrary.getObjectPropertyValues(op, ontology); Iterator<OWLIndividual> it = values.iterator(); while (it.hasNext()) { OWLIndividual i = it.next(); if (i.isNamed()) result.add(((OWLNamedIndividual) iLibrary).getIRI().toString()); } } } } return result.toArray(EMPTY_IRI_ARRAY); }
/** * To get all the instances of Scope in this configuration * * @param config * @return */ public static String[] getScopes(OWLOntology config) { Set<OWLIndividual> scopes = cScope.getIndividuals(config); List<String> result = new ArrayList<String>(); for (OWLIndividual iScope : scopes) { for (OWLClassExpression sce : iScope.getTypes(config)) { if (sce.containsConjunct(cScope)) { if (iScope.isNamed()) { result.add(((OWLNamedIndividual) iScope).getIRI().toString()); } } } } return result.toArray(EMPTY_IRI_ARRAY); }
/** * To get all the instances of Scope in this configuration * * @param config * @return */ public static String[] getScopes(OWLOntology config) { Set<OWLIndividual> scopes = cScope.getIndividuals(config); List<String> result = new ArrayList<String>(); for (OWLIndividual iScope : scopes) { for (OWLClassExpression sce : iScope.getTypes(config)) { if (sce.containsConjunct(cScope)) { if (iScope.isNamed()) { result.add(((OWLNamedIndividual) iScope).getIRI().toString()); } } } } return result.toArray(EMPTY_IRI_ARRAY); }
/** * Utility method to get all the values of a property from a Library subject * * @param ontology * @param individualIRI * @param op * @return */ private static String[] getLibraryObjectPropertyValues(OWLOntology ontology, String individualIRI, OWLObjectProperty op) { Set<OWLIndividual> scopes = cLibrary.getIndividuals(ontology); List<String> result = new ArrayList<String>(); for (OWLIndividual iLibrary : scopes) { if (iLibrary.isNamed()) { if (((OWLNamedIndividual) iLibrary).getIRI().toString().equals(individualIRI)) { Set<OWLIndividual> values = iLibrary.getObjectPropertyValues(op, ontology); Iterator<OWLIndividual> it = values.iterator(); while (it.hasNext()) { OWLIndividual i = it.next(); if (i.isNamed()) result.add(((OWLNamedIndividual) iLibrary).getIRI().toString()); } } } } return result.toArray(EMPTY_IRI_ARRAY); }
/** * Utility method to get all the values of a property from a Library subject * * @param ontology * @param individualIRI * @param op * @return */ private static String[] getLibraryObjectPropertyValues( OWLOntology ontology, String individualIRI, OWLObjectProperty op) { Set<OWLIndividual> scopes = cLibrary.getIndividuals(ontology); List<String> result = new ArrayList<String>(); for (OWLIndividual iLibrary : scopes) { if (iLibrary.isNamed()) { if (((OWLNamedIndividual) iLibrary).getIRI().toString().equals( individualIRI)) { Set<OWLIndividual> values = iLibrary .getObjectPropertyValues(op, ontology); Iterator<OWLIndividual> it = values.iterator(); while (it.hasNext()) { OWLIndividual i = it.next(); if (i.isNamed()) result.add(((OWLNamedIndividual) iLibrary).getIRI() .toString()); } } } } return result.toArray(EMPTY_IRI_ARRAY); }
private static void addIndividuals(OWLOntology ontology, OWLClass cls, Set<OWLIndividual> individuals, Set<OWLClass> includedClasses) { if (!includedClasses.contains(cls)) { includedClasses.add(cls); individuals.addAll(cls.getIndividuals(ontology.getImportsClosure())); for (OWLClassExpression subCls : cls.getSubClasses(ontology.getImportsClosure())) { if (!subCls.isAnonymous()) { addIndividuals(ontology, subCls.asOWLClass(), individuals, includedClasses); } } } }
String individualIRI, OWLObjectProperty op) { Set<OWLIndividual> scopes = cScope.getIndividuals(ontology); List<String> result = new ArrayList<String>();
protected void refill() { individualsInList.clear(); OWLClass cls = getOWLWorkspace().getOWLSelectionModel().getLastSelectedClass(); if (cls != null){ Set<OWLIndividual> individuals = cls.getIndividuals(getOntologies()); for (OWLIndividual ind : individuals){ if (!ind.isAnonymous()){ //TODO: why are anonymous individuals filtered out? individualsInList.add(ind.asOWLNamedIndividual()); } } if (cls.equals(getOWLModelManager().getOWLDataFactory().getOWLThing())) { individualsInList.addAll(getUntypedIndividuals()); } } reset(); }
protected void refill() { individualsInList.clear(); OWLClass cls = getOWLWorkspace().getOWLSelectionModel().getLastSelectedClass(); if (cls != null){ Set<OWLIndividual> individuals = cls.getIndividuals(getOntologies()); for (OWLIndividual ind : individuals){ if (!ind.isAnonymous()){ //TODO: why are anonymous individuals filtered out? individualsInList.add(ind.asOWLNamedIndividual()); } } if (cls.equals(getOWLModelManager().getOWLDataFactory().getOWLThing())) { individualsInList.addAll(getUntypedIndividuals()); } } reset(); }
/** * @param args * @throws OWLOntologyCreationException * @throws OWLOntologyStorageException */ public static void main(String[] args) throws OWLOntologyCreationException, OWLOntologyStorageException { File metaprojectLocation = new File(args[0]); String dataDir = args[1]; OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); OWLDataFactory factory = manager.getOWLDataFactory(); MetaprojectVocabulary.addIRIMapper(manager); OWLOntology ontology = manager.loadOntologyFromOntologyDocument(metaprojectLocation); List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>(); for (OWLDataPropertyAssertionAxiom axiom : ontology.getAxioms(AxiomType.DATA_PROPERTY_ASSERTION)) { if (axiom.getProperty().equals(HAS_ROOT_PATH)) { OWLIndividual server = axiom.getSubject(); changes.add(new RemoveAxiom(ontology, axiom)); changes.add(new AddAxiom(ontology, factory.getOWLDataPropertyAssertionAxiom(HAS_ROOT_PATH, server, dataDir))); } } for (OWLIndividual server : STANDARD_SERVER.getIndividuals(ontology)) { changes.add(new AddAxiom(ontology, factory.getOWLDataPropertyAssertionAxiom(HAS_ROOT_PATH, server, dataDir))); } manager.applyChanges(changes); manager.saveOntology(ontology); LOGGER.info("Set data directory to " + dataDir); }
/** * @param args * @throws OWLOntologyCreationException * @throws OWLOntologyStorageException */ public static void main(String[] args) throws OWLOntologyCreationException, OWLOntologyStorageException { File metaprojectLocation = new File(args[0]); int port = Integer.parseInt(args[1]); OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); OWLDataFactory factory = manager.getOWLDataFactory(); MetaprojectVocabulary.addIRIMapper(manager); OWLOntology ontology = manager.loadOntologyFromOntologyDocument(metaprojectLocation); List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>(); for (OWLDataPropertyAssertionAxiom axiom : ontology.getAxioms(AxiomType.DATA_PROPERTY_ASSERTION)) { if (axiom.getProperty().equals(HAS_REGISTRY_PORT) || axiom.getProperty().equals(HAS_SERVER_PORT)) { OWLIndividual server = axiom.getSubject(); changes.add(new RemoveAxiom(ontology, axiom)); changes.add(new AddAxiom(ontology, factory.getOWLDataPropertyAssertionAxiom(axiom.getProperty(), server, port))); } } for (OWLIndividual server : STANDARD_SERVER.getIndividuals(ontology)) { changes.add(new AddAxiom(ontology, factory.getOWLDataPropertyAssertionAxiom(HAS_SERVER_PORT, server, port))); changes.add(new AddAxiom(ontology, factory.getOWLDataPropertyAssertionAxiom(HAS_REGISTRY_PORT, server, port))); } manager.applyChanges(changes); manager.saveOntology(ontology); LOGGER.info("Port set to " + port); }
/** * @param args * @throws OWLOntologyCreationException * @throws OWLOntologyStorageException */ public static void main(String[] args) throws OWLOntologyCreationException, OWLOntologyStorageException { File metaprojectLocation = new File(args[0]); String configurationDir = args[1]; OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); OWLDataFactory factory = manager.getOWLDataFactory(); MetaprojectVocabulary.addIRIMapper(manager); OWLOntology ontology = manager.loadOntologyFromOntologyDocument(metaprojectLocation); List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>(); for (OWLDataPropertyAssertionAxiom axiom : ontology.getAxioms(AxiomType.DATA_PROPERTY_ASSERTION)) { if (axiom.getProperty().equals(HAS_CONFIGURATION_PATH)) { OWLIndividual server = axiom.getSubject(); changes.add(new RemoveAxiom(ontology, axiom)); changes.add(new AddAxiom(ontology, factory.getOWLDataPropertyAssertionAxiom(HAS_CONFIGURATION_PATH, server, configurationDir))); } } for (OWLIndividual server : STANDARD_SERVER.getIndividuals(ontology)) { changes.add(new AddAxiom(ontology, factory.getOWLDataPropertyAssertionAxiom(HAS_CONFIGURATION_PATH, server, configurationDir))); } manager.applyChanges(changes); manager.saveOntology(ontology); LOGGER.info("Set configuration directory to " + configurationDir); } }