KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencrx > kernel > tools > CheckDb


1 /*
2  * ====================================================================
3  * Project: opencrx, http://www.opencrx.org/
4  * Name: $Id: CheckDb.java,v 1.4 2006/04/02 23:50:20 wfro Exp $
5  * Description: Convert database RID columns from numeric to string format
6  * Revision: $Revision: 1.4 $
7  * Owner: CRIXP AG, Switzerland, http://www.crixp.com
8  * Date: $Date: 2006/04/02 23:50:20 $
9  * ====================================================================
10  *
11  * This software is published under the BSD license
12  * as listed below.
13  *
14  * Copyright (c) 2004-2005, CRIXP Corp., Switzerland
15  * All rights reserved.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions
19  * are met:
20  *
21  * * Redistributions of source code must retain the above copyright
22  * notice, this list of conditions and the following disclaimer.
23  *
24  * * Redistributions in binary form must reproduce the above copyright
25  * notice, this list of conditions and the following disclaimer in
26  * the documentation and/or other materials provided with the
27  * distribution.
28  *
29  * * Neither the name of CRIXP Corp. nor the names of the contributors
30  * to openCRX may be used to endorse or promote products derived
31  * from this software without specific prior written permission
32  *
33  *
34  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
35  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
36  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
37  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
39  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
40  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
41  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
42  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
43  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
45  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
46  * POSSIBILITY OF SUCH DAMAGE.
47  *
48  * ------------------
49  *
50  * This product includes software developed by the Apache Software
51  * Foundation (http://www.apache.org/).
52  *
53  * This product includes software developed by contributors to
54  * openMDX (http://www.openmdx.org/)
55  */

56 package org.opencrx.kernel.tools;
57
58 import java.math.BigInteger JavaDoc;
59 import java.sql.Connection JavaDoc;
60 import java.sql.DriverManager JavaDoc;
61 import java.sql.PreparedStatement JavaDoc;
62 import java.sql.ResultSet JavaDoc;
63 import java.sql.ResultSetMetaData JavaDoc;
64 import java.sql.SQLException JavaDoc;
65 import java.util.ArrayList JavaDoc;
66 import java.util.HashMap JavaDoc;
67 import java.util.HashSet JavaDoc;
68 import java.util.Iterator JavaDoc;
69 import java.util.List JavaDoc;
70 import java.util.Map JavaDoc;
71 import java.util.Set JavaDoc;
72
73 import javax.naming.Context JavaDoc;
74 import javax.naming.InitialContext JavaDoc;
75 import javax.naming.NamingException JavaDoc;
76
77 import org.openmdx.base.exception.ServiceException;
78 import org.openmdx.base.text.conversion.Base64;
79 import org.openmdx.base.text.conversion.UUIDConversion;
80 import org.openmdx.compatibility.base.exception.StackedException;
81 import org.openmdx.compatibility.base.naming.Path;
82 import org.openmdx.kernel.exception.BasicException;
83 import org.openmdx.uses.java.util.UUID;
84
85 public class CheckDb {
86
87     //---------------------------------------------------------------------------
88
static Path getReference(
89         Connection JavaDoc conn,
90         long referenceId,
91         String JavaDoc refTableName
92     ) throws ServiceException {
93         PreparedStatement JavaDoc ps = null;
94         String JavaDoc statement = null;
95         ResultSet JavaDoc rs = null;
96         Path reference = null;
97         try {
98             List JavaDoc statementParameters = new ArrayList JavaDoc();
99             ps = conn.prepareStatement(
100                 statement = "SELECT * FROM " + refTableName + " WHERE (object_rid = ?)"
101             );
102             ps.setLong(
103                 1,
104                 referenceId
105             );
106             statementParameters.add(new Long JavaDoc(referenceId));
107             rs = ps.executeQuery();
108             if(rs.next()) {
109                 int n = rs.getInt("n");
110                 reference = new Path("");
111                 for(int i = 0; i < n; i++) {
112                     reference = reference.add(
113                         rs.getString("c$" + i)
114                     );
115                 }
116             }
117             else {
118                 return null;
119             }
120         }
121         catch(SQLException JavaDoc ex) {
122             throw new ServiceException(
123               ex,
124               StackedException.DEFAULT_DOMAIN,
125               StackedException.MEDIA_ACCESS_FAILURE,
126               new BasicException.Parameter[]{
127                 new BasicException.Parameter("reference", reference),
128                 new BasicException.Parameter("statement", statement)
129               },
130               null
131             );
132         }
133         catch(Exception JavaDoc ex) {
134             throw new ServiceException(
135               ex,
136               StackedException.DEFAULT_DOMAIN,
137               StackedException.GENERIC,
138               null,
139               ex.toString()
140             );
141         }
142         finally {
143             try {
144               if(rs != null) rs.close();
145             } catch(Throwable JavaDoc ex) {}
146             try {
147               if(ps != null) ps.close();
148             } catch(Throwable JavaDoc ex) {}
149         }
150         return reference;
151     }
152
153     //---------------------------------------------------------------------------
154
/**
155      * Convert s from UUID to UID. Return s if it is not an UUID.
156      */

157     private static String JavaDoc convertPathComponent(
158         String JavaDoc s
159     ) {
160         if((s.length() == 36) && ('-' == s.charAt(8)) && ('-' == s.charAt(13)) && ('-' == s.charAt(18)) && ('-' == s.charAt(23))) {
161             UUID uuid = UUIDConversion.fromString(s);
162             return UUIDConversion.toUID(uuid);
163         }
164         // (deprecated) openMDX ID format
165
else if(s.length() == 46) {
166             try {
167                 return Base64.encode(new BigInteger JavaDoc(s).toByteArray()).substring(0, 26).replace('/', '-');
168             }
169             catch(Exception JavaDoc e) {
170                 return s;
171             }
172         }
173         else {
174             return s;
175         }
176     }
177     
178     //---------------------------------------------------------------------------
179
private static String JavaDoc convertRid(
180         Connection JavaDoc conn,
181         String JavaDoc dbObject,
182         String JavaDoc columnName,
183         String JavaDoc rid,
184         Path[] types,
185         String JavaDoc[] typeNames,
186         Map JavaDoc referencesInError
187     ) throws ServiceException {
188         String JavaDoc namespace = dbObject.substring(0, dbObject.indexOf("_"));
189         String JavaDoc refTableName = namespace + "_REF";
190         Path reference = getReference(
191             conn,
192             Long.parseLong(rid),
193             refTableName
194         );
195         if(reference != null) {
196             String JavaDoc convertedRid = null;
197             for(
198                 int k = 0;
199                 k < types.length;
200                 k++
201             ) {
202                 Path type = types[k];
203                 if((type.size() >= 2) && reference.isLike(type.getParent())) {
204                     convertedRid = typeNames[k];
205                     if(convertedRid == null) {
206                         System.out.println("ERROR: No type name defined for type " + k);
207                         break;
208                     }
209                     for(
210                         int l = 0;
211                         l < reference.size();
212                         l++
213                     ) {
214                         if(!reference.get(l).equals(type.get(l))) {
215                             convertedRid += "/" + convertPathComponent(reference.get(l));
216                         }
217                     }
218                     break;
219                 }
220             }
221             if(convertedRid != null) {
222                 return convertedRid;
223             }
224             else {
225                 System.out.println("ERROR: No path pattern found for reference " + reference + " at column " + columnName);
226                 if(!"object_rid".equals(columnName) && !"p$$object_parent__rid".equals(columnName)) {
227                     String JavaDoc referenceName = columnName.endsWith("_parent__rid")
228                         ? columnName.substring(3, columnName.indexOf("_parent__rid"))
229                         : columnName.substring(3, columnName.indexOf("__rid"));
230                     if(referencesInError.get(dbObject) == null) {
231                         referencesInError.put(
232                             dbObject,
233                             new HashSet JavaDoc()
234                         );
235                     }
236                     ((Set JavaDoc)referencesInError.get(dbObject)).add(referenceName);
237                 }
238             }
239         }
240         else {
241             System.out.println("ERROR: No reference found for rid " + rid + " at column " + columnName);
242             if(!"object_rid".equals(columnName) && !"p$$object_parent__rid".equals(columnName)) {
243                 String JavaDoc referenceName = columnName.endsWith("_parent__rid")
244                     ? columnName.substring(3, columnName.indexOf("_parent__rid"))
245                     : columnName.substring(3, columnName.indexOf("__rid"));
246                 if(referencesInError.get(dbObject) == null) {
247                     referencesInError.put(
248                         dbObject,
249                         new HashSet JavaDoc()
250                     );
251                 }
252                 ((Set JavaDoc)referencesInError.get(dbObject)).add(referenceName);
253             }
254         }
255         return null;
256     }
257               
258     //---------------------------------------------------------------------------
259
private static void convertFrom181To191(
260         Connection JavaDoc conn,
261         String JavaDoc namespaceId,
262         boolean fixErrors,
263         Path[] types,
264         String JavaDoc[] dbObjects,
265         String JavaDoc[] typeNames,
266         Number JavaDoc startWithTable,
267         Number JavaDoc endWithTable,
268         Number JavaDoc startWithPhase
269     ) {
270         String JavaDoc currentStatement = null;
271         try {
272             String JavaDoc databaseProductName = conn.getMetaData().getDatabaseProductName();
273
274             System.out.println();
275             System.out.println("Converting namespace " + namespaceId + "(database=" + databaseProductName + ")");
276             
277             // Phase 0: Change column type of all RID columns to VARCHAR
278
if((startWithPhase == null) || (startWithPhase.intValue() <= 0)) {
279                 System.out.println();
280                 System.out.println("Phase 0: Checking tables");
281                 boolean hasErrors = false;
282                 Set JavaDoc processedDbObjects = new HashSet JavaDoc();
283                 for(
284                     int i = (startWithTable == null ? 0 : startWithTable.intValue());
285                     i < (endWithTable == null ? dbObjects.length : java.lang.Math.min(dbObjects.length, endWithTable.intValue() + 1));
286                     i++
287                 ) {
288                     String JavaDoc dbObject = dbObjects[i];
289                     if((dbObject != null) && (dbObject.length() > 0) && !processedDbObjects.contains(dbObject)) {
290                         System.out.println("Phase 0: Processing table " + i + " (" + dbObject + ")");
291                         PreparedStatement JavaDoc s = conn.prepareStatement(
292                             currentStatement = "SELECT * FROM " + dbObject + " WHERE (1=0)"
293                         );
294                         s.executeQuery();
295                         ResultSet JavaDoc rs = s.getResultSet();
296                         ResultSetMetaData JavaDoc rsm = rs.getMetaData();
297                         for(
298                             int j = 0;
299                             j < rsm.getColumnCount();
300                             j++
301                         ) {
302                             String JavaDoc columnName = rsm.getColumnName(j+1).toLowerCase();
303                             // Convert RID columns from integer to varchar
304
if(
305                                 "object_rid".equals(columnName) ||
306                                 "object_oid".equals(columnName) ||
307                                 (columnName.startsWith("p$$") && columnName.endsWith("__rid")) ||
308                                 (columnName.startsWith("p$$") && columnName.endsWith("__oid"))
309                             ) {
310                                 String JavaDoc nullableClause = "object_rid".equals(columnName) || "object_oid".equals(columnName)
311                                     ? "NOT NULL"
312                                     : "";
313                                 if("PostgreSQL".equals(databaseProductName)) {
314                                     try {
315                                         if(!columnName.endsWith("__oid")) {
316                                             PreparedStatement JavaDoc s0 = conn.prepareStatement(
317                                                 currentStatement = "ALTER TABLE " + dbObject + " ALTER " + columnName + " TYPE VARCHAR(200) " + nullableClause
318                                             );
319                                             System.out.println(" " + currentStatement);
320                                             s0.executeUpdate();
321                                             s0.close();
322                                         }
323                                     }
324                                     catch(Exception JavaDoc e) {
325                                         System.out.println("ERROR: Can not alter column " + columnName + " (Reason: " + e.getMessage() + ")");
326                                         hasErrors = true;
327                                     }
328                                 }
329                                 else if("MySQL".equals(databaseProductName)) {
330                                     try {
331                                         if(!columnName.endsWith("__oid")) {
332                                             PreparedStatement JavaDoc s0 = conn.prepareStatement(
333                                                 currentStatement = "ALTER TABLE " + dbObject + " MODIFY " + columnName + " VARCHAR(200) " + nullableClause
334                                             );
335                                             System.out.println(" " + currentStatement);
336                                             s0.executeUpdate();
337                                             s0.close();
338                                         }
339                                     }
340                                     catch(Exception JavaDoc e) {
341                                         System.out.println("ERROR: Can not alter column " + columnName + " (Reason: " + e.getMessage() + ")");
342                                         hasErrors = true;
343                                     }
344                                 }
345                                 else if("Microsoft SQL Server".equals(databaseProductName)) {
346                                     try {
347                                         if("object_rid".equals(columnName) || "object_oid".equals(columnName)) {
348                                             try {
349                                                 PreparedStatement JavaDoc s0 = conn.prepareStatement(
350                                                     currentStatement = "ALTER TABLE " + dbObject + " DROP CONSTRAINT PK_" + dbObject
351                                                 );
352                                                 s0.executeUpdate();
353                                                 s0.close();
354                                             }
355                                             catch(Exception JavaDoc e) {
356                                                 System.out.println("INFO: Can not drop PK constraint for table " + dbObject);
357                                             }
358                                         }
359                                         PreparedStatement JavaDoc s0 = conn.prepareStatement(
360                                             currentStatement = "ALTER TABLE " + dbObject + " ALTER COLUMN " + columnName + " NVARCHAR(200) COLLATE SQL_Latin1_General_CP1_CS_AS " + nullableClause
361                                         );
362                                         System.out.println(" " + currentStatement);
363                                         s0.executeUpdate();
364                                         s0.close();
365                                         if("object_rid".equals(columnName) || "object_oid".equals(columnName)) {
366                                             s0 = conn.prepareStatement(
367                                                 currentStatement = "ALTER TABLE " + dbObject + " ADD CONSTRAINT PK_" + dbObject + " PRIMARY KEY (object_rid,object_oid,object_idx)"
368                                             );
369                                             s0.executeUpdate();
370                                             s0.close();
371                                         }
372                                     }
373                                     catch(Exception JavaDoc e) {
374                                         System.out.println("ERROR: Can not alter column " + columnName + " (Reason: " + e.getMessage() + ")");
375                                         hasErrors = true;
376                                     }
377                                 }
378                                 else if("DB2 NT".equals(databaseProductName)) {
379                                     try {
380                                         if(!columnName.endsWith("__oid")) {
381                                             PreparedStatement JavaDoc s0 = conn.prepareStatement(
382                                                 currentStatement = "ALTER TABLE " + dbObject + " MODIFY " + columnName + " VARCHAR(200) " + nullableClause
383                                             );
384                                             System.out.println(" " + currentStatement);
385                                             s0.executeUpdate();
386                                             s0.close();
387                                         }
388                                     }
389                                     catch(Exception JavaDoc e) {
390                                         System.out.println("ERROR: Can not alter column " + columnName);
391                                         hasErrors = true;
392                                     }
393                                 }
394                                 else if("Oracle".equals(databaseProductName)) {
395                                     try {
396                                         if(!columnName.endsWith("__oid")) {
397                                             // Update in one transaction
398
conn.setAutoCommit(false);
399                                             // DROP PRIMARY KEY
400
if("object_rid".equals(columnName) || "object_oid".equals(columnName)) {
401                                                 try {
402                                                     PreparedStatement JavaDoc s0 = conn.prepareStatement(
403                                                         currentStatement = "ALTER TABLE " + dbObject + " DROP PRIMARY KEY"
404                                                     );
405                                                     System.out.println(" " + currentStatement);
406                                                     s0.executeUpdate();
407                                                     s0.close();
408                                                 }
409                                                 catch(Exception JavaDoc e) {
410                                                     System.out.println("INFO: Can not drop PK constraint for table " + dbObject);
411                                                 }
412                                             }
413                                             // RENAME column to be converted to COL_TMP
414
PreparedStatement JavaDoc s0 = conn.prepareStatement(
415                                                 currentStatement = "ALTER TABLE " + dbObject + " RENAME COLUMN " + columnName + " TO COL_TMP"
416                                             );
417                                             System.out.println(" " + currentStatement);
418                                             s0.executeUpdate();
419                                             s0.close();
420                                             // ADD column columnName
421
s0 = conn.prepareStatement(
422                                                 currentStatement = "ALTER TABLE " + dbObject + " ADD (" + columnName + " VARCHAR2(200) )"
423                                             );
424                                             System.out.println(" " + currentStatement);
425                                             s0.executeUpdate();
426                                             s0.close();
427                                             // Transfer and convert data from COL_TMP to new column
428
s0 = conn.prepareStatement(
429                                                 currentStatement = "UPDATE " + dbObject + " SET " + columnName + " = TO_CHAR(COL_TMP)"
430                                             );
431                                             System.out.println(" " + currentStatement);
432                                             s0.executeUpdate();
433                                             s0.close();
434                                             // Modify to NULL/NOT NULL
435
s0 = conn.prepareStatement(
436                                                 currentStatement = "ALTER TABLE " + dbObject + " MODIFY (" + columnName + " " + nullableClause + ")"
437                                             );
438                                             System.out.println(" " + currentStatement);
439                                             s0.executeUpdate();
440                                             s0.close();
441                                             // Drop column COL_TMP
442
s0 = conn.prepareStatement(
443                                                 currentStatement = "ALTER TABLE " + dbObject + " DROP (COL_TMP)"
444                                             );
445                                             System.out.println(" " + currentStatement);
446                                             s0.executeUpdate();
447                                             s0.close();
448                                             // Add primary key constraint
449
if("object_rid".equals(columnName) || "object_oid".equals(columnName)) {
450                                                 s0 = conn.prepareStatement(
451                                                     currentStatement = "ALTER TABLE " + dbObject + " ADD CONSTRAINT PK_" + (dbObject.length() > 27 ? dbObject.substring(0,27) : dbObject) + " PRIMARY KEY (object_rid,object_oid,object_idx)"
452                                                 );
453                                                 System.out.println(" " + currentStatement);
454                                                 s0.executeUpdate();
455                                                 s0.close();
456                                             }
457                                             // Commit
458
conn.commit();
459                                         }
460                                     }
461                                     catch(Exception JavaDoc e) {
462                                         try {
463                                             conn.rollback();
464                                         } catch(Exception JavaDoc e0) {}
465                                         System.out.println("ERROR: Can not alter column " + columnName + " (Reason: " + e.getMessage() + ")");
466                                         hasErrors = true;
467                                     }
468                                     finally {
469                                         try {
470                                             conn.setAutoCommit(true);
471                                         } catch(Exception JavaDoc e) {}
472                                     }
473                                 }
474                                 else if("SAP DB".equals(databaseProductName)) {
475                                     try {
476                                         if(!columnName.endsWith("__oid")) {
477                                             PreparedStatement JavaDoc s0 = conn.prepareStatement(
478                                                 currentStatement = "ALTER TABLE " + dbObject + " MODIFY " + columnName + " VARCHAR(200) " + nullableClause
479                                             );
480                                             System.out.println(" " + currentStatement);
481                                             s0.executeUpdate();
482                                             s0.close();
483                                         }
484                                     }
485                                     catch(Exception JavaDoc e) {
486                                         System.out.println("ERROR: Can not alter column " + columnName + " (Reason: " + e.getMessage() + ")");
487                                         hasErrors = true;
488                                     }
489                                 }
490                                 else {
491                                     throw new ServiceException(
492                                         StackedException.DEFAULT_DOMAIN,
493                                         StackedException.NOT_SUPPORTED,
494                                         new BasicException.Parameter[]{
495                                           new BasicException.Parameter("database product name", databaseProductName)
496                                         },
497                                         "Database not supported"
498                                       );
499                                 }
500                             }
501                         }
502                         processedDbObjects.add(dbObject);
503                         rs.close();
504                         s.close();
505                     }
506                 }
507                 if(hasErrors) {
508                     System.out.println("Phase 0: Can not convert RIDs. Fix above errors first and restart again.");
509                     return;
510                 }
511             }
512             
513             // Phase I: set values of RID columns
514
Map JavaDoc referencesInError = new HashMap JavaDoc();
515             if((startWithPhase == null) || (startWithPhase.intValue() <= 1)) {
516                 System.out.println();
517                 System.out.println("Phase I: Checking references");
518                 Set JavaDoc processedDbObjects = new HashSet JavaDoc();
519                 for(
520                     int i = (startWithTable == null ? 0 : startWithTable.intValue());
521                     i < (endWithTable == null ? dbObjects.length : java.lang.Math.min(dbObjects.length, endWithTable.intValue() + 1));
522                     i++
523                 ) {
524                     String JavaDoc dbObject = dbObjects[i];
525                     if((dbObject != null) && (dbObject.length() > 0) && !processedDbObjects.contains(dbObject)) {
526                         System.out.println("Phase I: Processing table " + i + " (" + dbObject + ")");
527                         long nRows = 0;
528                         // Iterate all rows
529
PreparedStatement JavaDoc ps = conn.prepareStatement(
530                             currentStatement = "SELECT * FROM " + dbObject
531                         );
532                         ps.executeQuery();
533                         FastResultSet frs = new FastResultSet(ps.getResultSet());
534                         while(frs.next()) {
535                             String JavaDoc objectRid = (String JavaDoc)frs.getObject("object_rid");
536                             String JavaDoc objectOid = (String JavaDoc)frs.getObject("object_oid");
537                             int objectIdx = ((Number JavaDoc)frs.getObject("object_idx")).intValue();
538                             String JavaDoc statement = "UPDATE " + dbObject + " SET ";
539                             List JavaDoc statementParameters = new ArrayList JavaDoc();
540                             boolean hasClause = false;
541                             for(
542                                 int j = 0;
543                                 j < frs.getColumnNames().size();
544                                 j++
545                             ) {
546                                 String JavaDoc columnName = (String JavaDoc)frs.getColumnNames().get(j);
547                                 
548                                 // Update columns object_rid, object_oid
549
if("object_rid".equals(columnName)) {
550                                     if((objectRid != null) && (objectRid.indexOf("/") < 0)) {
551                                         String JavaDoc newRid = convertRid(conn, dbObject, columnName, objectRid, types, typeNames, referencesInError);
552                                         if(newRid != null) {
553                                             statement += hasClause ? ", " : "";
554                                             statement += "object_rid = ?, object_oid = ?";
555                                             statementParameters.add(
556                                                 newRid
557                                             );
558                                             statementParameters.add(
559                                                 convertPathComponent(objectOid)
560                                             );
561                                             hasClause = true;
562                                         }
563                                     }
564                                 }
565                                 // Update columns p$$<reference name>_parent__rid, p$$<reference name>_parent__oid
566
else if((columnName.startsWith("p$$") && columnName.endsWith("_parent__rid"))) {
567                                     String JavaDoc columnNameReference = columnName.substring(3, columnName.indexOf("_parent__rid"));
568                                     String JavaDoc columnNameRid = "p$$" + columnNameReference + "_parent__rid";
569                                     String JavaDoc columnNameOid = "p$$" + columnNameReference + "_parent__oid";
570                                     String JavaDoc rid = (String JavaDoc)frs.getObject(columnNameRid);
571                                     String JavaDoc oid = (String JavaDoc)frs.getObject(columnNameOid);
572                                     if((rid != null) && (rid.indexOf("/") < 0)) {
573                                         String JavaDoc newRid = convertRid(conn, dbObject, columnName, rid, types, typeNames, referencesInError);
574                                         if(newRid != null) {
575                                             statement += hasClause ? ", " : "";
576                                             statement += columnNameRid + " = ?, " + columnNameOid + " = ?";
577                                             statementParameters.add(
578                                                 newRid
579                                             );
580                                             statementParameters.add(
581                                                 convertPathComponent(oid)
582                                             );
583                                             hasClause = true;
584                                         }
585                                     }
586                                 }
587                                 // Update columns p$$<reference name>_parent__rid, p$$<reference name>_parent__oid
588
else if((columnName.startsWith("p$$") && columnName.endsWith("__rid"))) {
589                                     String JavaDoc columnNameReference = columnName.substring(3, columnName.indexOf("__rid"));
590                                     
591                                     // Update
592
String JavaDoc columnNameRid = "p$$" + columnNameReference + "__rid";
593                                     String JavaDoc columnNameOid = "p$$" + columnNameReference + "__oid";
594                                     String JavaDoc rid = (String JavaDoc)frs.getObject(columnNameRid);
595                                     String JavaDoc oid = (String JavaDoc)frs.getObject(columnNameOid);
596                                     if((rid != null) && (rid.indexOf("/") < 0)) {
597                                         if(frs.getObject(columnNameReference) == null) {
598                                             if(referencesInError.get(dbObject) == null) {
599                                                 referencesInError.put(
600                                                     dbObject,
601                                                     new HashSet JavaDoc()
602                                                 );
603                                             }
604                                             ((Set JavaDoc)referencesInError.get(dbObject)).add(columnNameReference);
605                                         }
606                                         else {
607                                             String JavaDoc newRid = convertRid(conn, dbObject, columnName, rid, types, typeNames, referencesInError);
608                                             if(newRid != null) {
609                                                 statement += hasClause ? ", " : "";
610                                                 statement += columnNameReference + " = ?, " + columnNameRid + " = ?, " + columnNameOid + " = ?";
611                                                 statementParameters.add(
612                                                     newRid + "/" + convertPathComponent(oid)
613                                                 );
614                                                 statementParameters.add(
615                                                     newRid
616                                                 );
617                                                 statementParameters.add(
618                                                     convertPathComponent(oid)
619                                                 );
620                                                 hasClause = true;
621                                             }
622                                         }
623                                     }
624                                 }
625                             }
626                             if(hasClause) {
627                                 statement += " WHERE (object_rid = ?) AND (object_oid = ?) AND (object_idx = ?)";
628                                 PreparedStatement JavaDoc ps1 = conn.prepareStatement(
629                                     currentStatement = statement
630                                 );
631                                 int j = 0;
632                                 while(j < statementParameters.size()) {
633                                     if(statementParameters.get(j) instanceof Path) {
634                                         ps1.setString(
635                                             j+1,
636                                             ((Path)statementParameters.get(j)).toUri()
637                                         );
638                                     }
639                                     else {
640                                         ps1.setString(
641                                             j+1,
642                                             (String JavaDoc)statementParameters.get(j)
643                                         );
644                                     }
645                                     j++;
646                                 }
647                                 ps1.setString(j+1, objectRid);
648                                 ps1.setString(j+2, objectOid);
649                                 ps1.setInt(j+3, objectIdx);
650                                 try {
651                                     ps1.executeUpdate();
652                                 }
653                                 catch(SQLException JavaDoc e) {
654                                     System.out.println("Update failed. Reason: " + e.getMessage());
655                                     System.out.println("Row.rid=" + objectRid + ", oid=" + objectOid + ", idx=" + objectIdx);
656                                     System.out.println("statement=" + statement);
657                                     System.out.println("parameters=" + statementParameters);
658                                 }
659                                 ps1.close();
660                             }
661                             nRows++;
662                             if(nRows % 50 == 0) {
663                                 System.out.println("INFO: Processed " + nRows + " rows");
664                             }
665                         }
666                         ps.close();
667                         processedDbObjects.add(dbObject);
668                     }
669                 }
670             }
671             
672             // Phase II: Fix errors
673
if(
674                fixErrors &&
675                ((startWithPhase == null) || (startWithPhase.intValue() <= 2))
676             ) {
677                 System.out.println();
678                 System.out.println("Phase II: Fixing tables");
679                 Set JavaDoc processedDbObjects = new HashSet JavaDoc();
680                 for(
681                     int i = (startWithTable == null ? 0 : startWithTable.intValue());
682                     i < (endWithTable == null ? dbObjects.length : java.lang.Math.min(dbObjects.length, endWithTable.intValue() + 1));
683                     i++
684                 ) {
685                     String JavaDoc dbObject = dbObjects[i];
686                     if((dbObject != null) && (dbObject.length() > 0) && !processedDbObjects.contains(dbObject)) {
687                         System.out.println("Phase II: Processing table " + i + " (" + dbObject + ")");
688                         try {
689                             // Remove objects with non-convertable object_rid
690
PreparedStatement JavaDoc ps = conn.prepareStatement(
691                                 currentStatement = "DELETE FROM " + dbObject + " WHERE object_rid NOT LIKE '%/%'"
692                             );
693                             ps.executeUpdate();
694                             // Remove objects with non-convertable p$$parent_object__rid
695
ps = conn.prepareStatement(
696                                 currentStatement = "DELETE FROM " + dbObject + " WHERE object_oid IN (SELECT object_oid FROM " + dbObject + " WHERE p$$object_parent__rid NOT LIKE '%/%')"
697                             );
698                             ps.executeUpdate();
699                             // Set invalid references to NULL
700
if(referencesInError.get(dbObject) != null) {
701                                 for(
702                                     Iterator JavaDoc j = ((Set JavaDoc)referencesInError.get(dbObject)).iterator();
703                                     j.hasNext();
704                                 ) {
705                                     String JavaDoc referenceName = (String JavaDoc)j.next();
706                                     System.out.println(" Fixing reference " + referenceName);
707                                     ps = conn.prepareStatement(
708                                         currentStatement = "UPDATE " + dbObject + " SET " +
709                                         referenceName + " = NULL," +
710                                         "p$$" + referenceName + "__rid = NULL, " +
711                                         "p$$" + referenceName + "__oid = NULL, " +
712                                         "p$$" + referenceName + "_parent__rid = NULL," +
713                                         "p$$" + referenceName + "_parent__oid = NULL" +
714                                         " WHERE (p$$" + referenceName + "__rid NOT LIKE '%/%') OR (p$$" + referenceName + "_parent__rid NOT LIKE '%/%')"
715                                     );
716                                     ps.executeUpdate();
717                                 }
718                             }
719                         }
720                         catch(Exception JavaDoc e) {
721                             System.out.println("INFO: Can not fix table " + dbObject + ". Reason is " + e.getMessage());
722                         }
723                         processedDbObjects.add(dbObject);
724                     }
725                 }
726             }
727             
728             System.out.println("INFO: Done");
729         }
730         catch (SQLException JavaDoc e) {
731             e.printStackTrace();
732             System.out.println("statement: " + currentStatement);
733         }
734         catch(ServiceException e) {
735             e.printStackTrace();
736         }
737     }
738
739    //-----------------------------------------------------------------------
740
public static void main(
741         String JavaDoc[] args
742     ) {
743         try {
744             Context JavaDoc componentEnvironment = (Context JavaDoc)new InitialContext JavaDoc().lookup("java:comp/env");
745
746             Class.forName((String JavaDoc)componentEnvironment.lookup("jdbcDriver"));
747             Connection JavaDoc conn = DriverManager.getConnection(
748                 (String JavaDoc)componentEnvironment.lookup("jdbcUrl"),
749                 (String JavaDoc)componentEnvironment.lookup("username"),
750                 (String JavaDoc)componentEnvironment.lookup("password")
751             );
752             conn.setAutoCommit(true);
753
754             String JavaDoc command = (String JavaDoc)componentEnvironment.lookup("command");
755             
756             // convert-from-181-to-191
757
if("convert-from-181-to-191".equals(command)) {
758                 convertFrom181To191(
759                     conn,
760                     "kernel",
761                     ((Boolean JavaDoc)componentEnvironment.lookup("fixErrors")).booleanValue(),
762                     KERNEL_TYPES_181,
763                     KERNEL_DBOBJECTS_181,
764                     KERNEL_TYPENAMES_181,
765                     (Number JavaDoc)componentEnvironment.lookup("startWithTable"),
766                     (Number JavaDoc)componentEnvironment.lookup("endWithTable"),
767                     (Number JavaDoc)componentEnvironment.lookup("startWithPhase")
768                 );
769                 convertFrom181To191(
770                     conn,
771                     "security",
772                     ((Boolean JavaDoc)componentEnvironment.lookup("fixErrors")).booleanValue(),
773                     SECURITY_TYPES_181,
774                     SECURITY_DBOBJECTS_181,
775                     SECURITY_TYPENAMES_181,
776                     (Number JavaDoc)componentEnvironment.lookup("startWithTable"),
777                     (Number JavaDoc)componentEnvironment.lookup("endWithTable"),
778                     (Number JavaDoc)componentEnvironment.lookup("startWithPhase")
779                 );
780             }
781             else {
782                 System.out.println("Unknown command " + command);
783                 System.out.println("Valid commands are:");
784                 System.out.println("* convert-from-181-to-191");
785             }
786         }
787         catch(NamingException JavaDoc e) {
788             e.printStackTrace();
789         }
790         catch (ClassNotFoundException JavaDoc e) {
791             e.printStackTrace();
792         }
793         catch (SQLException JavaDoc e) {
794             e.printStackTrace();
795         }
796     }
797
798     //-----------------------------------------------------------------------
799
// Members
800
//-----------------------------------------------------------------------
801

802     // Namespace kernel
803
private static final Path[] KERNEL_TYPES_181 = new Path[]{
804         new Path("xri:@openmdx:org.opencrx.kernel.account1/provider/:*/segment/:*/organization/:*"),
805         new Path("xri:@openmdx:org.opencrx.kernel.uom1/provider/:*/segment/:*/uomSchedule/:*"),
806         new Path("xri:@openmdx:org.opencrx.kernel.uom1/provider/:*/segment/:*/uom/:*"),
807         new Path("xri:@openmdx:org.opencrx.kernel.contract1/provider/:*/segment/:*/lead/:*"),
808         new Path("xri:@openmdx:org.opencrx.kernel.contract1/provider/:*/segment/:*/opportunity/:*"),
809         new Path("xri:@openmdx:org.opencrx.kernel.contract1/provider/:*/segment/:*/quote/:*"),
810         new Path("xri:@openmdx:org.opencrx.kernel.contract1/provider/:*/segment/:*/salesOrder/:*"),
811         new Path("xri:@openmdx:org.opencrx.kernel.contract1/provider/:*/segment/:*/invoice/:*"),
812         new Path("xri:@openmdx:org.opencrx.kernel.contract1/provider/:*/segment/:*/lead/:*/position/:*"),
813         new Path("xri:@openmdx:org.opencrx.kernel.contract1/provider/:*/segment/:*/opportunity/:*/position/:*"),
814         new Path("xri:@openmdx:org.opencrx.kernel.contract1/provider/:*/segment/:*/quote/:*/position/:*"),
815         new Path("xri:@openmdx:org.opencrx.kernel.contract1/provider/:*/segment/:*/salesOrder/:*/position/:*"),
816         new Path("xri:@openmdx:org.opencrx.kernel.contract1/provider/:*/segment/:*/invoice/:*/position/:*"),
817         new Path("xri:@openmdx:org.opencrx.kernel.workflow1/provider/:*/segment/:*/wfProcess/:*"),
818         new Path("xri:@openmdx:org.opencrx.kernel.product1/provider/:*/segment/:*/product/:*"),
819         new Path("xri:@openmdx:org.openmdx.security.authentication1/provider/:*/segment/:*"),
820         new Path("xri:@openmdx:org.opencrx.kernel.document1/provider/:*/segment/:*"),
821         new Path("xri:@openmdx:org.opencrx.kernel.building1/provider/:*/segment/:*"),
822         new Path("xri:@openmdx:org.opencrx.kernel.code1/provider/:*/segment/:*"),
823         new Path("xri:@openmdx:org.opencrx.kernel.product1/provider/:*/segment/:*"),
824         new Path("xri:@openmdx:org.opencrx.kernel.admin1/provider/:*/segment/:*"),
825         new Path("xri:@openmdx:org.opencrx.kernel.region1/provider/:*/segment/:*"),
826         new Path("xri:@openmdx:org.opencrx.kernel.reservation1/provider/:*/segment/:*"),
827         new Path("xri:@openmdx:org.opencrx.kernel.account1/provider/:*/segment/:*"),
828         new Path("xri:@openmdx:org.opencrx.kernel.model1/provider/:*/segment/:*"),
829         new Path("xri:@openmdx:org.opencrx.kernel.depot1/provider/:*/segment/:*"),
830         new Path("xri:@openmdx:org.opencrx.kernel.forecast1/provider/:*/segment/:*"),
831         new Path("xri:@openmdx:org.opencrx.kernel.workflow1/provider/:*/segment/:*"),
832         new Path("xri:@openmdx:org.opencrx.kernel.uom1/provider/:*/segment/:*"),
833         new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*"),
834         new Path("xri:@openmdx:org.opencrx.kernel.home1/provider/:*/segment/:*"),
835         new Path("xri:@openmdx:org.opencrx.kernel.contract1/provider/:*/segment/:*"),
836         new Path("xri:@openmdx:org.openmdx.security.realm1/provider/:*/segment/:*"),
837         new Path("xri:@openmdx:org.opencrx.security.identity1/provider/:*/segment/:*"),
838         new Path("xri:@openmdx:org.openmdx.security.authorization1/provider/:*/segment/:*"),
839         new Path("xri:@openmdx:org.opencrx.kernel.account1/provider/:*/segment/:*/account/:*/revenueReport/:*"),
840         new Path("xri:@openmdx:org.opencrx.kernel.home1/provider/:*/segment/:*/userHome/:*/subscription/:*"),
841         new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/activity/:*"),
842         new Path("xri:@openmdx:org.opencrx.kernel.workflow1/provider/:*/segment/:*/topic/:*"),
843         new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/activity/:*/emailRecipient/:*"),
844         new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/activity/:*/faxRecipient/:*"),
845         new Path("xri:@openmdx:org.opencrx.kernel.code1/provider/:*/segment/:*/valueContainer/:*/entry/:*"),
846         new Path("xri:@openmdx:org.opencrx.kernel.code1/provider/:*/segment/:*/valueContainer/:*"),
847         new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/activity/:*/incidentParty/:*"),
848         new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/activity/:*/mailingRecipient/:*"),
849         new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/activity/:*/mmsRecipient/:*"),
850         new Path("xri:@openmdx:org.opencrx.kernel.document1/provider/:*/segment/:*/document/:*"),
851         new Path("xri:@openmdx:org.opencrx.kernel.home1/provider/:*/segment/:*/userHome/:*/eMailAccount/:*"),
852         new Path("xri:@openmdx:org.opencrx.kernel.account1/provider/:*/segment/:*/account/:*/contactRelationship/:*"),
853         new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/activity/:*/phoneCallRecipient/:*"),
854         new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/activity/:*/smsRecipient/:*"),
855         new Path("xri:@openmdx:org.opencrx.kernel.building1/provider/:*/segment/:*/building/:*"),
856         new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/activity/:*/taskParty/:*"),
857         new Path("xri:@openmdx:org.opencrx.kernel.product1/provider/:*/segment/:*/salesTaxType/:*"),
858         new Path("xri:@openmdx:org.opencrx.kernel.product1/provider/:*/segment/:*/priceLevel/:*"),
859         new Path("xri:@openmdx:org.opencrx.kernel.account1/provider/:*/segment/:*/competitor/:*"),
860         new Path("xri:@openmdx:org.opencrx.kernel.building1/provider/:*/segment/:*/building/:*/buildingUnit/:*"),
861         new Path("xri:@openmdx:org.opencrx.kernel.forecast1/provider/:*/segment/:*/forecast/:*/forecastPeriod/:*"),
862         new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/addressGroup/:*/member/:*"),
863         new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/activity/:*/meetingParty/:*"),
864         new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/activityTracker/:*"),
865         new Path("xri:@openmdx:org.opencrx.kernel.account1/provider/:*/segment/:*/organization/:*/ouRelationship/:*"),
866         new Path("xri:@openmdx:org.opencrx.kernel.forecast1/provider/:*/segment/:*/budget/:*"),
867         new Path("xri:@openmdx:org.opencrx.kernel.forecast1/provider/:*/segment/:*/forecast/:*"),
868         new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/activityTracker/:*/incidentTransition/:*"),
869         new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/addressGroup/:*"),
870         new Path("xri:@openmdx:org.opencrx.kernel.home1/provider/:*/segment/:*/userHome/:*/wfProcessInstance/:*/actionLog/:*"),
871         new Path("xri:@openmdx:org.opencrx.kernel.building1/provider/:*/segment/:*/buildingComplex/:*"),
872         new Path("xri:@openmdx:org.opencrx.kernel.forecast1/provider/:*/segment/:*/budget/:*/budgetMilestone/:*"),
873         new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/activityTracker/:*/trackerCategory/:*"),
874         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/address/:*"),
875         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/:*/:*/address/:*"),
876         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/:*/:*/:*/:*/address/:*"),
877         new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/activity/:*/slide/:*"),
878         new Path("xri:@openmdx:org.opencrx.kernel.account1/provider/:*/segment/:*/account/:*"),
879         new Path("xri:@openmdx:org.opencrx.kernel.home1/provider/:*/segment/:*/userHome/:*/wfProcessInstance/:*"),
880         new Path("xri:@openmdx:org.opencrx.kernel.account1/provider/:*/segment/:*/organization/:*/organizationalUnit/:*"),
881         new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/activityTracker/:*/trackerMilestone/:*"),
882         new Path("xri:@openmdx:org.opencrx.kernel.contract1/provider/:*/segment/:*/:*/:*/position/:*/productApplication/:*"),
883         new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/activity/:*/workRecord/:*"),
884         new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/activity/:*/vote/:*"),
885         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/additionalExternalLink/:*"),
886         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/:*/:*/additionalExternalLink/:*"),
887         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/:*/:*/:*/:*/additionalExternalLink/:*"),
888         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/:*/:*/:*/:*/:*/:*/additionalExternalLink/:*"),
889         new Path("xri:@openmdx:org.opencrx.kernel.building1/provider/:*/segment/:*/:*/:*/facility/:*"),
890         new Path("xri:@openmdx:org.opencrx.kernel.building1/provider/:*/segment/:*/:*/:*/:*/:*/facility/:*"),
891         new Path("xri:@openmdx:org.opencrx.kernel.account1/provider/:*/segment/:*/organization/:*/contactMembership/:*"),
892         new Path("xri:@openmdx:org.opencrx.kernel.account1/provider/:*/segment/:*/organization/:*/organizationalUnit/:*/contactMembership/:*"),
893         new Path("xri:@openmdx:org.opencrx.kernel.contract1/provider/:*/segment/:*/:*/:*/position/:*/deliveryInformation/:*"),
894         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/attachedDocument/:*"),
895         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/:*/:*/attachedDocument/:*"),
896         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/:*/:*/:*/:*/attachedDocument/:*"),
897         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/:*/:*/:*/:*/:*/:*/attachedDocument/:*"),
898         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/rating/:*"),
899         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/:*/:*/rating/:*"),
900         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/:*/:*/:*/:*/rating/:*"),
901         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/:*/:*/:*/:*/:*/:*/rating/:*"),
902         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/note/:*"),
903         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/:*/:*/note/:*"),
904         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/:*/:*/:*/:*/note/:*"),
905         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/:*/:*/:*/:*/:*/:*/note/:*"),
906         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/deliveryRequest/:*"),
907         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/:*/:*/deliveryRequest/:*"),
908         new Path("xri:@openmdx:org.opencrx.kernel.account1/provider/:*/segment/:*/organization/:*/organizationalUnit/:*/creditLimit/:*"),
909         new Path("xri:@openmdx:org.opencrx.kernel.account1/provider/:*/segment/:*/organization/:*/creditLimit/:*"),
910         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/additionalDescription/:*"),
911         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/:*/:*/additionalDescription/:*"),
912         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/:*/:*/:*/:*/additionalDescription/:*"),
913         new Path("xri:@openmdx:org.opencrx.kernel.account1/provider/:*/segment/:*/account/:*/member/:*"),
914         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/media/:*"),
915         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/:*/:*/media/:*"),
916         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/:*/:*/:*/:*/media/:*"),
917         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/:*/:*/:*/:*/:*/:*/media/:*"),
918         new Path("xri:@openmdx:org.opencrx.kernel.home1/provider/:*/segment/:*/userHome/:*"),
919         new Path("xri:@openmdx:org.opencrx.kernel.home1/provider/:*/segment/:*/userHome/:*/alert/:*"),
920         new Path("xri:@openmdx:org.opencrx.kernel.home1/provider/:*/segment/:*/userHome/:*/quickAccess/:*"),
921         new Path("xri:@openmdx:org.opencrx.kernel.home1/provider/:*/segment/:*/userHome/:*/accessHistory/:*"),
922         new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/activityTracker/:*/trackerActivityLink/:*"),
923         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/chart/:*"),
924         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/productReference/:*"),
925         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/property/:*"),
926         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/:*/:*/property/:*"),
927         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/:*/:*/:*/:*/property/:*"),
928         new Path("xri:@openmdx::*/provider/:*/segment/:*/audit/:*"),
929         new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/activity/:*/activityLinkTo/:*"),
930         new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/activity/:*/incidentTransition/:*"),
931         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/replacement/:*"),
932         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/:*/:*/replacement/:*"),
933         new Path("xri:@openmdx:org.opencrx.kernel.model1/provider/:*/segment/:*/element/:*"),
934         new Path("xri:@openmdx:org.opencrx.kernel.depot1/provider/:*/segment/:*/entity/:*/bookingText/:*"),
935         new Path("xri:@openmdx:org.opencrx.kernel.product1/provider/:*/segment/:*/product/:*/definingProfile/:*"),
936         new Path("xri:@openmdx:org.opencrx.kernel.product1/provider/:*/segment/:*/product/:*/relatedProduct/:*"),
937         new Path("xri:@openmdx:org.opencrx.kernel.product1/provider/:*/segment/:*/product/:*/classificationElement/:*"),
938         new Path("xri:@openmdx:org.opencrx.kernel.product1/provider/:*/segment/:*/product/:*/classificationElement/:*/descriptor/:*"),
939         new Path("xri:@openmdx:org.opencrx.kernel.product1/provider/:*/segment/:*/product/:*/solutionPart/:*"),
940         new Path("xri:@openmdx:org.opencrx.kernel.product1/provider/:*/segment/:*/product/:*/solutionPart/:*/dependency/:*"),
941         new Path("xri:@openmdx:org.opencrx.kernel.product1/provider/:*/segment/:*/product/:*/solutionPart/:*/artifactContext/:*"),
942         new Path("xri:@openmdx:org.opencrx.kernel.product1/provider/:*/segment/:*/product/:*/solutionPart/:*/vp/:*"),
943         new Path("xri:@openmdx:org.opencrx.kernel.depot1/provider/:*/segment/:*/entity/:*"),
944         new Path("xri:@openmdx:org.opencrx.kernel.depot1/provider/:*/segment/:*/entityRelationship/:*"),
945         new Path("xri:@openmdx:org.opencrx.kernel.depot1/provider/:*/segment/:*/depotType/:*"),
946         new Path("xri:@openmdx:org.opencrx.kernel.depot1/provider/:*/segment/:*/entity/:*/depotGroup/:*"),
947         new Path("xri:@openmdx:org.opencrx.kernel.depot1/provider/:*/segment/:*/entity/:*/depotHolder/:*"),
948         new Path("xri:@openmdx:org.opencrx.kernel.depot1/provider/:*/segment/:*/cb/:*"),
949         new Path("xri:@openmdx:org.opencrx.kernel.depot1/provider/:*/segment/:*/entity/:*/bookingPeriod/:*"),
950         new Path("xri:@openmdx:org.opencrx.kernel.depot1/provider/:*/segment/:*/booking/:*"),
951         new Path("xri:@openmdx:org.opencrx.kernel.depot1/provider/:*/segment/:*/entity/:*/depotHolder/:*/depot/:*"),
952         new Path("xri:@openmdx:org.opencrx.kernel.depot1/provider/:*/segment/:*/entity/:*/depotHolder/:*/depot/:*/position/:*"),
953         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/configuration/:*"),
954         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/:*/:*/configuration/:*"),
955         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/:*/:*/:*/:*/configuration/:*"),
956         new Path("xri:@openmdx:org.opencrx.kernel.depot1/provider/:*/segment/:*/entity/:*/depotHolder/:*/depot/:*/report/:*"),
957         new Path("xri:@openmdx:org.opencrx.kernel.depot1/provider/:*/segment/:*/entity/:*/depotHolder/:*/depot/:*/report/:*/itemPosition/:*"),
958         new Path("xri:@openmdx:org.opencrx.kernel.depot1/provider/:*/segment/:*/entity/:*/depotHolder/:*/depot/:*/report/:*/itemBooking/:*"),
959         new Path("xri:@openmdx:org.opencrx.kernel.document1/provider/:*/segment/:*/folder/:*"),
960         new Path("xri:@openmdx:org.opencrx.kernel.document1/provider/:*/segment/:*/document/:*/revision/:*"),
961         new Path("xri:@openmdx:org.opencrx.kernel.product1/provider/:*/segment/:*/productOffering/:*"),
962         new Path("xri:@openmdx:org.opencrx.kernel.product1/provider/:*/segment/:*/productOffering/:*/productBundle/:*"),
963         new Path("xri:@openmdx:org.opencrx.kernel.product1/provider/:*/segment/:*/productBundleType/:*/bundledProduct/:*"),
964         new Path("xri:@openmdx:org.opencrx.kernel.product1/provider/:*/segment/:*/:*/:*/basePrice/:*"),
965         new Path("xri:@openmdx:org.opencrx.kernel.product1/provider/:*/segment/:*/:*/:*/:*/:*/basePrice/:*"),
966         new Path("xri:@openmdx:org.opencrx.kernel.product1/provider/:*/segment/:*/productBundleType/:*"),
967         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/depotReference/:*"),
968         new Path("xri:@openmdx::*/provider/:*/segment/:*/:*/:*/:*/:*/depotReference/:*"),
969         new Path("xri:@openmdx:org.opencrx.kernel.product1/provider/:*/segment/:*/configurationTypeSet/:*"),
970         new Path("xri:@openmdx:org.opencrx.kernel.product1/provider/:*/segment/:*/configurationTypeSet/:*/configurationType/:*"),
971         new Path("xri:@openmdx:org.openmdx.security.realm1/provider/:*/segment/:*/realm/:*"),
972         new Path("xri:@openmdx:org.openmdx.security.realm1/provider/:*/segment/:*/realm/:*/principal/:*")
973     };
974     
975     private static final String JavaDoc[] KERNEL_DBOBJECTS_181 = new String JavaDoc[]{
976         "kernel_Organization",
977         "kernel_UomSchedule",
978         "kernel_Uom",
979         "kernel_Contract",
980         "kernel_Contract",
981         "kernel_Contract",
982         "kernel_Contract",
983         "kernel_Contract",
984         "kernel_ContractPosition",
985         "kernel_ContractPosition",
986         "kernel_ContractPosition",
987         "kernel_ContractPosition",
988         "kernel_ContractPosition",
989         "kernel_WfProcess",
990         "kernel_Product",
991         "kernel_Segment",
992         "kernel_Segment",
993         "kernel_Segment",
994         "kernel_Segment",
995         "kernel_Segment",
996         "kernel_Segment",
997         "kernel_Segment",
998         "kernel_Segment",
999         "kernel_Segment",
1000        "kernel_Segment",
1001        "kernel_Segment",
1002        "kernel_Segment",
1003        "kernel_Segment",
1004        "kernel_Segment",
1005        "kernel_Segment",
1006        "kernel_Segment",
1007        "kernel_Segment",
1008        "kernel_Segment",
1009        "kernel_Segment",
1010        "kernel_Segment",
1011        "kernel_RevenueReport",
1012        "kernel_Subscription",
1013        "kernel_Activity",
1014        "kernel_Topic",
1015        "kernel_ActivityParty",
1016        "kernel_ActivityParty",
1017        "kernel_CodeValueEntry",
1018        "kernel_CodeValueContainer",
1019        "kernel_ActivityParty",
1020        "kernel_ActivityParty",
1021        "kernel_ActivityParty",
1022        "kernel_Document",
1023        "kernel_EMailAccount",
1024        "kernel_ContactRelationship",
1025        "kernel_ActivityParty",
1026        "kernel_ActivityParty",
1027        "kernel_Building",
1028        "kernel_ActivityParty",
1029        "kernel_SalesTaxType",
1030        "kernel_PriceLevel",
1031        "kernel_Competitor",
1032        "kernel_BuildingUnit",
1033        "kernel_ForecastPeriod",
1034        "kernel_AddressGroupMember",
1035        "kernel_ActivityParty",
1036        "kernel_ActivityTracker",
1037        "kernel_OrgUnitRelationship",
1038        "kernel_Budget",
1039        "kernel_Forecast",
1040        "kernel_IncidentTransition",
1041        "kernel_AddressGroup",
1042        "kernel_WfActionLogEntry",
1043        "kernel_BuildingComplex",
1044        "kernel_BudgetMilestone",
1045        "kernel_TrackerCategory",
1046        "kernel_Address",
1047        "kernel_Address",
1048        "kernel_Address",
1049        "kernel_MmsSlide",
1050        "kernel_Account",
1051        "kernel_WfProcessInstance",
1052        "kernel_OrganizationalUnit",
1053        "kernel_TrackerMilestone",
1054        "kernel_ProductApplication",
1055        "kernel_WorkRecord",
1056        "kernel_Vote",
1057        "kernel_AdditionalExternalLink",
1058        "kernel_AdditionalExternalLink",
1059        "kernel_AdditionalExternalLink",
1060        "kernel_AdditionalExternalLink",
1061        "kernel_Facility",
1062        "kernel_Facility",
1063        "kernel_ContactMembership",
1064        "kernel_ContactMembership",
1065        "kernel_DeliveryInformation",
1066        "kernel_DocumentAttachment",
1067        "kernel_DocumentAttachment",
1068        "kernel_DocumentAttachment",
1069        "kernel_DocumentAttachment",
1070        "kernel_Rating",
1071        "kernel_Rating",
1072        "kernel_Rating",
1073        "kernel_Rating",
1074        "kernel_Note",
1075        "kernel_Note",
1076        "kernel_Note",
1077        "kernel_Note",
1078        "kernel_DeliveryRequest",
1079        "kernel_DeliveryRequest",
1080        "kernel_CreditLimit",
1081        "kernel_CreditLimit",
1082        "kernel_Description",
1083        "kernel_Description",
1084        "kernel_Description",
1085        "kernel_Member",
1086        "kernel_Media",
1087        "kernel_Media",
1088        "kernel_Media",
1089        "kernel_Media",
1090        "kernel_UserHome",
1091        "kernel_Alert",
1092        "kernel_QuickAccess",
1093        "kernel_AccessHistory",
1094        "kernel_TrackerActivityLink",
1095        "kernel_Chart",
1096        "kernel_ProductReference",
1097        "kernel_Property",
1098        "kernel_Property",
1099        "kernel_Property",
1100        "kernel_AuditEntry",
1101        "kernel_ActivityLink",
1102        "kernel_IncidentTransition",
1103        "kernel_TemplateReplacement",
1104        "kernel_TemplateReplacement",
1105        "kernel_ModelElement",
1106        "kernel_BookingText",
1107        "kernel_RASProfile",
1108        "kernel_RelatedProduct",
1109        "kernel_RASClassificationElt",
1110        "kernel_RASDescriptor",
1111        "kernel_RASSolutionPart",
1112        "kernel_RASArtifactDep",
1113        "kernel_RASArtifactContext",
1114        "kernel_RASVariabilityPoint",
1115        "kernel_DepotEntity",
1116        "kernel_DepotEntityRel",
1117        "kernel_DepotType",
1118        "kernel_DepotGroup",
1119        "kernel_DepotHolder",
1120        "kernel_CompoundBooking",
1121        "kernel_BookingPeriod",
1122        "kernel_Booking",
1123        "kernel_Depot",
1124        "kernel_DepotPosition",
1125        "kernel_ProductConfiguration",
1126        "kernel_ProductConfiguration",
1127        "kernel_ProductConfiguration",
1128        "kernel_DepotReport",
1129        "kernel_DepotReportItem",
1130        "kernel_DepotReportItem",
1131        "kernel_DocumentFolder",
1132        "kernel_Media",
1133        "kernel_ProductOffering",
1134        "kernel_ProductBundle",
1135        "kernel_BundledProduct",
1136        "kernel_ProductBasePrice",
1137        "kernel_ProductBasePrice",
1138        "kernel_ProductBundleType",
1139        "kernel_DepotReference",
1140        "kernel_DepotReference",
1141        "kernel_ProductConfigTypeSet",
1142        "kernel_ProductConfiguration",
1143        null,
1144        null
1145    };
1146    
1147    private static final String JavaDoc[] KERNEL_TYPENAMES_181 = new String JavaDoc[]{
1148        "organization",
1149        "uomSchedule",
1150        "uom",
1151        "lead",
1152        "opportunity",
1153        "quote",
1154        "salesOrder",
1155        "invoice",
1156        "leadPos",
1157        "opportunityPos",
1158        "quotePos",
1159        "salesOrderPos",
1160        "invoicePos",
1161        "wfProcess",
1162        "product",
1163        "authentications",
1164        "docs",
1165        "buildings",
1166        "codes",
1167        "products",
1168        "admins",
1169        "regions",
1170        "reservations",
1171        "accounts",
1172        "models",
1173        "depots",
1174        "forecasts",
1175        "workflows",
1176        "uoms",
1177        "activities",
1178        "homes",
1179        "contracts",
1180        "realms",
1181        "identities",
1182        "authorizations",
1183        "revenueReport",
1184        "subscription",
1185        "activity",
1186        "topic",
1187        "emailRecipient",
1188        "faxRecipient",
1189        "valueContainerEntry",
1190        "valueContainer",
1191        "incidentParty",
1192        "mailingRecipient",
1193        "mmsRecipient",
1194        "doc",
1195        "eMailAccount",
1196        "contactRelationship",
1197        "phoneCallRecipient",
1198        "smsRecipient",
1199        "building",
1200        "taskParty",
1201        "salesTaxType",
1202        "priceLevel",
1203        "competitor",
1204        "buildingUnit",
1205        "forecastPeriod",
1206        "addressGroupMember",
1207        "meetingParty",
1208        "activityTracker",
1209        "ouRelationship",
1210        "budget",
1211        "forecast",
1212        "incidentTransition",
1213        "addressGroup",
1214        "actionLog",
1215        "buildingComplex",
1216        "budgetMilestone",
1217        "activityCategory",
1218        "address1",
1219        "address2",
1220        "address3",
1221        "activitySlide",
1222        "account",
1223        "wfProcessInstance",
1224        "organizationalUnit",
1225        "activityMilestone",
1226        "productApplication",
1227        "workRecord0",
1228        "vote",
1229        "externalLink1",
1230        "externalLink2",
1231        "externalLink3",
1232        "externalLink4",
1233        "facility1",
1234        "facility2",
1235        "oContactMembership",
1236        "ouContactMembership",
1237        "deliveryInfo",
1238        "doc1",
1239        "doc2",
1240        "doc3",
1241        "doc4",
1242        "rating1",
1243        "rating2",
1244        "rating3",
1245        "rating4",
1246        "note1",
1247        "note2",
1248        "note3",
1249        "note4",
1250        "deliveryRequest1",
1251        "deliveryRequest2",
1252        "organizationalUnitCreditLimit",
1253        "organizationCreditLimit",
1254        "descr1",
1255        "descr2",
1256        "descr3",
1257        "accountMember",
1258        "media1",
1259        "media2",
1260        "media3",
1261        "media4",
1262        "userHome",
1263        "alert",
1264        "quickAccess",
1265        "accessHistory",
1266        "trackerActivityLink",
1267        "chart",
1268        "productRef1",
1269        "p1",
1270        "p2",
1271        "p3",
1272        "audit",
1273        "activityLinkTo",
1274        "incidentTransition",
1275        "replacement1",
1276        "replacement2",
1277        "modelElement",
1278        "bookingText",
1279        "productDefiningProfile",
1280        "relatedProduct",
1281        "productCassificationElement",
1282        "classificationElementDescriptor",
1283        "productSolutionPart",
1284        "solutionPartDependency",
1285        "solutionPartArtifactContext",
1286        "solutionPartVp",
1287        "depotEntity",
1288        "depotEntityRelationship",
1289        "depotType",
1290        "depotGroup",
1291        "depotHolder",
1292        "cb",
1293        "bookingPeriod",
1294        "booking",
1295        "depot",
1296        "depotPos",
1297        "config1",
1298        "config2",
1299        "config3",
1300        "depotReport",
1301        "depotReportItemPosition",
1302        "depotReportItemBooking",
1303        "docFolder",
1304        "docRevision",
1305        "productOffering",
1306        "productBundle",
1307        "bundledProduct",
1308        "price1",
1309        "price2",
1310        "productBundleType",
1311        "depotRef1",
1312        "depotRef2",
1313        "configTypeSet",
1314        "configType",
1315        "realm",
1316        "principal"
1317    };
1318
1319    // Namespace security
1320
private static final Path[] SECURITY_TYPES_181 = new Path[]{
1321        new Path("xri:@openmdx:org:opencrx:security:identity1/provider/:*/segment/:*"),
1322        new Path("xri:@openmdx:org.openmdx.security.realm1/provider/:*/segment/:*/realm/:*"),
1323        new Path("xri:@openmdx:org.openmdx.security.realm1/provider/:*/segment/:*/realm/:*/principal/:*"),
1324        new Path("xri:@openmdx:org.openmdx.security.authorization1/provider/:*/segment/:*/policy/:*"),
1325        new Path("xri:@openmdx:org.openmdx.security.authorization1/provider/:*/segment/:*/policy/:*/role/:*"),
1326        new Path("xri:@openmdx:org.openmdx.security.authorization1/provider/:*/segment/:*/policy/:*/role/:*/permission/:*"),
1327        new Path("xri:@openmdx:org.openmdx.security.authorization1/provider/:*/segment/:*/policy/:*/privilege/:*"),
1328        new Path("xri:@openmdx:org.opencrx.security.identity1/provider/:*/segment/:*/subject/:*"),
1329        new Path("xri:@openmdx:org.openmdx.security.authentication1/provider/:*/segment/:*/credential/:*"),
1330        new Path("xri:@openmdx:org:openmdx.security.authentication1/provider/:*/segment/:*"),
1331        new Path("xri:@openmdx:org:openmdx.security.realm1/provider/:*/segment/:*"),
1332        new Path("xri:@openmdx:org.openmdx.security.authorization1/provider/:*/segment/:*")
1333    };
1334    
1335    private static final String JavaDoc[] SECURITY_DBOBJECTS_181 = new String JavaDoc[]{
1336        "security_Segment",
1337        "security_Realm",
1338        "security_Principal",
1339        "security_Policy",
1340        "security_Role",
1341        "security_Permission",
1342        "security_Privilege",
1343        "security_Subject",
1344        "security_Credential",
1345        "security_Segment",
1346        "security_Segment",
1347        "security_Segment"
1348    };
1349    
1350    private static final String JavaDoc[] SECURITY_TYPENAMES_181 = new String JavaDoc[]{
1351        "identities",
1352        "realm",
1353        "principal",
1354        "policy",
1355        "role",
1356        "permission",
1357        "privilege",
1358        "subject",
1359        "credential",
1360        "authentications",
1361        "realms",
1362        "authorizations"
1363    };
1364    
1365}
1366
1367//---------------------------------------------------------------------------
1368
Popular Tags