-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCreateProjectDefProcessor.java
533 lines (516 loc) · 21.8 KB
/
CreateProjectDefProcessor.java
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
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
package decodepcode;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import java.util.logging.Logger;
import decodepcode.compares.ExtractPeopleCodeFromCompareReport;
public class CreateProjectDefProcessor extends ContainerProcessor
{
static Logger logger = Logger.getLogger(ExtractPeopleCodeFromCompareReport.class.getName());
private static class ObjTypes
{
int[] i = new int[7];
ObjTypes( int i0, int i1, int i2, int i3)
{
i[0] = i1; i[1] = i1; i[2]=i2; i[3]=i3; i[4]=0; i[5]=0; i[6]=0;
}
public int[] getObjTypes() { return i; }
}
private static ObjTypes getObjectTypesFromPCodeType( int pcType)
{
if (pcType== 8 ) return new ObjTypes( 1 , 2 , 12 , 0 );
if (pcType== 9 ) return new ObjTypes( 3 , 4 , 5 , 12 );
if (pcType==39 ) return new ObjTypes( 60, 12 , 0 , 0 );
if (pcType==40 ) return new ObjTypes( 60, 87 , 12 , 0 );
if (pcType==43 ) return new ObjTypes( 66, 77 , 78 , 12 );
//if (pcType==43 ) return new ObjTypes( 66, 77 , 39 , 20 );
if (pcType==42 ) return new ObjTypes( 74, 12 , 0 , 0 );
if (pcType==44 ) return new ObjTypes( 9 , 12 , 0 , 0 );
if (pcType==46 ) return new ObjTypes( 10, 39 , 12 , 0 );
if (pcType==47 ) return new ObjTypes( 10, 39 , 1 , 12 );
if (pcType==48 ) return new ObjTypes( 10, 39 , 1 , 2 );
return null;
}
public static int[] getObjTypesFromPCType( int pcType, String[] keys)
{
if (pcType == 58) // App Package Pcode - check number of keys
{
if (keys[1] == null || keys[2].trim().length() == 0) return new int[] { 104,107,0,0 };
if (keys[1] == null || keys[2].trim().length() == 0) return new int[] { 104,105,107,0 };
return new int[] { 104,105,106,107 };
}
ObjTypes o = getObjectTypesFromPCodeType(pcType);
if (o == null)
return null;
return o.getObjTypes();
}
static private String fill( int l)
{
String s= "";
for (int i=0; i<l; i++)
s+= " ";
return s;
}
static class BarePTobject implements PeopleToolsObject
{
int[] objTypes;
String[] objValues;
int type;
public BarePTobject( PeopleCodeObject o ) {
type = o.getPeopleCodeType();
objTypes = new int[4];
objValues = new String[4];
if (o.getKeyTypes() != null)
{
if (type == 43) // app engine- cram 7 keys into 4
{
objValues[0] = o.getKeys()[0];
objValues[1] =
(o.getKeys()[1].length() < 8? o.getKeys()[1]+" "
: o.getKeys()[1].substring(0,8))
+ o.getKeys()[2] +o.getKeys()[3] +" " + o.getKeys()[4];
objValues[2] = o.getKeys()[5];
objValues[3] = o.getKeys()[6];
objTypes = new int[] {66, 77 , 78 , 12 };
}
else
if (type == 48 ) //Component Rec Fld PeopleCode
{
objValues[0] = o.getKeys()[0];
objValues[1] = o.getKeys()[1];
objValues[2] = o.getKeys()[2];
objValues[3] = o.getKeys()[3] + fill(29 - o.getKeys()[3].length() - o.getKeys()[4].length()) + o.getKeys()[4];
objTypes = new int[] {10, 39 , 1 , 2 };
}
else
for (int i = 0; i < 4; i++)
{
String k = o.getKeys()[i];
if (k != null && k.trim().length() > 0)
{
objTypes[i] = o.getKeyTypes()[i];
objValues[i] = k;
}
}
}
else
logger.severe("No key types?? "+ o);
}
public int[] getKeyTypes() {
return objTypes;
}
public String[] getKeys() {
return objValues;
}
public String getLastChangedBy() {
return null;
}
public Date getLastChangedDtTm() {
return null;
}
public int getPeopleCodeType() {
return type;
}
public String getSource() {
return null;
}
@Override
public boolean equals( Object o1)
{
BarePTobject o = (BarePTobject) o1;
return type == o.type
&& objValues[0].equals(o.objValues[0])
&& objValues[1].equals(o.objValues[1])
&& objValues[2].equals(o.objValues[2])
&& objValues[3].equals(o.objValues[3]);
}
public String toString()
{
return objValues[0] + "," +objValues[1] + "," +objValues[2] + "," +objValues[3];
}
}
Set<BarePTobject> list;
File projectToCreate;
SimpleDateFormat df;
String projName;
boolean onlyProjectItems;
File sqlFileToCreate;
String stripExtension( String s)
{
int i = s.indexOf(".");
return (i < 0)? s: s.substring(0, i);
}
public CreateProjectDefProcessor( File _projectToCreate, boolean _onlyProjectItems)
{
projectToCreate= _projectToCreate;
onlyProjectItems = _onlyProjectItems;
projName = stripExtension(projectToCreate.getName()).toUpperCase();
sqlFileToCreate = new File(projectToCreate.getParent(), projName + ".sql");
df = new SimpleDateFormat("yyyy-MM-dd-HH.mm.ss.000000");
}
@Override
public void aboutToProcess()
{
list = new HashSet<BarePTobject>();
}
@Override
public void finishedProcessing()
{
try
{
PrintWriter p = new PrintWriter(projectToCreate),
p2 = new PrintWriter(sqlFileToCreate);
if (!onlyProjectItems)
{
p.println("<?xml version='1.0'?>");
p.println(" <!--Warning : Don't edit this file -->");
p.println(" <instance class=\"PJM\">");
p.println(" <rowset name=\"PjmDefn\" size=\"1628\" count=\"1\">");
p.println(" <row>");
p.println(" <szLastUpdDttm>" + df.format(new Date()) + "</szLastUpdDttm>");
p.println(" <szLastUpdOprId>" + System.getProperty("user.name").substring(0,6)+ "</szLastUpdOprId>");
p.println(" <szObjectOwnerID></szObjectOwnerID>");
p.println(" <nUseCount>1</nUseCount>");
p.println(" <bUseUpdate>1</bUseUpdate>");
p.println(" <lVersion>231</lVersion>");
p.println(" <lSwapVersion>0</lSwapVersion>");
p.println(" <nSwapNum>0</nSwapNum>");
p.println(" <szProjectName>" + projName + "</szProjectName>");
p.println(" <szLanguageCd>ENG</szLanguageCd>");
p.println(" <szProjectDescr></szProjectDescr>");
p.println(" <szTgtServerName></szTgtServerName>");
p.println(" <szTgtDBName></szTgtDBName>");
p.println(" <szTgtOprId></szTgtOprId>");
p.println(" <fReportFilter>16232832</fReportFilter>");
p.println(" <eTargetOrientation>0</eTargetOrientation>");
p.println(" <eCompareType>1</eCompareType>");
p.println(" <fKeepTgt>31</fKeepTgt>");
p.println(" <nCommitLimit>50</nCommitLimit>");
p.println(" <szCompRelease></szCompRelease>");
p.println(" <szCompRelDttm></szCompRelDttm>");
p.println(" <bMaintenanceProject>0</bMaintenanceProject>");
p.println(" <bUseDbFieldNameAttrib>0</bUseDbFieldNameAttrib>");
p.println(" <szReleaseLabel></szReleaseLabel>");
p.println(" <szReleaseDttm></szReleaseDttm>");
p.println(" <nDescrLongLen>0</nDescrLongLen>");
p.println(" <hDescrLong>HANDLE</hDescrLong>");
p.println(" <nProjectCount>1</nProjectCount>");
p.println(" <lpPit> POINTER");
}
p.println(" <rowset name=\"PjmPit\" size=\"" + (list.size() * 296) + "\" count=\"" + list.size() + "\">");
for (BarePTobject o: list)
{
p.println(" <row>");
p.println(" <eObjectType>" + o.getPeopleCodeType() + "</eObjectType>");
p.println(" <szObjectValue_0>" + o.getKeys()[0] + "</szObjectValue_0>");
p.println(" <szObjectValue_1>" + (o.getKeys()[1] == null? " " : o.getKeys()[1]) + "</szObjectValue_1>");
p.println(" <szObjectValue_2>" + (o.getKeys()[2] == null? " " : o.getKeys()[2]) + "</szObjectValue_2>");
p.println(" <szObjectValue_3>" + (o.getKeys()[3] == null? " " : o.getKeys()[3]) + "</szObjectValue_3>");
p.println(" <eObjectID_0>" + o.getKeyTypes()[0] + "</eObjectID_0>");
p.println(" <eObjectID_1>" + o.getKeyTypes()[1] + "</eObjectID_1>");
p.println(" <eObjectID_2>" + o.getKeyTypes()[2] + "</eObjectID_2>");
p.println(" <eObjectID_3>" + o.getKeyTypes()[3] + "</eObjectID_3>");
p.println(" <bExecute>0</bExecute>");
p.println(" <eSourceStatus>0</eSourceStatus>");
p.println(" <eTargetStatus>0</eTargetStatus>");
p.println(" <eUpgradeAction>0</eUpgradeAction>");
p.println(" <bTakeAction>1</bTakeAction>");
p.println(" <bCopyDone>0</bCopyDone>");
p.println(" <eRowStatus>3</eRowStatus>");
p.println(" </row>");
p2.println("INSERT INTO \"PSPROJECTITEM\" (PROJECTNAME,OBJECTTYPE,OBJECTID1,OBJECTVALUE1,OBJECTID2,OBJECTVALUE2,OBJECTID3,OBJECTVALUE3,OBJECTID4,OBJECTVALUE4,NODETYPE,SOURCESTATUS,TARGETSTATUS,UPGRADEACTION,TAKEACTION,COPYDONE) VALUES (");
p2.print("\t'"+ projName + "',"); // PROJECTNAME
p2.print("'" + o.getPeopleCodeType() + "',"); // OBJECTTYPE
p2.print( o.getKeyTypes()[0] + ","); // OBJECTID1
p2.print("'" + (o.getKeys()[0] == null? " " : o.getKeys()[0]) + "',"); // OBJECTVALUE1
p2.print( o.getKeyTypes()[1] + ","); // OBJECTID2
p2.print("'" + (o.getKeys()[1] == null? " " : o.getKeys()[1]) + "',"); // OBJECTVALUE2
p2.print( o.getKeyTypes()[2] + ","); // OBJECTID3
p2.print("'" + (o.getKeys()[2] == null? " " : o.getKeys()[2]) + "',"); // OBJECTVALUE3
p2.print( o.getKeyTypes()[3] + ","); // OBJECTID4
p2.print("'" + (o.getKeys()[3] == null? " " : o.getKeys()[3]) + "',"); // OBJECTVALUE3
p2.print("0,"); // NODETYPE
p2.print("0,"); // SOURCESTATUS
p2.print("0,"); // TARGETSTATUS
p2.print("0,"); // UPGRADEACTION
p2.print("1,"); // TAKEACTION
p2.println("0);"); // COPYDONE
}
p.println(" </rowset>");
if (!onlyProjectItems) {
p.println(" </lpPit>");
p.println(" <bCopyAllSec>1</bCopyAllSec>");
p.println(" <bCompAllSec>1</bCompAllSec>");
p.println(" <nSecCount>54</nSecCount>");
p.println(" <lpSec> POINTER");
p.println(" <rowset name=\"PjmSec\" size=\"1080\" count=\"54\">");
p.println(" <row>");
p.println(" <eProcessType>0</eProcessType>");
p.println(" <szSectionName>COMMON</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>0</eProcessType>");
p.println(" <szSectionName>ARA</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>0</eProcessType>");
p.println(" <szSectionName>CFR</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>0</eProcessType>");
p.println(" <szSectionName>CZE</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>0</eProcessType>");
p.println(" <szSectionName>DAN</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>0</eProcessType>");
p.println(" <szSectionName>DUT</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>0</eProcessType>");
p.println(" <szSectionName>ENG</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>0</eProcessType>");
p.println(" <szSectionName>ESP</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>0</eProcessType>");
p.println(" <szSectionName>FIN</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>0</eProcessType>");
p.println(" <szSectionName>FRA</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>0</eProcessType>");
p.println(" <szSectionName>GER</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>0</eProcessType>");
p.println(" <szSectionName>GRK</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>0</eProcessType>");
p.println(" <szSectionName>HEB</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>0</eProcessType>");
p.println(" <szSectionName>HUN</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>0</eProcessType>");
p.println(" <szSectionName>ITA</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>0</eProcessType>");
p.println(" <szSectionName>JPN</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>0</eProcessType>");
p.println(" <szSectionName>KOR</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>0</eProcessType>");
p.println(" <szSectionName>MAY</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>0</eProcessType>");
p.println(" <szSectionName>NOR</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>0</eProcessType>");
p.println(" <szSectionName>POL</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>0</eProcessType>");
p.println(" <szSectionName>POR</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>0</eProcessType>");
p.println(" <szSectionName>RUS</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>0</eProcessType>");
p.println(" <szSectionName>SVE</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>0</eProcessType>");
p.println(" <szSectionName>THA</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>0</eProcessType>");
p.println(" <szSectionName>TUR</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>0</eProcessType>");
p.println(" <szSectionName>ZHS</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>0</eProcessType>");
p.println(" <szSectionName>ZHT</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>2</eProcessType>");
p.println(" <szSectionName>COMMON</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>2</eProcessType>");
p.println(" <szSectionName>ARA</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>2</eProcessType>");
p.println(" <szSectionName>CFR</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>2</eProcessType>");
p.println(" <szSectionName>CZE</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>2</eProcessType>");
p.println(" <szSectionName>DAN</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>2</eProcessType>");
p.println(" <szSectionName>DUT</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>2</eProcessType>");
p.println(" <szSectionName>ENG</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>2</eProcessType>");
p.println(" <szSectionName>ESP</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>2</eProcessType>");
p.println(" <szSectionName>FIN</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>2</eProcessType>");
p.println(" <szSectionName>FRA</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>2</eProcessType>");
p.println(" <szSectionName>GER</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>2</eProcessType>");
p.println(" <szSectionName>GRK</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>2</eProcessType>");
p.println(" <szSectionName>HEB</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>2</eProcessType>");
p.println(" <szSectionName>HUN</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>2</eProcessType>");
p.println(" <szSectionName>ITA</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>2</eProcessType>");
p.println(" <szSectionName>JPN</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>2</eProcessType>");
p.println(" <szSectionName>KOR</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>2</eProcessType>");
p.println(" <szSectionName>MAY</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>2</eProcessType>");
p.println(" <szSectionName>NOR</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>2</eProcessType>");
p.println(" <szSectionName>POL</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>2</eProcessType>");
p.println(" <szSectionName>POR</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>2</eProcessType>");
p.println(" <szSectionName>RUS</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>2</eProcessType>");
p.println(" <szSectionName>SVE</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>2</eProcessType>");
p.println(" <szSectionName>THA</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>2</eProcessType>");
p.println(" <szSectionName>TUR</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>2</eProcessType>");
p.println(" <szSectionName>ZHS</szSectionName>");
p.println(" </row>");
p.println(" <row>");
p.println(" <eProcessType>2</eProcessType>");
p.println(" <szSectionName>ZHT</szSectionName>");
p.println(" </row>");
p.println(" </rowset>");
p.println(" </lpSec>");
p.println(" <nIncCount>0</nIncCount>");
p.println(" <lpInc>POINTER</lpInc>");
p.println(" <nDepCount>0</nDepCount>");
p.println(" <lpDep>POINTER</lpDep>");
p.println(" <nLangCount>0</nLangCount>");
p.println(" <hLang>HANDLE</hLang>");
p.println(" </row>");
p.println(" </rowset>");
p.println(" </instance>");
p.println("");
p.println("");
}
p.close();
p2.close();
logger.info("Created " + projectToCreate + "\n and " + sqlFileToCreate +"\n ("+ list.size() + " object(s))");
}
catch (Exception ex) {
ex.printStackTrace();
logger.severe(ex.getMessage());
}
}
@Override
public void process(PeopleCodeObject c) throws IOException {
BarePTobject c1 = new BarePTobject(c);
if (c1.getKeyTypes() != null)
list.add(c1);
}
@Override
public void processSQL(SQLobject sql) throws IOException {
// TODO Auto-generated method stub
}
@Override
public void processCONT(CONTobject cont) throws IOException {
// TODO Auto-generated method stub
}
public static void main( String[] a)
{
try {
ContainerProcessor processor = new CreateProjectDefProcessor( new File("c:\\temp\\UPGCUST.items"), true);
new ExtractPeopleCodeFromCompareReport().
processPeopleCodeFromTree( new File("C:\\projects\\sandbox\\PeopleCode\\compare_reports\\UPGCUST"),
processor, ExtractPeopleCodeFromCompareReport.PROCESS_SOURCE_PCODE);
} catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}
}
}