pse.SchedulingStrategyServiceglobal without sharing class SchedulingStrategyService
This class contains a Scheduling API implementation for each type of Scheduling Strategy. There are inner classes for each type of Scheduling Strategy which have a method for the creation of schedules associated with assignments or resource requests. This class contains deprecated items. Methods
prepareScheduleglobal pse.SchedulingStrategyService.ProposedScheduleDetail prepareSchedule(pse.SchedulingStrategyService.ScheduleDetail scheduleDetail) This method calculates a Schedule and ScheduleExceptions for the provided ScheduleDetail parameters. Input Parameters
Return ValueThis service returns ProposedScheduleDetail object. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. // This sample code is to Prepare Schedule and Schedule Exception using EndDate Level strategy static void testPrepareSchedule() { /** * EndDateLevelScheduleDetail extends ScheduleDetail so here we can create an instance of EndDateLevelScheduleDetail as an over requirement. * Here we can generate a schedule using any type of scheduling strategy by creating an instance of that class. */ pse.SchedulingStrategyService.EndDateLevelScheduleDetail schDet = new pse.SchedulingStrategyService.EndDateLevelScheduleDetail(); schDet.startDate = date.valueOf('2013-12-08'); schDet.endDate = date.valueOf('2013-12-14'); schDet.resourceId = resource.id; // Number of hours for schedule schDet.scheduledHours = 40; // Creating an object of SchedulingStrategyService pse.SchedulingStrategyService ser = new pse.SchedulingStrategyService(); // Calling prepareSchedule API method pse.SchedulingStrategyService.ProposedScheduleDetail ps = ser.prepareSchedule(schDet); SchedulingStrategyService.SchedulePattern schPattern = ps.schedule; system.assertEquals(date.valueOf('2013-12-08'), schPattern.startDate); system.assertEquals(date.valueOf('2013-12-13'), schPattern.endDate); system.assertEquals(0, ps.scheduleExceptions.size()); } prepareSchedulesglobal List<pse.SchedulingStrategyService.ProposedScheduleDetail> prepareSchedules(List<pse.SchedulingStrategyService.ScheduleDetail> scheduleDetails) This method calculates Schedules and ScheduleExceptions for the provided ScheduleDetails parameter. Input Parameters
Return ValueThis service returns a List of ProposedScheduleDetail objects. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. // This sample code is to Prepare Schedule and Schedule Exception using EndDate Level strategy static void testPrepareSchedule() { /** * EndDateLevelScheduleDetail extends ScheduleDetail so here we can create an instance of EndDateLevelScheduleDetail as an over requirement. * Here we can generate a schedule using any type of scheduling strategy by creating an instance of that class. */ pse.SchedulingStrategyService.EndDateLevelScheduleDetail schDet = new pse.SchedulingStrategyService.EndDateLevelScheduleDetail(); schDet.startDate = date.valueOf('2013-12-08'); schDet.endDate = date.valueOf('2013-12-14'); schDet.resourceId = resource.id; // Number of hours for schedule schDet.scheduledHours = 40; // Creating an object of SchedulingStrategyService pse.SchedulingStrategyService ser = new pse.SchedulingStrategyService(); // Calling prepareSchedule API method pse.SchedulingStrategyService.ProposedScheduleDetail ps = ser.prepareSchedule(schDet); SchedulingStrategyService.SchedulePattern schPattern = ps.schedule; system.assertEquals(date.valueOf('2013-12-08'), schPattern.startDate); system.assertEquals(date.valueOf('2013-12-13'), schPattern.endDate); system.assertEquals(0, ps.scheduleExceptions.size()); } rescheduleglobal Boolean reschedule(List<pse.SchedulingStrategyService.RescheduleWrapper> rescheduleWrapperList) A global method to reschedule the provided list of schedules with a new proposed corresponding scheduling strategy in rescheduleWrapper. Input Parameters
Exceptions Thrown
Return ValueThis service returns True if the Schedule updated then completed successfully. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. static void testReschedule() { integer MaxScheduleLimit = 15; List<Contact> contactsList = [select id FROM Contact limit MaxScheduleLimit]; List<Schedule__c> schedulesList = [select id from pse__Schedule__c limit MaxScheduleLimit]; // Creating a list of RescheduleWrapper List<pse.SchedulingStrategyService.RescheduleWrapper> wrapperList = new List<pse.SchedulingStrategyService.RescheduleWrapper>(); for(integer i = 0;i<MaxScheduleLimit;i++) { // Creating an object of SchedulePattern. pse.SchedulingStrategyService.SchedulePattern schPat = new pse.SchedulingStrategyService.SchedulePattern(); schPat.mondayHours = 4.00; schPat.tuesdayHours = 4.00; schPat.wednesdayHours = 8.00; schPat.thursdayHours = 3.00; schPat.fridayHours = 8.00; // Creating an object of CustomScheduleDetail. pse.SchedulingStrategyService.CustomScheduleDetail schDet = new pse.SchedulingStrategyService.CustomScheduleDetail(); // Start date of schedule. schDet.startDate = date.valueOf('2014-08-1'); // End date of schedule. schDet.endDate = date.valueOf('2014-08-15'); // Schedule pattern of schedule. schDet.schedulePattern = schPat; // Number of hours for schedule. schDet.scheduledHours = 40; // Creating an object of RescheduleWrapper pse.SchedulingStrategyService.RescheduleWrapper rescheduleWrapper = new pse.SchedulingStrategyService.RescheduleWrapper(); // Resource id for schedule. schDet.resourceId = contactsList[i].id; rescheduleWrapper.ScheduleDetail = schDet; rescheduleWrapper.scheduleId = schedulesList[i].Id; wrapperList.add(rescheduleWrapper); } pse.SchedulingStrategyService ser = new pse.SchedulingStrategyService(); try{ //Calling reschedule API method Boolean scheduledUpdated = ser.reschedule(wrapperList); system.assert(scheduledUpdated, 'Schedules updation failed'); } catch(Exception ex) { system.assert(false, 'Schedules updation failed : ' + ex.getMessage()); } } splitRescheduleglobal List<pse__Assignment__c> splitReschedule(List<pse.SchedulingStrategyService.SplitRescheduleWrapper> splitRescheduleWrapperList) A global method to split and reschedule the schedules.
Input Parameters
Exceptions Thrown
Return ValueThis service returns a list of newly created assignments. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. static void testSplitReschedule() { List<Contact> contactsList = [select id FROM Contact limit MaxScheduleLimit]; List<pse__Schedule__c> schedulesList = [select id from pse__Schedule__c limit MaxScheduleLimit]; List<pse__Assignment__c> assignmentList = [select id from pse__Assignment__c] // Creating a list of SplitRescheduleWrapper List<pse.SchedulingStrategyService.SplitRescheduleWrapper> wrapperList = new List<pse.SchedulingStrategyService.SplitRescheduleWrapper>(); // Creating an object of EndDateLevelScheduleDetail pse.SchedulingStrategyService.EndDateLevelScheduleDetail schDet1 = new pse.SchedulingStrategyService.EndDateLevelScheduleDetail(); // Start date of schedule. schDet1.startDate = System.Today(); // End date of schedule. schDet1.endDate = System.Today() + 7; // Resource id for schedule. schDet1.resourceId = contactsList.get(0).Id; // Number of hours for schedule. schDet1.scheduledHours = 40; // Creating an object of SplitRescheduleWrapper pse.SchedulingStrategyService.SplitRescheduleWrapper wrapper1 = new pse.SchedulingStrategyService.SplitRescheduleWrapper(); wrapper1.scheduleDetail = schDet1; wrapper1.assignment = assignmentList.get(0).id; wrapper1.markAssignmentAsClosedFlag = true; wrapperList.add(wrapper1); // Creating an object of EndDateLevelScheduleDetail pse.SchedulingStrategyService.EndDateLevelScheduleDetail schDet2 = new pse.SchedulingStrategyService.EndDateLevelScheduleDetail(); // Start date of schedule. schDet2.startDate = System.Today(); // End date of schedule. schDet2.endDate = System.Today() + 7; // Resource id for schedule. schDet2.resourceId = contactsList.get(1).Id; // Number of hours for schedule. schDet2.scheduledHours = 40; // Creating an object of SplitRescheduleWrapper pse.SchedulingStrategyService.SplitRescheduleWrapper wrapper2 = new pse.SchedulingStrategyService.SplitRescheduleWrapper(); wrapper2.scheduleDetail = schDet2; wrapper2.assignment = assignmentList.get(1).id; wrapper2.markAssignmentAsClosedFlag = false; wrapperList.add(wrapper2); pse.SchedulingStrategyService ser = new pse.SchedulingStrategyService(); List<Assignment__c> updatedAssignments; try { // Calling splitReschedule API Method updatedAssignments = ser.splitReschedule(wrapperList); } catch(Exception ex) { system.assert(false, 'Schedules updation failed : ' + ex.getMessage()); } pse__Assignment__c updatedOldAssignment1 = [select pse__Status__c, pse__Closed_For_Time_Entry__c, pse__End_date__c from pse__Assignment__c where id=: assignmentList.get(0).id ]; system.assert(updatedOldAssignment1.pse__Status__c.equalsIgnoreCase('closed')); } } DeprecatedThe following items are deprecated and not supported for use. We recommend that you stop using these items to avoid exceptions. Methods
rescheduleDeprecated: Use reschedule(List global Boolean reschedule(pse.SchedulingStrategyService.RescheduleWrapper request) This global method reschedules a Schedule with a new proposed scheduling strategy in rescheduleWrapper. Input Parameters
Return ValueThis service returns True if the Schedule updated then completed successfully, False otherwise. splitRescheduleDeprecated: Use splitReschedule(List global pse__Assignment__c splitReschedule(pse.SchedulingStrategyService.SplitRescheduleWrapper request) A global method to split and reschedule the Schedule. Input Parameters
Return ValueThis service returns an assignment object. pse.SchedulingStrategyService.ScheduleDetailFieldglobal inherited sharing class ScheduleDetailField The structure for Metadata information related to the ScheduleDetail field. Properties
MethodsScheduleDetailFieldglobal ScheduleDetailField() pse.SchedulingStrategyService.SplitRescheduleWrapperglobal inherited sharing class SplitRescheduleWrapper The structure for Split Reschedule related input values that are common for all strategy types. Properties
pse.SchedulingStrategyService.RescheduleWrapperglobal inherited sharing class RescheduleWrapper The structure for Reschedule related input values that are common for all strategy types. Properties
pse.SchedulingStrategyService.ScheduleDetailglobal abstract inherited sharing class ScheduleDetail The structure for Schedule related input values that are common for all strategy types. Properties
Methods
resolveImplementationglobal abstract Type resolveImplementation() An abstract method to resolve the Schedule class dynamically at runtime. getFieldglobal virtual Object getField() getFieldglobal virtual Object getField(String key) setFieldglobal virtual void setField(String key, Object value) enumerateFieldsglobal virtual Map<String, pse.SchedulingStrategyService.ScheduleDetailField> enumerateFields() pse.SchedulingStrategyService.EndDateLevelScheduleDetailglobal inherited sharing class EndDateLevelScheduleDetail extends ScheduleDetail The structure for Schedule related input values that will be used in the "EndDateLevelSchedule" schedule Strategy. This class extends pse.SchedulingStrategyService.ScheduleDetail Properties
Methods
resolveImplementationglobal override Type resolveImplementation() enumerateFieldsglobal override virtual Map<String, pse.SchedulingStrategyService.ScheduleDetailField> enumerateFields() pse.SchedulingStrategyService.IgnoreAvailabilityScheduleDetailglobal inherited sharing class IgnoreAvailabilityScheduleDetail extends ScheduleDetail The structure for Schedule related input values that will be used in "EndDateIgnoreAvailability" Schedule Strategy types. This class extends pse.SchedulingStrategyService.ScheduleDetail Properties
Methods
resolveImplementationglobal override Type resolveImplementation() enumerateFieldsglobal override virtual Map<String, pse.SchedulingStrategyService.ScheduleDetailField> enumerateFields() pse.SchedulingStrategyService.AdjustHoursScheduleDetailglobal inherited sharing class AdjustHoursScheduleDetail extends ScheduleDetail The structure for Schedule related input values that will be used in "AdjustHours" Strategy types. This class extends pse.SchedulingStrategyService.ScheduleDetail Properties
Methods
resolveImplementationglobal override Type resolveImplementation() enumerateFieldsglobal override virtual Map<String, pse.SchedulingStrategyService.ScheduleDetailField> enumerateFields() pse.SchedulingStrategyService.PercentAllocationScheduleDetailglobal inherited sharing class PercentAllocationScheduleDetail extends ScheduleDetail The structure for Schedule related input values that will be used in "PercentAllocation" Strategy types. This class extends pse.SchedulingStrategyService.ScheduleDetail Properties
Methods
resolveImplementationglobal override Type resolveImplementation() enumerateFieldsglobal override virtual Map<String, pse.SchedulingStrategyService.ScheduleDetailField> enumerateFields() pse.SchedulingStrategyService.CustomScheduleDetailglobal inherited sharing class CustomScheduleDetail extends ScheduleDetail The structure for Schedule related input values that will be used in "Custom" Strategy types. This class extends pse.SchedulingStrategyService.ScheduleDetail Properties
Methods
resolveImplementationglobal override Type resolveImplementation() enumerateFieldsglobal override virtual Map<String, pse.SchedulingStrategyService.ScheduleDetailField> enumerateFields() pse.SchedulingStrategyService.ZeroHourScheduleDetailglobal inherited sharing class ZeroHourScheduleDetail extends ScheduleDetail The structure for Schedule related input values that will be used in "ZeroHour" Strategy types. This class extends pse.SchedulingStrategyService.ScheduleDetail MethodsresolveImplementationglobal override Type resolveImplementation() pse.SchedulingStrategyService.SchedulePatternglobal inherited sharing class SchedulePattern The structure for input variables for Schedule creation using "Custom" strategy types. Properties
pse.SchedulingStrategyService.ProposedScheduleDetailglobal inherited sharing class ProposedScheduleDetail The structure for information returned in the output. It will contain the Schedule and ScheduleExceptions (related to Schedule_Exception__c PSA object) for that Schedule. Properties
pse.SchedulingStrategyService.PercentAllocationRowglobal inherited sharing class PercentAllocationRow The structure for the information (startDate, endDate, percentAllocated) related to each Percent Allocation Row. Properties
pse.SchedulingStrategyService.ISchedulingStrategyglobal interface ISchedulingStrategy Common interface for the different schedule calculations. MethodsprepareScheduleProposedScheduleDetail prepareSchedule(pse.SchedulingStrategyService.ScheduleDetail scheduleDetail) pse.SchedulingStrategyService.IBulkifySchedulingStrategyglobal interface IBulkifySchedulingStrategy Common interface for the different schedule calculations in bulk. This is newly created interface to avoid packaging failure as we cannont add new method in global interface. MethodsprepareSchedulesList<ProposedScheduleDetail> prepareSchedules(List<pse.SchedulingStrategyService.ScheduleDetail> scheduleDetails) |