示例#1
0
        public static int getSortPriority(EnumQueueEntryStatus status, int priority)
        {
            int sort = (status == null) ? 0 : 10000 - 1000 * status.getValue();

            sort += priority;
            return(sort);
        }
示例#2
0
            //
            //		 * (non-Javadoc)
            //		 *
            //		 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
            //
            public virtual int Compare(object a1, object a2)
            {
                if (!(a1 is KElement))
                {
                    return(-1);
                }
                if (!(a2 is KElement))
                {
                    return(1);
                }
                KElement o1 = (KElement)a1;
                KElement o2 = (KElement)a2;
                int      i  = o1.Name.CompareTo(o2.Name);

                if (i != 0)
                {
                    return(i);
                }
                if ((o1 is JDFQueueEntry) && (o2 is JDFQueueEntry))
                {
                    JDFQueueEntry        q1      = (JDFQueueEntry)o1;
                    JDFQueueEntry        q2      = (JDFQueueEntry)o2;
                    EnumQueueEntryStatus status1 = q1.getQueueEntryStatus();
                    EnumQueueEntryStatus status2 = q2.getQueueEntryStatus();
                    int s1 = (status1 == null) ? 0 : status1.getValue();
                    int s2 = (status2 == null) ? 0 : status2.getValue();
                    if (s1 != s2)
                    {
                        return(s1 - s2);
                    }
                    if (q1.isCompleted())
                    {
                        JDFDate d1 = q1.getEndTime();
                        JDFDate d2 = q1.getEndTime();
                        if (d1 != null && d2 != null)
                        {
                            return(d1.CompareTo(d2));
                        }
                    }
                    else
                    {
                        s1 = q1.getPriority();
                        s2 = q2.getPriority();
                        if (s1 != s2)
                        {
                            return(s2 - s1);
                        }
                    }

                    JDFDate d11 = q1.getStartTime();
                    JDFDate d22 = q2.getStartTime();
                    int     d   = ContainerUtil.compare(d11, d22);
                    if (d != 0)
                    {
                        return(d);
                    }

                    d11 = q1.getSubmissionTime();
                    d22 = q2.getSubmissionTime();
                    d   = ContainerUtil.compare(d11, d22);
                    if (d != 0)
                    {
                        return(d);
                    }
                }
                return(0);
            }