public void initCmbValues(Component comp) { // first click in panel
   if (comp != null) {
     FeatureList featList = new FeatureList(FeatureManager.getDefaultFeatures(comp.getName()));
     componentName.setText("Component: " + comp.getName());
     cmbFeatures.removeAllItems();
     for (Feature feat : featList.getFeatureList()) {
       cmbFeatures.addItem(feat.getName());
     }
     renewCmbValues(comp);
     unlockComponents();
   }
 }
  public void renewCmbValues(Component comp) { // call when an item state changes in Cmb
    DBFeatureValues values = null;
    if (comp != null && cmbFeatures.getSelectedItem() != null) {
      // try{
      values =
          FeatureManager.getFeatureValues(comp.getName(), cmbFeatures.getSelectedItem().toString());
      // }catch(Exception e){}
      unlockComponents();

      // remove listeners first so that changing the values in combo box will not trigger saves
      removeCmbValuesListeners();

      cmbValues.removeAllItems();
      if (values != null) {
        for (String value : values.getValues()) {
          cmbValues.addItem(value);
        }
        cmbValues.setSelectedItem(
            comp.getFeature(cmbFeatures.getSelectedItem().toString()).getValue());
      }

      cmbValues.addItemListener(saveFeatureListener);
    }
  }
Esempio n. 3
0
  private int attachToQueryPlan() {
    if (_aggOps.isEmpty()) {
      ProjectionOperator project = new ProjectionOperator(_selectExpr);
      _affectedComponent.setProjection(project);
      return NON_AGG;
    } else if (_aggOps.size() == 1) {
      // all the others are group by
      AggregateOperator firstAgg = _aggOps.get(0);

      if (ParserUtil.isAllColumnRefs(_selectExpr)) {
        // plain fields in select
        List<Integer> groupByColumns = ParserUtil.extractColumnIndexes(_selectExpr);
        firstAgg.setGroupByColumns(groupByColumns);

        // Setting new level of components is necessary for correctness only for distinct in
        // aggregates
        //  but it's certainly pleasant to have the final result grouped on nodes by group by
        // columns.
        boolean newLevel = !(HierarchyExtractor.isHashedBy(_affectedComponent, groupByColumns));
        if (newLevel) {
          _affectedComponent.setHashIndexes(groupByColumns);
          OperatorComponent newComponent =
              new OperatorComponent(
                      _affectedComponent, ParserUtil.generateUniqueName("OPERATOR"), _queryPlan)
                  .setAggregation(firstAgg);

          // this now becomes "active component"
          _affectedComponent = newComponent;
        } else {
          _affectedComponent.setAggregation(firstAgg);
        }
      } else {
        // Sometimes selectExpr contains other functions, so we have to use projections instead of
        // simple groupBy
        // Check for complexity
        if (_affectedComponent.getHashExpressions() != null
            && !_affectedComponent.getHashExpressions().isEmpty()) {
          throw new RuntimeException(
              "Too complex: cannot have hashExpression both for joinCondition and groupBy!");
        }

        // WARNING: _selectExpr cannot be used on two places: that's why we do deep copy
        _affectedComponent.setHashExpressions((List<ValueExpression>) DeepCopy.copy(_selectExpr));

        // always new level
        ProjectionOperator groupByProj =
            new ProjectionOperator((List<ValueExpression>) DeepCopy.copy(_selectExpr));
        firstAgg.setGroupByProjection(groupByProj);
        OperatorComponent newComponent =
            new OperatorComponent(
                    _affectedComponent, ParserUtil.generateUniqueName("OPERATOR"), _queryPlan)
                .setAggregation(firstAgg);

        // this now becomes "active component"
        _affectedComponent = newComponent;
      }
      return AGG;
    } else {
      throw new RuntimeException("For now only one aggregate function supported!");
    }
  }