Source Code Cross Referenced for DMSServiceBean.java in  » Workflow-Engines » JFolder » org » jfolder » services » dms » 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 » Workflow Engines » JFolder » org.jfolder.services.dms 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JFolder, Copyright 2001-2006 Gary Steinmetz
003:         *
004:         * Distributable under LGPL license.
005:         * See terms of license at gnu.org.
006:         */
007:
008:        package org.jfolder.services.dms;
009:
010:        //base classes
011:        import java.math.BigDecimal;
012:        import java.sql.Connection;
013:        import java.util.ArrayList;
014:        import java.util.Collections;
015:        import java.util.HashMap;
016:
017:        //project specific classes
018:        import org.jfolder.common.UnexpectedSystemException;
019:        import org.jfolder.common.entity.SystemEntityUpdatesContext;
020:        import org.jfolder.common.files.VirtualFileSystemHolder;
021:        import org.jfolder.common.tagging.ConceptTagCharacteristic;
022:        import org.jfolder.common.tagging.RootConceptTagHolder;
023:        import org.jfolder.common.utils.misc.MiscHelper;
024:        import org.jfolder.dms.model.DocumentFileSystemDirectory;
025:        import org.jfolder.dms.model.DocumentFileSystemDirectoryUpdates;
026:        import org.jfolder.dms.model.DocumentFileSystemFile;
027:        import org.jfolder.dms.model.DocumentFileSystemFileUpdates;
028:        import org.jfolder.dms.model.DocumentFileSystemRoot;
029:        import org.jfolder.dms.model.DocumentFileSystemRootUpdates;
030:        import org.jfolder.dms.model.v1.DocumentFileSystemDirectoryTag;
031:        import org.jfolder.dms.model.v1.DocumentFileSystemHolderTag;
032:        import org.jfolder.dms.model.v1.DocumentFileSystemRootTag;
033:        import org.jfolder.engines.call.GovernorCall;
034:        import org.jfolder.engines.call.GovernorCallHelper;
035:        import org.jfolder.platforms.stores.base.CreateStatement;
036:        import org.jfolder.platforms.stores.base.InsertStatement;
037:        import org.jfolder.platforms.stores.base.SelectStatement;
038:        import org.jfolder.platforms.stores.base.SystemDatabase;
039:        import org.jfolder.platforms.stores.base.SystemResultSet;
040:        import org.jfolder.platforms.stores.base.SystemStatement;
041:        import org.jfolder.platforms.stores.base.SystemStore;
042:        import org.jfolder.platforms.stores.base.SystemStoreFactory;
043:        import org.jfolder.services.base.AbstractBaseServiceBean;
044:
045:        //other classes
046:
047:        public class DMSServiceBean extends AbstractBaseServiceBean implements 
048:                DMSService {
049:
050:            protected DMSServiceBean() {
051:            }
052:
053:            public DocumentFileSystemRoot accessDocumentSystem(
054:                    ConceptTagCharacteristic inCtchar, int inIndex,
055:                    String inSection, String inSubSection) {
056:
057:                Connection conn = null;
058:
059:                try {
060:
061:                    DocumentFileSystemRootTag outValue = null;
062:
063:                    SystemStore ss = SystemStoreFactory.getSystemStore();
064:                    SystemDatabase sd = SystemDatabase.newInstance();
065:
066:                    conn = SystemStore.getConnection(ss);
067:
068:                    BigDecimal docSysRoId[] = new BigDecimal[1];
069:                    BigDecimal version[] = new BigDecimal[1];
070:
071:                    loadIdAndVersion(conn, docSysRoId, version, inSection,
072:                            inSubSection);
073:                    //MiscHelper.println(
074:                    //    "DMSSerBean,accDocSys version = " + version[0]);
075:                    //MiscHelper.println(
076:                    //    "DMSSerB,aDocSys docSysRoId = " + docSysRoId[0]);
077:
078:                    outValue = DocumentFileSystemRootTag.newInstance(inCtchar,
079:                            inIndex, inSection, inSubSection, ((version[0])
080:                                    .intValue() - 1));
081:                    //
082:                    // version - 1, because update below will raise to current version
083:
084:                    //
085:                    CreateStatement docSysFileTable = sd
086:                            .createDocSysFileTable();
087:                    CreateStatement docSysDirTable = sd.createDocSysDirTable();
088:                    //CreateStatement docSysTable = sd.createDocSysTable();
089:                    //CreateStatement docSysRoTable = sd.createDocSysReadOnlyTable();
090:
091:                    //find groups
092:                    SelectStatement docSysDirSelect = SelectStatement
093:                            .createOrderByColumn(
094:                                    SystemDatabase.C_GROUP_PATH_T_DOC_SYS_DIR,
095:                                    docSysDirTable, null);
096:                    //
097:                    docSysDirSelect.addSelectColumn(
098:                            SystemDatabase.C_ACTUAL_NAME_T_DOC_SYS_DIR,
099:                            docSysDirTable, null);
100:                    //
101:                    docSysDirSelect.addSelectColumn(
102:                            SystemDatabase.C_ACTIVE_T_DOC_SYS_DIR,
103:                            docSysDirTable, null);
104:                    //
105:                    docSysDirSelect.addWhereColumn(null,
106:                            SystemStatement.ID_COLUMN, docSysDirTable,
107:                            getLatestDocSysDirIds(inSection, inSubSection,
108:                                    version[0], sd), SelectStatement.IN, null);
109:                    //
110:                    ss.execute(docSysDirSelect, conn);
111:                    //
112:                    SystemResultSet docGroupSrs = docSysDirSelect.getResults();
113:
114:                    //now create groups
115:                    //
116:                    HashMap groupPathToName = new HashMap();
117:                    HashMap groupPathToActive = new HashMap();
118:                    for (int i = 0; i < docGroupSrs.getRowCount(); i++) {
119:                        String nextGroupPath = docGroupSrs.getSString(i, 0);
120:                        String nextActualName = docGroupSrs.getSString(i, 1);
121:                        Boolean nextActive = docGroupSrs.getBoolean(i, 2);
122:                        //DocumentGroup nextDg = DocumentGroupTag.newInstance(nextPath);
123:                        //outValue.addDocumentGroup(nextPath);
124:                        groupPathToName.put(nextGroupPath, nextActualName);
125:                        groupPathToActive.put(nextGroupPath, nextActive);
126:                    }
127:                    //
128:                    ArrayList pathList = new ArrayList(groupPathToName.keySet());
129:                    Collections.sort(pathList);
130:                    for (int i = 0; i < pathList.size(); i++) {
131:                        String nextPath = (String) pathList.get(i);
132:                        ArrayList nextPathList = DocumentFileSystemRootTag
133:                                .parseDirectoryName(nextPath);
134:                        if (nextPathList.size() > 0) {
135:                            nextPathList.remove(nextPathList.size() - 1);
136:                            //
137:                            DocumentFileSystemHolderTag nextParentDir = outValue
138:                                    .getActiveOrDeletedDirectory(nextPathList,
139:                                            0);
140:                            //
141:                            String nextName = (String) groupPathToName
142:                                    .get(nextPath);
143:                            Boolean nextActive = (Boolean) groupPathToActive
144:                                    .get(nextPath);
145:                            //
146:                            if (!nextActive.booleanValue()) {
147:                                nextParentDir
148:                                        .registerDeletedDirectory(nextName);
149:                            } else {
150:                                nextParentDir.registerDirectory(nextName);
151:                            }
152:                        }
153:                    }
154:
155:                    //find instances
156:                    SelectStatement docSysFileSelect = SelectStatement
157:                            .createOrderByColumn(
158:                                    SystemDatabase.C_ACTUAL_NAME_T_DOC_SYS_FILE,
159:                                    docSysFileTable, null);
160:                    docSysFileSelect.addSelectColumn(
161:                            SystemDatabase.C_GROUP_PATH_T_DOC_SYS_DIR,
162:                            docSysDirTable, null);
163:                    docSysFileSelect.addSelectColumn(
164:                            SystemDatabase.C_CONTENT_T_DOC_SYS_FILE,
165:                            docSysFileTable, null);
166:                    docSysFileSelect.addSelectColumn(
167:                            SystemDatabase.C_ACTIVE_T_DOC_SYS_FILE,
168:                            docSysFileTable, null);
169:                    //
170:                    docSysFileSelect.addWhereColumn(null,
171:                            SystemStatement.ID_COLUMN, docSysFileTable,
172:                            getLatestDocSysFileIds(inSection, inSubSection,
173:                                    version[0], sd), SelectStatement.IN, null);
174:                    //
175:                    ss.execute(docSysFileSelect, conn);
176:                    //
177:                    SystemResultSet docSysFileSrs = docSysFileSelect
178:                            .getResults();
179:                    //
180:                    for (int i = 0; i < docSysFileSrs.getRowCount(); i++) {
181:                        String nextName = docSysFileSrs.getSString(i, 0);
182:                        String nextPath = docSysFileSrs.getSString(i, 1);
183:                        byte nextContent[] = docSysFileSrs.getBObject(i, 2);
184:                        Boolean nextActive = docSysFileSrs.getBoolean(i, 3);
185:
186:                        ArrayList nextPathList = DocumentFileSystemRootTag
187:                                .parseDirectoryName(nextPath);
188:                        //
189:                        DocumentFileSystemHolderTag nextParentDir = outValue
190:                                .getActiveOrDeletedDirectory(nextPathList, 0);
191:                        if (nextActive.booleanValue()) {
192:                            nextParentDir.registerFile(nextName, nextContent);
193:                        } else {
194:                            nextParentDir.registerDeletedFile(nextName,
195:                                    nextContent);
196:                        }
197:                    }
198:
199:                    //
200:                    RootConceptTagHolder dummyRcth = GovernorCallHelper
201:                            .createGovernorRequest("dummy", "dummy");
202:                    GovernorCall dummyGc = (GovernorCall) dummyRcth
203:                            .getFirstChildConceptTag();
204:                    outValue.getSystemEntityUpdates(SystemEntityUpdatesContext
205:                            .newInstance(null, true, dummyGc
206:                                    .addPrepareArgumentAsSEntity(), 0));
207:
208:                    return outValue;
209:                } finally {
210:                    SystemStore.closeSQLObjects(conn, null, null);
211:                }
212:            }
213:
214:            public final static DocumentFileSystemRootTag getEmptyTestRoot() {
215:
216:                DocumentFileSystemRootTag outValue = null;
217:
218:                //
219:                RootConceptTagHolder dummyRcth = GovernorCallHelper
220:                        .createGovernorRequest("dummy", "dummy");
221:                GovernorCall dummyGc = (GovernorCall) dummyRcth
222:                        .getFirstChildConceptTag();
223:                outValue = DocumentFileSystemRootTag.newInstance(dummyGc
224:                        .addPrepareArgumentAsSEntity(), 0, "NA_SECTION",
225:                        "NA_SUB_SECTION", (1 - 1));
226:
227:                //
228:                dummyRcth = GovernorCallHelper.createGovernorRequest("dummy",
229:                        "dummy");
230:                dummyGc = (GovernorCall) dummyRcth.getFirstChildConceptTag();
231:                outValue.getSystemEntityUpdates(SystemEntityUpdatesContext
232:                        .newInstance(null, true, dummyGc
233:                                .addPrepareArgumentAsSEntity(), 0));
234:
235:                return outValue;
236:            }
237:
238:            private final static SelectStatement getLatestDocSysFileIds(
239:                    String inSection, String inSubSection,
240:                    BigDecimal inVersion, SystemDatabase inSd) {
241:
242:                SelectStatement outValue = null;
243:
244:                CreateStatement docSysFileTable = inSd.createDocSysFileTable();
245:                CreateStatement docSysDirTable = inSd.createDocSysDirTable();
246:                CreateStatement docSysRoTable = inSd
247:                        .createDocSysReadOnlyTable();
248:                CreateStatement docSysTable = inSd.createDocSysTable();
249:
250:                outValue = SelectStatement.createOrderById(docSysFileTable,
251:                        SystemStatement.MAX_COLUMN);
252:                //
253:                outValue.addToAllTables(docSysTable);
254:                //
255:                //public void addWhereColumn(
256:                //    String inName, Integer inMetaType, CreateStatement inTable,
257:                //    Object inValue, Integer inComparison, Integer inParenthesis) {
258:
259:                outValue.addWhereColumn(SystemDatabase.C_SECTION_T_DOC_SYS_RO,
260:                        SystemStatement.NORMAL_COLUMN, docSysRoTable,
261:                        inSection, SelectStatement.EQUALS, null);
262:                outValue.addWhereColumn(
263:                        SystemDatabase.C_SUB_SECTION_T_DOC_SYS_RO,
264:                        SystemStatement.NORMAL_COLUMN, docSysRoTable,
265:                        inSubSection, SelectStatement.EQUALS, null);
266:                outValue.addWhereColumn(SystemDatabase.C_VERSION_T_DOC_SYS,
267:                        SystemStatement.NORMAL_COLUMN, docSysTable, inVersion,
268:                        SelectStatement.LESS_THAN_OR_EQUAL, null);
269:                //
270:                outValue.blockForeignKey(docSysDirTable,
271:                        SystemDatabase.C_DOC_SYS_ID_T_DOC_SYS_DIR);
272:                //
273:                outValue.addGroupByColumn(
274:                        SystemDatabase.C_GROUP_PATH_T_DOC_SYS_DIR,
275:                        SystemStatement.NORMAL_COLUMN, docSysDirTable);
276:                outValue.addGroupByColumn(
277:                        SystemDatabase.C_GROUP_NAME_T_DOC_SYS_FILE,
278:                        SystemStatement.NORMAL_COLUMN, docSysFileTable);
279:
280:                return outValue;
281:            }
282:
283:            private final static SelectStatement getLatestDocSysDirIds(
284:                    String inSection, String inSubSection,
285:                    BigDecimal inVersion, SystemDatabase inSd) {
286:
287:                SelectStatement outValue = null;
288:
289:                //CreateStatement docInstanceTable = inSd.createDocInstanceTable();
290:                CreateStatement docSysDirTable = inSd.createDocSysDirTable();
291:                CreateStatement docSysRoTable = inSd
292:                        .createDocSysReadOnlyTable();
293:                CreateStatement docSysTable = inSd.createDocSysTable();
294:
295:                outValue = SelectStatement.createOrderById(docSysDirTable,
296:                        SystemStatement.MAX_COLUMN);
297:                //
298:                outValue.addToAllTables(docSysTable);
299:                //
300:                outValue.addWhereColumn(SystemDatabase.C_SECTION_T_DOC_SYS_RO,
301:                        SystemStatement.NORMAL_COLUMN, docSysRoTable,
302:                        inSection, SelectStatement.EQUALS, null);
303:                outValue.addWhereColumn(
304:                        SystemDatabase.C_SUB_SECTION_T_DOC_SYS_RO,
305:                        SystemStatement.NORMAL_COLUMN, docSysRoTable,
306:                        inSubSection, SelectStatement.EQUALS, null);
307:                //
308:                outValue.addWhereColumn(SystemDatabase.C_VERSION_T_DOC_SYS,
309:                        SystemStatement.NORMAL_COLUMN, docSysTable, inVersion,
310:                        SelectStatement.LESS_THAN_OR_EQUAL, null);
311:                //
312:                outValue.addGroupByColumn(
313:                        SystemDatabase.C_GROUP_PATH_T_DOC_SYS_DIR,
314:                        SystemStatement.NORMAL_COLUMN, docSysDirTable);
315:                //outValue.addGroupByColumn(SystemDatabase.C_NAME_T_DOC_INSTANCE,
316:                //    SystemStatement.NORMAL_COLUMN, docInstanceTable);
317:
318:                return outValue;
319:            }
320:
321:            public BigDecimal saveDocumentSystem(
322:                    DocumentFileSystemRootUpdates inDsu) {
323:                //
324:
325:                Connection conn = null;
326:
327:                try {
328:
329:                    BigDecimal outValue = null;
330:
331:                    SystemStore ss = SystemStoreFactory.getSystemStore();
332:                    //SystemDatabase sd = SystemDatabase.newInstance();
333:
334:                    conn = SystemStore.getConnection(ss);
335:
336:                    outValue = saveDocumentSystem(inDsu, conn);
337:                    ss.commit(conn);
338:
339:                    return outValue;
340:                } finally {
341:                    SystemStore.closeSQLObjects(conn, null, null);
342:                }
343:            }
344:
345:            public BigDecimal saveDocumentSystem(
346:                    DocumentFileSystemRootUpdates inDsu, Connection inConn) {
347:
348:                BigDecimal outValue = null;
349:
350:                //Connection conn = null;
351:
352:                //try {
353:
354:                //MiscHelper.println("AbsDMSSerBean::accDocSet this = " + this);
355:                SystemStore ss = SystemStoreFactory.getSystemStore();
356:                SystemDatabase sd = SystemDatabase.newInstance();
357:
358:                //conn = SystemStore.getConnection(ss);
359:
360:                String section = inDsu.getSection();
361:                String subSection = inDsu.getSubSection();
362:
363:                //
364:                BigDecimal docSysRoId[] = new BigDecimal[1];
365:                BigDecimal version[] = new BigDecimal[1];
366:                //
367:                if (inDsu.getVersion() > 1) {
368:                    //do nothing
369:                    loadIdAndVersion(inConn, docSysRoId, version, section,
370:                            subSection);
371:                } else if (inDsu.getVersion() == 1) {
372:                    InsertStatement docSysRoIs = SystemStatement
373:                            .newInsertStatement(sd.createDocSysReadOnlyTable());
374:                    docSysRoIs.setSStringColumn(
375:                            SystemDatabase.C_SECTION_T_DOC_SYS_RO, section);
376:                    docSysRoIs.setSStringColumn(
377:                            SystemDatabase.C_SUB_SECTION_T_DOC_SYS_RO,
378:                            subSection);
379:                    ss.execute(docSysRoIs, inConn);
380:                    //MiscHelper.println("DMSBean docSysRoIs ID = "
381:                    //    + docSysRoIs.getIdColumnValue());
382:                    docSysRoId[0] = docSysRoIs.getIdColumnValue();
383:                    version[0] = new BigDecimal(0);
384:                } else {
385:                    throw UnexpectedSystemException.unknownState();
386:                }
387:
388:                if ((version[0]).intValue() + 1 != inDsu.getVersion()) {
389:                    throw new UnexpectedSystemException("Version '"
390:                            + version[0] + "' has already been saved");
391:                }
392:
393:                //MiscHelper.println("DMSBean docSysRoIs NEXT ID = "
394:                //    + docSysRoId[0]);
395:                //MiscHelper.println("DMSBean docSysRoIs VERSION = "
396:                //    + version[0]);
397:                //
398:                InsertStatement docSysIs = SystemStatement
399:                        .newInsertStatement(sd.createDocSysTable());
400:                docSysIs
401:                        .setDecimalColumn(
402:                                SystemDatabase.C_DOC_SYS_RO_ID_T_DOC_SYS,
403:                                docSysRoId[0]);
404:                docSysIs.setDecimalColumn(SystemDatabase.C_VERSION_T_DOC_SYS,
405:                        new BigDecimal(inDsu.getVersion()));
406:                ss.execute(docSysIs, inConn);
407:
408:                BigDecimal docSysId = docSysIs.getIdColumnValue();
409:
410:                if (inDsu.getVersion() == 1) {
411:                    insertDocSysDir(docSysId,
412:                            VirtualFileSystemHolder.ROOT_DIRECTORY_PATH,
413:                            VirtualFileSystemHolder.ROOT_DIRECTORY_LOCAL_NAME,
414:                            new Boolean(true), inConn, ss, sd);
415:                }
416:
417:                //
418:                for (int i = 0; i < inDsu.getCreateDirectoryCount(); i++) {
419:                    DocumentFileSystemDirectoryUpdates nextDsdu = inDsu
420:                            .getCreateDirectory(i);
421:                    //
422:                    insertDocSysDir(docSysId, nextDsdu.getPath().toUpperCase(),
423:                            nextDsdu.getName(), new Boolean(true), inConn, ss,
424:                            sd);
425:                }
426:                for (int i = 0; i < inDsu.getDeleteDirectoryCount(); i++) {
427:                    DocumentFileSystemDirectoryUpdates nextDsdu = inDsu
428:                            .getDeleteDirectory(i);
429:                    //
430:                    MiscHelper
431:                            .println("DMSSerB delDir = " + nextDsdu.getPath());
432:                    //
433:                    insertDocSysDir(docSysId, nextDsdu.getPath().toUpperCase(),
434:                            nextDsdu.getName(), new Boolean(false), inConn, ss,
435:                            sd);
436:                }
437:                for (int i = 0; i < inDsu.getReviveDirectoryCount(); i++) {
438:                    DocumentFileSystemDirectoryUpdates nextDsdu = inDsu
439:                            .getReviveDirectory(i);
440:                    //
441:                    insertDocSysDir(docSysId, nextDsdu.getPath().toUpperCase(),
442:                            nextDsdu.getName(), new Boolean(true), inConn, ss,
443:                            sd);
444:                }
445:                //
446:                //
447:                HashMap latestDocSysDirIds = getLatestDocSysDirIds(docSysId,
448:                        inConn, ss, sd);
449:                //
450:                for (int i = 0; i < inDsu.getCreateFileCount(); i++) {
451:                    DocumentFileSystemFileUpdates nextDsfu = inDsu
452:                            .getCreateFile(i);
453:                    //
454:                    //MiscHelper.println(
455:                    //    "DMSSerB,savDS pat = " + nextDsfu.getPath());
456:                    BigDecimal nextDocSysDirId = (BigDecimal) latestDocSysDirIds
457:                            .get(nextDsfu.getPath().toUpperCase());
458:                    //
459:                    insertDocSysFile(nextDocSysDirId, docSysId, nextDsfu
460:                            .getName(), nextDsfu.getContent(),
461:                            new Boolean(true), inConn, ss, sd);
462:                }
463:                for (int i = 0; i < inDsu.getUpdateFileCount(); i++) {
464:                    DocumentFileSystemFileUpdates nextDsfu = inDsu
465:                            .getUpdateFile(i);
466:                    //
467:                    BigDecimal nextDocSysDirId = (BigDecimal) latestDocSysDirIds
468:                            .get(nextDsfu.getPath().toUpperCase());
469:                    //
470:                    insertDocSysFile(nextDocSysDirId, docSysId, nextDsfu
471:                            .getName(), nextDsfu.getContent(),
472:                            new Boolean(true), inConn, ss, sd);
473:                }
474:                for (int i = 0; i < inDsu.getDeleteFileCount(); i++) {
475:                    DocumentFileSystemFileUpdates nextDsfu = inDsu
476:                            .getDeleteFile(i);
477:                    //
478:                    MiscHelper
479:                            .println("DMSSerB delFil = " + nextDsfu.getPath());
480:                    //
481:                    BigDecimal nextDocSysDirId = (BigDecimal) latestDocSysDirIds
482:                            .get(nextDsfu.getPath().toUpperCase());
483:                    //
484:                    insertDocSysFile(nextDocSysDirId, docSysId, nextDsfu
485:                            .getName(), null, new Boolean(false), inConn, ss,
486:                            sd);
487:                }
488:                for (int i = 0; i < inDsu.getReviveFileCount(); i++) {
489:                    DocumentFileSystemFileUpdates nextDsfu = inDsu
490:                            .getReviveFile(i);
491:                    //
492:                    BigDecimal nextDocSysDirId = (BigDecimal) latestDocSysDirIds
493:                            .get(nextDsfu.getPath().toUpperCase());
494:                    //
495:                    insertDocSysFile(nextDocSysDirId, docSysId, nextDsfu
496:                            .getName(), nextDsfu.getContent(),
497:                            new Boolean(true), inConn, ss, sd);
498:                }
499:                //
500:
501:                //if (inCommit) {
502:                //    ss.commit(conn);
503:                //}
504:                //
505:                outValue = docSysRoId[0];
506:                //}
507:                //finally {
508:                //    SystemStore.closeSQLObjects(null, null, null);
509:                //}
510:
511:                return outValue;
512:            }
513:
514:            private final static void insertDocSysDir(BigDecimal inDocSysId,
515:                    String inPath, String inName, Boolean inActive,
516:                    Connection inConn, SystemStore inSs, SystemDatabase inSd) {
517:
518:                InsertStatement docSysDirIs = SystemStatement
519:                        .newInsertStatement(inSd.createDocSysDirTable());
520:                //
521:                docSysDirIs.setDecimalColumn(
522:                        SystemDatabase.C_DOC_SYS_ID_T_DOC_SYS_DIR, inDocSysId);
523:                docSysDirIs.setSStringColumn(
524:                        SystemDatabase.C_GROUP_PATH_T_DOC_SYS_DIR, inPath
525:                                .toUpperCase());
526:                docSysDirIs.setSStringColumn(
527:                        SystemDatabase.C_ACTUAL_NAME_T_DOC_SYS_DIR, inName);
528:                docSysDirIs.setBooleanColumn(
529:                        SystemDatabase.C_ACTIVE_T_DOC_SYS_DIR, inActive);
530:                //
531:                inSs.execute(docSysDirIs, inConn);
532:
533:            }
534:
535:            private final static void insertDocSysFile(
536:                    BigDecimal inDocSysDirId, BigDecimal inDocSysId,
537:                    String inName, byte inContent[], Boolean inActive,
538:                    Connection inConn, SystemStore inSs, SystemDatabase inSd) {
539:
540:                InsertStatement docSysFileIs = SystemStatement
541:                        .newInsertStatement(inSd.createDocSysFileTable());
542:                //
543:                docSysFileIs.setDecimalColumn(
544:                        SystemDatabase.C_DOC_SYS_DIR_ID_T_DOC_SYS_FILE,
545:                        inDocSysDirId);
546:                docSysFileIs.setDecimalColumn(
547:                        SystemDatabase.C_DOC_SYS_ID_T_DOC_SYS_FILE, inDocSysId);
548:                docSysFileIs.setSStringColumn(
549:                        SystemDatabase.C_GROUP_NAME_T_DOC_SYS_FILE, inName
550:                                .toUpperCase());
551:                docSysFileIs.setSStringColumn(
552:                        SystemDatabase.C_ACTUAL_NAME_T_DOC_SYS_FILE, inName);
553:                docSysFileIs.setBObjectColumn(
554:                        SystemDatabase.C_CONTENT_T_DOC_SYS_FILE, inContent);
555:                docSysFileIs.setBooleanColumn(
556:                        SystemDatabase.C_ACTIVE_T_DOC_SYS_FILE, inActive);
557:                //
558:                try {
559:                    MiscHelper.println("DMSSerBean,insDocSysFile autoCommit = "
560:                            + inConn.getAutoCommit());
561:                } catch (Exception e) {
562:                }
563:                inSs.execute(docSysFileIs, inConn);
564:                try {
565:                    MiscHelper.println("DMSSerBean,insDocSysFile autoCommit = "
566:                            + inConn.getAutoCommit());
567:                } catch (Exception e) {
568:                }
569:            }
570:
571:            private final static HashMap getLatestDocSysDirIds(
572:                    BigDecimal inDocSysId, Connection inConn, SystemStore inSs,
573:                    SystemDatabase inSd) {
574:
575:                HashMap outValue = new HashMap();
576:
577:                CreateStatement docSysDirTable = inSd.createDocSysDirTable();
578:
579:                SelectStatement docSysDirSelect = SelectStatement
580:                        .createOrderById(docSysDirTable,
581:                                SystemStatement.MAX_COLUMN);
582:                //
583:                docSysDirSelect.addSelectColumn(
584:                        SystemDatabase.C_GROUP_PATH_T_DOC_SYS_DIR,
585:                        docSysDirTable, null);
586:                //
587:                docSysDirSelect.addWhereColumn(
588:                        SystemDatabase.C_DOC_SYS_ID_T_DOC_SYS_DIR,
589:                        SystemStatement.NORMAL_COLUMN, docSysDirTable,
590:                        inDocSysId, SelectStatement.LESS_THAN_OR_EQUAL, null);
591:                //
592:                docSysDirSelect.addGroupByColumn(
593:                        SystemDatabase.C_GROUP_PATH_T_DOC_SYS_DIR,
594:                        SystemStatement.NORMAL_COLUMN, docSysDirTable);
595:                //
596:                docSysDirSelect.setQuerySize(1024 * 1024);
597:                //
598:                inSs.execute(docSysDirSelect, inConn);
599:
600:                //
601:                SystemResultSet srs = docSysDirSelect.getResults();
602:                for (int i = 0; i < srs.getRowCount(); i++) {
603:                    BigDecimal nextId = srs.getDecimal(i, 0);
604:                    String nextPath = srs.getSString(i, 1);
605:
606:                    outValue.put(nextPath, nextId);
607:                }
608:
609:                return outValue;
610:            }
611:
612:            private final static void loadIdAndVersion(Connection inConn,
613:                    BigDecimal inId[], BigDecimal inVersion[],
614:                    String inSection, String inSubSection) {
615:
616:                SystemStore ss = SystemStoreFactory.getSystemStore();
617:                SystemDatabase sd = SystemDatabase.newInstance();
618:
619:                CreateStatement docSysTable = sd.createDocSysTable();
620:                CreateStatement docSysRoTable = sd.createDocSysReadOnlyTable();
621:
622:                //
623:                SelectStatement latestDocSysIdSelect = SelectStatement
624:                        .createOrderByColumn(
625:                                SystemDatabase.C_VERSION_T_DOC_SYS,
626:                                docSysTable, null);
627:                //
628:                latestDocSysIdSelect.addSelectIdColumn(docSysRoTable, null);
629:                latestDocSysIdSelect.setListOrderAscending(false);
630:                latestDocSysIdSelect.addWhereColumn(
631:                        SystemDatabase.C_SECTION_T_DOC_SYS_RO,
632:                        SystemStatement.NORMAL_COLUMN, docSysRoTable,
633:                        inSection, latestDocSysIdSelect.EQUALS, null);
634:                latestDocSysIdSelect.addWhereColumn(
635:                        SystemDatabase.C_SUB_SECTION_T_DOC_SYS_RO,
636:                        SystemStatement.NORMAL_COLUMN, docSysRoTable,
637:                        inSubSection, latestDocSysIdSelect.EQUALS, null);
638:
639:                ss.execute(latestDocSysIdSelect, inConn);
640:                SystemResultSet srs = latestDocSysIdSelect.getResults();
641:
642:                if (srs.getRowCount() > 0) {
643:
644:                    BigDecimal latestVersion = srs.getDecimal(0, 0);
645:                    BigDecimal docSysRoId = srs.getDecimal(0, 1);
646:
647:                    inId[0] = docSysRoId;
648:                    inVersion[0] = latestVersion;
649:                } else {
650:                    inId[0] = new BigDecimal(0);
651:                    inVersion[0] = new BigDecimal(0);
652:                }
653:            }
654:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.