Package org.incenp.obofoundry.kgcl
Class KGCLHelper
java.lang.Object
org.incenp.obofoundry.kgcl.KGCLHelper
A class providing static helper methods to work with KGCL.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidapply(List<Change> changeset, IPatcher patcher, boolean noPartialApply, List<RejectedChange> rejects) Applies a KGCL changeset using the provided patcher object.static voidapply(List<Change> changeset, org.semanticweb.owlapi.model.OWLOntology ontology, org.semanticweb.owlapi.reasoner.OWLReasoner reasoner, boolean noPartialApply) Applies a KGCL changeset to an ontology.static voidapply(List<Change> changeset, org.semanticweb.owlapi.model.OWLOntology ontology, org.semanticweb.owlapi.reasoner.OWLReasoner reasoner, boolean noPartialApply, List<RejectedChange> rejects) Applies a KGCL changeset to an ontology.static voidapply(List<Change> changeset, org.semanticweb.owlapi.model.OWLOntology ontology, org.semanticweb.owlapi.reasoner.OWLReasoner reasoner, boolean noPartialApply, List<RejectedChange> rejects, boolean provisional) Applies a KGCL changeset to an ontology.extractPendingChanges(org.semanticweb.owlapi.model.OWLOntology ontology, ZonedDateTime before) Gets the "pending" (provisional) changes that are stored as KGCL annotations in the ontology,parse(File kgcl, Map<String, String> prefixMap, List<KGCLSyntaxError> errors, ILabelResolver labelResolver) Parses KGCL from a file and collects syntax errors.Parses KGCL from a file.parse(File kgcl, org.semanticweb.owlapi.model.PrefixManager prefixManager, List<KGCLSyntaxError> errors) Parses KGCL from a file and collects syntax errors.parse(File kgcl, org.semanticweb.owlapi.model.PrefixManager prefixManager, List<KGCLSyntaxError> errors, ILabelResolver labelResolver) Parses KGCL from a file and collects syntax errors.parse(String kgcl, Map<String, String> prefixMap, List<KGCLSyntaxError> errors, ILabelResolver labelResolver) Parses KGCL from a string and collects syntax errors.Parses KGCL from a string.parse(String kgcl, org.semanticweb.owlapi.model.PrefixManager prefixManager, List<KGCLSyntaxError> errors) Parses KGCL from a string and collects syntax errors.parse(String kgcl, org.semanticweb.owlapi.model.PrefixManager prefixManager, List<KGCLSyntaxError> errors, ILabelResolver labelResolver) Parses KGCL from a string and collects syntax errors.
-
Constructor Details
-
KGCLHelper
public KGCLHelper()
-
-
Method Details
-
parse
public static List<Change> parse(String kgcl, org.semanticweb.owlapi.model.PrefixManager prefixManager) Parses KGCL from a string.- Parameters:
kgcl- The KGCL instructions to parse.prefixManager- A prefix manager to expand CURIEs into IRIs. May benull.- Returns:
- A KGCL changeset.
-
parse
public static List<Change> parse(String kgcl, org.semanticweb.owlapi.model.PrefixManager prefixManager, List<KGCLSyntaxError> errors) Parses KGCL from a string and collects syntax errors.- Parameters:
kgcl- The KGCL instructions to parse.prefixManager- A prefix manager to expand CURIEs into IRIs. May benull.errors- A list that will collect any syntax error encountered when parsing. Ifnull, errors will be ignored.- Returns:
- A KGCL changeset.
-
parse
public static List<Change> parse(String kgcl, org.semanticweb.owlapi.model.PrefixManager prefixManager, List<KGCLSyntaxError> errors, ILabelResolver labelResolver) Parses KGCL from a string and collects syntax errors. This method allows the use of labels in place of identifiers.- Parameters:
kgcl- The KGCL instructions to parse.prefixManager- A prefix manager to expand CURIEs into IRIS. May benull.errors- A list that will collect any syntax error encountered when parsing. Ifnull, errors will be ignored.labelResolver- A helper object to resolve labels into identifiers. May benull, in which case any use of a label where an identifier is normally expected would result in a syntax error.- Returns:
- A KGCL changeset.
-
parse
public static List<Change> parse(String kgcl, Map<String, String> prefixMap, List<KGCLSyntaxError> errors, ILabelResolver labelResolver) Parses KGCL from a string and collects syntax errors.- Parameters:
kgcl- The KGCL instructions to parse.prefixMap- A map of prefix names to prefix IRIs.errors- A list that will collect any syntax error encountered when parsing. Ifnull, errors will be ignored.labelResolver- A helper object to resolve labels into identifiers. May benull, in which case any use of a label where an identifier is normally expected would result in an error.- Returns:
- A KGCL changeset.
-
parse
public static List<Change> parse(File kgcl, org.semanticweb.owlapi.model.PrefixManager prefixManager) throws IOException Parses KGCL from a file.- Parameters:
kgcl- The file to parse.prefixManager- A prefix manager to expand CURIEs into IRIs. May benull.- Returns:
- A KGCL changeset.
- Throws:
IOException- If any non-KGCL I/O error occurs.
-
parse
public static List<Change> parse(File kgcl, org.semanticweb.owlapi.model.PrefixManager prefixManager, List<KGCLSyntaxError> errors) throws IOException Parses KGCL from a file and collects syntax errors.- Parameters:
kgcl- The file to parse.prefixManager- A prefix manager to expand CURIEs into IRIs. May benull.errors- A list that will collect any syntax error encountered when parsing. Ifnull, errors will be ignored.- Returns:
- A KGCL changeset.
- Throws:
IOException- If any non-KGCL I/O error occurs.
-
parse
public static List<Change> parse(File kgcl, org.semanticweb.owlapi.model.PrefixManager prefixManager, List<KGCLSyntaxError> errors, ILabelResolver labelResolver) throws IOException Parses KGCL from a file and collects syntax errors. This method allows the use of labels in place of identifiers.- Parameters:
kgcl- The file to parse.prefixManager- A prefix manager to expand CURIEs into IRIs. May benull.errors- A list that will collect any syntax error encountered when parsing. Ifnull, errors will be ignored.labelResolver- A helper object to resolve labels into identifiers. May benull, in which case any use of a label where an identifier is normally expected would result in a syntax error.- Returns:
- A KGCL changeset.
- Throws:
IOException- If any non-KGCL I/O error occurs.
-
parse
public static List<Change> parse(File kgcl, Map<String, String> prefixMap, List<KGCLSyntaxError> errors, ILabelResolver labelResolver) throws IOExceptionParses KGCL from a file and collects syntax errors.- Parameters:
kgcl- The file to parse.prefixMap- A map of prefix names to prefix IRIs.errors- A list that will collect any syntax error encountered when parsing. Ifnull, errors will be ignoredlabelResolver- A helper object to resolve labels into identifiers. May benull, in which case any use of a label where an identifier is normally expected would result in a syntax error.- Returns:
- A KGCL changeset.
- Throws:
IOException- If any non-KGCL I/O error occurs.
-
extractPendingChanges
public static List<Change> extractPendingChanges(org.semanticweb.owlapi.model.OWLOntology ontology, ZonedDateTime before) Gets the "pending" (provisional) changes that are stored as KGCL annotations in the ontology,Note that the annotations are removed during the process.
- Parameters:
ontology- The ontology to extract pending changes from.before- If notnull, only changes older than the specified date are extracted.- Returns:
- The list of pending changes.
-
apply
public static void apply(List<Change> changeset, org.semanticweb.owlapi.model.OWLOntology ontology, org.semanticweb.owlapi.reasoner.OWLReasoner reasoner, boolean noPartialApply) Applies a KGCL changeset to an ontology.- Parameters:
changeset- The changeset to apply.ontology- The ontology to apply it to.reasoner- The reasoner to use.noPartialApply- Iftrue, changes will only be applied if they all can be applied.
-
apply
public static void apply(List<Change> changeset, org.semanticweb.owlapi.model.OWLOntology ontology, org.semanticweb.owlapi.reasoner.OWLReasoner reasoner, boolean noPartialApply, List<RejectedChange> rejects) Applies a KGCL changeset to an ontology.- Parameters:
changeset- The changeset to apply.ontology- The ontology to apply it to.reasoner- The reasoner to use.noPartialApply- Iftrue, changes will only be applied if they can all be applied.rejects- A list that will collect the changes that cannot be applied. May benull.
-
apply
public static void apply(List<Change> changeset, org.semanticweb.owlapi.model.OWLOntology ontology, org.semanticweb.owlapi.reasoner.OWLReasoner reasoner, boolean noPartialApply, List<RejectedChange> rejects, boolean provisional) Applies a KGCL changeset to an ontology.- Parameters:
changeset- The changeset to apply.ontology- The ontology to apply it to.reasoner- The reasoner to use,noPartialApply- Iftrue, changes will only be applied if they can all be applied.rejects- A list that will collect the changes that cannot be applied. May benull.provisional- Iftrue, changes will be recorded in the ontology for later application, rather than applied directly.
-
apply
public static void apply(List<Change> changeset, IPatcher patcher, boolean noPartialApply, List<RejectedChange> rejects) Applies a KGCL changeset using the provided patcher object.- Parameters:
changeset- The changeset to apply.patcher- The patcher for the knowledge graph to modify.noPartialApply- Iftrue, changes will only be applied if they can all be applied.rejects- A list that will collect the changes that cannot be applied. May benull.
-