public String getVariableNameForTaskInstance ( Long taskInstId , String name ) throws SQLException { String query = "select v.VARIABLE_NAME " + "from VARIABLE v, VARIABLE_MAPPING vm, TASK t, TASK_INSTANCE ti " + "where ti.TASK_INSTANCE_ID = ?" + " and ti.TASK_ID = t.TASK_ID" + " and vm.MAPPING_OWNER = 'TASK'" + " and vm.MAPPING_OWNER_ID = t.TASK_ID" + " and v.VARIABLE_ID = vm.VARIABLE_ID" + " and (v.VARIABLE_NAME = ? or vm.VAR_REFERRED_AS = ?)" ; Object [ ] args = new Object [ 3 ] ; args [ 0 ] = taskInstId ; args [ 1 ] = name ; args [ 2 ] = name ; ResultSet rs = db . runSelect ( query , args ) ; if ( rs . next ( ) ) { /*if (rs.isLast())*/ return rs . getString ( 1 ) ; //else throw new SQLException("getVariableNameForTaskInstance returns non-unique result"); } else throw new SQLException ( "getVariableNameForTaskInstance returns no result" ) ; }
Get the variable name for a task instance with Referred as name