nus-yam/ex-repair huggingface dataset:
Program: 138524
Project: 138524
Buggy source:
@Override public void openEditor(Item item){
  IndicatorDefinitionItemEditorInput udiEditorInput=new IndicatorDefinitionItemEditorInput(item);
  CorePlugin.getDefault().openEditor(udiEditorInput,IndicatorEditor.class.getName());
}

Fixed version (ground truth):
@Override public void openEditor(Item item){
  TDQIndicatorDefinitionItem indicatorItem=(TDQIndicatorDefinitionItem)item;
  String subfolderPath=indicatorItem.getState().getPath();
  String folderPath=ResourceManager.getIndicatorFolder().getFullPath().toString();
  Path path=new Path(folderPath);
  Path append=(Path)path.append(new Path(subfolderPath)).append(new Path(indicatorItem.getFilename()));
  IPath removeLastSegments=append.removeFirstSegments(1);
  IFile fileEditorInput=ResourceManager.getRootProject().getFile(removeLastSegments);
  try {
    IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(),fileEditorInput,true);
  }
 catch (  PartInitException e) {
    log.error(e,e);
  }
}
Program: 138525
Project: 138525
Buggy source:
@Override public void openEditor(Item item){
  TDQAnalysisItem anaItem=(TDQAnalysisItem)item;
  String folderPath=anaItem.getState().getPath();
  Path path=new Path(folderPath);
  Path append=(Path)path.append(new Path(anaItem.getFilename()));
  IPath removeLastSegments=append.removeFirstSegments(1);
  IFile fileEditorInput=ResourceManager.getRootProject().getFile(removeLastSegments);
  try {
    IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(),fileEditorInput,true);
  }
 catch (  PartInitException e) {
    log.error(e,e);
  }
}

Fixed version (ground truth):
@Override public void openEditor(Item item){
  AnalysisItemEditorInput analysisEditorInput=new AnalysisItemEditorInput(item);
  DBConnectionRepNode connectionRepNode=getParameter().getConnectionRepNode();
  analysisEditorInput.setConnectionNode(connectionRepNode);
  CorePlugin.getDefault().openEditor(analysisEditorInput,AnalysisEditor.class.getName());
}
Program: 138526
Project: 138526
Buggy source:
@Override public boolean handleResourceChange(ModelElement modelElement){
  List<ModelElement> clientDependencys=EObjectHelper.getDependencyClients(modelElement);
  if (clientDependencys.size() > 0) {
    ModelElement[] dependencyElements=clientDependencys.toArray(new ModelElement[clientDependencys.size()]);
    DeleteModelElementConfirmDialog.showDialog(null,PropertyHelper.getItemFile(PropertyHelper.getProperty(modelElement)),dependencyElements,DefaultMessagesImpl.getString("String_Node_Str"));
    return false;
  }
  return super.handleResourceChange(modelElement);
}

Fixed version (ground truth):
@Override public boolean handleResourceChange(ModelElement modelElement){
  final ModelElement modelElementFinal=modelElement;
  List<ModelElement> clientDependencys=EObjectHelper.getDependencyClients(modelElement);
  if (clientDependencys.size() > 0) {
    final ModelElement[] dependencyElements=clientDependencys.toArray(new ModelElement[clientDependencys.size()]);
    Display.getDefault().asyncExec(new Runnable(){
      public void run(){
        DeleteModelElementConfirmDialog.showDialog(null,PropertyHelper.getItemFile(PropertyHelper.getProperty(modelElementFinal)),dependencyElements,DefaultMessagesImpl.getString("String_Node_Str"));
      }
    }
);
    return false;
  }
  return super.handleResourceChange(modelElement);
}
Program: 138527
Project: 138527
Buggy source:
@Override public void run(){
  boolean haveDependencies=false;
  ISelection selection=this.getSelection();
  for (  Object obj : ((IStructuredSelection)selection).toArray()) {
    if (obj instanceof RepositoryNode) {
      RepositoryNode node=(RepositoryNode)obj;
      List<ModelElement> dependencies=EObjectHelper.getDependencyClients(node);
      if (dependencies != null && !dependencies.isEmpty()) {
        haveDependencies=true;
        ModelElement modEle=RepositoryNodeHelper.getMetadataElement(node);
        showDependenciesDialog(modEle,dependencies);
        break;
      }
    }
  }
  if (haveDependencies) {
    return;
  }
  super.run();
  CorePlugin.getDefault().refreshDQView();
  CorePlugin.getDefault().refreshWorkSpace();
}

Fixed version (ground truth):
@Override public void run(){
  boolean haveDependencies=false;
  ISelection selection=this.getSelection();
  for (  Object obj : ((IStructuredSelection)selection).toArray()) {
    if (obj instanceof RepositoryNode) {
      RepositoryNode node=(RepositoryNode)obj;
      List<ModelElement> dependencies=EObjectHelper.getDependencyClients(node);
      if (dependencies != null && !dependencies.isEmpty()) {
        haveDependencies=true;
        ModelElement modEle=RepositoryNodeHelper.getModelElementFromRepositoryNode(node);
        showDependenciesDialog(modEle,dependencies);
        break;
      }
    }
  }
  if (haveDependencies) {
    return;
  }
  super.run();
  CorePlugin.getDefault().refreshDQView();
  CorePlugin.getDefault().refreshWorkSpace();
}
Program: 138528
Project: 138528
Buggy source:
@Override public List<IRepositoryNode> getChildren(){
  anaElement=new ArrayList<IRepositoryNode>();
  IRepositoryViewObject reportViewObject=this.getObject();
  if (reportViewObject == null) {
    ReportRepNode parent=(ReportRepNode)this.getParent();
    TDQReportItem reportItem=(TDQReportItem)parent.getObject().getProperty().getItem();
    TdReport report=(TdReport)reportItem.getReport();
    if (this.getProperties(EProperties.LABEL).equals(parent.ANA_FLODER)) {
      for (      AnalysisMap analysisMap : analysisMaps) {
        Analysis analysis=analysisMap.getAnalysis();
        RepositoryNode recursiveFind=RepositoryNodeHelper.recursiveFind(analysis);
        IRepositoryViewObject viewObject=recursiveFind.getObject();
        AnalysisRepNode anaNode=new AnalysisRepNode(viewObject,this,ENodeType.REPOSITORY_ELEMENT);
        anaNode.setProperties(EProperties.LABEL,ERepositoryObjectType.TDQ_ANALYSIS_ELEMENT);
        anaNode.setProperties(EProperties.CONTENT_TYPE,ERepositoryObjectType.TDQ_ANALYSIS_ELEMENT);
        viewObject.setRepositoryNode(anaNode);
        anaElement.add(anaNode);
      }
    }
 else {
      EList<Document> documents=report.getDocument();
      for (      Document document : documents) {
      }
    }
    return anaElement;
  }
  return super.getChildren();
}

Fixed version (ground truth):
@Override public List<IRepositoryNode> getChildren(){
  anaElement=new ArrayList<IRepositoryNode>();
  IRepositoryViewObject reportViewObject=this.getObject();
  if (reportViewObject == null) {
    ReportRepNode parent=(ReportRepNode)this.getParent();
    TDQReportItem reportItem=(TDQReportItem)parent.getObject().getProperty().getItem();
    TdReport report=(TdReport)reportItem.getReport();
    if (this.getProperties(EProperties.LABEL).equals(parent.ANA_FLODER)) {
      for (      AnalysisMap analysisMap : analysisMaps) {
        Analysis analysis=analysisMap.getAnalysis();
        RepositoryNode recursiveFind=RepositoryNodeHelper.recursiveFind(analysis);
        if (recursiveFind == null) {
          continue;
        }
        IRepositoryViewObject viewObject=recursiveFind.getObject();
        AnalysisRepNode anaNode=new AnalysisRepNode(viewObject,this,ENodeType.REPOSITORY_ELEMENT);
        anaNode.setProperties(EProperties.LABEL,ERepositoryObjectType.TDQ_ANALYSIS_ELEMENT);
        anaNode.setProperties(EProperties.CONTENT_TYPE,ERepositoryObjectType.TDQ_ANALYSIS_ELEMENT);
        viewObject.setRepositoryNode(anaNode);
        anaElement.add(anaNode);
      }
    }
 else {
      EList<Document> documents=report.getDocument();
      for (      Document document : documents) {
      }
    }
    return anaElement;
  }
  return super.getChildren();
}
Program: 138529
Project: 138529
Buggy source:
@Override public void init(IViewSite site,IMemento memento) throws PartInitException {
  super.init(site,memento);
  if (memento == null) {
    setLinkingEnabled(false);
  }
  try {
    addPostWindowCloseListener();
    addResourceChangedListener();
    initToolBar();
    initWorkspace();
  }
 catch (  Exception e) {
    log.error(e,e);
  }
}

Fixed version (ground truth):
@Override public void init(IViewSite site,IMemento memento) throws PartInitException {
  super.init(site,memento);
  if (memento == null) {
    setLinkingEnabled(false);
  }
  try {
    addPostWindowCloseListener();
    initToolBar();
    initWorkspace();
  }
 catch (  Exception e) {
    log.error(e,e);
  }
}
Program: 138530
Project: 138530
Buggy source:
/** 
 * DOC bZhou Comment method "getAvailableComponentExtensions".
 * @param version
 * @param categry
 * @param reload
 * @return
 */
public static List<IEcosComponent> getAvailableComponentExtensions(String version,IEcosCategory categry,boolean reload){
  List<IEcosComponent> extensions=new ArrayList<IEcosComponent>();
  try {
    List<RevisionInfo> revisions=EcosystemService.getRevisionList(categry.getId(),version);
    Map<String,IEcosComponent> extensionsMap=new HashMap<String,IEcosComponent>();
    for (    RevisionInfo revision : revisions) {
      IEcosComponent extension=extensionsMap.get(revision.getExtension_name());
      if (extension == null) {
        extension=new EcosComponent();
        extension.setName(revision.getExtension_name());
        extension.setAuthor(revision.getAuthor_name());
        extension.setCategry(categry);
        extension.setDescription(revision.getExtension_description());
        extensionsMap.put(extension.getName(),extension);
        extensions.add(extension);
      }
      IRevision rev=convertRevision(revision);
      extension.getRevisions().add(rev);
      if (extension.getLatestRevision() == null || extension.getLatestRevision().getDate().before(rev.getDate())) {
        extension.setLatestRevision(rev);
      }
    }
  }
 catch (  Exception e) {
    log.error(e,e);
  }
  return extensions;
}

Fixed version (ground truth):
/** 
 * DOC bZhou Comment method "getAvailableComponentExtensions".
 * @param version
 * @param categry
 * @param reload
 * @return
 */
public static List<IEcosComponent> getAvailableComponentExtensions(String version,IEcosCategory categry,boolean reload){
  List<IEcosComponent> extensions=new ArrayList<IEcosComponent>();
  try {
    List<RevisionInfo> revisions=EcosystemService.getRevisionList(categry.getId(),version);
    Map<String,IEcosComponent> extensionsMap=new HashMap<String,IEcosComponent>();
    for (    RevisionInfo revision : revisions) {
      IEcosComponent extension=extensionsMap.get(revision.getExtensOnName());
      if (extension == null) {
        extension=new EcosComponent();
        extension.setName(revision.getExtensOnName());
        extension.setAuthor(revision.getAuthorName());
        extension.setCategry(categry);
        extension.setDescription(revision.getExtensionDescription());
        extensionsMap.put(extension.getName(),extension);
        extensions.add(extension);
      }
      IRevision rev=convertRevision(revision);
      extension.getRevisions().add(rev);
      if (extension.getLatestRevision() == null || extension.getLatestRevision().getDate().before(rev.getDate())) {
        extension.setLatestRevision(rev);
      }
    }
  }
 catch (  Exception e) {
    log.error(e,e);
  }
  return extensions;
}
Program: 138531
Project: 138531
Buggy source:
/** 
 * Convert the web service returned value to our model object.
 * @param revision The message returned from web service method call.
 * @return
 * @throws ParseException
 */
private static IRevision convertRevision(RevisionInfo revision) throws ParseException {
  IRevision rev=new Revision();
  rev.setDate(formatter.parse(revision.getRevision_date()));
  rev.setName(revision.getRevision_name());
  rev.setUrl(revision.getDownload_url());
  rev.setDescription(revision.getRevision_description());
  rev.setId(revision.getRevision_id());
  rev.setFileName(revision.getFilename());
  return rev;
}

Fixed version (ground truth):
/** 
 * Convert the web service returned value to our model object.
 * @param revision The message returned from web service method call.
 * @return
 * @throws ParseException
 */
private static IRevision convertRevision(RevisionInfo revision) throws ParseException {
  IRevision rev=new Revision();
  rev.setDate(formatter.parse(revision.getRevisionDate()));
  rev.setName(revision.getRevisionName());
  rev.setUrl(revision.getDownloadUrl());
  rev.setDescription(revision.getRevisionDescription());
  rev.setId(revision.getRevisionId());
  rev.setFileName(revision.getFilename());
  return rev;
}
Program: 138532
Project: 138532
Buggy source:
/** 
 * Method "getIndicators".
 * @param column
 * @return the indicators attached to this column
 */
public Collection<Indicator> getIndicators(ModelElement modelElement){
  Collection<Indicator> indics=new ArrayList<Indicator>();
  EList<Indicator> allIndics=analysis.getResults().getIndicators();
  for (  Indicator indicator : allIndics) {
    if (indicator.getAnalyzedElement() != null && indicator.getAnalyzedElement().equals(modelElement)) {
      indics.add(indicator);
    }
  }
  return indics;
}

Fixed version (ground truth):
/** 
 * Method "getIndicators".
 * @param column
 * @return the indicators attached to this column
 */
public Collection<Indicator> getIndicators(ModelElement modelElement){
  Collection<Indicator> indics=new ArrayList<Indicator>();
  EList<Indicator> allIndics=analysis.getResults().getIndicators();
  for (  Indicator indicator : allIndics) {
    if (indicator.getAnalyzedElement() != null && indicator.getAnalyzedElement().equals(modelElement)) {
      initializeIndicator(indicator);
      indics.add(indicator);
    }
  }
  return indics;
}
Program: 138533
Project: 138533
Buggy source:
private void initializeIndicator(Indicator indicator,ModelElement modelElement){
  indicator.setAnalyzedElement(modelElement);
  if (indicator.getIndicatorDefinition() == null) {
    DefinitionHandler.getInstance().setDefaultIndicatorDefinition(indicator);
  }
  if (indicator instanceof CompositeIndicator) {
    for (    Indicator child : ((CompositeIndicator)indicator).getChildIndicators()) {
      initializeIndicator(child,modelElement);
    }
  }
}

Fixed version (ground truth):
/** 
 * zshen Comment method "initializeIndicator".
 * @param indicator
 */
private void initializeIndicator(Indicator indicator){
  if (indicator.getIndicatorDefinition() == null || indicator.getIndicatorDefinition().eIsProxy()) {
    DefinitionHandler.getInstance().setDefaultIndicatorDefinition(indicator);
  }
  if (indicator instanceof CompositeIndicator) {
    for (    Indicator child : ((CompositeIndicator)indicator).getChildIndicators()) {
      initializeIndicator(child);
    }
  }
}
Program: 138534
Project: 138534
Buggy source:
public void clear(){
  for (  Analysis analysis : allAnalysisMap.values()) {
    URI uri=analysis.eResource().getURI();
    EMFSharedResources.getInstance().unloadResource(uri.toString());
  }
  super.clear();
  this.allAnalysisMap.clear();
}

Fixed version (ground truth):
public void clear(){
  super.clear();
  this.allAnalysisMap.clear();
}
Program: 138535
Project: 138535
Buggy source:
/** 
 * DOC rli Comment method "retireAnalysis".
 * @param fileResource
 * @return
 */
public Analysis retireAnalysis(Resource fileResource){
  EList<EObject> contents=fileResource.getContents();
  if (contents.isEmpty()) {
    log.error("String_Node_Str" + fileResource);
  }
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + contents.size());
  }
  AnalysisSwitch<Analysis> mySwitch=new AnalysisSwitch<Analysis>(){
    public Analysis caseAnalysis(    Analysis object){
      return object;
    }
  }
;
  Analysis analysis=null;
  if (contents != null && contents.size() != 0) {
    analysis=mySwitch.doSwitch(contents.get(0));
  }
  return analysis;
}

Fixed version (ground truth):
/** 
 * DOC rli Comment method "retireAnalysis".
 * @param fileResource
 * @return
 */
public Analysis retireAnalysis(Resource fileResource){
  EList<EObject> contents=fileResource.getContents();
  if (contents.isEmpty()) {
    log.error("String_Node_Str" + fileResource);
  }
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + contents.size());
  }
  AnalysisSwitch<Analysis> mySwitch=new AnalysisSwitch<Analysis>(){
    public Analysis caseAnalysis(    Analysis object){
      return object;
    }
  }
;
  Analysis analysis=null;
  if (contents != null) {
    Iterator<EObject> iter=contents.iterator();
    while (iter.hasNext()) {
      analysis=mySwitch.doSwitch(iter.next());
      if (analysis != null) {
        break;
      }
    }
  }
  return analysis;
}
Program: 138536
Project: 138536
Buggy source:
public static List<ModelElement> getAll(){
  List<ModelElement> all=new ArrayList<ModelElement>();
  all.addAll(AnaResourceFileHelper.getInstance().getAllAnalysis());
  all.addAll(DQRuleResourceFileHelper.getInstance().getAllDQRules());
  all.addAll(IndicatorResourceFileHelper.getInstance().getAllUDIs());
  all.addAll(PatternResourceFileHelper.getInstance().getAllPatternes());
  all.addAll(PrvResourceFileHelper.getInstance().getAllDataProviders());
  if (!PluginChecker.isOnlyTopLoaded()) {
    all.addAll(RepResourceFileHelper.getInstance().getAllReports());
  }
  return all;
}

Fixed version (ground truth):
public static List<ModelElement> getAll(){
  List<ModelElement> all=new ArrayList<ModelElement>();
  all.addAll(AnaResourceFileHelper.getInstance().getAllAnalysis());
  all.addAll(DQRuleResourceFileHelper.getInstance().getAllDQRules());
  all.addAll(IndicatorResourceFileHelper.getInstance().getAllUDIs());
  all.addAll(IndicatorResourceFileHelper.getInstance().getAllSysIs());
  DefinitionHandler.reload();
  all.addAll(PatternResourceFileHelper.getInstance().getAllPatternes());
  all.addAll(PrvResourceFileHelper.getInstance().getAllDataProviders());
  if (!PluginChecker.isOnlyTopLoaded()) {
    all.addAll(RepResourceFileHelper.getInstance().getAllReports());
  }
  return all;
}
Program: 138538
Project: 138538
Buggy source:
@Override protected boolean doExecute() throws Exception {
  boolean result=true;
  File fileAnalysis=this.getWorkspacePath().append(EResourceConstant.ANALYSIS.getPath()).toFile();
  try {
    String[] anaFileExtentionNames={"String_Node_Str"};
    result=FilesUtils.migrateFolder(fileAnalysis,anaFileExtentionNames,this.getReplaceStringMapMdm(),log);
    AnaResourceFileHelper.getInstance().clear();
    AnaResourceFileHelper.getInstance().getAllAnalysis();
  }
 catch (  Exception e) {
    result=false;
    log.error(e,e);
  }
  return result;
}

Fixed version (ground truth):
@Override protected boolean doExecute() throws Exception {
  boolean result=true;
  File fileAnalysis=this.getWorkspacePath().append(EResourceConstant.ANALYSIS.getPath()).toFile();
  try {
    String[] anaFileExtentionNames={"String_Node_Str"};
    result=FilesUtils.migrateFolder(fileAnalysis,anaFileExtentionNames,this.getReplaceStringMapMdm(),log);
  }
 catch (  Exception e) {
    result=false;
    log.error(e,e);
  }
  return result;
}
Program: 138539
Project: 138539
Buggy source:
/** 
 * delete mig folders.
 * @param basePath
 * @return
 */
private boolean deleteMigFolders(IPath basePath){
  IPath librariesPath=basePath.append(ResourceManager.getLibrariesFolder().getFullPath().makeRelativeTo(ResourceManager.getRootProject().getFullPath()));
  IPath dataProfilingPath=basePath.append(ResourceManager.getDataProfilingFolder().getFullPath().makeRelativeTo(ResourceManager.getRootProject().getFullPath()));
  boolean delete=FilesUtils.removeFolder(new File(librariesPath.toOSString() + MIGRATION_FOLDER_EXT),true);
  boolean delete2=FilesUtils.removeFolder(new File(dataProfilingPath.toOSString() + MIGRATION_FOLDER_EXT),true);
  ResourceService.refreshStructure();
  return delete && delete2;
}

Fixed version (ground truth):
/** 
 * delete mig folders.
 * @param basePath
 * @return
 */
private boolean deleteMigFolders(IPath basePath){
  IPath librariesPath=basePath.append(ResourceManager.getLibrariesFolder().getFullPath().makeRelativeTo(ResourceManager.getRootProject().getFullPath()));
  IPath dataProfilingPath=basePath.append(ResourceManager.getDataProfilingFolder().getFullPath().makeRelativeTo(ResourceManager.getRootProject().getFullPath()));
  File librariesFile=new File(librariesPath.toOSString() + MIGRATION_FOLDER_EXT);
  File dataProfilingFile=new File(dataProfilingPath.toOSString() + MIGRATION_FOLDER_EXT);
  boolean delete=true;
  boolean delete2=true;
  if (librariesFile != null) {
    delete=FilesUtils.removeFolder(librariesFile,true);
  }
  if (dataProfilingFile != null) {
    delete2=FilesUtils.removeFolder(dataProfilingFile,true);
  }
  ResourceService.refreshStructure();
  return delete && delete2;
}
Program: 138540
Project: 138540
Buggy source:
/** 
 * clear the cache of ModelElement.
 * @return
 */
private boolean reloadModelElementCache(){
  try {
    AnaResourceFileHelper.getInstance().clear();
    RepResourceFileHelper.getInstance().clear();
    IndicatorResourceFileHelper.getInstance().clear();
    PatternResourceFileHelper.getInstance().clear();
    DQRuleResourceFileHelper.getInstance().clear();
    ResourceFileMap.getAll();
  }
 catch (  Exception e) {
    log.error(e,e);
    return false;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * clear the cache of ModelElement.
 * @return
 */
private boolean reloadModelElementCache(){
  try {
    AnaResourceFileHelper.getInstance().clear();
    RepResourceFileHelper.getInstance().clear();
    IndicatorResourceFileHelper.getInstance().clear();
    PatternResourceFileHelper.getInstance().clear();
    DQRuleResourceFileHelper.getInstance().clear();
    EMFSharedResources.getInstance().unloadResources();
    ResourceFileMap.getAll();
  }
 catch (  Exception e) {
    log.error(e,e);
    return false;
  }
  return true;
}
Program: 138542
Project: 138542
Buggy source:
private TableIndicatorUnit createIndicatorUnit(IFile fe,IndicatorEnum indicatorEnum,Indicator indicator){
  if (indicator == null) {
    IndicatorsFactory factory=IndicatorsFactory.eINSTANCE;
    indicator=(Indicator)factory.create(indicatorEnum.getIndicatorType());
    indicator.setAnalyzedElement(getColumnSet());
    if (!DefinitionHandler.getInstance().setDefaultIndicatorDefinition(indicator)) {
      log.error(DefaultMessagesImpl.getString("String_Node_Str") + indicator.getName());
    }
  }
  TableIndicatorUnit indicatorUnit=new TableIndicatorUnit(indicatorEnum,indicator,this);
  this.indicatorUnitMap.put(indicatorEnum,indicatorUnit);
  return indicatorUnit;
}

Fixed version (ground truth):
private TableIndicatorUnit createIndicatorUnit(IFile fe,IndicatorEnum indicatorEnum,Indicator indicator){
  if (indicator == null) {
    IndicatorsFactory factory=IndicatorsFactory.eINSTANCE;
    indicator=(Indicator)factory.create(indicatorEnum.getIndicatorType());
    indicator.setAnalyzedElement(getColumnSet());
  }
  if (!DefinitionHandler.getInstance().setDefaultIndicatorDefinition(indicator)) {
    log.error(DefaultMessagesImpl.getString("String_Node_Str") + indicator.getName());
  }
  TableIndicatorUnit indicatorUnit=new TableIndicatorUnit(indicatorEnum,indicator,this);
  this.indicatorUnitMap.put(indicatorEnum,indicatorUnit);
  return indicatorUnit;
}
Program: 138543
Project: 138543
Buggy source:
private void initializeIndicator(Indicator indicator){
  if (indicator.getIndicatorDefinition() == null) {
    DefinitionHandler.getInstance().setDefaultIndicatorDefinition(indicator);
  }
  if (indicator instanceof CompositeIndicator) {
    for (    Indicator child : ((CompositeIndicator)indicator).getChildIndicators()) {
      initializeIndicator(child);
    }
  }
}

Fixed version (ground truth):
private void initializeIndicator(Indicator indicator){
  if (indicator.getIndicatorDefinition() == null || indicator.getIndicatorDefinition().eIsProxy()) {
    DefinitionHandler.getInstance().setDefaultIndicatorDefinition(indicator);
  }
  if (indicator instanceof CompositeIndicator) {
    for (    Indicator child : ((CompositeIndicator)indicator).getChildIndicators()) {
      initializeIndicator(child);
    }
  }
}
Program: 138546
Project: 138546
Buggy source:
/** 
 * Method "getRegexp".
 * @param pattern a pattern
 * @return the body of the regular expression applicable to this dbms or null
 */
public Expression getRegexp(Pattern pattern,boolean isJavaEngin){
  Expression expression=null;
  EList<PatternComponent> components=pattern.getComponents();
  for (  PatternComponent patternComponent : components) {
    if (patternComponent != null) {
      expression=this.getExpression(patternComponent);
      if (expression != null && !(isJavaEngin ^ DbmsLanguageFactory.compareDbmsLanguage(ExecutionLanguage.JAVA.getName(),expression.getLanguage()))) {
        return expression;
      }
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Method "getRegexp".
 * @param pattern a pattern
 * @return the body of the regular expression applicable to this dbms or null
 */
public Expression getRegexp(Pattern pattern,boolean isJavaEngin){
  Expression expression=null;
  EList<PatternComponent> components=pattern.getComponents();
  for (  PatternComponent patternComponent : components) {
    if (patternComponent != null) {
      expression=this.getExpression(patternComponent);
      if (expression != null && (!(isJavaEngin ^ DbmsLanguageFactory.compareDbmsLanguage(ExecutionLanguage.JAVA.getName(),expression.getLanguage())) || DbmsLanguageFactory.compareDbmsLanguage(ExecutionLanguage.SQL.getName(),expression.getLanguage()))) {
        return expression;
      }
    }
  }
  return null;
}
Program: 138547
Project: 138547
Buggy source:
/** 
 * ADD mzhao 15750 , build dq metadata tree, get connection root node.
 */
public static List<IRepositoryNode> getConnectionRepositoryNodes(){
  RepositoryNode node=getRootNode(EResourceConstant.METADATA.getName());
  List<IRepositoryNode> connNodes=new ArrayList<IRepositoryNode>();
  if (node != null) {
    List<IRepositoryNode> childrens=node.getChildren();
    for (    IRepositoryNode subNode : childrens) {
      if (subNode instanceof DBConnectionFolderRepNode || subNode instanceof DFConnectionFolderRepNode) {
        connNodes.addAll(getConnectionFromFolder(subNode));
      }
    }
  }
  return connNodes;
}

Fixed version (ground truth):
/** 
 * ADD mzhao 15750 , build dq metadata tree, get connection root node.
 */
public static List<IRepositoryNode> getConnectionRepositoryNodes(){
  RepositoryNode node=getRootNode(EResourceConstant.METADATA.getName());
  List<IRepositoryNode> connNodes=new ArrayList<IRepositoryNode>();
  if (node != null) {
    List<IRepositoryNode> childrens=node.getChildren();
    for (    IRepositoryNode subNode : childrens) {
      if (subNode instanceof DBConnectionFolderRepNode || subNode instanceof DFConnectionFolderRepNode) {
        connNodes.addAll(getModelElementFromFolder(subNode));
      }
    }
  }
  return connNodes;
}
Program: 138549
Project: 138549
Buggy source:
/** 
 * DOC klliu Comment method "getRootNode".
 * @return
 */
public static RepositoryNode getRootNode(String nodeName){
  RepositoryNode node=null;
  CommonViewer commonViewer=getDQCommonViewer();
  if (commonViewer != null) {
    TreeItem[] items=commonViewer.getTree().getItems();
    for (    TreeItem item : items) {
      String text=item.getText();
      if (text.equals(nodeName)) {
        node=(RepositoryNode)item.getData();
      }
    }
  }
  return node;
}

Fixed version (ground truth):
/** 
 * DOC klliu Comment method "getRootNode".
 * @return
 */
public static RepositoryNode getRootNode(String nodeName){
  RepositoryNode node=null;
  CommonViewer commonViewer=getDQCommonViewer();
  if (commonViewer != null) {
    TreeItem[] items=commonViewer.getTree().getItems();
    for (    TreeItem item : items) {
      String text=item.getText();
      if (text.equals(nodeName)) {
        node=(RepositoryNode)item.getData();
        return node;
      }
    }
  }
  return node;
}
Program: 138550
Project: 138550
Buggy source:
public static List<IRepositoryNode> getDataProfilingRepositoryNodes(){
  RepositoryNode node=getRootNode(EResourceConstant.DATA_PROFILING.getName());
  List<IRepositoryNode> dataProfilingNodes=new ArrayList<IRepositoryNode>();
  if (node != null) {
    List<IRepositoryNode> childrens=node.getChildren();
    for (    IRepositoryNode subNode : childrens) {
      if (subNode instanceof AnalysisFolderRepNode || subNode instanceof ReportFolderRepNode) {
        dataProfilingNodes.addAll(getAnalysisFromFolder(subNode));
      }
    }
  }
  return dataProfilingNodes;
}

Fixed version (ground truth):
public static List<IRepositoryNode> getDataProfilingRepositoryNodes(){
  RepositoryNode node=getRootNode(EResourceConstant.DATA_PROFILING.getName());
  List<IRepositoryNode> dataProfilingNodes=new ArrayList<IRepositoryNode>();
  if (node != null) {
    List<IRepositoryNode> childrens=node.getChildren();
    for (    IRepositoryNode subNode : childrens) {
      if (subNode instanceof AnalysisFolderRepNode || subNode instanceof ReportFolderRepNode) {
        dataProfilingNodes.addAll(getModelElementFromFolder(subNode));
      }
    }
  }
  return dataProfilingNodes;
}
Program: 138551
Project: 138551
Buggy source:
/** 
 * (non-Javadoc)
 * @see org.talend.dq.writer.AElementPersistance#addDependencies(orgomg.cwm.objectmodel.core.ModelElement)
 */
@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()) {
          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()) {
          ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider().getResourceManager().saveResource(pattern.eResource());
        }
      }
    }
  }
 catch (  PersistenceException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
/** 
 * (non-Javadoc)
 * @see org.talend.dq.writer.AElementPersistance#addDependencies(orgomg.cwm.objectmodel.core.ModelElement)
 */
@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()) {
          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()) {
          TDQPatternItem patternItem=(TDQPatternItem)RepositoryNodeHelper.recursiveFind(pattern).getObject().getProperty().getItem();
          patternItem.setPattern(pattern);
          ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider().getResourceManager().saveResource(pattern.eResource());
        }
      }
    }
  }
 catch (  PersistenceException e) {
    e.printStackTrace();
  }
}
Program: 138552
Project: 138552
Buggy source:
public ReturnCode save(Item item){
  return null;
}

Fixed version (ground truth):
public ReturnCode save(Item item){
  ReturnCode rc=new ReturnCode();
  try {
    TDQPatternItem patternItem=(TDQPatternItem)item;
    if (patternItem != null && patternItem.eIsProxy()) {
      patternItem=(TDQPatternItem)EObjectHelper.resolveObject(patternItem);
      patternItem.getProperty().setLabel(patternItem.getPattern().getName());
    }
    Pattern pattern=patternItem.getPattern();
    addDependencies(pattern);
    addResourceContent(pattern.eResource(),pattern);
    patternItem.setPattern(pattern);
    ProxyRepositoryFactory.getInstance().save(patternItem);
  }
 catch (  PersistenceException e) {
    log.error(e,e);
    rc.setOk(Boolean.FALSE);
    rc.setMessage(e.getMessage());
  }
  return rc;
}
Program: 138554
Project: 138554
Buggy source:
private boolean savePattern(){
  if (tempPatternComponents.size() == 0) {
    MessageDialog.openError(null,DefaultMessagesImpl.getString("String_Node_Str"),DefaultMessagesImpl.getString("String_Node_Str",pattern.getName()));
    return false;
  }
  this.pattern.getComponents().clear();
  this.pattern.getComponents().addAll(tempPatternComponents);
  TaggedValueHelper.setValidStatus(true,pattern);
  EList<PatternComponent> components=this.pattern.getComponents();
  List<String> existLanguage=new ArrayList<String>();
  for (int i=0; i < components.size(); i++) {
    RegularExpressionImpl regularExpress=(RegularExpressionImpl)components.get(i);
    String language=regularExpress.getExpression().getLanguage();
    if ((regularExpress.getExpression().getBody() == null) || (!regularExpress.getExpression().getBody().matches("String_Node_Str"))) {
      MessageDialog.openWarning(null,DefaultMessagesImpl.getString("String_Node_Str"),DefaultMessagesImpl.getString("String_Node_Str",language));
      return false;
    }
    if (existLanguage.contains(language)) {
      MessageDialog.openError(null,DefaultMessagesImpl.getString("String_Node_Str"),DefaultMessagesImpl.getString("String_Node_Str",language));
      return false;
    }
 else {
      existLanguage.add(language);
    }
  }
  PatternResourceFileHelper.getInstance().save(pattern);
  return true;
}

Fixed version (ground truth):
private boolean savePattern(){
  if (tempPatternComponents.size() == 0) {
    MessageDialog.openError(null,DefaultMessagesImpl.getString("String_Node_Str"),DefaultMessagesImpl.getString("String_Node_Str",pattern.getName()));
    return false;
  }
  this.pattern.getComponents().clear();
  this.pattern.getComponents().addAll(tempPatternComponents);
  TaggedValueHelper.setValidStatus(true,pattern);
  EList<PatternComponent> components=this.pattern.getComponents();
  List<String> existLanguage=new ArrayList<String>();
  for (int i=0; i < components.size(); i++) {
    RegularExpressionImpl regularExpress=(RegularExpressionImpl)components.get(i);
    String language=regularExpress.getExpression().getLanguage();
    if ((regularExpress.getExpression().getBody() == null) || (!regularExpress.getExpression().getBody().matches("String_Node_Str"))) {
      MessageDialog.openWarning(null,DefaultMessagesImpl.getString("String_Node_Str"),DefaultMessagesImpl.getString("String_Node_Str",language));
      return false;
    }
    if (existLanguage.contains(language)) {
      MessageDialog.openError(null,DefaultMessagesImpl.getString("String_Node_Str"),DefaultMessagesImpl.getString("String_Node_Str",language));
      return false;
    }
 else {
      existLanguage.add(language);
    }
  }
  Item patternItem=((PatternItemEditorInput)this.getEditor().getEditorInput()).getItem();
  ((TDQPatternItem)patternItem).setPattern(this.pattern);
  ElementWriterFactory.getInstance().createPatternWriter().save(patternItem);
  return true;
}
Program: 138556
Project: 138556
Buggy source:
@Override public String getLabel(){
  if (this.getObject() != null) {
    this.getObject().getLabel();
  }
  return super.getLabel();
}

Fixed version (ground truth):
@Override public String getLabel(){
  if (this.getObject() != null) {
    this.getObject().getLabel();
  }
  if (getObjectType() == null) {
    return ERepositoryObjectType.TDQ_FOLDER_NODE.toString();
  }
  return super.getLabel();
}
Program: 138557
Project: 138557
Buggy source:
/** 
 * DOC klliu Comment method "getRootNode".
 * @return
 */
public static RepositoryNode getRootNode(String nodeName){
  RepositoryNode node=null;
  CommonViewer commonViewer=getDQCommonViewer();
  if (commonViewer != null) {
    TreeItem[] items=commonViewer.getTree().getItems();
    for (    TreeItem item : items) {
      String text=item.getText();
      if (text.equals(nodeName)) {
        node=(RepositoryNode)item.getData();
        return node;
      }
    }
  }
  return node;
}

Fixed version (ground truth):
/** 
 * DOC klliu Comment method "getRootNode".
 * @return
 */
public static RepositoryNode getRootNode(String nodeName){
  RepositoryNode node=null;
  CommonViewer commonViewer=getDQCommonViewer();
  if (commonViewer != null) {
    TreeItem[] items=commonViewer.getTree().getItems();
    for (    TreeItem item : items) {
      String text=item.getText();
      if (text.equalsIgnoreCase(nodeName)) {
        node=(RepositoryNode)item.getData();
        return node;
      }
    }
  }
  return node;
}
Program: 138558
Project: 138558
Buggy source:
public void run(){
  setExecuted(AnalysisExecutorSelector.executeAnalysis(getAnalysis(),getMonitor()));
  AnaResourceFileHelper.getInstance().save(getAnalysis());
}

Fixed version (ground truth):
public void run(){
  AnaResourceFileHelper.getInstance().save(getAnalysis());
}
Program: 138559
Project: 138559
Buggy source:
@Override public boolean equals(Object obj){
  if (this == obj) {
    return true;
  }
  if (obj instanceof AbstractItemEditorInput) {
    AbstractItemEditorInput other=(AbstractItemEditorInput)obj;
    return item.getProperty().getLabel().equals(other.item.getProperty().getLabel());
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean equals(Object obj){
  if (this == obj) {
    return true;
  }
  if (obj instanceof AbstractItemEditorInput) {
    AbstractItemEditorInput other=(AbstractItemEditorInput)obj;
    return StringUtils.equals(item.getProperty().getLabel(),other.item.getProperty().getLabel());
  }
  return false;
}
Program: 138561
Project: 138561
Buggy source:
@Override public void addDependencies(ModelElement element){
  TdReport report=(TdReport)element;
  for (  Analysis ana : ReportHelper.getAnalyses(report)) {
    TypedReturnCode<Dependency> dependencyReturn=DependenciesHandler.getInstance().setDependencyOn(report,ana);
    if (dependencyReturn.isOk()) {
      try {
        RepositoryNode repositoryNode=RepositoryNodeHelper.recursiveFind(ana);
        TDQAnalysisItem anaItem=(TDQAnalysisItem)repositoryNode.getObject().getProperty().getItem();
        anaItem.setAnalysis(ana);
        ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider().getResourceManager().saveResource(ana.eResource());
      }
 catch (      PersistenceException e) {
        e.printStackTrace();
      }
    }
  }
}

Fixed version (ground truth):
@Override public void addDependencies(ModelElement element){
  TdReport report=(TdReport)element;
  for (  Analysis ana : ReportHelper.getAnalyses(report)) {
    TypedReturnCode<Dependency> dependencyReturn=DependenciesHandler.getInstance().setDependencyOn(report,ana);
    if (dependencyReturn.isOk()) {
      try {
        RepositoryNode repositoryNode=RepositoryNodeHelper.recursiveFind(ana);
        if (repositoryNode != null) {
          TDQAnalysisItem anaItem=(TDQAnalysisItem)repositoryNode.getObject().getProperty().getItem();
          anaItem.setAnalysis(ana);
        }
        ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider().getResourceManager().saveResource(ana.eResource());
      }
 catch (      PersistenceException e) {
        e.printStackTrace();
      }
    }
  }
}
Program: 138562
Project: 138562
Buggy source:
/** 
 * DOC klliu Comment method "copyFileToFolder".
 * @param inputStream
 * @param fileName
 * @param folder
 * @throws CoreException
 * @throws IOException
 */
private void copyFileToFolder(InputStream inputStream,String fileName,IFolder folder) throws CoreException, IOException {
  if (inputStream == null) {
    return;
  }
  IFile element=folder.getFile(fileName);
  if (!element.exists()) {
    element.create(inputStream,false,null);
    ModelElement modelElement=ModelElementFileFactory.getModelElement(element);
    if (modelElement != null) {
      AElementPersistance writer=ElementWriterFactory.getInstance().create(element.getFileExtension());
      if (writer != null) {
        writer.create(modelElement,folder);
        element.delete(true,null);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * DOC klliu Comment method "copyFileToFolder".
 * @param inputStream
 * @param fileName
 * @param folder
 * @throws CoreException
 * @throws IOException
 */
private void copyFileToFolder(InputStream inputStream,String fileName,IFolder folder,boolean... isImportItem) throws CoreException, IOException {
  if (inputStream == null) {
    return;
  }
  IFile element=folder.getFile(fileName);
  if (!element.exists()) {
    element.create(inputStream,false,null);
    ModelElement modelElement=ModelElementFileFactory.getModelElement(element);
    if (modelElement != null) {
      AElementPersistance writer=ElementWriterFactory.getInstance().create(element.getFileExtension());
      if (writer != null) {
        writer.create(modelElement,folder,isImportItem);
        element.delete(true,null);
      }
    }
  }
}
Program: 138564
Project: 138564
Buggy source:
protected Collection<Analysis> searchAllAnalysis(IFolder folder){
  Collection<Analysis> analyses=new ArrayList<Analysis>();
  try {
    for (    IResource resource : folder.members()) {
      if (resource.getType() == IResource.FOLDER) {
        if (!resource.getName().startsWith("String_Node_Str")) {
          analyses.addAll(searchAllAnalysis(folder.getFolder(resource.getName())));
        }
        continue;
      }
      IFile file=(IFile)resource;
      if (null != file.getFileExtension() && file.getFileExtension().equals(FactoriesUtil.ANA)) {
        URI uri=URI.createPlatformResourceURI(file.getFullPath().toString(),false);
        Resource eResource=EMFSharedResources.getInstance().getResource(uri,true);
        if (!eResource.getContents().isEmpty()) {
          analyses.add((Analysis)eResource.getContents().get(0));
        }
      }
    }
  }
 catch (  Exception e) {
    log.error(e);
  }
  return analyses;
}

Fixed version (ground truth):
protected Collection<Analysis> searchAllAnalysis(IFolder folder){
  Collection<Analysis> analyses=new ArrayList<Analysis>();
  try {
    for (    IResource resource : folder.members()) {
      if (resource.getType() == IResource.FOLDER) {
        if (!resource.getName().startsWith("String_Node_Str")) {
          analyses.addAll(searchAllAnalysis(folder.getFolder(resource.getName())));
        }
        continue;
      }
      IFile file=(IFile)resource;
      if (null != file.getFileExtension() && file.getFileExtension().equals(FactoriesUtil.ANA)) {
        URI uri=URI.createPlatformResourceURI(file.getFullPath().toString(),false);
        Resource eResource=EMFSharedResources.getInstance().getResource(uri,true);
        if (eResource.getContents().size() > 0) {
          analyses.add((Analysis)eResource.getContents().get(0));
        }
 else {
          log.error("String_Node_Str" + eResource);
        }
      }
    }
  }
 catch (  Exception e) {
    log.error(e);
  }
  return analyses;
}
Program: 138566
Project: 138566
Buggy source:
@Override protected boolean doExecute() throws Exception {
  boolean result=true;
  File fileAnalysis=this.getWorkspacePath().append(EResourceConstant.ANALYSIS.getPath()).toFile();
  try {
    String[] anaFileExtentionNames={"String_Node_Str"};
    result=FilesUtils.migrateFolder(fileAnalysis,anaFileExtentionNames,this.getReplaceStringMapMdm(),log);
    AnaResourceFileHelper.getInstance().clear();
  }
 catch (  Exception e) {
    result=false;
    log.error(e,e);
  }
  return result;
}

Fixed version (ground truth):
@Override protected boolean doExecute() throws Exception {
  boolean result=true;
  File fileAnalysis=this.getWorkspacePath().append(EResourceConstant.ANALYSIS.getPath()).toFile();
  try {
    String[] anaFileExtentionNames={"String_Node_Str"};
    result=FilesUtils.migrateFolder(fileAnalysis,anaFileExtentionNames,this.getReplaceStringMapMdm(),log);
    AnaResourceFileHelper.getInstance().clear();
    AnaResourceFileHelper.getInstance().getAllAnalysis();
  }
 catch (  Exception e) {
    result=false;
    log.error(e,e);
  }
  return result;
}
Program: 138567
Project: 138567
Buggy source:
public Date getOrder(){
  return createDate(2010,9,28);
}

Fixed version (ground truth):
public Date getOrder(){
  return createDate(2010,8,15);
}
Program: 138568
Project: 138568
Buggy source:
@Override protected boolean doExecute() throws Exception {
  boolean ok=true;
  DQStructureManager manager=DQStructureManager.getInstance();
  IFolder systemIndicatorFolder=ResourceManager.getSystemIndicatorFolder();
  if (!systemIndicatorFolder.exists()) {
    systemIndicatorFolder=manager.createNewFolder(ResourceManager.getIndicatorFolder(),EResourceConstant.SYSTEM_INDICATORS);
  }
  manager.copyFilesToFolder(CorePlugin.getDefault(),DQStructureManager.SYSTEM_INDICATOR_PATH,true,systemIndicatorFolder,null);
  DefinitionHandler.getInstance().reloadIndicatorsDefinitions();
  Collection<Analysis> analyses=searchAllAnalysis(ResourceManager.getAnalysisFolder());
  AnalysisWriter analysisWriter=ElementWriterFactory.getInstance().createAnalysisWrite();
  for (  Analysis ana : analyses) {
    try {
      for (      Indicator ind : ana.getResults().getIndicators()) {
        updateIndDefinition(ind);
        if (ind instanceof CompositeIndicator) {
          for (          Indicator indLeave : IndicatorHelper.getIndicatorLeaves(ind)) {
            updateIndDefinition(indLeave);
          }
        }
      }
      analysisWriter.save(ana);
    }
 catch (    Exception e) {
      log.warn(e,e);
      ok=false;
    }
  }
  ResourceManager.getLibrariesFolder().getFile(DefinitionHandler.FILENAME).delete(true,new NullProgressMonitor());
  DefinitionHandler.getInstance().copyDefinitionsIntoFolder(ResourceManager.getLibrariesFolder());
  return ok;
}

Fixed version (ground truth):
@Override protected boolean doExecute() throws Exception {
  boolean ok=true;
  DQStructureManager manager=DQStructureManager.getInstance();
  IFolder systemIndicatorFolder=ResourceManager.getSystemIndicatorFolder();
  if (!systemIndicatorFolder.exists()) {
    systemIndicatorFolder=manager.createNewFolder(ResourceManager.getIndicatorFolder(),EResourceConstant.SYSTEM_INDICATORS);
  }
  manager.copyFilesToFolder(CorePlugin.getDefault(),DQStructureManager.SYSTEM_INDICATOR_PATH,true,systemIndicatorFolder,null,true);
  DefinitionHandler.getInstance().reloadIndicatorsDefinitions();
  Collection<Analysis> analyses=searchAllAnalysis(ResourceManager.getAnalysisFolder());
  AnalysisWriter analysisWriter=ElementWriterFactory.getInstance().createAnalysisWrite();
  for (  Analysis ana : analyses) {
    try {
      for (      Indicator ind : ana.getResults().getIndicators()) {
        updateIndDefinition(ind);
        if (ind instanceof CompositeIndicator) {
          for (          Indicator indLeave : IndicatorHelper.getIndicatorLeaves(ind)) {
            updateIndDefinition(indLeave);
          }
        }
      }
      analysisWriter.save(ana);
    }
 catch (    Exception e) {
      log.warn(e,e);
      ok=false;
    }
  }
  ResourceManager.getLibrariesFolder().getFile(DefinitionHandler.FILENAME).delete(true,new NullProgressMonitor());
  DefinitionHandler.getInstance().copyDefinitionsIntoFolder(ResourceManager.getLibrariesFolder());
  return ok;
}