Example case 1 - Updating multiple shifts

This example shows the most common method used to modify and save shifts.

Before

public List<EsShiftCDO> publishSwapShifts(List<EsShiftCDO> swapShiftCDOs) {
    List<EsShiftSummary> shiftSummaries = new ArrayList<EsShiftSummary>();
    List<EsShiftDetail> shiftDetails = new ArrayList<EsShiftDetail>();
    for (EsShiftCDO shiftCDO : swapShiftCDOs) {
        shiftCDO.getEss().setShiftsumStatus(
        EsConstants.SHIFT_STATUS_ACTIVE);
        // make more changes to a shift
        shiftSummaries.add(shiftCDO.getEss());
        shiftDetails.addAll(shiftCDO.getShiftDetails());
    }
    shiftService.updateShiftSummaries(shiftSummaries);
    shiftService.updateShiftDetails(shiftDetails);
    return swapShiftCDOs;
}

This example shows a very simple way to migrate. The new API supports operations that act directly on the EsShiftCDO objects.

After

public List<EsShiftCDO> publishSwapShifts(List<EsShiftCDO> swapShiftCDOs) {
    for (EsShiftCDO shiftCDO : swapShiftCDOs) {
        shiftCDO.getEss().setShiftsumStatus(
        EsConstants.SHIFT_STATUS_ACTIVE);
        // make more changes to a shift
    }
    flatShiftService.insertOrUpdateShiftsBatch(swapShiftCDOs);
    return swapShiftCDOs;
}