Package au.edu.qut.yawl.engine

Examples of au.edu.qut.yawl.engine.YLogIdentifier


                     */
                   
                    if (resultlist!=null && filter.intervaltime > 0) {
                        int maxSize = (int) (resultlist.size() * filter.intervaltime / 100);
                        for (int j = 0; j < resultlist.size();j++) {
                            YLogIdentifier ylog = (YLogIdentifier) resultlist.get(j);
                            /*
                              Calculate intervaltime for this identifier...
                              if it is not a percentage based interval
                             */
                            ylog.setTime(ylog.getCompleted()-ylog.getCreated());
                            if (!filter.granularity.equals("Percent")) {
                                if (filter.LessThan) {
                                    if ((ylog.getCompleted()-ylog.getCreated()) < filter.intervaltime) {
                                        finalresult.add(ylog);
                                    }
                                } else {
                                    if ((ylog.getCompleted()-ylog.getCreated()) > filter.intervaltime) {
                                        finalresult.add(ylog);
                                    }
                                }
                            } else {
                                /*
                                  If it is a percentage based interval
                                  Compare to the rest of the list to see if it is
                                  within the X percent...if there is room...then ok
                                 */
                                System.out.println("MAX SIZE: " + maxSize);
                                if (finalresult.size() < maxSize) {
                                    finalresult.add(ylog);
                                } else {
                                    for (int k = 0; k < finalresult.size();k++) {
                                        YLogIdentifier old = (YLogIdentifier) finalresult.get(k);
                                        if (filter.LessThan) {
                                            if (old.getTime() > ylog.getTime()) {
                                                finalresult.remove(old);
                                                finalresult.add(ylog);
                                            }
                                        } else {
                                            if (old.getTime() < ylog.getTime()) {
                                                finalresult.remove(old);
                                                finalresult.add(ylog);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        for (int j = 0; j < finalresult.size();j++) {
                            YLogIdentifier ylog = (YLogIdentifier) finalresult.get(j);
                            //reallyfinal.add(addCaseParameters(req,ylog));
                            reallyfinal.add(ylog);
                        }
                    } else {
                        finalresult = resultlist;
                        for (int j = 0; j < finalresult.size();j++) {
                            YLogIdentifier ylog = (YLogIdentifier) finalresult.get(j);
                            ylog.setTime(ylog.getCompleted()-ylog.getCreated());
                           
                            //reallyfinal.add(addCaseParameters(req,ylog));
                            System.out.println("YLOG: " + ylog.getCreatedby());
                            reallyfinal.add(ylog);
                        }
                    }
                   
                    /*
                      This should be done if there is a grouping
                      request in the query rather than individual
                     */
                   
                    if (!grouping.equals("No grouping")) {
                        reallyfinal = calculateCaseAggregation(reallyfinal,grouping);
                    }
                   
                    /*
                      If this is a work item query
                     */
                } else {
                    checkWorkItemDisplayParameters(req);
                    boolean add = false;
                    String currentid = "";
                    String exec_query = filter.query;
                   
                    /*
                      WHY are they sorted this way??
                      Actually to keep the grouping of items
                      So that we know when we are finished with one item
                     */
                   
                    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);
                    }
                   
                    /*
                      calculate the aggregation according to the grouping
                     */
                   
                    if (!grouping.equals("No grouping")) {
                        reallyfinal = calculateWorkItemAggregation(reallyfinal,grouping);
                       
                        System.out.println(reallyfinal);
                       
                    }
                   
                   
                }
            }
           
           
            if (action!=null && action.equals("Create chart")) {
               
                String interval_granul = req.getParameter("interval_chart_granularity");
                int granul = 0;
                if (interval_granul.equals("Seconds")) {
                    granul = Calendar.SECOND;
                }
                if (interval_granul.equals("Minutes")) {
                    granul = Calendar.MINUTE;
                }
                if (interval_granul.equals("Hours")) {
                    granul = Calendar.HOUR_OF_DAY;
                }
                if (interval_granul.equals("Days")) {
                    granul = Calendar.DATE;
                }
                if (interval_granul.equals("Months")) {
                    granul = Calendar.MONTH;
                }
                if (interval_granul.equals("Years")) {
                    granul = Calendar.YEAR;
                }
               
               
                String charttype = req.getParameter("graphtype");
               
                System.out.println(charttype);
               
                List chartValues = new LinkedList();
               
                String xaxis = req.getParameter("groupbyvalue");
                String yaxis = req.getParameter("chartvalue");
               
                for (int i = 0; i < reallyfinal.size();i++) {
                   
                   
                    if (querytype.equals("case")) {
                       
                        YLogIdentifier ylog = (YLogIdentifier) reallyfinal.get(i);
                        System.out.println(ylog.getTime());
                        System.out.println(ylog.getSpecification());
                        Object[] o = new Object[2];
                       
                        /*
                          Select time selected
                         */
                        if (yaxis.equals("Started-Completed")) {
                            o[1] = new Integer((int)DateTransform.getTime(ylog.getTime(),granul));
                        } else if (yaxis.equals("Count")) {
                            o[1] = new Integer((int) ylog.getCount());
                        }
                       
                        /*
                          Select group by element
                         */
                        if (grouping.equals("Specification")) {
                            o[0] = ylog.getSpecification();
                        } else if (grouping.equals("Resource")) {
                            o[0] = ylog.getCreatedby();
                        } else {
                            o[0] = ylog.getIdentifier();
                        }
                       
                        System.out.println("Setting " +  grouping +  " as " + o[0] + " " + ylog.getCreatedby());
                        chartValues.add(o);
                       
                    } else {
                        AggregatedWorkItemRecord witem = (AggregatedWorkItemRecord) reallyfinal.get(i);
                        Object[] o = new Object[2];
View Full Code Here


                if (columnlist.contains("Average Enabled-Started")) {
                    paramlist.add(DateTransform.convertRelativeTime(witem.getFired2Started()));
                }

            } else {
                YLogIdentifier ylog = (YLogIdentifier) parseList.get(i);
               
                if (columnlist.contains("Completion Time")) {
                    //paramlist.add(DateTransform.convertRelativeTime(ylog.getCompleted()- ylog.getCreated()));
                   
                    paramlist.add(DateTransform.convertRelativeTime(ylog.getTime()));
                }
                if (columnlist.contains("Average Completion Time")) {
                    //paramlist.add(DateTransform.convertRelativeTime(ylog.getCompleted()- ylog.getCreated()));
                   
                    paramlist.add(DateTransform.convertRelativeTime(ylog.getTime()));
                }
                if (columnlist.contains("Created")) {
                    paramlist.add(DateTransform.transform(ylog.getCreated()));
                }
                if (columnlist.contains("Completed")) {
                    paramlist.add(DateTransform.transform(ylog.getCompleted()));
                }
                if (columnlist.contains("Cancelled")) {
                    paramlist.add(DateTransform.transform(ylog.getCancelled()));
                }
                if (columnlist.contains("Specification")) {
                    paramlist.add(ylog.getSpecification());
                }

                if (columnlist.contains("Count")) {
                    paramlist.add(new Long(ylog.getCount()).toString());
                }
                if (columnlist.contains("Owner")) {
                    paramlist.add(ylog.getCreatedby());
                }
               
               
               
               
View Full Code Here

       
        LinkedList aggregated = new LinkedList();
        HashMap map = new HashMap();
       
        for (int i = 0; i < parseList.size(); i++) {
            YLogIdentifier ylog = (YLogIdentifier) parseList.get(i);
           
            /*
              The grouping variable is used as the key
              Default is group by specification
             */
           
           
            YLogIdentifier agglog = null;
            if (grouping.equals("Specification")) {
                agglog = (YLogIdentifier) map.get(ylog.getSpecification());
            } else if (grouping.equals("Resource")) {
                agglog = (YLogIdentifier) map.get(ylog.getCreatedby());
            else {
                return parseList;
            }
           
            if (agglog == null) {
                /*
                  There is no element within this group yet....
                 */
                agglog = new YLogIdentifier();
               
                agglog.setSpecification(ylog.getSpecification());
                System.out.println("new grouping by: " + grouping + " " + ylog.getCreatedby());
               
                agglog.setCreatedby(ylog.getCreatedby());
                agglog.setCreated(ylog.getCreated());
                agglog.setCompleted(ylog.getCompleted());
                agglog.setCancelled(ylog.getCancelled());
                agglog.setTime(ylog.getCompleted()- ylog.getCreated());
                //agglog.setFirstCompletionTime();
                //agglog.setFirstStartTime();
                //agglog.setLastCompletionTime();
                //agglog.setLastStartTime();
                agglog.setCount(1);
               
               
                if (grouping.equals("Specification")) {
                    map.put(agglog.getSpecification(),agglog);
                } else if (grouping.equals("Resource")) {
                    map.put(agglog.getCreatedby(),agglog);
                }
                System.out.println("New spec....time is: " + agglog.getTime());
            } else {
               
                /*
                  Existing element within this group exists
                  Add to this group
                 */
               
                agglog.setTime(agglog.getTime() + (ylog.getCompleted()-ylog.getCreated()));
                agglog.setCount(agglog.getCount()+1);
            }
           
        }
        Iterator it = map.values().iterator();
        while (it.hasNext()) {
            YLogIdentifier ylog = (YLogIdentifier) it.next();
            ylog.setTime(ylog.getTime()/ylog.getCount());
            aggregated.add(ylog);
            System.out.println("Calculating Averages....!!!!!!!!! " + ylog.getTime() + " " + ylog.getCreatedby());
        }
       
        return aggregated;
    }
View Full Code Here

TOP

Related Classes of au.edu.qut.yawl.engine.YLogIdentifier

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.