summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/uic/barcode/ticket/api/test/testtickets/OpenLuggageRestrictionTestTicketV3.java
blob: f14acfa2fd8a04f0d1b4cff1811f0ca8abbd4b2e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
/*
 *   This file was generated by openASN.1 - an open source ASN.1 toolkit for java
 *
 *   openASN.1 is Copyright (C) 2007 Clayton Hoss, Marc Weyland
 *
 *   openASN.1 is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as
 *   published by the Free Software Foundation, either version 3 of
 *   the License, or (at your option) any later version.
 *
 *   openASN.1 is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *   GNU Lesser General Public License for more details.
 *
 *   You should have received a copy of the GNU Lesser General Public License
 *   along with openASN.1. If not, see <http://www.gnu.org/licenses/>.
 *
 */
package org.uic.barcode.ticket.api.test.testtickets;

import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringUTF8;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfUnrestrictedLong;
import org.uic.barcode.ticket.api.asn.omv3.CardReferenceType;
import org.uic.barcode.ticket.api.asn.omv3.ControlData;
import org.uic.barcode.ticket.api.asn.omv3.CustomerStatusType;
import org.uic.barcode.ticket.api.asn.omv3.DocumentData;
import org.uic.barcode.ticket.api.asn.omv3.ExtensionData;
import org.uic.barcode.ticket.api.asn.omv3.IncludedOpenTicketType;
import org.uic.barcode.ticket.api.asn.omv3.IssuingData;
import org.uic.barcode.ticket.api.asn.omv3.LinkMode;
import org.uic.barcode.ticket.api.asn.omv3.OpenTicketData;
import org.uic.barcode.ticket.api.asn.omv3.PassengerType;
import org.uic.barcode.ticket.api.asn.omv3.RegionalValidityType;
import org.uic.barcode.ticket.api.asn.omv3.RegisteredLuggageType;
import org.uic.barcode.ticket.api.asn.omv3.RouteSectionType;
import org.uic.barcode.ticket.api.asn.omv3.SequenceOfCardReferenceType;
import org.uic.barcode.ticket.api.asn.omv3.SequenceOfCustomerStatusType;
import org.uic.barcode.ticket.api.asn.omv3.SequenceOfDocumentData;
import org.uic.barcode.ticket.api.asn.omv3.SequenceOfExtensionData;
import org.uic.barcode.ticket.api.asn.omv3.SequenceOfIncludedOpenTicketType;
import org.uic.barcode.ticket.api.asn.omv3.SequenceOfRegionalValidityType;
import org.uic.barcode.ticket.api.asn.omv3.SequenceOfRegisteredLuggageType;
import org.uic.barcode.ticket.api.asn.omv3.SequenceOfTariffType;
import org.uic.barcode.ticket.api.asn.omv3.SequenceOfTicketLinkType;
import org.uic.barcode.ticket.api.asn.omv3.SequenceOfTravelerType;
import org.uic.barcode.ticket.api.asn.omv3.SequenceOfVatDetail;
import org.uic.barcode.ticket.api.asn.omv3.StationPassageData;
import org.uic.barcode.ticket.api.asn.omv3.TariffType;
import org.uic.barcode.ticket.api.asn.omv3.TicketDetailData;
import org.uic.barcode.ticket.api.asn.omv3.TicketLinkType;
import org.uic.barcode.ticket.api.asn.omv3.TicketType;
import org.uic.barcode.ticket.api.asn.omv3.TokenType;
import org.uic.barcode.ticket.api.asn.omv3.TravelClassType;
import org.uic.barcode.ticket.api.asn.omv3.TravelerData;
import org.uic.barcode.ticket.api.asn.omv3.TravelerType;
import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData;
import org.uic.barcode.ticket.api.asn.omv3.VatDetailType;
import org.uic.barcode.ticket.api.asn.omv3.ZoneType;
import org.uic.barcode.ticket.api.asn.omv3.LuggageRestrictionType;

	public class OpenLuggageRestrictionTestTicketV3 {
		
		public static UicRailTicketData getUicTestTicket() {
			UicRailTicketData ticket = new UicRailTicketData();
	    	populateTicket(ticket);
			return ticket;
		}
		
		/*
value UicRailTicketData ::= {
  issuingDetail {
    issuingYear 2018,
    issuingDay 1,
    issuingTime 600,
    specimen TRUE,
    securePaperTicket FALSE,
    activated TRUE,
    currency "EUR",
    currencyFract 2,
    issuerPNR "issuerTestPNR",
    issuedOnLine 12
  },
  travelerDetail {
    traveler {
      {
        firstName "John",
        secondName "Dow",
        idCard "12345",
        ticketHolder TRUE,
        status {
          {
            customerStatusDescr "senior"
          }
        }
      }
    },
    groupName "myGroup"
  },
  transportDocument {
    {
      token {
        tokenProviderIA5 "VDV",
        token '82DA'H
      },
      ticket openTicket : {
        returnIncluded FALSE,
        stationCodeTable stationUIC,
        validFromDay 0,
        validUntilDay 0,
        classCode first,
        vatDetail {
          {
            country 80,
            percentage 70,
            amount 10,
            vatId "IUDGTE"
          }
        },
        infoText "openTicketInfo",
        includedAddOns {
          {
            productOwnerNum 1080,
            stationCodeTable stationUIC,
            validRegion {
              zones : {
                stationCodeTable stationUIC,
                zoneId {
                  100
                }
              }
            },
            validFromDay 0,
            validFromTime 1000,
            validUntilDay 1,
            validUntilTime 1000,
            classCode second,
            tariffs {
              {
                numberOfPassengers 2,
                passengerType adult,
                restrictedToCountryOfResidence FALSE,
                restrictedToRouteSection {
                  stationCodeTable stationUIC,
                  fromStationNum 8000001,
                  toStationNum 8010000
                }
              }
            },
            infoText "included ticket"
          }
        },
        luggage {
          maxHandLuggagePieces 2,
          maxNonHandLuggagePieces 1,
          registeredLuggage {
            {
              registrationId "IODHUV",
              maxWeight 20,
              maxSize 100
            },
            {
              registrationId "XXDHUV",
              maxWeight 21,
              maxSize 101
            }
          }
        }
      }
    },
    {
      ticket stationPassage : {
        productName "passage",
        stationCodeTable stationUIC,
        stationNameUTF8 {
          "Amsterdam"
        },
        validFromDay 0,
        validUntilDay 0,
        numberOfDaysValid 123
      }
    }
  },
  controlDetail {
    identificationByCardReference {
      {
        trailingCardIdNum 100
      }
    },
    identificationByIdCard FALSE,
    identificationByPassportId FALSE,
    passportValidationRequired FALSE,
    onlineValidationRequired FALSE,
    ageCheckRequired FALSE,
    reductionCardCheckRequired FALSE,
    infoText "cd",
    includedTickets {
      {
        referenceIA5 "UED12435867",
        issuerName "OEBB",
        issuerPNR "PNR",
        productOwnerIA5 "test",
        ticketType pass,
        linkMode onlyValidInCombination
      }
    }
  },
  extension {
    {
      extensionId "1",
      extensionData '82DA'H
    },
    {
      extensionId "2",
      extensionData '83DA'H
    }
  }
}

		*/
		

		
		public static String getEncodingHex() {
			return  	
			"7804404004B14374F3E7D72F2A9979F4A13A90086280B4001044A6F686"
			+ "E03446F770562C99B46B01106E797769DFC81DB5E51DC9BDD5C00940"
			+ "75A2560282DA1000000101E0101C4F11804281A4D5891EA450E6F706"
			+ "56E5469636B6574496E666F0140AD06021B8090020080B23E8013E81"
			+ "00B10008143D09003D1C8787B4B731B63AB232B2103A34B1B5B2BA28"
			+ "202706933E248AB58998DC1AC588922AD62864120220103B830B9B9B"
			+ "0B3B28084A0B6B9BA32B93230B696F017B4C0200805900026364015B"
			+ "85D58B118B268CDAB86CDC113D1509080E84EA409D32F3E850201620"
			+ "505B402C80A0F680";
			
		}

		
		
	    private static void populateTicket(UicRailTicketData ticket) {
	    	
	    	ticket.setControlDetail(new ControlData());
	    	populate(ticket.getControlDetail());
	    	
	     	
	    	ticket.setIssuingDetail(new IssuingData());
	    	populateIssuingData(ticket.getIssuingDetail());
	    	
	    	TravelerData td = new TravelerData();
	    	populateTravelerData(td);
	    	ticket.setTravelerDetail(td);    	
	    	
	    	SequenceOfDocumentData ds = new SequenceOfDocumentData();

	    	
	    	//OpenTicket
	    	DocumentData do1 = new DocumentData();
	    	addOpenTicketData(do1);
	    	ds.add(do1);   	    	
	    	
	    	//StationPassage
	    	DocumentData do2 = new DocumentData();    	
	    	addStationPassage(do2);
	    	ds.add(do2);   	    	
	    	
	    	ticket.setTransportDocument(ds);
	    	
	       	SequenceOfExtensionData ed = new SequenceOfExtensionData();
	    	populateExtensionSequence(ed);
	    	ticket.setExtension(ed);
	    	
		}

	    private static void addStationPassage(DocumentData dd) {
	    	TicketDetailData tdd = new TicketDetailData();
	    	StationPassageData sp = new StationPassageData();  
	    	sp.setProductName("passage");
	    	sp.setValidFromDay(0L);
	    	sp.setNumberOfDaysValid(123L);
	    	SequenceOfStringUTF8 ss = new SequenceOfStringUTF8();
	    	ss.add("Amsterdam");
	    	sp.setStationNameUTF8(ss);   	
	     	tdd.setStationPassage(sp);    	
	    	dd.setTicket(tdd);
		}

	    /*
	     * 
	     * 	    	       		   returnIncluded    FALSE
	    	        			  ,classCode         first
	    	        			  ,vatDetail {
	    	        			     { country    80
	    	        			      ,percentage 70
	    	        			      ,amount     10
	    	        			      ,vatId      "IUDGTE"
	    	        			     }
	    	        			   } 
	    	        		   	  ,infoText          "openTicketInfo"
	     */
		private static void addOpenTicketData(DocumentData dd) {
	    	TokenType to = new TokenType();
	    	to.setTokenProviderIA5("VDV");
	    	byte[] ba = { (byte) 0x82, (byte) 0xDA };
	    	to.setToken(ba);
	    	dd.setToken(to);   		
			
	    	TicketDetailData tdd = new TicketDetailData();
	    	OpenTicketData otd = new OpenTicketData();  
	    	otd.setInfoText("openTicketInfo");
	    	otd.setClassCode(TravelClassType.first);
	    	otd.setReturnIncluded(false);
	    	
	    	otd.setIncludedAddOns(new SequenceOfIncludedOpenTicketType());
	    	otd.getIncludedAddOns().add(getIncludedOpenTicket());
	    	
	    	otd.setVatDetails(new SequenceOfVatDetail());
	    	otd.getVatDetails().add(getVatDetail());
	    	
	    	otd.setLuggage(getLuggage());
	    		    		    	
	    	tdd.setOpenTicket(otd);
	    	dd.setTicket(tdd);
	    	
		}
		
		private static LuggageRestrictionType getLuggage() {
			LuggageRestrictionType l = new LuggageRestrictionType();
			l.setMaxHandLuggagePieces(2L);
			l.setMaxNonHandLuggagePieces(1L);
			l.setRegisteredLuggage(getRegisteredLuggage());
			return l;
		}

		private static SequenceOfRegisteredLuggageType getRegisteredLuggage() {
			SequenceOfRegisteredLuggageType sl = new SequenceOfRegisteredLuggageType();
			sl.add(getRegisteredLuggage1());
			sl.add(getRegisteredLuggage2());
			return sl;
		}

		private static RegisteredLuggageType getRegisteredLuggage1() {
			RegisteredLuggageType rl = new RegisteredLuggageType();
			rl.setMaxSize(100L);
			rl.setMaxWeight(20L);
			rl.setRegistrationId("IODHUV");
			return rl;
		}

		private static RegisteredLuggageType getRegisteredLuggage2() {
			RegisteredLuggageType rl = new RegisteredLuggageType();
			rl.setMaxSize(101L);
			rl.setMaxWeight(21L);
			rl.setRegistrationId("XXDHUV");
			return rl;
		}

		private static VatDetailType getVatDetail() {
			VatDetailType v = new VatDetailType();
			v.setAmount(10L);
			v.setCountry(80L);
			v.setPercentage(70L);
			v.setVatId("IUDGTE");
			return v;
		}
		
		/*
		  	          			     {  productOwnerNum  1080
	    	        			       ,validRegion { zones : { zoneId { 100 } }	    	        			      }
	    	        			       ,validFromDay 0
	    	        			       ,validFromTime 1000
	    	        			       ,validUntilDay 1
	    	        			       ,validUntilTime 1000
	    	        			       ,classCode second
	    	        			       ,tariffs  {
	    	        			         {  numberOfPassengers 2
	    	        			           ,passengerType adult
	    	        			           ,restrictedToCountryOfResidence FALSE
	    	        			           ,restrictedToRouteSection { fromStationNum 8000001 , toStationNum 8010000 }
	    	        			         }
	    	        			        }
	    	        			       ,infoText "included ticket"
	    	        			     }
		 */
		
		private static IncludedOpenTicketType getIncludedOpenTicket() {
			IncludedOpenTicketType t = new IncludedOpenTicketType();
			t.setClassCode(TravelClassType.second);
			t.setInfoText("included ticket");
			t.setProductOwnerNum(1080L);
			t.setValidRegion(new SequenceOfRegionalValidityType());
			t.getValidRegion().add(getZone());
			t.setValidFromDay(0L); 
			t.setValidFromTime(1000L);
			t.setValidUntilDay(1L);
			t.setValidUntilTime(1000L);
			t.setTariffs(new SequenceOfTariffType());
			t.getTariffs().add(getTariff());
	    	return t;
		}
		
		

	    
	    private static RegionalValidityType getZone() {
	    	
	    	RegionalValidityType r = new RegionalValidityType();
	    	ZoneType z = new ZoneType();
	    	z.setZoneId(new SequenceOfUnrestrictedLong());
	    	z.getZoneId().add(100L);
	    	r.setZones(z);
			return r;
		}

		private static void populateTravelerData(TravelerData td) {
	    	td.setGroupName("myGroup");
	    	SequenceOfTravelerType trs = new SequenceOfTravelerType();
	    	TravelerType tr = new TravelerType();
	    	tr.setIdCard("12345");
	    	tr.setFirstName("John");
	    	tr.setSecondName("Dow");
	    	tr.setTicketHolder(true);
	    	SequenceOfCustomerStatusType ts = new SequenceOfCustomerStatusType();  	
	    	CustomerStatusType cst = new CustomerStatusType();
	    	cst.setCustomerStatusDescr("senior");
	    	ts.add(cst);
	    	tr.setStatus(ts);
	    	trs.add(tr);
	    	td.setTraveler(trs);
		}

/*

 */
	    private static void populateIssuingData(IssuingData issuingDetail) {
	    	issuingDetail.setIssuingYear(2018L);
	    	issuingDetail.setIssuingDay(1L);
	    	issuingDetail.setIssuingTime(600L);
	    	issuingDetail.setIssuerPNR("issuerTestPNR");
	    	issuingDetail.setSpecimen(true);
	    	issuingDetail.setSecurePaperTicket(false);
	    	issuingDetail.setActivated(true);
	    	issuingDetail.setIssuedOnLine(12L);	
		}


	    private static void populateExtensionSequence(SequenceOfExtensionData ed) {
	       	ExtensionData ed1 = new ExtensionData();
	    	ed1.setExtensionId("1");
	    	byte[] ba1 = { (byte) 0x82, (byte) 0xDA };
	    	ed1.setExtensionData(ba1); 	
	    	ExtensionData ed2 = new ExtensionData();    	
	    	ed2.setExtensionId("2");
	    	byte[] ba2 = { (byte) 0x83, (byte) 0xDA };
	    	ed2.setExtensionData(ba2);     	
	    	ed.add(ed1);
	    	ed.add(ed2);
		}


		private static void populate(ControlData controlDetail) {
			controlDetail.infoText = "cd";
			controlDetail.setAgeCheckRequired(false);
			controlDetail.setIdentificationByIdCard(false);
			controlDetail.setIdentificationByPassportId(false);
			controlDetail.setOnlineValidationRequired(false);
			controlDetail.setPassportValidationRequired(false);
			controlDetail.setReductionCardCheckRequired(false);
			controlDetail.setIdentificationByCardReference(new SequenceOfCardReferenceType());
			controlDetail.getIdentificationByCardReference().add(populateCardRefrence());
			SequenceOfTicketLinkType sit = new SequenceOfTicketLinkType();
			populateLinkedTickets(sit);
			controlDetail.setIncludedTickets(sit);
		}

		
		/*
		 * 
		 */
		private static void populateLinkedTickets(SequenceOfTicketLinkType sequenceOfTicketLinkType) {
			TicketLinkType tlt = new TicketLinkType();
			tlt.productOwnerIA5="test";
			tlt.setTicketType(TicketType.pass);
			tlt.setIssuerPNR("PNR");
			tlt.setReferenceIA5("UED12435867");
			tlt.setLinkMode(LinkMode.onlyValidInCombination);
			tlt.setIssuerName("OEBB");
			sequenceOfTicketLinkType.add(tlt);
		}

		/*
		 {
		   trailingCardIdNum 100
		 }
		 */
		private static CardReferenceType populateCardRefrence() {
			CardReferenceType cr = new CardReferenceType();
			cr.setTrailingCardIdNum(100L);
			return cr;
		}

		private static TariffType getTariff() {
			TariffType t = new TariffType();
			t.setNumberOfPassengers(2L);
			t.setPassengerType(PassengerType.adult);
			t.setRestrictedToRouteSection(getRouteSection());
			t.setRestrictedToCountryOfResidence(false);
			return t;
		}

		private static RouteSectionType getRouteSection() {
			RouteSectionType r = new RouteSectionType();
			r.setFromStationNum(8000001L);
			r.setToStationNum(8010000L);

			return r;
		}

	}