@Override public String getPrefix(String uri) { for (String prefix : owlmapper.getPrefixName2PrefixMap().keySet()) { if (owlmapper.getPrefixName2PrefixMap().get(prefix).contains(uri)) { return prefix; } } return null; }
@Override public ImmutableMap<String, String> getPrefixMap() { return ImmutableMap.copyOf(owlmapper.getPrefixName2PrefixMap()); }
public void refill() { logger.debug("Clearing changed flag because of a refill operation"); changed = false; // arguably here we should only delete the prefixes that don't have an empty value // it is a little weird when they disappear because they were not committed to the PrefixOWLOntologyFormat prefixes.clear(); prefixValueMap.clear(); for (Map.Entry<String, String> prefixName2PrefixEntry : prefixManager.getPrefixName2PrefixMap().entrySet()) { String prefixName = prefixName2PrefixEntry.getKey(); String prefix = prefixName2PrefixEntry.getValue(); // remove trailing : prefixName = prefixName.substring(0, prefixName.length() - 1); prefixValueMap.put(prefixName, prefix); } prefixes.addAll(prefixValueMap.keySet()); Collections.sort(prefixes); fireTableDataChanged(); }
public void refill() { logger.debug("Clearing changed flag because of a refill operation"); changed = false; // arguably here we should only delete the prefixes that don't have an empty value // it is a little weird when they disappear because they were not committed to the PrefixOWLOntologyFormat prefixes.clear(); prefixValueMap.clear(); for (Map.Entry<String, String> prefixName2PrefixEntry : prefixManager.getPrefixName2PrefixMap().entrySet()) { String prefixName = prefixName2PrefixEntry.getKey(); String prefix = prefixName2PrefixEntry.getValue(); // remove trailing : prefixName = prefixName.substring(0, prefixName.length() - 1); prefixValueMap.put(prefixName, prefix); } prefixes.addAll(prefixValueMap.keySet()); Collections.sort(prefixes); fireTableDataChanged(); }
private void copyPrefixes(OWLDocumentFormat ontologyFormat) { if (!(ontologyFormat instanceof PrefixDocumentFormat)) { return; } PrefixDocumentFormat prefixFormat = (PrefixDocumentFormat) ontologyFormat; if (!isUsingDefaultShortFormProvider()) { resetShortFormProvider(); } ((DefaultPrefixManager) shortFormProvider) .copyPrefixesFrom(prefixFormat.getPrefixName2PrefixMap()); }
private void copyPrefixes(OWLDocumentFormat ontologyFormat) { if (!(ontologyFormat instanceof PrefixDocumentFormat)) { return; } PrefixDocumentFormat prefixFormat = (PrefixDocumentFormat) ontologyFormat; if (!isUsingDefaultShortFormProvider()) { resetShortFormProvider(); } ((DefaultPrefixManager) shortFormProvider) .copyPrefixesFrom(prefixFormat.getPrefixName2PrefixMap()); }
private void copyPrefixes(OWLDocumentFormat ontologyFormat) { if (!(ontologyFormat instanceof PrefixDocumentFormat)) { return; } PrefixDocumentFormat prefixFormat = (PrefixDocumentFormat) ontologyFormat; if (!isUsingDefaultShortFormProvider()) { resetShortFormProvider(); } ((DefaultPrefixManager) shortFormProvider) .copyPrefixesFrom(prefixFormat.getPrefixName2PrefixMap()); }
public static PrefixManager getPrefixOWLOntologyFormat(OWLModelManager modelManager) { OWLOntologyManager owlManager = modelManager.getOWLOntologyManager(); DefaultPrefixManager prefixes = new DefaultPrefixManager(); List<OWLOntology> ontologies = new ArrayList<>(modelManager.getOntologies()); Collections.sort(ontologies, new ActiveOntologyComparator()); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Sorted ontologies = " + ontologies); } Set<String> prefixValues = new HashSet<>(); for (OWLOntology ontology : ontologies) { OWLDocumentFormat format = owlManager.getOntologyFormat(ontology); if (format instanceof PrefixDocumentFormat) { PrefixDocumentFormat newPrefixes = (PrefixDocumentFormat) format; for (Entry<String, String> entry : newPrefixes.getPrefixName2PrefixMap().entrySet()) { String prefixName = entry.getKey(); String prefix = entry.getValue(); if (!prefixes.containsPrefixMapping(prefixName) && !prefixValues.contains(prefix)) { prefixes.setPrefix(prefixName, prefix); prefixValues.add(prefix); } } } } if (LOGGER.isDebugEnabled()) { LOGGER.debug("Merged prefix to prefix value map = " + prefixes.getPrefixName2PrefixMap()); } return prefixes; }
public static PrefixManager getPrefixOWLOntologyFormat(OWLModelManager modelManager) { OWLOntologyManager owlManager = modelManager.getOWLOntologyManager(); DefaultPrefixManager prefixes = new DefaultPrefixManager(); List<OWLOntology> ontologies = new ArrayList<>(modelManager.getOntologies()); ontologies.sort(new ActiveOntologyComparator()); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Sorted ontologies = " + ontologies); } Set<String> prefixValues = new HashSet<>(); for (OWLOntology ontology : ontologies) { OWLDocumentFormat format = owlManager.getOntologyFormat(ontology); if (format instanceof PrefixDocumentFormat) { PrefixDocumentFormat newPrefixes = (PrefixDocumentFormat) format; for (Entry<String, String> entry : newPrefixes.getPrefixName2PrefixMap().entrySet()) { String prefixName = entry.getKey(); String prefix = entry.getValue(); if (!prefixes.containsPrefixMapping(prefixName) && !prefixValues.contains(prefix)) { prefixes.setPrefix(prefixName, prefix); prefixValues.add(prefix); } } } } if (LOGGER.isDebugEnabled()) { LOGGER.debug("Merged prefix to prefix value map = " + prefixes.getPrefixName2PrefixMap()); } return prefixes; }
private final void processOntology() { if (ontologyFormat instanceof PrefixDocumentFormat) { PrefixDocumentFormat namespaceFormat = (PrefixDocumentFormat) ontologyFormat; Map<String, String> namespacesByPrefix = namespaceFormat.getPrefixName2PrefixMap(); for (Map.Entry<String, String> e : namespacesByPrefix.entrySet()) { String xmlnsPrefixName = e.getKey().substring(0, e.getKey().length() - 1); namespaceUtil .setPrefix(verifyNotNull(e.getValue()), verifyNotNull(xmlnsPrefixName)); } } if (ontology.getAxiomCount(AxiomType.SWRL_RULE) != 0) { namespaceUtil.setPrefix(Namespaces.SWRL.toString(), "swrl"); namespaceUtil.setPrefix(Namespaces.SWRLB.toString(), "swrlb"); } getEntitiesThatRequireNamespaces().forEach(this::processEntity); namespaceUtil.getNamespace2PrefixMap().forEach(this::setOWL2Prefix); }
private final void processOntology() { if (ontologyFormat instanceof PrefixDocumentFormat) { PrefixDocumentFormat namespaceFormat = (PrefixDocumentFormat) ontologyFormat; Map<String, String> namespacesByPrefix = namespaceFormat.getPrefixName2PrefixMap(); for (Map.Entry<String, String> e : namespacesByPrefix.entrySet()) { String xmlnsPrefixName = e.getKey().substring(0, e.getKey().length() - 1); namespaceUtil .setPrefix(verifyNotNull(e.getValue()), verifyNotNull(xmlnsPrefixName)); } } if (ontology.getAxiomCount(AxiomType.SWRL_RULE) != 0) { namespaceUtil.setPrefix(Namespaces.SWRL.toString(), "swrl"); namespaceUtil.setPrefix(Namespaces.SWRLB.toString(), "swrlb"); } getEntitiesThatRequireNamespaces().forEach(this::processEntity); namespaceUtil.getNamespace2PrefixMap().forEach(this::setOWL2Prefix); }
private final void processOntology() { if (ontologyFormat instanceof PrefixDocumentFormat) { PrefixDocumentFormat namespaceFormat = (PrefixDocumentFormat) ontologyFormat; Map<String, String> namespacesByPrefix = namespaceFormat.getPrefixName2PrefixMap(); for (Map.Entry<String, String> e : namespacesByPrefix.entrySet()) { String xmlnsPrefixName = e.getKey().substring(0, e.getKey().length() - 1); namespaceUtil .setPrefix(verifyNotNull(e.getValue()), verifyNotNull(xmlnsPrefixName)); } } if (ontology.getAxiomCount(AxiomType.SWRL_RULE) != 0) { namespaceUtil.setPrefix(Namespaces.SWRL.toString(), "swrl"); namespaceUtil.setPrefix(Namespaces.SWRLB.toString(), "swrlb"); } getEntitiesThatRequireNamespaces().forEach(this::processEntity); namespaceUtil.getNamespace2PrefixMap().forEach(this::setOWL2Prefix); }
private final void processOntology() { if (ontologyFormat instanceof PrefixDocumentFormat) { PrefixDocumentFormat namespaceFormat = (PrefixDocumentFormat) ontologyFormat; Map<String, String> namespacesByPrefix = namespaceFormat.getPrefixName2PrefixMap(); for (Map.Entry<String, String> e : namespacesByPrefix.entrySet()) { String xmlnsPrefixName = e.getKey().substring(0, e.getKey().length() - 1); namespaceUtil .setPrefix(verifyNotNull(e.getValue()), verifyNotNull(xmlnsPrefixName)); } } if (ontology.getAxiomCount(AxiomType.SWRL_RULE) != 0) { namespaceUtil.setPrefix(Namespaces.SWRL.toString(), "swrl"); namespaceUtil.setPrefix(Namespaces.SWRLB.toString(), "swrlb"); } getEntitiesThatRequireNamespaces().forEach(this::processEntity); namespaceUtil.getNamespace2PrefixMap().forEach(this::setOWL2Prefix); }
private PrefixManager buildPrefixManager() { PrefixManager prefixManager = new DefaultPrefixManager(); OWLDocumentFormat format = ontology.getOWLOntologyManager().getOntologyFormat(ontology); if (format.isPrefixOWLOntologyFormat()) { Map<String, String> prefixMap = format.asPrefixOWLOntologyFormat().getPrefixName2PrefixMap(); for (String prefixName : prefixMap.keySet()) { prefixManager.setPrefix(prefixName, prefixMap.get(prefixName)); } } return prefixManager; } }
private void postParsing(OWLOntology loadedOntology, VowlData vowlData, OWLOntologyManager manager) { setCorrectType(vowlData.getEntityMap().values()); parseAnnotations(vowlData, manager); fillDomainRanges(vowlData); createSubclassProperties(vowlData); new ImportedChecker(vowlData, manager, loadedOntology, loadedOntologyPath).execute(); vowlData.getEntityMap().values().forEach(entity -> entity.accept(new EquivalentSorter(ontology.getOntologyID().getOntologyIRI().orElse(IRI .create(loadedOntologyPath)), vowlData))); new BaseIriCollector(vowlData).execute(); PrefixDocumentFormat pm = (PrefixDocumentFormat) manager.getOntologyFormat(ontology); Map<String, String> prefixName2PrefixMap = pm.getPrefixName2PrefixMap(); // adding prefix list to that thing; for (Map.Entry<String,String> entry : prefixName2PrefixMap.entrySet()) { vowlData.addPrefix(entry.getKey(),entry.getValue()); } // get the importedOntologies; Stream<OWLOntology> imported=ontology.imports(); for (OWLOntology importedOntology : imported.collect(Collectors.toSet())) { PrefixDocumentFormat i_pm = (PrefixDocumentFormat) manager.getOntologyFormat(importedOntology); Map<String, String> i_prefixName2PrefixMap = i_pm.getPrefixName2PrefixMap(); // adding prefix list to that thing; for (Map.Entry<String,String> entry : i_prefixName2PrefixMap.entrySet()) { vowlData.addPrefix(entry.getKey(),entry.getValue()); } } }
@Override public void updatePrefixes(@NonNull OWLOntology ontology) { OWLOntologyManager owlOntologyManager = ontology.getOWLOntologyManager(); OWLDocumentFormat ontologyFormat = owlOntologyManager.getOntologyFormat(ontology); this.prefixManager.clear(); if (this.defaultPrefix != null) this.prefixManager.setDefaultPrefix(this.defaultPrefix); if (ontologyFormat != null && ontologyFormat.isPrefixOWLOntologyFormat()) { PrefixDocumentFormat prefixOntologyFormat = ontologyFormat.asPrefixOWLOntologyFormat(); Map<@NonNull String, String> map = prefixOntologyFormat.getPrefixName2PrefixMap(); for (String prefix : map.keySet()) this.prefixManager.setPrefix(prefix, map.get(prefix)); } addSWRLAPIPrefixes(); }
private OWLObjectFactory(OWLOntology ontology, OWLEntityResolver entityResolver) { this.entityResolver = entityResolver; owlDataFactory = ontology.getOWLOntologyManager().getOWLDataFactory(); labelToEntityMapper = new LabelToEntityMapper(ontology); OWLDocumentFormat format = ontology.getOWLOntologyManager().getOntologyFormat(ontology); if (format.isPrefixOWLOntologyFormat()) { prefixMap = format.asPrefixOWLOntologyFormat().getPrefixName2PrefixMap(); } }
if (format instanceof PrefixDocumentFormat) { PrefixDocumentFormat fromPrefixFormat = (PrefixDocumentFormat) format; Map<String, String> map = fromPrefixFormat.getPrefixName2PrefixMap(); for (Map.Entry<String, String> e : map.entrySet()) { if (e.getValue() != null && !e.getValue().isEmpty()) {
if (format instanceof PrefixDocumentFormat) { PrefixDocumentFormat fromPrefixFormat = (PrefixDocumentFormat) format; Map<String, String> map = fromPrefixFormat.getPrefixName2PrefixMap(); for (Map.Entry<String, String> e : map.entrySet()) { if (e.getValue() != null && !e.getValue().isEmpty()) {
protected void createPrefixes() { m_prefixes=new Prefixes(); m_prefixes.declareSemanticWebPrefixes(); Set<String> individualIRIs=new HashSet<>(); Set<String> anonIndividualIRIs=new HashSet<>(); for (Individual individual : m_dlOntology.getAllIndividuals()) if (individual.isAnonymous()) addIRI(individual.getIRI(),anonIndividualIRIs); else addIRI(individual.getIRI(),individualIRIs); m_prefixes.declareInternalPrefixes(individualIRIs,anonIndividualIRIs); m_prefixes.declareDefaultPrefix(m_dlOntology.getOntologyIRI()+"#"); // declare prefixes as used in the ontology if possible OWLDocumentFormat format=m_rootOntology.getOWLOntologyManager().getOntologyFormat(m_rootOntology); if (format instanceof PrefixDocumentFormat) { PrefixDocumentFormat prefixFormat=(PrefixDocumentFormat)format; prefixFormat.getPrefixName2PrefixMap().forEach((prefixName,prefix)->{ if (m_prefixes.getPrefixName(prefix)==null) try { m_prefixes.declarePrefix(prefixName,prefix); } catch (@SuppressWarnings("unused") IllegalArgumentException e) { // ignore } }); } } protected void addIRI(String uri,Set<String> prefixIRIs) {