Package org.apache.tuscany.das.rdb.config

Examples of org.apache.tuscany.das.rdb.config.ResultDescriptor


        columns = new String[size];
        tables = new String[size];
        types = new Type[size];

        for (int i = 0; i < size; i++) {
            ResultDescriptor desc = (ResultDescriptor) resultDescriptor.get(i);
            tables[i] = desc.getTableName();
            columns[i] = desc.getColumnName();

            int idx = desc.getColumnType().lastIndexOf('.');
            String uri = desc.getColumnType().substring(0, idx);
            String typeName = desc.getColumnType().substring(idx + 1);

            types[i] = helper.getType(uri, typeName);
            if (types[i] == null) {
                throw new RuntimeException("Could not find type " + desc.getColumnType()
                        + " for column " + desc.getColumnName());
            }
        }

    }
View Full Code Here


        tables = new String[size];
        types = new Type[size];
        schema = new String[size];
       
        for (int i = 0; i < size; i++) {
            ResultDescriptor desc = (ResultDescriptor) resultDescriptor.get(i);
            if(model.isDatabaseSchemaNameSupported()){
              if(desc.getSchemaName() != null && !desc.getSchemaName().equals("")){
                tables[i] = desc.getTableName();
                schema[i] = desc.getSchemaName();
              }else{
                tables[i] = desc.getTableName();
                schema[i] = "";
              }
               
            }else{
               tables[i] = desc.getTableName();
               schema[i] = "";
            }
            columns[i] = desc.getColumnName();

            int idx = desc.getColumnType().lastIndexOf('.');
            String uri = desc.getColumnType().substring(0, idx);
            String typeName = desc.getColumnType().substring(idx + 1);

            types[i] = helper.getType(uri, typeName);
            if (types[i] == null) {
                throw new RuntimeException("Could not find type " + desc.getColumnType()
                        + " for column " + desc.getColumnName());
            }
        }

    }
View Full Code Here

      return;
    }
   
    //when any index is found not set, do not sort 
    for(Iterator it =  this.resultDescriptors.iterator() ; it.hasNext();){
      ResultDescriptor resultDescriptor = (ResultDescriptor) it.next();
      if(resultDescriptor.getColumnIndex() <= -1){
        return;
      }
    }

    //now is time to sort
    Object[] resultDescAry = this.resultDescriptors.toArray();
    for(int i=0; i<resultDescAry.length; i++){
      for(int j=i+1; j<resultDescAry.length; j++){
        if( ((ResultDescriptor)resultDescAry[j]).getColumnIndex()
            < ((ResultDescriptor)resultDescAry[i]).getColumnIndex()){
          ResultDescriptor tmpResDesc = (ResultDescriptor)resultDescAry[i];
          resultDescAry[i] = resultDescAry[j];
          resultDescAry[j] = tmpResDesc;
        }
       
        if( ((ResultDescriptor)resultDescAry[j]).getColumnIndex()
View Full Code Here

   
      if(resultDescriptor.getColumnIndex() <0){
        this.resultDescriptors.add(deepCopyResultDescriptor(resultDescriptor));//dont care about columnIndex,add at end,  old way
      }
      else{
        ResultDescriptor existing = getResultDescriptor(resultDescriptor.getColumnIndex());
        if(existing != null){
          removeResultDescriptor(resultDescriptor.getColumnIndex());
        }
        this.resultDescriptors.add(deepCopyResultDescriptor(resultDescriptor));//add at end, sorting will happen below
      }
View Full Code Here

    public ResultDescriptor removeResultDescriptor(int columnIndex){
      //if < 0 index return null
      //if >=0 index and available at given index, remove and return same
      //if >=0 index and not available at given index, return null
      ResultDescriptor existing = null;
      if(columnIndex >=0 && ((existing = getResultDescriptor(columnIndex)) != null) ){
        this.resultDescriptors.remove(existing);     
        refreshResultSetShape();     
        return existing;
      }     
View Full Code Here

   
    public ResultDescriptor removeResultDescriptor(ResultDescriptor resultDescriptor){
      //remove and return only if matched for index, name, type, table name, schema name
      //else return null
      if(resultDescriptor != null){
        ResultDescriptor existing = getResultDescriptor(resultDescriptor.getColumnIndex());
        if(existing != null &&
           existing.getColumnName().equals(resultDescriptor.getColumnName()) &&
           existing.getColumnType().equals(resultDescriptor.getColumnType()) &&
           existing.getTableName().equals(resultDescriptor.getTableName()) ) {
           if(this.configWrapper.getConfig().isDatabaseSchemaNameSupported()){//multi schema support
             if(resultDescriptor.getSchemaName() != null && existing.getSchemaName() != null
            && resultDescriptor.getSchemaName().equals(existing.getSchemaName())){
               this.resultDescriptors.remove(existing);              
               refreshResultSetShape();             
               return existing;
             }
             return null;
View Full Code Here

      //if >=0 index and available at given index,  return same
      //if >=0 index and not available at given index, return null
      if(columnIndex >=0 && this.resultDescriptors != null){
     
      for(Iterator it =  this.resultDescriptors.iterator() ; it.hasNext();){
        ResultDescriptor rs = (ResultDescriptor) it.next();

        if( rs.getColumnIndex() == columnIndex){
          return rs;
        }

      }       
      }
View Full Code Here

        // Read a customer
        Command select = das.createCommand("SELECT ID, LASTNAME, ADDRESS FROM CUSTOMER WHERE CUSTOMER.ID = 1");
       
        List resultDescriptorList = new ArrayList();
        //as long as columnIndex is correct, order in ArrayList does not matter
        ResultDescriptor desc3 = factory.createResultDescriptor();
        desc3.setColumnIndex(3);
        desc3.setColumnName("ADDRESS");
        desc3.setColumnType("commonj.sdo.String");
        desc3.setTableName("CUSTOMER");

        ResultDescriptor desc1 = factory.createResultDescriptor();
        desc1.setColumnIndex(1);
        desc1.setColumnName("ID");
        desc1.setColumnType("commonj.sdo.Int");
        desc1.setTableName("CUSTOMER");
       
        ResultDescriptor desc2 = factory.createResultDescriptor();
        desc2.setColumnIndex(2);
        desc2.setColumnName("LASTNAME");
        desc2.setColumnType("commonj.sdo.String");
        desc2.setTableName("CUSTOMER");
               
        resultDescriptorList.add(desc3);
        resultDescriptorList.add(desc1);
        resultDescriptorList.add(desc2);
       
        select.setResultDescriptors(resultDescriptorList);
        DataObject root = select.executeQuery();
        assertEquals(1, root.getList("CUSTOMER").size());
       
        //Now use invalid one
        resultDescriptorList.clear();
       
        desc3.setColumnIndex(3);
        desc3.setColumnName("ADDRESS");
        desc3.setColumnType("commonj.sdo.Int");//incompatible type
        desc3.setTableName("CUSTOMER");

        desc1.setColumnIndex(1);
        desc1.setColumnName("ID");
        desc1.setColumnType("commonj.sdo.Int");
        desc1.setTableName("CUSTOMER");
       
        desc2 = factory.createResultDescriptor();
        desc2.setColumnIndex(2);
        desc2.setColumnName("LASTNAME");
        desc2.setColumnType("commonj.sdo.String");
        desc2.setTableName("CUSTOMER");
       
        resultDescriptorList.add(desc3);
        resultDescriptorList.add(desc2);
        resultDescriptorList.add(desc1);
       
View Full Code Here

        List custList = root.getList("CUSTOMER");
        assertEquals("Williams", ((DataObject)custList.get(0)).getString("LASTNAME"));
       
        List resultDescriptorList = new ArrayList();

        ResultDescriptor desc3 = factory.createResultDescriptor();
        desc3.setColumnIndex(3);
        desc3.setColumnName("ADDRESS");
        desc3.setColumnType("commonj.sdo.Int");//incompatible type
        desc3.setTableName("CUSTOMER");

        ResultDescriptor desc1 = factory.createResultDescriptor();
        desc1.setColumnIndex(1);
        desc1.setColumnName("ID");
        desc1.setColumnType("commonj.sdo.Int");
        desc1.setTableName("CUSTOMER");
       
        ResultDescriptor desc2 = factory.createResultDescriptor();
        desc2.setColumnIndex(2);
        desc2.setColumnName("LASTNAME");
        desc2.setColumnType("commonj.sdo.String");
        desc2.setTableName("CUSTOMER");
               
        resultDescriptorList.add(desc3);
        resultDescriptorList.add(desc1);
        resultDescriptorList.add(desc2);
       
View Full Code Here

        // Read a customer
        Command select = das.createCommand("SELECT ID, LASTNAME, ADDRESS FROM CUSTOMER WHERE CUSTOMER.ID = 1");
       
        List resultDescriptorList = new ArrayList();
       
        ResultDescriptor desc3 = factory.createResultDescriptor();
        desc3.setColumnIndex(-3);//invalid
        desc3.setColumnName("ADDRESS");
        desc3.setColumnType("commonj.sdo.String");
        desc3.setTableName("CUSTOMER");

        ResultDescriptor desc1 = factory.createResultDescriptor();
        desc1.setColumnIndex(1);
        desc1.setColumnName("ID");
        desc1.setColumnType("commonj.sdo.Int");
        desc1.setTableName("CUSTOMER");
       
        ResultDescriptor desc2 = factory.createResultDescriptor();
        desc2.setColumnIndex(2);
        desc2.setColumnName("LASTNAME");
        desc2.setColumnType("commonj.sdo.String");
        desc2.setTableName("CUSTOMER");
               
        resultDescriptorList.add(desc3);
        resultDescriptorList.add(desc1);
        resultDescriptorList.add(desc2);
View Full Code Here

TOP

Related Classes of org.apache.tuscany.das.rdb.config.ResultDescriptor

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.