Package de.danet.an.util

Examples of de.danet.an.util.UniversalPrepStmt


     */
    public void updateState (long instId, Object state)
  throws InvalidKeyException {
  try {
      Connection con = null;
      UniversalPrepStmt prepStmt = null;
      ResultSet rs = null;
      try {
    con = ds.getConnection();
    prepStmt = new UniversalPrepStmt
        (ds, con,
         "UPDATE SimpleAppl SET InstData = ? WHERE DBId = ? ");
    prepStmt.setBinary (1, state);
    prepStmt.setLong (2, instId);
    if (prepStmt.executeUpdate() == 0) {
        throw new InvalidKeyException
      ("No application instance with key = " + instId);
    }
    if (logger.isDebugEnabled()) {
        logger.debug
View Full Code Here


     */
    public void updateResourceKey (long instId, String resourceKey)
        throws InvalidKeyException {
        try {
            Connection con = null;
            UniversalPrepStmt prepStmt = null;
            ResultSet rs = null;
            try {
                con = ds.getConnection();
                prepStmt = new UniversalPrepStmt
                    (ds, con,
                     "UPDATE SIMPLEAPPL SET RESOURCEKEY = ? WHERE DBID = ? ");
                prepStmt.setString (1, resourceKey);
                prepStmt.setLong (2, instId);
                if (prepStmt.executeUpdate() == 0) {
                    throw new InvalidKeyException
                        ("No application instance with key = " + instId);
                }
                if (logger.isDebugEnabled()) {
                    logger.debug
View Full Code Here

     */
    public void updateInvokingActivity (long instId, ActivityUniqueKey auk)
  throws InvalidKeyException {
  try {
      Connection con = null;
      UniversalPrepStmt prepStmt = null;
      ResultSet rs = null;
      try {
    con = ds.getConnection();
    prepStmt = new UniversalPrepStmt
        (ds, con, "UPDATE SimpleAppl "
         + "SET ActivityKey = ? WHERE DBId = ?");
    prepStmt.setString (1, auk == null ? null : auk.activityKey());
    prepStmt.setLong (2, instId);
    if (prepStmt.executeUpdate() == 0) {
        throw new InvalidKeyException
      ("No application instance with key = " + instId);
    }
    if (logger.isDebugEnabled()) {
        logger.debug ("Application " + instId
View Full Code Here

    public long registerInstance
        (String applName, String applInstKey,
         Activity activity, Object state, boolean saveAssignment) {
  try {
      Connection con = null;
      UniversalPrepStmt prepStmt = null;
      try {
    ActivityUniqueKey auk = activity.uniqueKey();
    con = ds.getConnection();
    long instId = EJBUtil.newPrimaryKey
        ("SimpleApplicationDirectory");
    prepStmt = new UniversalPrepStmt
        (ds, con, "INSERT INTO SimpleAppl (DBId, ApplName, "
         + "InstKey, ActivityKey, ProcessKey, ProcessMgr"
         + (saveAssignment ? ", ResourceKey" : "")
         + ", AssignedAt, InstData) VALUES (?, ?, ?, ?, ?, ?"
         + (saveAssignment ? ", ?" : "")
         + ", ?, ?)");
    int offset = 1;
    prepStmt.setLong (offset++, instId);
    prepStmt.setString (offset++, applName);
                prepStmt.setString (offset++, applInstKey);
    prepStmt.setString (offset++, auk.activityKey());
    prepStmt.setString (offset++, auk.processKey());
    prepStmt.setString (offset++, auk.managerName());
    if (saveAssignment) {
        String resourceKey = null;
        Iterator i = activity.assignments().iterator();
        if (i.hasNext ()) {
      WfAssignment assignment = (WfAssignment)i.next();
      resourceKey = assignment.assignee().resourceKey();
        }
        prepStmt.setString (offset++, resourceKey);
    }
    prepStmt.setTimestamp
        (offset++, new Timestamp (System.currentTimeMillis()));
    prepStmt.setBinary(offset++, state);
    prepStmt.executeUpdate();
    if (logger.isDebugEnabled()) {
        logger.debug
      ("Created application " + instId + " for " + auk);
    }
    return instId;
View Full Code Here

     * Insert a new process info into the database.
     */
    private void insertProcess()
  throws SQLException, IOException {
  Connection con = null;
  UniversalPrepStmt prepStmt = null;
  try {
      con = ds.getConnection();
      prepStmt = new UniversalPrepStmt
    (ds, con, "INSERT INTO process ("
     + "DBId, PackageId, ProcessId, XPDLREF, Name, State, "
     + "StateTime, Priority"
     + (paRequester != null
        ? ", Requester, ReqHash" : "")
     + ", Creator, ProcessMgr, "
     + "MgrVersion, CreateTime, Description, Flags) "
     + "VALUES (?, ?, ?, ?, ?, ?, ?, ?"
     + (paRequester != null ? ", ?, ?" : "")
     + ", ?, ?, ?, ?, ?, ?)");
      int offset = 1;
      Long procKey = (Long)ctx.getPrimaryKey();
      prepStmt.setLong(offset++, procKey.longValue());
      prepStmt.setString(offset++, packageId);
      prepStmt.setString(offset++, processId);
            prepStmt.setLong(offset++, xpdlRef);
      prepStmt.setString(offset++, paName);
      prepStmt.setString(offset++, paTypedState.toString());
      prepStmt.setTimestamp
    (offset++, new Timestamp (paLastStateTime.getTime()));
      prepStmt.setInt(offset++, paPriority.toInt());
      if (paRequester != null) {
    prepStmt.setBinary(offset++, paRequester);
    prepStmt.setInt (offset++, paRequester.hashCode ());
      }
      prepStmt.setString(offset++, processCreator);
      prepStmt.setString(offset++, paProcessMgrName);
      prepStmt.setString(offset++, paProcessMgrVersion);
      prepStmt.setTimestamp
    (offset++, new Timestamp (paCreateTime.getTime()));
      prepStmt.setString(offset++, paDescription);
      prepStmt.setInt(offset++, paFlags);
      prepStmt.executeUpdate();
      ((ProcessDataStore)paProcessData).setConnection (con);
      try {
    ((PersistentMap)paProcessData).store();
      } catch (PersistentMapSQLException e) {
    throw (SQLException)e.getCause();
View Full Code Here

     * transitions of a process does not need
     * to be stored.
     */
    private void storeProcess() throws SQLException, IOException {
  Connection con = null;
  UniversalPrepStmt prepStmt = null;
  try {
      if (persistentAttributeModified) {
    con = ds.getConnection();
    prepStmt = new UniversalPrepStmt
        (ds, con, "UPDATE process SET Name = ?, State = ?, "
         + "StateTime = ?, Priority = ?, Flags = ?"
         + (paDescriptionModified ? ", Description = ? " : "")
         + (myProcDef != null ? ", Xpdl = ? " : "")
         + " WHERE DBId = ? ");
    int offset = 1;
    prepStmt.setString(offset++, paName);
    prepStmt.setString(offset++, paTypedState.toString());
    prepStmt.setTimestamp
        (offset++, new Timestamp (paLastStateTime.getTime()));
    prepStmt.setInt(offset++, paPriority.toInt());
    prepStmt.setInt(offset++, paFlags);
    if (paDescriptionModified) {
        prepStmt.setString(offset++, paDescription);
        paDescriptionModified = false;
    }
    if (myProcDef != null) {
        prepStmt.setLargeString(offset++, myProcDef);
    }
    // for where clause
    prepStmt.setLong
        (offset++, ((Long)ctx.getPrimaryKey()).longValue());
    int rowCount = prepStmt.executeUpdate();
    myProcDef = null;
    if (rowCount == 0) {
        throw new NoSuchEntityException
      ("Storing row for DBId "
       + (Long)ctx.getPrimaryKey() + " failed.");
View Full Code Here

      prepStmt = con.prepareStatement(deleteStatement);
      prepStmt.setLong(1, procId);
      prepStmt.executeUpdate();
      prepStmt.close ();
      prepStmt = null;
      prepStmt = new UniversalPrepStmt
    (ds, con, "DELETE FROM Deadline WHERE Process = ?");
      prepStmt.setLong(1, ((Long)ctx.getPrimaryKey()).longValue());
      prepStmt.executeUpdate();
      prepStmt.close ();
      prepStmt = null;
      prepStmt = new UniversalPrepStmt
    (ds, con, "DELETE FROM SimpleAppl WHERE ProcessKey = ?");
      prepStmt.setString(1, ((Long)ctx.getPrimaryKey()).toString());
      prepStmt.executeUpdate();
      if (xpdlRef != null) {
          processDefinitionDirectoryLocal()
View Full Code Here

     */
    public static void updateDeadlines
  (DataSource ds, Connection con,
   Long pk, Long ak, List dls, boolean doDelete)
  throws SQLException, IOException {
  UniversalPrepStmt prepStmt = null;
  try {
      if (doDelete) {
    prepStmt = new UniversalPrepStmt
        (ds, con, "DELETE FROM Deadline WHERE Activity = ?");
    prepStmt.setLong(1, ak.longValue());
    prepStmt.executeUpdate();
    prepStmt.close ();
                prepStmt = null;
      }
      if (dls != null && dls.size () > 0) {
    prepStmt = new UniversalPrepStmt
        (ds, con, "INSERT INTO Deadline (Process, Activity, Entry, "
         + "DeadlineCond, ExceptionName, Execution, State) "
         + "VALUES (?, ?, ?, ?, ?, ?, ?)",
         new String[] {"Activity", "Entry"});
    int entry = 0;
    for (Iterator i = dls.iterator(); i.hasNext();) {
        Deadline dl = (Deadline)i.next ();
        int offset = 1;
        prepStmt.setLong(offset++, pk.longValue());
        prepStmt.setLong(offset++, ak.longValue());
        prepStmt.setInt(offset++, entry++);
        prepStmt.setLargeString(offset++, dl.getCondition());
        prepStmt.setString (offset++, dl.getExceptionName());
        prepStmt.setInt(offset++, dl.getExecution());
        prepStmt.setInt(offset++, dl.getState());
        prepStmt.executeUpdate();
    }
      }
  } finally {
      JDBCUtil.closeAll (null, prepStmt, null);
  }
View Full Code Here

    /**
     * insert the transitions into the db.
     */
    private void insertTransitions() throws SQLException {
  Connection con = null;
  UniversalPrepStmt prepStmt = null;
  try {
      con = ds.getConnection();
      Iterator it = transitionsLocalCache.iterator();
      prepStmt = new UniversalPrepStmt
    (ds, con, "INSERT INTO transition ("
     + "TransitionId, ProcessDBId, FromActivity, ToActivity, "
     + "TransGroup, TransOrder, CondType, TransCond) "
     + "VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
      while (it.hasNext()) {
    TransitionLocal t = (TransitionLocal)it.next();
    TransitionDefinitionLocal td = (TransitionDefinitionLocal)t;
    try {
        int offset = 1;
        prepStmt.setString(offset++, t.id());
        prepStmt.setLong(offset++,
             ((Long)ctx.getPrimaryKey()).longValue());
        prepStmt.setLong
      (offset++, Long.parseLong(t.from().key()));
        prepStmt.setLong
      (offset++, Long.parseLong(t.to().key()));
        prepStmt.setString(offset++, td.group());
        prepStmt.setInt(offset++, td.order());
        prepStmt.setInt(offset++, td.conditionType());
        prepStmt.setString(offset++, td.condition());
    } catch (NumberFormatException re) {
        throw new SQLException(re.getMessage());
    }
    prepStmt.executeUpdate();
      }
  } finally {
      try {
    JDBCUtil.closeAll (null, prepStmt, con);
      } catch (SQLException e) {
View Full Code Here

  }
    }

    private void updateTransitions (Connection con)
        throws SQLException, RemoteException {
        UniversalPrepStmt prepStmt = null;
        try {
            Iterator it = updatedTransitions.iterator();
            prepStmt = new UniversalPrepStmt
                (ds, con, "UPDATE transition SET Flags = ?"
                     + " WHERE ProcessDBId = ? AND TransitionId = ?");
            while (it.hasNext()) {
                ExtTransitionLocal t = (ExtTransitionLocal)it.next();
                if (logger.isDebugEnabled ()) {
                    logger.debug ("Storing " + t);
                }
                int offset = 1;
                prepStmt.setInt(offset++,
                        ((t.hasPendingToken() ? FLAGS_HAS_PENDING_TOKEN : 0)));
                prepStmt.setLong(offset++,
                        ((Long)ctx.getPrimaryKey()).longValue());
                prepStmt.setString(offset++, t.id());
                prepStmt.executeUpdate();
            }
            updatedTransitions.clear();
        } finally {
            try {
                JDBCUtil.closeAll (null, prepStmt, null);
View Full Code Here

TOP

Related Classes of de.danet.an.util.UniversalPrepStmt

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.