View Javadoc
1   package org.kuali.ole.docstore.model.bo;
2   
3   import org.junit.Test;
4   import org.kuali.ole.docstore.model.enums.DocCategory;
5   import org.kuali.ole.docstore.model.enums.DocFormat;
6   import org.kuali.ole.docstore.model.enums.DocType;
7   import org.kuali.ole.docstore.xstream.BaseTestCase;
8   import org.slf4j.Logger;
9   import org.slf4j.LoggerFactory;
10  
11  import java.util.ArrayList;
12  import java.util.List;
13  
14  /**
15   * Created with IntelliJ IDEA.
16   * User: ?
17   * Date: 1/21/13
18   * Time: 12:50 AM
19   * To change this template use File | Settings | File Templates.
20   */
21  public class OleDocument_UT extends BaseTestCase {
22      private static final Logger LOG = LoggerFactory.getLogger(OleDocument_UT.class);
23  
24      @Test
25      public void testOleDocuments() throws Exception {
26          List<OleDocument> oleDocumentList = new ArrayList<OleDocument>();
27          OleDocument oleDocument = new OleDocument();
28          oleDocument.setId("44555654ed");
29          oleDocument.setDocCategory(DocCategory.WORK);
30          oleDocument.setDocType(DocType.BIB);
31          oleDocumentList.add(oleDocument);
32  
33          WorkBibDocument workBibDocument = new WorkBibDocument();
34          List<String> formatList = new ArrayList<String>();
35          formatList.add(DocFormat.MARC.getCode());
36          formatList.add(DocFormat.DUBLIN_CORE.getCode());
37          formatList.add(DocFormat.DUBLIN_UNQUALIFIED.getCode());
38          formatList.add(DocFormat.OLEML.getCode());
39          formatList.add(DocFormat.ONIXPL.getCode());
40          formatList.add(DocFormat.PDF.getCode());
41          formatList.add(DocFormat.DOC.getCode());
42          workBibDocument.setFormats(formatList);
43          oleDocumentList.add(workBibDocument);
44  
45  
46          workBibDocument = new WorkBibDocument();
47          WorkInstanceDocument workInstanceDocument = new WorkInstanceDocument();
48          LOG.info(workInstanceDocument.toString());
49          List<WorkInstanceDocument> workInstanceDocumentList = new ArrayList<WorkInstanceDocument>();
50          WorkHoldingsDocument workHoldingsDocument = new WorkHoldingsDocument();
51          LOG.info(workHoldingsDocument.toString());
52          WorkItemDocument workItemDocument = new WorkItemDocument();
53          LOG.info(workItemDocument.toString());
54  
55  
56          List<WorkItemDocument> itemDocumentList = new ArrayList<WorkItemDocument>();
57          workHoldingsDocument.setHoldingsIdentifier("2ce77");
58          workHoldingsDocument.setLocationName("string");
59          workHoldingsDocument.setCallNumber("2232");
60  
61          workItemDocument.setItemIdentifier("7dd66");
62          workItemDocument.setCallNumber("555664");
63          workItemDocument.setLocation("string");
64          workItemDocument.setBarcode("445de");
65          itemDocumentList.add(workItemDocument);
66          workItemDocument = new WorkItemDocument();
67          workItemDocument.setItemIdentifier("5548");
68          workItemDocument.setCallNumber("44733");
69          workInstanceDocument.setInstanceIdentifier("855ud");
70          itemDocumentList.add(workItemDocument);
71          workInstanceDocument.setHoldingsDocument(workHoldingsDocument);
72          workInstanceDocument.setItemDocumentList(itemDocumentList);
73          workBibDocument.setInstanceDocument(workInstanceDocument);
74          workBibDocument.setAuthor("Leo");
75          workBibDocument.setAuthor("Martin");
76          List<String> titleList = new ArrayList<String>();
77          String title1 = "Theory in practice";
78          String title2 = "Seven Essays";
79          titleList.add(title1);
80          titleList.add(title2);
81          List<String> authorList = new ArrayList<String>();
82          String author1 = "Edmondo";
83          String author2 = "Carol";
84          authorList.add(author1);
85          authorList.add(author2);
86          workBibDocument.setTitles(titleList);
87          workBibDocument.setAuthors(authorList);
88          List<String> subjectList = new ArrayList<String>();
89          String subject1 = "subject1";
90          String subject2 = "subject2";
91          subjectList.add(subject1);
92          subjectList.add(subject2);
93          workBibDocument.setSubjects(subjectList);
94          List<String> issnList = new ArrayList<String>();
95          String issn1 = "10002";
96          String issn2 = "10003";
97          issnList.add(issn1);
98          issnList.add(issn2);
99          workBibDocument.setIssns(issnList);
100         List<String> isbnList = new ArrayList<String>();
101         isbnList.add("221001");
102         isbnList.add("221002");
103         workBibDocument.setIsbns(isbnList);
104         List<String> publicationPlacesList = new ArrayList<String>();
105         publicationPlacesList.add("A");
106         publicationPlacesList.add("X");
107         workBibDocument.setPublicationPlaces(publicationPlacesList);
108         List<String> publisherList = new ArrayList<String>();
109         publisherList.add("X");
110         publisherList.add("Y");
111         workBibDocument.setPublishers(publisherList);
112         List<String> descriptionsList = new ArrayList<String>();
113         descriptionsList.add("X");
114         descriptionsList.add("Y");
115         workBibDocument.setDescriptions(descriptionsList);
116         List<String> publicationDateList = new ArrayList<String>();
117         publicationDateList.add("2003");
118         publicationDateList.add("1997");
119         workBibDocument.setPublicationDates(publicationDateList);
120         List<String> editionsList = new ArrayList<String>();
121         editionsList.add("1");
122         editionsList.add("2");
123         workBibDocument.setEditions(editionsList);
124         List<String> formGenresList = new ArrayList<String>();
125         formGenresList.add("1");
126         formGenresList.add("2");
127         workBibDocument.setFormGenres(formGenresList);
128         List<String> languagesList = new ArrayList<String>();
129         languagesList.add("French");
130         languagesList.add("German");
131         workBibDocument.setLanguages(languagesList);
132         formatList = new ArrayList<String>();
133         formatList.add(DocFormat.MARC.getCode());
134         formatList.add(DocFormat.DUBLIN_CORE.getCode());
135         workBibDocument.setFormats(formatList);
136         oleDocumentList.add(workBibDocument);
137         workBibDocument.setTitle("Language Teaching");
138         workBibDocument.setAuthor("Ernest");
139         workBibDocument.setPublicationDate("1994");
140         workBibDocument.setIsbn("4457778");
141         workBibDocument.setPublisher("Oxford University");
142         oleDocumentList.add(workBibDocument);
143 
144 
145         workInstanceDocument = new WorkInstanceDocument();
146         workInstanceDocument.setInstanceIdentifier("77ede888");
147         workInstanceDocumentList.add(workInstanceDocument);
148         workBibDocument.setWorkInstanceDocumentList(workInstanceDocumentList);
149 
150         if (oleDocument.getDocCategory().isEqualTo("input")) {
151             LOG.info("equal");
152         }
153         if (oleDocument.getDocCategory().isEqualTo(DocCategory.WORK.getCode())) {
154             LOG.info("Category:" + DocCategory.WORK.getDescription());
155         }
156 
157         if (DocCategory.AUTHORITY.isEqualTo("authority")) {
158             LOG.info(DocCategory.AUTHORITY.getDescription());
159         }
160 
161         if (oleDocument.getDocCategory().isEqualTo(null)) {
162             LOG.info("Category:" + DocCategory.WORK.getDescription());
163         }
164         if (oleDocument.getDocType().isEqualTo("input")) {
165             LOG.info("equal");
166         }
167         if (oleDocument.getDocType().isEqualTo(DocType.BIB.getCode())) {
168             LOG.info("Type:" + DocType.BIB.getDescription());
169         }
170         if (oleDocument.getDocType().isEqualTo("bibliographic")) {
171             LOG.info("Type :" + oleDocument.getDocType().getDescription());
172         }
173         if (oleDocument.getDocType().isEqualTo(null)) {
174             LOG.info("null value");
175         }
176         if (oleDocument.getDocType().isEqualTo("rrrr")) {
177             LOG.info("invalid value");
178         }
179         OleDocument oleDocument1 = oleDocumentList.get(2);
180         LOG.info("Id:" + oleDocument1.getId());
181 
182         LOG.info("Category Code:" + oleDocument1.getDocCategory().getCode());
183         LOG.info("Category Description:" + oleDocument1.getDocCategory().getDescription());
184         LOG.info("Type Code:" + oleDocument1.getDocType().getCode());
185         LOG.info("Type Description:" + oleDocument1.getDocType().getDescription());
186         WorkBibDocument workBibDocument1 = (WorkBibDocument) oleDocument1;
187         WorkInstanceDocument workInstanceDocument1 = workBibDocument1.getInstanceDocument();
188         LOG.info("instance id:" + workInstanceDocument1.getInstanceIdentifier());
189         LOG.info("category:" + workInstanceDocument1.getDocCategory());
190 
191         LOG.info("type:" + workInstanceDocument1.getDocType());
192         WorkHoldingsDocument workHoldingsDocument1 = workInstanceDocument1.getHoldingsDocument();
193         LOG.info("Holdings identifier:" + workHoldingsDocument1.getHoldingsIdentifier());
194         LOG.info("Location:" + workHoldingsDocument1.getLocationName());
195         LOG.info("Call Number:" + workHoldingsDocument1.getCallNumber());
196         for (WorkItemDocument workItemDocument1 : workInstanceDocument1.getItemDocumentList()) {
197             LOG.info("Item Identifier:" + workItemDocument1.getItemIdentifier());
198             LOG.info("Call Number:" + workItemDocument1.getCallNumber());
199             LOG.info("Location:" + workItemDocument1.getLocation());
200             LOG.info("Barcode:" + workItemDocument1.getBarcode());
201         }
202 
203         LOG.info("Authors:");
204         for (String author : workBibDocument1.getAuthors()) {
205             LOG.info(author);
206         }
207         LOG.info("Titles:");
208         for (String title : workBibDocument1.getTitles()) {
209             LOG.info(title);
210         }
211         LOG.info("Subjects:");
212         for (String subject : workBibDocument1.getSubjects()) {
213             LOG.info(subject);
214         }
215         LOG.info("ISSNs:");
216         for (String issn : workBibDocument1.getIssns()) {
217             LOG.info(issn);
218         }
219 
220         LOG.info("ISBNs:");
221         for (String isbn : workBibDocument1.getIsbns()) {
222             LOG.info(isbn);
223         }
224         LOG.info("Publication Places:");
225         for (String publicationPlace : workBibDocument1.getPublicationPlaces()) {
226             LOG.info(publicationPlace);
227         }
228         LOG.info("Publishers:");
229         for (String publisher : workBibDocument1.getPublishers()) {
230             LOG.info(publisher);
231         }
232         LOG.info("Descriptions:");
233         for (String description : workBibDocument1.getDescriptions()) {
234             LOG.info(description);
235         }
236         LOG.info("Publication Dates:");
237         for (String publicationDate : workBibDocument1.getPublicationDates()) {
238             LOG.info(publicationDate);
239         }
240         LOG.info("Editions:");
241         for (String edition : workBibDocument1.getEditions()) {
242             LOG.info(edition);
243         }
244         LOG.info("FormGenres:");
245         for (String formGenre : workBibDocument1.getFormGenres()) {
246             LOG.info(formGenre);
247         }
248         LOG.info("Languages:");
249         for (String language : workBibDocument1.getLanguages()) {
250             LOG.info(language);
251         }
252         LOG.info("Formats:");
253         for (String format : workBibDocument1.getFormats()) {
254             LOG.info(format);
255         }
256 
257         LOG.info("WorkBibDocument2 Details:");
258         WorkBibDocument workBibDocument2 = (WorkBibDocument) oleDocumentList.get(1);
259         LOG.info("Title:" + workBibDocument2.getTitle());
260         LOG.info("Author:" + workBibDocument2.getAuthor());
261         LOG.info("Publication Date:" + workBibDocument2.getPublicationDate());
262         LOG.info("Isbn:" + workBibDocument2.getIsbn());
263         LOG.info("Publisher:" + workBibDocument2.getPublisher());
264 
265 
266         LOG.info("workInstanceDocumentList");
267         workInstanceDocument = workBibDocument.getWorkInstanceDocumentList().get(0);
268         LOG.info("Instance Identifier:" + workInstanceDocument.getInstanceIdentifier());
269 
270         WorkBibDocument workBibDocument3 = (WorkBibDocument) oleDocumentList.get(1);
271         List<String> formats = workBibDocument3.getFormats();
272         if (DocFormat.MARC.isEqualTo(formats.get(0).toString())) {
273             LOG.info("Code:" + DocFormat.MARC.getCode());
274             LOG.info("Description:" + DocFormat.MARC.getDescription());
275         }
276         if (DocFormat.DUBLIN_CORE.isEqualTo("dublin_core")) {
277             LOG.info("Description:" + DocFormat.DUBLIN_CORE.getDescription());
278         }
279         if (DocFormat.DUBLIN_UNQUALIFIED.isEqualTo(null)) {
280             LOG.info("Description:" + DocFormat.DUBLIN_UNQUALIFIED.getDescription());
281         }
282         //Added by Sundar Rajakani
283         WorkBibDocument workBibDocument4 = new WorkBibDocument();
284         workBibDocument4.setTitles(titleList);
285         LOG.info(workBibDocument4.getTitle());
286         workBibDocument4.setTitles(null);
287         workBibDocument4.setTitle(null);
288 
289         workBibDocument4.setEditions(editionsList);
290         LOG.info(workBibDocument4.getEdition());
291         workBibDocument4.setEditions(null);
292         LOG.info(workBibDocument4.getEdition());
293         workBibDocument4.setEdition(null);
294 
295         workBibDocument4.setAuthors(authorList);
296         LOG.info(workBibDocument4.getAuthor());
297         workBibDocument4.setAuthors(null);
298         workBibDocument4.setAuthor(null);
299 
300         workBibDocument4.setPublicationDates(publicationDateList);
301         LOG.info(workBibDocument4.getPublicationDate());
302         workBibDocument4.setPublicationDates(null);
303         workBibDocument4.setPublicationDate(null);
304 
305         workBibDocument4.setIsbns(isbnList);
306         LOG.info(workBibDocument4.getIsbn());
307         workBibDocument4.setIsbns(null);
308         workBibDocument4.setIsbn(null);
309 
310         workBibDocument4.setPublishers(publisherList);
311         LOG.info(workBibDocument4.getPublisher());
312         workBibDocument4.setPublishers(null);
313         workBibDocument4.setPublisher(null);
314         LOG.info(workBibDocument4.toString());
315 
316         WorkBibDocument workBibDocument5 = new WorkBibDocument();
317         workBibDocument5.setEdition("edition");
318     }
319 
320 }