Source Code Cross Referenced for AbstractBaseServiceBean.java in  » Workflow-Engines » JFolder » org » jfolder » services » base » 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.base 
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.base;
009:
010:        //base classes
011:        import java.math.BigDecimal;
012:        import java.sql.Connection;
013:        import java.util.HashMap;
014:
015:        //project specific classes
016:        import org.jfolder.common.entity.SystemEntity;
017:        import org.jfolder.common.entity.properties.SystemEntityProperties;
018:        import org.jfolder.common.entity.properties.SystemEntityPropertiesUpdates;
019:        import org.jfolder.common.entity.properties.v1.SystemEntityPropertiesTag;
020:        import org.jfolder.common.tagging.ConceptTagCharacteristic;
021:        import org.jfolder.common.tagging.ConceptTagCharacteristicHolder;
022:        import org.jfolder.common.utils.misc.MiscHelper;
023:        import org.jfolder.platforms.stores.base.CreateStatement;
024:        import org.jfolder.platforms.stores.base.InsertStatement;
025:        import org.jfolder.platforms.stores.base.SelectStatement;
026:        import org.jfolder.platforms.stores.base.SystemDatabase;
027:        import org.jfolder.platforms.stores.base.SystemResultSet;
028:        import org.jfolder.platforms.stores.base.SystemStatement;
029:        import org.jfolder.platforms.stores.base.SystemStore;
030:        import org.jfolder.security.audit.SecurityAudit;
031:        import org.jfolder.security.audit.SecurityAuditHelper;
032:        import org.jfolder.security.audit.SimpleSecurityAudit;
033:        import org.jfolder.security.model.SimpleUserIdentity;
034:        import org.jfolder.security.model.UserIdentity;
035:
036:        //other classes
037:
038:        public abstract class AbstractBaseServiceBean implements  BaseService {
039:
040:            public final static String RESULTS = "RESULTS";
041:
042:            protected AbstractBaseServiceBean() {
043:            }
044:
045:            protected ConceptTagCharacteristic createResultsCtchar(
046:                    ConceptTagCharacteristic inParentCtchar, int inIndex) {
047:                //
048:                ConceptTagCharacteristic outValue = null;
049:
050:                ConceptTagCharacteristicHolder subCtcharh = inParentCtchar
051:                        .createRegisteredHolder(inIndex, true);
052:                outValue = subCtcharh.registerCharacteristic(RESULTS);
053:
054:                return outValue;
055:            }
056:
057:            protected SystemEntityProperties accessProperties(
058:                    ConceptTagCharacteristic inCtchar, int inIndex,
059:                    BigDecimal inId, Connection inConn, SystemStore inSs) {
060:
061:                SystemEntityPropertiesTag outValue = null;
062:
063:                //outValue = SystemEntityPropertiesTag.newInstance(inCtchar, inIndex);
064:
065:                //
066:                String propDoc = null;
067:                HashMap propNames = new HashMap();
068:                HashMap propValues = new HashMap();
069:                HashMap deletedPropNames = new HashMap();
070:                int currentVersion = 0;
071:                //
072:                if (inId != null) {
073:                    //
074:                    BigDecimal propId[] = new BigDecimal[1];
075:                    BigDecimal version[] = new BigDecimal[1];
076:                    Boolean shortDoc[] = new Boolean[1];
077:                    getLatestPropertyVersion(inId, propId, version, shortDoc,
078:                            inConn, inSs);
079:                    //
080:                    propDoc = getLatestPropertyDoc(inId, propId[0],
081:                            (shortDoc[0]).booleanValue(), inConn, inSs);
082:                    loadProperties(inId, propId[0], propNames, propValues,
083:                            deletedPropNames, inConn, inSs);
084:                    //
085:                    currentVersion = (version[0]).intValue();
086:                } else {
087:                    //outValue =
088:                    //SystemEntityPropertiesTag.newInstance(inCtchar, inIndex);
089:                    propDoc = SystemEntityProperties.DEFAULT_DOCUMENT;
090:                    currentVersion = 0;
091:                }
092:
093:                outValue = SystemEntityPropertiesTag.newInstance(inCtchar,
094:                        inIndex, propDoc, currentVersion, propNames,
095:                        propValues, deletedPropNames);
096:                //MiscHelper.println("AbsBasSerBean accessProps = " + outValue);
097:
098:                return outValue;
099:            }
100:
101:            private String getLatestPropertyDoc(BigDecimal inPropRoId,
102:                    BigDecimal inPropId, boolean inShortDoc, Connection inConn,
103:                    SystemStore inSs) {
104:
105:                String outValue = null;
106:
107:                //
108:                SystemDatabase sd = SystemDatabase.newInstance();
109:                CreateStatement propRoTable = sd.createPropReadOnlyTable();
110:                CreateStatement propTable = sd.createPropTable();
111:                CreateStatement propDocTable = sd.createPropDocTable();
112:
113:                //
114:                SelectStatement maxPropDocSelect = SelectStatement
115:                        .createOrderById(propDocTable,
116:                                SelectStatement.MAX_COLUMN);
117:                //
118:                maxPropDocSelect.addWhereColumn(
119:                        SystemDatabase.C_PROP_ID_T_PROP_DOC,
120:                        SystemStatement.NORMAL_COLUMN, propDocTable, inPropId,
121:                        SelectStatement.LESS_THAN_OR_EQUAL, null);
122:                maxPropDocSelect.addWhereColumn(
123:                        SystemDatabase.C_PROP_RO_ID_T_PROP,
124:                        SystemStatement.NORMAL_COLUMN, propTable, inPropRoId,
125:                        SelectStatement.EQUALS, null);
126:                //
127:                maxPropDocSelect.addGroupByColumn(null,
128:                        SystemStatement.ID_COLUMN, propDocTable);
129:
130:                if (inShortDoc) {
131:
132:                    //
133:                    SelectStatement propDocSelect = SelectStatement
134:                            .createOrderById(propDocTable, null);
135:                    //
136:                    propDocSelect.addSelectColumn(
137:                            SystemDatabase.C_SHORT_DOC_T_PROP_DOC,
138:                            propDocTable, null);
139:                    //
140:                    propDocSelect.addWhereColumn(null,
141:                            SystemStatement.ID_COLUMN, propDocTable,
142:                            maxPropDocSelect, SelectStatement.IN, null);
143:                    //
144:                    inSs.execute(propDocSelect, inConn);
145:                    SystemResultSet propDocSrs = propDocSelect.getResults();
146:                    if (propDocSrs.getRowCount() > 0) {
147:                        outValue = propDocSrs.getSString(0, 1);
148:                    }
149:                } else {
150:
151:                    //
152:                    SelectStatement propDocSelect = SelectStatement
153:                            .createOrderById(propDocTable, null);
154:                    //
155:                    propDocSelect.addSelectColumn(
156:                            SystemDatabase.C_LONG_DOC_T_PROP_DOC, propDocTable,
157:                            null);
158:                    //
159:                    propDocSelect.addWhereColumn(null,
160:                            SystemStatement.ID_COLUMN, propDocTable,
161:                            maxPropDocSelect, SelectStatement.IN, null);
162:                    //
163:                    inSs.execute(propDocSelect, inConn);
164:                    SystemResultSet propDocSrs = propDocSelect.getResults();
165:                    if (propDocSrs.getRowCount() > 0) {
166:                        outValue = propDocSrs.getLString(0, 0);
167:                    }
168:                }
169:
170:                return outValue;
171:            }
172:
173:            private void loadProperties(BigDecimal inPropRoId,
174:                    BigDecimal inPropId, HashMap inPropNames,
175:                    HashMap inPropValues, HashMap inDeletedPropNames,
176:                    Connection inConn, SystemStore inSs) {
177:
178:                //
179:                SystemDatabase sd = SystemDatabase.newInstance();
180:                CreateStatement propInstanceTable = sd
181:                        .createPropInstanceTable();
182:                CreateStatement propTable = sd.createPropTable();
183:
184:                //
185:                SelectStatement maxPropInstanceSelect = SelectStatement
186:                        .createOrderById(propInstanceTable,
187:                                SystemStatement.MAX_COLUMN);
188:                //
189:                maxPropInstanceSelect.addWhereColumn(
190:                        SystemDatabase.C_PROP_ID_T_PROP_INSTANCE,
191:                        SystemStatement.NORMAL_COLUMN, propInstanceTable,
192:                        inPropId, SelectStatement.LESS_THAN_OR_EQUAL, null);
193:                maxPropInstanceSelect.addWhereColumn(
194:                        SystemDatabase.C_PROP_RO_ID_T_PROP,
195:                        SystemStatement.NORMAL_COLUMN, propTable, inPropRoId,
196:                        SelectStatement.EQUALS, null);
197:                //
198:                maxPropInstanceSelect.addGroupByColumn(
199:                        SystemDatabase.C_GROUP_NAME_T_GROUP_INSTANCE,
200:                        SystemStatement.NORMAL_COLUMN, propInstanceTable);
201:
202:                //
203:                SelectStatement propInstanceSelect = SelectStatement
204:                        .createOrderById(propInstanceTable, null);
205:                //
206:                propInstanceSelect.addSelectColumn(
207:                        SystemDatabase.C_ACTUAL_NAME_T_GROUP_INSTANCE,
208:                        propInstanceTable, null);
209:                propInstanceSelect.addSelectColumn(
210:                        SystemDatabase.C_VALUE_T_GROUP_INSTANCE,
211:                        propInstanceTable, null);
212:                propInstanceSelect.addSelectColumn(
213:                        SystemDatabase.C_ACTIVE_T_PROP_INSTANCE,
214:                        propInstanceTable, null);
215:                //
216:                propInstanceSelect.addWhereColumn(null,
217:                        SystemStatement.ID_COLUMN, propInstanceTable,
218:                        maxPropInstanceSelect, SelectStatement.IN, null);
219:
220:                //
221:                inSs.execute(propInstanceSelect, inConn);
222:                SystemResultSet propInstanceSrs = propInstanceSelect
223:                        .getResults();
224:                //MiscHelper.println("AbsSerBean propInstSrs = " + propInstanceSrs);
225:                for (int i = 0; i < propInstanceSrs.getRowCount(); i++) {
226:                    String nextName = propInstanceSrs.getSString(i, 1);
227:                    String nextValue = propInstanceSrs.getSString(i, 2);
228:                    Boolean nextActive = propInstanceSrs.getBoolean(i, 3);
229:                    if (nextActive.booleanValue()) {
230:                        inPropNames.put(nextName.toUpperCase(), nextName);
231:                        inPropValues.put(nextName.toUpperCase(), nextValue);
232:                    } else {
233:                        inDeletedPropNames
234:                                .put(nextName.toUpperCase(), nextName);
235:                    }
236:                }
237:            }
238:
239:            private boolean getLatestPropertyVersion(BigDecimal inPropertyId,
240:                    BigDecimal inId[], BigDecimal inVersion[],
241:                    Boolean inShortDoc[], Connection inConn, SystemStore inSs) {
242:                //
243:
244:                boolean outValue = false;
245:                //
246:                SystemDatabase sd = SystemDatabase.newInstance();
247:                CreateStatement propTable = sd.createPropTable();
248:
249:                if (inPropertyId != null) {
250:                    //
251:                    SelectStatement maxPropSelect = SelectStatement
252:                            .createOrderById(propTable,
253:                                    SystemStatement.MAX_COLUMN);
254:                    //
255:                    maxPropSelect.addWhereColumn(
256:                            SystemDatabase.C_PROP_RO_ID_T_PROP,
257:                            SystemStatement.NORMAL_COLUMN, propTable,
258:                            inPropertyId, SelectStatement.EQUALS, null);
259:                    //
260:                    maxPropSelect.addGroupByColumn(
261:                            SystemDatabase.C_PROP_RO_ID_T_PROP,
262:                            SystemStatement.NORMAL_COLUMN, propTable);
263:
264:                    SelectStatement propSelect = SelectStatement
265:                            .createOrderById(propTable, null);
266:                    //
267:                    propSelect.addSelectColumn(SystemDatabase.C_VERSION_T_PROP,
268:                            propTable, null);
269:                    propSelect.addSelectColumn(
270:                            SystemDatabase.C_SHORT_DOC_T_PROP, propTable, null);
271:                    //
272:                    propSelect.addWhereColumn(null, SystemStatement.ID_COLUMN,
273:                            propTable, maxPropSelect, SelectStatement.IN, null);
274:                    //
275:                    inSs.execute(propSelect, inConn);
276:                    SystemResultSet propSrs = propSelect.getResults();
277:                    //
278:                    if (propSrs.getRowCount() > 0) {
279:                        outValue = true;
280:                        inId[0] = propSrs.getDecimal(0, 0);
281:                        inVersion[0] = propSrs.getDecimal(0, 1);
282:                        //for (int i = 0; i < 100; i++) {
283:                        //    MiscHelper.println(
284:                        //        "AbsBaseServBean,getLatPrVer vers = " + inVersion[0]);
285:                        //}
286:                        inShortDoc[0] = propSrs.getBoolean(0, 2);
287:                    }
288:                } else {
289:                }
290:
291:                return outValue;
292:            }
293:
294:            protected BigDecimal saveProperties(
295:                    SystemEntityPropertiesUpdates inSepu, BigDecimal inId,
296:                    Connection inConn, SystemStore inSs) {
297:
298:                BigDecimal outValue = null;
299:
300:                //
301:                SystemDatabase sd = SystemDatabase.newInstance();
302:                CreateStatement propRoTable = sd.createPropReadOnlyTable();
303:                CreateStatement propTable = sd.createPropTable();
304:                CreateStatement propDocTable = sd.createPropDocTable();
305:                CreateStatement propInstanceTable = sd
306:                        .createPropInstanceTable();
307:                //
308:                boolean shortDoc = inSepu.getDocLength() <= SystemDatabase.MAXIMUM_SHORT_STRING_LENGTH;
309:
310:                if (inSepu.getVersion() == 1) {
311:                    InsertStatement propRoIs = SystemStatement
312:                            .newInsertStatement(propRoTable);
313:                    propRoIs.setDecimalColumn(SystemDatabase.C_TYPE_T_PROP_RO,
314:                            new BigDecimal(1));
315:                    inSs.execute(propRoIs, inConn);
316:                    inId = propRoIs.getIdColumnValue();
317:                    //outValue = propRoIs.getIdColumnValue();
318:                } else {
319:                    //outValue = inId;
320:                }
321:
322:                //MiscHelper.println("AbsServBean,sP version = " + inSepu.getVersion());
323:                InsertStatement propIs = SystemStatement
324:                        .newInsertStatement(propTable);
325:                //
326:                propIs.setDecimalColumn(SystemDatabase.C_PROP_RO_ID_T_PROP,
327:                        inId);
328:                propIs.setDecimalColumn(SystemDatabase.C_VERSION_T_PROP,
329:                        new BigDecimal(inSepu.getVersion()));
330:                propIs.setBooleanColumn(SystemDatabase.C_SHORT_DOC_T_PROP,
331:                        new Boolean(shortDoc));
332:                //
333:                inSs.execute(propIs, inConn);
334:                BigDecimal propId = propIs.getIdColumnValue();
335:
336:                if (inSepu.isDocPresent()) {
337:                    InsertStatement propDocIs = SystemStatement
338:                            .newInsertStatement(propDocTable);
339:                    propDocIs.setDecimalColumn(
340:                            SystemDatabase.C_PROP_ID_T_PROP_DOC, propId);
341:                    if (shortDoc) {
342:                        propDocIs.setSStringColumn(
343:                                SystemDatabase.C_SHORT_DOC_T_PROP_DOC, inSepu
344:                                        .getDoc());
345:                    } else {
346:                        propDocIs.setLStringColumn(
347:                                SystemDatabase.C_LONG_DOC_T_PROP_DOC, inSepu
348:                                        .getDoc());
349:                    }
350:                    inSs.execute(propDocIs, inConn);
351:                }
352:
353:                //
354:                for (int i = 0; i < inSepu.getInstanceCount(); i++) {
355:                    int nextType = new BigDecimal(inSepu.getInstanceType(i))
356:                            .intValue();
357:                    String nextName = inSepu.getInstanceName(i);
358:                    String nextValue = inSepu.getInstanceValue(i);
359:                    //MiscHelper.println("    INSERT PROPERTY NAME = " + nextName);
360:                    //MiscHelper.println("    INSERT PROPERTY NAME = " + nextValue);
361:                    //
362:                    InsertStatement propInstanceIs = SystemStatement
363:                            .newInsertStatement(propInstanceTable);
364:                    //
365:                    propInstanceIs.setDecimalColumn(
366:                            SystemDatabase.C_PROP_ID_T_PROP_INSTANCE, propId);
367:                    //
368:                    if (nextType != SystemEntity.DELETE_ENTITY) {
369:                        propInstanceIs.setBooleanColumn(
370:                                SystemDatabase.C_ACTIVE_T_PROP_INSTANCE,
371:                                new Boolean(true));
372:                    } else {
373:                        propInstanceIs.setBooleanColumn(
374:                                SystemDatabase.C_ACTIVE_T_PROP_INSTANCE,
375:                                new Boolean(false));
376:                    }
377:                    propInstanceIs.setSStringColumn(
378:                            SystemDatabase.C_GROUP_NAME_T_GROUP_INSTANCE,
379:                            nextName.toUpperCase());
380:                    propInstanceIs.setSStringColumn(
381:                            SystemDatabase.C_ACTUAL_NAME_T_GROUP_INSTANCE,
382:                            nextName);
383:                    propInstanceIs.setSStringColumn(
384:                            SystemDatabase.C_VALUE_T_GROUP_INSTANCE, nextValue);
385:                    //
386:                    inSs.execute(propInstanceIs, inConn);
387:                }
388:
389:                //
390:                outValue = inId;
391:
392:                return outValue;
393:            }
394:
395:            protected SelectStatement getSecurityAuditSelectWithoutWhereClause() {
396:                //
397:                SelectStatement outValue = null;
398:
399:                SystemDatabase sd = SystemDatabase.newInstance();
400:                CreateStatement auditTable = sd.createAuditTable();
401:
402:                outValue = SelectStatement.createOrderById(auditTable, null);
403:                //
404:                outValue.addSelectColumn(SystemDatabase.C_USER_ID_T_AUDIT,
405:                        auditTable, null);
406:                outValue.addSelectColumn(SystemDatabase.C_SEQ_NUMBER_T_AUDIT,
407:                        auditTable, null);
408:                outValue.addSelectColumn(
409:                        SystemDatabase.C_MACHINE_OF_ORIG_T_AUDIT, auditTable,
410:                        null);
411:                outValue.addSelectColumn(SystemDatabase.C_DATE_TIME_T_AUDIT,
412:                        auditTable, null);
413:                outValue.addSelectColumn(
414:                        SystemDatabase.C_SEVERITY_LEVEL_T_AUDIT, auditTable,
415:                        null);
416:                outValue.addSelectColumn(
417:                        SystemDatabase.C_CATEGORY_TYPE_T_AUDIT, auditTable,
418:                        null);
419:                outValue.addSelectColumn(SystemDatabase.C_SOURCE_TYPE_T_AUDIT,
420:                        auditTable, null);
421:                outValue.addSelectColumn(
422:                        SystemDatabase.C_SERVER_VERSION_T_AUDIT, auditTable,
423:                        null);
424:                //
425:                outValue.addSelectColumn(SystemDatabase.C_CUSTOM_CODE_T_AUDIT,
426:                        auditTable, null);
427:                outValue.addSelectColumn(
428:                        SystemDatabase.C_CUSTOM_CAT_TYPE_T_AUDIT, auditTable,
429:                        null);
430:                outValue.addSelectColumn(
431:                        SystemDatabase.C_CUSTOM_SRC_TYPE_T_AUDIT, auditTable,
432:                        null);
433:                outValue.addSelectColumn(
434:                        SystemDatabase.C_CUSTOM_MESSAGE_T_AUDIT, auditTable,
435:                        null);
436:                //
437:                outValue.addSelectColumn(SystemDatabase.C_OPENED_T_AUDIT,
438:                        auditTable, null);
439:
440:                return outValue;
441:            }
442:
443:            protected SecurityAudit getSecurityAuditFromResults(
444:                    Connection inConn, SystemStore inSs, SystemResultSet inSrs,
445:                    int inIndex) {
446:                //
447:                SecurityAudit outValue = null;
448:
449:                //
450:                BigDecimal userIdentityId = inSrs.getDecimal(inIndex, 1);
451:                BigDecimal sequenceNumber = inSrs.getDecimal(inIndex, 2);
452:                String machineOfOrigin = inSrs.getSString(inIndex, 3);
453:                BigDecimal dateTime = inSrs.getDecimal(inIndex, 4);
454:                BigDecimal severityLevel = inSrs.getDecimal(inIndex, 5);
455:                String categoryType = inSrs.getSString(inIndex, 6);
456:                String sourceType = inSrs.getSString(inIndex, 7);
457:                String serverVersion = inSrs.getSString(inIndex, 8);
458:                //
459:                BigDecimal customCode = inSrs.getDecimal(inIndex, 9);
460:                String customCategoryType = inSrs.getSString(inIndex, 10);
461:                String customSourceType = inSrs.getSString(inIndex, 11);
462:                String customMessage = inSrs.getLString(inIndex, 12);
463:                //
464:                Boolean opened = inSrs.getBoolean(inIndex, 13);
465:
466:                UserIdentity user = accessUser(userIdentityId, inConn, inSs);
467:                //
468:                outValue = SimpleSecurityAudit.newInstance(user,
469:                        sequenceNumber, machineOfOrigin, MiscHelper
470:                                .fromTimeToString(dateTime.longValue()),
471:                        SecurityAuditHelper
472:                                .convertNumberToSeverityLevel(severityLevel),
473:                        SecurityAuditHelper
474:                                .convertStringToAuditType(categoryType),
475:                        SecurityAuditHelper
476:                                .convertStringToAuditType(sourceType),
477:                        serverVersion, customCode, SecurityAuditHelper
478:                                .convertStringToAuditType(customCategoryType),
479:                        SecurityAuditHelper
480:                                .convertStringToAuditType(customSourceType),
481:                        customMessage, opened.booleanValue());
482:
483:                return outValue;
484:            }
485:
486:            protected BigDecimal getSecurityAuditIdFromResults(
487:                    SystemResultSet inSrs, int inIndex) {
488:                //
489:                BigDecimal outValue = null;
490:
491:                outValue = inSrs.getDecimal(inIndex, 0);
492:
493:                return outValue;
494:            }
495:
496:            protected SecurityAudit accessAudit(BigDecimal inId,
497:                    Connection inConn, SystemStore inSs) {
498:
499:                SecurityAudit outValue = null;
500:
501:                //
502:                SystemDatabase sd = SystemDatabase.newInstance();
503:                CreateStatement auditTable = sd.createAuditTable();
504:
505:                //
506:                SelectStatement auditSelect = getSecurityAuditSelectWithoutWhereClause();
507:                //
508:                auditSelect.addWhereColumn(null, SystemStatement.ID_COLUMN,
509:                        auditTable, inId, SelectStatement.EQUALS, null);
510:                //
511:                inSs.execute(auditSelect, inConn);
512:                SystemResultSet auditSrs = auditSelect.getResults();
513:                //
514:                if (auditSrs.getRowCount() > 0) {
515:                    //
516:                    //
517:                    outValue = getSecurityAuditFromResults(inConn, inSs,
518:                            auditSrs, 0);
519:                }
520:
521:                return outValue;
522:            }
523:
524:            protected BigDecimal saveAudit(SecurityAudit inSa,
525:                    Connection inConn, SystemStore inSs) {
526:
527:                BigDecimal outValue = null;
528:
529:                //
530:                UserIdentity ui = inSa.getAuditUserIdentity();
531:                BigDecimal userId = saveUser(ui, inConn, inSs);
532:
533:                //
534:                SystemDatabase sd = SystemDatabase.newInstance();
535:                CreateStatement auditTable = sd.createAuditTable();
536:                //
537:                InsertStatement userIs = SystemStatement
538:                        .newInsertStatement(auditTable);
539:                //
540:                userIs.setDecimalColumn(SystemDatabase.C_USER_ID_T_AUDIT,
541:                        userId);
542:                userIs.setDecimalColumn(SystemDatabase.C_SEQ_NUMBER_T_AUDIT,
543:                        inSa.getAuditSequenceNumber());
544:                userIs.setSStringColumn(
545:                        SystemDatabase.C_MACHINE_OF_ORIG_T_AUDIT, inSa
546:                                .getAuditMachineOfOrigin());
547:                userIs.setDecimalColumn(SystemDatabase.C_DATE_TIME_T_AUDIT,
548:                        new BigDecimal(MiscHelper.fromStringToTime(inSa
549:                                .getAuditDateTime())));
550:                userIs.setDecimalColumn(
551:                        SystemDatabase.C_SEVERITY_LEVEL_T_AUDIT,
552:                        SecurityAuditHelper.convertSeverityLevelToNumber(inSa
553:                                .getAuditSeverityLevel()));
554:                userIs.setSStringColumn(SystemDatabase.C_CATEGORY_TYPE_T_AUDIT,
555:                        SecurityAuditHelper.convertAuditTypeToString(inSa
556:                                .getAuditCategoryType()));
557:                userIs.setSStringColumn(SystemDatabase.C_SOURCE_TYPE_T_AUDIT,
558:                        SecurityAuditHelper.convertAuditTypeToString(inSa
559:                                .getAuditSourceType()));
560:                userIs.setSStringColumn(
561:                        SystemDatabase.C_SERVER_VERSION_T_AUDIT, inSa
562:                                .getAuditServerVersion());
563:                //
564:                userIs.setDecimalColumn(SystemDatabase.C_CUSTOM_CODE_T_AUDIT,
565:                        inSa.getAuditCustomCode());
566:                userIs.setSStringColumn(
567:                        SystemDatabase.C_CUSTOM_CAT_TYPE_T_AUDIT,
568:                        SecurityAuditHelper.convertAuditTypeToString(inSa
569:                                .getAuditCustomCategoryType()));
570:                userIs.setSStringColumn(
571:                        SystemDatabase.C_CUSTOM_SRC_TYPE_T_AUDIT,
572:                        SecurityAuditHelper.convertAuditTypeToString(inSa
573:                                .getAuditCustomSourceType()));
574:                userIs.setLStringColumn(
575:                        SystemDatabase.C_CUSTOM_MESSAGE_T_AUDIT, inSa
576:                                .getAuditCustomMessage());
577:                //
578:                userIs.setBooleanColumn(SystemDatabase.C_OPENED_T_AUDIT,
579:                        new Boolean(inSa.isAuditOpened()));
580:
581:                //
582:                //try {
583:                //    MiscHelper.println(
584:                //        "AbBasServBean autoCommit = " + inConn.getAutoCommit());
585:                //}
586:                //catch (Exception e) {
587:                //}
588:                inSs.execute(userIs, inConn);
589:                //
590:                outValue = userIs.getIdColumnValue();
591:
592:                return outValue;
593:            }
594:
595:            protected UserIdentity accessUser(BigDecimal inId,
596:                    Connection inConn, SystemStore inSs) {
597:
598:                UserIdentity outValue = null;
599:
600:                //
601:                SystemDatabase sd = SystemDatabase.newInstance();
602:                CreateStatement userTable = sd.createUserTable();
603:
604:                //find user
605:                SelectStatement userSelect = SelectStatement.createOrderById(
606:                        userTable, null);
607:                userSelect.addSelectColumn(SystemDatabase.C_NAME_T_USER,
608:                        userTable, null);
609:                userSelect.addSelectColumn(SystemDatabase.C_TYPE_T_USER,
610:                        userTable, null);
611:                //
612:                userSelect.addWhereColumn(null, SystemStatement.ID_COLUMN,
613:                        userTable, inId, SelectStatement.EQUALS, null);
614:                //
615:                inSs.execute(userSelect, inConn);
616:                SystemResultSet userSrs = userSelect.getResults();
617:                //
618:                if (userSrs.getRowCount() > 0) {
619:                    String name = userSrs.getSString(0, 1);
620:                    String type = userSrs.getSString(0, 2);
621:                    //
622:                    outValue = SimpleUserIdentity.newInstance(name, type, true,
623:                            false);
624:                    //outValue = userSrs.getDecimal(0, 0);
625:                }
626:
627:                return outValue;
628:            }
629:
630:            protected BigDecimal saveUser(UserIdentity inUi, Connection inConn,
631:                    SystemStore inSs) {
632:
633:                BigDecimal outValue = null;
634:
635:                //SystemStore ss = SystemStore.getSystemStore();
636:                SystemDatabase sd = SystemDatabase.newInstance();
637:
638:                CreateStatement userTable = sd.createUserTable();
639:
640:                //find user
641:                SelectStatement userSelect = SelectStatement.createOrderById(
642:                        userTable, null);
643:                //
644:                userSelect.addWhereColumn(SystemDatabase.C_NAME_T_USER,
645:                        SystemStatement.NORMAL_COLUMN, userTable, inUi
646:                                .getName(), SelectStatement.EQUALS, null);
647:                userSelect.addWhereColumn(SystemDatabase.C_TYPE_T_USER,
648:                        SystemStatement.NORMAL_COLUMN, userTable, inUi
649:                                .getSecurityType(), SelectStatement.EQUALS,
650:                        null);
651:                //
652:                inSs.execute(userSelect, inConn);
653:                SystemResultSet userSrs = userSelect.getResults();
654:                //
655:                if (userSrs.getRowCount() > 0) {
656:                    outValue = userSrs.getDecimal(0, 0);
657:                } else {
658:                    InsertStatement userIs = SystemStatement
659:                            .newInsertStatement(userTable);
660:                    //
661:                    userIs.setSStringColumn(SystemDatabase.C_NAME_T_USER, inUi
662:                            .getName());
663:                    userIs.setSStringColumn(SystemDatabase.C_TYPE_T_USER, inUi
664:                            .getSecurityType());
665:                    //
666:                    inSs.execute(userIs, inConn);
667:                    inSs.commit(inConn);
668:                    //
669:                    outValue = userIs.getIdColumnValue();
670:                }
671:
672:                return outValue;
673:            }
674:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.