1 package org.kuali.ole.batch.keyvalue;
2
3 import org.kuali.ole.gl.web.util.OriginEntryFileComparator;
4 import org.kuali.ole.select.document.service.OLEEncumberOpenRecurringOrdersService;
5 import org.kuali.ole.sys.context.SpringContext;
6 import org.kuali.rice.core.api.datetime.DateTimeService;
7 import org.kuali.rice.core.api.util.ConcreteKeyValue;
8 import org.kuali.rice.krad.keyvalues.KeyValuesBase;
9
10 import java.io.File;
11 import java.util.*;
12
13
14
15
16
17
18
19
20 public class OLEEncumberOpenRecurringOrdersValueFinder extends KeyValuesBase {
21
22 public List getKeyValues() {
23 List activeLabels = new ArrayList();
24 OLEEncumberOpenRecurringOrdersService encumberOpenRecurringOrdersService = SpringContext.getBean(OLEEncumberOpenRecurringOrdersService.class) ;
25 File[] fileList = encumberOpenRecurringOrdersService.getAllFileInBatchDirectory();
26 List<File> sortedFileList = Arrays.asList(fileList);
27 Collections.sort(sortedFileList, new OriginEntryFileComparator());
28
29 for (File file : sortedFileList) {
30 String fileName = file.getName();
31
32 Date date = new Date(file.lastModified());
33 String timeInfo = "(" + SpringContext.getBean(DateTimeService.class).toDateTimeString(date) + ")";
34 String sizeInfo = "(" + (new Long(file.length())).toString() + ")";
35 activeLabels.add(new ConcreteKeyValue(fileName, timeInfo + " " + fileName + " " + sizeInfo));
36 }
37
38 return activeLabels;
39 }
40 }