예제 #1
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());
          }
        }
      }
    }
  }
예제 #2
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);
      }
    }
  }