Package org.uengine.util.dao

Examples of org.uengine.util.dao.IDAO


   
    return new int[]{};
  }
 
  public static int getCurrnetRunningCount(TransactionContext tc,String defVerId,String tracingTag) throws Exception {
    IDAO dao = (IDAO)ConnectiveDAO.createDAOImpl(tc, currnetRunningCount_SQL, IDAO.class);
    dao.set("defVerId", defVerId);
    dao.set("tracingTag", tracingTag);
    dao.select();
    if(dao.next()){
      return ((Number)dao.get("CNT")).intValue();
    }
   
    return 0;
  }
View Full Code Here


  }
   
  protected Map retreiveTargetStartingPoints() throws Exception{
    Map targetKeys = new HashMap();
   
    IDAO targetKeysDAO = GenericDAO.createDAOImpl(getTargetConnectionFactory(), SQL_RETREIVETARGETSTARTINGPOINTS, IDAO.class);
    targetKeysDAO.select();
    if(targetKeysDAO.size() ==0) throw new UEngineException("Failed to retreive starting points from source server: No rows are returned.");
   
    while(targetKeysDAO.next()){
      Date recentModified = (Date)targetKeysDAO.get("recentModified");
      Number lastKey = (Number)targetKeysDAO.get("lastkey");
      String objectName = (String)targetKeysDAO.get("objectName");
     
      SychronizationStartingPoint startingPoint = new SychronizationStartingPoint();
     
      startingPoint.setKeyFieldName((String)targetKeysDAO.get("keyFieldName"));
      startingPoint.setObjectName((String)targetKeysDAO.get("objectName"));
     
      if(recentModified != null)
        startingPoint.setStartingPoint(recentModified);
      else
        startingPoint.setStartingPoint(lastKey);
View Full Code Here

    /**
     * Retreives the source data first.
     */
   
    IDAO sourceDAO = GenericDAO.createDAOImpl(getSourceConnectionFactory(), SQL_RETREIVE_SOURCE, IDAO.class);
    sourceDAO.set("key", startingKey);
    sourceDAO.select();
   
    AbstractGenericDAO implSourceDAO = (AbstractGenericDAO)sourceDAO.getImplementationObject();
   
    /**
     * Change the connection information of the source data in order to store to the target server.
     */
    ConnectionFactory targetConnectionFactoryInTransaction = new ConnectionFactory(){
      public Connection getConnection() throws Exception{       
        return targetConnectionInTransaction;
      }
    };
   
    implSourceDAO.setConnectionFactory(targetConnectionFactoryInTransaction);

    /**
     * Let the SQLs auto-generated again.
     */
    implSourceDAO.setConnective(true);
    implSourceDAO.setSqlStmt(null);
    implSourceDAO.setAutoSQLGeneration(true);
    implSourceDAO.setTableName(objectName);
    implSourceDAO.setKeyField(keyFieldName);
   
    /** Create and store the insert and update SQL in order to use them later
     * since we don't have to generate them again and again within the following while-loop.
     */   
    implSourceDAO.createInsertSql();
    String insertSql = implSourceDAO.getSqlStmt();
   
    implSourceDAO.createUpdateSql();
    String updateSql = implSourceDAO.getSqlStmt();
   
   
    /**
     * this loop will insert(if new) or update(if exist) all of the source rowset
     */   
    while(sourceDAO.next() && !stopSignaled){
      System.out.print("  . "+ keyFieldName +"=["+ sourceDAO.get(keyFieldName) + "]");

      // this will check if the source value already exists
      IDAO testDAO = ConnectiveDAO.createDAOImpl(targetConnectionFactoryInTransaction, "select 1 from " + objectName + " where " + keyFieldName +" = ?key", IDAO.class);
      testDAO.set("key", sourceDAO.get(keyFieldName));
      testDAO.select();

      if(testDAO.size() > 0){
        implSourceDAO.setSqlStmt(updateSql);
        System.out.println(" [UPDATE]" + sourceDAO);
      }else{
        implSourceDAO.setSqlStmt(insertSql);
        System.out.println(" [INSERT]" + sourceDAO);
View Full Code Here

 
  public void executeActivity(ProcessInstance instance) throws Exception{
   
    Connection con = null;

    IDAO dao = ConnectiveDAO.createDAOImpl(instance.getProcessTransactionContext(), null, IDAO.class);

    MappingContext mappingContext = getMappingContext();

    //Using DAO
/*    for(int i=0; i<mappingContext.getMappingElements().length; i++){
View Full Code Here

  public String getDBMSProductName() throws Exception {
    return "Oracle";
  }

  public Calendar getNow() throws Exception {
    IDAO nowQuery = (IDAO)create(IDAO.class, "SELECT TO_CHAR( SYSDATE , 'YYYYMMDDHH24MISS' ) as NOW from dual");
    nowQuery.select();
   
    if(nowQuery.next()){
      Calendar now = Calendar.getInstance();
     
      String dateTimeStr = (String)nowQuery.get("NOW");
      int year = Integer.parseInt(dateTimeStr.substring(0, 4));
      int month = Integer.parseInt(dateTimeStr.substring(4, 6)) - 1;
      int date = Integer.parseInt(dateTimeStr.substring(6, 8));
      int hour = Integer.parseInt(dateTimeStr.substring(8, 10));
      int min = Integer.parseInt(dateTimeStr.substring(10, 12));
View Full Code Here

          forColumnName = forColumnName.replaceFirst("Proc","");
         
          if(forWhat.equals("WorkList")) forColumnName = "taskid";

          Long key  = null;
          IDAO gdao = ConnectiveDAO.createDAOImpl(
              getConnectionFactory(),
              "select isNull(max(seq),0) + 1 as lastKey from bpm_seq where tbname = '" + forTableName + "'",
              IDAO.class
            );
            gdao.select();
            if(gdao.next()){
              Number currKey = (Number)gdao.get("lastKey");
            key = new Long(currKey.longValue());
            } else {
              key = new Long(1);
            }
           
          IDAO udao = ConnectiveDAO.createDAOImpl(
              getConnectionFactory(),
              //"update bpm_seq set seq = ?seq , moddate = current timestamp where  tbname = '" + forTableName + "'",
              "update bpm_seq set seq = ?seq , moddate = getdate() where  tbname = ?tbname",
              IDAO.class
            );
         
          udao.set("seq", key);
          udao.set("tbname", forTableName);
         
          int modcount = udao.update();
          if(modcount == 0){
            IDAO idao = ConnectiveDAO.createDAOImpl(
                getConnectionFactory(),
                "insert into bpm_seq (tbname, seq, description, moddate) values(?tbname, ?seq, ?description, getdate())",
                IDAO.class
              );
            idao.set("tbname", forTableName);
            idao.set("seq", key);
            idao.set("description", forTableName);
            idao.insert();         
          }
         
          return key;
         
        } catch (Exception e) {
View Full Code Here

    return "MSsql";
  }
 
  public Calendar getNow() throws Exception {
    //IDAO nowQuery = (IDAO)create(IDAO.class, "select convert(varchar(10), getdate(), 120) as now");
    IDAO nowQuery = (IDAO)create(IDAO.class, "select getdate() as now");
    nowQuery.select();
   
    if(nowQuery.next()){
      Calendar now = Calendar.getInstance();
      now.setTime((Date)nowQuery.get("now"));
     
      return now;
    }else{
      throw new Exception("Can't get current system date from DB.");
    }
View Full Code Here

      String sharedContextKey = tableName + "@" + keyFieldValue;
      sharedContextKey = sharedContextKey.toUpperCase();
     
      if(getSharedContext(sharedContextKey)!=null){
        IDAO cachedOne = (IDAO)getSharedContext(sharedContextKey);
       
        try{
          cachedOne.first();
        }catch(Exception e){}
       
        return cachedOne;
      }
     
View Full Code Here

     
      return createSynchronizedDAO(tableName, keyFieldName, keyFieldValue, daoType, false);
    }
    private IDAO createSynchronizedDAO(String tableName, String keyFieldName, Object keyFieldValue, Class daoType, final boolean isNew) throws Exception{

      final IDAO dao = ConnectiveDAO.createDAOImpl(this, null, daoType);
      dao.getImplementationObject().setTableName(tableName);
      dao.getImplementationObject().setKeyField(keyFieldName);
      dao.set(keyFieldName, keyFieldValue);

      if(!isNew){
        dao.getImplementationObject().createSelectSql();
        dao.select();
        if(!dao.next()) throw new UEngineException("No Such "+tableName+" where "+keyFieldName+" is " + keyFieldValue);
      }
     
      String sharedContextKey = tableName + "@" + keyFieldValue;
      sharedContextKey = sharedContextKey.toUpperCase();
     
      setSharedContext(sharedContextKey, dao);
      addTransactionListener(new TransactionListener(){

        public void beforeCommit(TransactionContext tx) throws Exception {
          if(isNew)
            dao.getImplementationObject().createInsertSql();
          else
            dao.getImplementationObject().createUpdateSql();
          dao.update();
        }

        public void beforeRollback(TransactionContext tx) throws Exception {
        }
View Full Code Here

  }
 
 
  public Serializable get(ProcessInstance instance, String scope) throws Exception {
   
    IDAO dao;
   
/*    if(getFieldName().equals("BTTM_DCD")){
      System.out.println();
    }
*/   
    if(instance==null) throw new UEngineException("Instance is null");
   
    if("bpm_procinst".equalsIgnoreCase(getTableName()) && instance instanceof EJBProcessInstance){
      dao = ((EJBProcessInstance)instance).getProcessInstanceDAO();
    }else{
      Object keyValue = ((EJBProcessInstance)instance).getProcessInstanceDAO().get(getCorrelatedFieldName());
      String sharedContextKey = "DAO." + getTableName() + "@" + keyValue;
     
      if(keyValue==null) throw new UEngineException("Database Synchronization Process Variable Exception: No value for correlation key [" + getCorrelatedFieldName() + "] of instance [" + instance.getInstanceId() + "]");
     
      dao = (IDAO)instance.getProcessTransactionContext().getSharedContext(sharedContextKey);

      if(dao==null){
        String sql = "select * from " + getTableName() + " where " + getCorrelationFieldName() + "=?" + getCorrelationFieldName();
       
        //if the using database product is DB2, an uncommitted read (phantom read) should be allowed by explicit expression.
        if("DB2".equals(DAOFactory.getInstance(null).getDBMSProductName()))
          sql = sql + " with ur";
       
        dao = ConnectiveDAO.createDAOImpl(instance.getProcessTransactionContext(), sql, IDAO.class);
       
        dao.set(getCorrelationFieldName(), keyValue);
        dao.select();

        if(dao.next()){
          instance.getProcessTransactionContext().setSharedContext(sharedContextKey, dao);
        }else
          return null;
      }else{
                try{
                    dao.beforeFirst();
            dao.next();
                }catch(Exception e){}
            }
    }

    try{
      if(dao.size() == 1)
        return (Serializable)dao.get(getFieldName());
    }catch(Exception e){
      return (Serializable)dao.get(getFieldName());
    }

    ProcessVariableValue pvv = new ProcessVariableValue();
    do{
      pvv.setValue((Serializable)dao.get(getFieldName()));
      pvv.moveToAdd();
    }while(dao.next());
        pvv.beforeFirst();

        return pvv;
  }
View Full Code Here

TOP

Related Classes of org.uengine.util.dao.IDAO

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.