Program: 138391
Project: 138391
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()) {
          RepositoryNode repositoryNode=RepositoryNodeHelper.recursiveFind(udi);
          if (repositoryNode != null) {
            TDQItem udiItem=(TDQItem)repositoryNode.getObject().getProperty().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()) {
          RepositoryNode repositoryNode=RepositoryNodeHelper.recursiveFind(pattern);
          if (repositoryNode != null) {
            TDQPatternItem patternItem=(TDQPatternItem)repositoryNode.getObject().getProperty().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) {
            TDQPatternItem patternItem=(TDQPatternItem)property.getItem();
            patternItem.setPattern(pattern);
          }
          ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider().getResourceManager().saveResource(pattern.eResource());
        }
      }
    }
  }
 catch (  PersistenceException e) {
    log.error(e,e);
  }
}