예제 #1
0
 def accept_ACT_SEL(self, inst):
     self.buf('select ', inst.cardinality, ' ')
     self.accept(one(inst).V_VAR[638]())
     self.buf(' related by ')
     self.accept(one(inst).V_VAL[613]())
     self.accept(one(inst).ACT_LNK[637]())
     self.accept(one(inst).ACT_SRW[664]())
예제 #2
0
 def accept_ACT_FIW(self, inst):
     o_obj = one(inst).O_OBJ[676]()
     self.buf('select ', inst.cardinality, ' ')
     self.accept(one(inst).V_VAR[665]())
     self.buf(' from instances of ', o_obj.Key_Lett)
     self.buf(' where ')
     self.accept(one(inst).V_VAL[610]())
 def check_link(side):
     r_rto = one(side).R_RTO[204]()
     target_o_obj = one(r_rto).R_OIR[203].O_OBJ[201]()
     
     if side.Mult:
         cardinality = 'many'
     else:
         cardinality = 'one'
             
     text = atleast_one_tmpl.substitute(From=target_o_obj.Key_Lett,
                                        To=source_o_obj.Key_Lett,
                                        Numb=r_rel.Numb,
                                        Cardinality=cardinality,
                                        Phrase=side.Txt_Phrs)
     if not side.Cond:
         if side.Mult:
             cardinality = 'one'
         else:
             cardinality = 'one'
             
         text += atleast_one_tmpl.substitute(From=source_o_obj.Key_Lett,
                                             To=target_o_obj.Key_Lett,
                                             Numb=r_rel.Numb,
                                             Cardinality=cardinality,
                                             Phrase=side.Txt_Phrs)
     return text
예제 #4
0
 def accept_V_PAR(self, inst):
     if one(inst).V_PAR[816, 'succeeds']() is not None:
         self.buf(', ')
         
     self.buf(inst.Name, ': ')
     self.accept(one(inst).V_VAL[800]())
     self.accept(one(inst).V_PAR[816, 'precedes']())
예제 #5
0
 def accept_ACT_IOP(self, inst):
     self.accept(one(inst).SPR_PO[680].SPR_PEP[4503]())
     self.accept(one(inst).SPR_RO[657].SPR_REP[4502]())
     self.buf('(')
     first_filter = lambda sel: one(sel).V_PAR[816, 'succeeds']() is None
     self.accept(any(inst).V_PAR[679](first_filter))
     self.buf(')')
예제 #6
0
 def parameters(self, function_name):
     s_sync = self.m.select_one('S_SYNC', where(Name=function_name))
     first_filt = lambda sel: not one(sel).S_SPARM[54, 'precedes']()
     s_sparm = one(s_sync).S_SPARM[24](first_filt)
     while s_sparm:
         yield s_sparm.Name
         s_sparm = one(s_sparm).S_SPARM[54, 'succeeds']()
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
예제 #8
0
 def accept_ACT_SGN(self, inst):
     self.accept(one(inst).SPR_PS[663].SPR_PEP[4503]())
     self.accept(one(inst).SPR_RS[660].SPR_REP[4502]())
     self.buf('(')
     first_filter = lambda sel: one(sel).V_PAR[816, 'succeeds']() is None
     self.accept(any(inst).V_PAR[662](first_filter))
     self.buf(')')
예제 #9
0
 def accept_ACT_IOP(self, inst):
     self.accept(one(inst).SPR_PO[680].SPR_PEP[4503]())
     self.accept(one(inst).SPR_RO[657].SPR_REP[4502]())
     self.buf('(')
     first_filter = lambda sel: one(sel).V_PAR[816, 'succeeds']() is None
     self.accept(any(inst).V_PAR[679](first_filter))
     self.buf(')')
예제 #10
0
    def test_for_each_loop(self):
        '''
        create object instance of A;
        create object instance of A;       
        select many a_set from instances of A;
        for each a in a_set
        end for;
        '''
        act_for = self.metamodel.select_one('ACT_FOR')
        self.assertTrue(act_for.is_implicit)

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

        act_blk = one(act_for).ACT_BLK[605]()
        self.assertIsNotNone(act_blk)

        v_var = one(act_for).V_VAR[614]()
        self.assertEqual(v_var.Name, 'a')

        v_var = one(act_for).V_VAR[652]()
        self.assertEqual(v_var.Name, 'a_set')

        o_obj = one(act_for).O_OBJ[670]()
        self.assertEqual(o_obj.Key_Lett, 'A')
예제 #11
0
    def accept_V_PAR(self, inst):
        if one(inst).V_PAR[816, 'succeeds']() is not None:
            self.buf(', ')

        self.buf(inst.Name, ': ')
        self.accept(one(inst).V_VAL[800]())
        self.accept(one(inst).V_PAR[816, 'precedes']())
예제 #12
0
 def accept_V_FNV(self, inst):
     s_sync = one(inst).S_SYNC[827]()
     self.buf('::', s_sync.Name)
     self.buf('(')
     first_filter = lambda sel: one(sel).V_PAR[816, 'succeeds']() is None
     self.accept(any(inst).V_PAR[817](first_filter))
     self.buf(')')
예제 #13
0
 def accept_V_MSV(self, inst):
     self.accept(one(inst).SPR_PEP[841]())
     self.accept(one(inst).SPR_REP[845]())
     self.buf('(')
     first_filter = lambda sel: one(sel).V_PAR[816, 'succeeds']() is None
     self.accept(any(inst).V_PAR[842](first_filter))
     self.buf(')')
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
예제 #15
0
def mk_linked_association(m, inst):
    '''
    Create pyxtuml associations from a linked association in BridgePoint.
    '''
    r_rel = one(inst).R_REL[206]()
    r_rgo = one(inst).R_ASSR[211].R_RGO[205]()
    source_o_obj = one(r_rgo).R_OIR[203].O_OBJ[201]()
    
    def _mk_link(side1, side2):
        r_rto = one(side1).R_RTO[204]()

        target_o_obj = one(r_rto).R_OIR[203].O_OBJ[201]()
        cardinality = mult_cond(side2.Mult, side2.Cond)
        source_ids, target_ids = get_related_attributes(r_rgo, r_rto)
    
        source = xtuml.AssociationLink(source_o_obj.Key_Lett, cardinality,
                                       source_ids, side1.Txt_Phrs)
        target = xtuml.AssociationLink(target_o_obj.Key_Lett, '1', target_ids,
                                       side2.Txt_Phrs)

        if side1.Obj_ID != side2.Obj_ID:
            target.phrase = source.phrase = ''
        
        m.define_association(r_rel.Numb, source, target)
        
    r_aone = one(inst).R_AONE[209]()
    r_aoth = one(inst).R_AOTH[210]()
    
    if None in [r_rgo, r_aone, r_aoth]:
        logger.info('Omitting unformalized association R%s' % (r_rel.Numb))
        return
    
    _mk_link(r_aone, r_aoth)
    _mk_link(r_aoth, r_aone)
예제 #16
0
 def accept_ACT_FOR(self, inst):
     self.buf('for each ')
     self.accept(one(inst).V_VAR[614]())
     self.buf(' in ')
     self.accept(one(inst).V_VAR[652]())
     self.accept(one(inst).ACT_BLK[605]())
     self.buf('end for')
예제 #17
0
 def accept_V_MSV(self, inst):
     self.accept(one(inst).SPR_PEP[841]())
     self.accept(one(inst).SPR_REP[845]())
     self.buf('(')
     first_filter = lambda sel: one(sel).V_PAR[816, 'succeeds']() is None
     self.accept(any(inst).V_PAR[842](first_filter))
     self.buf(')')
예제 #18
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 check_link(side):
        r_rto = one(side).R_RTO[204]()
        target_o_obj = one(r_rto).R_OIR[203].O_OBJ[201]()

        if side.Mult:
            cardinality = 'many'
        else:
            cardinality = 'one'

        text = atleast_one_tmpl.substitute(From=target_o_obj.Key_Lett,
                                           To=source_o_obj.Key_Lett,
                                           Numb=r_rel.Numb,
                                           Cardinality=cardinality,
                                           Phrase=side.Txt_Phrs)
        if not side.Cond:
            if side.Mult:
                cardinality = 'one'
            else:
                cardinality = 'one'

            text += atleast_one_tmpl.substitute(From=source_o_obj.Key_Lett,
                                                To=target_o_obj.Key_Lett,
                                                Numb=r_rel.Numb,
                                                Cardinality=cardinality,
                                                Phrase=side.Txt_Phrs)
        return text
예제 #20
0
    def test_for_each_loop(self):
        '''
        create object instance of A;
        create object instance of A;       
        select many a_set from instances of A;
        for each a in a_set
        end for;
        '''
        act_for = self.metamodel.select_one('ACT_FOR')
        self.assertTrue(act_for.is_implicit)
        
        act_smt = one(act_for).ACT_SMT[603]()
        self.assertIsNotNone(act_smt)
        
        act_blk = one(act_for).ACT_BLK[605]()
        self.assertIsNotNone(act_blk)
        
        v_var = one(act_for).V_VAR[614]()
        self.assertEqual(v_var.Name, 'a')
        
        v_var = one(act_for).V_VAR[652]()
        self.assertEqual(v_var.Name, 'a_set')

        o_obj = one(act_for).O_OBJ[670]()
        self.assertEqual(o_obj.Key_Lett, 'A')
예제 #21
0
 def accept_V_FNV(self, inst):
     s_sync = one(inst).S_SYNC[827]()
     self.buf('::', s_sync.Name)
     self.buf('(')
     first_filter = lambda sel: one(sel).V_PAR[816, 'succeeds']() is None
     self.accept(any(inst).V_PAR[817](first_filter))
     self.buf(')')
예제 #22
0
 def accept_ACT_FIW(self, inst):
     o_obj = one(inst).O_OBJ[676]()
     self.buf('select ', inst.cardinality, ' ')
     self.accept(one(inst).V_VAR[665]())
     self.buf(' from instances of ', o_obj.Key_Lett)
     self.buf(' where ')
     self.accept(one(inst).V_VAL[610]())
예제 #23
0
 def accept_ACT_SGN(self, inst):
     self.accept(one(inst).SPR_PS[663].SPR_PEP[4503]())
     self.accept(one(inst).SPR_RS[660].SPR_REP[4502]())
     self.buf('(')
     first_filter = lambda sel: one(sel).V_PAR[816, 'succeeds']() is None
     self.accept(any(inst).V_PAR[662](first_filter))
     self.buf(')')
예제 #24
0
    def test_unrelate_using_with_phrase(self):
        '''
        create object instance a of A;
        create object instance b of B;
        create object instance c of C;
        relate a to b across R2.'some phrase' using c;
        unrelate b from a across R2.'some invalid phrase' using c;
        '''
        act_unr = self.metamodel.select_one('ACT_URU')
        self.assertEqual(act_unr.relationship_phrase, "'some invalid phrase'")
        
        act_smt = one(act_unr).ACT_SMT[603]()
        self.assertIsNotNone(act_smt)
        
        v_var = one(act_unr).V_VAR[622]()
        self.assertEqual(v_var.Name, 'b')
        
        v_var = one(act_unr).V_VAR[623]()
        self.assertEqual(v_var.Name, 'a')

        v_var = one(act_unr).V_VAR[624]()
        self.assertEqual(v_var.Name, 'c')
        
        r_rel = one(act_unr).R_REL[656]()
        self.assertEqual(r_rel.Numb, 2)
예제 #25
0
 def accept_ACT_SEL(self, inst):
     self.buf('select ', inst.cardinality, ' ')
     self.accept(one(inst).V_VAR[638]())
     self.buf(' related by ')
     self.accept(one(inst).V_VAL[613]())
     self.accept(one(inst).ACT_LNK[637]())
     self.accept(one(inst).ACT_SRW[664]())
예제 #26
0
 def parameters(self, function_name):
     s_sync = self.m.select_one('S_SYNC', where(Name=function_name))
     first_filt = lambda sel: not one(sel).S_SPARM[54, 'precedes']()
     s_sparm = one(s_sync).S_SPARM[24](first_filt)
     while s_sparm:
         yield s_sparm.Name
         s_sparm = one(s_sparm).S_SPARM[54, 'succeeds']()
예제 #27
0
 def accept_ACT_FOR(self, inst):
     self.buf('for each ')
     self.accept(one(inst).V_VAR[614]())
     self.buf(' in ')
     self.accept(one(inst).V_VAR[652]())
     self.accept(one(inst).ACT_BLK[605]())
     self.buf('end for')
예제 #28
0
 def accept_ACT_LNK(self, inst):
     o_obj = one(inst).O_OBJ[678]()
     r_rel = one(inst).R_REL[681]()
     self.buf('->', o_obj.Key_Lett, '[R', str(r_rel.Numb))
     if inst.Rel_Phrase:
         self.buf('.', inst.Rel_Phrase)
     self.buf(']')
     self.accept(one(inst).ACT_LNK[604, 'precedes']())
예제 #29
0
    def accept_E_CES(self, inst):
        self.buf('create event instance ')
        self.accept(one(inst).V_VAR[710]())

        self.buf(' of ')

        self.accept(one(inst).E_CSME[702].SM_EVT[706]())
        self.accept(one(inst).E_CEE[702].S_EEEVT[708]())
예제 #30
0
 def accept_V_BRV(self, inst):
     s_brg = one(inst).S_BRG[828]()
     s_ee = one(s_brg).S_EE[19]()
     self.buf('bridge ', s_ee.Key_Lett, '::', s_brg.Name)
     self.buf('(')
     first_filter = lambda sel: one(sel).V_PAR[816, 'succeeds']() is None
     self.accept(any(inst).V_PAR[810](first_filter))
     self.buf(')')
예제 #31
0
 def accept_V_BRV(self, inst):
     s_brg = one(inst).S_BRG[828]()
     s_ee = one(s_brg).S_EE[19]()
     self.buf('bridge ', s_ee.Key_Lett, '::', s_brg.Name)
     self.buf('(')
     first_filter = lambda sel: one(sel).V_PAR[816, 'succeeds']() is None
     self.accept(any(inst).V_PAR[810](first_filter))
     self.buf(')')
예제 #32
0
 def accept_E_CES(self, inst):
     self.buf('create event instance ')
     self.accept(one(inst).V_VAR[710]())
     
     self.buf(' of ')
     
     self.accept(one(inst).E_CSME[702].SM_EVT[706]())
     self.accept(one(inst).E_CEE[702].S_EEEVT[708]())
예제 #33
0
 def accept_ACT_LNK(self, inst):
     o_obj = one(inst).O_OBJ[678]()
     r_rel = one(inst).R_REL[681]()
     self.buf('->', o_obj.Key_Lett, '[R', str(r_rel.Numb))
     if inst.Rel_Phrase:
         self.buf('.', inst.Rel_Phrase)
     self.buf(']')
     self.accept(one(inst).ACT_LNK[604, 'precedes']())
예제 #34
0
def get_attribute_type(o_attr):
    '''
    Get the base data type (S_DT) associated with a BridgePoint attribute.
    '''
    ref_o_attr = one(o_attr).O_RATTR[106].O_BATTR[113].O_ATTR[106]()
    if ref_o_attr:
        return get_attribute_type(ref_o_attr)
    else:
        return one(o_attr).S_DT[114]()
예제 #35
0
    def accept_ACT_AI(self, inst):
        if one(inst).V_VAL[609].V_MSV[801]():
            self.buf('send ')
        else:
            self.buf('assign ')

        self.accept(one(inst).V_VAL[689]())
        self.buf(' = ')
        self.accept(one(inst).V_VAL[609]())
예제 #36
0
def get_attribute_type(o_attr):
    '''
    Get the base data type (S_DT) associated with a BridgePoint attribute.
    '''
    ref_o_attr = one(o_attr).O_RATTR[106].O_BATTR[113].O_ATTR[106]()
    if ref_o_attr:
        return get_attribute_type(ref_o_attr)
    else:
        return one(o_attr).S_DT[114]()
예제 #37
0
 def accept_ACT_AI(self, inst):
     if one(inst).V_VAL[609].V_MSV[801]():
         self.buf('send ')
     else:
         self.buf('assign ')
         
     self.accept(one(inst).V_VAL[689]())
     self.buf(' = ')
     self.accept(one(inst).V_VAL[609]())
예제 #38
0
    def test_chained_unary_op(self):
        '''return not (1 == 1);'''
        act_ret = self.metamodel.select_one('ACT_RET')
        self.assertIsNotNone(act_ret)

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

        v_val = one(act_ret).V_VAL[668]()
        self.assertEqual(v_val.isLValue, False)
        self.assertEqual(v_val.isImplicit, False)
        self.assertEqual(v_val.LineNumber, 1)
        self.assertEqual(v_val.StartPosition, 8)
        self.assertEqual(v_val.EndPosition, 19)

        s_dt = one(v_val).S_DT[820]()
        self.assertEqual(s_dt.Name, 'boolean')

        v_uny = one(v_val).V_UNY[801]()
        self.assertEqual(v_uny.Operator, 'not')

        v_val = one(v_uny).V_VAL[804]()
        s_dt = one(v_val).S_DT[820]()
        self.assertEqual(s_dt.Name, 'boolean')

        v_bin = one(v_val).V_BIN[801]()
        self.assertEqual(v_bin.Operator, '==')

        v_val = one(v_bin).V_VAL[802]()
        self.assertIsNotNone(v_val)

        v_val = one(v_bin).V_VAL[803]()
        self.assertIsNotNone(v_val)
예제 #39
0
 def test_chained_unary_op(self):
     '''return not (1 == 1);'''
     act_ret = self.metamodel.select_one('ACT_RET')
     self.assertIsNotNone(act_ret)
     
     act_smt = one(act_ret).ACT_SMT[603]()
     self.assertIsNotNone(act_smt)
     
     v_val = one(act_ret).V_VAL[668]()
     self.assertEqual(v_val.isLValue, False)
     self.assertEqual(v_val.isImplicit, False)
     self.assertEqual(v_val.LineNumber, 1)
     self.assertEqual(v_val.StartPosition, 8)
     self.assertEqual(v_val.EndPosition, 19)
     
     s_dt = one(v_val).S_DT[820]()
     self.assertEqual(s_dt.Name, 'boolean')
     
     v_uny = one(v_val).V_UNY[801]()
     self.assertEqual(v_uny.Operator, 'not')
     
     v_val = one(v_uny).V_VAL[804]()
     s_dt = one(v_val).S_DT[820]()
     self.assertEqual(s_dt.Name, 'boolean')
     
     v_bin = one(v_val).V_BIN[801]()
     self.assertEqual(v_bin.Operator, '==')
     
     v_val = one(v_bin).V_VAL[802]()
     self.assertIsNotNone(v_val)
     
     v_val = one(v_bin).V_VAL[803]()
     self.assertIsNotNone(v_val)
예제 #40
0
    def accept_ACT_REL(self, inst):
        self.buf('relate ')
        self.accept(one(inst).V_VAR[615]())

        self.buf(' to ')
        self.accept(one(inst).V_VAR[616]())

        r_rel = one(inst).R_REL[653]()
        self.buf(' across R', str(r_rel.Numb))
        if inst.relationship_phrase:
            self.buf('.', inst.relationship_phrase)
예제 #41
0
    def accept_ACT_UNR(self, inst):
        self.buf('unrelate ')
        self.accept(one(inst).V_VAR[620]())

        self.buf(' from ')
        self.accept(one(inst).V_VAR[621]())

        r_rel = one(inst).R_REL[655]()
        self.buf(' across R', str(r_rel.Numb))
        if inst.relationship_phrase:
            self.buf('.', inst.relationship_phrase)
예제 #42
0
def get_attribute_type(o_attr):
    '''
    Get the pyxtuml meta model type associated with a BridgePoint class
    attribute.
    '''
    ref_o_attr = one(o_attr).O_RATTR[106].O_BATTR[113].O_ATTR[106]()
    if ref_o_attr:
        return get_attribute_type(ref_o_attr)
    else:
        s_dt = one(o_attr).S_DT[114]()
        return get_data_type_name(s_dt)
예제 #43
0
def get_attribute_type(o_attr):
    '''
    Get the pyxtuml meta model type associated with a BridgePoint class
    attribute.
    '''
    ref_o_attr = one(o_attr).O_RATTR[106].O_BATTR[113].O_ATTR[106]()
    if ref_o_attr:
        return get_attribute_type(ref_o_attr)
    else:
        s_dt = one(o_attr).S_DT[114]()
        return get_data_type_name(s_dt)
예제 #44
0
    def test_create_object_no_variable(self):
        '''
        create object instance of A;
        '''
        act_cnv = self.metamodel.select_one('ACT_CNV')

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

        o_obj = one(act_cnv).O_OBJ[672]()
        self.assertEqual(o_obj.Key_Lett, 'A')
예제 #45
0
 def accept_ACT_UNR(self, inst):
     self.buf('unrelate ')
     self.accept(one(inst).V_VAR[620]())
     
     self.buf(' from ')
     self.accept(one(inst).V_VAR[621]())
     
     r_rel = one(inst).R_REL[655]()
     self.buf(' across R', str(r_rel.Numb))
     if inst.relationship_phrase:
         self.buf('.', inst.relationship_phrase)
예제 #46
0
 def accept_ACT_REL(self, inst):
     self.buf('relate ')
     self.accept(one(inst).V_VAR[615]())
     
     self.buf(' to ')
     self.accept(one(inst).V_VAR[616]())
     
     r_rel = one(inst).R_REL[653]()
     self.buf(' across R', str(r_rel.Numb))
     if inst.relationship_phrase:
         self.buf('.', inst.relationship_phrase)
예제 #47
0
def mk_derived_attribute(metaclass, o_dbattr):
    '''
    Create a python property that interprets that action of a BridgePoint derived
    attribute.
    '''
    o_attr = one(o_dbattr).O_BATTR[107].O_ATTR[106]()
    o_obj = one(o_attr).O_OBJ[102]()
    action = o_dbattr.Action_Semantics_internal
    label = '%s::%s' % (o_obj.Name, o_attr.Name)
    fget = functools.partial(interpret.run_derived_attribute, metaclass, 
                             label, action, o_attr.Name)
    return property(fget)
예제 #48
0
    def test_delete_object(self):
        '''
        create object instance inst of A;
        delete object instance inst;
        '''
        act_del = self.metamodel.select_one('ACT_DEL')

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

        v_var = one(act_del).V_VAR[634]()
        self.assertEqual(v_var.Name, 'inst')
예제 #49
0
def mk_derived_attribute(metaclass, o_dbattr):
    '''
    Create a python property that interprets that action of a BridgePoint derived
    attribute.
    '''
    o_attr = one(o_dbattr).O_BATTR[107].O_ATTR[106]()
    o_obj = one(o_attr).O_OBJ[102]()
    action = o_dbattr.Action_Semantics_internal
    label = '%s::%s' % (o_obj.Name, o_attr.Name)
    fget = functools.partial(interpret.run_derived_attribute, metaclass, label,
                             action, o_attr.Name)
    return property(fget)
예제 #50
0
    def test_relate_assoc_to_two_classes(self):
        cls1 = self.m.new('Class')
        cls2 = self.m.new('Class')
        assoc = self.m.new('Assoc')

        self.assertTrue(relate(assoc, cls1, 1, 'one'))
        self.assertTrue(relate(assoc, cls2, 1, 'other'))

        self.assertTrue(one(cls1).Class[1, 'other']())
        self.assertFalse(one(cls2).Class[1, 'other']())

        self.assertFalse(one(cls1).Class[1, 'one']())
        self.assertTrue(one(cls2).Class[1, 'one']())
예제 #51
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')
예제 #52
0
 def accept_ACT_RU(self, inst):
     self.buf('relate ')
     self.accept(one(inst).V_VAR[617]())
     
     self.buf(' to ')
     self.accept(one(inst).V_VAR[618]())
     
     r_rel = one(inst).R_REL[654]()
     self.buf(' across R', str(r_rel.Numb))
     if inst.relationship_phrase:
         self.buf('.', inst.relationship_phrase)
         
     self.buf(' using ')
     self.accept(one(inst).V_VAR[619]())
예제 #53
0
 def accept_ACT_URU(self, inst):
     self.buf('unrelate ')
     self.accept(one(inst).V_VAR[622]())
     
     self.buf(' from ')
     self.accept(one(inst).V_VAR[623]())
     
     r_rel = one(inst).R_REL[656]()
     self.buf(' across R', str(r_rel.Numb))
     if inst.relationship_phrase:
         self.buf('.', inst.relationship_phrase)
         
     self.buf(' using ')
     self.accept(one(inst).V_VAR[624]())
예제 #54
0
def get_data_type_name(s_dt):
    '''
    Convert a BridgePoint data type to a pyxtuml meta model type.
    '''
    s_cdt = one(s_dt).S_CDT[17]()
    if s_cdt and s_cdt.core_typ in range(1, 6):
        return s_dt.name
    
    if one(s_dt).S_EDT[17]():
        return 'INTEGER'
    
    s_dt = one(s_dt).S_UDT[17].S_DT[18]()
    if s_dt:
        return get_data_type_name(s_dt)
예제 #55
0
    def accept_ACT_RU(self, inst):
        self.buf('relate ')
        self.accept(one(inst).V_VAR[617]())

        self.buf(' to ')
        self.accept(one(inst).V_VAR[618]())

        r_rel = one(inst).R_REL[654]()
        self.buf(' across R', str(r_rel.Numb))
        if inst.relationship_phrase:
            self.buf('.', inst.relationship_phrase)

        self.buf(' using ')
        self.accept(one(inst).V_VAR[619]())
예제 #56
0
    def accept_ACT_URU(self, inst):
        self.buf('unrelate ')
        self.accept(one(inst).V_VAR[622]())

        self.buf(' from ')
        self.accept(one(inst).V_VAR[623]())

        r_rel = one(inst).R_REL[656]()
        self.buf(' across R', str(r_rel.Numb))
        if inst.relationship_phrase:
            self.buf('.', inst.relationship_phrase)

        self.buf(' using ')
        self.accept(one(inst).V_VAR[624]())
예제 #57
0
def get_data_type_name(s_dt):
    '''
    Convert a BridgePoint data type to a pyxtuml meta model type.
    '''
    s_cdt = one(s_dt).S_CDT[17]()
    if s_cdt and s_cdt.Core_Typ in range(1, 6):
        return s_dt.Name

    if one(s_dt).S_EDT[17]():
        return 'INTEGER'

    s_dt = one(s_dt).S_UDT[17].S_DT[18]()
    if s_dt:
        return get_data_type_name(s_dt)
예제 #58
0
def is_global(pe_pe):
    '''
    Check if a PE_PE is globally defined, i.e. not inside a C_C
    '''
    if pe_pe.__class__.__name__ != 'PE_PE':
        pe_pe = one(pe_pe).PE_PE[8001]()
    
    if one(pe_pe).C_C[8003]():
        return False
    
    pe_pe = one(pe_pe).EP_PKG[8000].PE_PE[8001]()
    if not pe_pe:
        return True
    
    return is_global(pe_pe)
예제 #59
0
    def _mk_link(side1, side2):
        r_rto = one(side1).R_RTO[204]()

        target_o_obj = one(r_rto).R_OIR[203].O_OBJ[201]()
        cardinality = mult_cond(side2.Mult, side2.Cond)
        source_ids, target_ids = get_related_attributes(r_rgo, r_rto)
    
        source = xtuml.AssociationLink(source_o_obj.Key_Lett, cardinality,
                                       source_ids, side1.Txt_Phrs)
        target = xtuml.AssociationLink(target_o_obj.Key_Lett, '1', target_ids,
                                       side2.Txt_Phrs)

        if side1.Obj_ID != side2.Obj_ID:
            target.phrase = source.phrase = ''
        
        m.define_association(r_rel.Numb, source, target)
예제 #60
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