com.ibm.tivoli.maximo.skd.util

Class GanttModelUtil

  • java.lang.Object
    • com.ibm.tivoli.maximo.skd.util.GanttModelUtil


  • public class GanttModelUtil
    extends java.lang.Object
    Utility methods for working with Gantt Models (ie, WorkOrders, Assignments, etc) Much of this is copied from the Activies class in the Applet.
    • Field Detail

      • WO_INTERNAL_STATUS_APPR

        public static final java.lang.String WO_INTERNAL_STATUS_APPR
        Internal Status for Approved WorkOrder "APPR"
        See Also:
        Constant Field Values
      • PROPERTY_READ_ONLY_MODEL

        public static final java.lang.String PROPERTY_READ_ONLY_MODEL
        Property on the ROOT activity to indicate that the model is readonly
        See Also:
        Constant Field Values
      • WORKORDER_OBJECTNAMES

        public static final java.util.List WORKORDER_OBJECTNAMES
        Global List of WORKORDER type object names
    • Constructor Detail

      • GanttModelUtil

        public GanttModelUtil()
    • Method Detail

      • findActivityById

        public static ilog.views.gantt.IlvActivity findActivityById(java.lang.String id,
                                                                    ilog.views.gantt.IlvHierarchyNode start,
                                                                    ilog.views.gantt.IlvGanttModel model)
      • findResourceById

        public static ilog.views.gantt.IlvResource findResourceById(java.lang.String id,
                                                                    ilog.views.gantt.IlvHierarchyNode start,
                                                                    ilog.views.gantt.IlvGanttModel model)
      • find

        public static ilog.views.gantt.IlvHierarchyNode find(GanttModelUtil.Predicate idp,
                                                             ilog.views.gantt.IlvHierarchyNode start,
                                                             ilog.views.gantt.IlvGanttModel model)
      • isAssignment

        public static boolean isAssignment(MXActivity mxa)
      • isOtherAssignment

        public static boolean isOtherAssignment(MXActivity mxa)
      • isReadOnly

        public static boolean isReadOnly(MXActivity mxa)
      • isLocked

        public static boolean isLocked(MXActivity activity)
      • isResourceLocked

        public static boolean isResourceLocked(MXActivity activity)
      • isSecondary

        public static boolean isSecondary(MXActivity mxa)
      • isHidden

        public static boolean isHidden(MXActivity mxa)
      • isHidden

        public static boolean isHidden(ilog.views.gantt.IlvHierarchyNode node)
      • showWorklogIcon

        public static boolean showWorklogIcon(MXActivity mxa)
      • showRequirementIcon

        public static boolean showRequirementIcon(MXActivity mxa)
      • isDummy

        public static boolean isDummy(ilog.views.gantt.IlvResource next)
      • isDummy

        public static boolean isDummy(IMXActivity act)
      • isCompleted

        public static boolean isCompleted(MXActivity mxa)
      • toStringArray

        public static java.lang.Object toStringArray(java.lang.String[] items)
      • getParentWorkorder

        public static MXActivity getParentWorkorder(MXGanttModel model,
                                                    ilog.views.gantt.IlvActivity assignment)
      • getSecondaryAssignmens

        public static java.util.List getSecondaryAssignmens(MXGanttModel model,
                                                            MXActivity primary)
      • isWorkorder

        public static boolean isWorkorder(ilog.views.gantt.IlvActivity act)
        Returns true if the given IlvActivity is a work order
        Parameters:
        act - IlvActivity instance
        Returns:
        true if it's a work order activity
      • isAssignment

        public static boolean isAssignment(ilog.views.gantt.IlvActivity act)
        Returns true if the Activity is an Assignment
        Parameters:
        act -
        Returns:
      • isPM

        public static boolean isPM(ilog.views.gantt.IlvActivity act)
        Returns true if the activity is a PM activity
        Parameters:
        act -
        Returns:
      • isPM

        public static boolean isPM(ilog.views.gantt.IlvHierarchyNode act)
        Returns true if the activity is a PM activity
        Parameters:
        act -
        Returns:
      • hasChildren

        public static boolean hasChildren(ilog.views.gantt.IlvHierarchyNode item,
                                          ilog.views.gantt.IlvGanttModel model)
        Returns true if the given MXActivity, IlvActivity or IlvHierarchyNode has children.
        Parameters:
        item - IlvActivity instance (can be MXActivity or IlvHierarchyNode)
        chart - gantt chart to while the item belongs
        Returns:
        true if the item has children
      • hasAnyChildren

        public static boolean hasAnyChildren(ilog.views.gantt.IlvHierarchyNode[] items,
                                             ilog.views.gantt.IlvGanttModel model)
        Returns true if ANY item has children
        Parameters:
        items -
        ganttChart -
        Returns:
      • addCrafts

        public static void addCrafts(java.util.HashSet crafts,
                                     ilog.views.gantt.IlvActivity item,
                                     ilog.views.gantt.IlvGanttChart ganttChart)
        For a given Activity on the chart, add its crafts to the set of passed in crafts. NOTE: THis will also return Cost and Crews as well.
        Parameters:
        crafts - HashSet to which the crafts should be placed
        item - IlvActivity item on the chart
        ganttChart - IlvGanttChart gantt chart
      • visitResource

        public static void visitResource(ilog.views.gantt.IlvResource item,
                                         ilog.views.gantt.IlvGanttModel model,
                                         GanttModelUtil.IlvResourceVisitor visitor,
                                         java.lang.Object state)
        Allow an IlvResource object to be visited by the visitor.
        Parameters:
        item - Item being visited
        chart - Chart to which the item belongs
        visitor - Visitor that will accept the item
        state - State that will be passed to the visitor
      • visitResources

        public static void visitResources(ilog.views.gantt.IlvResource[] items,
                                          ilog.views.gantt.IlvGanttModel model,
                                          GanttModelUtil.IlvResourceVisitor visitor,
                                          java.lang.Object state)
        Visits an array of Resources
        Parameters:
        items - array of IlvResource items
        chart - chart to which the items belong
        visitor - visitor that will accept each of the items
        state - state that will be passed to the visitor
      • visitActivity

        public static void visitActivity(ilog.views.gantt.IlvActivity item,
                                         ilog.views.gantt.IlvGanttModel model,
                                         GanttModelUtil.IlvActivityVisitor visitor,
                                         java.lang.Object state)
        Applies an IlvActivityVisitor to each activity and it's children.
        Parameters:
        item - IlvActivity parent activity
        ganttChart - IlvGanttChart to which the IlvActivity belongs
        visitor - GanttModelUtil.IlvActivityVisitor that will visit each item
      • visitNodes

        public static void visitNodes(ilog.views.gantt.IlvHierarchyNode[] items,
                                      ilog.views.gantt.IlvGanttModel model,
                                      GanttModelUtil.IlvNodeVisitor visitor,
                                      java.lang.Object state)
        Generic Visitor for IlvHierarchNodes
        Parameters:
        items -
        ganttChart -
        visitor -
        state -
      • visitNode

        public static void visitNode(ilog.views.gantt.IlvHierarchyNode item,
                                     ilog.views.gantt.IlvGanttModel model,
                                     GanttModelUtil.IlvNodeVisitor visitor,
                                     java.lang.Object state)
        Generic Visitor for visiting IlvHeirarchyNodes
      • visitActivities

        public static void visitActivities(ilog.views.gantt.IlvActivity[] items,
                                           ilog.views.gantt.IlvGanttModel model,
                                           GanttModelUtil.IlvActivityVisitor visitor,
                                           java.lang.Object state)
        Applies an IlvActivityVisitor to each activity and it's children.
        Parameters:
        item - IlvActivity parent activity
        ganttChart - IlvGanttChart to which the IlvActivity belongs
        visitor - GanttModelUtil.IlvActivityVisitor that will visit each item
      • newAdjustTimeVisitor

        public static final GanttModelUtil.IlvActivityVisitor newAdjustTimeVisitor(ilog.views.gantt.IlvDuration adjustment)
        Creates a visitor that will adjust the start and end times on an activity by the given IlvDuration. IlvDuration defines constants for ONE_DAY, ONE_WEEK, etc, or you can pass your own duration. This visitor will tract each item that is visited in in the state Set, to prevent the same item from being visited more than once. The only use case for this is when you are processing multiple selected rows of a selected parent.
        Parameters:
        adjustment - IlvDuration to which to apply to the start and end time
        Returns:
        GanttModelUtil.IlvActivityVisitor implementation that will adjust by the given adjustment
      • moveToDay

        public static void moveToDay(java.util.Calendar day,
                                     ilog.views.gantt.IlvActivity[] selected,
                                     ilog.views.gantt.IlvGanttModel model)
        Given the Date and the selected items, it performs a Move To Day operation. The Time on the activities are retained, but their "day" is reparented to the given day
        Parameters:
        day -
        selected -
        gchart -
      • dumpDebegInfoForContaints

        public static void dumpDebegInfoForContaints(java.lang.String msg,
                                                     java.util.Iterator iter,
                                                     java.io.PrintStream out)
      • dumpDebugInfoForContstraint

        public static void dumpDebugInfoForContstraint(ilog.views.gantt.IlvConstraint c,
                                                       java.io.PrintStream out)
      • dumpDebugCompareInfoForItems

        public static void dumpDebugCompareInfoForItems(java.lang.String msg,
                                                        ilog.views.gantt.property.IlvUserPropertyHolder item1,
                                                        ilog.views.gantt.property.IlvUserPropertyHolder item2,
                                                        java.io.PrintStream out)
        Dumps 2 Activities and compares their properties
        Parameters:
        item1 -
        item2 -
      • copyProperties

        public static void copyProperties(ilog.views.gantt.IlvActivity src,
                                          ilog.views.gantt.IlvActivity dest)
        Copies all Non-Null properties from the source to the destination, but it will NOT overwrite existing Non-Null properties in the destination.
        Parameters:
        src -
        dest -
      • getEarliestStartTime

        public static java.util.Date getEarliestStartTime(ilog.views.gantt.IlvActivity[] selected)
        Given an array of items, then return the earliest start time for all the activities
        Parameters:
        selected -
        Returns:
      • getLatestEndTime

        public static java.util.Date getLatestEndTime(ilog.views.gantt.IlvActivity[] selected)
        Given the array of items, return the latest end time for all the activites
        Parameters:
        selected -
        Returns:
      • applyTimeAdjustmentForItems

        protected static void applyTimeAdjustmentForItems(ilog.views.gantt.IlvActivity[] items,
                                                          ilog.views.gantt.IlvGanttModel model,
                                                          ilog.views.gantt.IlvDuration dur)
        Applies the time adjustment (duration) to each (and it's children) for the given chart.
        Parameters:
        items -
        gchart -
        dur -
      • getParent

        public static ilog.views.gantt.IlvActivity getParent(ilog.views.gantt.IlvActivity act,
                                                             ilog.views.gantt.IlvGanttModel model)
        Returns the parent activity for the given activity in the model
        Parameters:
        act -
        model -
        Returns:
      • getParentSafely

        public static ilog.views.gantt.IlvActivity getParentSafely(ilog.views.gantt.IlvActivity act,
                                                                   ilog.views.gantt.IlvGanttModel model)
        Returns the parent activity for the given activity in the model. If the activity not in the model, then null is returned.
        Parameters:
        act -
        model -
        Returns:
      • getID

        public static java.lang.String getID(IMXActivity mxa)
        Returns the TreeGrid ID for this activity and creates one, if one does not exist.
        Parameters:
        act -
        model -
        Returns:
      • getID

        public static java.lang.String getID(java.lang.String actid)
        Given an activity ID from ILOG create a TreeGrid compatible ID
        Parameters:
        actid -
        Returns:
      • getID

        public static java.lang.String getID(ilog.views.gantt.IlvHierarchyNode node)
        Returns the ID for a Resource or Activity
        Parameters:
        node -
        Returns:
      • setProperty

        public static boolean setProperty(java.lang.Object node,
                                          java.lang.String prop,
                                          java.lang.Object val)
        Sets a property, if possible, in the IlvHierarchyNode. The node must implement IlvUserPropertyHolder for this to work.
        Parameters:
        node -
        prop -
        val -
        Returns:
        true if the property was set
      • getProperty

        public static java.lang.Object getProperty(java.lang.Object node,
                                                   java.lang.String prop)
        Gets a property from a node
        Parameters:
        node -
        prop -
        Returns:
      • getProperty

        public static java.lang.Object getProperty(java.lang.Object node,
                                                   java.lang.String prop,
                                                   java.lang.Object defaultValue)
        Gets a property from a Node and returns the default if not set.
        Parameters:
        node -
        prop -
        defaultValue -
        Returns:
      • createUnionTimeInterval

        public static ilog.views.gantt.IlvTimeInterval createUnionTimeInterval(ilog.views.gantt.IlvHierarchyNode[] nodes)
        Returns a TimeInterval that fits all the nodes that are passed in.
        Parameters:
        charts -
        Returns:
      • isWorkorderApproved

        public static boolean isWorkorderApproved(MXActivity source)
        Returns true if the source is a workorder and it is approved
        Parameters:
        source -
        Returns:
      • getActivityById

        public static ilog.views.gantt.IlvActivity getActivityById(ilog.views.gantt.IlvGanttModel model,
                                                                   ilog.views.gantt.IlvActivity parent,
                                                                   java.lang.String id)
        Convenience method for finding an Activiy by ID
        Parameters:
        model -
        id -
        Returns:
      • getChildren

        public static ilog.views.gantt.IlvHierarchyNode[] getChildren(ilog.views.gantt.IlvHierarchyNode item,
                                                                      ilog.views.gantt.IlvGanttModel model)
        Convenience Method that returns all direct children for a given node
        Parameters:
        item -
        chart -
        Returns:
      • dumpDebugInfoForResource

        public static void dumpDebugInfoForResource(ilog.views.gantt.IlvResource selectedresource,
                                                    ilog.views.gantt.IlvGanttModel model,
                                                    java.io.PrintStream out)
      • count

        public static long count(java.util.Iterator items)
        Count the items
        Parameters:
        items -
        Returns:
      • countActivities

        public static long countActivities(ilog.views.gantt.IlvGanttModel model)
      • countResources

        public static long countResources(ilog.views.gantt.IlvGanttModel model)
      • countReservations

        public static long countReservations(ilog.views.gantt.IlvGanttModel model)
      • dumpModel

        public static void dumpModel(java.lang.String msg,
                                     MXGanttModel model,
                                     java.io.PrintStream out,
                                     boolean simple)
      • dumpActivity

        public static void dumpActivity(MXGanttModel model,
                                        ilog.views.gantt.IlvActivity rootActivity,
                                        java.io.PrintStream out,
                                        boolean simple,
                                        int indent)
      • isAssignmentDummy

        public static boolean isAssignmentDummy(ilog.views.gantt.IlvHierarchyNode node)
      • dumpReservationsForResource

        public static void dumpReservationsForResource(MXResource mxr,
                                                       MXGanttModel model,
                                                       java.io.PrintStream out)
      • updateProperty

        public static boolean updateProperty(IMXActivity act,
                                             java.lang.String prop,
                                             java.lang.Object val)
      • isTimeRollupEnabled

        public static boolean isTimeRollupEnabled()
      • isAverageRollupEnabled

        public static boolean isAverageRollupEnabled()
      • isRootActivity

        public static boolean isRootActivity(IMXActivity activity)
      • getTravelTimeConstraintForToActivity

        public static MXTravelTimeConstraint getTravelTimeConstraintForToActivity(MXGanttModel theModel,
                                                                                  ilog.views.gantt.IlvActivity activity)
        returns the 'TO' constraint for the passed in activity
        Returns:
      • IlvDurationToDouble

        public static double IlvDurationToDouble(ilog.views.gantt.IlvDuration lv,
                                                 UserInfo ui)
                                          throws java.lang.Exception
        Convert IlvDuration to a double
        Parameters:
        lv -
        Returns:
        duration in double
        Throws:
        java.lang.Exception
      • encodeTreeGridActivityContraints

        public static java.lang.String encodeTreeGridActivityContraints(IMXGanttModel model,
                                                                        IMXActivity mxa)
                                                                 throws java.io.IOException
        Encodes the Contstaints and form the IlvConstaints coming from this activity and update the Activity's DECENDENTS field with the newly calculated descendents. It will return the encoded constraint data as well.
        Parameters:
        model -
        mxa -
        Returns:
        Throws:
        java.io.IOException
      • getFormattedProjectID

        public static long getFormattedProjectID(java.lang.String projectId)
      • removeIDPrefix

        public static java.lang.String removeIDPrefix(java.lang.String actid)
        Remove activity ID prefix.
        Parameters:
        actid -
        Returns:
      • convertTreeInFlatList

        public static com.ibm.json.java.JSONArray convertTreeInFlatList(com.ibm.json.java.JSONArray tree)
        Converts a tree of Activities into a flat list.
        Parameters:
        tree -
        Returns: