protected DynamicValuesQuery updateDynamicValueQuery(
      DataSetHandle setHandle,
      Object valueColumn,
      Object labelColumn,
      DataSetDesign dataSetDesign,
      boolean isEnabled) {
    DynamicValuesQuery valueQuery = null;

    if (setHandle instanceof OdaDataSetHandle && valueColumn != null) {
      valueQuery = designFactory.createDynamicValuesQuery();

      if (dataSetDesign != null) {
        DataSetDesign targetDataSetDesign = (DataSetDesign) EcoreUtil.copy(dataSetDesign);
        if (!setHandle.getName().equals(dataSetDesign.getName()))
          targetDataSetDesign =
              new ModelOdaAdapter().createDataSetDesign((OdaDataSetHandle) setHandle);
        valueQuery.setDataSetDesign(targetDataSetDesign);
      } else {
        DataSetDesign targetDataSetDesign =
            new ModelOdaAdapter().createDataSetDesign((OdaDataSetHandle) setHandle);
        valueQuery.setDataSetDesign(targetDataSetDesign);
      }
      valueQuery.setDisplayNameColumn(AdapterUtil.extractColumnName(labelColumn));
      valueQuery.setValueColumn(AdapterUtil.extractColumnName(valueColumn));
      valueQuery.setEnabled(isEnabled);
    }

    return valueQuery;
  }
예제 #2
0
  /**
   * reset the property binding in dataset.
   *
   * @param dsHandle
   * @param dataSetMap
   * @param dataSourceMap
   * @throws SemanticException
   */
  public static void resetPropertyBinding(DataSetHandle dsHandle, Map dataSetMap, Map dataSourceMap)
      throws SemanticException {
    if (dsHandle == null) {
      return;
    }
    if (dsHandle.getExtends() != null) {
      return;
    }
    if (dsHandle instanceof JointDataSetHandle) {
      Iterator iter = ((JointDataSetHandle) dsHandle).dataSetsIterator();
      while (iter.hasNext()) {
        DataSetHandle ds = (DataSetHandle) iter.next();
        if (dsHandle != null) {
          resetPropertyBinding(ds, dataSetMap, dataSourceMap);
        }
      }
    } else if (dsHandle instanceof DerivedDataSetHandle) {
      List<DataSetHandle> dataSets = ((DerivedDataSetHandle) dsHandle).getInputDataSets();
      if (dataSets != null && dataSets.size() != 0) {
        for (int i = 0; i < dataSets.size(); i++) {
          DataSetHandle ds = dataSets.get(i);
          if (dsHandle != null) {
            resetPropertyBinding(ds, dataSetMap, dataSourceMap);
          }
        }
      }
    } else {
      if (dsHandle instanceof OdaDataSetHandle) {
        if (dataSetMap.get(dsHandle.getName()) != null) {
          List pList = (List) dataSetMap.get(dsHandle.getName());

          for (int i = 0; i < pList.size(); i++) {
            PropertyBinding binding = (PropertyBinding) pList.get(i);
            dsHandle.setPropertyBinding(binding.getName(), binding.getValue());
          }
        }
        if (dsHandle.getDataSource() != null
            && dataSourceMap.get(dsHandle.getDataSource().getName()) != null) {
          List pList = (List) dataSourceMap.get(dsHandle.getDataSource().getName());
          for (int i = 0; i < pList.size(); i++) {
            PropertyBinding binding = (PropertyBinding) pList.get(i);
            dsHandle.getDataSource().setPropertyBinding(binding.getName(), binding.getValue());
          }
        }
      }
    }
  }
예제 #3
0
  /**
   * clear the property binding in dataset to disable it when run the query
   *
   * @param dsHandle
   * @param dataSetMap
   * @param dataSourceMap
   * @throws SemanticException
   */
  public static void clearPropertyBindingMap(
      DataSetHandle dsHandle, Map dataSetMap, Map dataSourceMap) throws SemanticException {
    if (dsHandle == null) {
      return;
    }
    if (dsHandle.getExtends() != null) {
      return;
    }
    if (dsHandle instanceof JointDataSetHandle) {
      Iterator iter = ((JointDataSetHandle) dsHandle).dataSetsIterator();
      while (iter.hasNext()) {
        DataSetHandle ds = (DataSetHandle) iter.next();
        if (dsHandle != null) {
          clearPropertyBindingMap(ds, dataSetMap, dataSourceMap);
        }
      }
    } else if (dsHandle instanceof DerivedDataSetHandle) {
      List<DataSetHandle> dataSets = ((DerivedDataSetHandle) dsHandle).getInputDataSets();
      if (dataSets != null && dataSets.size() != 0) {
        for (int i = 0; i < dataSets.size(); i++) {
          DataSetHandle ds = dataSets.get(i);
          if (dsHandle != null) {
            clearPropertyBindingMap(ds, dataSetMap, dataSourceMap);
          }
        }
      }
    } else if (dsHandle instanceof OdaDataSetHandle) {
      List dataSetBindingList = dsHandle.getPropertyBindings();
      List dataSourceBindingList =
          dsHandle.getDataSource() == null
              ? new ArrayList()
              : dsHandle.getDataSource().getPropertyBindings();

      if (!dataSetBindingList.isEmpty()) dataSetMap.put(dsHandle.getName(), dataSetBindingList);
      if (!dataSourceBindingList.isEmpty())
        dataSourceMap.put(dsHandle.getDataSource().getName(), dataSourceBindingList);

      for (int i = 0; i < dataSetBindingList.size(); i++) {
        PropertyBinding binding = (PropertyBinding) dataSetBindingList.get(i);
        dsHandle.setPropertyBinding(binding.getName(), (Expression) null);
      }
      for (int i = 0; i < dataSourceBindingList.size(); i++) {
        PropertyBinding binding = (PropertyBinding) dataSourceBindingList.get(i);
        dsHandle.getDataSource().setPropertyBinding(binding.getName(), (Expression) null);
      }
    }
  }