Ejemplo n.º 1
0
        ///
        ///	 <summary> * Create or modify a PhaseTime Audit and fill it If the phase is identical to the prior phase that has been set,
        ///	 * the existing PhaseTime is modified otherwise an existing phaseTime is closed and a new phaseTime is appended
        ///	 * Phasetime elements with different Parts are treated independently
        ///	 *  </summary>
        ///	 * <param name="status"> the node status at this time </param>
        ///	 * <param name="statusDetails"> details of this status </param>
        ///	 * <param name="vmParts"> defines a vector of map of parts for which the PhaseTime is valid </param>
        ///	 * <param name="employees"> Vector of employees that are currently registered for this job </param>
        ///	 * <returns> JDFPhaseTime the newly created PhaseTime audit
        ///	 *
        ///	 *         default: SetPhase(status, null,null,null) </returns>
        ///
        public virtual JDFPhaseTime setPhase(EnumNodeStatus status, string statusDetails, VJDFAttributeMap vmParts, VElement employees)
        {
            string statusDetailsLocal = statusDetails;

            JDFPhaseTime pt = getLastPhase(vmParts, null);

            statusDetailsLocal = StringUtil.getNonEmpty(statusDetailsLocal);
            bool     bChanged    = false;
            VElement ptEmployees = pt == null ? new VElement() : pt.getChildElementVector(ElementName.EMPLOYEE, null);

            if (pt == null)
            {
                bChanged = true;
            }
            else if (!ContainerUtil.Equals(pt.getStatus(), status) || !ContainerUtil.Equals(statusDetailsLocal, pt.getAttribute(AttributeName.STATUSDETAILS, null, null)) || !ptEmployees.isEqual(employees))
            {
                pt.setEnd(new JDFDate());
                bChanged = true;
            }
            if (bChanged)
            {
                pt = addPhaseTime(status, null, vmParts);
                pt.setStatusDetails(statusDetailsLocal);
                pt.copyElements(employees, null);
            }
            return(pt);
        }
Ejemplo n.º 2
0
 ///
 ///	 <summary> * returns true if this is the same phase, i.e. the
 ///	 *  </summary>
 ///	 * <param name="lastphase"> the phase to compare with </param>
 ///	 * <param name="bExact"> if true, use startTime as hook, else compare stati
 ///	 * @return </param>
 ///
 public virtual bool isSamePhase(JDFJobPhase lastphase, bool bExact)
 {
     if (lastphase == null)
     {
         return(false);
     }
     if (bExact)
     {
         JDFDate startTime     = getPhaseStartTime();
         JDFDate lastStartTime = lastphase.getPhaseStartTime();
         return(startTime != null && startTime.Equals(lastStartTime));
     }
     if (!ContainerUtil.Equals(getStatus(), lastphase.getStatus()))
     {
         return(false);
     }
     if (!ContainerUtil.Equals(getStatusDetails(), lastphase.getStatusDetails()))
     {
         return(false);
     }
     if (!ContainerUtil.Equals(getIdentifier(), lastphase.getIdentifier()))
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 3
0
        ///
        ///	 <summary> * returns true if the input object is equivalent to this or null</br> valid
        ///	 * object types are:<br/> Employee<br/> EmployeeDef<br/> String - must match @PersonalID
        ///	 * <br/> (non-Javadoc)
        ///	 *  </summary>
        ///	 * <seealso cref= org.cip4.jdflib.ifaces.IMatches#matches(java.lang.Object) </seealso>
        ///
        public virtual bool matches(object subset)
        {
            if (subset == null)
            {
                return(true); // ( matches contract requires true for null to allow
            }
            // wildcards

            if (subset is JDFEmployee)
            {
                // TODO more criteria - person etc.
                JDFEmployee employee = (JDFEmployee)subset;
                return(ContainerUtil.Equals(getPersonalID(), employee.getPersonalID()));
            }
            else if (subset is JDFEmployeeDef)
            {
                JDFEmployeeDef ed = (JDFEmployeeDef)subset;
                return(ContainerUtil.Equals(getPersonalID(), ed.getPersonalID()));
            }
            else if (subset is string)
            {
                return(ContainerUtil.Equals(getPersonalID(), subset));
            }

            return(false);
        }
Ejemplo n.º 4
0
        ///
        ///	 <summary> * sets the QueueEntry/@Status if the queue is automated, also resorts the queue to reflect the new Status and sets
        ///	 * the Queue/@Status based on the maximum number of concurrently running jobs also sets StartTime and EndTime
        ///	 * appropriately if the queue is automated
        ///	 *  </summary>
        ///	 * <param name="value"> the queuentry status to set
        ///	 *  </param>
        ///	 * <seealso cref= org.cip4.jdflib.auto.JDFAutoQueueEntry#setQueueEntryStatus(org.cip4.jdflib.auto.JDFAutoQueueEntry.EnumQueueEntryStatus) </seealso>
        ///
        public override void setQueueEntryStatus(EnumQueueEntryStatus @value)
        {
            EnumQueueEntryStatus oldVal = getQueueEntryStatus();

            if (isAutomated() && !ContainerUtil.Equals(oldVal, @value))
            {
                JDFQueue queue = (JDFQueue)getParentNode_KElement();
                lock (queue)
                {
                    base.setQueueEntryStatus(@value);
                    if (isCompleted())
                    {
                        if (!hasAttribute(AttributeName.ENDTIME))
                        {
                            base.setEndTime(new JDFDate());
                        }
                        queue.cleanup();
                    }
                    if (EnumQueueEntryStatus.Running.Equals(@value))
                    {
                        if (!hasAttribute(AttributeName.STARTTIME))
                        {
                            base.setStartTime(new JDFDate());
                        }
                        removeAttribute(AttributeName.ENDTIME);
                    }
                    queue.sortChildren();
                    queue.setStatusFromEntries();
                }
            }
            else if (!ContainerUtil.Equals(oldVal, @value)) // non automated
            {
                base.setQueueEntryStatus(@value);
            }
        }
Ejemplo n.º 5
0
        ///
        ///	 <summary> * get a vector of all unlinked resources of n and its children
        ///	 *  </summary>
        ///	 * <param name="n"> the node to walk
        ///	 * @return </param>
        ///
        public virtual VElement getUnlinkedResources(JDFNode n)
        {
            ld.clear();
            walk(n);
            List <KElement> toValueVector = ContainerUtil.toValueVector(ld.resMap, false);

            return(toValueVector == null ? null : new VElement(VElement.ToVElement <KElement>(toValueVector)));
        }
Ejemplo n.º 6
0
        ///
        ///	 <summary> * Get a PartAmount that fits to the filter defined by mPart
        ///	 *  </summary>
        ///	 * <param name="vPart"> filter for the part to set the status </param>
        ///	 * <returns> the PartAmount that fits </returns>
        ///
        public virtual JDFPartAmount getPartAmount(VJDFAttributeMap vPart)
        {
            VElement vPartAmount = getChildElementVector(ElementName.PARTAMOUNT, null, null, true, 0, false);

            for (int i = vPartAmount.Count - 1; i >= 0; i--)
            {
                JDFPartAmount    partAmount = (JDFPartAmount)vPartAmount[i];
                VJDFAttributeMap vMapPart   = partAmount.getPartMapVector();

                if (ContainerUtil.Equals(vMapPart, vPart))
                {
                    return(partAmount); // exact match
                }
            }
            return(null);
        }
Ejemplo n.º 7
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);
            }