use of org.semanticweb.owlapi.util.DefaultPrefixManager in project webprotege by protegeproject.
the class ProjectChangesManager_IT method createChanges.
private static void createChanges(OWLOntologyManager manager, OWLOntology rootOntology, OWLDataFactory dataFactory, RevisionManager revisionManager) {
PrefixManager pm = new DefaultPrefixManager();
pm.setDefaultPrefix("http://stuff.com/");
List<OWLOntologyChange> changeList = new ArrayList<>();
for (int i = 0; i < CHANGE_COUNT; i++) {
OWLClass clsA = dataFactory.getOWLClass(":A" + i, pm);
OWLClass clsB = dataFactory.getOWLClass(":B" + i, pm);
OWLSubClassOfAxiom ax = dataFactory.getOWLSubClassOfAxiom(clsA, clsB);
changeList.add(new AddAxiom(rootOntology, ax));
OWLAnnotationProperty rdfsLabel = dataFactory.getRDFSLabel();
IRI annotationSubject = clsA.getIRI();
OWLAnnotationAssertionAxiom labAxA = dataFactory.getOWLAnnotationAssertionAxiom(rdfsLabel, annotationSubject, dataFactory.getOWLLiteral("Class A " + i));
changeList.add(new AddAxiom(rootOntology, labAxA));
OWLAnnotationAssertionAxiom labAxB = dataFactory.getOWLAnnotationAssertionAxiom(rdfsLabel, annotationSubject, dataFactory.getOWLLiteral("Class B " + i));
changeList.add(new AddAxiom(rootOntology, labAxB));
}
manager.applyChanges(changeList);
revisionManager.addRevision(UserId.getUserId("MH"), changeList.stream().map(OWLOntologyChange::getChangeRecord).collect(toList()), "Adding axioms");
}
use of org.semanticweb.owlapi.util.DefaultPrefixManager in project snow-owl by b2ihealthcare.
the class DelegateOntology method createPrefixManager.
/**
* Creates a {@link DefaultPrefixManager} instance for the specified ontology.
* Prefixes will be configured in accordance with the OWL reference set
* specification, with the exception of the default prefix.
*
* @see <a href="https://docs.google.com/document/d/1jn9jiWe2cKNA5WrbQZ2MGWV_VoKU6Una6ZpQLskeRXA/">OWL
* Reference Sets Specification (draft)</a>
* @return the created prefix manager
*/
private static DefaultPrefixManager createPrefixManager() {
final DefaultPrefixManager prefixManager = new DefaultPrefixManager();
prefixManager.setDefaultPrefix(NAMESPACE_SCT);
prefixManager.setPrefix(PREFIX_SCT_LONG, NAMESPACE_SCT);
prefixManager.setPrefix(PREFIX_SCTM, NAMESPACE_SCTM);
return prefixManager;
}
use of org.semanticweb.owlapi.util.DefaultPrefixManager in project webprotege by protegeproject.
the class ProjectViewPlaceTokenizer method getPlace.
public ProjectViewPlace getPlace(String token) {
GWT.log("[ProjectViewPlaceTokenizer] Parsing: " + token);
token = URL.decode(token);
GWT.log("[ProjectViewPlaceTokenizer] Decoded: " + token);
MatchResult result = regExp.exec(token);
GWT.log("[ProjectViewPlaceTokenizer] MatchResult: " + result);
String projectId = result.getGroup(1);
String perspectiveId = result.getGroup(2);
String selectionString = result.getGroup(4);
GWT.log("[ProjectViewPlaceTokenizer] Parsed: ProjectId: " + projectId);
GWT.log("[ProjectViewPlaceTokenizer] Parsed: PerspectiveId: " + perspectiveId);
GWT.log("[ProjectViewPlaceTokenizer] Parsed: Selection: " + selectionString);
ProjectViewPlace.Builder builder = new ProjectViewPlace.Builder(ProjectId.get(projectId), new PerspectiveId(perspectiveId));
if (selectionString != null) {
ItemTokenizer tokenizer = new ItemTokenizer();
List<ItemToken> tokenList = tokenizer.parseTokens(selectionString);
for (ItemToken t : tokenList) {
OWLDataFactoryImpl dataFactory = new OWLDataFactoryImpl();
ItemTokenParser parser = new ItemTokenParser();
DefaultPrefixManager prefixManager = new DefaultPrefixManager();
prefixManager.setPrefix("owl:", Namespaces.OWL.getPrefixIRI());
List<Item<?>> entity = parser.parse(t, new DefaultItemTypeMapper(dataFactory, prefixManager));
for (Item<?> item : entity) {
builder.withSelectedItem(item);
}
}
}
return builder.build();
}
use of org.semanticweb.owlapi.util.DefaultPrefixManager in project graal by graphik-team.
the class OWL2Parser method getShortFormProvider.
// /////////////////////////////////////////////////////////////////////////
// PRIVATE METHODS
// /////////////////////////////////////////////////////////////////////////
private ShortFormProvider getShortFormProvider(OWLOntology ontology) {
OWLDocumentFormat format = this.manager.getOntologyFormat(this.ontology);
DefaultPrefixManager pm = new DefaultPrefixManager();
if (prefixEnable && format.isPrefixOWLOntologyFormat()) {
PrefixDocumentFormat prefixFormat = format.asPrefixOWLOntologyFormat();
Map<String, String> prefixMap = prefixFormat.getPrefixName2PrefixMap();
Set<String> forbiddenPrefix = new TreeSet<>();
forbiddenPrefix.add("xml:");
forbiddenPrefix.add("rdf:");
forbiddenPrefix.add("rdfs:");
forbiddenPrefix.add("owl:");
for (Map.Entry<String, String> entry : prefixMap.entrySet()) {
String prefix = entry.getKey();
if (!forbiddenPrefix.contains(prefix)) {
pm.setPrefix(prefix, entry.getValue());
prefix = prefix.substring(0, prefix.length() - 1);
buffer.write(new Prefix(prefix, entry.getValue()));
}
}
}
return pm;
}
Aggregations