Commit b21b0644 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

Use AuthorityRecord from eac cube instead of Agent


Closes #16684239
parent 6ef2ee157e1a
......@@ -19,6 +19,7 @@ web = 'http://www.cubicweb.org/project/%s' % distname
__depends__ = {
'cubicweb': '>= 3.23', 'six': '>= 1.4.0',
'cubicweb-eac': None,
'cubicweb-skos': '>= 0.12.1',
'cubicweb-compound': '>= 0.4',
'cubicweb-relationwidget': '>= 0.4',
......
......@@ -21,6 +21,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
BuildRequires: %{python} %{python}-setuptools
Requires: cubicweb >= 3.23
Requires: cubicweb-eac
Requires: cubicweb-skos >= 0.12.1
Requires: cubicweb-compound >= 0.4
Requires: cubicweb-relationwidget >= 0.4l
......
......@@ -12,6 +12,7 @@ Package: cubicweb-seda
Architecture: all
Depends:
cubicweb-common (>= 3.23),
cubicweb-eac,
cubicweb-skos (>= 0.12.1),
cubicweb-compound (>= 0.4),
cubicweb-relationwidget (>= 0.4),
......
......@@ -271,7 +271,7 @@ class SEDA2HTMLExport(SEDA2ExportAdapter):
if value is None:
return None
if hasattr(value, 'eid'):
if value.cw_etype in ('Agent', 'ConceptScheme'):
if value.cw_etype in ('AuthorityRecord', 'ConceptScheme'):
href, label = value.absolute_url(), value.dc_title()
elif value.cw_etype == 'Concept':
href = value.absolute_url()
......
......@@ -476,7 +476,7 @@ class SEDA2XSDExport(SEDA2ExportAdapter):
seq_element = self.element('xsd:sequence', type_element)
# target is a complex element
if getattr(target_value, 'eid', None): # value is an entity
if target_value.cw_etype == 'Agent':
if target_value.cw_etype == 'AuthorityRecord':
self.fill_organization_element(seq_element, target_value)
elif xselement.local_name in ('ArchivalAgency', 'TransferringAgency'):
self.fill_organization_element(seq_element, None)
......@@ -657,7 +657,7 @@ class SEDA2RelaxNGExport(RNGMixin, SEDA2ExportAdapter):
else:
# target is a complex element
if getattr(target_value, 'eid', None): # value is an entity
if target_value.cw_etype == 'Agent':
if target_value.cw_etype == 'AuthorityRecord':
self.fill_organization_element(target_element, target_value)
elif xselement.local_name in ('ArchivalAgency', 'TransferringAgency'):
self.fill_organization_element(target_element, None)
......
......@@ -15,8 +15,7 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
"""cubicweb-seda schema"""
from yams.reader import context
from yams.buildobjs import EntityType, RelationType, RelationDefinition
from yams.buildobjs import RelationType, RelationDefinition
from yams.buildobjs import String
from cubicweb import _
......@@ -124,15 +123,6 @@ kind = skos.Label.get_relation('kind')
kind.indexed = True
if 'Agent' not in context.defined:
class Agent(EntityType):
"""An agent is something that bears some form of responsibility for an
activity taking place, for the existence of an entity, or for another
agent's activity.
"""
name = String(required=True, fulltextindexed=True)
from cubes.seda.schema.seda2 import data_object_reference_data_object_reference_id # noqa
data_object_reference_data_object_reference_id.composite = 'subject'
......
......@@ -113,7 +113,7 @@ class archive_transfer_transfer_request_reply_identifier(RelationDefinition):
class archive_transfer_archival_agency(RelationDefinition):
name = 'seda_archival_agency'
subject = 'SEDAArchiveTransfer'
object = 'Agent'
object = 'AuthorityRecord'
cardinality = '?*'
composite = fulltext_container = None
inlined = True
......@@ -122,7 +122,7 @@ class archive_transfer_archival_agency(RelationDefinition):
class archive_transfer_transferring_agency(RelationDefinition):
name = 'seda_transferring_agency'
subject = 'SEDAArchiveTransfer'
object = 'Agent'
object = 'AuthorityRecord'
cardinality = '?*'
composite = fulltext_container = None
inlined = True
......@@ -1852,7 +1852,7 @@ class content_originating_agency_from(RelationDefinition):
class originating_agency_originating_agency_to(RelationDefinition):
name = 'seda_originating_agency_to'
subject = 'SEDAOriginatingAgency'
object = 'Agent'
object = 'AuthorityRecord'
cardinality = '?*'
composite = fulltext_container = None
inlined = True
......@@ -1876,7 +1876,7 @@ class content_submission_agency_from(RelationDefinition):
class submission_agency_submission_agency_to(RelationDefinition):
name = 'seda_submission_agency_to'
subject = 'SEDASubmissionAgency'
object = 'Agent'
object = 'AuthorityRecord'
cardinality = '?*'
composite = fulltext_container = None
inlined = True
......@@ -1900,7 +1900,7 @@ class content_authorized_agent_from(RelationDefinition):
class authorized_agent_authorized_agent_to(RelationDefinition):
name = 'seda_authorized_agent_to'
subject = 'SEDAAuthorizedAgent'
object = 'Agent'
object = 'AuthorityRecord'
cardinality = '?*'
composite = fulltext_container = None
inlined = True
......@@ -1924,7 +1924,7 @@ class content_writer_from(RelationDefinition):
class writer_writer_to(RelationDefinition):
name = 'seda_writer_to'
subject = 'SEDAWriter'
object = 'Agent'
object = 'AuthorityRecord'
cardinality = '**'
composite = fulltext_container = None
inlined = False
......@@ -1948,7 +1948,7 @@ class content_addressee_from(RelationDefinition):
class addressee_addressee_to(RelationDefinition):
name = 'seda_addressee_to'
subject = 'SEDAAddressee'
object = 'Agent'
object = 'AuthorityRecord'
cardinality = '**'
composite = fulltext_container = None
inlined = False
......@@ -1972,7 +1972,7 @@ class content_recipient_from(RelationDefinition):
class recipient_recipient_to(RelationDefinition):
name = 'seda_recipient_to'
subject = 'SEDARecipient'
object = 'Agent'
object = 'AuthorityRecord'
cardinality = '**'
composite = fulltext_container = None
inlined = False
......
......@@ -45,7 +45,7 @@ class ContainerTC(CubicWebTC):
[('seda_mime_type_from', 'subject')])
self.assertNotIn('ConceptScheme', container_def)
self.assertNotIn('Concept', container_def)
self.assertNotIn('Agent', container_def)
self.assertNotIn('AuthorityRecord', container_def)
entity = self.vreg['etypes'].etype_class('SEDAArchiveTransfer')(self)
self.assertIsNotNone(entity.cw_adapt_to('IContainer'))
self.assertIsNone(entity.cw_adapt_to('IContained'))
......
......@@ -680,7 +680,7 @@ class OldSEDAExportMixin(object):
scheme = testutils.scheme_for_type(cnx, rtype, etype, value)
concepts[value] = scheme.reverse_in_scheme[0]
agent = create('Agent', name=u'bob')
agent = testutils.create_authority_record(cnx, u'bob')
transfer = create('SEDAArchiveTransfer', title=u'my profile title &&',
simplified_profile=True)
......
......@@ -273,8 +273,8 @@ class SecurityTC(CubicWebTC):
with self.new_access('alice').repo_cnx() as cnx:
transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'Alice Profile')
testutils.create_archive_unit(transfer)
cnx.create_entity('Agent', name=u'Archival inc.',
reverse_seda_archival_agency=transfer)
testutils.create_authority_record(cnx, u'Archival inc.',
reverse_seda_archival_agency=transfer)
cnx.create_entity('SEDAComment', comment=u'Whooot.',
seda_comment=transfer)
scheme = cnx.create_entity('ConceptScheme', title=u'Some vocabulary')
......@@ -295,8 +295,8 @@ class SecurityTC(CubicWebTC):
cnx.create_entity('SEDAComment', seda_comment=transfer)
# modification of a relation from the container to a non contained entity
with self.assertUnauthorized(cnx):
cnx.create_entity('Agent', name=u'Bob Archival inc.',
reverse_seda_archival_agency=transfer)
testutils.create_authority_record(cnx, name=u'Bob Archival inc.',
reverse_seda_archival_agency=transfer)
# modification of a relation from a contained entity to a non contained entity
mtclv = transfer.reverse_seda_mime_type_code_list_version_from[0]
with self.assertUnauthorized(cnx):
......
......@@ -247,8 +247,9 @@ class XSIterateTC(unittest.TestCase):
[('seda_transfer_request_reply_identifier', 'object',
'SEDATransferRequestReplyIdentifier'),
('transfer_request_reply_identifier', 'subject', 'String')]),
('ArchivalAgency', [('seda_archival_agency', 'subject', 'Agent')]),
('TransferringAgency', [('seda_transferring_agency', 'subject', 'Agent')]),
('ArchivalAgency', [('seda_archival_agency', 'subject', 'AuthorityRecord')]),
('TransferringAgency',
[('seda_transferring_agency', 'subject', 'AuthorityRecord')]),
]))
dao_element = edef[2][7][0].target
dao_edef = (dao_element,) + element_defs[dao_element]
......
......@@ -55,6 +55,13 @@ def create_data_object(parent, **kwargs):
return bdo
def create_authority_record(cnx, name, kind=u'person', **kwargs):
"""Return an AuthorityRecord with specified kind and name."""
kind_eid = cnx.find('AgentKind', name=kind)[0][0]
return cnx.create_entity('AuthorityRecord', name=name,
agent_kind=kind_eid, **kwargs)
def map_cs_to_type(scheme, rtype, etype=None):
cnx = scheme._cw
cnx.execute('SET CS scheme_relation_type RT WHERE CS eid %(cs)s, RT name %(rt)s',
......
......@@ -20,7 +20,7 @@ from yams import BASE_TYPES
from cubicweb import tags, neg_role, _
from cubicweb.utils import UStringIO
from cubicweb.web import formwidgets as fw, formfields as ff
from cubicweb.web import formfields as ff
# XXX alias to avoid side effect: uicfg will become our uicfg submodule. Not necessary with 3.23?
from cubicweb.web.views import uicfg as cwuicfg
......@@ -39,7 +39,6 @@ pvs.tag_subject_of(('*', 'container', '*'), 'hidden')
pvs.tag_object_of(('*', 'container', '*'), 'hidden')
afs.tag_subject_of(('*', 'container', '*'), 'main', 'hidden')
afs.tag_object_of(('*', 'container', '*'), 'main', 'hidden')
affk.tag_attribute(('Agent', 'name'), {'widget': fw.TextInput({'size': 80})})
pvs.tag_subject_of(('*', 'scheme_relation_type', '*'), 'hidden')
pvs.tag_subject_of(('*', 'scheme_entity_type', '*'), 'hidden')
......
......@@ -163,8 +163,8 @@ class TypeAndMetaEntityView(EntityView):
class ListItemView(EntityView):
"""Extended 'oneline' view for entities related to an Agent, including link to remove the
relation.
"""Extended 'oneline' view for entities related to an AuthorityRecord, including link to remove
the relation.
"""
__regid__ = 'seda.listitem'
__select__ = EntityView.__select__ & match_kwargs('parent', 'tabid')
......
......@@ -111,16 +111,16 @@ XSD2YAMS = {
'SignedObjectId': 'SEDABinaryDataObject',
'target': ('SEDABinaryDataObject', 'SEDAPhysicalDataObject'),
'Validator': 'Agent',
'Signer': 'Agent',
'Writer': 'Agent',
'AuthorizedAgent': 'Agent',
'Addressee': 'Agent',
'Recipient': 'Agent',
'OriginatingAgency': 'Agent',
'SubmissionAgency': 'Agent',
'ArchivalAgency': 'Agent',
'TransferringAgency': 'Agent',
'Validator': 'AuthorityRecord',
'Signer': 'AuthorityRecord',
'Writer': 'AuthorityRecord',
'AuthorizedAgent': 'AuthorityRecord',
'Addressee': 'AuthorityRecord',
'Recipient': 'AuthorityRecord',
'OriginatingAgency': 'AuthorityRecord',
'SubmissionAgency': 'AuthorityRecord',
'ArchivalAgency': 'AuthorityRecord',
'TransferringAgency': 'AuthorityRecord',
'type': 'Concept', # Relationship
'algorithm': 'Concept',
......
......@@ -26,7 +26,7 @@ from pyxst.xml_struct import graph_nodes
from xsd import XSDMMapping, un_camel_case
EXT_ETYPES = set(['Agent', 'ConceptScheme', 'Concept'])
EXT_ETYPES = set(['AuthorityRecord', 'ConceptScheme', 'Concept'])
RULE_TYPES = set(('access', 'appraisal', 'classification', 'reuse', 'dissemination', 'storage'))
# elements in the intermediary model but not in the yams model
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment