Package it.eng.spagobi.tools.dataset.bo

Examples of it.eng.spagobi.tools.dataset.bo.DataSetVariable


          fieldMetaDataJSON.put("type", "string");
        }
       
        Boolean calculated = (Boolean)fieldMetaData.getProperty("calculated");
        if(calculated.booleanValue() == true) {
          DataSetVariable variable =  (DataSetVariable)fieldMetaData.getProperty("variable");
          if(variable.getType().equalsIgnoreCase(DataSetVariable.HTML)) {
            fieldMetaDataJSON.put("type", "auto");
            fieldMetaDataJSON.remove("type");
            fieldMetaDataJSON.put("subtype", "html");
          }       
        }
View Full Code Here


        }
       
        Boolean calculated = (Boolean)fieldMetaData.getProperty("calculated");
        calculated = calculated == null? Boolean.FALSE: calculated;
        if(calculated.booleanValue() == true) {
          DataSetVariable variable =  (DataSetVariable)fieldMetaData.getProperty("variable");
          if(variable.getType().equalsIgnoreCase(DataSetVariable.HTML)) {
            fieldMetaDataJSON.put("type", "auto");
            fieldMetaDataJSON.remove("type");
            fieldMetaDataJSON.put("subtype", "html");
          }
         
View Full Code Here

        CalculatedSelectField claculatedQueryField = (CalculatedSelectField)queryFiled;
        dataStoreFieldMeta.setName(claculatedQueryField.getAlias());
        dataStoreFieldMeta.setProperty("calculated", new Boolean(true))
        // FIXME also calculated field must have uniquename for uniformity
        dataStoreFieldMeta.setProperty("uniqueName", claculatedQueryField.getAlias());
        DataSetVariable variable = new DataSetVariable(claculatedQueryField.getAlias(), claculatedQueryField.getType(), claculatedQueryField.getExpression());
        dataStoreFieldMeta.setProperty("variable", variable)
        dataStoreFieldMeta.setType( variable.getTypeClass() )
       
      } else if(queryFiled.isInLineCalculatedField()){
        InLineCalculatedSelectField claculatedQueryField = (InLineCalculatedSelectField)queryFiled;
        dataStoreFieldMeta.setName(claculatedQueryField.getAlias());
        dataStoreFieldMeta.setProperty("calculated", new Boolean(false))
        // FIXME also calculated field must have uniquename for uniformity
        dataStoreFieldMeta.setProperty("uniqueName", claculatedQueryField.getAlias());
        DataSetVariable variable = new DataSetVariable(claculatedQueryField.getAlias(), claculatedQueryField.getType(), claculatedQueryField.getExpression());
        dataStoreFieldMeta.setProperty("variable", variable)
        dataStoreFieldMeta.setType( variable.getTypeClass() )
       
      }
      dataStoreFieldMeta.setProperty("visible", new Boolean(queryFiled.isVisible()))
     
      dataStoreMeta.addFiedMeta(dataStoreFieldMeta);
View Full Code Here

          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);
        dataStore.appendRecord(record);
View Full Code Here

   
    dataStoreMeta = dataStore.getMetaData();
    calculatedFieldsMeta = dataStoreMeta.findFieldMeta("calculated", Boolean.TRUE);
    for(int i = 0; i < calculatedFieldsMeta.size(); i++) {
      IFieldMetaData fieldMeta = (IFieldMetaData)calculatedFieldsMeta.get(i);
      DataSetVariable variable = (DataSetVariable)fieldMeta.getProperty("variable");
     
      ScriptEngineManager scriptManager = new ScriptEngineManager();
      ScriptEngine groovyScriptEngine = scriptManager.getEngineByName("groovy");
     
     
      // handle bindings
      // ... static bindings first
      Iterator it = bindings.keySet().iterator();
      while(it.hasNext()) {
        String bindingName = (String)it.next();
        Object bindingValue = bindings.get(bindingName);
        groovyScriptEngine.put(bindingName, bindingValue);
      }
     
      // ... then runtime bindings
      Map qFields = new HashMap();
      Map dmFields = new HashMap();
      Object[] columns = new Object[dataStoreMeta.getFieldCount()];
      for(int j = 0; j < dataStoreMeta.getFieldCount(); j++) {
        qFields.put(dataStoreMeta.getFieldMeta(j).getAlias(), record.getFieldAt(j).getValue());
        dmFields.put(dataStoreMeta.getFieldMeta(j).getProperty("uniqueName"), record.getFieldAt(j).getValue());
        columns[j] = record.getFieldAt(j).getValue();
      }
     
      groovyScriptEngine.put("qFields", qFields); // key = alias
      groovyScriptEngine.put("dmFields", dmFields); // key = id
      groovyScriptEngine.put("fields", qFields); // default key = alias
      groovyScriptEngine.put("columns", columns); // key = col-index
     
      // show time
      Object calculatedValue = null;
      try {
        calculatedValue = groovyScriptEngine.eval(variable.getExpression());
       
      } catch (ScriptException ex) {
        calculatedValue = "NA";
          ex.printStackTrace();
     
     
      //logger.debug("Field [" + fieldMeta.getName()+ "] is equals to [" + calculatedValue + "]");
      variable.setValue(calculatedValue);
     
      record.getFieldAt(dataStoreMeta.getFieldIndex(fieldMeta.getName())).setValue(variable.getValue());
    }
  }
View Full Code Here

TOP

Related Classes of it.eng.spagobi.tools.dataset.bo.DataSetVariable

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.