protected void writeImports(OWLImportsDeclaration decl) { fireSectionItemPrepared(IMPORT.toString()); write(IMPORT.toString()); write(":"); writeSpace(); fireSectionRenderingStarted(IMPORT.toString()); writeFullURI(decl.getIRI().toString()); writeNewLine(); fireSectionRenderingFinished(IMPORT.toString()); }
/** * Write entity section end. * * @param type the type */ protected void writeEntitySectionEnd(String type) { fireFrameRenderingFinished(type); popTab(); writeNewLine(); }
/** * Write section. * * @param keyword the keyword */ public void writeSection(ManchesterOWLSyntax keyword) { write("", keyword, ""); write(":"); writeSpace(); }
/** * @param commentDelim the comment delim * @param comment the comment * @param placeOnNewline the place on newline */ public void writeComment(String commentDelim, String comment, boolean placeOnNewline) { if (placeOnNewline) { writeNewLine(); } write(commentDelim); write(comment); writeNewLine(); }
String sec = keyword.toString(); if (content.hasNext() || renderingDirector.renderEmptyFrameSection(keyword, o)) { fireSectionRenderingPrepared(sec); writeSection(keyword); writeOntologiesList(o); incrementTab(4); writeNewLine(); fireSectionRenderingStarted(sec); while (content.hasNext()) { Object obj = content.next(); fireSectionItemPrepared(sec); if (obj instanceof OWLObject) { ((OWLObject) obj).accept(this); } else { write(obj.toString()); write(delimiter); fireSectionItemFinished(sec); if (newline) { writeNewLine(); fireSectionItemFinished(sec); fireSectionRenderingFinished(sec); popTab(); writeNewLine(); writeNewLine();
axioms.addAll(writeEntityStart(INDIVIDUAL, individual)); if (!isFiltered(AxiomType.CLASS_ASSERTION)) { SectionMap<Object, OWLAxiom> expressions = new SectionMap<>(); filtersort(o.classAssertionAxioms(individual)).forEach(ax -> { expressions.put(ax.getClassExpression(), ax); axioms.add(ax); }); writeSection(TYPES, expressions, ",", true); .collect(toList()); if (!assertions.isEmpty()) { handleAssertions(assertions); if (!isFiltered(AxiomType.SAME_INDIVIDUAL)) { Collection<OWLIndividual> inds = sortedCollection(); filtersort(o.sameIndividualAxioms(individual)).forEach(ax -> { add(inds, ax.individuals()); axioms.add(ax); }); inds.remove(individual); writeSection(SAME_AS, inds.iterator(), ",", true); if (!isFiltered(AxiomType.DIFFERENT_INDIVIDUALS)) { Collection<OWLIndividual> inds = sortedCollection(); Collection<OWLDifferentIndividualsAxiom> nary = sortedCollection(); filtersort(o.differentIndividualAxioms(individual)).forEach(ax -> { if (ax.individuals().count() == 2) { add(inds, ax.individuals());
/** * Write ontology header. */ public void writeOntologyHeader() { event = new RendererEvent(this, o); fireFrameRenderingPrepared(ONTOLOGY.toString()); write(ONTOLOGY.toString()); write(":"); writeSpace(); if (!o.isAnonymous()) { int indent = getIndent(); writeFullURI(o.getOntologyID().getOntologyIRI().get().toString()); writeNewLine(); pushTab(indent); Optional<IRI> versionIRI = o.getOntologyID().getVersionIRI(); if (versionIRI.isPresent()) { writeFullURI(versionIRI.get().toString()); } popTab(); } fireFrameRenderingStarted(ONTOLOGY.toString()); writeNewLine(); o.importsDeclarations().sorted().forEach(this::writeImports); writeNewLine(); writeSection(ANNOTATIONS, o.annotations().iterator(), ",", true); fireFrameRenderingFinished(ONTOLOGY.toString()); }
writePrefixMap(); writeNewLine(); writeOntologyHeader(); o.annotationPropertiesInSignature().sorted(ooc).forEach(this::write); o.datatypesInSignature().sorted(ooc).forEach(this::write); o.objectPropertiesInSignature().sorted(ooc).forEach(prop -> { write(prop); OWLObjectPropertyExpression invProp = prop.getInverseProperty(); if (o.axioms(invProp).count() > 0) { write(invProp); .forEach(ax -> writeMoreThanTwo(ax, ax.classExpressions(), DISJOINT_CLASSES)); .forEach(ax -> writeMoreThanTwo(ax, ax.classExpressions(), EQUIVALENT_CLASSES)); .forEach(ax -> writeMoreThanTwo(ax, ax.properties(), DISJOINT_PROPERTIES)); .forEach(ax -> writeMoreThanTwo(ax, ax.properties(), EQUIVALENT_PROPERTIES)); .forEach(ax -> writeMoreThanTwo(ax, ax.properties(), DISJOINT_PROPERTIES)); .forEach(ax -> writeMoreThanTwo(ax, ax.properties(), EQUIVALENT_PROPERTIES));
/** * Write entity start. * * @param keyword the keyword * @param entity the entity * @return written axioms */ private Collection<OWLAnnotationAssertionAxiom> writeEntityStart(ManchesterOWLSyntax keyword, OWLObject entity) { event = new RendererEvent(this, entity); String kw = keyword.toString(); fireFrameRenderingPrepared(kw); writeSection(keyword); entity.accept(this); fireFrameRenderingStarted(kw); writeNewLine(); incrementTab(4); writeNewLine(); if (entity instanceof OWLEntity) { return writeAnnotations(((OWLEntity) entity).getIRI()); } else if (entity instanceof OWLAnonymousIndividual) { return writeAnnotations((OWLAnonymousIndividual) entity); } return Collections.emptySet(); }
/** * Write prefix map. */ public void writePrefixMap() { ShortFormProvider sfp = getShortFormProvider(); if (!(sfp instanceof ManchesterOWLSyntaxPrefixNameShortFormProvider)) { return; } ManchesterOWLSyntaxPrefixNameShortFormProvider prov = (ManchesterOWLSyntaxPrefixNameShortFormProvider) sfp; Map<String, String> prefixMap = prov.getPrefixName2PrefixMap(); prefixMap.entrySet().stream().sorted((o1, o2) -> o1.getKey().compareTo(o2.getKey())) .forEach(value -> { write(PREFIX.toString()); write(": "); write(value.getKey()); write(" "); writeFullURI(value.getValue()); writeNewLine(); }); if (!prefixMap.isEmpty()) { writeNewLine(); writeNewLine(); } }
/** * Write annotations. * * @param subject the subject * @return written axioms */ public Collection<OWLAnnotationAssertionAxiom> writeAnnotations(OWLAnnotationSubject subject) { Collection<OWLAnnotationAssertionAxiom> axioms = sortedCollection(); if (!isFiltered(AxiomType.ANNOTATION_ASSERTION)) { SectionMap<Object, OWLAxiom> sectionMap = new SectionMap<>(); filtersort(o.annotationAssertionAxioms(subject)).forEach(ax -> { axioms.add(ax); sectionMap.put(ax.getAnnotation(), ax); }); writeSection(ANNOTATIONS, sectionMap, ",", true); } return axioms; }
@Override public void render(OWLOntology ontology, PrintWriter writer) throws OWLRendererException { ManchesterOWLSyntaxFrameRenderer ren = new ManchesterOWLSyntaxFrameRenderer(ontology, writer, new ManchesterOWLSyntaxPrefixNameShortFormProvider(ontology.getFormat())); ren.writeOntology(); ren.flush(); } }
@Override protected void storeOntology(OWLOntology ontology, PrintWriter writer, OWLDocumentFormat format) throws OWLOntologyStorageException { ManchesterOWLSyntaxFrameRenderer ren = new ManchesterOWLSyntaxFrameRenderer( ontology, writer, new ManchesterOWLSyntaxPrefixNameShortFormProvider(format)); ren.writeOntology(); } }
@Nonnull @Override public GetManchesterSyntaxFrameResult execute(@Nonnull GetManchesterSyntaxFrameAction action, @Nonnull ExecutionContext executionContext) { var writer = new StringWriter(); var escapingShortFormProvider = new EscapingShortFormProvider(dictionaryManager); var frameRenderer = new ManchesterOWLSyntaxFrameRenderer(importsClosure.getImportsClosure(), writer, escapingShortFormProvider); frameRenderer.setOntologyIRIShortFormProvider(ontologyIRIShortFormProvider); frameRenderer.setRenderExtensions(true); frameRenderer.writeFrame(action.getSubject()); var frameSubject = renderingManager.getRendering(action.getSubject()); return GetManchesterSyntaxFrameResult.get(frameSubject, writer.getBuffer().toString()); }
OWLEntityFrameRendererAdapter(OWLModelManager mngr, Writer writer) { ren = new ManchesterOWLSyntaxFrameRenderer(mngr.getActiveOntology(), writer, mngr.getOWLEntityRenderer()); }
String sec = keyword.toString(); if (content.hasNext() || renderingDirector.renderEmptyFrameSection(keyword, o)) { fireSectionRenderingPrepared(sec); writeSection(keyword); writeOntologiesList(o); incrementTab(4); writeNewLine(); fireSectionRenderingStarted(sec); while (content.hasNext()) { Object obj = content.next(); fireSectionItemPrepared(sec); if (obj instanceof OWLObject) { ((OWLObject) obj).accept(this); } else { write(obj.toString()); write(delimiter); fireSectionItemFinished(sec); if (newline) { writeNewLine(); fireSectionItemFinished(sec); fireSectionRenderingFinished(sec); popTab(); writeNewLine(); writeNewLine();
axioms.addAll(writeEntityStart(INDIVIDUAL, individual)); if (!isFiltered(AxiomType.CLASS_ASSERTION)) { SectionMap<Object, OWLAxiom> expressions = new SectionMap<>(); filtersort(o.classAssertionAxioms(individual)).forEach(ax -> { expressions.put(ax.getClassExpression(), ax); axioms.add(ax); }); writeSection(TYPES, expressions, ",", true); .collect(toList()); if (!assertions.isEmpty()) { handleAssertions(assertions); if (!isFiltered(AxiomType.SAME_INDIVIDUAL)) { Collection<OWLIndividual> inds = sortedCollection(); filtersort(o.sameIndividualAxioms(individual)).forEach(ax -> { add(inds, ax.individuals()); axioms.add(ax); }); inds.remove(individual); writeSection(SAME_AS, inds.iterator(), ",", true); if (!isFiltered(AxiomType.DIFFERENT_INDIVIDUALS)) { Collection<OWLIndividual> inds = sortedCollection(); Collection<OWLDifferentIndividualsAxiom> nary = sortedCollection(); filtersort(o.differentIndividualAxioms(individual)).forEach(ax -> { if (ax.individuals().count() == 2) { add(inds, ax.individuals());
/** * Write ontology header. */ public void writeOntologyHeader() { event = new RendererEvent(this, o); fireFrameRenderingPrepared(ONTOLOGY.toString()); write(ONTOLOGY.toString()); write(":"); writeSpace(); if (!o.isAnonymous()) { int indent = getIndent(); writeFullURI(o.getOntologyID().getOntologyIRI().get().toString()); writeNewLine(); pushTab(indent); Optional<IRI> versionIRI = o.getOntologyID().getVersionIRI(); if (versionIRI.isPresent()) { writeFullURI(versionIRI.get().toString()); } popTab(); } fireFrameRenderingStarted(ONTOLOGY.toString()); writeNewLine(); o.importsDeclarations().sorted().forEach(this::writeImports); writeNewLine(); writeSection(ANNOTATIONS, o.annotations().iterator(), ",", true); fireFrameRenderingFinished(ONTOLOGY.toString()); }
writePrefixMap(); writeNewLine(); writeOntologyHeader(); o.annotationPropertiesInSignature().sorted(ooc).forEach(this::write); o.datatypesInSignature().sorted(ooc).forEach(this::write); o.objectPropertiesInSignature().sorted(ooc).forEach(prop -> { write(prop); OWLObjectPropertyExpression invProp = prop.getInverseProperty(); if (o.axioms(invProp).count() > 0) { write(invProp); .forEach(ax -> writeMoreThanTwo(ax, ax.classExpressions(), DISJOINT_CLASSES)); .forEach(ax -> writeMoreThanTwo(ax, ax.classExpressions(), EQUIVALENT_CLASSES)); .forEach(ax -> writeMoreThanTwo(ax, ax.properties(), DISJOINT_PROPERTIES)); .forEach(ax -> writeMoreThanTwo(ax, ax.properties(), EQUIVALENT_PROPERTIES)); .forEach(ax -> writeMoreThanTwo(ax, ax.properties(), DISJOINT_PROPERTIES)); .forEach(ax -> writeMoreThanTwo(ax, ax.properties(), EQUIVALENT_PROPERTIES));