def interfacegeneralization(self, source, target):
    """Create generalization between interfaces .
    """
    inheritance = Inheritance(source)
    targetclass = read_target_node(source, target.target)
    if targetclass:
        tok = token(str(targetclass.uuid), True, depends_on=set())
    for obj in inheritance.values():
        tok.depends_on.add(read_target_node(obj.context, target.target))
        if not obj.context.name in targetclass.bases:
            targetclass.bases.append(obj.context.name)
            tgv = TaggedValues(obj.context)
            import_from = tgv.direct('import', 'pyegg:stub')
            if import_from is not UNSET:
                imp = Imports(targetclass.__parent__)
                imp.set(import_from, [[obj.context.name, None]])
        derive_from = read_target_node(obj.context, target.target)
        if not derive_from:
            continue
        if targetclass.__parent__ is not derive_from.__parent__:
            imp = Imports(targetclass.__parent__)
            imp.set(class_base_name(derive_from),
                    [[derive_from.classname, None]])
    if targetclass and not targetclass.bases:
        targetclass.bases.append('Interface')
Exemplo n.º 2
0
def get_pks(klass):
    """gets the pks of an uml class.
    """
    res = [f for f in klass.filtereditems(IProperty) \
        if f.stereotype('sql:primary')]

    if not res:
        # then we look if we can find an inherited primary key
        inhs = Inheritance(klass)
        for inh in inhs.values():
            if inh.context.stereotype('sql:sql_content'):
                res = get_pks(inh.context)
                if res:
                    return res

    return res