void preventTrackingLevelAbuse ( Workitem workitem ) { TrackingLevel level = getTrackingLevel ( workitem ) ; if ( workitem instanceof PrimaryWorkitem ) { if ( level == TrackingLevel . SecondaryWorkitem ) { throw new IllegalStateException ( "You cannot set DetailEstimate " + "or ToDo on this item, nor can you log effort, because" + " the system is configured to track Detail Estimate " + "and ToDo at the Task/Test level." ) ; } } else if ( level == TrackingLevel . PrimaryWorkitem ) { throw new IllegalStateException ( "You cannot set DetailEstimate or " + "ToDo on this item, nor can you log effort, because the " + "system is configured to track Detail Estimate and ToDo " + "at the Story/Defect level." ) ; } }
Call this before setting DetailEstimate or ToDo on a workitem .