Beispiel #1
0
def mk_external_entity(metamodel, s_ee):
    bridges = many(s_ee).S_BRG[19]()
    names = [brg.Name for brg in bridges]
    EE = collections.namedtuple(s_ee.Key_Lett, names)

    funcs = list()
    for s_brg in many(s_ee).S_BRG[19]():
        fn = mk_bridge(metamodel, s_brg)
        funcs.append(fn)

    return EE(*funcs)
Beispiel #2
0
def mk_external_entity(metamodel, s_ee):
    bridges = many(s_ee).S_BRG[19]()
    names = [brg.Name for brg in bridges]
    EE = collections.namedtuple(s_ee.Key_Lett, names)

    funcs = list()
    for s_brg in many(s_ee).S_BRG[19]():
        fn = mk_bridge(metamodel, s_brg)
        funcs.append(fn)

    return EE(*funcs)
Beispiel #3
0
def mk_class(m, o_obj, derived_attributes=False):
    '''
    Create a pyxtuml class from a BridgePoint class.
    '''
    first_filter = lambda selected: not one(selected).O_ATTR[103, 'succeeds']()
    o_attr = one(o_obj).O_ATTR[102](first_filter)
    attributes = list()

    while o_attr:
        s_dt = get_attribute_type(o_attr)
        ty = _get_data_type_name(s_dt)
        if not derived_attributes and one(o_attr).O_BATTR[106].O_DBATTR[107]():
            pass


#            logger.warning('Omitting derived attribute %s.%s ' %
#                           (o_obj.Key_Lett, o_attr.Name))
        elif not ty:
            logger.warning('Omitting unsupported attribute %s.%s ' %
                           (o_obj.Key_Lett, o_attr.Name))
        else:
            attributes.append((o_attr.Name, ty))

        o_attr = one(o_attr).O_ATTR[103, 'precedes']()

    metaclass = m.define_class(o_obj.Key_Lett, list(attributes), o_obj.Descrip)

    for o_id in many(o_obj).O_ID[104]():
        o_oida = many(o_id).O_OIDA[105]()
        o_attrs = many(o_oida).O_ATTR[105]()
        if not derived_attributes and one(
                o_attrs).O_BATTR[106].O_DBATTR[107]():
            logger.warning('Omitting unique identifier %s.I%d' %
                           (o_obj.Key_Lett, o_id.Oid_ID + 1))
            continue

        names = [o_attr.Name for o_attr in o_attrs]
        m.define_unique_identifier(o_obj.Key_Lett, o_id.Oid_ID + 1, *names)

    for o_tfr in many(o_obj).O_TFR[115]():
        fn = mk_operation(metaclass, o_tfr)
        setattr(metaclass.clazz, o_tfr.Name, fn)

    for o_dbattr in many(o_obj).O_ATTR[102].O_BATTR[106].O_DBATTR[107]():
        o_attr = one(o_dbattr).O_BATTR[107].O_ATTR[106]()
        fn = mk_derived_attribute(metaclass, o_dbattr)
        setattr(metaclass.clazz, o_attr.Name, fn)

    return metaclass
Beispiel #4
0
def mk_external_entity(metamodel, s_ee):
    '''
    Create a python object from a BridgePoint external entity with bridges
    realized as python member functions.
    '''
    bridges = many(s_ee).S_BRG[19]()
    names = [brg.Name for brg in bridges]
    EE = collections.namedtuple(s_ee.Key_Lett, names)

    funcs = list()
    for s_brg in many(s_ee).S_BRG[19]():
        fn = mk_bridge(metamodel, s_brg)
        funcs.append(fn)

    return EE(*funcs)
Beispiel #5
0
def mk_external_entity(metamodel, s_ee):
    '''
    Create a python object from a BridgePoint external entity with bridges
    realized as python member functions.
    '''
    bridges = many(s_ee).S_BRG[19]()
    names = [brg.Name for brg in bridges]
    EE = collections.namedtuple(s_ee.Key_Lett, names)

    funcs = list()
    for s_brg in many(s_ee).S_BRG[19]():
        fn = mk_bridge(metamodel, s_brg)
        funcs.append(fn)

    return EE(*funcs)
def mk_subsuper_association_check(m, r_subsup):
    r_rel = one(r_subsup).R_REL[206]()
    r_rto = one(r_subsup).R_SUPER[212].R_RTO[204]()
    target_o_obj = one(r_rto).R_OIR[203].O_OBJ[201]()
    
    text = ''
    loop_body = ''
    for r_sub in many(r_subsup).R_SUB[213]():
        r_rgo = one(r_sub).R_RGO[205]()
        source_o_obj = one(r_rgo).R_OIR[203].O_OBJ[201]()
        
        text += subtype_tmpl.substitute(From=source_o_obj.Key_Lett,
                                        To=target_o_obj.Key_Lett,
                                        Numb=r_rel.Numb,
                                        Cardinality='one')

        loop_body += supertype_body_tmpl.substitute(From=target_o_obj.Key_Lett,
                                                    To=source_o_obj.Key_Lett,
                                                    Numb=r_rel.Numb)
    
    text += supertype_loop_tmpl.substitute(From=target_o_obj.Key_Lett,
                                           Numb=r_rel.Numb,
                                           Loop_Body=loop_body)

    return text
Beispiel #7
0
def is_contained_in(pe_pe, root):
    '''
    Determine if a PE_PE is contained within a EP_PKG, EP_PKGREF, or a C_C.
    '''
    if not pe_pe:
        return False

    if type(pe_pe).__name__ != 'PE_PE':
        pe_pe = one(pe_pe).PE_PE[8001]()

    ep_pkg = one(pe_pe).EP_PKG[8000]()
    c_c = one(pe_pe).C_C[8003]()

    if root in [ep_pkg, c_c]:
        return True

    elif is_contained_in(ep_pkg, root):
        return True

    elif is_contained_in(c_c, root):
        return True

    for ep_pkg in many(ep_pkg).EP_PKG[1402, 'is referenced by']():
        if is_contained_in(ep_pkg, root):
            return True

    return False
def mk_subsuper_association_check(m, r_subsup):
    r_rel = one(r_subsup).R_REL[206]()
    r_rto = one(r_subsup).R_SUPER[212].R_RTO[204]()
    target_o_obj = one(r_rto).R_OIR[203].O_OBJ[201]()

    text = ''
    loop_body = ''
    for r_sub in many(r_subsup).R_SUB[213]():
        r_rgo = one(r_sub).R_RGO[205]()
        source_o_obj = one(r_rgo).R_OIR[203].O_OBJ[201]()

        text += subtype_tmpl.substitute(From=source_o_obj.Key_Lett,
                                        To=target_o_obj.Key_Lett,
                                        Numb=r_rel.Numb,
                                        Cardinality='one')

        loop_body += supertype_body_tmpl.substitute(From=target_o_obj.Key_Lett,
                                                    To=source_o_obj.Key_Lett,
                                                    Numb=r_rel.Numb)

    text += supertype_loop_tmpl.substitute(From=target_o_obj.Key_Lett,
                                           Numb=r_rel.Numb,
                                           Loop_Body=loop_body)

    return text
Beispiel #9
0
def mk_class(m, o_obj, derived_attributes=False):
    '''
    Create a pyxtuml class from a BridgePoint class.
    '''
    first_filter = lambda selected: not one(selected).O_ATTR[103, 'succeeds']()
    o_attr = one(o_obj).O_ATTR[102](first_filter)
    attributes = list()
        
    while o_attr:
        s_dt = get_attribute_type(o_attr)
        ty = _get_data_type_name(s_dt)
        if not derived_attributes and one(o_attr).O_BATTR[106].O_DBATTR[107]():
            pass
#            logger.warning('Omitting derived attribute %s.%s ' %
#                           (o_obj.Key_Lett, o_attr.Name))
        elif not ty:
            logger.warning('Omitting unsupported attribute %s.%s ' %
                           (o_obj.Key_Lett, o_attr.Name))
        else:
            attributes.append((o_attr.Name, ty))
        
        o_attr = one(o_attr).O_ATTR[103, 'precedes']()
            
    metaclass = m.define_class(o_obj.Key_Lett, list(attributes), o_obj.Descrip)

    for o_id in many(o_obj).O_ID[104]():
        o_oida = many(o_id).O_OIDA[105]()
        o_attrs = many(o_oida).O_ATTR[105]()
        if not derived_attributes and one(o_attrs).O_BATTR[106].O_DBATTR[107]():
            logger.warning('Omitting unique identifier %s.I%d' %
                           (o_obj.Key_Lett, o_id.Oid_ID + 1))
            continue
        
        names = [o_attr.Name for o_attr in o_attrs]
        m.define_unique_identifier(o_obj.Key_Lett, o_id.Oid_ID + 1, *names)
    
    for o_tfr in many(o_obj).O_TFR[115]():
        fn = mk_operation(metaclass, o_tfr)
        setattr(metaclass.clazz, o_tfr.Name, fn)
        
    for o_dbattr in many(o_obj).O_ATTR[102].O_BATTR[106].O_DBATTR[107]():
        o_attr = one(o_dbattr).O_BATTR[107].O_ATTR[106]()
        fn = mk_derived_attribute(metaclass, o_dbattr)
        setattr(metaclass.clazz, o_attr.Name, fn)
            
    return metaclass
Beispiel #10
0
def mk_enum(s_edt):
    '''
    Create a named tuple from a BridgePoint enumeration.
    '''
    s_dt = one(s_edt).S_DT[17]()
    enums = many(s_edt).S_ENUM[27]()
    enums = [enum.Name for enum in enums]
    Enum = collections.namedtuple(s_dt.Name, enums)
    return Enum(*range(len(enums)))
Beispiel #11
0
def mk_enum(s_edt):
    '''
    Create a named tuple from a BridgePoint enumeration.
    '''
    s_dt = one(s_edt).S_DT[17]()
    enums = many(s_edt).S_ENUM[27]()
    enums = [enum.Name for enum in enums]
    Enum = collections.namedtuple(s_dt.Name, enums)
    return Enum(*range(len(enums)))
Beispiel #12
0
 def accept_ACT_IF(self, inst):
     by_position = lambda inst: (one(inst).ACT_SMT[603]().LineNumber,
                                 one(inst).ACT_SMT[603]().StartPosition)
     
     self.buf('if ')
     self.accept(one(inst).V_VAL[625]())
     self.accept(one(inst).ACT_BLK[607]())
     
     for act_el in sorted(many(inst).ACT_EL[682](), key=by_position):
         self.accept(act_el)
     
     self.accept(one(inst).ACT_E[683]())
     
     self.buf('end if')
Beispiel #13
0
 def accept_ACT_IF(self, inst):
     by_position = lambda inst: (one(inst).ACT_SMT[603]().LineNumber,
                                 one(inst).ACT_SMT[603]().StartPosition)
     
     self.buf('if ')
     self.accept(one(inst).V_VAL[625]())
     self.accept(one(inst).ACT_BLK[607]())
     
     for act_el in sorted(many(inst).ACT_EL[682](), key=by_position):
         self.accept(act_el)
     
     self.accept(one(inst).ACT_E[683]())
     
     self.buf('end if')
Beispiel #14
0
def mk_enum(s_edt):
    '''
    Create a named tuple from a BridgePoint enumeration.
    '''
    s_dt = one(s_edt).S_DT[17]()
    enums = list()
    kwlist = ['False', 'None', 'True'] + keyword.kwlist
    for enum in many(s_edt).S_ENUM[27]():
        if enum.Name in kwlist:
            enums.append(enum.Name + '_')
        else:
            enums.append(enum.Name)

    Enum = collections.namedtuple(s_dt.Name, enums)
    return Enum(*range(len(enums)))
Beispiel #15
0
def mk_enum(s_edt):
    '''
    Create a named tuple from a BridgePoint enumeration.
    '''
    s_dt = one(s_edt).S_DT[17]()
    enums = list()
    kwlist =['False', 'None', 'True'] + keyword.kwlist
    for enum in many(s_edt).S_ENUM[27]():
        if enum.Name in kwlist:
            enums.append(enum.Name + '_')
        else:
            enums.append(enum.Name)
            
    Enum = collections.namedtuple(s_dt.Name, enums)
    return Enum(*range(len(enums)))
Beispiel #16
0
def get_related_attributes(r_rgo, r_rto):
    '''
    The two lists of attributes which relates two classes in an association.
    '''
    l1 = list()
    l2 = list()
    
    ref_filter = lambda ref: ref.OIR_ID == r_rgo.OIR_ID
    for o_ref in many(r_rto).O_RTIDA[110].O_REF[111](ref_filter):
        o_attr = one(o_ref).O_RATTR[108].O_ATTR[106]()
        l1.append(o_attr.Name)
        
        o_attr = one(o_ref).O_RTIDA[111].O_OIDA[110].O_ATTR[105]()
        l2.append(o_attr.Name)
        
    return l1, l2
Beispiel #17
0
def get_related_attributes(r_rgo, r_rto):
    '''
    The two lists of attributes which relates two classes in an association.
    '''
    l1 = list()
    l2 = list()

    ref_filter = lambda ref: ref.OIR_ID == r_rgo.OIR_ID
    for o_ref in many(r_rto).O_RTIDA[110].O_REF[111](ref_filter):
        o_attr = one(o_ref).O_RATTR[108].O_ATTR[106]()
        l1.append(o_attr.Name)

        o_attr = one(o_ref).O_RTIDA[111].O_OIDA[110].O_ATTR[105]()
        l2.append(o_attr.Name)

    return l1, l2
def mk_unique_constraint_check(m, o_id):
    o_obj = one(o_id).O_OBJ[104]()
    where_clause = prefix = ''
    for o_oida in many(o_id).O_OIDA[105]():
        clause = '(%s.%s == %s_Instance.%s)' % (
            'selected', o_oida.localAttributeName, o_obj.Key_Lett,
            o_oida.localAttributeName)
        where_clause += (prefix + clause)
        prefix = ' and '

    if not where_clause:
        return ''

    return constraint_tmpl.substitute(Kind=o_obj.Key_Lett,
                                      Where_Clause=where_clause,
                                      Numb=o_id.Oid_ID + 1)
def mk_unique_constraint_check(m, o_id):
    o_obj = one(o_id).O_OBJ[104]()
    where_clause = prefix = ''
    for o_oida in many(o_id).O_OIDA[105]():
        clause = '(%s.%s == %s_Instance.%s)' % ('selected',
                                                o_oida.localAttributeName,
                                                o_obj.Key_Lett,
                                                o_oida.localAttributeName)
        where_clause += (prefix + clause)
        prefix = ' and '
    
    if not where_clause:
        return ''
    
    return constraint_tmpl.substitute(Kind=o_obj.Key_Lett,
                                      Where_Clause=where_clause,
                                      Numb=o_id.Oid_ID + 1)
Beispiel #20
0
def mk_component(bp_model, c_c=None, derived_attributes=False):
    '''
    Create a pyxtuml meta model from a BridgePoint model. 
    Optionally, restrict to classes and associations contained in the
    component c_c.
    '''
    target = Domain()

    c_c_filt = lambda sel: c_c is None or is_contained_in(sel, c_c)

    for o_obj in bp_model.select_many('O_OBJ', c_c_filt):
        mk_class(target, o_obj, derived_attributes)

    for r_rel in bp_model.select_many('R_REL', c_c_filt):
        mk_association(target, r_rel)

    for s_sync in bp_model.select_many('S_SYNC', c_c_filt):
        fn = mk_function(target, s_sync)
        target.add_symbol(s_sync.Name, fn)

    for s_dt in bp_model.select_many('S_DT', c_c_filt):
        s_edt = one(s_dt).S_EDT[17]()
        if s_edt:
            enum = mk_enum(s_edt)
            target.add_symbol(s_dt.Name, enum)

    for cnst_csp in bp_model.select_many('CNST_CSP', c_c_filt):
        for cnst_syc in many(cnst_csp).CNST_SYC[1504]():
            value = mk_constant(cnst_syc)
            target.add_symbol(cnst_syc.Name, value)

    for ass in target.associations:
        ass.formalize()

    for s_ee in bp_model.select_many('S_EE', c_c_filt):
        if s_ee.Key_Lett in ['LOG', 'ARCH', 'TIM', 'NVS', 'PERSIST']:
            target.add_symbol(s_ee.Key_Lett, getattr(builtin_ee,
                                                     s_ee.Key_Lett))

        else:
            ee = mk_external_entity(target, s_ee)
            target.add_symbol(s_ee.Key_Lett, ee)

    return target
def main():
    if len(sys.argv) < 2:
        logger.info('usage: %s <path to ooaofooa model folder>' % sys.argv[0])
        sys.exit(1)

    loader = ooaofooa.Loader()
    for filename in sys.argv[1:]:
        loader.filename_input(filename)

    m = loader.build_metamodel()

    for r_rel in m.select_many('R_REL', description_filter):
        logger.info('Filtering R%d' % r_rel.Numb)
        xtuml.delete(r_rel)

    for o_obj in m.select_many('O_OBJ', description_filter):
        logger.info('Filtering %s' % o_obj.Key_Lett)
        for r_rel in many(o_obj).R_OIR[201].R_REL[201]():
            logger.info('Filtering R%d' % r_rel.Numb)
            for r_oir in many(r_rel).R_OIR[201]():
                xtuml.unrelate(r_rel, r_oir, 201)

            xtuml.delete(r_rel)

        xtuml.delete(o_obj)

    for o_attr in m.select_many('O_ATTR', where(Name='SMspd_ID')):
        if not one(o_attr).O_RATTR[106]():
            continue

        for o_oida in many(o_attr).O_OIDA[105]():
            for o_rtida in many(o_oida).O_RTIDA[110]():
                xtuml.delete(o_rtida)
            xtuml.delete(o_oida)

        for o_ref in many(o_attr).O_RATTR[106].O_REF[108]():
            xtuml.delete(o_ref)

    c = ooaofooa.mk_component(m, None, derived_attributes=True)
    metaclass = c.find_metaclass('ACT_ACT')
    metaclass.insert_attribute(index=5,
                               name='return_value',
                               type_name='INTEGER')

    for o_obj in m.select_many('O_OBJ'):
        for o_attr in many(o_obj).O_ATTR[102](description_filter):
            logger.info('Filtering %s.%s' % (o_obj.Key_Lett, o_attr.Name))
            metaclass = c.find_metaclass(o_obj.Key_Lett)
            metaclass.delete_attribute(o_attr.Name)

    xtuml.persist_schema(c, '/dev/stdout')
Beispiel #22
0
def mk_component(bp_model, c_c=None, derived_attributes=False):
    '''
    Create a pyxtuml meta model from a BridgePoint model. 
    Optionally, restrict to classes and associations contained in the
    component c_c.
    '''
    target = Domain()

    c_c_filt = lambda sel: c_c is None or is_contained_in(sel, c_c)
    
    for o_obj in bp_model.select_many('O_OBJ', c_c_filt):
        mk_class(target, o_obj, derived_attributes)
        
    for r_rel in bp_model.select_many('R_REL', c_c_filt):
        mk_association(target, r_rel)
        
    for s_sync in bp_model.select_many('S_SYNC', c_c_filt):
        fn = mk_function(target, s_sync)
        target.add_symbol(s_sync.Name, fn)
    
    for s_dt in bp_model.select_many('S_DT', c_c_filt):
        s_edt = one(s_dt).S_EDT[17]()
        if s_edt:
            enum = mk_enum(s_edt)
            target.add_symbol(s_dt.Name, enum)
        
    for cnst_csp in bp_model.select_many('CNST_CSP', c_c_filt):
        for cnst_syc in many(cnst_csp).CNST_SYC[1504]():
            value = mk_constant(cnst_syc)
            target.add_symbol(cnst_syc.Name, value)
        
    for ass in target.associations:
        ass.formalize()
    
    for s_ee in bp_model.select_many('S_EE', c_c_filt):
        if s_ee.Key_Lett in ['LOG', 'ARCH', 'TIM', 'NVS', 'PERSIST']:
            target.add_symbol(s_ee.Key_Lett, getattr(builtin_ee, s_ee.Key_Lett))
                              
        else:
            ee = mk_external_entity(target, s_ee)
            target.add_symbol(s_ee.Key_Lett, ee)
    
    return target
def main():
    if len(sys.argv) < 2:
        logger.info('usage: %s <path to ooaofooa model folder>' % sys.argv[0])
        sys.exit(1)
        
    loader = ooaofooa.Loader()
    for filename in sys.argv[1:]:
        loader.filename_input(filename)
    
    m = loader.build_metamodel()

    for r_rel in m.select_many('R_REL', description_filter):
        logger.info('Filtering R%d' % r_rel.Numb)
        xtuml.delete(r_rel)

    for o_obj in m.select_many('O_OBJ', description_filter):
        logger.info('Filtering %s' % o_obj.Key_Lett)
        for r_rel in many(o_obj).R_OIR[201].R_REL[201]():
            logger.info('Filtering R%d' % r_rel.Numb)
            for r_oir in many(r_rel).R_OIR[201]():
                xtuml.unrelate(r_rel, r_oir, 201)
                
            xtuml.delete(r_rel)
            
        xtuml.delete(o_obj)

    for o_attr in m.select_many('O_ATTR', where(Name='SMspd_ID')):
        if not one(o_attr).O_RATTR[106]():
            continue
            
        for o_oida in many(o_attr).O_OIDA[105]():
            for o_rtida in many(o_oida).O_RTIDA[110]():
                xtuml.delete(o_rtida)
            xtuml.delete(o_oida)

        for o_ref in many(o_attr).O_RATTR[106].O_REF[108]():
            xtuml.delete(o_ref)
            
    c = ooaofooa.mk_component(m, None, derived_attributes=True)
    metaclass = c.find_metaclass('ACT_ACT')
    metaclass.insert_attribute(index=5, name='return_value', type_name='INTEGER')

    for o_obj in m.select_many('O_OBJ'):
        for o_attr in many(o_obj).O_ATTR[102](description_filter):
            logger.info('Filtering %s.%s' % (o_obj.Key_Lett, o_attr.Name))
            metaclass = c.find_metaclass(o_obj.Key_Lett)
            metaclass.delete_attribute(o_attr.Name)
            
    xtuml.persist_schema(c, '/dev/stdout')
Beispiel #24
0
    def test_elif_else(self):
        '''
        assign x = 0;
        if (1 == 0)
            assign x = 1;
        elif (1 == 1)
            assign x = 2;
        else
            assign x = 3;
        end if;
        return x;
        '''
        act_if = self.metamodel.select_one('ACT_IF')
        self.assertIsNotNone(act_if)
        
        act_smt = one(act_if).ACT_SMT[603]()
        self.assertIsNotNone(act_smt)
        
        v_val = one(act_if).V_VAL[625]()
        self.assertIsNotNone(v_val)
        
        act_blk = one(act_if).ACT_BLK[607]()
        self.assertIsNotNone(act_blk)
        
        act_el = many(act_if).ACT_EL[682]()
        self.assertEqual(len(act_el), 1)
        
        act_el = one(act_if).ACT_EL[682]()
        act_smt = one(act_el).ACT_SMT[603]()
        self.assertIsNotNone(act_smt)

        v_val = one(act_el).V_VAL[659]()
        self.assertIsNotNone(v_val)
        
        act_blk = one(act_el).ACT_BLK[658]()
        self.assertIsNotNone(act_blk)
        
        act_e = one(act_if).ACT_E[683]()
        act_blk = one(act_e).ACT_BLK[606]()
        self.assertIsNotNone(act_blk)
Beispiel #25
0
    def test_elif_else(self):
        '''
        assign x = 0;
        if (1 == 0)
            assign x = 1;
        elif (1 == 1)
            assign x = 2;
        else
            assign x = 3;
        end if;
        return x;
        '''
        act_if = self.metamodel.select_one('ACT_IF')
        self.assertIsNotNone(act_if)

        act_smt = one(act_if).ACT_SMT[603]()
        self.assertIsNotNone(act_smt)

        v_val = one(act_if).V_VAL[625]()
        self.assertIsNotNone(v_val)

        act_blk = one(act_if).ACT_BLK[607]()
        self.assertIsNotNone(act_blk)

        act_el = many(act_if).ACT_EL[682]()
        self.assertEqual(len(act_el), 1)

        act_el = one(act_if).ACT_EL[682]()
        act_smt = one(act_el).ACT_SMT[603]()
        self.assertIsNotNone(act_smt)

        v_val = one(act_el).V_VAL[659]()
        self.assertIsNotNone(v_val)

        act_blk = one(act_el).ACT_BLK[658]()
        self.assertIsNotNone(act_blk)

        act_e = one(act_if).ACT_E[683]()
        act_blk = one(act_e).ACT_BLK[606]()
        self.assertIsNotNone(act_blk)
Beispiel #26
0
def mk_subsuper_association(m, inst):
    '''
    Create pyxtuml associations from a sub/super association in BridgePoint.
    '''
    r_rel = one(inst).R_REL[206]()
    r_rto = one(inst).R_SUPER[212].R_RTO[204]()
    target_o_obj = one(r_rto).R_OIR[203].O_OBJ[201]()
    
    if not r_rto:
        logger.info('Omitting unformalized association R%s' % (r_rel.Numb))
        return
    
    for r_sub in many(inst).R_SUB[213]():
        r_rgo = one(r_sub).R_RGO[205]()

        source_o_obj = one(r_rgo).R_OIR[203].O_OBJ[201]()
        source_ids, target_ids = get_related_attributes(r_rgo, r_rto)
        
        source = xtuml.AssociationLink(source_o_obj.Key_Lett, '1C', source_ids)
        target = xtuml.AssociationLink(target_o_obj.Key_Lett, '1', target_ids)
        
        m.define_association(r_rel.Numb, source, target)
def generate_actions(m, c_c, s_sync):
    text = ''

    handler = {
        'R_SIMP': mk_simple_association_check,
        'R_ASSOC': mk_linked_association_check,
        'R_SUBSUP': mk_subsuper_association_check,
        'R_COMP': mk_derived_association_check,
    }

    filt = lambda sel: ooaofooa.is_contained_in(sel, c_c)
    for r_rel in m.select_many('R_REL', filt):
        inst = subtype(r_rel, 206)
        fn = handler.get(inst.__class__.__name__)
        text += fn(m, inst)

    o_objs = m.select_many('O_OBJ', filt)
    for o_id in many(o_objs).O_ID[104]():
        text += mk_unique_constraint_check(m, o_id)

    text += 'return True;'
    s_sync.Action_Semantics_internal = text
    s_sync.Suc_Pars = 1
def generate_actions(m, c_c, s_sync):
    text = ''
    
    handler = {
        'R_SIMP': mk_simple_association_check,
        'R_ASSOC': mk_linked_association_check,
        'R_SUBSUP': mk_subsuper_association_check,
        'R_COMP': mk_derived_association_check,
    }

    filt = lambda sel: ooaofooa.is_contained_in(sel, c_c)
    for r_rel in m.select_many('R_REL', filt):
        inst = subtype(r_rel, 206)
        fn = handler.get(inst.__class__.__name__)
        text += fn(m, inst)

    o_objs = m.select_many('O_OBJ', filt)
    for o_id in many(o_objs).O_ID[104]():
        text += mk_unique_constraint_check(m, o_id)
    
    text += 'return True;'
    s_sync.Action_Semantics_internal = text
    s_sync.Suc_Pars = 1
Beispiel #29
0
def mk_subsuper_association(m, inst):
    '''
    Create pyxtuml associations from a sub/super association in BridgePoint.
    '''
    r_rel = one(inst).R_REL[206]()
    r_rto = one(inst).R_SUPER[212].R_RTO[204]()
    target_o_obj = one(r_rto).R_OIR[203].O_OBJ[201]()

    for r_sub in many(inst).R_SUB[213]():
        r_rgo = one(r_sub).R_RGO[205]()

        source_o_obj = one(r_rgo).R_OIR[203].O_OBJ[201]()
        source_ids, target_ids = get_related_attributes(r_rgo, r_rto)
        m.define_association(rel_id=r_rel.Numb,
                             source_kind=source_o_obj.Key_Lett,
                             target_kind=target_o_obj.Key_Lett,
                             source_keys=source_ids,
                             target_keys=target_ids,
                             source_conditional=True,
                             target_conditional=False,
                             source_phrase='',
                             target_phrase='',
                             source_many=False,
                             target_many=False)
Beispiel #30
0
    def test_single_if_true(self):
        '''
        if ( 0 == 0 )
            return 1;
        end if;
        return 0;
        '''
        act_if = self.metamodel.select_one('ACT_IF')
        self.assertIsNotNone(act_if)

        act_smt = one(act_if).ACT_SMT[603]()
        self.assertIsNotNone(act_smt)

        v_val = one(act_if).V_VAL[625]()
        self.assertIsNotNone(v_val)

        act_blk = one(act_if).ACT_BLK[607]()
        self.assertIsNotNone(act_blk)

        act_el = many(act_if).ACT_EL[682]()
        self.assertEqual(len(act_el), 0)

        act_e = one(act_if).ACT_E[683]()
        self.assertIsNone(act_e)
Beispiel #31
0
def mk_subsuper_association(m, inst):
    '''
    Create pyxtuml associations from a sub/super association in BridgePoint.
    '''
    r_rel = one(inst).R_REL[206]()
    r_rto = one(inst).R_SUPER[212].R_RTO[204]()
    target_o_obj = one(r_rto).R_OIR[203].O_OBJ[201]()
    
    for r_sub in many(inst).R_SUB[213]():
        r_rgo = one(r_sub).R_RGO[205]()

        source_o_obj = one(r_rgo).R_OIR[203].O_OBJ[201]()
        source_ids, target_ids = get_related_attributes(r_rgo, r_rto)
        m.define_association(rel_id=r_rel.Numb, 
                             source_kind=source_o_obj.Key_Lett,
                             target_kind=target_o_obj.Key_Lett,
                             source_keys=source_ids,
                             target_keys=target_ids,
                             source_conditional=True,
                             target_conditional=False,
                             source_phrase='',
                             target_phrase='',
                             source_many=False,
                             target_many=False)
Beispiel #32
0
 def test_single_if_true(self):
     '''
     if ( 0 == 0 )
         return 1;
     end if;
     return 0;
     '''
     act_if = self.metamodel.select_one('ACT_IF')
     self.assertIsNotNone(act_if)
     
     act_smt = one(act_if).ACT_SMT[603]()
     self.assertIsNotNone(act_smt)
     
     v_val = one(act_if).V_VAL[625]()
     self.assertIsNotNone(v_val)
     
     act_blk = one(act_if).ACT_BLK[607]()
     self.assertIsNotNone(act_blk)
     
     act_el = many(act_if).ACT_EL[682]()
     self.assertEqual(len(act_el), 0)
     
     act_e = one(act_if).ACT_E[683]()
     self.assertIsNone(act_e)
 def accept_S_SYS(self, inst):
     '''
     A System Model contains top-level packages
     '''
     for child in many(inst).EP_PKG[1401]():
         self.accept(child)
#
# pyxtuml is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with pyxtuml. If not, see <http://www.gnu.org/licenses/>.

import sys

from xtuml import navigate_one as one
from xtuml import navigate_many as many
from bridgepoint import ooaofooa

if len(sys.argv) < 2:
    print('')
    print('  usage: %s <path to bridgepoint model folder>' % sys.argv[0])
    print('')
    sys.exit(1)

m = ooaofooa.load_metamodel(sys.argv[1])

by_name = lambda inst: inst.Name
for o_obj in sorted(m.select_many('O_OBJ'), key=by_name):
    print(o_obj.Name)

    for o_attr in sorted(many(o_obj).O_ATTR[102](), key=by_name):
        s_dt = one(o_attr).S_DT[114]()
        print('   %s : %s' % (o_attr.Name, s_dt.Name))
#!/usr/bin/env python
# encoding: utf-8
# Copyright (C) 2015 John Törnblom

import sys

from xtuml import navigate_one as one
from xtuml import navigate_many as many
from bridgepoint import ooaofooa


if len(sys.argv) < 2:
    print('')
    print('  usage: %s <path to bridgepoint model folder>' % sys.argv[0])
    print('')
    sys.exit(1)

    
loader = ooaofooa.Loader()
loader.filename_input(sys.argv[1])
m = loader.build_metamodel()

by_name = lambda inst: inst.Name
for o_obj in sorted(m.select_many('O_OBJ'), key=by_name):
    print(o_obj.Name)

    for o_attr in sorted(many(o_obj).O_ATTR[102](), key=by_name):
        s_dt = one(o_attr).S_DT[114]()
        print('   %s : %s' % (o_attr.Name, s_dt.Name))

 def accept_C_C(self, inst):
     '''
     A Component contains packageable elements
     '''
     for child in many(inst).PE_PE[8003]():
         self.accept(child)
 def accept_EP_PKG(self, inst):
     '''
     A Package contains packageable elements
     '''
     for child in many(inst).PE_PE[8000]():
         self.accept(child)