Source Code Cross Referenced for GenericEnvironmentLoader.java in  » J2EE » fleXive » com » flexive » core » storage » genericSQL » 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 » J2EE » fleXive » com.flexive.core.storage.genericSQL 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /***************************************************************
0002:         *  This file is part of the [fleXive](R) project.
0003:         *
0004:         *  Copyright (c) 1999-2008
0005:         *  UCS - unique computing solutions gmbh (http://www.ucs.at)
0006:         *  All rights reserved
0007:         *
0008:         *  The [fleXive](R) project is free software; you can redistribute
0009:         *  it and/or modify it under the terms of the GNU General Public
0010:         *  License as published by the Free Software Foundation;
0011:         *  either version 2 of the License, or (at your option) any
0012:         *  later version.
0013:         *
0014:         *  The GNU General Public License can be found at
0015:         *  http://www.gnu.org/copyleft/gpl.html.
0016:         *  A copy is found in the textfile GPL.txt and important notices to the
0017:         *  license from the author are found in LICENSE.txt distributed with
0018:         *  these libraries.
0019:         *
0020:         *  This library is distributed in the hope that it will be useful,
0021:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0022:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0023:         *  GNU General Public License for more details.
0024:         *
0025:         *  For further information about UCS - unique computing solutions gmbh,
0026:         *  please see the company website: http://www.ucs.at
0027:         *
0028:         *  For further information about [fleXive](R), please see the
0029:         *  project website: http://www.flexive.org
0030:         *
0031:         *
0032:         *  This copyright notice MUST APPEAR in all copies of the file!
0033:         ***************************************************************/package com.flexive.core.storage.genericSQL;
0034:
0035:        import com.flexive.core.Database;
0036:        import static com.flexive.core.DatabaseConst.*;
0037:        import com.flexive.core.LifeCycleInfoImpl;
0038:        import com.flexive.core.storage.EnvironmentLoader;
0039:        import com.flexive.core.structure.FxEnvironmentImpl;
0040:        import com.flexive.core.structure.FxPreloadGroupAssignment;
0041:        import com.flexive.core.structure.FxPreloadType;
0042:        import com.flexive.shared.FxLanguage;
0043:        import com.flexive.shared.FxSharedUtils;
0044:        import com.flexive.shared.exceptions.FxInvalidParameterException;
0045:        import com.flexive.shared.exceptions.FxLoadException;
0046:        import com.flexive.shared.exceptions.FxNotFoundException;
0047:        import com.flexive.shared.scripting.FxScriptEvent;
0048:        import com.flexive.shared.scripting.FxScriptInfo;
0049:        import com.flexive.shared.scripting.FxScriptMapping;
0050:        import com.flexive.shared.scripting.FxScriptMappingEntry;
0051:        import com.flexive.shared.security.ACL;
0052:        import com.flexive.shared.security.Mandator;
0053:        import com.flexive.shared.structure.*;
0054:        import com.flexive.shared.value.FxString;
0055:        import com.flexive.shared.workflow.Route;
0056:        import com.flexive.shared.workflow.Step;
0057:        import com.flexive.shared.workflow.StepDefinition;
0058:        import com.flexive.shared.workflow.Workflow;
0059:        import org.apache.commons.logging.Log;
0060:        import org.apache.commons.logging.LogFactory;
0061:
0062:        import java.sql.*;
0063:        import java.util.ArrayList;
0064:        import java.util.HashMap;
0065:        import java.util.List;
0066:        import java.util.Map;
0067:
0068:        /**
0069:         * generic sql environment loader implementation
0070:         *
0071:         * @author Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
0072:         */
0073:        public class GenericEnvironmentLoader implements  EnvironmentLoader {
0074:
0075:            protected static final transient Log LOG = LogFactory
0076:                    .getLog(GenericEnvironmentLoader.class);
0077:
0078:            /**
0079:             * {@inheritDoc}
0080:             */
0081:            public List<ACL> loadACLs(Connection con) throws FxLoadException {
0082:                Statement stmt = null;
0083:                String curSql;
0084:                ArrayList<ACL> result = new ArrayList<ACL>(250);
0085:                try {
0086:                    //                            1      2          3             4                5          6                 7
0087:                    curSql = "SELECT DISTINCT acl.ID, acl.NAME, acl.CAT_TYPE, acl.DESCRIPTION, acl.COLOR, acl.MANDATOR, mand.NAME, "
0088:                            +
0089:                            //    8               9               10               11
0090:                            " acl.CREATED_BY, acl.CREATED_AT, acl.MODIFIED_BY, acl.MODIFIED_AT FROM "
0091:                            + TBL_ACLS
0092:                            + " acl, "
0093:                            + TBL_MANDATORS
0094:                            + " mand WHERE mand.ID=acl.MANDATOR";
0095:                    stmt = con.createStatement();
0096:                    ResultSet rs = stmt.executeQuery(curSql);
0097:                    while (rs != null && rs.next()) {
0098:                        result.add(new ACL(rs.getInt(1), rs.getString(2),
0099:                                Database.loadFxString(con, TBL_ACLS, "LABEL",
0100:                                        "ID=" + rs.getInt(1)), rs.getInt(6), rs
0101:                                        .getString(7), rs.getString(4), rs
0102:                                        .getString(5), ACL.Category.getById(rs
0103:                                        .getInt(3)), LifeCycleInfoImpl.load(rs,
0104:                                        8, 9, 10, 11)));
0105:                    }
0106:                } catch (SQLException exc) {
0107:                    throw new FxLoadException(LOG, "Failed to load all ACLs: "
0108:                            + exc.getMessage(), exc);
0109:                } finally {
0110:                    Database.closeObjects(GenericEnvironmentLoader.class, null,
0111:                            stmt);
0112:                }
0113:                return result;
0114:            }
0115:
0116:            /**
0117:             * {@inheritDoc}
0118:             */
0119:            public Mandator[] loadMandators(Connection con)
0120:                    throws FxLoadException {
0121:
0122:                PreparedStatement ps = null;
0123:                try {
0124:                    // Load all mandators within the system
0125:                    ps = con
0126:                            .prepareStatement("SELECT ID,NAME,METADATA,IS_ACTIVE,CREATED_BY,CREATED_AT,MODIFIED_BY,MODIFIED_AT FROM "
0127:                                    + TBL_MANDATORS + " order by upper(NAME)");
0128:                    ResultSet rs = ps.executeQuery();
0129:                    ArrayList<Mandator> result = new ArrayList<Mandator>(20);
0130:                    while (rs != null && rs.next()) {
0131:                        result.add(new Mandator(rs.getInt(1), rs.getString(2),
0132:                                rs.getInt(3), rs.getBoolean(4),
0133:                                LifeCycleInfoImpl.load(rs, 5, 6, 7, 8)));
0134:                    }
0135:                    // return the result
0136:                    return result.toArray(new Mandator[result.size()]);
0137:                } catch (SQLException se) {
0138:                    FxLoadException le = new FxLoadException(se.getMessage(),
0139:                            se);
0140:                    LOG.error(le);
0141:                    throw le;
0142:                } finally {
0143:                    Database.closeObjects(GenericEnvironmentLoader.class, null,
0144:                            ps);
0145:                }
0146:            }
0147:
0148:            /**
0149:             * {@inheritDoc}
0150:             */
0151:            public List<FxDataType> loadDataTypes(Connection con)
0152:                    throws FxLoadException {
0153:                Statement stmt = null;
0154:                ArrayList<FxDataType> alRet = new ArrayList<FxDataType>(20);
0155:                try {
0156:                    String sql = "SELECT d.TYPECODE, d.NAME, t.LANG, t.DESCRIPTION FROM "
0157:                            + TBL_STRUCT_DATATYPES
0158:                            + " d, "
0159:                            + TBL_STRUCT_DATATYPES
0160:                            + ML
0161:                            + " t WHERE t.ID=d.TYPECODE ORDER BY d.TYPECODE, t.LANG ASC";
0162:                    stmt = con.createStatement();
0163:                    ResultSet rs = stmt.executeQuery(sql);
0164:                    FxDataType dtCurr = null;
0165:                    Map<Long, String> hmDesc = new HashMap<Long, String>(5);
0166:                    String name = null;
0167:                    while (rs != null && rs.next()) {
0168:                        if (dtCurr != null && rs.getLong(1) != dtCurr.getId()) {
0169:                            dtCurr.initialize(name, new FxString(
0170:                                    FxLanguage.DEFAULT_ID, hmDesc));
0171:                            alRet.add(dtCurr);
0172:                            hmDesc.clear();
0173:                            dtCurr = null;
0174:                        }
0175:                        if (dtCurr == null)
0176:                            for (FxDataType dt : FxDataType.values()) {
0177:                                if (dt.getId() == rs.getInt(1)) {
0178:                                    dtCurr = dt;
0179:                                    break;
0180:                                }
0181:                            }
0182:                        if (dtCurr == null)
0183:                            throw new FxLoadException(LOG,
0184:                                    "ex.structure.dataType.unknownId", rs
0185:                                            .getInt(1));
0186:                        hmDesc.put(rs.getLong(3), rs.getString(4));
0187:                        name = rs.getString(2);
0188:                    }
0189:                    if (dtCurr != null) {
0190:                        dtCurr.initialize(name, new FxString(
0191:                                FxLanguage.DEFAULT_ID, hmDesc));
0192:                        alRet.add(dtCurr);
0193:                    }
0194:                    return alRet;
0195:                } catch (SQLException e) {
0196:                    throw new FxLoadException(LOG, e, "ex.db.sqlError", e
0197:                            .getMessage());
0198:                } finally {
0199:                    Database.closeObjects(GenericEnvironmentLoader.class, null,
0200:                            stmt);
0201:                }
0202:            }
0203:
0204:            /**
0205:             * {@inheritDoc}
0206:             */
0207:            public List<FxGroup> loadGroups(Connection con)
0208:                    throws FxLoadException {
0209:                Statement stmt = null;
0210:                ArrayList<FxGroup> alRet = new ArrayList<FxGroup>(50);
0211:                try {
0212:                    final Map<Long, List<FxStructureOption>> groupOptions = loadAllGroupOptions(con);
0213:                    //final List<FxStructureOption> emptyGroupOptions = new ArrayList<FxStructureOption>(0);
0214:                    //                     1     2       3             4             5                  6       7              8
0215:                    final String sql = "SELECT g.ID, g.NAME, g.DEFMINMULT, g.DEFMAXMULT, g.MAYOVERRIDEMULT, t.LANG, t.DESCRIPTION, t.HINT FROM "
0216:                            + TBL_STRUCT_GROUPS
0217:                            + " g, "
0218:                            + TBL_STRUCT_GROUPS
0219:                            + ML
0220:                            + " t WHERE t.ID=g.ID ORDER BY g.ID, t.LANG ASC";
0221:                    stmt = con.createStatement();
0222:                    ResultSet rs = stmt.executeQuery(sql);
0223:                    Map<Long, String> hmDesc = new HashMap<Long, String>(5);
0224:                    Map<Long, String> hmHint = new HashMap<Long, String>(5);
0225:                    String name = null;
0226:                    long id = -1;
0227:                    int minMult = -1;
0228:                    int maxMult = -1;
0229:                    boolean mayOverride = false;
0230:                    while (rs != null && rs.next()) {
0231:                        if (name != null && rs.getLong(1) != id) {
0232:                            alRet
0233:                                    .add(new FxGroup(
0234:                                            id,
0235:                                            name,
0236:                                            new FxString(FxLanguage.DEFAULT_ID,
0237:                                                    hmDesc),
0238:                                            new FxString(FxLanguage.DEFAULT_ID,
0239:                                                    hmHint),
0240:                                            mayOverride,
0241:                                            new FxMultiplicity(minMult, maxMult),
0242:                                            FxSharedUtils
0243:                                                    .get(
0244:                                                            groupOptions,
0245:                                                            id,
0246:                                                            new ArrayList<FxStructureOption>(
0247:                                                                    0))));
0248:                            hmDesc.clear();
0249:                        }
0250:
0251:                        if (hmDesc.size() == 0) {
0252:                            id = rs.getLong(1);
0253:                            name = rs.getString(2);
0254:                            minMult = rs.getInt(3);
0255:                            maxMult = rs.getInt(4);
0256:                            mayOverride = rs.getBoolean(5);
0257:                        }
0258:                        hmDesc.put(rs.getLong(6), rs.getString(7));
0259:                        hmHint.put(rs.getLong(6), rs.getString(8));
0260:                    }
0261:                    if (hmDesc.size() > 0) {
0262:                        alRet.add(new FxGroup(id, name, new FxString(
0263:                                FxLanguage.DEFAULT_ID, hmDesc), new FxString(
0264:                                FxLanguage.DEFAULT_ID, hmHint), mayOverride,
0265:                                new FxMultiplicity(minMult, maxMult),
0266:                                FxSharedUtils.get(groupOptions, id,
0267:                                        new ArrayList<FxStructureOption>(0))));
0268:                    }
0269:                    return alRet;
0270:                } catch (SQLException e) {
0271:                    throw new FxLoadException(LOG, e, "ex.db.sqlError", e
0272:                            .getMessage());
0273:                } finally {
0274:                    Database.closeObjects(GenericEnvironmentLoader.class, null,
0275:                            stmt);
0276:                }
0277:            }
0278:
0279:            /**
0280:             * {@inheritDoc}
0281:             */
0282:            public List<FxProperty> loadProperties(Connection con,
0283:                    FxEnvironment environment) throws FxLoadException,
0284:                    FxNotFoundException {
0285:                Statement stmt = null;
0286:                ArrayList<FxProperty> alRet = new ArrayList<FxProperty>(50);
0287:                try {
0288:                    final Map<Long, List<FxStructureOption>> propertyOptions = loadAllPropertyOptions(con);
0289:                    //final List<FxStructureOption> emptyPropertyOptions = new ArrayList<FxStructureOption>(0);
0290:
0291:                    //                     1     2       3             4             5                  6       7
0292:                    String sql = "SELECT p.ID, p.NAME, p.DEFMINMULT, p.DEFMAXMULT, p.MAYOVERRIDEMULT, t.LANG, t.DESCRIPTION, "
0293:                            +
0294:                            // 8      9                 10          11
0295:                            "p.ACL, p.MAYOVERRIDEACL, p.DATATYPE, p.REFTYPE, "
0296:                            +
0297:                            // 12                   13               14     15
0298:                            "p.ISFULLTEXTINDEXED, t.DEFAULT_VALUE, t.HINT, p.SYSINTERNAL, "
0299:                            +
0300:                            //16          17
0301:                            "p.REFLIST, p.UNIQUEMODE FROM "
0302:                            + TBL_STRUCT_PROPERTIES
0303:                            + " p, "
0304:                            + TBL_STRUCT_PROPERTIES
0305:                            + ML
0306:                            + " t WHERE t.ID=p.ID ORDER BY p.ID, t.LANG ASC";
0307:                    stmt = con.createStatement();
0308:                    ResultSet rs = stmt.executeQuery(sql);
0309:                    Map<Long, String> hmDesc = new HashMap<Long, String>(5);
0310:                    Map<Long, String> hmHint = new HashMap<Long, String>(5);
0311:                    Map<Long, String> hmDefault = new HashMap<Long, String>(5);
0312:                    String name = null;
0313:                    long id = -1;
0314:                    int minMult = -1;
0315:                    int maxMult = -1;
0316:                    boolean mayOverrideMult = false;
0317:                    boolean mayOverrideACL = false;
0318:                    ACL acl = null;
0319:                    FxDataType dataType = null;
0320:                    boolean fulltextIndexed = false;
0321:                    long refTypeId = -1;
0322:                    long refListId = -1;
0323:                    boolean systemInternal = false;
0324:                    UniqueMode uniqueMode = UniqueMode.None;
0325:
0326:                    while (rs != null && rs.next()) {
0327:                        if (name != null && rs.getLong(1) != id) {
0328:                            //                    if( !name.startsWith("TEST"))
0329:                            //                        System.out.println("=======> Loaded: "+name);
0330:                            alRet
0331:                                    .add(new FxProperty(
0332:                                            id,
0333:                                            name,
0334:                                            new FxString(FxLanguage.DEFAULT_ID,
0335:                                                    hmDesc),
0336:                                            new FxString(FxLanguage.DEFAULT_ID,
0337:                                                    hmHint),
0338:                                            systemInternal,
0339:                                            mayOverrideMult,
0340:                                            new FxMultiplicity(minMult, maxMult),
0341:                                            mayOverrideACL,
0342:                                            acl,
0343:                                            dataType,
0344:                                            new FxString(FxLanguage.DEFAULT_ID,
0345:                                                    hmDefault),
0346:                                            fulltextIndexed,
0347:                                            (refTypeId == -1 ? null
0348:                                                    : environment
0349:                                                            .getType(refTypeId)),
0350:                                            (refListId == -1 ? null
0351:                                                    : environment
0352:                                                            .getSelectList(refListId)),
0353:                                            uniqueMode,
0354:                                            FxSharedUtils
0355:                                                    .get(
0356:                                                            propertyOptions,
0357:                                                            id,
0358:                                                            new ArrayList<FxStructureOption>(
0359:                                                                    0))));
0360:                            hmDesc.clear();
0361:                        }
0362:
0363:                        if (hmDesc.size() == 0) {
0364:                            id = rs.getLong(1);
0365:                            name = rs.getString(2);
0366:                            minMult = rs.getInt(3);
0367:                            maxMult = rs.getInt(4);
0368:                            mayOverrideMult = rs.getBoolean(5);
0369:                            acl = environment.getACL(rs.getInt(8));
0370:                            mayOverrideACL = rs.getBoolean(9);
0371:                            dataType = environment.getDataType(rs.getLong(10));
0372:                            refTypeId = rs.getLong(11);
0373:                            if (rs.wasNull())
0374:                                refTypeId = -1;
0375:                            refListId = rs.getLong(16);
0376:                            if (rs.wasNull())
0377:                                refListId = -1;
0378:                            fulltextIndexed = rs.getBoolean(12);
0379:                            systemInternal = rs.getBoolean(15);
0380:                            uniqueMode = UniqueMode.getById(rs.getInt(17));
0381:                        }
0382:                        hmDesc.put(rs.getLong(6), rs.getString(7));
0383:                        hmDefault.put(rs.getLong(6), rs.getString(13));
0384:                        hmHint.put(rs.getLong(6), rs.getString(14));
0385:                    }
0386:                    if (hmDesc.size() > 0) {
0387:                        //                if( !name.startsWith("TEST"))
0388:                        //                        System.out.println("=======> Loaded: "+name);
0389:                        alRet.add(new FxProperty(id, name, new FxString(
0390:                                FxLanguage.DEFAULT_ID, hmDesc), new FxString(
0391:                                FxLanguage.DEFAULT_ID, hmHint), systemInternal,
0392:                                mayOverrideMult, new FxMultiplicity(minMult,
0393:                                        maxMult), mayOverrideACL, acl,
0394:                                dataType, new FxString(FxLanguage.DEFAULT_ID,
0395:                                        hmDefault), fulltextIndexed,
0396:                                (refTypeId == -1 ? null : environment
0397:                                        .getType(refTypeId)),
0398:                                (refListId == -1 ? null : environment
0399:                                        .getSelectList(refListId)), uniqueMode,
0400:                                FxSharedUtils.get(propertyOptions, id,
0401:                                        new ArrayList<FxStructureOption>(0))));
0402:                    }
0403:                    return alRet;
0404:                } catch (SQLException e) {
0405:                    throw new FxLoadException(LOG, e, "ex.db.sqlError", e
0406:                            .getMessage());
0407:                } finally {
0408:                    Database.closeObjects(GenericEnvironmentLoader.class, null,
0409:                            stmt);
0410:                }
0411:            }
0412:
0413:            /**
0414:             * Load all options for group assignments
0415:             *
0416:             * @param con an open and valid connection
0417:             * @return options
0418:             * @throws SQLException on errors
0419:             */
0420:            private Map<Long, List<FxStructureOption>> loadAllGroupAssignmentOptions(
0421:                    Connection con) throws SQLException {
0422:                return loadAllOptions(con, "ASSID", "ASSID IS NOT NULL",
0423:                        TBL_GROUP_OPTIONS);
0424:            }
0425:
0426:            /**
0427:             * Load all options for groups
0428:             *
0429:             * @param con an open and valid connection
0430:             * @return options
0431:             * @throws SQLException on errors
0432:             */
0433:            private Map<Long, List<FxStructureOption>> loadAllGroupOptions(
0434:                    Connection con) throws SQLException {
0435:                return loadAllOptions(con, "ID", "ASSID IS NULL",
0436:                        TBL_GROUP_OPTIONS);
0437:            }
0438:
0439:            private Map<Long, List<FxStructureOption>> loadAllPropertyAssignmentOptions(
0440:                    Connection con) throws SQLException {
0441:                return loadAllOptions(con, "ASSID", "ASSID IS NOT NULL",
0442:                        TBL_PROPERTY_OPTIONS);
0443:            }
0444:
0445:            private Map<Long, List<FxStructureOption>> loadAllPropertyOptions(
0446:                    Connection con) throws SQLException {
0447:                return loadAllOptions(con, "ID", "ASSID IS NULL",
0448:                        TBL_PROPERTY_OPTIONS);
0449:            }
0450:
0451:            private Map<Long, List<FxStructureOption>> loadAllOptions(
0452:                    Connection con, String idColumn, String whereClause,
0453:                    String table) throws SQLException {
0454:                Statement stmt = null;
0455:                Map<Long, List<FxStructureOption>> result = new HashMap<Long, List<FxStructureOption>>();
0456:                try {
0457:                    stmt = con.createStatement();
0458:                    final ResultSet rs = stmt.executeQuery("SELECT " + idColumn
0459:                            + ",OPTKEY,MAYOVERRIDE,OPTVALUE FROM " + table
0460:                            + " WHERE " + whereClause);
0461:                    while (rs.next()) {
0462:                        final long id = rs.getLong(1);
0463:                        if (!result.containsKey(id)) {
0464:                            result.put(id, new ArrayList<FxStructureOption>());
0465:                        }
0466:                        FxStructureOption.setOption(result.get(id), rs
0467:                                .getString(2), rs.getBoolean(3), rs
0468:                                .getString(4));
0469:                    }
0470:                    return result;
0471:                } finally {
0472:                    Database.closeObjects(GenericEnvironmentLoader.class, null,
0473:                            stmt);
0474:                }
0475:            }
0476:
0477:            /**
0478:             * {@inheritDoc}
0479:             */
0480:            public List<FxType> loadTypes(Connection con,
0481:                    FxEnvironment environment) throws FxLoadException {
0482:                Statement stmt = null;
0483:                PreparedStatement ps = null;
0484:                String curSql;
0485:                ArrayList<FxType> result = new ArrayList<FxType>(20);
0486:                try {
0487:                    //                                 1         2       3        4
0488:                    ps = con
0489:                            .prepareStatement("SELECT TYPESRC, TYPEDST, MAXSRC, MAXDST FROM "
0490:                                    + TBL_STRUCT_TYPERELATIONS
0491:                                    + " WHERE TYPEDEF=?");
0492:                    //               1   2     3       4             5         6          7
0493:                    curSql = "SELECT ID, NAME, PARENT, STORAGE_MODE, CATEGORY, TYPE_MODE, VALIDITY_CHECKS, "
0494:                            +
0495:                            //8         9           10             11            12           13
0496:                            "LANG_MODE, TYPE_STATE, SECURITY_MODE, TRACKHISTORY, HISTORY_AGE, MAX_VERSIONS,"
0497:                            +
0498:                            //14               15                16          17          18           19           20   21
0499:                            "REL_TOTAL_MAXSRC, REL_TOTAL_MAXDST, CREATED_BY, CREATED_AT, MODIFIED_BY, MODIFIED_AT, ACL, WORKFLOW"
0500:                            + " FROM " + TBL_STRUCT_TYPES + " ORDER BY NAME";
0501:
0502:                    stmt = con.createStatement();
0503:                    ResultSet rs = stmt.executeQuery(curSql);
0504:                    ResultSet rsRelations;
0505:                    while (rs != null && rs.next()) {
0506:                        try {
0507:                            ps.setLong(1, rs.getLong(1));
0508:                            ArrayList<FxTypeRelation> alRelations = new ArrayList<FxTypeRelation>(
0509:                                    10);
0510:                            rsRelations = ps.executeQuery();
0511:                            while (rsRelations != null && rsRelations.next())
0512:                                alRelations.add(new FxTypeRelation(
0513:                                        new FxPreloadType(rsRelations
0514:                                                .getLong(1)),
0515:                                        new FxPreloadType(rsRelations
0516:                                                .getLong(2)), rsRelations
0517:                                                .getInt(3), rsRelations
0518:                                                .getInt(4)));
0519:                            long parentId = rs.getLong(3);
0520:                            FxType parentType = rs.wasNull() ? null
0521:                                    : new FxPreloadType(parentId);
0522:                            result.add(new FxType(rs.getLong(1), environment
0523:                                    .getACL(rs.getInt(20)), environment
0524:                                    .getWorkflow(rs.getInt(21)), rs
0525:                                    .getString(2), Database.loadFxString(con,
0526:                                    TBL_STRUCT_TYPES, "description", "id="
0527:                                            + rs.getLong(1)), parentType,
0528:                                    TypeStorageMode.getById(rs.getInt(4)),
0529:                                    TypeCategory.getById(rs.getInt(5)),
0530:                                    TypeMode.getById(rs.getInt(6)), rs
0531:                                            .getBoolean(7), LanguageMode
0532:                                            .getById(rs.getInt(8)), TypeState
0533:                                            .getById(rs.getInt(9)), rs
0534:                                            .getByte(10), rs.getBoolean(11), rs
0535:                                            .getLong(12), rs.getLong(13), rs
0536:                                            .getInt(14), rs.getInt(15),
0537:                                    LifeCycleInfoImpl.load(rs, 16, 17, 18, 19),
0538:                                    new ArrayList<FxType>(5), alRelations));
0539:                        } catch (FxNotFoundException e) {
0540:                            throw new FxLoadException(LOG, e);
0541:                        }
0542:                    }
0543:                } catch (SQLException exc) {
0544:                    throw new FxLoadException(LOG,
0545:                            "Failed to load all FxAssignments: "
0546:                                    + exc.getMessage(), exc);
0547:                } finally {
0548:                    try {
0549:                        if (ps != null)
0550:                            ps.close();
0551:                    } catch (SQLException e) {
0552:                        //ignore
0553:                    }
0554:                    Database.closeObjects(GenericEnvironmentLoader.class, null,
0555:                            stmt);
0556:                }
0557:                return result;
0558:            }
0559:
0560:            /**
0561:             * {@inheritDoc}
0562:             */
0563:            public List<FxAssignment> loadAssignments(Connection con,
0564:                    FxEnvironment environment) throws FxLoadException {
0565:                Statement stmt = null;
0566:                String curSql;
0567:                ArrayList<FxAssignment> result = new ArrayList<FxAssignment>(
0568:                        250);
0569:                try {
0570:                    final Map<Long, FxString[]> translations = Database
0571:                            .loadFxStrings(con, TBL_STRUCT_ASSIGNMENTS,
0572:                                    new String[] { "DESCRIPTION", "HINT",
0573:                                            "DEFAULT_VALUE" });
0574:                    final FxString[] emptyTranslation = new FxString[] {
0575:                            new FxString(""), new FxString(""),
0576:                            new FxString("") };
0577:                    final Map<Long, List<FxStructureOption>> propertyAssignmentOptions = loadAllPropertyAssignmentOptions(con);
0578:                    final Map<Long, List<FxStructureOption>> groupAssignmentOptions = loadAllGroupAssignmentOptions(con);
0579:                    //final List<FxStructureOption> emptyOptions = new ArrayList<FxStructureOption>(0);
0580:
0581:                    //               1   2      3        4        5        6        7    8      9
0582:                    curSql = "SELECT ID, ATYPE, ENABLED, TYPEDEF, MINMULT, MAXMULT, POS, XPATH, XALIAS, "
0583:                            +
0584:                            //10          11      12         13   14    15       16           17         18
0585:                            "PARENTGROUP, AGROUP, APROPERTY, ACL, BASE, DEFLANG, SYSINTERNAL, GROUPMODE, DEFMULT FROM "
0586:                            + TBL_STRUCT_ASSIGNMENTS
0587:                            + " ORDER BY TYPEDEF, PARENTGROUP, POS";
0588:
0589:                    stmt = con.createStatement();
0590:                    ResultSet rs = stmt.executeQuery(curSql);
0591:                    while (rs != null && rs.next()) {
0592:                        switch (rs.getInt(2)) { //ATYPE
0593:                        case FxAssignment.TYPE_GROUP:
0594:                            if (rs.getLong(1) == FxAssignment.NO_PARENT)
0595:                                break;
0596:                            final FxString[] desc_hint = FxSharedUtils.get(
0597:                                    translations, rs.getLong(1),
0598:                                    emptyTranslation);
0599:                            FxGroupAssignment ga = new FxGroupAssignment(
0600:                                    rs.getLong(1),
0601:                                    rs.getBoolean(3),
0602:                                    environment.getType(rs.getLong(4)),
0603:                                    rs.getString(9),
0604:                                    rs.getString(8),
0605:                                    rs.getInt(7),
0606:                                    new FxMultiplicity(rs.getInt(5), rs
0607:                                            .getInt(6)),
0608:                                    rs.getInt(18),
0609:                                    new FxPreloadGroupAssignment(rs.getLong(10)),
0610:                                    rs.getLong(14),
0611:                                    desc_hint[0],
0612:                                    desc_hint[1],
0613:                                    environment.getGroup(rs.getLong(11)),
0614:                                    GroupMode.getById(rs.getInt(17)),
0615:                                    FxSharedUtils
0616:                                            .get(
0617:                                                    groupAssignmentOptions,
0618:                                                    rs.getLong(1),
0619:                                                    new ArrayList<FxStructureOption>(
0620:                                                            0)));
0621:                            if (rs.getBoolean(16))
0622:                                ga._setSystemInternal();
0623:                            result.add(ga);
0624:                            break;
0625:                        case FxAssignment.TYPE_PROPERTY:
0626:                            final FxString[] desc_hint_def = FxSharedUtils.get(
0627:                                    translations, rs.getLong(1),
0628:                                    emptyTranslation);
0629:                            FxPropertyAssignment pa = new FxPropertyAssignment(
0630:                                    rs.getLong(1),
0631:                                    rs.getBoolean(3),
0632:                                    environment.getType(rs.getLong(4)),
0633:                                    rs.getString(9),
0634:                                    rs.getString(8),
0635:                                    rs.getInt(7),
0636:                                    new FxMultiplicity(rs.getInt(5), rs
0637:                                            .getInt(6)),
0638:                                    rs.getInt(18),
0639:                                    new FxPreloadGroupAssignment(rs.getLong(10)),
0640:                                    rs.getLong(14),
0641:                                    desc_hint_def[0],
0642:                                    desc_hint_def[1],
0643:                                    desc_hint_def[2],
0644:                                    environment.getProperty(rs.getLong(12)),
0645:                                    environment.getACL(rs.getInt(13)),
0646:                                    rs.getInt(15),
0647:                                    FxSharedUtils
0648:                                            .get(
0649:                                                    propertyAssignmentOptions,
0650:                                                    rs.getLong(1),
0651:                                                    new ArrayList<FxStructureOption>(
0652:                                                            0)));
0653:                            if (rs.getBoolean(16))
0654:                                pa._setSystemInternal();
0655:                            result.add(pa);
0656:                            break;
0657:                        default:
0658:                            LOG.error("Invalid assignment type " + rs.getInt(2)
0659:                                    + " for assignment #" + rs.getLong(1));
0660:                        }
0661:                    }
0662:                    for (FxAssignment as : result)
0663:                        as.resolvePreloadDependencies(result);
0664:                    for (FxAssignment as : result)
0665:                        as.resolveParentDependencies(result);
0666:                } catch (SQLException exc) {
0667:                    throw new FxLoadException(LOG,
0668:                            "Failed to load all FxAssignments: "
0669:                                    + exc.getMessage(), exc);
0670:                } catch (FxNotFoundException e) {
0671:                    throw new FxLoadException(e);
0672:                } finally {
0673:                    Database.closeObjects(GenericEnvironmentLoader.class, null,
0674:                            stmt);
0675:                }
0676:                return result;
0677:            }
0678:
0679:            /**
0680:             * {@inheritDoc}
0681:             */
0682:            public List<Workflow> loadWorkflows(Connection con,
0683:                    FxEnvironment environment) throws FxLoadException {
0684:                Statement stmt = null;
0685:                final String sql = "SELECT ID, NAME, DESCRIPTION FROM "
0686:                        + TBL_WORKFLOW;
0687:                try {
0688:                    // Create the new workflow instance
0689:                    stmt = con.createStatement();
0690:                    // Read all defined workflows
0691:                    stmt = con.createStatement();
0692:                    ResultSet rs = stmt.executeQuery(sql);
0693:                    ArrayList<Workflow> tmp = new ArrayList<Workflow>(10);
0694:                    while (rs != null && rs.next()) {
0695:                        int id = rs.getInt(1);
0696:                        String name = rs.getString(2);
0697:                        String description = rs.getString(3);
0698:                        ArrayList<Step> wfSteps = new ArrayList<Step>(5);
0699:                        for (Step step : environment.getSteps()) {
0700:                            if (step.getWorkflowId() == id) {
0701:                                wfSteps.add(step);
0702:                            }
0703:                        }
0704:                        tmp.add(new Workflow(id, name, description, wfSteps,
0705:                                loadRoutes(con, id)));
0706:                    }
0707:                    return tmp;
0708:                } catch (SQLException exc) {
0709:                    String sErr = "Unable to retrieve workflows";
0710:                    LOG.error(sErr + ", sql=" + sql);
0711:                    throw new FxLoadException(sErr, exc);
0712:                } finally {
0713:                    Database.closeObjects(GenericEnvironmentLoader.class, null,
0714:                            stmt);
0715:                }
0716:            }
0717:
0718:            /**
0719:             * {@inheritDoc}
0720:             */
0721:            public List<StepDefinition> loadStepDefinitions(Connection con)
0722:                    throws FxLoadException {
0723:                Statement stmt = null;
0724:                try {
0725:                    // Read all stepDefinitions from the database
0726:                    stmt = con.createStatement();
0727:                    //                                             1  2           3
0728:                    final ResultSet rs = stmt
0729:                            .executeQuery("SELECT ID,DESCRIPTION,UNIQUE_TARGET FROM "
0730:                                    + TBL_STEPDEFINITION);
0731:                    ArrayList<StepDefinition> tmp = new ArrayList<StepDefinition>(
0732:                            10);
0733:
0734:                    // Build the result array set
0735:                    while (rs != null && rs.next()) {
0736:                        int id = rs.getInt(1);
0737:                        String description = rs.getString(2);
0738:                        int uniqueTargetId = rs.getInt(3);
0739:                        if (rs.wasNull()) {
0740:                            uniqueTargetId = -1;
0741:                        }
0742:                        FxString name = Database.loadFxString(con,
0743:                                TBL_STEPDEFINITION, "name", "id=" + id);
0744:                        StepDefinition aStepDef = new StepDefinition(id, name,
0745:                                description, uniqueTargetId);
0746:                        tmp.add(aStepDef);
0747:                    }
0748:                    return tmp;
0749:                } catch (SQLException exc) {
0750:                    throw new FxLoadException(LOG,
0751:                            "Unable to read steps definitions", exc);
0752:                } finally {
0753:                    Database.closeObjects(GenericEnvironmentLoader.class, null,
0754:                            stmt);
0755:                }
0756:            }
0757:
0758:            /**
0759:             * {@inheritDoc}
0760:             */
0761:            public List<Step> loadSteps(Connection con) throws FxLoadException {
0762:                Statement stmt = null;
0763:                //                                      1      2               3                4
0764:                final String sql = "SELECT DISTINCT stp.ID, stp.WORKFLOW, stp.STEPDEF,stp.ACL "
0765:                        + "FROM " + TBL_STEP + " stp";
0766:                try {
0767:                    // Load all steps in the database
0768:                    stmt = con.createStatement();
0769:                    ResultSet rs = stmt.executeQuery(sql);
0770:                    ArrayList<Step> steps = new ArrayList<Step>(30);
0771:                    while (rs != null && rs.next())
0772:                        steps.add(new Step(rs.getLong(1), rs.getLong(3), rs
0773:                                .getLong(2), rs.getLong(4)));
0774:
0775:                    return steps;
0776:                } catch (SQLException exc) {
0777:                    throw new FxLoadException(LOG,
0778:                            "Unable to read the steps from the database. "
0779:                                    + "Error=" + exc.getMessage() + ", sql="
0780:                                    + sql, exc);
0781:                } finally {
0782:                    Database.closeObjects(GenericEnvironmentLoader.class, null,
0783:                            stmt);
0784:                }
0785:            }
0786:
0787:            /**
0788:             * {@inheritDoc}
0789:             */
0790:            public List<Route> loadRoutes(Connection con, int workflowId)
0791:                    throws FxLoadException {
0792:                //                             1     2               3             4
0793:                final String sql = "SELECT ro.ID,ro.FROM_STEP,ro.TO_STEP,ro.USERGROUP "
0794:                        + "FROM "
0795:                        + TBL_ROUTES
0796:                        + " ro, "
0797:                        + TBL_STEP
0798:                        + " stp "
0799:                        + "WHERE ro.TO_STEP=stp.ID AND stp.WORKFLOW="
0800:                        + workflowId + " " + "ORDER BY ro.USERGROUP ASC";
0801:
0802:                if (LOG.isDebugEnabled())
0803:                    LOG.debug("getRoute(" + workflowId + ")=" + sql);
0804:
0805:                Statement stmt = null;
0806:                try {
0807:                    stmt = con.createStatement();
0808:                    ResultSet rs = stmt.executeQuery(sql);
0809:                    ArrayList<Route> routes = new ArrayList<Route>(50);
0810:
0811:                    // Process result set
0812:                    while (rs != null && rs.next()) {
0813:                        long routeId = rs.getLong(1);
0814:                        long fromId = rs.getLong(2);
0815:                        long toId = rs.getLong(3);
0816:                        long groupId = rs.getLong(4);
0817:                        Route route = new Route(routeId, groupId, fromId, toId);
0818:                        routes.add(route);
0819:                    }
0820:
0821:                    return routes;
0822:                } catch (SQLException exc) {
0823:                    throw new FxLoadException(LOG,
0824:                            "Unable to load routes for workflow [" + workflowId
0825:                                    + "], msg=" + exc.getMessage() + ", sql="
0826:                                    + sql, exc);
0827:                } finally {
0828:                    Database.closeObjects(GenericEnvironmentLoader.class, null,
0829:                            stmt);
0830:                }
0831:            }
0832:
0833:            /**
0834:             * {@inheritDoc}
0835:             */
0836:            public List<FxScriptInfo> loadScripts(Connection con)
0837:                    throws FxLoadException, FxNotFoundException,
0838:                    FxInvalidParameterException {
0839:                PreparedStatement ps = null;
0840:                String sql;
0841:                List<FxScriptInfo> scripts = new ArrayList<FxScriptInfo>(10);
0842:                try {
0843:                    //            1  2     3     4     5       6
0844:                    sql = "SELECT ID,SNAME,SDESC,SDATA,STYPE,ACTIVE FROM "
0845:                            + TBL_SCRIPTS + " ORDER BY ID";
0846:                    ps = con.prepareStatement(sql);
0847:                    ResultSet rs = ps.executeQuery();
0848:                    while (rs != null && rs.next())
0849:                        scripts.add(new FxScriptInfo(rs.getLong(1),
0850:                                FxScriptEvent.getById(rs.getLong(5)), rs
0851:                                        .getString(2), rs.getString(3), rs
0852:                                        .getString(4), rs.getBoolean(6)));
0853:                } catch (SQLException exc) {
0854:                    throw new FxLoadException(LOG, exc,
0855:                            "ex.scripting.load.failed", -1, exc.getMessage());
0856:                } finally {
0857:                    Database.closeObjects(GenericEnvironmentLoader.class, null,
0858:                            ps);
0859:                }
0860:                return scripts;
0861:            }
0862:
0863:            /**
0864:             * {@inheritDoc}
0865:             */
0866:            public List<FxScriptMapping> loadScriptMapping(Connection con,
0867:                    FxEnvironmentImpl environment) throws FxLoadException {
0868:                List<FxScriptMapping> mapping = new ArrayList<FxScriptMapping>(
0869:                        20);
0870:                List<FxScriptMappingEntry> e_ass;
0871:                List<FxScriptMappingEntry> e_types;
0872:                PreparedStatement ps_a = null, ps_t = null;
0873:                String sql;
0874:                try {
0875:                    //            1          2             3      4
0876:                    sql = "SELECT ASSIGNMENT,DERIVED_USAGE,ACTIVE,STYPE FROM "
0877:                            + TBL_SCRIPT_MAPPING_ASSIGN + " WHERE SCRIPT=?";
0878:                    ps_a = con.prepareStatement(sql);
0879:                    sql = "SELECT TYPEDEF,DERIVED_USAGE,ACTIVE,STYPE FROM "
0880:                            + TBL_SCRIPT_MAPPING_TYPES + " WHERE SCRIPT=?";
0881:                    ps_t = con.prepareStatement(sql);
0882:                    ResultSet rs;
0883:                    for (FxScriptInfo si : environment.getScripts()) {
0884:                        ps_a.setLong(1, si.getId());
0885:                        ps_t.setLong(1, si.getId());
0886:                        rs = ps_a.executeQuery();
0887:                        e_ass = new ArrayList<FxScriptMappingEntry>(20);
0888:                        e_types = new ArrayList<FxScriptMappingEntry>(20);
0889:                        while (rs != null && rs.next()) {
0890:                            long[] derived;
0891:                            if (!rs.getBoolean(2))
0892:                                derived = new long[0];
0893:                            else {
0894:                                List<FxAssignment> ass = environment
0895:                                        .getDerivedAssignments(rs.getLong(1));
0896:                                derived = new long[ass.size()];
0897:                                for (int i = 0; i < ass.size(); i++)
0898:                                    derived[i] = ass.get(i).getId();
0899:                            }
0900:                            e_ass.add(new FxScriptMappingEntry(FxScriptEvent
0901:                                    .getById(rs.getLong(4)), si.getId(), rs
0902:                                    .getBoolean(3), rs.getBoolean(2), rs
0903:                                    .getLong(1), derived));
0904:                        }
0905:                        rs = ps_t.executeQuery();
0906:                        while (rs != null && rs.next()) {
0907:                            long[] derived;
0908:                            if (!rs.getBoolean(2))
0909:                                derived = new long[0];
0910:                            else {
0911:                                List<FxType> types = environment.getType(
0912:                                        rs.getLong(1)).getDerivedTypes();
0913:                                derived = new long[types.size()];
0914:                                for (int i = 0; i < types.size(); i++)
0915:                                    derived[i] = types.get(i).getId();
0916:                            }
0917:                            e_types.add(new FxScriptMappingEntry(FxScriptEvent
0918:                                    .getById(rs.getLong(4)), si.getId(), rs
0919:                                    .getBoolean(3), rs.getBoolean(2), rs
0920:                                    .getLong(1), derived));
0921:                        }
0922:                        mapping.add(new FxScriptMapping(si.getId(), e_types,
0923:                                e_ass));
0924:                    }
0925:
0926:                } catch (SQLException exc) {
0927:                    throw new FxLoadException(LOG, exc,
0928:                            "ex.scripting.mapping.load.failed", exc
0929:                                    .getMessage());
0930:                } catch (FxNotFoundException e) {
0931:                    throw new FxLoadException(e);
0932:                } finally {
0933:                    try {
0934:                        if (ps_t != null)
0935:                            ps_t.close();
0936:                    } catch (SQLException e) {
0937:                        //ignore
0938:                    }
0939:                    Database.closeObjects(GenericEnvironmentLoader.class, null,
0940:                            ps_a);
0941:                }
0942:                return mapping;
0943:            }
0944:
0945:            /**
0946:             * {@inheritDoc}
0947:             */
0948:            public List<FxSelectList> loadSelectLists(Connection con,
0949:                    FxEnvironmentImpl environment) throws FxLoadException {
0950:                PreparedStatement ps = null;
0951:                String sql;
0952:                List<FxSelectList> lists = new ArrayList<FxSelectList>(10);
0953:                try {
0954:                    final Map<Long, FxString[]> translations = Database
0955:                            .loadFxStrings(con, TBL_SELECTLIST, new String[] {
0956:                                    "LABEL", "DESCRIPTION" });
0957:                    final FxString[] emptyTranslation = new FxString[] {
0958:                            new FxString(""), new FxString("") };
0959:                    final Map<Long, FxString[]> itemTranslations = Database
0960:                            .loadFxStrings(con, TBL_SELECTLIST_ITEM,
0961:                                    new String[] { "LABEL" });
0962:                    final FxString[] emptyItemTranslation = new FxString[] {
0963:                            new FxString(""), new FxString(""),
0964:                            new FxString("") };
0965:
0966:                    //            1  2        3    4                 5               6            7
0967:                    sql = "SELECT ID,PARENTID,NAME,ALLOW_ITEM_CREATE,ACL_CREATE_ITEM,ACL_ITEM_NEW,DEFAULT_ITEM FROM "
0968:                            + TBL_SELECTLIST + " ORDER BY NAME";
0969:                    ps = con.prepareStatement(sql);
0970:                    ResultSet rs = ps.executeQuery();
0971:                    while (rs != null && rs.next()) {
0972:                        FxString[] strings = FxSharedUtils.get(translations, rs
0973:                                .getLong(1), emptyTranslation);
0974:                        long parent = rs.getLong(2);
0975:                        if (rs.wasNull())
0976:                            parent = -1;
0977:                        lists.add(new FxSelectList(rs.getLong(1), parent, rs
0978:                                .getString(3), strings[0], strings[1], rs
0979:                                .getBoolean(5), environment.getACL(rs
0980:                                .getLong(5)),
0981:                                environment.getACL(rs.getLong(6)), rs
0982:                                        .getLong(7)));
0983:                    }
0984:                    ps.close();
0985:                    //            1  2   3        4    5     6          7          8           9           10      11       12
0986:                    sql = "SELECT ID,ACL,PARENTID,DATA,COLOR,CREATED_BY,CREATED_AT,MODIFIED_BY,MODIFIED_AT,DBIN_ID,DBIN_VER,DBIN_QUALITY FROM "
0987:                            + TBL_SELECTLIST_ITEM
0988:                            + " WHERE LISTID=? ORDER BY ID";
0989:                    ps = con.prepareStatement(sql);
0990:                    for (FxSelectList list : lists) {
0991:                        ps.setLong(1, list.getId());
0992:                        rs = ps.executeQuery();
0993:                        while (rs != null && rs.next()) {
0994:                            long parent = rs.getLong(3);
0995:                            if (rs.wasNull())
0996:                                parent = -1;
0997:                            new FxSelectListItem(
0998:                                    rs.getLong(1),
0999:                                    environment.getACL(rs.getLong(2)),
1000:                                    list,
1001:                                    parent,
1002:                                    FxSharedUtils.get(itemTranslations, rs
1003:                                            .getLong(1), emptyItemTranslation)[0],
1004:                                    rs.getString(4), rs.getString(5), rs
1005:                                            .getLong(10), rs.getInt(11), rs
1006:                                            .getInt(12), LifeCycleInfoImpl
1007:                                            .load(rs, 6, 7, 8, 9));
1008:                        }
1009:                    }
1010:                } catch (SQLException exc) {
1011:                    throw new FxLoadException(LOG, exc,
1012:                            "ex.structure.list.load.failed", exc.getMessage());
1013:                } finally {
1014:                    Database.closeObjects(GenericEnvironmentLoader.class, null,
1015:                            ps);
1016:                }
1017:                return lists;
1018:            }
1019:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.