/**
* @param map
* @return Execution.
*/
public static final Execution getExecution(Map<String, Object> map) {
Execution execution = null;
if (map != null && map.size() > 0) {
Object o = map.get(TestLinkResponseParams.ID.toString());
if (o != null) {
Integer id = Integer.parseInt(o.toString());
if (id > 0) {
execution = new Execution();
execution.setId(id);
execution.setBuildId(getInteger(map, TestLinkResponseParams.BUILD_ID.toString()));
execution.setTesterId(getInteger(map, TestLinkResponseParams.TESTER_ID.toString()));
String statusText = getString(map, TestLinkResponseParams.STATUS.toString());
ExecutionStatus status = ExecutionStatus.getExecutionStatus(statusText.charAt(0));
execution.setStatus(status);
execution.setTestPlanId(getInteger(map, TestLinkResponseParams.TEST_PLAN_ID.toString()));
execution.setTestCaseVersionId(getInteger(map,
TestLinkResponseParams.TEST_CASE_VERSION_ID.toString()));
execution.setTestCaseVersionNumber(getInteger(map,
TestLinkResponseParams.TEST_CASE_VERSION_NUMBER.toString()));
Integer executionTypeText = getInteger(map, TestLinkResponseParams.EXECUTION_TYPE.toString());
ExecutionType executionType = ExecutionType.getExecutionType(executionTypeText);
execution.setExecutionType(executionType);
execution.setNotes(getString(map, TestLinkResponseParams.NOTES.toString()));
String timestamp = getString(map, TestLinkResponseParams.EXECUTION_TS.toString());
if (StringUtils.isNotBlank(timestamp)) {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
Date executionTimeStamp = df.parse(timestamp);
execution.setExecutionTimeStamp(executionTimeStamp);
} catch (ParseException e) {
LOG.log(Level.WARNING, "Failed to parse execution_ts: " + e.getMessage(), e);
}
}
}