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


        /*
         * JFolder, Copyright 2001-2006 Gary Steinmetz
         *
         * Distributable under LGPL license.
         * See terms of license at gnu.org.
         */

        package org.jfolder.workflow.lifecycle;

        //base classes
        import java.io.File;
        import java.io.FileInputStream;
        import java.io.FileNotFoundException;
        import java.io.FileOutputStream;
        import java.io.IOException;
        import java.math.BigDecimal;
        import java.sql.Connection;
        import java.sql.SQLException;
        import java.util.HashMap;
        import java.util.Iterator;
        import java.util.Properties;
        import javax.naming.Context;
        import javax.naming.InitialContext;
        import javax.naming.NamingException;
        import javax.rmi.PortableRemoteObject;
        import javax.sql.DataSource;

        //project specific classes
        import org.jfolder.common.UnexpectedSystemException;
        import org.jfolder.common.tagging.RootConceptTagHolder;
        import org.jfolder.common.tagging.ValueAndClassForConceptTag;
        import org.jfolder.common.utils.misc.MiscHelper;
        import org.jfolder.project.model.ProjectApplicationSet;
        import org.jfolder.security.audit.SecurityAuditQuery;
        import org.jfolder.security.audit.SecurityAuditSet;
        import org.jfolder.security.model.UserHolder;
        import org.jfolder.services.config.ConfigServiceCaller;
        import org.jfolder.services.config.ConfigServiceCallerFactory;
        import org.jfolder.workflow.model.dms.WorkflowDocumentGroup;
        import org.jfolder.workflow.model.dms.WorkflowDocumentGroupUpdates;
        import org.jfolder.workflow.model.instance.WorkflowInstance;
        import org.jfolder.workflow.model.instance.WorkflowInstanceUpdates;
        import org.jfolder.workflow.model.trigger.WorkflowTrigger;
        import org.jfolder.workflow.query.BaseDBQueryVendor;
        import org.jfolder.workflow.query.BaseDBQueryVendorProprietarySyntax;
        import org.jfolder.workflow.query.ResultSetContainer;
        import org.jfolder.workflow.query.StatementContainer;

        //other classes

        /*
         //TO DO: make calls transactional where appropriate
         public abstract class BaseDBWorkflowLifecycleBean
         implements WorkflowLifecycle {
        
         //protected final static String T_JFOLDER_WORKFLOWS = "T_JFOLDER_WORKFLOWS";
         protected final static String T_USERS = "T_USERS";
         protected final static String T_WORKFLOWS = "T_WORKFLOWS";
         protected final static String T_DEPLOYED_SCRIPTS = "T_DEPLOYED_SCRIPTS";
         protected final static String T_ATTRIBUTES = BaseDBQueryVendor.T_ATTRIBUTES;
         protected final static String T_TRIGGERS = "T_TRIGGERS";
         //
         protected final static String WF_INSTANCE = "WF_INSTANCE";
         protected final static String STATE_CODE = "STATE_CODE";
         protected final static String ID = BaseDBQueryVendor.ID;
         protected final static String SECURITY_CLASS = "SECURITY_CLASS";
         protected final static String USER_NAME = "USER_NAME";
         protected final static String SCRIPT_NAME = "SCRIPT_NAME";
         protected final static String WORKFLOW_ID = "WORKFLOW_ID";
         protected final static String HANDLE = "HANDLE";
         protected final static String CONTENT = "CONTENT";
         protected final static String AUDIT_ID = "AUDIT_ID";
         protected final static String AUDIT_USER_ID = "AUDIT_USER_ID";
         protected final static String AUDIT_TIMESTAMP = "AUDIT_TIMESTAMP";
         protected final static String AUDIT_STATUS = "AUDIT_STATUS";
         protected final static String AUDIT_COMMENT = "AUDIT_COMMENT";
         protected final static String AUDIT_EXCEPTION_MESSAGE =
         "AUDIT_EXCEPTION_MESSAGE";
         protected final static String AUDIT_EXCEPTION_SOURCE =
         "AUDIT_EXCEPTION_SOURCE";
        
         //
         protected final static String JF_ID = BaseDBQueryVendor.JF_ID;
         protected final static String ATTR_NAME = BaseDBQueryVendor.ATTR_NAME;
         protected final static String ATTR_TYPE = BaseDBQueryVendor.ATTR_TYPE;
         protected final static String DECIMAL_VALUE =
         BaseDBQueryVendor.DECIMAL_VALUE;
         protected final static String BOOLEAN_VALUE =
         BaseDBQueryVendor.BOOLEAN_VALUE;
         protected final static String STRING_VALUE =
         BaseDBQueryVendor.STRING_VALUE;
         protected final static String LONG_STRING_VALUE =
         BaseDBQueryVendor.LONG_STRING_VALUE;
        
        
         public BaseDBWorkflowLifecycleBean() {
         }
        
         public void close() {
         //not implemented, included in WorkflowLifecycle, not used
         }
        
        
         protected abstract BaseDBQueryVendorProprietarySyntax
         getBaseDBQueryVendorProprietarySyntax();
        
         //protected abstract void updateWorkflowAttribute(Connection inCon,
         //    String inPfId, String inAttrName, ValueAndClassForConceptTag inVac,
         //    int inSysAttr) throws SQLException;
        
         //protected abstract void insertWorkflowAttribute(Connection inCon,
         //    String inPfId, String inAttrName, ValueAndClassForConceptTag inVac,
         //    int inPubAttr, int inSysAttr) throws SQLException;
        
         protected abstract int getFileIdOfUser(UserHolder inUh);
        
         //protected abstract BigDecimal getNextIndex(Connection inCon);
        
         //protected abstract void insertWorkflowInstance(Connection inCon,
         //    String inPfId, WorkflowInstance inWorkflow);
        
         //protected abstract void updateWorkflowInstance(Connection inCon,
         //    String inPfId, WorkflowInstance inWorkflow);
        
         //public abstract String submitTriggerData(String inHandle,
         //    TriggerData inTd);
        
         //public abstract void updateTriggerDataStatus(String inHandle,
         //    TriggerData inTd);
        
         //public abstract TriggerData retrieveTriggerData(String inHandle);
        
         //properties functions
         public void loadApplicationProperties(String inApp, Properties inProps) {
        
         try {
         File propsDir = getPropertiesDir();
         File propsFile = new File(propsDir, inApp + ".properties");
         FileOutputStream fos = new FileOutputStream(propsFile);
        
         inProps.store(fos, "Application - " + inApp);
         }
         catch (FileNotFoundException fnfe) {
         throw new UnexpectedSystemException(fnfe);
         }
         catch (IOException ioe) {
         throw new UnexpectedSystemException(ioe);
         }
         }
        
         public Properties getApplicationProperties(String inApp) {
        
         try {
        
         Properties outValue = new Properties();
        
         File propsDir = getPropertiesDir();
         File propsFile = new File(propsDir, inApp + ".properties");
         FileInputStream fis = new FileInputStream(propsFile);
         outValue.load(fis);
        
         return outValue;
         }
         catch (FileNotFoundException fnfe) {
         throw new UnexpectedSystemException(fnfe);
         }
         catch (IOException ioe) {
         throw new UnexpectedSystemException(ioe);
         }
         }
        
         public void unloadApplicationProperties(String inApp) {
         File propsDir = getPropertiesDir();
         File propsFile = new File(propsDir, inApp + ".properties");
         propsFile.delete();
         }
        
         //public void updateWorkflowInstance(WorkflowInstance inWi) {
         //    
         //    //throw UnexpectedSystemException.notImplemented();
         //    Connection con = null;
         //    
         //    try {
         //    
         //        //MiscHelper.println(
         //        //"GenericHSQLWorkflowLifecycleBean - updateWf");
         //        
         //        con = getDatabaseConnection();
         //    
         //        AttributeSet as = inWi.getAttributeSet();
         //        ValueAndClassForConceptTag idVac =
         //            as.getPublicSysAttr(AttributeSet.ID);
         //        ValueAndClassForConceptTag statusVac =
         //            as.getPublicSysAttr(AttributeSet.STATUS);
         //    
         //        String id = (String)idVac.getValue();
         //        String status = (String)statusVac.getValue();
         //    
         //        updateWorkflowInstance(con, id, inWi);
         //        storeWorkflowAttributes(con, id, as, false);
         //    
         //        //con.commit();//TO DO: remove this
         //    
         //        if (status.equals(TraceAudit.STATUS_ACTIVE)) {
         //            putTextMessageOnQueue(id, null, getWorkflowQueue());
         //        }
         //    }
         //    //catch (SQLException sqle) {
         //    //    throw new UnexpectedSystemException(sqle);
         //    //}
         //    finally {
         //        try {
         //            if (con != null) {
         //                con.close();
         //            }
         //        }
         //        catch (SQLException sqle) {
         //            throw new UnexpectedSystemException(sqle);
         //        }
         //    }
         //
         //    //TO DO: should this function return anything?
         //
         //}
        
         //TO DO: determine good function name and return type
         //TO DO: is there a regular expressions library
         //TO DO: determine if returning list of string ID's is okay
         //TO DO: determine what should be returned in a query
         //TO DO: determine what return will work with messaging and database
        
         //TO DO: determine good function name and return type
         //TO DO: determine if returning list of string ID's is okay
         //TO DO: determine what should be returned in a query
         //TO DO: determine what return will work with messaging and database
         public ResultSetContainer queryWorkflowInstances(
         StatementContainer inStatement) {
        
         Connection con = null;
        
         try {
         ResultSetContainer outValue = null;
        
         con = getDatabaseConnection();
        
         BaseDBQueryVendor bdbqv = BaseDBQueryVendor.newBaseDBQueryVendor(
         getBaseDBQueryVendorProprietarySyntax(), true);
        
         outValue = bdbqv.executeStatement(con, inStatement);
        
         return outValue;
        
         }
         //catch (SQLException sqle) {
         //    throw new UnexpectedSystemException(sqle);
         //}
         finally {
         try {
         if (con != null) {
         con.close();
         }
         }
         catch (SQLException sqle) {
         throw new UnexpectedSystemException(sqle);
         }
         }
         }
        
         public ProjectApplicationSet getProjectApplicationSet(UserHolder inUh) {
        
         GenericFileProjectApplicationSet outValue =
         new GenericFileProjectApplicationSet(
         getApplicationsDirectory(inUh));
        
         //MiscHelper.println(
         //    "getWorkflowApplicationSet::getApplicationsDirectory(inUh) = "
         //    + getApplicationsDirectory(inUh).getAbsolutePath());
        
         File appList[] = getApplicationsDirectory(inUh).listFiles();
         for (int i = 0; i < appList.length; i++) {
         if (appList[i].isDirectory()) {
         GenericFileProjectApplication nextWa =
         new GenericFileProjectApplication(appList[i]);
         outValue.registerApplication(nextWa);
         }
         }
        
         outValue.load();
        
         return outValue;
         }
        
         public void setProjectApplicationSet(ProjectApplicationSet inWas,
         UserHolder inUh) {
        
         //reset deployed applications
         File appList[] = getApplicationsDirectory(inUh).listFiles();
         for (int i = 0; i < appList.length; i++) {
         MiscHelper.deleteFileOrDirectory(appList[i]);
         }
        
         ((GenericFileProjectApplicationSet)inWas).store();
         }
        
         protected File getApplicationsDirectory(UserHolder inUh) {
        
         File outValue = null;
        
         ConfigServiceCaller csc =
         ConfigServiceCallerFactory.getConfigServiceCaller();
         //ConfigLifecycle cm = ConfigLifecycleFactory.getConfigLifecycle();
        
         //File pfDir =
         //    GenericFileProjectApplicationSet.getJFolderDirectory(cm);
         File usersDir =
         GenericFileProjectApplicationSet.getRuntimeProjectSubDir("users");
         //if (!usersDir.exists()) {
         //    usersDir.mkdirs();
         //}
        
         int id = getFileIdOfUser(inUh);
         File userDir = new File(usersDir, id + "");
         if (!userDir.exists()) {
         userDir.mkdirs();
         }
        
         outValue = new File(userDir, "applications");
         if (!outValue.exists()) {
         outValue.mkdirs();
         }
        
         //cm.close();
        
         return outValue;
         }
        
         //public void fireTriggerData(TriggerDataPrecursor inTrigger) {
         //    
         //    throw UnexpectedSystemException.notImplemented();
         //    //putTextMessageOnQueue(
         //    //    inTrigger.getDataAsString(), null, getTriggerQueue());
         //}
        
         //public TriggerDataHistory getTriggerDataHistory(String inHandle) {
         //    throw UnexpectedSystemException.notImplemented();
         //}
         //public TriggerDataLabels getFailedTriggerSubmissions() {
         //    throw UnexpectedSystemException.notImplemented();
         //}
        
         //public void startWorkflowInstance(WorkflowInstancePrecursor inWp) {
         //    
         //    Connection con = null;
         //    
         //    try {
         //        
         //        //4 scenarios when starting a workflow-instance
         //        //Scenario 1 - trigger good, new workflow-instance
         //        //Scenario 2 - trigger bad, new workflow-instance
         //        //Scenario 3 - trigger good, existing workflow-instance
         //        //Scenario 4 - trigger bad, existing workflow-instance
         //        
         //        con = getDatabaseConnection();
         //        
         //        TriggerData t = inWp.getTriggerData();
         //        
         //        //boolean triggerBad = t.isAuditExceptionPresent();
         //        //boolean existingWorkflow = tc.isWorkflowPresent();
         //        
         //        String pfId = getNextIndex(con).toString();
         //        
         //        //if (!existingWorkflow) {
         //        //    pfId = getNextIndex(con).toString();
         //        //}
         //        //else {
         //        //    pfId = tc.getWorkflowId();
         //        //}
         //        //
         //        //if (!triggerBad) {
         //            
         //            AttributeSet as = inWp.getAttributeSet();
         //            RootConceptTagHolder rth = inWp.getRootScriptTagHolder();
         //            HistoryAudit h = inWp.getHistoryAudit();
         //            
         //            //if (!existingWorkflow) {
         //                //this is the only attribute added in this function
         //                as.addPublicSysAttr(AttributeSet.ID,
         //                    ValueAndClassForConceptTagFactory.newValueAndClass(
         //                        pfId, String.class));
         //                WorkflowInstance w =
         //                    WorkflowInstanceFactory.newWorkflowInstance(
         //                        h, rth, as, t, pfId,
         //                        WorkflowInstance.INITIAL_STATE);
         //                insertWorkflowInstance(con, pfId, w);
         //            //}
         //            //else {
         //            //    WorkflowInstance w = null;
         //            //    updateWorkflowInstance(con, pfId, w);
         //            //}
         //            
         //            storeWorkflowAttributes(con, pfId, as, true);
         //            
         //            Object s = as.getPublicSysAttr(
         //AttributeSet.STATUS).getValue();
         //        
         //            if (s.equals(TraceAudit.STATUS_ACTIVE)) {
         //                putTextMessageOnQueue(pfId, null, getWorkflowQueue());
         //            }
         //        //}
         //        //else {
         //        //    if (!existingWorkflow) {
         //        //        //this is the only attribute added in this function
         //        //        WorkflowInstance w = null;
         //        //        insertWorkflowInstance(con, pfId, w);
         //        //    }
         //        //    else {
         //        //        WorkflowInstance w = null;
         //        //        updateWorkflowInstance(con, pfId, w);
         //        //    }
         //        //}
         //        
         //    }
         //    //catch (SQLException sqle) {
         //    //    throw new UnexpectedSystemException(sqle);
         //    //}
         //    finally {
         //        try {
         //            if (con != null) {
         //                con.close();
         //            }
         //        }
         //        catch (SQLException sqle) {
         //            throw new UnexpectedSystemException(sqle);
         //        }
         //    }
         //}
        
         public SecurityAuditSet getSecurityAudits(SecurityAuditQuery inSaq) {
         throw UnexpectedSystemException.notImplemented();
         }
        
         //protected void storeWorkflowAttributes(Connection inCon,
         //    String inPfId, AttributeSet inAs, boolean inIsInsert) {
         //    
         //    try {
         //        
         //        Iterator iter = null;
         //        
         //        //public system attributes
         //        iter = inAs.getPublicSysAttrNames();
         //        while (iter.hasNext()) {
         //            String attrName = (String)iter.next();
         //            ValueAndClassForConceptTag vac =
         //                inAs.getPublicSysAttr(attrName);
         //            int pubAttr = BaseDBQueryVendor.PUBLIC;
         //            int sysAttr = BaseDBQueryVendor.SYSTEM;
         //            if (inIsInsert) {
         //                insertWorkflowAttribute(inCon, inPfId, attrName, vac,
         //                    pubAttr, sysAttr);
         //            }
         //            else {
         //                updateWorkflowAttribute(inCon, inPfId, attrName, vac,
         //                    sysAttr);
         //            }
         //        }
         //        
         //        //private system attributes
         //        iter = inAs.getPrivateSysAttrNames();
         //        while (iter.hasNext()) {
         //            String attrName = (String)iter.next();
         //            ValueAndClassForConceptTag vac =
         //                inAs.getPrivateSysAttr(attrName);
         //            int pubAttr = BaseDBQueryVendor.PRIVATE;
         //            int sysAttr = BaseDBQueryVendor.SYSTEM;
         //            if (inIsInsert) {
         //                insertWorkflowAttribute(inCon, inPfId, attrName, vac,
         //                    pubAttr, sysAttr);
         //            }
         //            else {
         //                updateWorkflowAttribute(inCon, inPfId, attrName, vac,
         //                    sysAttr);
         //            }
         //        }
         //        
         //        //public application attributes
         //        iter = inAs.getPublicAppAttrNames();
         //        while (iter.hasNext()) {
         //            String attrName = (String)iter.next();
         //            ValueAndClassForConceptTag vac =
         //                inAs.getPublicAppAttr(attrName);
         //            int pubAttr = BaseDBQueryVendor.PUBLIC;
         //            int sysAttr = BaseDBQueryVendor.APPLICATION;
         //            if (inIsInsert) {
         //                insertWorkflowAttribute(inCon, inPfId, attrName, vac,
         //                    pubAttr, sysAttr);
         //            }
         //            else {
         //                updateWorkflowAttribute(inCon, inPfId, attrName, vac,
         //                    sysAttr);
         //            }
         //        }
         //        
         //        //private application attributes
         //        iter = inAs.getPrivateAppAttrNames();
         //        while (iter.hasNext()) {
         //            String attrName = (String)iter.next();
         //            ValueAndClassForConceptTag vac =
         //                inAs.getPrivateAppAttr(attrName);
         //            int pubAttr = BaseDBQueryVendor.PRIVATE;
         //            int sysAttr = BaseDBQueryVendor.APPLICATION;
         //            if (inIsInsert) {
         //                insertWorkflowAttribute(inCon, inPfId, attrName, vac,
         //                    pubAttr, sysAttr);
         //            }
         //            else {
         //                updateWorkflowAttribute(inCon, inPfId, attrName, vac,
         //                    sysAttr);
         //            }
         //        }
         //        
         //    }
         //    catch (SQLException sqle) {
         //        throw new UnexpectedSystemException(sqle);
         //    }
         //}
        
         //private helper methods
         protected final static Connection getDatabaseConnection() {
         try {
         Connection outValue = null;
        
         Context context = new InitialContext();
         Object dsObject = context.lookup(
         "java:comp/env/jdbc/WorkflowLifecycle/DBStore");
         DataSource ds = (DataSource)PortableRemoteObject.narrow(
         dsObject, DataSource.class);
        
         outValue = ds.getConnection();
        
         return outValue;
         }
         catch (SQLException sqle) {
         throw new UnexpectedSystemException(sqle);
         }
         catch (NamingException ne) {
         throw new UnexpectedSystemException(ne);
         }
         }
        
         protected final static File getScriptsDir() {
         return GenericFileProjectApplicationSet.getRuntimeProjectSubDir(
         "scripts");
         }
        
         protected final static File getPropertiesDir() {
         return GenericFileProjectApplicationSet.getRuntimeProjectSubDir(
         "properties");
         }
        
         //document functions
         //public DocumentGroup getDocumentGroup(String inId, Integer inVersion) {
         //    throw UnexpectedSystemException.notImplemented();
         //}
        
         //public void updateDocumentGroup(DocumentGroupUpdates inDgu) {
         //    throw UnexpectedSystemException.notImplemented();
         //}
        
         }*/
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.