static String taskReason(TaskReason tr) { if(tr instanceof TaskReasonAlarm) { return " <-- Alarm"; } else if(tr instanceof TaskReasonSchedule) { return " <-- ScheduledTask"; } else if(tr instanceof TaskReasonSystem) { return " <-- System"; } else if(tr instanceof TaskReasonUser) { return " <-- User : " + ((TaskReasonUser)tr).getUserName(); } return "Unknown"; }
private void logTaskInfo(TaskInfo info) { String key = info.getKey(); String name = info.getName(); String target = info.getEntityName(); TaskInfoState state = info.getState(); Integer progress = info.getProgress(); if (state == TaskInfoState.SUCCESS) { progress = Integer.valueOf(100); } else if (progress == null) { progress = Integer.valueOf(0); } LocalizableMessage desc = info.getDescription(); String description = desc != null ? desc.getMessage() : ""; TaskReason reason = info.getReason(); String initiatedBy = ""; if (reason != null) { if (reason instanceof TaskReasonUser) { initiatedBy = ((TaskReasonUser) reason).getUserName(); } else if (reason instanceof TaskReasonSystem) { initiatedBy = "System"; } else if (reason instanceof TaskReasonSchedule) { initiatedBy = ((TaskReasonSchedule) reason).getName(); } else if (reason instanceof TaskReasonAlarm) { initiatedBy = ((TaskReasonAlarm) reason).getAlarmName(); } } XMLGregorianCalendar queueT = info.getQueueTime(); String queueTime = queueT != null ? queueT.toGregorianCalendar().getTime().toString() : ""; XMLGregorianCalendar startT = info.getStartTime(); String startTime = startT != null ? startT.toGregorianCalendar().getTime().toString() : ""; XMLGregorianCalendar completeT = info.getCompleteTime(); String completeTime = completeT != null ? completeT.toGregorianCalendar().getTime().toString() : ""; logger.debug(key + " name: " + name + " target: " + target + " state: " + state + " progress: " + progress + "% description: " + description + " initiated: " + initiatedBy + " queue-time: " + queueTime + " start-time: " + startTime + " complete-time: " + completeTime); }