Examples of InLineCalculatedSelectField


Examples of it.eng.qbe.query.InLineCalculatedSelectField

            fieldJSON.put(QuerySerializationConstants.FIELD_ICON_CLS, "calculation");
           
            nature = QuerySerializationConstants.FIELD_NATURE_POST_LINE_CALCULATED;
           
          } else if (field.isInLineCalculatedField()) {
            InLineCalculatedSelectField calculatedSelectField = (InLineCalculatedSelectField)field;
           
            fieldJSON.put(QuerySerializationConstants.FIELD_TYPE, field.IN_LINE_CALCULATED_FIELD);
           
            JSONObject fieldClaculationDescriptor = new JSONObject();
            fieldClaculationDescriptor.put(QuerySerializationConstants.FIELD_ALIAS, calculatedSelectField.getAlias());
            fieldClaculationDescriptor.put(QuerySerializationConstants.FIELD_TYPE, calculatedSelectField.getType());
            fieldClaculationDescriptor.put(QuerySerializationConstants.FIELD_EXPRESSION, calculatedSelectField.getExpression());
            fieldJSON.put(QuerySerializationConstants.FIELD_ID, fieldClaculationDescriptor);
            fieldJSON.put(QuerySerializationConstants.FIELD_LONG_DESCRIPTION, calculatedSelectField.getExpression());

            if ( calculatedSelectField.isGroupByField() ) {
              fieldJSON.put(QuerySerializationConstants.FIELD_GROUP, "true");
            } else {
              fieldJSON.put(QuerySerializationConstants.FIELD_GROUP, "");
            }
           
            fieldJSON.put(QuerySerializationConstants.FIELD_AGGREGATION_FUNCTION, calculatedSelectField.getFunction().getName());
            fieldJSON.put(QuerySerializationConstants.FIELD_ORDER, calculatedSelectField.getOrderType());
           
            //fieldJSON.put(SerializationConstants.FIELD_GROUP, "");
            fieldJSON.put(QuerySerializationConstants.FIELD_ORDER, "");
            //fieldJSON.put(SerializationConstants.FIELD_AGGREGATION_FUNCTION, "");
           
            fieldJSON.put(QuerySerializationConstants.FIELD_ICON_CLS, "calculation");
           
            /*
             * We should understand if the calculated field is an attribute (i.e. a composition of attributes)
             * or a measure (i.e. a composition of measures).
             * The easiest way to understand this it to see if it is a grouping field.
             * TODO manage queries without any aggregation and grouping.
             * At the time being this information is used only in crosstab definition, and crosstab base query SHOULD
             * make aggregation.
             */
            if ( calculatedSelectField.isGroupByField() ) {
              nature = QuerySerializationConstants.FIELD_NATURE_ATTRIBUTE;
            } else {
              nature = QuerySerializationConstants.FIELD_NATURE_MEASURE;
            }
           
View Full Code Here

Examples of it.eng.qbe.query.InLineCalculatedSelectField

    List selectFields;
    List allSelectFields;
    List<InLineCalculatedSelectField> selectInLineCalculatedFields = new ArrayList<InLineCalculatedSelectField>();
    AbstractSelectField selectAbstractField;
    DataMartSelectField selectField;
    InLineCalculatedSelectField selectInLineField;
    IModelEntity rootEntity;
    IModelField datamartField;
    String queryName;
    String rootEntityAlias;
    String selectClauseElement; // rootEntityAlias.queryName
    Map entityAliases;
    List<String> aliasEntityMapping;
   
    logger.debug("IN");
    buffer = new StringBuffer();
    try {
      selectFields = query.getSelectFields(true);
     
      if(selectFields == null ||selectFields.size() == 0) {
        return "";
      }
     
      entityAliases = (Map)entityAliasesMaps.get(query.getId());
           
      buffer.append(SELECT);   
      if (query.isDistinctClauseEnabled()) {
        buffer.append(" " + DISTINCT);
      }
     
      Iterator it = selectFields.iterator();
      if(it.hasNext()){
        selectAbstractField = (AbstractSelectField)it.next();
        String[] idsForQuery = new String[selectFields.size()-query.getCalculatedSelectFields(true).size()];
        int index=0;
        do{       
          if(selectAbstractField.isDataMartField()){
         
            selectField = (DataMartSelectField)selectAbstractField;
           
            logger.debug("select field unique name [" + selectField.getUniqueName() + "]");
           
            datamartField = getDataSource().getModelStructure().getField(selectField.getUniqueName());
            queryName = (String)datamartField.getQueryName().getFirst();
            logger.debug("select field query name [" + queryName + "]");
           
            rootEntity = datamartField.getParent().getRoot();    
            logger.debug("select field root entity unique name [" + rootEntity.getUniqueName() + "]");
           
            rootEntityAlias = (String)entityAliases.get(rootEntity.getUniqueName());
            if(rootEntityAlias == null) {
              rootEntityAlias = getNextAlias(entityAliasesMaps);
              entityAliases.put(rootEntity.getUniqueName(), rootEntityAlias);
            }
            logger.debug("select field root entity alias [" + rootEntityAlias + "]");
           
           
            selectClauseElement = rootEntityAlias + "." + queryName;
            logger.debug("select clause element before aggregation [" + selectClauseElement + "]");
           
            selectClauseElement = selectField.getFunction().apply(selectClauseElement);
            logger.debug("select clause element after aggregation [" + selectClauseElement + "]");
           
           
            idsForQuery[index] = " " + selectClauseElement;
            index++;
            logger.debug("select clause element succesfully added to select clause");

          }else if(selectAbstractField.isInLineCalculatedField()){
            selectInLineCalculatedFields.add((InLineCalculatedSelectField)selectAbstractField);
            index++;
          }

          if(it.hasNext()){
            selectAbstractField = (AbstractSelectField)it.next();
          }else{
            break;
          }
         
        } while( true );
       

       
        aliasEntityMapping = new ArrayList<String>();
        for(int k=0; k< selectInLineCalculatedFields.size(); k++){
          selectInLineField = selectInLineCalculatedFields.get(k);
         
          String expr = selectInLineField.getExpression();//.replace("\'", "");     
          expr = parseInLinecalculatedField(expr, query, entityAliasesMaps);
          expr = selectInLineField.getFunction().apply(expr);
         
          for(int y= 0; y<idsForQuery.length; y++){
            if(idsForQuery[y]==null){
              idsForQuery[y]=" " +expr;
              index = y;
View Full Code Here

Examples of it.eng.qbe.query.InLineCalculatedSelectField

    Iterator<AbstractSelectField> it = groupByFields.iterator();
    while( it.hasNext() ) {
      AbstractSelectField abstractSelectedField = it.next();
     
      if(abstractSelectedField.isInLineCalculatedField()){
        InLineCalculatedSelectField icf = (InLineCalculatedSelectField)abstractSelectedField;
        fieldName = parseInLinecalculatedField(icf.getExpression(), query, entityAliasesMaps);
      }else{
     
        DataMartSelectField groupByField = (DataMartSelectField)abstractSelectedField;
        IModelField datamartField = getDataSource().getModelStructure().getField(groupByField.getUniqueName());
        IModelEntity entity = datamartField.getParent().getRoot();
View Full Code Here

Examples of it.eng.qbe.query.InLineCalculatedSelectField

        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()))
View Full Code Here

Examples of it.eng.qbe.query.InLineCalculatedSelectField

    List selectFields;
    List allSelectFields;
    List<InLineCalculatedSelectField> selectInLineCalculatedFields = new ArrayList<InLineCalculatedSelectField>();
    AbstractSelectField selectAbstractField;
    DataMartSelectField selectField;
    InLineCalculatedSelectField selectInLineField;
    IModelEntity rootEntity;
    IModelField datamartField;
    String queryName;
    String rootEntityAlias;
    String selectClauseElement; // rootEntityAlias.queryName
    Map entityAliases;
     
    logger.debug("IN");
    buffer = new StringBuffer();
    try {
      selectFields = query.getSelectFields(true);
     
      if(selectFields == null ||selectFields.size() == 0) {
        return "";
      }
     
      entityAliases = (Map)entityAliasesMaps.get(query.getId());
           
      buffer.append(SELECT);   
      if (query.isDistinctClauseEnabled()) {
        buffer.append(" " + DISTINCT);
      }
     
      Iterator it = selectFields.iterator();
      if(it.hasNext()){
        selectAbstractField = (AbstractSelectField)it.next();
        String[] idsForQuery = new String[selectFields.size()-query.getCalculatedSelectFields(true).size()];
        int index=0;
        do{       
          if(selectAbstractField.isDataMartField()){
         
            selectField = (DataMartSelectField)selectAbstractField;
           
            logger.debug("select field unique name [" + selectField.getUniqueName() + "]");
           
            datamartField = getDataSource().getModelStructure().getField(selectField.getUniqueName());
           
            Couple queryNameAndRoot = datamartField.getQueryName();
           
            queryName = (String) queryNameAndRoot.getFirst();
            logger.debug("select field query name [" + queryName + "]");
           
            if(queryNameAndRoot.getSecond()!=null){
              rootEntity = (IModelEntity)queryNameAndRoot.getSecond();  
            }else{
              rootEntity = datamartField.getParent().getRoot();  
            }
           
             
            logger.debug("select field root entity unique name [" + rootEntity.getUniqueName() + "]");
           
            rootEntityAlias = (String)entityAliases.get(rootEntity.getUniqueName());
            if(rootEntityAlias == null) {
              rootEntityAlias = getNextAlias(entityAliasesMaps);
              entityAliases.put(rootEntity.getUniqueName(), rootEntityAlias);
            }
            logger.debug("select field root entity alias [" + rootEntityAlias + "]");
           
           
            selectClauseElement = rootEntityAlias + "." + queryName.substring(0,1).toLowerCase()+queryName.substring(1);
            //selectClauseElement = rootEntityAlias + "." + queryName;
            logger.debug("select clause element before aggregation [" + selectClauseElement + "]");
           
            selectClauseElement = selectField.getFunction().apply(selectClauseElement);
            logger.debug("select clause element after aggregation [" + selectClauseElement + "]");
           
           
            idsForQuery[index] = " " + selectClauseElement;
            index++;
            logger.debug("select clause element succesfully added to select clause");

          }else if(selectAbstractField.isInLineCalculatedField()){
            selectInLineCalculatedFields.add((InLineCalculatedSelectField)selectAbstractField);
            index++;
          }

          if(it.hasNext()){
            selectAbstractField = (AbstractSelectField)it.next();
          }else{
            break;
          }
         
        } while( true );
       

        for(int k=0; k< selectInLineCalculatedFields.size(); k++){
          selectInLineField = selectInLineCalculatedFields.get(k);
         
          String expr = selectInLineField.getExpression();//.replace("\'", "");     
          expr = parseInLinecalculatedField(expr, query, entityAliasesMaps);
          expr = selectInLineField.getFunction().apply(expr);
         
          for(int y= 0; y<idsForQuery.length; y++){
            if(idsForQuery[y]==null){
              idsForQuery[y]=" " +expr;
              index = y;
View Full Code Here

Examples of it.eng.qbe.query.InLineCalculatedSelectField

    Iterator<AbstractSelectField> it = groupByFields.iterator();
    while( it.hasNext() ) {
      AbstractSelectField abstractSelectedField = it.next();
     
      if(abstractSelectedField.isInLineCalculatedField()){
        InLineCalculatedSelectField icf = (InLineCalculatedSelectField)abstractSelectedField;
        fieldName = parseInLinecalculatedField(icf.getExpression(), query, entityAliasesMaps);
      }else{
     
        DataMartSelectField groupByField = (DataMartSelectField)abstractSelectedField;
        IModelField datamartField = getDataSource().getModelStructure().getField(groupByField.getUniqueName());
       
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.