Program: 68110
Project: 68110
Buggy source:
private void setQueryExpression(String expression){
  if (ChartUIConstants.QUERY_VALUE.equals(queryType)) {
    if (!(context.getChartType() instanceof GanttChart) && !context.getDataServiceProvider().checkState(IDataServiceProvider.SHARE_QUERY) && context.getDataServiceProvider().checkState(IDataServiceProvider.HAS_DATA_SET)) {
      if (context.getDataServiceProvider().getDataType(expression) == DataType.DATE_TIME_LITERAL) {
        ChartAdapter.beginIgnoreNotifications();
        if (query.getGrouping() == null) {
          query.setGrouping(DataFactoryImpl.init().createSeriesGrouping());
        }
        SeriesGrouping group=query.getGrouping();
        group.setEnabled(true);
        group.setAggregateExpression("String_Node_Str");
        ChartAdapter.endIgnoreNotifications();
      }
    }
  }
 else   if (ChartUIConstants.QUERY_CATEGORY.equals(queryType)) {
    DataType type=context.getDataServiceProvider().getDataType(expression);
    ChartAdapter.beginIgnoreNotifications();
    if (seriesdefinition.getGrouping() == null) {
      seriesdefinition.setGrouping(DataFactoryImpl.init().createSeriesGrouping());
    }
    seriesdefinition.getGrouping().setGroupType(type);
    if (type == DataType.DATE_TIME_LITERAL) {
      seriesdefinition.getGrouping().setGroupingUnit(GroupingUnitType.YEARS_LITERAL);
    }
    ChartAdapter.endIgnoreNotifications();
  }
 else   if (ChartUIConstants.QUERY_OPTIONAL.equals(queryType)) {
    ChartAdapter.beginIgnoreNotifications();
    if (expression == null || expression.trim().length() == 0) {
      seriesdefinition.eUnset(DataPackage.eINSTANCE.getSeriesDefinition_Sorting());
      if (seriesdefinition.getSortKey() != null) {
        seriesdefinition.getSortKey().setDefinition(null);
      }
    }
 else {
      if (seriesdefinition.getSortKey() != null && seriesdefinition.getSortKey().getDefinition() != null && seriesdefinition.getSortKey().getDefinition().equals(query.getDefinition())) {
        seriesdefinition.getSortKey().setDefinition(expression);
      }
      DataType type=context.getDataServiceProvider().getDataType(expression);
      if (query.getGrouping() == null) {
        query.setGrouping(DataFactoryImpl.init().createSeriesGrouping());
      }
      query.getGrouping().setGroupType(type);
      if (type == DataType.DATE_TIME_LITERAL) {
        query.getGrouping().setGroupingUnit(GroupingUnitType.YEARS_LITERAL);
      }
    }
    ChartAdapter.endIgnoreNotifications();
  }
  if (query != null) {
    query.setDefinition(expression);
  }
 else {
    query=QueryImpl.create(expression);
    query.eAdapters().addAll(seriesdefinition.eAdapters());
    seriesdefinition.setQuery(query);
  }
}

Fixed version (ground truth):
private void setQueryExpression(String expression){
  if (ChartUIConstants.QUERY_VALUE.equals(queryType)) {
    if (!(context.getChartType() instanceof GanttChart) && !context.getDataServiceProvider().checkState(IDataServiceProvider.SHARE_QUERY) && context.getDataServiceProvider().checkState(IDataServiceProvider.HAS_DATA_SET)) {
      if (context.getDataServiceProvider().getDataType(expression) == DataType.DATE_TIME_LITERAL) {
        ChartAdapter.beginIgnoreNotifications();
        if (query.getGrouping() == null) {
          query.setGrouping(DataFactoryImpl.init().createSeriesGrouping());
        }
        SeriesGrouping group=query.getGrouping();
        group.setEnabled(true);
        group.setAggregateExpression("String_Node_Str");
        ChartAdapter.endIgnoreNotifications();
      }
    }
  }
 else   if (ChartUIConstants.QUERY_CATEGORY.equals(queryType)) {
    DataType type=context.getDataServiceProvider().getDataType(expression);
    ChartAdapter.beginIgnoreNotifications();
    if (seriesdefinition.getGrouping() == null) {
      seriesdefinition.setGrouping(DataFactoryImpl.init().createSeriesGrouping());
    }
    seriesdefinition.getGrouping().setGroupType(type);
    if (type == DataType.DATE_TIME_LITERAL) {
      seriesdefinition.getGrouping().setGroupingUnit(GroupingUnitType.YEARS_LITERAL);
    }
    if (ChartUIUtil.hasLimitOnCategorySortKey(context) && ChartUtil.hasSorting(seriesdefinition)) {
      Query sortQuery=seriesdefinition.getSortKey();
      if (sortQuery == null) {
        sortQuery=QueryImpl.create(expression);
        sortQuery.eAdapters().addAll(seriesdefinition.eAdapters());
        seriesdefinition.setSortKey(sortQuery);
      }
 else {
        sortQuery.setDefinition(expression);
      }
    }
    ChartAdapter.endIgnoreNotifications();
  }
 else   if (ChartUIConstants.QUERY_OPTIONAL.equals(queryType)) {
    ChartAdapter.beginIgnoreNotifications();
    if (expression == null || expression.trim().length() == 0) {
      seriesdefinition.eUnset(DataPackage.eINSTANCE.getSeriesDefinition_Sorting());
      if (seriesdefinition.getSortKey() != null) {
        seriesdefinition.getSortKey().setDefinition(null);
      }
    }
 else {
      if (seriesdefinition.getSortKey() != null && seriesdefinition.getSortKey().getDefinition() != null && seriesdefinition.getSortKey().getDefinition().equals(query.getDefinition())) {
        seriesdefinition.getSortKey().setDefinition(expression);
      }
      DataType type=context.getDataServiceProvider().getDataType(expression);
      if (query.getGrouping() == null) {
        query.setGrouping(DataFactoryImpl.init().createSeriesGrouping());
      }
      query.getGrouping().setGroupType(type);
      if (type == DataType.DATE_TIME_LITERAL) {
        query.getGrouping().setGroupingUnit(GroupingUnitType.YEARS_LITERAL);
      }
    }
    ChartAdapter.endIgnoreNotifications();
  }
  if (query != null) {
    query.setDefinition(expression);
  }
 else {
    query=QueryImpl.create(expression);
    query.eAdapters().addAll(seriesdefinition.eAdapters());
    seriesdefinition.setQuery(query);
  }
}