oldman.storage.model package¶
Subpackages¶
Submodules¶
oldman.storage.model.manager module¶
-
class
oldman.storage.model.manager.
StoreModelManager
(schema_graph=None, attr_extractor=None)[source]¶ Bases:
oldman.core.model.manager.ModelManager
-
create_model
(class_name_or_iri, context_iri_or_payload, store, iri_prefix=None, iri_fragment=None, iri_generator=None, untyped=False, incremental_iri=False, is_default=False, context_file_path=None)[source]¶ Creates a
StoreModel
object.TODO: remove data_store from the constructor!
To create it, they are three elements to consider:
- Its class IRI which can be retrieved from class_name_or_iri;
- Its JSON-LD context for mapping
OMAttribute
values to RDF triples; - The
IriGenerator
object that generates IRIs from newResource
objects.
The
IriGenerator
object is either:- directly given: iri_generator;
- created from the parameters iri_prefix, iri_fragment and incremental_iri.
Parameters: - class_name_or_iri – IRI or JSON-LD term of a RDFS class.
- context_iri_or_payload – dict, list or IRI that represents the JSON-LD context .
- iri_generator –
IriGenerator
object. If given, other iri_* parameters are ignored. - iri_prefix – Prefix of generated IRIs. Defaults to None.
If is None and no iri_generator is given, a
BlankNodeIriGenerator
is created. - iri_fragment – IRI fragment that is added at the end of generated IRIs. For instance, “me” adds “#me” at the end of the new IRI. Defaults to None. Has no effect if iri_prefix is not given.
- incremental_iri – If True an
IncrementalIriGenerator
is created instead of aRandomPrefixedIriGenerator
. Defaults to False. Has no effect if iri_prefix is not given. - context_file_path – TODO: describe.
-
oldman.storage.model.model module¶
-
class
oldman.storage.model.model.
StoreModel
(name, class_iri, ancestry_iris, context, om_attributes, id_generator, local_context=None)[source]¶ Bases:
oldman.core.model.model.Model
Parameters: - name – Model name. Usually corresponds to a JSON-LD term or to a class IRI.
- class_iri – IRI of the RDFS class represented by this
Model
object. - ancestry_iris – ancestry of the attribute class_iri. Each instance of class_iri is also instance of these classes.
- context – An IRI, a list or a dict that describes the JSON-LD context. See http://www.w3.org/TR/json-ld/#the-context for more details.
- om_attributes – dict of
OMAttribute
objects. Keys are their names. - id_generator –
IriGenerator
object that generates IRIs from newResource
objects. - methods – dict of Python functions that takes as first argument a
Resource
object. Keys are the method names. Defaults to {}. TODO: see if is still needed. - local_context – TODO: describe.