1 package org.kuali.ole.deliver.batch;
2
3 import org.apache.commons.collections.CollectionUtils;
4 import org.kuali.ole.deliver.bo.OlePatronDocument;
5 import org.kuali.ole.service.OlePatronHelperService;
6 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
7 import org.kuali.rice.kim.api.identity.IdentityService;
8 import org.kuali.rice.kim.api.identity.entity.Entity;
9 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
10 import org.kuali.rice.krad.service.KRADServiceLocator;
11
12 import java.util.List;
13
14
15
16
17
18
19
20
21 public class OLEPatronSynchronization {
22 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OLEPatronSynchronization.class);
23
24 private OlePatronHelperService olePatronHelperService;
25
26 public OlePatronHelperService getOlePatronHelperService(){
27 if(olePatronHelperService==null){
28 olePatronHelperService = GlobalResourceLoader.getService("olePatronHelperService");
29 }
30 return olePatronHelperService;
31 }
32
33 public void synchronizePatronRecords(){
34 List<OlePatronDocument> olePatronDocumentList=getOlePatronHelperService().getPatronDocumentsForBatchUpdate();
35 if(CollectionUtils.isNotEmpty(olePatronDocumentList)){
36 for(OlePatronDocument olePatronDocument:olePatronDocumentList){
37 olePatronDocument.setPatronBatchUpdate(false);
38 olePatronDocument=getOlePatronHelperService().saveEntity(olePatronDocument);
39 try {
40 KRADServiceLocator.getDataObjectService().save(olePatronDocument);
41 } catch (Exception e) {
42 LOG.error(" While save ole-patron-document" + e);
43 }
44 }
45 }
46 }
47
48 }