View Javadoc

1   package org.kuali.ole.sys.batch;
2   
3   import java.util.ArrayList;
4   import java.util.HashMap;
5   import java.util.List;
6   import java.util.Map;
7   
8   /**
9    * This class represents a full file which can be separated into a number of logical files, each logical file
10   * holding its own set of errors, warnings, and informative messages for post-processing 
11   */
12  public class PhysicalFlatFileInformation {
13      private String fileName;
14      private List<String[]> messages;
15      private List<FlatFileInformation> flatFileInfomationList;
16      
17      /**
18       * Constructs a PhysicalFlatFileInformation
19       * @param fileName the name of the file this encapsulates
20       */
21      public PhysicalFlatFileInformation(String fileName) {
22          this.fileName = fileName;
23          messages = new ArrayList<String[]>();
24          flatFileInfomationList = new ArrayList<FlatFileInformation>();
25      }
26      
27      public void addFileErrorMessages(List<String> messages) {
28          for(String message : messages) {
29              this.messages.add(new String[] { FlatFileTransactionInformation.getEntryTypeString(FlatFileTransactionInformation.EntryType.ERROR), message });
30          }
31      }
32      
33      /**
34       * Adds an error message applicable to the entire file
35       * @param message
36       */
37      public void addFileErrorMessage(String message) {
38          this.messages.add(new String[] { FlatFileTransactionInformation.getEntryTypeString(FlatFileTransactionInformation.EntryType.ERROR), message });
39      }
40      
41      public void addFileInfoMessage(List<String> messages) {
42          for(String message : messages) {
43              this.messages.add(new String[] { FlatFileTransactionInformation.getEntryTypeString(FlatFileTransactionInformation.EntryType.INFO), message });
44          }
45      }
46  
47      /**
48       * Adds an informative message applicable to the entire file
49       * @param message
50       */
51      public void addFileInfoMessage(String message) {
52          this.messages.add(new String[] { FlatFileTransactionInformation.getEntryTypeString(FlatFileTransactionInformation.EntryType.INFO), message });
53      }
54  
55      /**
56       * @return the file name of the physical file encapsulated in this PhysicalFlatFileInformation object
57       */
58      public String getFileName() {
59          return fileName;
60      }
61  
62      /**
63       * Sets the file name of the physical file encapsulated in this PhysicalFlatFileInformation object
64       * @param fileName the file name of the physical file encapsulated in this PhysicalFlatFileInformation object
65       */
66      public void setFileName(String fileName) {
67          this.fileName = fileName;
68      }
69  
70      /**
71       * @return a List of all messages associated with the physical file as a whole
72       */
73      public List<String[]> getMessages() {
74          return messages;
75      }
76      
77      public String getAllMessages() {
78          StringBuffer message = new StringBuffer();
79          for(String[] resultMessage : getMessages()) {
80              message.append(resultMessage[1]);
81              message.append("\n");
82          }
83          return message.toString();
84      }
85      
86      /**
87       * Sets a List of messages associated with the physical file as a whole
88       * @param messages a List of messages
89       */
90      public void setMessages(List<String[]> messages) {
91          this.messages = messages;
92      }
93  
94  
95      /**
96       * @return a List of the FlatFileInformation objects, each representing a logical file within this physical file
97       */
98      public List<FlatFileInformation> getFlatFileInfomationList() {
99          return flatFileInfomationList;
100     }
101 
102 
103     /**
104      * Sets the List of FlatFileInformation objects, each representing a logical file within the encapsulated physical file
105      * @param flatFileInfomationList
106      */
107     public void setFlatFileInfomationList(List<FlatFileInformation> flatFileInfomationList) {
108         this.flatFileInfomationList = flatFileInfomationList;
109     }
110 }