Program: 68322
Project: 68322
Buggy source:
private void setQueryExpression(String expression,boolean isSharing){
  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());
      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) {
    if (isSharing) {
      query.setDefinition(expression);
    }
 else {
      query.setDefinition(btnBuilder.getExpression());
    }
  }
 else {
    query=QueryImpl.create(expression);
    query.eAdapters().addAll(seriesdefinition.eAdapters());
    seriesdefinition.setQuery(query);
  }
}

Fixed version (ground truth):
private void setQueryExpression(String expression,boolean isSharing){
  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) {
    if (isSharing) {
      query.setDefinition(expression);
    }
 else {
      query.setDefinition(btnBuilder.getExpression());
    }
  }
 else {
    query=QueryImpl.create(expression);
    query.eAdapters().addAll(seriesdefinition.eAdapters());
    seriesdefinition.setQuery(query);
  }
}