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

[code gen] Generate rules for attributes order

parent 43a1cc1693fb
......@@ -35,8 +35,6 @@ pvs.tag_attribute(('SEDAArchiveTransfer', 'title'), 'hidden')
pvs.tag_subject_of(('SEDAArchiveTransfer', 'seda_archival_agency', '*'), 'attributes')
pvs.tag_subject_of(('SEDAArchiveTransfer', 'seda_transferring_agency', '*'), 'attributes')
affk.set_fields_order('SEDAArchiveTransfer', ('title', 'user_annotation'))
pvdc.set_fields_order('SEDAArchiveTransfer', ('title', 'user_annotation'))
affk.set_field_kwargs('SEDAArchiveTransfer', 'title', widget=fw.TextInput({'size': 80}))
......
......@@ -28,11 +28,6 @@ from cubes.seda.views import rtags_from_xsd_element
_ = unicode
affk = uicfg.autoform_field_kwargs
pvdc = uicfg.primaryview_display_ctrl
for etype in ('SEDABinaryDataObject', 'SEDAPhysicalDataObject'):
affk.set_fields_order(etype, ('id', 'user_cardinality', 'user_annotation'))
pvdc.set_fields_order(etype, ('id', 'user_cardinality', 'user_annotation'))
def _container_eid(entity):
......@@ -116,9 +111,6 @@ class BinaryDataObjectTabbedPrimaryView(tabs.TabbedPrimaryView):
]
affk.set_fields_order('SEDAFormatLitteral', ('user_cardinality', 'format_litteral'))
class BinaryDataObjectFormatIdentificationTab(tabs.PrimaryTab):
"""Display format identification information of a binary data object"""
__regid__ = 'seda_bdo_format_identification'
......
......@@ -703,3 +703,144 @@ pvs.tag_subject_of(('*', 'seda_classification_rule_code_list_version_from', '*')
pvs.tag_object_of(('*', 'seda_classification_rule_code_list_version_from', '*'), 'hidden')
pvs.tag_subject_of(('*', 'seda_relationship_code_list_version_from', '*'), 'hidden')
pvs.tag_object_of(('*', 'seda_relationship_code_list_version_from', '*'), 'hidden')
pvds = uicfg.primaryview_display_ctrl
affk.set_fields_order('SEDAArchiveTransfer', ['title', 'user_annotation'])
pvds.set_fields_order('SEDAArchiveTransfer', ['title', 'user_annotation'])
affk.set_fields_order('SEDAComment', ['user_cardinality', 'comment'])
pvds.set_fields_order('SEDAComment', ['user_cardinality', 'comment'])
affk.set_fields_order('SEDASignature', ['user_cardinality', 'date_signature'])
pvds.set_fields_order('SEDASignature', ['user_cardinality', 'date_signature'])
affk.set_fields_order('SEDARelatedTransferReference', ['user_cardinality', 'related_transfer_reference'])
pvds.set_fields_order('SEDARelatedTransferReference', ['user_cardinality', 'related_transfer_reference'])
affk.set_fields_order('SEDATransferRequestReplyIdentifier', ['user_cardinality', 'transfer_request_reply_identifier'])
pvds.set_fields_order('SEDATransferRequestReplyIdentifier', ['user_cardinality', 'transfer_request_reply_identifier'])
affk.set_fields_order('SEDABinaryDataObject', ['id', 'user_cardinality', 'user_annotation'])
pvds.set_fields_order('SEDABinaryDataObject', ['id', 'user_cardinality', 'user_annotation'])
affk.set_fields_order('SEDAPhysicalDataObject', ['id', 'user_cardinality', 'user_annotation'])
pvds.set_fields_order('SEDAPhysicalDataObject', ['id', 'user_cardinality', 'user_annotation'])
affk.set_fields_order('SEDAServiceLevel', ['user_cardinality', 'service_level'])
pvds.set_fields_order('SEDAServiceLevel', ['user_cardinality', 'service_level'])
affk.set_fields_order('SEDANeedAuthorization', ['user_cardinality', 'need_authorization'])
pvds.set_fields_order('SEDANeedAuthorization', ['user_cardinality', 'need_authorization'])
affk.set_fields_order('SEDAClassificationReassessingDate', ['user_cardinality', 'classification_reassessing_date'])
pvds.set_fields_order('SEDAClassificationReassessingDate', ['user_cardinality', 'classification_reassessing_date'])
affk.set_fields_order('SEDANeedReassessingAuthorization', ['user_cardinality', 'need_reassessing_authorization'])
pvds.set_fields_order('SEDANeedReassessingAuthorization', ['user_cardinality', 'need_reassessing_authorization'])
affk.set_fields_order('SEDAStartDate', ['user_cardinality', 'start_date'])
pvds.set_fields_order('SEDAStartDate', ['user_cardinality', 'start_date'])
affk.set_fields_order('SEDAArchiveUnit', ['id', 'user_cardinality', 'user_annotation'])
pvds.set_fields_order('SEDAArchiveUnit', ['id', 'user_cardinality', 'user_annotation'])
affk.set_fields_order('SEDAhref', ['user_cardinality', 'href'])
pvds.set_fields_order('SEDAhref', ['user_cardinality', 'href'])
affk.set_fields_order('SEDArestrictionRuleIdRef', ['user_cardinality', 'restriction_rule_id_ref'])
pvds.set_fields_order('SEDArestrictionRuleIdRef', ['user_cardinality', 'restriction_rule_id_ref'])
affk.set_fields_order('SEDArestrictionValue', ['user_cardinality', 'restriction_value'])
pvds.set_fields_order('SEDArestrictionValue', ['user_cardinality', 'restriction_value'])
affk.set_fields_order('SEDArestrictionEndDate', ['user_cardinality', 'restriction_end_date'])
pvds.set_fields_order('SEDArestrictionEndDate', ['user_cardinality', 'restriction_end_date'])
affk.set_fields_order('SEDATitle', ['user_cardinality', 'title'])
pvds.set_fields_order('SEDATitle', ['user_cardinality', 'title'])
affk.set_fields_order('SEDAFilePlanPosition', ['user_cardinality', 'file_plan_position'])
pvds.set_fields_order('SEDAFilePlanPosition', ['user_cardinality', 'file_plan_position'])
affk.set_fields_order('SEDASystemId', ['user_cardinality', 'system_id'])
pvds.set_fields_order('SEDASystemId', ['user_cardinality', 'system_id'])
affk.set_fields_order('SEDAOriginatingSystemId', ['user_cardinality', 'originating_system_id'])
pvds.set_fields_order('SEDAOriginatingSystemId', ['user_cardinality', 'originating_system_id'])
affk.set_fields_order('SEDAArchivalAgencyArchiveUnitIdentifier', ['user_cardinality', 'archival_agency_archive_unit_identifier'])
pvds.set_fields_order('SEDAArchivalAgencyArchiveUnitIdentifier', ['user_cardinality', 'archival_agency_archive_unit_identifier'])
affk.set_fields_order('SEDAOriginatingAgencyArchiveUnitIdentifier', ['user_cardinality', 'originating_agency_archive_unit_identifier'])
pvds.set_fields_order('SEDAOriginatingAgencyArchiveUnitIdentifier', ['user_cardinality', 'originating_agency_archive_unit_identifier'])
affk.set_fields_order('SEDATransferringAgencyArchiveUnitIdentifier', ['user_cardinality', 'transferring_agency_archive_unit_identifier'])
pvds.set_fields_order('SEDATransferringAgencyArchiveUnitIdentifier', ['user_cardinality', 'transferring_agency_archive_unit_identifier'])
affk.set_fields_order('SEDADescription', ['user_cardinality', 'description'])
pvds.set_fields_order('SEDADescription', ['user_cardinality', 'description'])
affk.set_fields_order('SEDAType', ['user_cardinality', 'type'])
pvds.set_fields_order('SEDAType', ['user_cardinality', 'type'])
affk.set_fields_order('SEDADocumentType', ['user_cardinality', 'document_type'])
pvds.set_fields_order('SEDADocumentType', ['user_cardinality', 'document_type'])
affk.set_fields_order('SEDAStatus', ['user_cardinality', 'status'])
pvds.set_fields_order('SEDAStatus', ['user_cardinality', 'status'])
affk.set_fields_order('SEDAVersion', ['user_cardinality', 'version'])
pvds.set_fields_order('SEDAVersion', ['user_cardinality', 'version'])
affk.set_fields_order('SEDATag', ['user_cardinality', 'tag'])
pvds.set_fields_order('SEDATag', ['user_cardinality', 'tag'])
affk.set_fields_order('SEDASource', ['user_cardinality', 'source'])
pvds.set_fields_order('SEDASource', ['user_cardinality', 'source'])
affk.set_fields_order('SEDACreatedDate', ['user_cardinality', 'created_date'])
pvds.set_fields_order('SEDACreatedDate', ['user_cardinality', 'created_date'])
affk.set_fields_order('SEDATransactedDate', ['user_cardinality', 'transacted_date'])
pvds.set_fields_order('SEDATransactedDate', ['user_cardinality', 'transacted_date'])
affk.set_fields_order('SEDAAcquiredDate', ['user_cardinality', 'acquired_date'])
pvds.set_fields_order('SEDAAcquiredDate', ['user_cardinality', 'acquired_date'])
affk.set_fields_order('SEDASentDate', ['user_cardinality', 'sent_date'])
pvds.set_fields_order('SEDASentDate', ['user_cardinality', 'sent_date'])
affk.set_fields_order('SEDAReceivedDate', ['user_cardinality', 'received_date'])
pvds.set_fields_order('SEDAReceivedDate', ['user_cardinality', 'received_date'])
affk.set_fields_order('SEDARegisteredDate', ['user_cardinality', 'registered_date'])
pvds.set_fields_order('SEDARegisteredDate', ['user_cardinality', 'registered_date'])
affk.set_fields_order('SEDAEndDate', ['user_cardinality', 'end_date'])
pvds.set_fields_order('SEDAEndDate', ['user_cardinality', 'end_date'])
affk.set_fields_order('SEDAEvent', ['user_cardinality', 'event_date_time'])
pvds.set_fields_order('SEDAEvent', ['user_cardinality', 'event_date_time'])
affk.set_fields_order('SEDAGpsVersionID', ['user_cardinality', 'gps_version_id'])
pvds.set_fields_order('SEDAGpsVersionID', ['user_cardinality', 'gps_version_id'])
affk.set_fields_order('SEDAGpsAltitude', ['user_cardinality', 'gps_altitude'])
pvds.set_fields_order('SEDAGpsAltitude', ['user_cardinality', 'gps_altitude'])
affk.set_fields_order('SEDAGpsAltitudeRef', ['user_cardinality', 'gps_altitude_ref'])
pvds.set_fields_order('SEDAGpsAltitudeRef', ['user_cardinality', 'gps_altitude_ref'])
affk.set_fields_order('SEDAGpsLatitude', ['user_cardinality', 'gps_latitude'])
pvds.set_fields_order('SEDAGpsLatitude', ['user_cardinality', 'gps_latitude'])
affk.set_fields_order('SEDAGpsLatitudeRef', ['user_cardinality', 'gps_latitude_ref'])
pvds.set_fields_order('SEDAGpsLatitudeRef', ['user_cardinality', 'gps_latitude_ref'])
affk.set_fields_order('SEDAGpsLongitude', ['user_cardinality', 'gps_longitude'])
pvds.set_fields_order('SEDAGpsLongitude', ['user_cardinality', 'gps_longitude'])
affk.set_fields_order('SEDAGpsLongitudeRef', ['user_cardinality', 'gps_longitude_ref'])
pvds.set_fields_order('SEDAGpsLongitudeRef', ['user_cardinality', 'gps_longitude_ref'])
affk.set_fields_order('SEDAGpsDateStamp', ['user_cardinality', 'gps_date_stamp'])
pvds.set_fields_order('SEDAGpsDateStamp', ['user_cardinality', 'gps_date_stamp'])
affk.set_fields_order('SEDAMasterdata', ['user_cardinality', 'masterdata'])
pvds.set_fields_order('SEDAMasterdata', ['user_cardinality', 'masterdata'])
affk.set_fields_order('SEDAEventIdentifier', ['user_cardinality', 'event_identifier'])
pvds.set_fields_order('SEDAEventIdentifier', ['user_cardinality', 'event_identifier'])
affk.set_fields_order('SEDAEventDetail', ['user_cardinality', 'event_detail'])
pvds.set_fields_order('SEDAEventDetail', ['user_cardinality', 'event_detail'])
affk.set_fields_order('SEDASpatial', ['user_cardinality', 'spatial'])
pvds.set_fields_order('SEDASpatial', ['user_cardinality', 'spatial'])
affk.set_fields_order('SEDATemporal', ['user_cardinality', 'temporal'])
pvds.set_fields_order('SEDATemporal', ['user_cardinality', 'temporal'])
affk.set_fields_order('SEDAJuridictional', ['user_cardinality', 'juridictional'])
pvds.set_fields_order('SEDAJuridictional', ['user_cardinality', 'juridictional'])
affk.set_fields_order('SEDACustodialHistoryItem', ['user_cardinality', 'custodial_history_item'])
pvds.set_fields_order('SEDACustodialHistoryItem', ['user_cardinality', 'custodial_history_item'])
affk.set_fields_order('SEDAwhen', ['user_cardinality', 'when'])
pvds.set_fields_order('SEDAwhen', ['user_cardinality', 'when'])
affk.set_fields_order('SEDAWidth', ['user_cardinality', 'width'])
pvds.set_fields_order('SEDAWidth', ['user_cardinality', 'width'])
affk.set_fields_order('SEDAHeight', ['user_cardinality', 'height'])
pvds.set_fields_order('SEDAHeight', ['user_cardinality', 'height'])
affk.set_fields_order('SEDADepth', ['user_cardinality', 'depth'])
pvds.set_fields_order('SEDADepth', ['user_cardinality', 'depth'])
affk.set_fields_order('SEDAShape', ['user_cardinality', 'shape'])
pvds.set_fields_order('SEDAShape', ['user_cardinality', 'shape'])
affk.set_fields_order('SEDADiameter', ['user_cardinality', 'diameter'])
pvds.set_fields_order('SEDADiameter', ['user_cardinality', 'diameter'])
affk.set_fields_order('SEDALength', ['user_cardinality', 'length'])
pvds.set_fields_order('SEDALength', ['user_cardinality', 'length'])
affk.set_fields_order('SEDAThickness', ['user_cardinality', 'thickness'])
pvds.set_fields_order('SEDAThickness', ['user_cardinality', 'thickness'])
affk.set_fields_order('SEDAWeight', ['user_cardinality', 'weight'])
pvds.set_fields_order('SEDAWeight', ['user_cardinality', 'weight'])
affk.set_fields_order('SEDANumberOfPage', ['user_cardinality', 'number_of_page'])
pvds.set_fields_order('SEDANumberOfPage', ['user_cardinality', 'number_of_page'])
affk.set_fields_order('SEDACompressed', ['user_cardinality', 'compressed'])
pvds.set_fields_order('SEDACompressed', ['user_cardinality', 'compressed'])
affk.set_fields_order('SEDACreatingApplicationName', ['user_cardinality', 'creating_application_name'])
pvds.set_fields_order('SEDACreatingApplicationName', ['user_cardinality', 'creating_application_name'])
affk.set_fields_order('SEDACreatingApplicationVersion', ['user_cardinality', 'creating_application_version'])
pvds.set_fields_order('SEDACreatingApplicationVersion', ['user_cardinality', 'creating_application_version'])
affk.set_fields_order('SEDACreatingOs', ['user_cardinality', 'creating_os'])
pvds.set_fields_order('SEDACreatingOs', ['user_cardinality', 'creating_os'])
affk.set_fields_order('SEDACreatingOsVersion', ['user_cardinality', 'creating_os_version'])
pvds.set_fields_order('SEDACreatingOsVersion', ['user_cardinality', 'creating_os_version'])
affk.set_fields_order('SEDAFormatLitteral', ['user_cardinality', 'format_litteral'])
pvds.set_fields_order('SEDAFormatLitteral', ['user_cardinality', 'format_litteral'])
......@@ -22,7 +22,7 @@ used bits).
from cubicweb import neg_role
from xsd import un_camel_case
from xsd2yams import PY_HEADER, xsy_mapping
from xsd2yams import PY_HEADER, HAS_ANNOTATIONS, xsy_mapping
LEVEL_ETYPES = set(('SEDABinaryDataObjectType', 'SEDAPhysicalDataObjectType',
......@@ -77,13 +77,21 @@ class UICFGGenerator(object):
all_etypes.remove('SEDAArchiveTransfer')
for etype in all_etypes:
stream.write("ives['{0}'] = 'subobject'\n".format(etype))
# autoform / primary view relation rtags
for rtag in ('autoform_section', 'autoform_field_kwargs', 'primaryview_section'):
rtag_info = self.rtags_info[rtag]
alias = rtag_info['shortname']
stream.write('\n\n{0} = uicfg.{1}\n'.format(rtag_info['shortname'], rtag))
for mapping_element in mapping.ordered:
for rtype, role, value in self._callback(rtag + '_for', mapping_element):
template = rtag_info[role]
stream.write(template.format(**locals()) + '\n')
# fields order
stream.write('pvds = uicfg.primaryview_display_ctrl\n')
for mapping_element in mapping.ordered:
for etype, attributes in self._callback('order_for', mapping_element):
stream.write("affk.set_fields_order('{0}', {1})\n".format(etype, attributes))
stream.write("pvds.set_fields_order('{0}', {1})\n".format(etype, attributes))
def _callback(self, prefix, mapping_element):
callback = '{0}_{1}'.format(prefix, un_camel_case(mapping_element.__class__.__name__))
......@@ -131,6 +139,22 @@ class UICFGGenerator(object):
yield mapping.rtype, neg_role(role), section
yield mapping.rtype, role, section
def order_for_e_type_mapping(self, mapping):
attributes = list(mapping.attributes)
if mapping.etype == 'SEDAArchiveTransfer':
attributes.append('title')
attributes.append('user_annotation')
elif attributes:
if len(mapping.cards) > 1:
if attributes[0] == 'id':
attributes.append('user_cardinality')
else:
attributes.insert(0, 'user_cardinality')
if mapping.etype in HAS_ANNOTATIONS:
attributes.append('user_annotation')
if len(attributes) > 1:
yield mapping.etype, attributes
class Code(unicode):
"""Special unicode subclass whose repr() doesn't add quotes, for insertion of python code in a data
......
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