1 package org.kuali.ole.deliver.maintenance;
2
3 import org.apache.commons.collections.CollectionUtils;
4 import org.apache.commons.lang3.StringUtils;
5 import org.kuali.ole.deliver.bo.OleCirculationDesk;
6 import org.kuali.ole.deliver.bo.OleCirculationDeskLocation;
7 import org.kuali.rice.krad.maintenance.MaintainableImpl;
8 import org.kuali.rice.krad.maintenance.MaintenanceDocument;
9
10 import java.util.ArrayList;
11 import java.util.List;
12 import java.util.Map;
13
14
15
16
17
18
19
20
21 public class OleCirculationDeskMaintenanceImpl extends MaintainableImpl {
22
23 @Override
24 public Object retrieveObjectForEditOrCopy(MaintenanceDocument document, Map<String, String> dataObjectKeys) {
25 Object object = super.retrieveObjectForEditOrCopy(document, dataObjectKeys);
26 if (object != null && object instanceof OleCirculationDesk) {
27 OleCirculationDesk oleCirculationDesk = (OleCirculationDesk) object;
28 List<OleCirculationDeskLocation> oleCirculationDeskLocationList = new ArrayList<OleCirculationDeskLocation>();
29 List<OleCirculationDeskLocation> olePickupCirculationDeskLocations = new ArrayList<OleCirculationDeskLocation>();
30 if (CollectionUtils.isNotEmpty(oleCirculationDesk.getOleCirculationDeskLocations())) {
31 for (OleCirculationDeskLocation oleCirculationDeskLocation : oleCirculationDesk.getOleCirculationDeskLocations()) {
32 if (StringUtils.isNotBlank(oleCirculationDeskLocation.getCirculationPickUpDeskLocation())) {
33 olePickupCirculationDeskLocations.add(oleCirculationDeskLocation);
34 } else {
35 oleCirculationDeskLocationList.add(oleCirculationDeskLocation);
36 }
37 }
38 }
39 if(oleCirculationDesk.getDefaultRequestTypeId()!=null){
40 oleCirculationDesk.setDefaultRequestTypeCode(oleCirculationDesk.getDefaultRequestType().getRequestTypeCode());
41 oleCirculationDesk.setDefaultRequestType(oleCirculationDesk.getDefaultRequestType());
42 }
43 oleCirculationDesk.setOleCirculationDeskLocationList(oleCirculationDeskLocationList);
44 oleCirculationDesk.setOlePickupCirculationDeskLocations(olePickupCirculationDeskLocations);
45 }
46 return object;
47 }
48 }