resultlist = _model.executeQueryWorkItems(exec_query+ " order by time");
AggregatedWorkItemRecord witem = new AggregatedWorkItemRecord();
HashMap parent_items = new HashMap();
YWorkItemEvent dummy_event = new YWorkItemEvent();
dummy_event.setIdentifier("");
dummy_event.setTaskid("");
dummy_event.setEvent("dummy");
resultlist.add(dummy_event);
/*
Create WorkItemRecords...
*/
/*
Rewrite into a hashMap Algorithm, which makes it order independent
That should fix it!!!
*/
HashMap eventview = new HashMap();
for (int j = 0; j < resultlist.size();j++) {
YWorkItemEvent event = (YWorkItemEvent) resultlist.get(j);
witem = (AggregatedWorkItemRecord) eventview.get(event.getIdentifier()+event.getTaskid());
if (witem==null) {
witem = new AggregatedWorkItemRecord();
witem.setCaseID(event.getIdentifier());
witem.setTaskID(event.getTaskid());
eventview.put(event.getIdentifier()+event.getTaskid(),witem);
}
if (event.getEvent().equals("Fired")) {
witem.setFiringTime(DateTransform.transform(event.getTime()));
Long parent_enablement = (Long) parent_items.get(event.getIdentifier().
substring(0,event.getIdentifier().
lastIndexOf("."))+
event.getTaskid());
if (parent_enablement!=null) {
long enabled = parent_enablement.longValue();
witem.setEnablementTime(DateTransform.transform(enabled));
witem.setFired2Started(enabled);
}
}
if (event.getEvent().equals("Executing")) {
witem.setStartTime(DateTransform.transform(event.getTime()));
add = true;
long started = event.getTime();
witem.setStarted2Complete(started);
}
if (event.getEvent().equals("Enabled")) {
parent_items.put(event.getIdentifier()+event.getTaskid(),
new Long(event.getTime()));
}
if (event.getEvent().equals("Complete")) {
witem.setCompletionTime(DateTransform.transform(event.getTime()));
long completed = event.getTime();
long enabled = witem.getFired2Started();
long started = witem.getStarted2Complete();
/*
fired to started
*/
witem.setFired2Started(started - enabled);
/*
completion time (fired - complete)
*/
witem.setFired2Complete(completed-enabled);
/*
started to complete
*/
witem.setStarted2Complete(completed-started);
witem.setAssignedTo(event.getResource());
/*
Do not add the parent items and items with missing information
*/
if (parent_items.get(event.getIdentifier()+event.getTaskid())==null) {
if (enabled!=0 && completed!=0 && started!=0) {
checkForAddition(filter,witem,reallyfinal);
}
}
}
witem.setTaskID(event.getTaskid());
witem.setSpecificationID(event.getDescription());
}
if (filter.granularity.equals("Percent")) {
reallyfinal = reduceToPercentage(reallyfinal, filter);