Source Code Cross Referenced for RepositoryXmlHandler.java in  » Database-ORM » db-ojb » org » apache » ojb » broker » metadata » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database ORM » db ojb » org.apache.ojb.broker.metadata 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        package org.apache.ojb.broker.metadata;
0002:
0003:        /* Copyright 2002-2005 The Apache Software Foundation
0004:         *
0005:         * Licensed under the Apache License, Version 2.0 (the "License");
0006:         * you may not use this file except in compliance with the License.
0007:         * You may obtain a copy of the License at
0008:         *
0009:         *     http://www.apache.org/licenses/LICENSE-2.0
0010:         *
0011:         * Unless required by applicable law or agreed to in writing, software
0012:         * distributed under the License is distributed on an "AS IS" BASIS,
0013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014:         * See the License for the specific language governing permissions and
0015:         * limitations under the License.
0016:         */
0017:
0018:        import org.apache.ojb.broker.accesslayer.QueryCustomizer;
0019:        import org.apache.ojb.broker.locking.IsolationLevels;
0020:        import org.apache.ojb.broker.locking.LockHelper;
0021:        import org.apache.ojb.broker.metadata.fieldaccess.PersistentField;
0022:        import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldFactory;
0023:        import org.apache.ojb.broker.util.ClassHelper;
0024:        import org.apache.ojb.broker.util.logging.Logger;
0025:        import org.apache.ojb.broker.util.logging.LoggerFactory;
0026:        import org.xml.sax.Attributes;
0027:        import org.xml.sax.SAXException;
0028:        import org.xml.sax.SAXParseException;
0029:        import org.xml.sax.helpers.DefaultHandler;
0030:
0031:        /**
0032:         * The handler catches Parsing events raised by the xml-parser
0033:         * and builds up the DescriptorRepository that is used within the
0034:         * OJB PersistenceBroker System.
0035:         * <p>
0036:         * TODO: Reading of metadata are split in two classes {@link RepositoryXmlHandler} and
0037:         * {@link ConnectionDescriptorXmlHandler}. Thus we should only read relevant tags in this
0038:         * classes. In further versions we should split repository.dtd in two parts, one for connetion
0039:         * metadata, one for pc object metadata.
0040:         * </p>
0041:         * @author <a href="mailto:thma@apache.org">Thomas Mahler<a>
0042:         * @author Jakob Br?uchi
0043:         * @version $Id: RepositoryXmlHandler.java,v 1.58.2.10 2005/12/21 22:26:10 tomdz Exp $
0044:         */
0045:        public class RepositoryXmlHandler extends DefaultHandler implements 
0046:                RepositoryElements, IsolationLevels {
0047:            private Logger logger = LoggerFactory
0048:                    .getLogger(RepositoryXmlHandler.class);
0049:
0050:            private DescriptorRepository m_repository;
0051:            private ClassDescriptor m_CurrentCLD;
0052:            private ProcedureDescriptor m_CurrentProcedure;
0053:            private FieldDescriptor m_CurrentFLD;
0054:            private ObjectReferenceDescriptor m_CurrentORD;
0055:            private CollectionDescriptor m_CurrentCOD;
0056:            private IndexDescriptor m_CurrentIndexDescriptor;
0057:            private String m_CurrentString;
0058:            /** holds custom attributes */
0059:            private AttributeContainer m_CurrentAttrContainer;
0060:            /** the default proxy prefetching limit*/
0061:            private int defProxyPrefetchingLimit = 50;
0062:            /**
0063:             * Allows not to specify field id
0064:             */
0065:            private int m_lastId;
0066:
0067:            /**
0068:             * All known xml tags are kept in this table.
0069:             * The tags table allows lookup from literal to id
0070:             * and from id to literal.
0071:             */
0072:            private RepositoryTags tags = RepositoryTags.getInstance();
0073:
0074:            /**
0075:             * returns the XmlCapable id associated with the literal.
0076:             * OJB maintains a RepositoryTags table that provides
0077:             * a mapping from xml-tags to XmlCapable ids.
0078:             * @param literal the literal to lookup
0079:             * @return the int value representing the XmlCapable
0080:             *
0081:             * @throws MetadataException if no literal was found in tags mapping
0082:             */
0083:            private int getLiteralId(String literal) throws MetadataException {
0084:                //logger.debug("lookup: " + literal);
0085:                try {
0086:                    return tags.getIdByTag(literal);
0087:                } catch (NullPointerException t) {
0088:                    throw new MetadataException(
0089:                            "Found Unknown literal '"
0090:                                    + literal
0091:                                    + "' in the repository file. Check repository file or/and RepositoryTags.java",
0092:                            t);
0093:                }
0094:
0095:            }
0096:
0097:            /**
0098:             * build a handler that fills the given repository
0099:             * from an XML file.
0100:             */
0101:            public RepositoryXmlHandler(DescriptorRepository dr) {
0102:                if (dr != null) {
0103:                    m_repository = dr;
0104:                } else {
0105:                    throw new MetadataException(
0106:                            "Given DescriptorRepository argument was null");
0107:                }
0108:            }
0109:
0110:            /**
0111:             * startDocument callback, nothing to do here.
0112:             */
0113:            public void startDocument() {
0114:                logger.debug("startDoc");
0115:            }
0116:
0117:            /**
0118:             * endDocument callback, nothing to do here.
0119:             */
0120:            public void endDocument() {
0121:                // arminw: no longer needed since SuperReferenceDescriptor was used
0122:                // AnonymousPersistentFieldHelper.computeInheritedPersistentFields(m_repository);
0123:                logger.debug("endDoc");
0124:            }
0125:
0126:            /**
0127:             * startElement callback.
0128:             * Only some Elements need special start operations.
0129:             * @throws MetadataException indicating mapping errors
0130:             */
0131:            public void startElement(String uri, String name, String qName,
0132:                    Attributes atts) {
0133:                boolean isDebug = logger.isDebugEnabled();
0134:
0135:                m_CurrentString = null;
0136:                try {
0137:                    switch (getLiteralId(qName)) {
0138:                    case MAPPING_REPOSITORY: {
0139:                        if (isDebug)
0140:                            logger.debug(" > "
0141:                                    + tags.getTagById(MAPPING_REPOSITORY));
0142:                        this .m_CurrentAttrContainer = m_repository;
0143:
0144:                        String defIso = atts.getValue(tags
0145:                                .getTagById(ISOLATION_LEVEL));
0146:                        this .m_repository.setDefaultIsolationLevel(LockHelper
0147:                                .getIsolationLevelFor(defIso));
0148:                        if (isDebug)
0149:                            logger.debug("     "
0150:                                    + tags.getTagById(ISOLATION_LEVEL) + ": "
0151:                                    + defIso);
0152:
0153:                        String proxyPrefetchingLimit = atts.getValue(tags
0154:                                .getTagById(PROXY_PREFETCHING_LIMIT));
0155:                        if (isDebug)
0156:                            logger.debug("     "
0157:                                    + tags.getTagById(PROXY_PREFETCHING_LIMIT)
0158:                                    + ": " + proxyPrefetchingLimit);
0159:                        if (proxyPrefetchingLimit != null) {
0160:                            defProxyPrefetchingLimit = Integer
0161:                                    .parseInt(proxyPrefetchingLimit);
0162:                        }
0163:
0164:                        // check repository version:
0165:                        String version = atts.getValue(tags
0166:                                .getTagById(REPOSITORY_VERSION));
0167:                        if (DescriptorRepository.getVersion().equals(version)) {
0168:                            if (isDebug)
0169:                                logger.debug("     "
0170:                                        + tags.getTagById(REPOSITORY_VERSION)
0171:                                        + ": " + version);
0172:                        } else {
0173:                            throw new MetadataException(
0174:                                    "Repository version does not match. expected "
0175:                                            + DescriptorRepository.getVersion()
0176:                                            + " but found: "
0177:                                            + version
0178:                                            + ". Please update your repository.dtd and your repository.xml"
0179:                                            + " version attribute entry");
0180:                        }
0181:                        break;
0182:                    }
0183:                    case CLASS_DESCRIPTOR: {
0184:                        if (isDebug)
0185:                            logger.debug("  > "
0186:                                    + tags.getTagById(CLASS_DESCRIPTOR));
0187:                        m_CurrentCLD = new ClassDescriptor(m_repository);
0188:
0189:                        // prepare for custom attributes
0190:                        this .m_CurrentAttrContainer = this .m_CurrentCLD;
0191:
0192:                        // set isolation-level attribute
0193:                        String isoLevel = atts.getValue(tags
0194:                                .getTagById(ISOLATION_LEVEL));
0195:                        if (isDebug)
0196:                            logger.debug("     "
0197:                                    + tags.getTagById(ISOLATION_LEVEL) + ": "
0198:                                    + isoLevel);
0199:                        /*
0200:                        arminw:
0201:                        only when an isolation-level is set in CLD, set it.
0202:                        Else the CLD use the default iso-level defined in the repository
0203:                         */
0204:                        if (checkString(isoLevel))
0205:                            m_CurrentCLD.setIsolationLevel(LockHelper
0206:                                    .getIsolationLevelFor(isoLevel));
0207:
0208:                        // set class attribute
0209:                        String classname = atts.getValue(tags
0210:                                .getTagById(CLASS_NAME));
0211:                        if (isDebug)
0212:                            logger.debug("     " + tags.getTagById(CLASS_NAME)
0213:                                    + ": " + classname);
0214:                        try {
0215:                            m_CurrentCLD.setClassOfObject(ClassHelper
0216:                                    .getClass(classname));
0217:                        } catch (ClassNotFoundException e) {
0218:                            m_CurrentCLD = null;
0219:                            throw new MetadataException(
0220:                                    "Class "
0221:                                            + classname
0222:                                            + " could not be found"
0223:                                            + " in the classpath. This could cause unexpected behaviour of OJB,"
0224:                                            + " please remove or comment out this class descriptor"
0225:                                            + " in the repository.xml file.", e);
0226:                        }
0227:
0228:                        // set schema attribute
0229:                        String schema = atts.getValue(tags
0230:                                .getTagById(SCHEMA_NAME));
0231:                        if (schema != null) {
0232:                            if (isDebug)
0233:                                logger.debug("     "
0234:                                        + tags.getTagById(SCHEMA_NAME) + ": "
0235:                                        + schema);
0236:                            m_CurrentCLD.setSchema(schema);
0237:                        }
0238:
0239:                        // set proxy attribute
0240:                        String proxy = atts.getValue(tags
0241:                                .getTagById(CLASS_PROXY));
0242:                        if (isDebug)
0243:                            logger.debug("     " + tags.getTagById(CLASS_PROXY)
0244:                                    + ": " + proxy);
0245:                        if (checkString(proxy)) {
0246:                            if (proxy
0247:                                    .equalsIgnoreCase(ClassDescriptor.DYNAMIC_STR)) {
0248:                                m_CurrentCLD
0249:                                        .setProxyClassName(ClassDescriptor.DYNAMIC_STR);
0250:                            } else {
0251:                                m_CurrentCLD.setProxyClassName(proxy);
0252:                            }
0253:                        }
0254:
0255:                        // set proxyPrefetchingLimit attribute
0256:                        String proxyPrefetchingLimit = atts.getValue(tags
0257:                                .getTagById(PROXY_PREFETCHING_LIMIT));
0258:                        if (isDebug)
0259:                            logger.debug("     "
0260:                                    + tags.getTagById(PROXY_PREFETCHING_LIMIT)
0261:                                    + ": " + proxyPrefetchingLimit);
0262:                        if (proxyPrefetchingLimit == null) {
0263:                            m_CurrentCLD
0264:                                    .setProxyPrefetchingLimit(defProxyPrefetchingLimit);
0265:                        } else {
0266:                            m_CurrentCLD.setProxyPrefetchingLimit(Integer
0267:                                    .parseInt(proxyPrefetchingLimit));
0268:                        }
0269:
0270:                        // set table attribute:
0271:                        String table = atts.getValue(tags
0272:                                .getTagById(TABLE_NAME));
0273:                        if (isDebug)
0274:                            logger.debug("     " + tags.getTagById(TABLE_NAME)
0275:                                    + ": " + table);
0276:                        m_CurrentCLD.setTableName(table);
0277:                        if (table == null) {
0278:                            m_CurrentCLD.setIsInterface(true);
0279:                        }
0280:
0281:                        // set row-reader attribute
0282:                        String rowreader = atts.getValue(tags
0283:                                .getTagById(ROW_READER));
0284:                        if (isDebug)
0285:                            logger.debug("     " + tags.getTagById(ROW_READER)
0286:                                    + ": " + rowreader);
0287:                        if (rowreader != null) {
0288:                            m_CurrentCLD.setRowReader(rowreader);
0289:                        }
0290:
0291:                        // set if extends
0292:                        // arminw: TODO: this feature doesn't work, remove this stuff?
0293:                        String extendsAtt = atts.getValue(tags
0294:                                .getTagById(EXTENDS));
0295:                        if (isDebug)
0296:                            logger.debug("     " + tags.getTagById(EXTENDS)
0297:                                    + ": " + extendsAtt);
0298:                        if (checkString(extendsAtt)) {
0299:                            m_CurrentCLD.setSuperClass(extendsAtt);
0300:                        }
0301:
0302:                        //set accept-locks attribute
0303:                        String acceptLocks = atts.getValue(tags
0304:                                .getTagById(ACCEPT_LOCKS));
0305:                        if (acceptLocks == null)
0306:                            acceptLocks = "true"; // default is true
0307:                        logger.debug("     " + tags.getTagById(ACCEPT_LOCKS)
0308:                                + ": " + acceptLocks);
0309:                        if (isDebug)
0310:                            logger.debug("     "
0311:                                    + tags.getTagById(ACCEPT_LOCKS) + ": "
0312:                                    + acceptLocks);
0313:                        boolean b = (Boolean.valueOf(acceptLocks))
0314:                                .booleanValue();
0315:                        m_CurrentCLD.setAcceptLocks(b);
0316:
0317:                        //set initializationMethod attribute
0318:                        String initializationMethod = atts.getValue(tags
0319:                                .getTagById(INITIALIZATION_METHOD));
0320:                        if (isDebug)
0321:                            logger.debug("     "
0322:                                    + tags.getTagById(INITIALIZATION_METHOD)
0323:                                    + ": " + initializationMethod);
0324:                        if (initializationMethod != null) {
0325:                            m_CurrentCLD
0326:                                    .setInitializationMethod(initializationMethod);
0327:                        }
0328:
0329:                        // set factoryClass attribute
0330:                        String factoryClass = atts.getValue(tags
0331:                                .getTagById(FACTORY_CLASS));
0332:                        if (isDebug)
0333:                            logger.debug("     "
0334:                                    + tags.getTagById(FACTORY_CLASS) + ": "
0335:                                    + factoryClass);
0336:                        if (factoryClass != null) {
0337:                            m_CurrentCLD.setFactoryClass(factoryClass);
0338:                        }
0339:
0340:                        //set factoryMethod attribute
0341:                        String factoryMethod = atts.getValue(tags
0342:                                .getTagById(FACTORY_METHOD));
0343:                        if (isDebug)
0344:                            logger.debug("     "
0345:                                    + tags.getTagById(FACTORY_METHOD) + ": "
0346:                                    + factoryMethod);
0347:                        if (factoryMethod != null) {
0348:                            m_CurrentCLD.setFactoryMethod(factoryMethod);
0349:                        }
0350:
0351:                        // set refresh attribute
0352:                        String refresh = atts
0353:                                .getValue(tags.getTagById(REFRESH));
0354:                        if (isDebug)
0355:                            logger.debug("     " + tags.getTagById(REFRESH)
0356:                                    + ": " + refresh);
0357:                        b = (Boolean.valueOf(refresh)).booleanValue();
0358:                        m_CurrentCLD.setAlwaysRefresh(b);
0359:
0360:                        // TODO: remove this or make offical feature
0361:                        // persistent field
0362:                        String pfClassName = atts
0363:                                .getValue("persistent-field-class");
0364:                        if (isDebug)
0365:                            logger.debug("     persistent-field-class: "
0366:                                    + pfClassName);
0367:                        m_CurrentCLD.setPersistentFieldClassName(pfClassName);
0368:
0369:                        // put cld to the metadata repository
0370:                        m_repository.put(classname, m_CurrentCLD);
0371:                        break;
0372:                    }
0373:                    case OBJECT_CACHE: {
0374:                        // we only interessted in object-cache tags declared within
0375:                        // an class-descriptor
0376:                        if (m_CurrentCLD != null) {
0377:                            String className = atts.getValue(tags
0378:                                    .getTagById(CLASS_NAME));
0379:                            if (checkString(className)) {
0380:                                if (isDebug)
0381:                                    logger.debug("     > "
0382:                                            + tags.getTagById(OBJECT_CACHE));
0383:                                ObjectCacheDescriptor ocd = new ObjectCacheDescriptor();
0384:                                this .m_CurrentAttrContainer = ocd;
0385:                                ocd.setObjectCache(ClassHelper
0386:                                        .getClass(className));
0387:                                if (m_CurrentCLD != null) {
0388:                                    m_CurrentCLD.setObjectCacheDescriptor(ocd);
0389:                                }
0390:                                if (isDebug)
0391:                                    logger.debug("     "
0392:                                            + tags.getTagById(CLASS_NAME)
0393:                                            + ": " + className);
0394:                            }
0395:                        }
0396:                        break;
0397:                    }
0398:                    case CLASS_EXTENT: {
0399:                        String classname = atts.getValue("class-ref");
0400:                        if (isDebug)
0401:                            logger.debug("     "
0402:                                    + tags.getTagById(CLASS_EXTENT) + ": "
0403:                                    + classname);
0404:                        m_CurrentCLD.addExtentClass(classname);
0405:                        break;
0406:                    }
0407:
0408:                    case FIELD_DESCRIPTOR: {
0409:                        if (isDebug)
0410:                            logger.debug("    > "
0411:                                    + tags.getTagById(FIELD_DESCRIPTOR));
0412:
0413:                        String strId = atts.getValue(tags.getTagById(ID));
0414:                        m_lastId = (strId == null ? m_lastId + 1 : Integer
0415:                                .parseInt(strId));
0416:
0417:                        String strAccess = atts.getValue(tags
0418:                                .getTagById(ACCESS));
0419:
0420:                        if (RepositoryElements.TAG_ACCESS_ANONYMOUS
0421:                                .equalsIgnoreCase(strAccess)) {
0422:                            m_CurrentFLD = new AnonymousFieldDescriptor(
0423:                                    m_CurrentCLD, m_lastId);
0424:                        } else {
0425:                            m_CurrentFLD = new FieldDescriptor(m_CurrentCLD,
0426:                                    m_lastId);
0427:                        }
0428:                        m_CurrentFLD.setAccess(strAccess);
0429:                        m_CurrentCLD.addFieldDescriptor(m_CurrentFLD);
0430:
0431:                        // prepare for custom attributes
0432:                        this .m_CurrentAttrContainer = this .m_CurrentFLD;
0433:
0434:                        String fieldName = atts.getValue(tags
0435:                                .getTagById(FIELD_NAME));
0436:                        if (isDebug)
0437:                            logger.debug("     " + tags.getTagById(FIELD_NAME)
0438:                                    + ": " + fieldName);
0439:
0440:                        if (RepositoryElements.TAG_ACCESS_ANONYMOUS
0441:                                .equalsIgnoreCase(strAccess)) {
0442:                            AnonymousFieldDescriptor anonymous = (AnonymousFieldDescriptor) m_CurrentFLD;
0443:                            anonymous.setPersistentField(null, fieldName);
0444:                        } else {
0445:                            String classname = m_CurrentCLD
0446:                                    .getClassNameOfObject();
0447:                            PersistentField pf = PersistentFieldFactory
0448:                                    .createPersistentField(m_CurrentCLD
0449:                                            .getPersistentFieldClassName(),
0450:                                            ClassHelper.getClass(classname),
0451:                                            fieldName);
0452:                            m_CurrentFLD.setPersistentField(pf);
0453:                        }
0454:
0455:                        String columnName = atts.getValue(tags
0456:                                .getTagById(COLUMN_NAME));
0457:                        if (isDebug)
0458:                            logger.debug("     " + tags.getTagById(COLUMN_NAME)
0459:                                    + ": " + columnName);
0460:                        m_CurrentFLD.setColumnName(columnName);
0461:
0462:                        String jdbcType = atts.getValue(tags
0463:                                .getTagById(JDBC_TYPE));
0464:                        if (isDebug)
0465:                            logger.debug("     " + tags.getTagById(JDBC_TYPE)
0466:                                    + ": " + jdbcType);
0467:                        m_CurrentFLD.setColumnType(jdbcType);
0468:
0469:                        String primaryKey = atts.getValue(tags
0470:                                .getTagById(PRIMARY_KEY));
0471:                        if (isDebug)
0472:                            logger.debug("     " + tags.getTagById(PRIMARY_KEY)
0473:                                    + ": " + primaryKey);
0474:                        boolean b = (Boolean.valueOf(primaryKey))
0475:                                .booleanValue();
0476:                        m_CurrentFLD.setPrimaryKey(b);
0477:
0478:                        String nullable = atts.getValue(tags
0479:                                .getTagById(NULLABLE));
0480:                        if (nullable != null) {
0481:                            if (isDebug)
0482:                                logger.debug("     "
0483:                                        + tags.getTagById(NULLABLE) + ": "
0484:                                        + nullable);
0485:                            b = !(Boolean.valueOf(nullable)).booleanValue();
0486:                            m_CurrentFLD.setRequired(b);
0487:                        }
0488:
0489:                        String indexed = atts
0490:                                .getValue(tags.getTagById(INDEXED));
0491:                        if (isDebug)
0492:                            logger.debug("     " + tags.getTagById(INDEXED)
0493:                                    + ": " + indexed);
0494:                        b = (Boolean.valueOf(indexed)).booleanValue();
0495:                        m_CurrentFLD.setIndexed(b);
0496:
0497:                        String autoincrement = atts.getValue(tags
0498:                                .getTagById(AUTO_INCREMENT));
0499:                        if (isDebug)
0500:                            logger.debug("     "
0501:                                    + tags.getTagById(AUTO_INCREMENT) + ": "
0502:                                    + autoincrement);
0503:                        b = (Boolean.valueOf(autoincrement)).booleanValue();
0504:                        m_CurrentFLD.setAutoIncrement(b);
0505:
0506:                        String sequenceName = atts.getValue(tags
0507:                                .getTagById(SEQUENCE_NAME));
0508:                        if (isDebug)
0509:                            logger.debug("     "
0510:                                    + tags.getTagById(SEQUENCE_NAME) + ": "
0511:                                    + sequenceName);
0512:                        m_CurrentFLD.setSequenceName(sequenceName);
0513:
0514:                        String locking = atts
0515:                                .getValue(tags.getTagById(LOCKING));
0516:                        if (isDebug)
0517:                            logger.debug("     " + tags.getTagById(LOCKING)
0518:                                    + ": " + locking);
0519:                        b = (Boolean.valueOf(locking)).booleanValue();
0520:                        m_CurrentFLD.setLocking(b);
0521:
0522:                        String updateLock = atts.getValue(tags
0523:                                .getTagById(UPDATE_LOCK));
0524:                        if (isDebug)
0525:                            logger.debug("     " + tags.getTagById(UPDATE_LOCK)
0526:                                    + ": " + updateLock);
0527:                        if (checkString(updateLock)) {
0528:                            b = (Boolean.valueOf(updateLock)).booleanValue();
0529:                            m_CurrentFLD.setUpdateLock(b);
0530:                        }
0531:
0532:                        String fieldConversion = atts.getValue(tags
0533:                                .getTagById(FIELD_CONVERSION));
0534:                        if (isDebug)
0535:                            logger.debug("     "
0536:                                    + tags.getTagById(FIELD_CONVERSION) + ": "
0537:                                    + fieldConversion);
0538:                        if (fieldConversion != null) {
0539:                            m_CurrentFLD
0540:                                    .setFieldConversionClassName(fieldConversion);
0541:                        }
0542:
0543:                        // set length attribute
0544:                        String length = atts.getValue(tags.getTagById(LENGTH));
0545:                        if (length != null) {
0546:                            int i = Integer.parseInt(length);
0547:                            if (isDebug)
0548:                                logger.debug("     " + tags.getTagById(LENGTH)
0549:                                        + ": " + i);
0550:                            m_CurrentFLD.setLength(i);
0551:                            m_CurrentFLD.setLengthSpecified(true);
0552:                        }
0553:
0554:                        // set precision attribute
0555:                        String precision = atts.getValue(tags
0556:                                .getTagById(PRECISION));
0557:                        if (precision != null) {
0558:                            int i = Integer.parseInt(precision);
0559:                            if (isDebug)
0560:                                logger
0561:                                        .debug("     "
0562:                                                + tags.getTagById(PRECISION)
0563:                                                + ": " + i);
0564:                            m_CurrentFLD.setPrecision(i);
0565:                            m_CurrentFLD.setPrecisionSpecified(true);
0566:                        }
0567:
0568:                        // set scale attribute
0569:                        String scale = atts.getValue(tags.getTagById(SCALE));
0570:                        if (scale != null) {
0571:                            int i = Integer.parseInt(scale);
0572:                            if (isDebug)
0573:                                logger.debug("     " + tags.getTagById(SCALE)
0574:                                        + ": " + i);
0575:                            m_CurrentFLD.setScale(i);
0576:                            m_CurrentFLD.setScaleSpecified(true);
0577:                        }
0578:
0579:                        break;
0580:                    }
0581:
0582:                    case REFERENCE_DESCRIPTOR: {
0583:                        if (isDebug)
0584:                            logger.debug("    > "
0585:                                    + tags.getTagById(REFERENCE_DESCRIPTOR));
0586:                        // set name attribute
0587:                        name = atts.getValue(tags.getTagById(FIELD_NAME));
0588:                        if (isDebug)
0589:                            logger.debug("     " + tags.getTagById(FIELD_NAME)
0590:                                    + ": " + name);
0591:
0592:                        // set class-ref attribute
0593:                        String classRef = atts.getValue(tags
0594:                                .getTagById(REFERENCED_CLASS));
0595:                        if (isDebug)
0596:                            logger.debug("     "
0597:                                    + tags.getTagById(REFERENCED_CLASS) + ": "
0598:                                    + classRef);
0599:
0600:                        ObjectReferenceDescriptor ord;
0601:                        if (name.equals(TAG_SUPER)) {
0602:                            // no longer needed sine SuperReferenceDescriptor was used
0603:                            //                            checkThis(classRef);
0604:                            //                            AnonymousObjectReferenceDescriptor aord =
0605:                            //                                new AnonymousObjectReferenceDescriptor(m_CurrentCLD);
0606:                            //                            aord.setPersistentField(null, TAG_SUPER);
0607:                            //                            ord = aord;
0608:
0609:                            ord = new SuperReferenceDescriptor(m_CurrentCLD);
0610:                        } else {
0611:                            ord = new ObjectReferenceDescriptor(m_CurrentCLD);
0612:                            PersistentField pf = PersistentFieldFactory
0613:                                    .createPersistentField(m_CurrentCLD
0614:                                            .getPersistentFieldClassName(),
0615:                                            m_CurrentCLD.getClassOfObject(),
0616:                                            name);
0617:                            ord.setPersistentField(pf);
0618:                        }
0619:                        m_CurrentORD = ord;
0620:
0621:                        // now we add the new descriptor
0622:                        m_CurrentCLD.addObjectReferenceDescriptor(m_CurrentORD);
0623:                        m_CurrentORD.setItemClass(ClassHelper
0624:                                .getClass(classRef));
0625:
0626:                        // prepare for custom attributes
0627:                        this .m_CurrentAttrContainer = m_CurrentORD;
0628:
0629:                        // set proxy attribute
0630:                        String proxy = atts.getValue(tags
0631:                                .getTagById(PROXY_REFERENCE));
0632:                        if (isDebug)
0633:                            logger.debug("     "
0634:                                    + tags.getTagById(PROXY_REFERENCE) + ": "
0635:                                    + proxy);
0636:                        boolean b = (Boolean.valueOf(proxy)).booleanValue();
0637:                        m_CurrentORD.setLazy(b);
0638:
0639:                        // set proxyPrefetchingLimit attribute
0640:                        String proxyPrefetchingLimit = atts.getValue(tags
0641:                                .getTagById(PROXY_PREFETCHING_LIMIT));
0642:                        if (isDebug)
0643:                            logger.debug("     "
0644:                                    + tags.getTagById(PROXY_PREFETCHING_LIMIT)
0645:                                    + ": " + proxyPrefetchingLimit);
0646:                        if (proxyPrefetchingLimit == null) {
0647:                            m_CurrentORD
0648:                                    .setProxyPrefetchingLimit(defProxyPrefetchingLimit);
0649:                        } else {
0650:                            m_CurrentORD.setProxyPrefetchingLimit(Integer
0651:                                    .parseInt(proxyPrefetchingLimit));
0652:                        }
0653:
0654:                        // set refresh attribute
0655:                        String refresh = atts
0656:                                .getValue(tags.getTagById(REFRESH));
0657:                        if (isDebug)
0658:                            logger.debug("     " + tags.getTagById(REFRESH)
0659:                                    + ": " + refresh);
0660:                        b = (Boolean.valueOf(refresh)).booleanValue();
0661:                        m_CurrentORD.setRefresh(b);
0662:
0663:                        // set auto-retrieve attribute
0664:                        String autoRetrieve = atts.getValue(tags
0665:                                .getTagById(AUTO_RETRIEVE));
0666:                        if (isDebug)
0667:                            logger.debug("     "
0668:                                    + tags.getTagById(AUTO_RETRIEVE) + ": "
0669:                                    + autoRetrieve);
0670:                        b = (Boolean.valueOf(autoRetrieve)).booleanValue();
0671:                        m_CurrentORD.setCascadeRetrieve(b);
0672:
0673:                        // set auto-update attribute
0674:                        String autoUpdate = atts.getValue(tags
0675:                                .getTagById(AUTO_UPDATE));
0676:                        if (isDebug)
0677:                            logger.debug("     " + tags.getTagById(AUTO_UPDATE)
0678:                                    + ": " + autoUpdate);
0679:                        if (autoUpdate != null) {
0680:                            m_CurrentORD.setCascadingStore(autoUpdate);
0681:                        }
0682:
0683:                        //set auto-delete attribute
0684:                        String autoDelete = atts.getValue(tags
0685:                                .getTagById(AUTO_DELETE));
0686:                        if (isDebug)
0687:                            logger.debug("     " + tags.getTagById(AUTO_DELETE)
0688:                                    + ": " + autoDelete);
0689:
0690:                        if (autoDelete != null) {
0691:                            m_CurrentORD.setCascadingDelete(autoDelete);
0692:                        }
0693:
0694:                        //set otm-dependent attribute
0695:                        String otmDependent = atts.getValue(tags
0696:                                .getTagById(OTM_DEPENDENT));
0697:                        if (isDebug)
0698:                            logger.debug("     "
0699:                                    + tags.getTagById(OTM_DEPENDENT) + ": "
0700:                                    + otmDependent);
0701:                        b = (Boolean.valueOf(otmDependent)).booleanValue();
0702:                        m_CurrentORD.setOtmDependent(b);
0703:
0704:                        break;
0705:                    }
0706:
0707:                    case FOREIGN_KEY: {
0708:                        if (isDebug)
0709:                            logger.debug("    > "
0710:                                    + tags.getTagById(FOREIGN_KEY));
0711:                        String fieldIdRef = atts.getValue(tags
0712:                                .getTagById(FIELD_ID_REF));
0713:
0714:                        if (fieldIdRef != null) {
0715:                            if (isDebug)
0716:                                logger.debug("      "
0717:                                        + tags.getTagById(FIELD_ID_REF) + ": "
0718:                                        + fieldIdRef);
0719:
0720:                            try {
0721:                                int fieldId;
0722:                                fieldId = Integer.parseInt(fieldIdRef);
0723:                                m_CurrentORD.addForeignKeyField(fieldId);
0724:                            } catch (NumberFormatException rex) {
0725:                                throw new MetadataException(
0726:                                        tags.getTagById(FIELD_ID_REF)
0727:                                                + " attribute must be an int. Found: "
0728:                                                + fieldIdRef
0729:                                                + ". Please check your repository file.",
0730:                                        rex);
0731:                            }
0732:                        } else {
0733:                            String fieldRef = atts.getValue(tags
0734:                                    .getTagById(FIELD_REF));
0735:                            if (isDebug)
0736:                                logger.debug("      "
0737:                                        + tags.getTagById(FIELD_REF) + ": "
0738:                                        + fieldRef);
0739:                            m_CurrentORD.addForeignKeyField(fieldRef);
0740:                        }
0741:                        break;
0742:                    }
0743:
0744:                    case COLLECTION_DESCRIPTOR: {
0745:                        if (isDebug)
0746:                            logger.debug("    > "
0747:                                    + tags.getTagById(COLLECTION_DESCRIPTOR));
0748:                        m_CurrentCOD = new CollectionDescriptor(m_CurrentCLD);
0749:
0750:                        // prepare for custom attributes
0751:                        this .m_CurrentAttrContainer = m_CurrentCOD;
0752:
0753:                        // set name attribute
0754:                        name = atts.getValue(tags.getTagById(FIELD_NAME));
0755:                        if (isDebug)
0756:                            logger.debug("     " + tags.getTagById(FIELD_NAME)
0757:                                    + ": " + name);
0758:                        PersistentField pf = PersistentFieldFactory
0759:                                .createPersistentField(m_CurrentCLD
0760:                                        .getPersistentFieldClassName(),
0761:                                        m_CurrentCLD.getClassOfObject(), name);
0762:                        m_CurrentCOD.setPersistentField(pf);
0763:
0764:                        // set collection-class attribute
0765:                        String collectionClassName = atts.getValue(tags
0766:                                .getTagById(COLLECTION_CLASS));
0767:                        if (collectionClassName != null) {
0768:                            if (isDebug)
0769:                                logger.debug("     "
0770:                                        + tags.getTagById(COLLECTION_CLASS)
0771:                                        + ": " + collectionClassName);
0772:                            m_CurrentCOD.setCollectionClass(ClassHelper
0773:                                    .getClass(collectionClassName));
0774:                        }
0775:                        // set element-class-ref attribute
0776:                        String elementClassRef = atts.getValue(tags
0777:                                .getTagById(ITEMS_CLASS));
0778:                        if (isDebug)
0779:                            logger.debug("     " + tags.getTagById(ITEMS_CLASS)
0780:                                    + ": " + elementClassRef);
0781:                        if (elementClassRef != null) {
0782:                            m_CurrentCOD.setItemClass(ClassHelper
0783:                                    .getClass(elementClassRef));
0784:                        }
0785:
0786:                        //set orderby and sort attributes:
0787:                        String orderby = atts
0788:                                .getValue(tags.getTagById(ORDERBY));
0789:                        String sort = atts.getValue(tags.getTagById(SORT));
0790:                        if (isDebug)
0791:                            logger.debug("     " + tags.getTagById(SORT) + ": "
0792:                                    + orderby + ", " + sort);
0793:                        if (orderby != null) {
0794:                            m_CurrentCOD.addOrderBy(orderby, "ASC"
0795:                                    .equalsIgnoreCase(sort));
0796:                        }
0797:
0798:                        // set indirection-table attribute
0799:                        String indirectionTable = atts.getValue(tags
0800:                                .getTagById(INDIRECTION_TABLE));
0801:                        if (isDebug)
0802:                            logger.debug("     "
0803:                                    + tags.getTagById(INDIRECTION_TABLE) + ": "
0804:                                    + indirectionTable);
0805:                        m_CurrentCOD.setIndirectionTable(indirectionTable);
0806:
0807:                        // set proxy attribute
0808:                        String proxy = atts.getValue(tags
0809:                                .getTagById(PROXY_REFERENCE));
0810:                        if (isDebug)
0811:                            logger.debug("     "
0812:                                    + tags.getTagById(PROXY_REFERENCE) + ": "
0813:                                    + proxy);
0814:                        boolean b = (Boolean.valueOf(proxy)).booleanValue();
0815:                        m_CurrentCOD.setLazy(b);
0816:
0817:                        // set proxyPrefetchingLimit attribute
0818:                        String proxyPrefetchingLimit = atts.getValue(tags
0819:                                .getTagById(PROXY_PREFETCHING_LIMIT));
0820:                        if (isDebug)
0821:                            logger.debug("     "
0822:                                    + tags.getTagById(PROXY_PREFETCHING_LIMIT)
0823:                                    + ": " + proxyPrefetchingLimit);
0824:                        if (proxyPrefetchingLimit == null) {
0825:                            m_CurrentCOD
0826:                                    .setProxyPrefetchingLimit(defProxyPrefetchingLimit);
0827:                        } else {
0828:                            m_CurrentCOD.setProxyPrefetchingLimit(Integer
0829:                                    .parseInt(proxyPrefetchingLimit));
0830:                        }
0831:
0832:                        // set refresh attribute
0833:                        String refresh = atts
0834:                                .getValue(tags.getTagById(REFRESH));
0835:                        if (isDebug)
0836:                            logger.debug("     " + tags.getTagById(REFRESH)
0837:                                    + ": " + refresh);
0838:                        b = (Boolean.valueOf(refresh)).booleanValue();
0839:                        m_CurrentCOD.setRefresh(b);
0840:
0841:                        // set auto-retrieve attribute
0842:                        String autoRetrieve = atts.getValue(tags
0843:                                .getTagById(AUTO_RETRIEVE));
0844:                        if (isDebug)
0845:                            logger.debug("     "
0846:                                    + tags.getTagById(AUTO_RETRIEVE) + ": "
0847:                                    + autoRetrieve);
0848:                        b = (Boolean.valueOf(autoRetrieve)).booleanValue();
0849:                        m_CurrentCOD.setCascadeRetrieve(b);
0850:
0851:                        // set auto-update attribute
0852:                        String autoUpdate = atts.getValue(tags
0853:                                .getTagById(AUTO_UPDATE));
0854:                        if (isDebug)
0855:                            logger.debug("     " + tags.getTagById(AUTO_UPDATE)
0856:                                    + ": " + autoUpdate);
0857:                        if (autoUpdate != null) {
0858:                            m_CurrentCOD.setCascadingStore(autoUpdate);
0859:                        }
0860:
0861:                        //set auto-delete attribute
0862:                        String autoDelete = atts.getValue(tags
0863:                                .getTagById(AUTO_DELETE));
0864:                        if (isDebug)
0865:                            logger.debug("     " + tags.getTagById(AUTO_DELETE)
0866:                                    + ": " + autoDelete);
0867:                        if (autoDelete != null) {
0868:                            m_CurrentCOD.setCascadingDelete(autoDelete);
0869:                        }
0870:
0871:                        //set otm-dependent attribute
0872:                        String otmDependent = atts.getValue(tags
0873:                                .getTagById(OTM_DEPENDENT));
0874:                        if (isDebug)
0875:                            logger.debug("     "
0876:                                    + tags.getTagById(OTM_DEPENDENT) + ": "
0877:                                    + otmDependent);
0878:                        b = (Boolean.valueOf(otmDependent)).booleanValue();
0879:                        m_CurrentCOD.setOtmDependent(b);
0880:
0881:                        m_CurrentCLD.addCollectionDescriptor(m_CurrentCOD);
0882:
0883:                        break;
0884:                    }
0885:                    case ORDERBY: {
0886:                        if (isDebug)
0887:                            logger.debug("    > " + tags.getTagById(ORDERBY));
0888:                        name = atts.getValue(tags.getTagById(FIELD_NAME));
0889:                        if (isDebug)
0890:                            logger.debug("     " + tags.getTagById(FIELD_NAME)
0891:                                    + ": " + name);
0892:                        String sort = atts.getValue(tags.getTagById(SORT));
0893:                        if (isDebug)
0894:                            logger.debug("     " + tags.getTagById(SORT) + ": "
0895:                                    + name + ", " + sort);
0896:
0897:                        m_CurrentCOD.addOrderBy(name, "ASC"
0898:                                .equalsIgnoreCase(sort));
0899:                        break;
0900:                    }
0901:                    case INVERSE_FK: {
0902:                        if (isDebug)
0903:                            logger
0904:                                    .debug("    > "
0905:                                            + tags.getTagById(INVERSE_FK));
0906:                        String fieldIdRef = atts.getValue(tags
0907:                                .getTagById(FIELD_ID_REF));
0908:
0909:                        if (fieldIdRef != null) {
0910:                            if (isDebug)
0911:                                logger.debug("      "
0912:                                        + tags.getTagById(FIELD_ID_REF) + ": "
0913:                                        + fieldIdRef);
0914:
0915:                            try {
0916:                                int fieldId;
0917:                                fieldId = Integer.parseInt(fieldIdRef);
0918:                                m_CurrentCOD.addForeignKeyField(fieldId);
0919:                            } catch (NumberFormatException rex) {
0920:                                throw new MetadataException(
0921:                                        tags.getTagById(FIELD_ID_REF)
0922:                                                + " attribute must be an int. Found: "
0923:                                                + fieldIdRef
0924:                                                + " Please check your repository file.",
0925:                                        rex);
0926:                            }
0927:                        } else {
0928:                            String fieldRef = atts.getValue(tags
0929:                                    .getTagById(FIELD_REF));
0930:                            if (isDebug)
0931:                                logger.debug("      "
0932:                                        + tags.getTagById(FIELD_REF) + ": "
0933:                                        + fieldRef);
0934:                            m_CurrentCOD.addForeignKeyField(fieldRef);
0935:                        }
0936:                        break;
0937:                    }
0938:
0939:                    case FK_POINTING_TO_THIS_CLASS: {
0940:                        if (isDebug)
0941:                            logger
0942:                                    .debug("    > "
0943:                                            + tags
0944:                                                    .getTagById(FK_POINTING_TO_THIS_CLASS));
0945:                        String column = atts.getValue("column");
0946:                        if (isDebug)
0947:                            logger.debug("      " + "column" + ": " + column);
0948:                        m_CurrentCOD.addFkToThisClass(column);
0949:                        break;
0950:                    }
0951:
0952:                    case FK_POINTING_TO_ITEMS_CLASS: {
0953:                        if (isDebug)
0954:                            logger
0955:                                    .debug("    > "
0956:                                            + tags
0957:                                                    .getTagById(FK_POINTING_TO_ITEMS_CLASS));
0958:                        String column = atts.getValue("column");
0959:                        if (isDebug)
0960:                            logger.debug("      " + "column" + ": " + column);
0961:                        m_CurrentCOD.addFkToItemClass(column);
0962:                        break;
0963:                    }
0964:                    case ATTRIBUTE: {
0965:                        //handle custom attributes
0966:                        String attributeName = atts.getValue(tags
0967:                                .getTagById(ATTRIBUTE_NAME));
0968:                        String attributeValue = atts.getValue(tags
0969:                                .getTagById(ATTRIBUTE_VALUE));
0970:                        // If we have a container to store this attribute in, then do so.
0971:                        if (this .m_CurrentAttrContainer != null) {
0972:                            if (isDebug)
0973:                                logger.debug("      > "
0974:                                        + tags.getTagById(ATTRIBUTE));
0975:                            if (isDebug)
0976:                                logger.debug("       "
0977:                                        + tags.getTagById(ATTRIBUTE_NAME)
0978:                                        + ": " + attributeName);
0979:                            if (isDebug)
0980:                                logger.debug("       "
0981:                                        + tags.getTagById(ATTRIBUTE_VALUE)
0982:                                        + ": " + attributeValue);
0983:                            this .m_CurrentAttrContainer.addAttribute(
0984:                                    attributeName, attributeValue);
0985:                        } else {
0986:                            //                            logger.debug("Found attribute (name="+attributeName+", value="+attributeValue+
0987:                            //                                    ") but I can not assign them to a descriptor");
0988:                        }
0989:                        break;
0990:                    }
0991:                        //                    case SEQUENCE_MANAGER:
0992:                        //                    {
0993:                        //                        if (isDebug) logger.debug("    > " + tags.getTagById(SEQUENCE_MANAGER));
0994:                        //                        // currently it's not possible to specify SM on class-descriptor level
0995:                        //                        // thus we use a dummy object to prevent ATTRIBUTE container report
0996:                        //                        // unassigned attributes
0997:                        //                        this.m_CurrentAttrContainer = new SequenceDescriptor(null);
0998:                        //                        break;
0999:                        //                    }
1000:                    case QUERY_CUSTOMIZER: {
1001:                        // set collection-class attribute
1002:                        String className = atts.getValue("class");
1003:                        QueryCustomizer queryCust;
1004:
1005:                        if (className != null) {
1006:                            if (isDebug)
1007:                                logger.debug("     " + "class" + ": "
1008:                                        + className);
1009:                            queryCust = (QueryCustomizer) ClassHelper
1010:                                    .newInstance(className);
1011:                            m_CurrentAttrContainer = queryCust;
1012:                            m_CurrentCOD.setQueryCustomizer(queryCust);
1013:                        }
1014:                        break;
1015:                    }
1016:                    case INDEX_DESCRIPTOR: {
1017:                        m_CurrentIndexDescriptor = new IndexDescriptor();
1018:                        m_CurrentIndexDescriptor.setName(atts.getValue(tags
1019:                                .getTagById(NAME)));
1020:                        m_CurrentIndexDescriptor.setUnique(Boolean.valueOf(
1021:                                atts.getValue(tags.getTagById(UNIQUE)))
1022:                                .booleanValue());
1023:                        break;
1024:                    }
1025:                    case INDEX_COLUMN: {
1026:                        m_CurrentIndexDescriptor.getIndexColumns().add(
1027:                                atts.getValue(tags.getTagById(NAME)));
1028:                        break;
1029:                    }
1030:                    case INSERT_PROCEDURE: {
1031:                        if (isDebug)
1032:                            logger.debug("    > "
1033:                                    + tags.getTagById(INSERT_PROCEDURE));
1034:
1035:                        // Get the proc name and the 'include all fields' setting
1036:                        String procName = atts.getValue(tags.getTagById(NAME));
1037:                        String includeAllFields = atts.getValue(tags
1038:                                .getTagById(INCLUDE_ALL_FIELDS));
1039:                        if (isDebug)
1040:                            logger.debug("     " + tags.getTagById(NAME) + ": "
1041:                                    + procName);
1042:                        if (isDebug)
1043:                            logger.debug("     "
1044:                                    + tags.getTagById(INCLUDE_ALL_FIELDS)
1045:                                    + ": " + includeAllFields);
1046:
1047:                        // create the procedure descriptor
1048:                        InsertProcedureDescriptor proc = new InsertProcedureDescriptor(
1049:                                m_CurrentCLD, procName, Boolean.valueOf(
1050:                                        includeAllFields).booleanValue());
1051:                        m_CurrentProcedure = proc;
1052:
1053:                        // Get the name of the field ref that will receive the
1054:                        // return value.
1055:                        String returnFieldRefName = atts.getValue(tags
1056:                                .getTagById(RETURN_FIELD_REF));
1057:                        if (isDebug)
1058:                            logger.debug("     "
1059:                                    + tags.getTagById(RETURN_FIELD_REF) + ": "
1060:                                    + returnFieldRefName);
1061:                        proc.setReturnValueFieldRef(returnFieldRefName);
1062:
1063:                        break;
1064:                    }
1065:                    case UPDATE_PROCEDURE: {
1066:                        if (isDebug)
1067:                            logger.debug("    > "
1068:                                    + tags.getTagById(UPDATE_PROCEDURE));
1069:
1070:                        // Get the proc name and the 'include all fields' setting
1071:                        String procName = atts.getValue(tags.getTagById(NAME));
1072:                        String includeAllFields = atts.getValue(tags
1073:                                .getTagById(INCLUDE_ALL_FIELDS));
1074:                        if (isDebug)
1075:                            logger.debug("     " + tags.getTagById(NAME) + ": "
1076:                                    + procName);
1077:                        if (isDebug)
1078:                            logger.debug("     "
1079:                                    + tags.getTagById(INCLUDE_ALL_FIELDS)
1080:                                    + ": " + includeAllFields);
1081:
1082:                        // create the procedure descriptor
1083:                        UpdateProcedureDescriptor proc = new UpdateProcedureDescriptor(
1084:                                m_CurrentCLD, procName, Boolean.valueOf(
1085:                                        includeAllFields).booleanValue());
1086:                        m_CurrentProcedure = proc;
1087:
1088:                        // Get the name of the field ref that will receive the
1089:                        // return value.
1090:                        String returnFieldRefName = atts.getValue(tags
1091:                                .getTagById(RETURN_FIELD_REF));
1092:                        if (isDebug)
1093:                            logger.debug("     "
1094:                                    + tags.getTagById(RETURN_FIELD_REF) + ": "
1095:                                    + returnFieldRefName);
1096:                        proc.setReturnValueFieldRef(returnFieldRefName);
1097:
1098:                        break;
1099:                    }
1100:                    case DELETE_PROCEDURE: {
1101:                        if (isDebug)
1102:                            logger.debug("    > "
1103:                                    + tags.getTagById(DELETE_PROCEDURE));
1104:
1105:                        // Get the proc name and the 'include all fields' setting
1106:                        String procName = atts.getValue(tags.getTagById(NAME));
1107:                        String includeAllPkFields = atts.getValue(tags
1108:                                .getTagById(INCLUDE_PK_FIELDS_ONLY));
1109:                        if (isDebug)
1110:                            logger.debug("     " + tags.getTagById(NAME) + ": "
1111:                                    + procName);
1112:                        if (isDebug)
1113:                            logger.debug("     "
1114:                                    + tags.getTagById(INCLUDE_PK_FIELDS_ONLY)
1115:                                    + ": " + includeAllPkFields);
1116:
1117:                        // create the procedure descriptor
1118:                        DeleteProcedureDescriptor proc = new DeleteProcedureDescriptor(
1119:                                m_CurrentCLD, procName, Boolean.valueOf(
1120:                                        includeAllPkFields).booleanValue());
1121:                        m_CurrentProcedure = proc;
1122:
1123:                        // Get the name of the field ref that will receive the
1124:                        // return value.
1125:                        String returnFieldRefName = atts.getValue(tags
1126:                                .getTagById(RETURN_FIELD_REF));
1127:                        if (isDebug)
1128:                            logger.debug("     "
1129:                                    + tags.getTagById(RETURN_FIELD_REF) + ": "
1130:                                    + returnFieldRefName);
1131:                        proc.setReturnValueFieldRef(returnFieldRefName);
1132:
1133:                        break;
1134:
1135:                    }
1136:                    case CONSTANT_ARGUMENT: {
1137:                        if (isDebug)
1138:                            logger.debug("    > "
1139:                                    + tags.getTagById(CONSTANT_ARGUMENT));
1140:                        ArgumentDescriptor arg = new ArgumentDescriptor(
1141:                                m_CurrentProcedure);
1142:
1143:                        // Get the value
1144:                        String value = atts.getValue(tags.getTagById(VALUE));
1145:                        if (isDebug)
1146:                            logger.debug("     " + tags.getTagById(VALUE)
1147:                                    + ": " + value);
1148:
1149:                        // Set the value for the argument
1150:                        arg.setValue(value);
1151:
1152:                        // Add the argument to the procedure.
1153:                        m_CurrentProcedure.addArgument(arg);
1154:                        break;
1155:                    }
1156:                    case RUNTIME_ARGUMENT: {
1157:                        if (isDebug)
1158:                            logger.debug("    > "
1159:                                    + tags.getTagById(RUNTIME_ARGUMENT));
1160:                        ArgumentDescriptor arg = new ArgumentDescriptor(
1161:                                m_CurrentProcedure);
1162:
1163:                        // Get the name of the field ref
1164:                        String fieldRefName = atts.getValue(tags
1165:                                .getTagById(FIELD_REF));
1166:                        if (isDebug)
1167:                            logger.debug("     " + tags.getTagById(FIELD_REF)
1168:                                    + ": " + fieldRefName);
1169:
1170:                        // Get the 'return' value.
1171:                        String returnValue = atts.getValue(tags
1172:                                .getTagById(RETURN));
1173:                        if (isDebug)
1174:                            logger.debug("     " + tags.getTagById(RETURN)
1175:                                    + ": " + returnValue);
1176:
1177:                        // Set the value for the argument.
1178:                        if ((fieldRefName != null)
1179:                                && (fieldRefName.trim().length() != 0)) {
1180:                            arg.setValue(fieldRefName, Boolean.valueOf(
1181:                                    returnValue).booleanValue());
1182:                        }
1183:
1184:                        // Add the argument to the procedure.
1185:                        m_CurrentProcedure.addArgument(arg);
1186:                        break;
1187:                    }
1188:
1189:                    default: {
1190:                        // nop
1191:                    }
1192:                    }
1193:                } catch (Exception ex) {
1194:                    logger.error("Exception while read metadata", ex);
1195:                    if (ex instanceof  MetadataException)
1196:                        throw (MetadataException) ex;
1197:                    else
1198:                        throw new MetadataException(
1199:                                "Exception when reading metadata information,"
1200:                                        + " please check your repository.xml file",
1201:                                ex);
1202:                }
1203:            }
1204:
1205:            /**
1206:             * endElement callback. most elements are build up from here.
1207:             */
1208:            public void endElement(String uri, String name, String qName) {
1209:                boolean isDebug = logger.isDebugEnabled();
1210:                try {
1211:                    switch (getLiteralId(qName)) {
1212:                    case MAPPING_REPOSITORY: {
1213:                        if (isDebug)
1214:                            logger.debug(" < "
1215:                                    + tags.getTagById(MAPPING_REPOSITORY));
1216:                        this .m_CurrentAttrContainer = null;
1217:                        m_CurrentCLD = null;
1218:                        break;
1219:                    }
1220:                    case CLASS_DESCRIPTOR: {
1221:                        if (isDebug)
1222:                            logger.debug("  < "
1223:                                    + tags.getTagById(CLASS_DESCRIPTOR));
1224:                        m_CurrentCLD = null;
1225:                        this .m_CurrentAttrContainer = null;
1226:                        break;
1227:                    }
1228:                    case OBJECT_CACHE: {
1229:                        if (m_CurrentAttrContainer != null) {
1230:                            if (isDebug)
1231:                                logger.debug("     < "
1232:                                        + tags.getTagById(OBJECT_CACHE));
1233:                        }
1234:                        this .m_CurrentAttrContainer = m_CurrentCLD;
1235:                        break;
1236:                    }
1237:                    case CLASS_EXTENT: {
1238:                        break;
1239:                    }
1240:                    case FIELD_DESCRIPTOR: {
1241:                        if (isDebug)
1242:                            logger.debug("    < "
1243:                                    + tags.getTagById(FIELD_DESCRIPTOR));
1244:                        m_CurrentFLD = null;
1245:                        m_CurrentAttrContainer = m_CurrentCLD;
1246:                        break;
1247:                    }
1248:                    case REFERENCE_DESCRIPTOR: {
1249:                        if (isDebug)
1250:                            logger.debug("    < "
1251:                                    + tags.getTagById(REFERENCE_DESCRIPTOR));
1252:                        m_CurrentORD = null;
1253:                        m_CurrentAttrContainer = m_CurrentCLD;
1254:                        break;
1255:                    }
1256:                    case FOREIGN_KEY: {
1257:                        if (isDebug)
1258:                            logger.debug("    < "
1259:                                    + tags.getTagById(FOREIGN_KEY));
1260:                        break;
1261:                    }
1262:                    case COLLECTION_DESCRIPTOR: {
1263:                        if (isDebug)
1264:                            logger.debug("    < "
1265:                                    + tags.getTagById(COLLECTION_DESCRIPTOR));
1266:                        m_CurrentCOD = null;
1267:                        m_CurrentAttrContainer = m_CurrentCLD;
1268:                        break;
1269:                    }
1270:                    case INVERSE_FK: {
1271:                        if (isDebug)
1272:                            logger
1273:                                    .debug("    < "
1274:                                            + tags.getTagById(INVERSE_FK));
1275:                        break;
1276:                    }
1277:                    case ORDERBY: {
1278:                        if (isDebug)
1279:                            logger.debug("    < " + tags.getTagById(ORDERBY));
1280:                        break;
1281:                    }
1282:                    case FK_POINTING_TO_THIS_CLASS: {
1283:                        if (isDebug)
1284:                            logger
1285:                                    .debug("    < "
1286:                                            + tags
1287:                                                    .getTagById(FK_POINTING_TO_THIS_CLASS));
1288:                        break;
1289:                    }
1290:                    case FK_POINTING_TO_ITEMS_CLASS: {
1291:                        if (isDebug)
1292:                            logger
1293:                                    .debug("    < "
1294:                                            + tags
1295:                                                    .getTagById(FK_POINTING_TO_ITEMS_CLASS));
1296:                        break;
1297:                    }
1298:                    case ATTRIBUTE: {
1299:                        if (m_CurrentAttrContainer != null) {
1300:                            if (isDebug)
1301:                                logger.debug("      < "
1302:                                        + tags.getTagById(ATTRIBUTE));
1303:                        }
1304:                        break;
1305:                    }
1306:                    case DOCUMENTATION: {
1307:                        if (isDebug)
1308:                            logger.debug("    < "
1309:                                    + tags.getTagById(DOCUMENTATION));
1310:                        break;
1311:                    }
1312:                        //                case SEQUENCE_MANAGER:
1313:                        //                    {
1314:                        //                        // currently not used on class-descriptor level
1315:                        //                        // if (isDebug) logger.debug("    < " + tags.getTagById(SEQUENCE_MANAGER));
1316:                        //                        this.m_CurrentAttrContainer = null;
1317:                        //                        break;
1318:                        //                    }
1319:                        //                case CONNECTION_POOL:
1320:                        //                    {
1321:                        //                        // not used on class-descriptor level
1322:                        //                        // if (isDebug) logger.debug("    < " + tags.getTagById(CONNECTION_POOL));
1323:                        //                        this.m_CurrentAttrContainer = null;
1324:                        //                        break;
1325:                        //                    }
1326:                        //                case JDBC_CONNECTION_DESCRIPTOR:
1327:                        //                    {
1328:                        //                        // not used on class-descriptor level
1329:                        //                        // if (isDebug) logger.debug("    < " + tags.getTagById(JDBC_CONNECTION_DESCRIPTOR));
1330:                        //                        this.m_CurrentAttrContainer = null;
1331:                        //                        break;
1332:                        //                    }
1333:                    case QUERY_CUSTOMIZER: {
1334:                        m_CurrentAttrContainer = m_CurrentCOD;
1335:                        break;
1336:                    }
1337:                    case INDEX_DESCRIPTOR: {
1338:                        m_CurrentCLD.getIndexes().add(m_CurrentIndexDescriptor);
1339:                        m_CurrentIndexDescriptor = null;
1340:                        break;
1341:                    }
1342:                    case INDEX_COLUMN: {
1343:                        // ignore; all processing done in startElement
1344:                        break;
1345:                    }
1346:                    case INSERT_PROCEDURE: {
1347:                        if (isDebug)
1348:                            logger.debug("    < "
1349:                                    + tags.getTagById(INSERT_PROCEDURE));
1350:                        m_CurrentCLD
1351:                                .setInsertProcedure((InsertProcedureDescriptor) m_CurrentProcedure);
1352:                        m_CurrentProcedure = null;
1353:                        break;
1354:                    }
1355:                    case UPDATE_PROCEDURE: {
1356:                        if (isDebug)
1357:                            logger.debug("    < "
1358:                                    + tags.getTagById(UPDATE_PROCEDURE));
1359:                        m_CurrentCLD
1360:                                .setUpdateProcedure((UpdateProcedureDescriptor) m_CurrentProcedure);
1361:                        m_CurrentProcedure = null;
1362:                        break;
1363:                    }
1364:                    case DELETE_PROCEDURE: {
1365:                        if (isDebug)
1366:                            logger.debug("    < "
1367:                                    + tags.getTagById(DELETE_PROCEDURE));
1368:                        m_CurrentCLD
1369:                                .setDeleteProcedure((DeleteProcedureDescriptor) m_CurrentProcedure);
1370:                        m_CurrentProcedure = null;
1371:                        break;
1372:                    }
1373:                    case CONSTANT_ARGUMENT: {
1374:                        if (isDebug)
1375:                            logger.debug("    < "
1376:                                    + tags.getTagById(CONSTANT_ARGUMENT));
1377:                        break;
1378:                    }
1379:                    case RUNTIME_ARGUMENT: {
1380:                        if (isDebug)
1381:                            logger.debug("    < "
1382:                                    + tags.getTagById(RUNTIME_ARGUMENT));
1383:                        break;
1384:                    }
1385:
1386:                        // handle failure:
1387:                    default: {
1388:                        logger.debug("Ignoring unused Element " + qName);
1389:                    }
1390:                    }
1391:                } catch (Exception ex) {
1392:                    if (ex instanceof  MetadataException)
1393:                        throw (MetadataException) ex;
1394:                    else
1395:                        throw new MetadataException(
1396:                                "Exception when reading metadata information,"
1397:                                        + " please check your repository.xml file",
1398:                                ex);
1399:                }
1400:            }
1401:
1402:            /**
1403:             * characters callback.
1404:             */
1405:            public void characters(char ch[], int start, int length) {
1406:                if (m_CurrentString == null)
1407:                    m_CurrentString = new String(ch, start, length);
1408:                else
1409:                    m_CurrentString += new String(ch, start, length);
1410:            }
1411:
1412:            /**
1413:             * Error callback.
1414:             */
1415:            public void error(SAXParseException e) throws SAXException {
1416:                logger.error(e);
1417:                throw e;
1418:            }
1419:
1420:            /**
1421:             * fatal error callback.
1422:             */
1423:            public void fatalError(SAXParseException e) throws SAXException {
1424:                logger.fatal(e);
1425:                throw e;
1426:            }
1427:
1428:            /**
1429:             * warning callback.
1430:             */
1431:            public void warning(SAXParseException e) throws SAXException {
1432:                logger.warn(e);
1433:                throw e;
1434:            }
1435:
1436:            private boolean checkString(String str) {
1437:                return (str != null && !str.trim().equals(""));
1438:            }
1439:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.