Package alps.java.api.parsing
Klasse PASSReaderWriter
java.lang.Object
alps.java.api.parsing.PASSReaderWriter
- Alle implementierten Schnittstellen:
IPASSReaderWriter
The main parser class (Singleton).
To load a model contained in an owl/rdf formatted file, either use:
- loadOWLParsingStructure() and pass path references to used ontology classes (i.e. the standard-pass-ont.owl) and afterwards loadModels(paths) with path references to the owl files containing the models
- loadModels(paths, true) with path references to the owl files containing the models.
Loading the parsing structure is expensive, so it is advised to do it separately and not reload it if not necessary.
-
Feldübersicht
Modifizierer und TypFeldBeschreibungThe element factory gets an uri that should be parsed and a list of possible instances of classes this uri can be instanciated with.private static final Logger
private final IParsingTreeMatcher
The matcher creates a mapping between owl classes (found in an owl file) and c# classes (found in the current assembly)private Map<String,
List<org.apache.commons.lang3.tuple.Pair<ITreeNode<IParseablePASSProcessModelElement>, Integer>>> A parsing dictionary that contains the mapping between ontology classes and a list of possible java classesprivate static PASSReaderWriter
Holds the current instance of the PASSReaderWriter class. -
Konstruktorübersicht
ModifiziererKonstruktorBeschreibungprivate
The private constructor that initializes logs -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungprivate List<IPASSProcessModel>
createClassInstancesFromNamedIndividuals
(org.apache.jena.rdf.model.Model graph, Map<String, List<String>> namedIndividualsDict) Method that creates the empty Instances of the Objects which later get completed by the completetObjects() methodorg.apache.jena.rdf.model.Model
exportModel
(IPASSProcessModel model, String filepath) // TODO: Out-Methode public String exportModel(IPASSProcessModel model, String filepath, Model exportGraph) { // Get the graph hold by the model and use the export function given by the library String fullPath = (filepath.endsWith(".owl")) ?findAllNamedIndividualTriples
(org.apache.jena.rdf.model.Model graph) Finds and creates all the named individuals in the given files and creates a new list with all the individualsstatic PASSReaderWriter
Get the current instance of the PASSReaderWriter class.Map<String,
List<org.apache.commons.lang3.tuple.Pair<ITreeNode<IParseablePASSProcessModelElement>, Integer>>> private boolean
isStandardPass
(String trpl) Verifies whether a triple (as string) is part of a standard pass definition owl or a modeprivate boolean
isStandardPass
(org.apache.jena.rdf.model.Statement triple) Verifies whether a triple (as string) is part of a standard pass definition owl or a modelloadModels
(List<String> filepaths) Loads in all the required files given by filepaths.loadModels
(List<String> filepaths, boolean overrideOWLParsingStructure) Loads in all the required files given by filepaths.void
loadOWLParsingStructure
(List<String> filepathsToOWLFiles) The abstract pass ont and/or the standard pass ont must be given either inside the same owl file or as seperate files.private void
preCleanFile
(String filePath) The .NetRDF library has a few problems with input files that are basically stupid E.g. an rdf:RDF xmlns="" at the beginning of an RDF document may cause an Invalid URI exception.void
setModelElementFactory
(IPASSProcessModelElementFactory<IParseablePASSProcessModelElement> elementFactory) Allows to set another factory to create the elements.
-
Felddetails
-
elementFactory
The element factory gets an uri that should be parsed and a list of possible instances of classes this uri can be instanciated with. The list of possible instances is stored inside the parsingDict. the element factory than decides which instance to use. -
matcher
The matcher creates a mapping between owl classes (found in an owl file) and c# classes (found in the current assembly) -
LOGGER
-
parsingDict
private Map<String,List<org.apache.commons.lang3.tuple.Pair<ITreeNode<IParseablePASSProcessModelElement>, Integer>>> parsingDict A parsing dictionary that contains the mapping between ontology classes and a list of possible java classes -
readerWriter
Holds the current instance of the PASSReaderWriter class. The class is only instanciated once
-
-
Konstruktordetails
-
PASSReaderWriter
private PASSReaderWriter()The private constructor that initializes logs
-
-
Methodendetails
-
getInstance
Get the current instance of the PASSReaderWriter class. The class structure must only be loaded once, afterwards each class can instantly load models without overwriting the parsing structure when fetching this instance.- Gibt zurück:
- The instance of this PASSReaderWriter class
-
getParsingDict
-
loadOWLParsingStructure
Beschreibung aus Schnittstelle kopiert:IPASSReaderWriter
The abstract pass ont and/or the standard pass ont must be given either inside the same owl file or as seperate files. These files will be used to create a parsing structure for models. This operation is likely to be an expensive one and should only be used once if loaded models share the same structure.- Angegeben von:
loadOWLParsingStructure
in SchnittstelleIPASSReaderWriter
- Parameter:
filepathsToOWLFiles
- The list of filepaths to valid formatted owl files containing the structure for models and components
-
loadModels
public List<IPASSProcessModel> loadModels(List<String> filepaths, boolean overrideOWLParsingStructure) Beschreibung aus Schnittstelle kopiert:IPASSReaderWriter
Loads in all the required files given by filepaths. The files must be written in correct owl format. If the structure defining owl files are passed alongside the model defining ones, it must be declared via boolean that the current parsing structure should be overwritten. It is advised to only load the structure defining owl files once viaIPASSReaderWriter.loadOWLParsingStructure(List)
, because the creation of the parsing structure is likely to be an expensive operation.- Angegeben von:
loadModels
in SchnittstelleIPASSReaderWriter
- Parameter:
filepaths
- The list of filepaths to valid formatted owl filesoverrideOWLParsingStructure
- Default false, should be set true when the structure defining owl files are passed alongside the model defining ones, and the current parsing structure should be overwritten.- Gibt zurück:
- A list of
IPASSProcessModel
the were created from the given owl
-
loadModels
Beschreibung aus Schnittstelle kopiert:IPASSReaderWriter
Loads in all the required files given by filepaths. The files must be written in correct owl format. If the structure defining owl files are passed alongside the model defining ones, it must be declared via boolean that the current parsing structure should be overwritten. It is advised to only load the structure defining owl files once viaIPASSReaderWriter.loadOWLParsingStructure(List)
, because the creation of the parsing structure is likely to be an expensive operation.- Angegeben von:
loadModels
in SchnittstelleIPASSReaderWriter
- Parameter:
filepaths
- The list of filepaths to valid formatted owl files- Gibt zurück:
- A list of
IPASSProcessModel
the were created from the given owl
-
preCleanFile
The .NetRDF library has a few problems with input files that are basically stupid E.g. an rdf:RDF xmlns="" at the beginning of an RDF document may cause an Invalid URI exception. Sadly some tools like Protegée generate exactly stuff like that This method simple tries to clean known problems- Parameter:
filePath
-
-
isStandardPass
private boolean isStandardPass(org.apache.jena.rdf.model.Statement triple) Verifies whether a triple (as string) is part of a standard pass definition owl or a model- Parameter:
triple
- a triple converted to string- Gibt zurück:
- true if it is part of a standard pass document, false if it is only part of a normal model
-
isStandardPass
Verifies whether a triple (as string) is part of a standard pass definition owl or a mode- Parameter:
trpl
- a triple converted to string- Gibt zurück:
- true if it is part of a standard pass document, false if it is only part of a normal model
-
findAllNamedIndividualTriples
private Map<String,List<String>> findAllNamedIndividualTriples (org.apache.jena.rdf.model.Model graph) Finds and creates all the named individuals in the given files and creates a new list with all the individuals- Parameter:
graph
-- Gibt zurück:
-
createClassInstancesFromNamedIndividuals
private List<IPASSProcessModel> createClassInstancesFromNamedIndividuals(org.apache.jena.rdf.model.Model graph, Map<String, List<String>> namedIndividualsDict) Method that creates the empty Instances of the Objects which later get completed by the completetObjects() method- Parameter:
graph
- The graph used for parsingnamedIndividualsDict
- A dictionary containing the uri for each NamedIndividual as key and the type(s) as value (in the form of a list)- Gibt zurück:
-
exportModel
// TODO: Out-Methode public String exportModel(IPASSProcessModel model, String filepath, Model exportGraph) { // Get the graph hold by the model and use the export function given by the library String fullPath = (filepath.endsWith(".owl")) ? filepath : filepath + ".owl"; model.getBaseGraph().exportTo(fullPath); if (model.getBaseGraph() instanceof PASSGraph graph) exportGraph = graph.getGraph(); else exportGraph = null; return fullPath; } //TODO Out-Methode public String exportModel(IPASSProcessModel model, String filepath) { Model graph;return exportModel(model, filepath, Model graph); }
- Angegeben von:
exportModel
in SchnittstelleIPASSReaderWriter
- Parameter:
model
- the model that should be exportedfilepath
- the path where the file will be saved- Gibt zurück:
- The model
-
setModelElementFactory
public void setModelElementFactory(IPASSProcessModelElementFactory<IParseablePASSProcessModelElement> elementFactory) Beschreibung aus Schnittstelle kopiert:IPASSReaderWriter
Allows to set another factory to create the elements. The standard factoryBasicPASSProcessModelElementFactory
is used automatically and decides on mapped elements based on the name similarity. If the factory should choose other elements, a new factory can be inserted here.- Angegeben von:
setModelElementFactory
in SchnittstelleIPASSReaderWriter
-