View Javadoc

1   package be.dvw.administration.util;
2   
3   import be.dvw.administration.model.Score;
4   import be.dvw.administration.model.Instrument;
5   
6   import java.io.FileWriter;
7   import java.io.OutputStream;
8   import java.io.IOException;
9   import java.io.OutputStreamWriter;
10  import java.util.List;
11  import java.util.Vector;
12  import java.util.Calendar;
13  
14  import org.exolab.castor.xml.Marshaller;
15  import org.exolab.castor.xml.ValidationException;
16  import org.exolab.castor.xml.MarshalException;
17  
18  
19  /***
20   * User: Toon
21   * Date: 4-jul-2005
22   * Time: 18:49:50
23   */
24  public class CastorUtils
25  {
26  
27      public static void main(String[] args) throws Exception
28      {
29          CreatePartituurList();
30          CreateInstrumentList();
31      }
32  
33      public static void CreatePartituurList() throws IOException, ValidationException, MarshalException
34      {
35          List list = new Vector();
36          Score p;
37          OutputStreamWriter writer;
38  
39          p = new Score();
40          p.setId(1);
41          p.setName("Jericho");
42          p.setComposer("Bert Appermont");
43          p.setDescription("Ferm stukske");
44          p.setPrice(100);
45          p.setBoxNumber(1);
46          list.add(p);
47          CreatePartituurXML(p);
48  
49          p = new Score();
50          p.setId(2);
51          p.setName("Absalon");
52          p.setComposer("Bert kwappermont");
53          p.setDescription("Ferm stukske");
54          p.setPrice(100);
55          p.setBoxNumber(1);
56          list.add(p);
57          CreatePartituurXML(p);
58  
59          // create a new partituur
60          writer = new FileWriter("C://tomcat//dvw-management//administratie//src//JavaSource//etc//partituurlijst-search.xml");
61          // Marshal the person object
62          Marshaller.marshal(list, writer);
63  
64          p = new Score();
65          p.setId(3);
66          p.setName("obladi, oblada");
67          p.setComposer("Bert beatlekont");
68          p.setArranger("John & Ringo");
69          p.setDescription("Ferm stukske");
70          p.setPrice(100);
71          p.setBoxNumber(2);
72          list.add(p);
73          CreatePartituurXML(p);
74  
75          // create a new partituur
76          writer = new FileWriter("C://tomcat//dvw-management//administratie//src//JavaSource//etc//partituurlijst-all.xml");
77          // Marshal the person object
78          Marshaller.marshal(list, writer);
79  
80  
81      }
82  
83      public static void CreatePartituurXML(Score p) throws IOException, ValidationException, MarshalException
84      {
85          // create a new partituur
86          String fileName = "C://tomcat//dvw-management//administratie//src//JavaSource//etc//partituur_"+p.getId()+".xml";
87          OutputStreamWriter writer = new FileWriter(fileName);
88          // Marshal the person object
89          Marshaller.marshal(p, writer);
90      }
91  
92      public static void CreateInstrumentList() throws IOException, ValidationException, MarshalException {
93           OutputStreamWriter writer;
94          List list = new Vector();
95  
96          Instrument i = new Instrument();
97          i.setId(1);
98          i.setBrand("Tama");
99          i.setType("Swingstar Drumset");
100         i.setInstrumentGroup("Percussion");
101         i.setPurchaseDate("23/10/2003");
102         i.setPurchasedFrom("ADAMS");
103         i.setPurchasedNew(true);
104         i.setPurchasePrice(2500);
105         i.setSerialNumber("123-AB-456");
106         CreateInstrumentXML(i);
107         list.add(i);
108 
109         i = new Instrument();
110         i.setId(2);
111         i.setBrand("Besson");
112         i.setType("BU-123");
113         i.setInstrumentGroup("Bugel");
114         i.setPurchaseDate("23/11/2003");
115         i.setPurchasedFrom("ADAMS");
116         i.setPurchasedNew(true);
117         i.setPurchasePrice(1500);
118         i.setSerialNumber("987-BU-654");
119         CreateInstrumentXML(i);
120         list.add(i);
121 
122       // create a new partituur
123         writer = new FileWriter("C://tomcat//dvw-management//administratie//src//JavaSource//etc//instrumentlijst-search.xml");
124         // Marshal the person object
125         Marshaller.marshal(list, writer);
126 
127         i = new Instrument();
128         i.setId(3);
129         i.setBrand("Besson");
130         i.setType("BU-124");
131         i.setInstrumentGroup("Bugel");
132         i.setPurchaseDate("23/11/2001");
133         i.setPurchasedFrom("ADAMS");
134         i.setPurchasedNew(false);
135         i.setPurchasePrice(1250);
136         i.setSerialNumber("123-AB-456");
137         CreateInstrumentXML(i);
138         list.add(i);
139 
140         // create a new partituur
141         writer = new FileWriter("C://tomcat//dvw-management//administratie//src//JavaSource//etc//instrumentlijst-all.xml");
142         // Marshal the person object
143         Marshaller.marshal(list, writer);
144     }
145 
146     public static void CreateInstrumentXML(Instrument i) throws IOException, ValidationException, MarshalException
147     {
148         // create a new partituur
149         String fileName = "C://tomcat//dvw-management//administratie//src//JavaSource//etc//instrument_"+i.getId()+".xml";
150         OutputStreamWriter writer = new FileWriter(fileName);
151         // Marshal the person object
152         Marshaller.marshal(i, writer);
153     }
154 
155 
156 
157 
158 }