Program: 138241
Project: 138241
Buggy source:
@Override public void addDependencies(ModelElement element){
  Analysis analysis=(Analysis)element;
  List<IndicatorDefinition> udis=AnalysisHelper.getUserDefinedIndicators(analysis);
  try {
    for (    IndicatorDefinition udi : udis) {
      if (udi == null) {
        continue;
      }
      InternalEObject iudi=(InternalEObject)udi;
      if (!iudi.eIsProxy()) {
        TypedReturnCode<Dependency> dependencyReturn=DependenciesHandler.getInstance().setDependencyOn(analysis,udi);
        if (dependencyReturn.isOk()) {
          Property property=PropertyHelper.getProperty(udi);
          if (property != null) {
            TDQItem udiItem=(TDQItem)property.getItem();
            if (udiItem instanceof TDQIndicatorDefinitionItem) {
              ((TDQIndicatorDefinitionItem)udiItem).setIndicatorDefinition(udi);
            }
 else             if (udiItem instanceof TDQBusinessRuleItem) {
              ((TDQBusinessRuleItem)udiItem).setDqrule((DQRule)udi);
            }
          }
          ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider().getResourceManager().saveResource(udi.eResource());
        }
      }
    }
    List<Pattern> patterns=AnalysisHelper.getPatterns(analysis);
    for (    Pattern pattern : patterns) {
      InternalEObject iptn=(InternalEObject)pattern;
      if (!iptn.eIsProxy()) {
        TypedReturnCode<Dependency> dependencyReturn=DependenciesHandler.getInstance().setDependencyOn(analysis,pattern);
        if (dependencyReturn.isOk()) {
          Property property=PropertyHelper.getProperty(pattern);
          if (property != null) {
            TDQPatternItem patternItem=(TDQPatternItem)property.getItem();
            patternItem.setPattern(pattern);
          }
          ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider().getResourceManager().saveResource(pattern.eResource());
        }
      }
    }
  }
 catch (  PersistenceException e) {
    log.error(e,e);
  }
}

Fixed version (ground truth):
@Override public void addDependencies(ModelElement element){
  Analysis analysis=(Analysis)element;
  List<IndicatorDefinition> udis=AnalysisHelper.getUserDefinedIndicators(analysis);
  try {
    for (    IndicatorDefinition udi : udis) {
      if (udi == null) {
        continue;
      }
      InternalEObject iudi=(InternalEObject)udi;
      if (!iudi.eIsProxy()) {
        TypedReturnCode<Dependency> dependencyReturn=DependenciesHandler.getInstance().setDependencyOn(analysis,udi);
        if (dependencyReturn.isOk()) {
          Property property=PropertyHelper.getProperty(udi);
          if (property != null) {
            TDQItem udiItem=(TDQItem)property.getItem();
            if (udiItem instanceof TDQIndicatorDefinitionItem) {
              ((TDQIndicatorDefinitionItem)udiItem).setIndicatorDefinition(udi);
            }
 else             if (udiItem instanceof TDQBusinessRuleItem) {
              ((TDQBusinessRuleItem)udiItem).setDqrule((DQRule)udi);
            }
          }
          ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider().getResourceManager().saveResource(udi.eResource());
        }
      }
    }
    List<Pattern> patterns=AnalysisHelper.getPatterns(analysis);
    for (    Pattern pattern : patterns) {
      InternalEObject iptn=(InternalEObject)pattern;
      if (!iptn.eIsProxy()) {
        TypedReturnCode<Dependency> dependencyReturn=DependenciesHandler.getInstance().setDependencyOn(analysis,pattern);
        if (dependencyReturn.isOk()) {
          Property property=PropertyHelper.getProperty(pattern);
          if (property != null && property.getItem() instanceof TDQPatternItem) {
            TDQPatternItem patternItem=(TDQPatternItem)property.getItem();
            patternItem.setPattern(pattern);
          }
          ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider().getResourceManager().saveResource(pattern.eResource());
        }
      }
    }
  }
 catch (  PersistenceException e) {
    log.error(e,e);
  }
}