Source:
public Workflow getworkflowReferenceByExternalWorkflowReference(String externalWorkflowRef)throws APIManagementException { Connection connection = null; PreparedStatement prepStmt = null; ResultSet rs = null; Workflow workflow=new Workflow(); String sqlQuery = SQLConstants.GET_ALL_WORKFLOW_DETAILS_BY_EWR; try { connection = APIMgtDBUtil.getConnection(); prepStmt = connection.prepareStatement(sqlQuery); prepStmt.setString(1, externalWorkflowRef); rs = prepStmt.executeQuery(); while (rs.next()) { workflow.setWorkflowId(rs.getInt("WF_ID")); workflow.setWorkflowReference(rs.getString("WF_REFERENCE")); workflow.setWorkflowType(rs.getString("WF_TYPE")); String workflowstatus =rs.getString("WF_STATUS"); workflow.setStatus(org.wso2.carbon.apimgt.api.WorkflowStatus.valueOf(workflowstatus)); workflow.setCreatedTime(rs.getTimestamp("WF_CREATED_TIME").toString()); workflow.setUpdatedTime(rs.getTimestamp("WF_UPDATED_TIME").toString()); workflow.setWorkflowStatusDesc(rs.getString("WF_STATUS_DESC")); workflow.setTenantId(rs.getInt("TENANT_ID")); workflow.setTenantDomain(rs.getString("TENANT_DOMAIN")); workflow.setExternalWorkflowReference(rs.getString("WF_EXTERNAL_REFERENCE")); Blob metadatablob = rs.getBlob("WF_METADATA"); byte[] metadataByte; if(metadatablob != null) { metadataByte = metadatablob.getBytes(1L, (int) metadatablob.length()); InputStream targetStream = new ByteArrayInputStream(metadataByte); String metadata = APIMgtDBUtil.getStringFromInputStream(targetStream); Gson g = new Gson(); JSONObject json = g.fromJson(metadata, JSONObject.class); workflow.setMetadata(json); } else { JSONObject json=new JSONObject(); workflow.setMetadata(json); } } } catch (SQLException e) { handleException("Error when retriving the workflow details" , e); } finally { APIMgtDBUtil.closeAllConnections(prepStmt, connection, rs); } return workflow; }

Target:
public Workflow getworkflowReferenceByExternalWorkflowReference(String externalWorkflowRef)throws APIManagementException { Connection connection = null; PreparedStatement prepStmt = null; ResultSet rs = null; Workflow workflow = new Workflow(); String sqlQuery = SQLConstants.GET_ALL_WORKFLOW_DETAILS_BY_EXTERNALWORKFLOWREF; try { connection = APIMgtDBUtil.getConnection(); prepStmt = connection.prepareStatement(sqlQuery); prepStmt.setString(1, externalWorkflowRef); rs = prepStmt.executeQuery(); while (rs.next()) { workflow.setWorkflowId(rs.getInt("WF_ID")); workflow.setWorkflowReference(rs.getString("WF_REFERENCE")); workflow.setWorkflowType(rs.getString("WF_TYPE")); String workflowstatus =rs.getString("WF_STATUS"); workflow.setStatus(org.wso2.carbon.apimgt.api.WorkflowStatus.valueOf(workflowstatus)); workflow.setCreatedTime(rs.getTimestamp("WF_CREATED_TIME").toString()); workflow.setUpdatedTime(rs.getTimestamp("WF_UPDATED_TIME").toString()); workflow.setWorkflowStatusDesc(rs.getString("WF_STATUS_DESC")); workflow.setTenantId(rs.getInt("TENANT_ID")); workflow.setTenantDomain(rs.getString("TENANT_DOMAIN")); workflow.setExternalWorkflowReference(rs.getString("WF_EXTERNAL_REFERENCE")); Blob metadatablob = rs.getBlob("WF_METADATA"); byte[] metadataByte; if(metadatablob != null) { metadataByte = metadatablob.getBytes(1L, (int) metadatablob.length()); InputStream targetStream = new ByteArrayInputStream(metadataByte); String metadata = APIMgtDBUtil.getStringFromInputStream(targetStream); Gson metadataGson = new Gson(); JSONObject metadataJson = metadataGson.fromJson(metadata, JSONObject.class); workflow.setMetadata(metadataJson); } else { JSONObject metadataJson = new JSONObject(); workflow.setMetadata(metadataJson); } } } catch (SQLException e) { handleException("Error when retriving the workflow details. " , e); } finally { APIMgtDBUtil.closeAllConnections(prepStmt, connection, rs); } return workflow; }