######################################### # Structural Comparision # ######################################### #----------------------------------------- # Parameter setup #----------------------------------------- SETL strtkn_element:"Task,Exclusive Gateway,Non-exclusive Gateway,X" SETL aqltkn_statements:"(<\"Task\">)@(<\"Exclusive Gateway\">)@(<\"Non-exclusive Gateway\">)" SETL int_cnt_elements:(tokcnt((strtkn_element),",")) SETL str_modeltype-1:"Business process diagram (BPMN 2.0)" SETL str_modeltype_name:"Comparison Model" #----------------------------------------- # Source Model and Target Model selection #----------------------------------------- SETL int_cnt_models:0 # in order to compare models, at least two models need to be selected. # WHILE loop is used in form of "do-repeat", hence int_cnt_models is first = 0 # this guarantees at least one run. WHILE (int_cnt_models < 2) { CC "CoreUI" MODEL_SELECT_BOX boxtext:"Models to Compare:" title:"Select source models to compare:" modeltype1:(str_modeltype-1) modeltype2:"Business process diagram (BPMN 2.0)" multi-sel #SETL endbutton2:(endbutton) IF ((endbutton) = "cancel") { EXIT } SETL idtkn_source_models:(modelids) SETL int_cnt_models:(tokcnt(idtkn_source_models," ")) IF (int_cnt_models <2) { CC "AdoScript" WARNINGBOX ("At least two models must be selected.") } } # Taget Modelgroup CC "CoreUI" MODEL_SELECT_BOX boxtext:"Target Model Group:" title:"Select where to place the target model:" without-models mgroup-sel SETL id_modelgroup_target:(mgroupids) SETL endbutton1:(endbutton) IF (endbutton1 = "cancel") { EXIT } SETL str_exist_model:0 WHILE (str_exist_model=0) { CC "Application" GET_DATE_TIME date-format:"YYYY/MM/DD" CC "AdoScript" EDITFIELD title:"Name your model" caption:"Insert a name for your model:" text:(date + " Comparison table") IF (ecode=1) { EXIT } SETL str_target_modelname:(text) CC "Core" GET_MODEL_ID modelname:(str_target_modelname) modeltype:(str_modeltype_name) IF (ecode=0) { CC "AdoScript" WARNINGBOX ("There is already a model called: " + mstr (str_target_modelname) + ". ") } SETL str_exist_model:(ecode) } #The model is created CC "Core" CREATE_MODEL modeltype:(str_modeltype_name) modelname:(str_target_modelname) version:"" mgroups:(id_modelgroup_target) SETL id_targetmodel:(modelid) #----------------------------------------- # Create Boxes in Target Model #----------------------------------------- # Create Target Model SETL idtkn_loadedModels:"" CC "Core" GET_CLASS_ID classname:"Box" SETL id_class_Box:(classid) IF (ecode != 0) { CC "AdoScript" ERRORBOX ("The library does not contain a class called \"Box\"\n") EXIT } CC "Core" GET_CLASS_ID classname:"Row Name" SETL id_class_RowName:(classid) IF (ecode != 0) { CC "AdoScript" ERRORBOX ("The library does not contain a class called \"Row Name\"\n") EXIT } # OPEN all Models that have been selected FOR currentModelId in:(idtkn_source_models) { CC "Core" IS_MODEL_LOADED modelid:(VAL currentModelId) IF(isloaded = 0) { CC "Core" LOAD_MODEL modelid:(VAL currentModelId) read-access SETL idtkn_loadedModels:(tokunion(idtkn_loadedModels,currentModelId)) } CC "Core" LOAD_MODEL modelid:(VAL currentModelId) read-access } # Setup matrix SETL int_row_distance:2.5 # rows SETL int_col_distance:3.5 # columns SETL int_x_offset:4 # Horizontal displacemente of the table SETL int_y_offset:2 # Vertical displacemente of the table SETL int_head_offset:2.50 SETL int_rowName_offset:1 SETL xobj:(int_x_offset + int_head_offset) SETL yobj:(int_y_offset) # HEADER is created implemneting an HYPERLINK to the source models FOR int_colum from:1 to:(int_cnt_models) { # Get Source model CC "Core" debug CREATE_OBJ modelid:(id_targetmodel) classid:(id_class_RowName) objname:((STR xobj)+"_"+(STR yobj)+"_rowName") CC "Core" GET_ATTR_ID classid:(id_class_RowName) attrname:"Row name" # make INTERREF CC "Core" GET_MODEL_BASENAME modelid:(VAL (token(modelids, (int_colum-1), " "))) CC "Core" SET_ATTR_VAL objid:(objid) attrid:(attrid) val:(basename) CC "Core" GET_ATTR_ID classid:(id_class_RowName) attrname:"Referenced model" CC "Core" ADD_INTERREF objid:(objid) attrid:(attrid) tmodelid:(VAL (token(modelids, (int_colum-1), " "))) # Position SETL int_x_coord: ("NODE x:" + (STR xobj) + "cm") SETL int_x_coord: (tokcat (int_x_coord, ("y:" + (STR yobj) + "cm"))) CC "Core" GET_ATTR_ID classid:(id_class_RowName) attrname:"Position" CC "Core" SET_ATTR_VAL objid:(objid) attrid:(attrid) val:(int_x_coord) # offset for next element SETL xobj:(xobj + int_col_distance) } SETL xobj:(int_x_offset) SETL yobj:(yobj + 1.5) # MATRIX is created implementing Quantity as structural comparison FOR int_rows from:1 to:(int_cnt_elements) { # x coordinates SETL int_x_coord: ("NODE x:" + (STR xobj) + "cm") SETL int_x_coord: (tokcat (int_x_coord, ("y:" + (STR yobj) + "cm"))) # Row Names are created CC "Core" CREATE_OBJ modelid:(id_targetmodel) classid:(id_class_RowName) objname:((STR xobj)+"_"+(STR yobj)+"_rowName") CC "Core" GET_ATTR_ID classid:(id_class_RowName) attrname:"Row name" CC "Core" SET_ATTR_VAL objid:(objid) attrid:(attrid) val:(token(strtkn_element, (int_rows-1), ",")) # Position CC "Core" GET_ATTR_ID classid:(id_class_RowName) attrname:"Position" CC "Core" SET_ATTR_VAL objid:(objid) attrid:(attrid) val:(int_x_coord) SETL xobj:(xobj + int_rowName_offset) FOR int_colum from:1 to:(int_cnt_models) { # BOXes are created on x CC "Core" CREATE_OBJ modelid:(id_targetmodel) classid:(id_class_Box) objname:((STR xobj)+"_"+(STR yobj)+"_box") # Invoke AQL with Source Model SETL aql_expr: (token(aqltkn_statements,(int_rows-1),"@") ) CC "AQL" EVAL_AQL_EXPRESSION expr:(aql_expr) modelid:(VAL (token(modelids, (int_colum-1), " "))) # BOXes are filled CC "Core" GET_ATTR_ID classid:(id_class_Box) attrname:"Quantity" CC "Core" SET_ATTR_VAL objid:(objid) attrid:(attrid) val:(tokcnt(objids," ")) # next colum SETL int_x_coord: ("NODE x:" + (STR xobj) + "cm") SETL int_x_coord: (tokcat (int_x_coord, ("y:" + (STR yobj) + "cm"))) # Position CC "Core" GET_ATTR_ID classid:(id_class_Box) attrname:"Position" CC "Core" SET_ATTR_VAL objid:(objid) attrid:(attrid) val:(int_x_coord) # next offset SETL xobj:(xobj + int_col_distance) } # next row SETL xobj:(int_x_offset) SETL yobj:(yobj + int_row_distance) } #The model is safed and open CC "Core" SAVE_MODEL modelid:(id_targetmodel) CC "Modeling" OPEN modelids:(STR id_targetmodel)