forked from ease-crc/soma
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from mrnolte/playground
Playground
- Loading branch information
Showing
7 changed files
with
56 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
scripts/java/src/main/java/main/GuardingXmlCatalogIriMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package main; | ||
|
||
import org.protege.xmlcatalog.CatalogUtilities; | ||
import org.protege.xmlcatalog.XMLCatalog; | ||
import org.protege.xmlcatalog.entry.Entry; | ||
import org.protege.xmlcatalog.redirect.UriRedirectVisitor; | ||
import org.semanticweb.owlapi.model.IRI; | ||
import org.semanticweb.owlapi.model.OWLOntologyIRIMapper; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
public class GuardingXmlCatalogIriMapper implements OWLOntologyIRIMapper { | ||
private final XMLCatalog catalog; | ||
|
||
public GuardingXmlCatalogIriMapper(File f) throws IOException { | ||
this(CatalogUtilities.parseDocument(f.toURI().toURL())); | ||
} | ||
|
||
public GuardingXmlCatalogIriMapper(XMLCatalog catalog) { | ||
this.catalog = catalog; | ||
} | ||
|
||
public IRI getDocumentIRI(IRI original) { | ||
UriRedirectVisitor visitor = new UriRedirectVisitor(original.toURI()); | ||
|
||
for (Entry subEntry : catalog.getEntries()) { | ||
subEntry.accept(visitor); | ||
if (visitor.getRedirect() != null) { | ||
return IRI.create(visitor.getRedirect()); | ||
} | ||
} | ||
throw new RuntimeException("You are trying to load an ontology from an online source, but we decided to self-host them, e.g, DUL. The ontology you are trying to load is: " + original); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters