oldman.storage.model package

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:

  1. Its class IRI which can be retrieved from class_name_or_iri;
  2. Its JSON-LD context for mapping OMAttribute values to RDF triples;
  3. The IriGenerator object that generates IRIs from new Resource 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_payloaddict, list or IRI that represents the JSON-LD context .
  • iri_generatorIriGenerator 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 a RandomPrefixedIriGenerator. 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_attributesdict of OMAttribute objects. Keys are their names.
  • id_generatorIriGenerator object that generates IRIs from new Resource objects.
  • methodsdict 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.
generate_permanent_id(previous_id)[source]

Generates a new OMId object.

Used by the StoreResource class but an end-user should not need to call it.

Returns:A new OMId object.
reset_counter()[source]

Resets the counter of the ID generator.

Please use it only for test purposes.

Module contents