Package it.eng.spagobi.tools.dataset.common.datastore

Examples of it.eng.spagobi.tools.dataset.common.datastore.Record


        }
       
        int recCount = 0;
        int resultNumber = 0;
        while ((recCount < maxRecToParse) && rs.next()) {
          IRecord record = new Record(dataStore);
          for(columnIndex = 1; columnIndex <= columnCount; columnIndex++) {
            Object columnValue = rs.getObject(columnIndex);
            IField field = new Field( columnValue );
          if(columnValue != null) {
            dataStoreMeta.getFieldMeta(columnIndex-1).setType( columnValue.getClass() );
          }
          record.appendField( field );
          }
          dataStore.appendRecord(record);
          recCount++;
          logger.debug("[" + recCount + "] - Records [" + rs.getRow()  + "] succesfully readed");
        }
View Full Code Here


      }

      int rowNumber = parsedRows.length();
      for (int i = 0; i < rowNumber; i++) {
        JSONObject parsedRow = parsedRows.getJSONObject(i);
        IRecord record = new Record(dataStore);
        for(int j = 0; j < dataStoreMeta.getFieldCount(); j++) {
          String columnName = dataStoreMeta.getFieldName(j);
          String columnValue = parsedRow.getString(columnName);
          IFieldMetaData fieldMeta = dataStoreMeta.getFieldMeta(j);
     
         
          Class fieldType = fieldMeta.getType();
          Object value = null;
          if(fieldType == String.class) {
            value = columnValue;
          } else if(fieldType == BigInteger.class ) {
            value = new BigInteger(columnValue);
          } else if(fieldType == Double.class) {
            value = new Double(columnValue);
          } else if(fieldType ==  Timestamp.class) {
            value = TIMESTAMP_FORMATTER.parse(columnValue);
          } else if(fieldType ==  Date.class) {
            value = DATE_FORMATTER.parse(columnValue);
          } else if(fieldType ==  Boolean.class) {
            value = new Boolean(columnValue);
          } else {
            throw new RuntimeException("Impossible to resolve field type [" + fieldType + "]");
          }
          IField field = new Field(value);
          record.appendField(field);
        }
          dataStore.appendRecord(record);
      }
      
      
View Full Code Here

    dataStore.setMetaData(dataStoreMeta);
   
    try {       
      lineReader = new LineNumberReader( new InputStreamReader( inputDataStream ) );
      while ( (line = lineReader.readLine()) != null ){
        IRecord record = new Record(dataStore);
               
        StringTokenizer tokenizer = new StringTokenizer(line, SEPARATOR);
        while(tokenizer.hasMoreElements()){
          String token = tokenizer.nextToken();
          if (lineReader.getLineNumber() == 1) {
            FieldMetadata fieldMeta = new FieldMetadata();
            fieldMeta.setName(token);
            fieldMeta.setType(String.class);
            dataStoreMeta.addFiedMeta(fieldMeta);
          } else {
            if (token != null) {
              IField field = new Field(token);
              record.appendField(field);
            }
          }
        }
       
        if (lineReader.getLineNumber() != 1){
View Full Code Here

      }

      int rowNumber = nodes.getLength();
      boolean firstRow = true;
      for (int i = 0; i < rowNumber; i++, firstRow = false) {
        IRecord record = new Record(dataStore);
       
          NamedNodeMap nodeAttributes = nodes.item(i).getAttributes();
          for(int j = 0; j < nodeAttributes.getLength(); j++) {
            Node attribute = nodeAttributes.item(j);
            String columnName = attribute.getNodeName();
            String columnValue = attribute.getNodeValue();
            Class columnType = attribute.getNodeValue().getClass();
           
            if(firstRow==true) {
            FieldMetadata fieldMeta = new FieldMetadata();
            fieldMeta.setName( columnName );
            fieldMeta.setType( columnType );
            dataStoreMeta.addFiedMeta(fieldMeta);
          }
           
            IField field = new Field(columnValue);
          record.appendField(field);
          }
         
          dataStore.appendRecord(record);
      }
      
View Full Code Here

          throw new RuntimeException("Impossible to extract rows content from sourcebean [" + resultSB + "]", t);
       
         
        while(rowIterator.hasNext()) {   
          SourceBean rowSB = (SourceBean) rowIterator.next();
          IRecord record = new Record(dataStore);
           
          for(int i = 0; i < dataStoreMeta.getFieldCount(); i++) {
            IFieldMetaData fieldMetaData = dataStoreMeta.getFieldMeta(i);
            try {
              Object value = rowSB.getAttribute( dataStoreMeta.getFieldName(i) );
              logger.debug("Column [" + fieldMetaData.getName() + "] of type [" + (value!=null? value.getClass(): "undef") + "] is equal to [" + value + "]");         
              IField field = new Field( value );
              if(value != null) {
                dataStoreMeta.getFieldMeta(i).setType( value.getClass() );
              }
              record.appendField( field );
            } catch(Throwable t ) {
              throw new RuntimeException("Impossible to read column [" + fieldMetaData.getName()+ "] value", t);
            }
          }
          dataStore.appendRecord(record);
View Full Code Here

      String newFValue = null;
     
      Iterator it = records.iterator();
      boolean sameRow = true;
      String rowValue = "";
      newRecord = new Record();

      while (it.hasNext()){
      IRecord record =(IRecord) it.next()
      DataStoreMetaData dataStoreMeta = (DataStoreMetaData)record.getDataStore().getMetaData();
      List fields = record.getFields();
      for(int j = 0; j < fields.size(); j++) {   
        IField field = (IField)fields.get(j);
        String fieldName = dataStoreMeta.getFieldName(j);
        String fieldValue = "" + field.getValue();
       
        //checks if the field is a row, a column or a value specified into configuration and manages them
        if (fieldName.equalsIgnoreCase(pivotRow)){
          if (rowValue.equals("")) rowValue = fieldValue;
          if (!(rowValue.trim()).equalsIgnoreCase(fieldValue.trim())){
            rowValue = fieldValue;
            newRecords.add(newRecord);
            newRecord = new Record();
          }
          if (newRecord.getFieldAt(dataStoreMeta.getFieldIndex(fieldName) ) == null)
            newRecord.appendField(field);
        }
        else if (fieldName.equalsIgnoreCase(pivotColumn)){
View Full Code Here

    dataStore.getMetaData().addFiedMeta(new FieldMetadata("VAL", Double.class));
    dataStore.getMetaData().addFiedMeta(new FieldMetadata("IDX", Integer.class));
   
    // ----------------------------------------------------
   
    record = new Record();
    record.appendField(new Field("Gennaio"));
    record.appendField(new Field("SER1"));
    record.appendField(new Field(new Double(33)));
    record.appendField(new Field(new Integer(1)));
    dataStore.appendRecord(record);
   
    record = new Record();
    record.appendField(new Field("Gennaio"));
    record.appendField(new Field("SER2"));
    record.appendField(new Field(new Field(new Double(12))));
    record.appendField(new Field(new Integer(1)));
    dataStore.appendRecord(record);
   
    record = new Record();
    record.appendField(new Field("Gennaio"));
    record.appendField(new Field("SER3"));
    record.appendField(new Field(new Field(new Double(64))));
    record.appendField(new Field(new Integer(1)));
    dataStore.appendRecord(record);
   
    record = new Record();
    record.appendField(new Field("Gennaio"));
    record.appendField(new Field("SER4"));
    record.appendField(new Field(new Field(new Double(21))));
    record.appendField(new Field(new Integer(1)));
    dataStore.appendRecord(record);
   
    // ----------------------------------------------------
   
    record = new Record();
    record.appendField(new Field("Febbraio"));
    record.appendField(new Field("SER1"));
    record.appendField(new Field("56"));
    record.appendField(new Field(new Integer(2)));
    dataStore.appendRecord(record);
   
    record = new Record();
    record.appendField(new Field("Febbraio"));
    record.appendField(new Field("SER2"));
    record.appendField(new Field(new Field(new Double(35))));
    record.appendField(new Field(new Integer(2)));
    dataStore.appendRecord(record);
   
    record = new Record();
    record.appendField(new Field("Febbraio"));
    record.appendField(new Field("SER3"));
    record.appendField(new Field(new Field(new Double(13))));
    record.appendField(new Field(new Integer(2)));
    dataStore.appendRecord(record);
   
    record = new Record();
    record.appendField(new Field("Febbraio"));
    record.appendField(new Field("SER4"));
    record.appendField(new Field(new Field(new Double(75))));
    record.appendField(new Field(new Integer(2)));
    dataStore.appendRecord(record);
View Full Code Here

        }else{
          row = (Object[])o;
        }
       
       
        IRecord record = new Record(dataStore);
        for(int i = 0,  j = 0; i < dataStoreMeta.getFieldCount(); i++) {
        IFieldMetaData fieldMeta = dataStoreMeta.getFieldMeta(i);
        Boolean calculated = (Boolean)fieldMeta.getProperty("calculated");
        if(calculated.booleanValue() == false) {
          Assert.assertTrue(j < row.length, "Impossible to read field [" + fieldMeta.getName() + "] from resultset");
          record.appendField( new Field( row[j] ) );
          if(row[j] != null) fieldMeta.setType(row[j].getClass());
          j++;         
        } else {
          DataSetVariable variable = (DataSetVariable)fieldMeta.getProperty("variable");
          if(variable.getResetType() == DataSetVariable.RESET_TYPE_RECORD) {
            variable.reset();
          }
         
          record.appendField( new Field( variable.getValue()) );
          if(variable.getValue() != nullfieldMeta.setType(variable.getValue().getClass());
        }
      }
       
        processCalculatedFields(record, dataStore);
View Full Code Here

TOP

Related Classes of it.eng.spagobi.tools.dataset.common.datastore.Record

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.