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

[xsd2yams] Don't put skipped attributes into mapping's attributes

rather then adding them and skipping them later. That made later use of the same
data structure easier.
parent 69b5df611848
......@@ -65,10 +65,9 @@ class XSYMappingTC(unittest.TestCase):
mapping = xsy_mapping('BinaryDataObject')
self.assertIn('SEDABinaryDataObject', mapping.etypes)
emapping = mapping.etypes['SEDABinaryDataObject']
self.assertEMappingEqual(emapping, {'id': 'String', 'filename': 'String', 'size': 'Int'})
self.assertEMappingEqual(emapping, {'id': 'String'})
emapping = mapping.etypes['SEDACompressed']
self.assertEMappingEqual(emapping, {'compressed': 'Boolean',
'uncompressed_size': 'Int'})
self.assertEMappingEqual(emapping, {'compressed': 'Boolean'})
class XSIterateTC(unittest.TestCase):
......
......@@ -92,44 +92,36 @@ class UICFGGenerator(object):
return method(mapping_element)
def etypes_for_e_type_mapping(self, mapping):
# special case SEDAid/seda_id which is still in the intermediary representation but not in
# the schema
if mapping.etype != 'SEDAid':
yield mapping.etype
yield mapping.etype
def autoform_section_for_rdef_mapping(self, mapping):
# special case SEDAid/seda_id which is still in the intermediary representation but not in
# the schema
if not mapping.final and mapping.subjtype != 'SEDAid':
if (mapping.rtype.endswith('code_list_version_from')
or mapping.rtype.endswith('code_list_version')
or mapping.rtype in RTYPES_IN_TAB):
section = 'hidden'
role = mapping.composite or 'subject'
yield mapping.rtype, neg_role(role), section
elif mapping.composite:
section = 'inlined'
role = mapping.composite
yield mapping.rtype, neg_role(role), 'hidden'
else:
section = 'attributes'
role = 'subject'
yield mapping.rtype, role, section
if (mapping.rtype.endswith('code_list_version_from')
or mapping.rtype.endswith('code_list_version')
or mapping.rtype in RTYPES_IN_TAB):
section = 'hidden'
role = mapping.composite or 'subject'
yield mapping.rtype, neg_role(role), section
elif mapping.composite:
section = 'inlined'
role = mapping.composite
yield mapping.rtype, neg_role(role), 'hidden'
else:
section = 'attributes'
role = 'subject'
yield mapping.rtype, role, section
def autoform_field_kwargs_for_rdef_mapping(self, mapping):
if not mapping.final and mapping.subjtype != 'SEDAid':
if mapping.rtype.endswith('code_list_version_to'):
yield mapping.rtype, 'subject', {'label': 'value'}
if mapping.rtype.endswith('code_list_version_to'):
yield mapping.rtype, 'subject', {'label': 'value'}
def primaryview_section_for_rdef_mapping(self, mapping):
if not mapping.final and mapping.subjtype != 'SEDAid':
if (mapping.rtype.endswith('code_list_version_from')
or mapping.rtype.endswith('code_list_version')
or mapping.rtype in RTYPES_IN_TAB):
section = 'hidden'
role = mapping.composite or 'subject'
yield mapping.rtype, neg_role(role), section
yield mapping.rtype, role, section
if (mapping.rtype.endswith('code_list_version_from')
or mapping.rtype.endswith('code_list_version')
or mapping.rtype in RTYPES_IN_TAB):
section = 'hidden'
role = mapping.composite or 'subject'
yield mapping.rtype, neg_role(role), section
yield mapping.rtype, role, section
if __name__ == '__main__':
......
......@@ -106,6 +106,8 @@ class XSYMapping(object):
for occ, path in child_defs:
if not path:
continue # jumped element
if path[0][2] in SKIP_ETYPES:
continue
current_emapping = emapping
is_complex = len(path) == 2
end_etype = path[-1][2]
......@@ -116,7 +118,8 @@ class XSYMapping(object):
for i, (rtype, role, target_etype, rdef_options) in enumerate(path):
if target_etype in BASE_TYPES:
assert role == 'subject'
current_emapping.attributes[rtype] = target_etype
if rtype not in SKIP_ATTRS:
current_emapping.attributes[rtype] = target_etype
continue
if role == 'subject':
subjtype = current_emapping.etype
......@@ -221,10 +224,6 @@ class CodeGenerator(object):
outfile.write(mapping_code.encode('utf8'))
def code_for_e_type_mapping(self, mapping):
# special case SEDAid/seda_id which is still in the intermediary representation but not in
# the schema
if mapping.etype in SKIP_ETYPES:
return u''
if mapping.cards:
annotable = mapping.etype in HAS_ANNOTATIONS
cards = mapping.cards
......@@ -239,8 +238,6 @@ class CodeGenerator(object):
u""""""
'''.format(mapping.etype)
for attrname, attrtype in sorted(mapping.attributes.items()):
if attrname in SKIP_ATTRS:
continue
args = u''
if attrname == 'id':
# XXX should be globaly unique in a profile
......@@ -252,10 +249,6 @@ class CodeGenerator(object):
return code + '\n\n'
def code_for_rdef_mapping(self, mapping):
# special case SEDAid/seda_id which is still in the intermediary representation but not in
# the schema
if mapping.subjtype == 'SEDAid':
return u''
rtype = mapping.rtype
alias = mapping.alias
if not alias:
......
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