BeanHelper.java
01 package com.bea.medrec.utils;
02 
03 import com.bea.medrec.beans.*;
04 import com.bea.medrec.value.Patient;
05 import com.bea.medrec.value.Prescription;
06 import com.bea.medrec.value.Record;
07 import com.bea.medrec.value.XMLImportFile;
08 import java.util.ArrayList;
09 import java.util.Collection;
10 import java.util.Iterator;
11 
12 /**
13  * This helper class converts collection of presentation beans to
14  * collection of value objects and visa versa.
15  *
16  @author Copyright (c) 2006 by BEA Systems. All Rights Reserved.
17  */
18 public class BeanHelper {
19 
20   //   I M P O R T   C O L L E C T I O N
21   /**
22    <p>Converts a collection of import value objects to
23    * a collection of import presentation beans.</p>
24    *
25    @param importFiles Collection of Import value objects
26    @return Collection   Collection of Import presentation beans
27    */
28   public static Collection toImportBeanCollection(Collection importFiles) {
29     Collection<Object> array = new ArrayList<Object>();
30     if (importFiles != null) {
31       Iterator itr = importFiles.iterator();
32       while (itr.hasNext()) {
33         XMLImportBean xmlImportBean =
34             new XMLImportBean((XMLImportFileitr.next());
35         array.add(xmlImportBean);
36       }
37     }
38     return array;
39   }
40 
41   //   P A T I E N T   A P P R O V A L
42   /**
43    <p>Converts a collection of patient approval presentation beans to
44    * a collection of patient approval value objects.</p>
45    *
46    @param patients Collection of Patient VOs
47    @return Collection   Collection of Patient Beans
48    */
49   public static Collection<Object> toPatientApprovalBeanCollection(Collection patients) {
50     Collection<Object> array = new ArrayList<Object>();
51     if (patients != null) {
52       Iterator itr = patients.iterator();
53       while (itr.hasNext()) {
54         Patient patient = (Patientitr.next();
55         PatientApprovalBean approval = new PatientApprovalBean(patient.getId(),
56             patient.getLastName(), patient.getFirstName());
57         array.add(approval);
58       }
59     }
60     return array;
61   }
62 
63 }