def accept_UnrelateUsingNode(self, node): from_inst = self.symtab.find_symbol(node.from_variable_name) to_inst = self.symtab.find_symbol(node.to_variable_name) using_inst = self.symtab.find_symbol(node.using_variable_name) xtuml.unrelate(from_inst, using_inst, node.rel_id, node.phrase) xtuml.unrelate(using_inst, to_inst, node.rel_id, node.phrase)
def accept_UnrelateUsingNode(self, node): from_inst = self.symtab.find_symbol(node.from_variable_name) to_inst = self.symtab.find_symbol(node.to_variable_name) using_inst = self.symtab.find_symbol(node.using_variable_name) xtuml.unrelate(from_inst, using_inst, node.rel_id, node.phrase) xtuml.unrelate(using_inst, to_inst, node.rel_id, node.phrase)
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')
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')
def test_select_where_after_relate(self): s_edt = self.m.new('S_EDT') s_dt = self.m.new('S_DT') pe_pe = self.m.new('PE_PE') self.assertFalse(self.m.select_any('S_DT', xtuml.where_eq(DT_ID=pe_pe.Element_ID))) self.assertTrue(xtuml.relate(s_dt, pe_pe, 8001)) self.assertTrue(xtuml.relate(s_dt, s_edt, 17)) self.assertTrue(self.m.select_any('S_DT', xtuml.where_eq(DT_ID=pe_pe.Element_ID))) self.assertTrue(xtuml.unrelate(s_dt, pe_pe, 8001)) self.assertTrue(xtuml.unrelate(s_dt, s_edt, 17)) self.assertFalse(self.m.select_any('S_DT', xtuml.where_eq(DT_ID=pe_pe.Element_ID)))
def test_select_where_after_relate(self): s_edt = self.m.new('S_EDT') s_dt = self.m.new('S_DT') pe_pe = self.m.new('PE_PE') self.assertFalse( self.m.select_any('S_DT', xtuml.where_eq(DT_ID=pe_pe.Element_ID))) self.assertTrue(xtuml.relate(s_dt, pe_pe, 8001)) self.assertTrue(xtuml.relate(s_dt, s_edt, 17)) self.assertTrue( self.m.select_any('S_DT', xtuml.where_eq(DT_ID=pe_pe.Element_ID))) self.assertTrue(xtuml.unrelate(s_dt, pe_pe, 8001)) self.assertTrue(xtuml.unrelate(s_dt, s_edt, 17)) self.assertFalse( self.m.select_any('S_DT', xtuml.where_eq(DT_ID=pe_pe.Element_ID)))
def testUnrelate(self): inst1 = self.metamodel.new('ACT_SMT') inst2 = self.metamodel.new('ACT_SMT') act_blk = self.metamodel.new('ACT_BLK') self.assertTrue(xtuml.relate(inst1, act_blk, 602)) self.assertTrue(xtuml.relate(inst2, act_blk, 602)) self.assertTrue(xtuml.relate(inst1, inst2, 661, 'precedes')) self.assertEqual(inst2, xtuml.navigate_one(inst1).ACT_SMT[661, 'succeeds']()) self.assertEqual(inst1, xtuml.navigate_one(inst2).ACT_SMT[661, 'precedes']()) self.assertTrue(xtuml.unrelate(inst1, inst2, 661, 'precedes')) self.assertIsNone(xtuml.navigate_one(inst2).ACT_SMT[661, 'precedes']()) self.assertIsNone(xtuml.navigate_one(inst1).ACT_SMT[661, 'succeeds']())
def test_unrelate(self): inst1 = self.m.new('ACT_SMT') inst2 = self.m.new('ACT_SMT') act_blk = self.m.new('ACT_BLK') self.assertTrue(xtuml.relate(inst1, act_blk, 602)) self.assertTrue(xtuml.relate(inst2, act_blk, 602)) self.assertTrue(xtuml.relate(inst1, inst2, 661, 'succeeds')) self.assertEqual(inst2, xtuml.navigate_one(inst1).ACT_SMT[661, 'succeeds']()) self.assertEqual(inst1, xtuml.navigate_one(inst2).ACT_SMT[661, 'precedes']()) self.assertTrue(xtuml.unrelate(inst1, inst2, 661, 'succeeds')) self.assertIsNone(xtuml.navigate_one(inst2).ACT_SMT[661, 'precedes']()) self.assertIsNone(xtuml.navigate_one(inst1).ACT_SMT[661, 'succeeds']())
def test_unrelate_none(self): inst = self.m.new('ACT_SMT') self.assertFalse(xtuml.unrelate(None, inst, 602)) self.assertFalse(xtuml.unrelate(inst, None, 602))
def test_unrelate_subtype(self): inst1 = self.m.new('PE_PE') inst2 = self.m.new('EP_PKG') self.assertTrue(xtuml.relate(inst1, inst2, 8001)) self.assertTrue(xtuml.unrelate(inst1, inst2, 8001))
def test_unrelate_none(self): inst = self.m.new('ACT_SMT') self.assertFalse(xtuml.unrelate(None, inst, 602)) self.assertFalse(xtuml.unrelate(inst, None, 602))
def test_unrelate_subtype(self): inst1 = self.m.new('PE_PE') inst2 = self.m.new('EP_PKG') self.assertTrue(xtuml.relate(inst1, inst2, 8001)) self.assertTrue(xtuml.unrelate(inst1, inst2, 8001))
def main(): parser = optparse.OptionParser(usage="%prog [options] <model_path> [another_model_path...]", formatter=optparse.TitledHelpFormatter()) parser.set_description(__doc__.strip()) parser.add_option("-o", "--output", dest='output', metavar="PATH", help="save sql model instances to PATH", action="store", default='/dev/stdout') parser.add_option("-v", "--verbosity", dest='verbosity', action="count", help="increase debug logging level", default=2) (opts, args) = parser.parse_args() if len(args) == 0 or None in [opts.output]: parser.print_help() sys.exit(1) levels = { 0: logging.ERROR, 1: logging.WARNING, 2: logging.INFO, 3: logging.DEBUG, } logging.basicConfig(level=levels.get(opts.verbosity, logging.DEBUG)) m1 = bridgepoint.load_metamodel(args, load_globals=True) m2 = ooaofooa.empty_model() dt_boolean = m2.select_any('S_DT', where(Name='boolean')) dt_integer = m2.select_any('S_DT', where(Name='integer')) dt_real = m2.select_any('S_DT', where(Name='real')) dt_string = m2.select_any('S_DT', where(Name='string')) dt_unique_id = m2.select_any('S_DT', where(Name='unique_id')) dt_void = m2.select_any('S_DT', where(Name='void')) pe_pe = m2.new('PE_PE', Visibility=True, type=7) ep_pkg = m2.new('EP_PKG', Name='SQL_Instance_Stream_Provider') relate(pe_pe, ep_pkg, 8001) s_sync = mk_function(ep_pkg, Name='SQL_Instance_Stream_Connect', Action_Semantics_internal=gen_connect(m1)) mk_parameters(s_sync, from_id=dt_unique_id, from_key_letter=dt_string, to_id=dt_unique_id, to_key_letter=dt_string, rel_id=dt_string) s_sync = mk_function(ep_pkg, Name='SQL_Instance_Stream_Connect_Using', Action_Semantics_internal=gen_connect_using(m1)) mk_parameters(s_sync, from_id=dt_unique_id, from_key_letter=dt_string, to_id=dt_unique_id, to_key_letter=dt_string, using_id=dt_unique_id, rel_id=dt_string) s_sync = mk_function(ep_pkg, Name='SQL_Instance_Stream_New', Action_Semantics_internal=gen_new(m1)) mk_parameters(s_sync, key_letter=dt_string) unrelate(s_sync, dt_void, 25) relate(s_sync, dt_unique_id, 25) s_sync = mk_function(ep_pkg, Name='SQL_Instance_Stream_Set_Boolean', Action_Semantics_internal=gen_set_boolean(m1)) mk_parameters(s_sync, key_letter=dt_string, instance_id=dt_unique_id, name=dt_string, value=dt_boolean) s_sync = mk_function(ep_pkg, Name='SQL_Instance_Stream_Set_Integer', Action_Semantics_internal=gen_set_integer(m1)) mk_parameters(s_sync, key_letter=dt_string, instance_id=dt_unique_id, name=dt_string, value=dt_integer) s_sync = mk_function(ep_pkg, Name='SQL_Instance_Stream_Set_Real', Action_Semantics_internal=gen_set_real(m1)) mk_parameters(s_sync, key_letter=dt_string, instance_id=dt_unique_id, name=dt_string, value=dt_real) s_sync = mk_function(ep_pkg, Name='SQL_Instance_Stream_Set_String', Action_Semantics_internal=gen_set_string(m1)) mk_parameters(s_sync, key_letter=dt_string, instance_id=dt_unique_id, name=dt_string, value=dt_string) s_sync = mk_function(ep_pkg, Name='SQL_Instance_Stream_Set_Unique_Id', Action_Semantics_internal=gen_set_unique_id(m1)) mk_parameters(s_sync, key_letter=dt_string, instance_id=dt_unique_id, name=dt_string, value=dt_unique_id) ooaofooa.delete_globals(m2) with open(opts.output, 'w') as f: f.write('-- root-types-contained: Package_c\n') f.write('-- generics\n') f.write('-- BP 7.1 content: StreamData syschar: 3 persistence-version: 7.1.6\n') f.write(xtuml.serialize_instances(m2))
def accept_UnrelateNode(self, node): inst1 = self.symtab.find_symbol(node.from_variable_name) inst2 = self.symtab.find_symbol(node.to_variable_name) xtuml.unrelate(inst1, inst2, node.rel_id, node.phrase.replace("'", ''))
def accept_UnrelateNode(self, node): inst1 = self.symtab.find_symbol(node.from_variable_name) inst2 = self.symtab.find_symbol(node.to_variable_name) xtuml.unrelate(inst1, inst2, node.rel_id, node.phrase.replace("'", ''))