def property(self, source, target): """Create property. """ if isprofilemember(source): return if source.attributes.get('association', None) is not None: return if 'type' in source.attributes.keys(): typedef = source.refindex[source.attributes['type']] tok = token('sourcetotargetuuidmapping', False) type = target.anchor.node(tok.uuids[typedef.uuid]) else: try: name = source['type'].attributes['href'] except KeyError: raise ValueError,'Property "%s" in class "%s" has no datatype!' % \ (source.element.get('name'),source.parent.element.get('name')) name = name[name.rfind('#') + 1:] tok = token('primitivetypemapping', False) type = target.anchor.node(tok.types[name]) property = Property() assignxmiprops(property,source) property.type = type target.anchor[source.attributes['name']] = property target.finalize(source, property)
def ownedend(self, source, target): """Create owned end. """ if isprofilemember(source): return oe_source = source.refindex[source.attributes['association']] tok = token('sourcetotargetuuidmapping', False) associationuuid = tok.uuids[oe_source.uuid] association = target.anchor.node(associationuuid) associationend = AssociationEnd() assignxmiprops(associationend,source) associationend.association = association # XXX: we the private uuid listing pointing to member ends. could # be simlified, read node.ext.uml.classes for details association._memberEnds.append(associationend.uuid) cla_source = source.refindex[source.attributes['type']] classuuid = tok.uuids[cla_source.uuid] associationend.type = target.anchor.node(classuuid) uppervalue = source['upperValue'].attributes['value'] if source.has_key('uppervalue') else '*' if uppervalue == '*': uppervalue = INFINITE else: uppervalue = int(uppervalue) associationend.uppervalue = uppervalue lowervalue = source['lowerValue'].attributes.get('value', '*') if source.has_key('lowervalue') else 1 if lowervalue == '*': lowervalue = INFINITE else: lowervalue = int(lowervalue) associationend.lowervalue = lowervalue association[source.attributes['name']] = associationend target.finalize(source, associationend)
def associationclass(self, source, target): """Create association classes. """ if isprofilemember(source): return association_class = AssociationClass() assignxmiprops(association_class, source) target.anchor[source.attributes['name']] = association_class target.finalize(source, association_class)
def association(self, source, target): """Create associations. """ if isprofilemember(source): return association = Association() assignxmiprops(association, source) target.anchor[str(association.uuid)] = association target.finalize(source, association)
def datatype(self, source, target): """Create datatypes. """ # XXX: discuss, if datatypes of profile are ignored, they are not available # in UML representation. if isprofilemember(source): return datatype = Datatype() target.anchor[source.attributes['name']] = datatype target.finalize(source, datatype)
def interfacerealization(self, source, target): """Create interface realization. """ if isprofilemember(source): return tok = token('sourcetotargetuuidmapping', False) containeruuid = tok.uuids[source.__parent__.uuid] container = target.anchor.node(containeruuid) contract_source = source.refindex[source.attributes['contract']] contractuuid = tok.uuids[contract_source.uuid] contract = target.anchor.node(contractuuid) interfacerealization = InterfaceRealization() interfacerealization.contract = contract container[str(interfacerealization.uuid)] = interfacerealization target.finalize(source, interfacerealization)
def generalization(self, source, target): """Create generalization. """ if isprofilemember(source): return tok = token('sourcetotargetuuidmapping', False) containeruuid = tok.uuids[source.__parent__.uuid] container = target.anchor.node(containeruuid) general_source = source.refindex[source.attributes['general']] generaluuid = tok.uuids[general_source.uuid] general = target.anchor.node(generaluuid) generalization = Generalization() generalization.general = general container[str(generalization.uuid)] = generalization target.finalize(source, generalization)
def dependency(self, source, target): if isprofilemember(source): return tok = token('sourcetotargetuuidmapping', False) supplier_source = source.refindex[source.attributes['supplier']] supplieruuid = tok.uuids[supplier_source.uuid] supplier = target.anchor.node(supplieruuid) client_source = source.refindex[source.attributes['client']] clientuuid = tok.uuids[client_source.uuid] client = target.anchor.node(clientuuid) dependency = Dependency() assignxmiprops(dependency,source) dependency.client = client dependency.supplier = supplier target.anchor[str(dependency.uuid)] = dependency target.finalize(source, dependency)