Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package org.geneontology.owl.differ.render
import com.google.common.base.Optional
import org.apache.commons.io.output.ByteArrayOutputStream
import org.apache.commons.text.StringEscapeUtils
import org.geneontology.owl.differ.Differ._
import org.geneontology.owl.differ.ManchesterSyntaxOWLObjectRenderer
import org.geneontology.owl.differ.Util.OptionalOption
import org.geneontology.owl.differ.shortform.{HTMLLinkShortFormProvider, HTMLSafeIRIShortFormProvider, HTMLSafeShortFormProvider}
import org.semanticweb.owlapi.apibinding.OWLManager
import org.semanticweb.owlapi.model._
import org.semanticweb.owlapi.util.{AnnotationValueShortFormProvider, SimpleIRIShortFormProvider, SimpleShortFormProvider}
import java.io.{OutputStream, PrintWriter, Writer}
import java.nio.charset.StandardCharsets
import scala.jdk.CollectionConverters._
import scala.util.Using
object HTMLDiffRenderer {
private val factory = OWLManager.getOWLDataFactory
private val rdfsLabel = factory.getRDFSLabel
def renderWriter(diff: GroupedDiff, renderingOntologyProvider: OWLOntologySetProvider, givenWriter: Writer): Unit =
Using.resource(new PrintWriter(givenWriter)) { writer =>
val shortFormProvider = new HTMLSafeShortFormProvider(new AnnotationValueShortFormProvider(renderingOntologyProvider, new SimpleShortFormProvider(), new HTMLSafeIRIShortFormProvider(new SimpleIRIShortFormProvider()), List(rdfsLabel).asJava, Map.empty[OWLAnnotationProperty, java.util.List[String]].asJava))
val htmlLinkShortFormProvider = new HTMLLinkShortFormProvider(shortFormProvider)
val labelRenderer = new ManchesterSyntaxOWLObjectRenderer()
labelRenderer.setShortFormProvider(shortFormProvider)
val htmlRenderer = new ManchesterSyntaxOWLObjectRenderer()
htmlRenderer.setShortFormProvider(htmlLinkShortFormProvider)
val groupsToLabels: Map[Grouping, String] = diff.groups.keys.map {
case group @ IRIGrouping(iri) => group -> labelRenderer.render(factory.getOWLClass(iri)) // send as OWLClass because labels aren't rendered for IRIs
case group @ GCIGrouping => group -> "GCIs"
case group @ RuleGrouping => group -> "Rules"
case group @ NonIRIGrouping(obj) => group -> labelRenderer.render(obj)
case group @ OntologyImportGrouping => group -> "Ontology imports"
case group @ OntologyAnnotationGrouping => group -> "Ontology annotations"
}.toMap
val sortedGroups = OntologyImportGrouping :: OntologyAnnotationGrouping :: (diff.groups - OntologyImportGrouping - OntologyAnnotationGrouping).keys.toList.sortBy(groupsToLabels)
val header =
s"""
OWL diff