View Javadoc
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   * Created with IntelliJ IDEA.
15   * User: gopalp
16   * Date: 1/27/15
17   * Time: 2:16 PM
18   * To change this template use File | Settings | File Templates.
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              // build display file name with date and size
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  }