1 package ejava.projects.edmv.xml;
2
3 import info.ejava.projects.edmv._1.Dmv;
4 import info.ejava.projects.edmv._1.PersonsType;
5 import info.ejava.projects.edmv._1.VehicleRegistrationsType;
6
7 import java.math.BigDecimal;
8 import java.util.ArrayList;
9 import java.util.List;
10
11 import javax.xml.datatype.DatatypeFactory;
12 import javax.xml.datatype.XMLGregorianCalendar;
13
14 import gov.ojp.it.jxdm._3_0.AddressType;
15 import gov.ojp.it.jxdm._3_0.DecalType;
16 import gov.ojp.it.jxdm._3_0.IDType;
17 import gov.ojp.it.jxdm._3_0.ImageType;
18 import gov.ojp.it.jxdm._3_0.Person;
19 import gov.ojp.it.jxdm._3_0.PersonHeightMeasureType;
20 import gov.ojp.it.jxdm._3_0.PersonNameTextType;
21 import gov.ojp.it.jxdm._3_0.PersonNameType;
22 import gov.ojp.it.jxdm._3_0.PersonPhysicalDetailsType;
23 import gov.ojp.it.jxdm._3_0.PersonWeightMeasureType;
24 import gov.ojp.it.jxdm._3_0.ReferenceType;
25 import gov.ojp.it.jxdm._3_0.ResidenceType;
26 import gov.ojp.it.jxdm._3_0.StreetType;
27 import gov.ojp.it.jxdm._3_0.TextType;
28 import gov.ojp.it.jxdm._3_0.VehicleRegistration;
29 import gov.ojp.it.jxdm._3_0.VehicleType;
30 import gov.ojp.it.jxdm._3_0_3.proxy.ncic_2000._1_0.EYEType;
31 import gov.ojp.it.jxdm._3_0_3.proxy.ncic_2000._1_0.RACType;
32 import gov.ojp.it.jxdm._3_0_3.proxy.ncic_2000._1_0.SEXType;
33 import gov.ojp.it.jxdm._3_0_3.proxy.ncic_2000._1_0.VCOType;
34 import gov.ojp.it.jxdm._3_0_3.proxy.ncic_2000._1_0.VMAType;
35 import gov.ojp.it.jxdm._3_0_3.proxy.ncic_2000._1_0.VMOType;
36 import gov.ojp.it.jxdm._3_0_3.proxy.usps_states._1.USStateCodeType;
37 import gov.ojp.it.jxdm._3_0_3.proxy.xsd._1.Base64Binary;
38 import gov.ojp.it.jxdm._3_0_3.proxy.xsd._1.Date;
39 import gov.ojp.it.jxdm._3_0_3.proxy.xsd._1.GMonth;
40 import gov.ojp.it.jxdm._3_0_3.proxy.xsd._1.GYear;
41
42 public class SampleGen {
43 private static int residenceId = 0;
44 private static int personId = 0;
45 private static int vehicleId = 0;
46
47 public Dmv createDmv() throws Exception {
48 Dmv dmv = new Dmv();
49 dmv.setPeople(new PersonsType());
50 dmv.setVehicleRegistrations(new VehicleRegistrationsType());
51
52 Person person = createPerson("John", "C", "Doe", null);
53 dmv.getPeople().getPerson().add(person);
54 dmv.getVehicleRegistrations().getVehicleRegistration().add(
55 createVehicleRegistration(person));
56
57 return dmv;
58 }
59
60 public Person createPerson(String first, String middle, String last,
61 String suffix) throws Exception {
62 Person person = new Person();
63 person.setId("p" + ++personId);
64 person.setSourceIDText("" + personId);
65
66
67
68
69
70
71
72
73
74 person.setPersonName(new PersonNameType(new PersonNameTextType(first,
75 null, null), new PersonNameTextType(middle, null, null),
76 new PersonNameTextType(last, null, null), new TextType(suffix,
77 null, null)));
78
79 DatatypeFactory dtf = DatatypeFactory.newInstance();
80 XMLGregorianCalendar cal = dtf.newXMLGregorianCalendar();
81 cal.setYear(1960);
82 cal.setMonth(01);
83 cal.setDay(03);
84 person.setPersonBirthDate(new Date());
85 person.getPersonBirthDate().setValue(cal);
86
87 person.setPersonPhysicalDetails(new PersonPhysicalDetailsType(
88 new EYEType("green", null, null), new TextType("brown", null,
89 null), new PersonHeightMeasureType(new BigDecimal(72)),
90 new PersonWeightMeasureType(new BigDecimal(220)), new RACType(
91 "blue", null, null), new SEXType("male", null, null),
92 new ImageType(null, null, new Base64Binary(
93 new byte[] { 0x00, 0x01, 0x02 }, null, null))));
94
95 ResidenceType homeAddress = new ResidenceType(null, null,
96 new AddressType(new StreetType(new TextType("500", null, null),
97 new TextType("Foo Bar Street", null, null)),
98 new TextType("Baz City", null, null),
99 new USStateCodeType("MD", null, null), new IDType(
100 new TextType("21000", null, null))),
101 null, null
102 );
103 cal = dtf.newXMLGregorianCalendar();
104 cal.setYear(2000);
105 cal.setMonth(1);
106 cal.setDay(1);
107 homeAddress.setResidenceStartDate(new Date());
108 homeAddress.getResidenceStartDate().setValue(cal);
109
110 cal = dtf.newXMLGregorianCalendar();
111 cal.setYear(2005);
112 cal.setMonth(12);
113 cal.setDay(31);
114 homeAddress.setResidenceEndDate(new Date());
115 homeAddress.getResidenceEndDate().setValue(cal);
116
117 homeAddress.setSourceIDText("" + ++residenceId);
118
119 person.getResidence().add(homeAddress);
120
121 return person;
122 }
123
124 public VehicleRegistration createVehicleRegistration(Person owner) throws Exception {
125 List<ReferenceType> owners = new ArrayList<ReferenceType>();
126 owners.add(new ReferenceType(owner));
127
128 VehicleRegistration registration = new VehicleRegistration(
129 null,
130 null,
131 new IDType(new TextType("12345678", null, null)),
132 new DecalType(null, null,
133 new GMonth(), new GYear()),
134 new VehicleType(null, null,
135 owners,
136 new IDType(new TextType("vin123", null, null)),
137 new VCOType("RED", null, null),
138 new VMAType("FORD", null, null),
139 new VMOType("BRONCOII", null, null),
140 new GYear())
141 );
142 DatatypeFactory dtf = DatatypeFactory.newInstance();
143 XMLGregorianCalendar cal = dtf.newXMLGregorianCalendar();
144 cal.setMonth(01);
145 registration.getVehicleRegistrationDecal().getDecalMonthDate().setValue(cal);
146
147 cal = dtf.newXMLGregorianCalendar();
148 cal.setYear(2006);
149 registration.getVehicleRegistrationDecal().getDecalYearDate().setValue(cal);
150
151 cal = dtf.newXMLGregorianCalendar();
152 cal.setYear(1996);
153 registration.getVehicle().getVehicleModelYearDate().setValue(cal);
154
155 registration.setId("vr" + ++vehicleId);
156 registration.setSourceIDText("" + vehicleId);
157
158 return registration;
159 }
160 }