Package it.eng.spago.dbaccess.sql

Examples of it.eng.spago.dbaccess.sql.DataConnection


   * @return  The Domain ID
   */
    private Integer findSBIDomainValueID(String domainCode, String valueCode ){
      SQLCommand cmd = null;
    DataResult dr = null;
    DataConnection dataConnection = null;
    Integer returnValue = null;
    try {
      IDomainDAO domdao = DAOFactory.getDomainDAO();
      Domain dom = domdao.loadDomainByCodeAndValue(domainCode, valueCode);
      returnValue = dom.getValueId();
View Full Code Here


    */
     public static Object executeSelect(RequestContainer requestContainer,
        ResponseContainer responseContainer, String datasource, String statement) throws EMFInternalError {
      Object result = null;
      DataConnectionManager dataConnectionManager = null;
      DataConnection dataConnection = null;
      SQLCommand sqlCommand = null;
      DataResult dataResult = null;
      try {
        //dataConnectionManager = DataConnectionManager.getInstance();
        //dataConnection = dataConnectionManager.getConnection(pool);
        DataSourceUtilities dsUtil = new DataSourceUtilities();
        Connection conn = dsUtil.getConnection(requestContainer,datasource);
        dataConnection = dsUtil.getDataConnection(conn);

        sqlCommand = dataConnection.createSelectCommand(statement);
        dataResult = sqlCommand.execute();
        ScrollableDataResult scrollableDataResult = (ScrollableDataResult) dataResult
            .getDataObject();
        result = scrollableDataResult.getSourceBean();
      } finally {
View Full Code Here

   * @return a boolean value with the response of the operation.
   *
   */
  public boolean executeUpdateQuery(Map<String , Object> params, JSONObject metaParams) throws Throwable, Exception{
    boolean toReturn = true;
    DataConnection dataConnection = null;
    SQLCommand sqlCommand = null;
    DataResult dataResult = null;
   
    logger.debug("IN");
   
    try {

      Connection jdbcConnection = datasource.getConnection();
      jdbcConnection.setAutoCommit(false);
      dataConnection = getDataConnection(jdbcConnection);

      String statement = SQLStatements.getStatement((String)params.get( STMT ));
      logger.debug("Parameter [" + STMT + "] is equals to [" + statement + "]");     
      Assert.assertTrue(!StringUtilities.isEmpty( statement ), "Parameter [" + STMT + "] cannot be null or empty");
     
      String numParsStr = (String) params.get( NUM_PARS );
      int numPars = (numParsStr != null)?Integer.parseInt(numParsStr):0;
      logger.debug("Parameter [ numPars ] is equals to [" + numPars + "]");
     
      sqlCommand = dataConnection.createUpdateCommand(statement);
      dataConnection.initTransaction();
     
      if (numPars > 0){
        List inputParameter = new ArrayList(numPars);

        if (metaParams == null){ 
          Assert.assertTrue(metaParams == null, "Parameter [" + metaParams + "] cannot be null or empty.");         
        }else{
          JSONArray queryPars = (JSONArray)metaParams.get("queryParams");
          //for (int j=0; j<queryPars.length(); j++){
          for (int j=0; j<numPars; j++){
            JSONObject obj = (JSONObject)queryPars.get(j);
            String paramType = (String)obj.get("type");
            String paramName = (String)obj.get("name");
            String paramValue = (String)params.get(paramName);
            //if value isn't valorized, checks the defualt (if it's defined into meta section)
            if (paramValue == null){
              try{
                paramValue =  (String)obj.get("default");
              }catch(JSONException je ){
                logger.error("param " + paramName + "in JSON template not found. Parameter value is null!");
                paramValue = null;
              }
            }
            inputParameter.add(dataConnection.createDataField(paramName,getParamType(paramType), paramValue));             
         
        }
       
        dataResult = sqlCommand.execute(inputParameter);
      }else{
        dataResult = sqlCommand.execute();
      }
      dataConnection.commitTransaction();
    } // try
    catch (Exception ex) {
      toReturn = false;
      logger.error("QueryExecutor::executeQuery:", ex);
      try{
        dataConnection.rollBackTransaction();
      } catch (Throwable t) {
        toReturn = false;
        throw new Throwable(t);
      }
      throw new Throwable(ex);
View Full Code Here

   * @return The Spago DataConnection Object
   *
   * @throws EMFInternalError the EMF internal error
   */
  public DataConnection getDataConnection(Connection con) throws EMFInternalError {
    DataConnection dataCon = null;
    try {
      Class mapperClass = Class.forName("it.eng.spago.dbaccess.sql.mappers.OracleSQLMapper");
      SQLMapper sqlMapper = (SQLMapper)mapperClass.newInstance();
      dataCon = new DataConnection(con, "2.1", sqlMapper);
    } catch(Exception e) {
      logger.error("Error while getting Data Source " + e);
      throw new EMFInternalError(EMFErrorSeverity.ERROR, "cannot build spago DataConnection object");
    }
    return dataCon;
View Full Code Here

   * @throws Exception 
   */

  private String getLovResult(IEngUserProfile profile,String statement) throws Exception {
    String resStr = null;
    DataConnection dataConnection = null;
    SQLCommand sqlCommand = null;
    DataResult dataResult = null;
    try {
      //gets connection
      DataSourceUtilities dsUtil = new DataSourceUtilities();
      Connection conn = dsUtil.getConnection(profile,dataSource);
      dataConnection = dsUtil.getDataConnection(conn);
      sqlCommand = dataConnection.createSelectCommand(statement, false);
      dataResult = sqlCommand.execute();
      ScrollableDataResult scrollableDataResult = (ScrollableDataResult) dataResult.getDataObject();
      SourceBean result = scrollableDataResult.getSourceBean();
      resStr = result.toXML(false);
      resStr = resStr.trim();
View Full Code Here

   */
  public List validateValues(IEngUserProfile profile, BIObjectParameter biparam) throws Exception {
    List toReturn = new ArrayList();
    List<String> values = biparam.getParameterValues();
    List parameterValuesDescription = new ArrayList();
    DataConnection dataConnection = null;
    SQLCommand sqlCommand = null;
    DataResult dataResult = null;
    String statement = null;
    SourceBean result = null;
    try {
      statement = getValidationQuery(profile, biparam, values);
      //gets connection
      DataSourceUtilities dsUtil = new DataSourceUtilities();
      Connection conn = dsUtil.getConnection(profile,dataSource);
      dataConnection = dsUtil.getDataConnection(conn);
      sqlCommand = dataConnection.createSelectCommand(statement, false);
      dataResult = sqlCommand.execute();
      ScrollableDataResult scrollableDataResult = (ScrollableDataResult) dataResult.getDataObject();
      result = scrollableDataResult.getSourceBean();
    } finally {
      Utils.releaseResources(dataConnection, sqlCommand, dataResult);
View Full Code Here

   public static Object executeSelect(RequestContainer requestContainer,
       ResponseContainer responseContainer, String datasource, String statement, List columnsNames) throws EMFInternalError {
      //ResponseContainer responseContainer, String pool, String statement, List columnsNames) throws EMFInternalError {
    Object result = null;
    //DataConnectionManager dataConnectionManager = null;
    DataConnection dataConnection = null;
    SQLCommand sqlCommand = null;
    DataResult dataResult = null;
    try {
      /*dataConnectionManager = DataConnectionManager.getInstance();
      dataConnection = dataConnectionManager.getConnection(pool);
      */
      //gets connection
      DataSourceUtilities dsUtil = new DataSourceUtilities();
      Connection conn = dsUtil.getConnection(requestContainer,datasource);
      dataConnection = dsUtil.getDataConnection(conn);

      sqlCommand = dataConnection.createSelectCommand(statement, false);
      dataResult = sqlCommand.execute();
      ScrollableDataResult scrollableDataResult = (ScrollableDataResult) dataResult
          .getDataObject();
      List temp = Arrays.asList(scrollableDataResult.getColumnNames());
      columnsNames.addAll(temp);
View Full Code Here

    String statement = getQueryStatement("CHECKED_QUERY", parameters);

    // exec CHECKED_QUERY
    ScrollableDataResult scrollableDataResult = null;
    SQLCommand sqlCommand = null;
    DataConnection dataConnection = null;
    DataResult dataResult = null;
    String pool = null;
    try {
      pool = (String) config.getAttribute("POOL");
      dataConnection = DataConnectionManager.getInstance().getConnection(
          pool);
      sqlCommand = dataConnection.createSelectCommand(statement);
      dataResult = sqlCommand.execute();
      scrollableDataResult = (ScrollableDataResult) dataResult
          .getDataObject();
      SourceBean chekedObjectsBean = scrollableDataResult.getSourceBean();
      List checkedObjectsList = chekedObjectsBean
          .getAttributeAsList("ROW");

      String tmpElements = (request.getAttribute("checkedElements")==null)?"":(String)request.getAttribute("checkedElements");
        String[] arrElements = tmpElements.split(",");
       for (int i = 0; i< arrElements.length; i++)
         allElements.add(arrElements[i]);
      
       checkedObjectsMap = copyLstObjects(allElements);
      
    } catch (Exception e) {
      SpagoBITracer.major(SpagoBIConstants.NAME_MODULE, this.getClass()
          .getName(), "createCheckedObjectMap", e.getMessage(), e);
    } finally {
      if (dataConnection != null)
        dataConnection.close();
    }
  }
View Full Code Here

   */
   public static Object executeSelect(RequestContainer requestContainer,
      ResponseContainer responseContainer, String pool, String statement) throws EMFInternalError {
    Object result = null;
    DataConnectionManager dataConnectionManager = null;
    DataConnection dataConnection = null;
    SQLCommand sqlCommand = null;
    DataResult dataResult = null;
    try {
      dataConnectionManager = DataConnectionManager.getInstance();
      dataConnection = dataConnectionManager.getConnection(pool);
      sqlCommand = dataConnection.createSelectCommand(statement);
      dataResult = sqlCommand.execute();
      ScrollableDataResult scrollableDataResult = (ScrollableDataResult) dataResult
          .getDataObject();
      result = scrollableDataResult.getSourceBean();
    } catch (Exception ex) {
View Full Code Here

    Transaction tx = null;
   
    // exec CHECKED_QUERY
    ScrollableDataResult scrollableDataResult = null;
    SQLCommand sqlCommand = null;
    DataConnection dataConnection = null;
    DataResult dataResult = null;
    try {
      aSession = HibernateUtil.currentSession();
      tx = aSession.beginTransaction();
      Connection jdbcConnection = aSession.connection();
      dataConnection = DelegatedHibernateConnectionListService.getDataConnection(jdbcConnection);
          sqlCommand = dataConnection.createSelectCommand(statement);
          dataResult = sqlCommand.execute();
          scrollableDataResult = (ScrollableDataResult) dataResult.getDataObject();
      SourceBean chekedObjectsBean = scrollableDataResult.getSourceBean();
      List checkedObjectsList = chekedObjectsBean
          .getAttributeAsList("ROW");
View Full Code Here

TOP

Related Classes of it.eng.spago.dbaccess.sql.DataConnection

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.