123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- from rdflib import Graph
- from lakesuperior.env import env
- from lakesuperior.globals import RES_UPDATED
- from lakesuperior.dictionaries.namespaces import ns_collection as nsc
- from lakesuperior.model.ldpr import Ldpr
- class LdpRs(Ldpr):
- '''LDP-RS (LDP RDF source).
- Definition: https://www.w3.org/TR/ldp/#ldprs
- '''
- def __init__(self, uuid, repr_opts={}, handling='lenient', **kwargs):
- '''
- Extends Ldpr.__init__ by adding LDP-RS specific parameters.
- @param handling (string) One of `strict`, `lenient` (the default) or
- `none`. `strict` raises an error if a server-managed term is in the
- graph. `lenient` removes all sever-managed triples encountered. `none`
- skips all server-managed checks. It is used for internal modifications.
- '''
- super().__init__(uuid, **kwargs)
- self.base_types = super().base_types | {
- nsc['fcrepo'].Container,
- nsc['ldp'].Container,
- }
-
- if self.provided_imr is not None:
- self.workflow = self.WRKF_INBOUND
- else:
- self.workflow = self.WRKF_OUTBOUND
- self._imr_options = repr_opts
- self.handling = handling
-
- def patch(self, update_str):
- '''
- Update an existing resource by applying a SPARQL-UPDATE query.
- @param update_str (string) SPARQL-Update staements.
- '''
- self.handling = 'lenient'
- return self._sparql_update(update_str)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- class Ldpc(LdpRs):
- '''LDPC (LDP Container).'''
- def __init__(self, uuid, *args, **kwargs):
- super().__init__(uuid, *args, **kwargs)
- self.base_types |= {
- nsc['fcrepo'].Container,
- nsc['ldp'].Container,
- }
- class LdpBc(Ldpc):
- '''LDP-BC (LDP Basic Container).'''
- def __init__(self, uuid, *args, **kwargs):
- super().__init__(uuid, *args, **kwargs)
- self.base_types |= {
- nsc['ldp'].BasicContainer,
- }
- class LdpDc(Ldpc):
- '''LDP-DC (LDP Direct Container).'''
- def __init__(self, uuid, *args, **kwargs):
- super().__init__(uuid, *args, **kwargs)
- self.base_types |= {
- nsc['ldp'].DirectContainer,
- }
- class LdpIc(Ldpc):
- '''LDP-IC (LDP Indirect Container).'''
- def __init__(self, uuid, *args, **kwargs):
- super().__init__(uuid, *args, **kwargs)
- self.base_types |= {
- nsc['ldp'].IndirectContainer,
- }
|