Package it.eng.qbe.query

Examples of it.eng.qbe.query.DataMartSelectField


    StringBuffer buffer;
    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++;
View Full Code Here


    try {
    Map<String, Set<String>> viewToInnerEntitiesMap = new HashMap<String, Set<String>>();
    List<ISelectField> selectFields =  query.getSelectFields(true);
    for(ISelectField selectField : selectFields) {
      if(selectField.isDataMartField()){
        DataMartSelectField dataMartSelectField = (DataMartSelectField)selectField;
        IModelField modelField = getDataSource().getModelStructure().getField(dataMartSelectField.getUniqueName());
        List<ModelViewEntity> viewEntities = modelField.getParentViews();
        if(viewEntities!=null){
          for(ModelViewEntity viewEntity : viewEntities) {
            if( !viewToInnerEntitiesMap.containsKey( viewEntity.getUniqueName() ) ) {
              viewToInnerEntitiesMap.put(viewEntity.getUniqueName(), new HashSet<String>());
View Full Code Here

      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());
       
           
        Couple queryNameAndRoot = datamartField.getQueryName();
        IModelEntity root;
        String queryName = (String) queryNameAndRoot.getFirst();
View Full Code Here

 
  private List getOrderByFields(Query query) {
    List orderByFields = new ArrayList();
    Iterator it = query.getDataMartSelectFields(false).iterator();
    while( it.hasNext() ) {
      DataMartSelectField selectField = (DataMartSelectField)it.next();
      if(selectField.isOrderByField()) {
        orderByFields.add(selectField);
      }
    }
    return orderByFields;
  }
View Full Code Here

  }
 
  private String buildOrderByClause(Query query, Map entityAliasesMaps) {
    StringBuffer buffer;
    Iterator it;
    DataMartSelectField selectField;
   
    it = getOrderByFields(query).iterator();   
    if(!it.hasNext()) {
      return "";
    }
   
    buffer = new StringBuffer()
    buffer.append("ORDER BY");
   
    Map entityAliases = (Map)entityAliasesMaps.get(query.getId());
         
    while( it.hasNext() ) {
      selectField = (DataMartSelectField)it.next();
     
      Assert.assertTrue(selectField.isOrderByField(), "Field [" + selectField.getUniqueName() +"] is not an orderBy filed");
     
      IModelField datamartField = getDataSource().getModelStructure().getField(selectField.getUniqueName());
      Couple queryNameAndRoot = datamartField.getQueryName();
      IModelEntity root;
      String queryName = (String) queryNameAndRoot.getFirst();
      logger.debug("select field query name [" + queryName + "]");
     
      if(queryNameAndRoot.getSecond()!=null){
        root = (IModelEntity)queryNameAndRoot.getSecond();  
      }else{
        root = datamartField.getParent().getRoot();  
      }
     
      if(!entityAliases.containsKey(root.getUniqueName())) {
        entityAliases.put(root.getUniqueName(), getNextAlias(entityAliasesMaps));
      }
      String entityAlias = (String)entityAliases.get( root.getUniqueName() );
      String fieldName = entityAlias + "." + queryName;
      buffer.append(" " + selectField.getFunction().apply(fieldName));
      buffer.append(" " + (selectField.isAscendingOrder()?"ASC": "DESC") );
           
      if( it.hasNext() ) {
        buffer.append(",");
      }
    }
View Full Code Here

TOP

Related Classes of it.eng.qbe.query.DataMartSelectField

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.