# # OMB Scripting Example # # Purpose: # To illustrate the basic mechanics of the OMB scripting grammar to create an expert. The # expert is a short number of steps to request to load an object (file, table etc.) into somewhere else. # When the expert is run the user is prompted for; # 1. the location of the source # 2. the object to be moved (let's call it ) # 3. the location of the target (an object named T_ will be created # After this information is collected the new target is created and the mapping to load it. # # Save the current project and we will change back later. set prj $OMB_CURRENT_PROJECT # Change current context to the public project, this is where we will create the expert OMBCC '/PUBLIC_PROJECT' # Drop and create the expert module, a folder for the expert. catch { OMBDROP EXPERT_MODULE 'INTEGRATION' } OMBCREATE EXPERT_MODULE 'INTEGRATION' OMBCC 'INTEGRATION' # Create the expert defining its name and some runtime properties along with variables OMBCREATE EXPERT 'DATA_MOVER' SET PROPERTIES \ (BUSINESS_NAME, SHOW_PROGRESS_GRAPH, SHOW_TASK_ASSISTANT, MENU_ITEM_DISPLAY_STRING) \ VALUES ('Data Mover', 'false', 'false', 'Data Mover') \ ADD VARIABLE 'G_FROM_GROUP' \ ADD VARIABLE 'G_IMPORT_RESULT' \ ADD VARIABLE 'G_MAP_NAME' \ ADD VARIABLE 'G_SRC_LOC' \ ADD VARIABLE 'G_SRC_MODULE' \ ADD VARIABLE 'G_SRC_MODULE_TYPE' \ ADD VARIABLE 'G_SRC_OBJ_NAME' \ ADD VARIABLE 'G_SRC_OBJ_PATH' \ ADD VARIABLE 'G_SRC_OBJ_TYPE' \ ADD VARIABLE 'G_TGT_LOC' \ ADD VARIABLE 'G_TGT_MODULE' \ ADD VARIABLE 'G_TGT_MODULE_TYPE' \ ADD VARIABLE 'G_TGT_OBJ_NAME' \ ADD VARIABLE 'G_TGT_OBJ_TYPE' # Add tasks to the expert. These tasks apart from OMB are already defined by OWB, so # we are essentially just chaining them together to build a useful flow. OMBALTER EXPERT 'DATA_MOVER' \ ADD SELECT_SOURCE TASK 'SELECT_SOURCE_TASK' \ ADD SOURCE_IMPORT TASK 'SOURCE_IMPORT_TASK' \ ADD SELECT_TARGET TASK 'SELECT_TARGET_TASK' \ ADD OMB TASK 'OMB_TASK' # Define the transition conditions between the tasks. If users select CANCEL then we must handle # this with the path to END_TASK. OMBALTER EXPERT 'DATA_MOVER' \ ADD TRANSITION 'T1' FROM TASK 'START_TASK' TO 'SELECT_SOURCE_TASK' \ ADD TRANSITION 'T2' FROM TASK 'SELECT_SOURCE_TASK' TO 'SOURCE_IMPORT_TASK' SET PROPERTIES (TRANSITION_CONDITION) VALUES ('SUCCESS') \ ADD TRANSITION 'T3' FROM TASK 'SOURCE_IMPORT_TASK' TO 'SELECT_TARGET_TASK' SET PROPERTIES (TRANSITION_CONDITION) VALUES ('SUCCESS') \ ADD TRANSITION 'T4' FROM TASK 'SELECT_TARGET_TASK' TO 'OMB_TASK' SET PROPERTIES (TRANSITION_CONDITION) VALUES ('SUCCESS') \ ADD TRANSITION 'T5' FROM TASK 'OMB_TASK' TO 'END_TASK' \ ADD TRANSITION 'T2_CANCEL' FROM TASK 'SELECT_SOURCE_TASK' TO 'END_TASK' SET PROPERTIES (TRANSITION_CONDITION) VALUES ('CANCEL') \ ADD TRANSITION 'T3_CANCEL' FROM TASK 'SOURCE_IMPORT_TASK' TO 'END_TASK' SET PROPERTIES (TRANSITION_CONDITION) VALUES ('CANCEL') \ ADD TRANSITION 'T4_CANCEL' FROM TASK 'SELECT_TARGET_TASK' TO 'END_TASK' SET PROPERTIES (TRANSITION_CONDITION) VALUES ('CANCEL') # Define the tasks' parameters and how they bind to the variables OMBALTER EXPERT 'DATA_MOVER' \ MODIFY PARAMETER 'OBJECT_TYPE' OF TASK 'SELECT_SOURCE_TASK' BIND TO VARIABLE 'G_SRC_OBJ_TYPE' \ MODIFY PARAMETER 'MODULE_NAME' OF TASK 'SELECT_SOURCE_TASK' BIND TO VARIABLE 'G_SRC_MODULE' \ MODIFY PARAMETER 'LOCATION_NAME' OF TASK 'SELECT_SOURCE_TASK' BIND TO VARIABLE 'G_SRC_LOC' \ MODIFY PARAMETER 'SOURCE_TYPE' OF TASK 'SELECT_SOURCE_TASK' BIND TO VARIABLE 'G_SRC_MODULE_TYPE' \ MODIFY PARAMETER 'PARENT_CONTEXT' OF TASK 'SELECT_SOURCE_TASK' BIND TO VARIABLE 'OMB_CURRENT_PROJECT' OMBALTER EXPERT 'DATA_MOVER' \ MODIFY PARAMETER 'OBJECT_TYPE' OF TASK 'SOURCE_IMPORT_TASK' BIND TO VARIABLE 'G_SRC_OBJ_TYPE' \ MODIFY PARAMETER 'RETURN_VALUE' OF TASK 'SOURCE_IMPORT_TASK' BIND TO VARIABLE 'G_IMPORT_RESULT' \ MODIFY PARAMETER 'IMPORT_MODE' OF TASK 'SOURCE_IMPORT_TASK' SET PROPERTIES (VALUE) VALUES ('MINIMAL_MODE') \ MODIFY PARAMETER 'PARENT_CONTEXT' OF TASK 'SOURCE_IMPORT_TASK' BIND TO VARIABLE 'G_SRC_MODULE' OMBALTER EXPERT 'DATA_MOVER' \ MODIFY PARAMETER 'OBJECT_TYPE' OF TASK 'SELECT_TARGET_TASK' BIND TO VARIABLE 'G_TGT_OBJ_TYPE' \ MODIFY PARAMETER 'MODULE_NAME' OF TASK 'SELECT_TARGET_TASK' BIND TO VARIABLE 'G_TGT_MODULE' \ MODIFY PARAMETER 'LOCATION_NAME' OF TASK 'SELECT_TARGET_TASK' BIND TO VARIABLE 'G_TGT_LOC' \ MODIFY PARAMETER 'SOURCE_TYPE' OF TASK 'SELECT_TARGET_TASK' BIND TO VARIABLE 'G_TGT_MODULE_TYPE' \ MODIFY PARAMETER 'PARENT_CONTEXT' OF TASK 'SELECT_TARGET_TASK' BIND TO VARIABLE 'OMB_CURRENT_PROJECT' # Define some post processing code for the SOURCE_IMPORT_TASK to setup the source object path. # OMBALTER EXPERT 'DATA_MOVER' \ MODIFY TASK 'SOURCE_IMPORT_TASK' SET PROPERTIES (POSTPROCESSING) VALUES ('global G_IMPORT_RESULT \n\ global G_SRC_OBJ_PATH \n\ # \n\ # The OMUIMPORT result is processed and the filename extracted into G_SRC_OBJ_PATH \n\ # \n\ set ii \[string first \" \" \$G_IMPORT_RESULT\] \n\ set ll \[string length \$G_IMPORT_RESULT\] \n\ incr ii \n\ set G_SRC_OBJ_PATH \[string range \$G_IMPORT_RESULT \$ii \$ll\] \n\ set ll \[string length \$G_SRC_OBJ_PATH\] \n\ incr ll -2 \n\ set G_SRC_OBJ_PATH \[string range \$G_SRC_OBJ_PATH 0 \$ll\]') # # The meat of the expert, create the mapping, create the target table operator, copy attributes # from the source group to the target group. Then do an # outbound reconcile to create the object type from the mapping definition. # OMBALTER EXPERT 'DATA_MOVER' \ MODIFY TASK 'OMB_TASK' SET PROPERTIES (MAIN) VALUES (' set i \[string last "/" \$G_SRC_OBJ_PATH\] \n\ set g_src_obj_name \[string range \$G_SRC_OBJ_PATH \[expr \$i+1\] end\] \n\ set g_tgt_obj_name T_ \n\ append g_tgt_obj_name \$g_src_obj_name \n\ set g_map_name OWBEXP_MAP \n\ if \{ \$G_SRC_OBJ_TYPE == \"FLAT_FILE\" \} \{ \n\ set g_from_group \$g_src_obj_name \n\ \} else \{ \n\ set g_from_group INOUTGRP1 \n\ \} \n\ OMBCC ''\$OMB_CURRENT_PROJECT/\$G_TGT_MODULE'' \n\ catch \{ OMBDROP \$G_TGT_OBJ_TYPE ''\$g_tgt_obj_name'' \} \n\ OMBCREATE \$G_TGT_OBJ_TYPE ''\$g_tgt_obj_name'' \n\ catch \{ OMBDROP MAPPING ''\$g_map_name'' \} \n\ OMBCREATE MAPPING ''\$g_map_name'' \\ \n\ ADD \$G_SRC_OBJ_TYPE OPERATOR ''\$g_src_obj_name'' BOUND TO \$G_SRC_OBJ_TYPE ''\$OMB_CURRENT_PROJECT/\$G_SRC_MODULE/\$g_src_obj_name'' \\ \n\ ADD \$G_TGT_OBJ_TYPE OPERATOR ''\$g_tgt_obj_name'' BOUND TO \$G_TGT_OBJ_TYPE ''\$OMB_CURRENT_PROJECT/\$G_TGT_MODULE/\$g_tgt_obj_name'' \\ \n\ ADD CONNECTION FROM GROUP ''\$g_from_group'' OF OPERATOR ''\$g_src_obj_name'' \\ \n\ TO GROUP ''INOUTGRP1'' OF OPERATOR ''\$g_tgt_obj_name'' COPY ALL \n\ OMBRECONCILE MAPPING ''\$g_map_name'' OPERATOR ''\$g_tgt_obj_name'' \\ \n\ TO \$G_TGT_OBJ_TYPE ''\$OMB_CURRENT_PROJECT/\$G_TGT_MODULE/\$g_tgt_obj_name'' \\ \n\ USE (RECONCILE_STRATEGY ''REPLACE'', MATCHING_STRATEGY ''MATCH_BY_OBJECT_NAME'') \n\ OMBCOMMIT') OMBCOMMIT