nus-yam/ex-repair huggingface dataset:
Program: 102161
Project: 102161
Buggy source:
/** 
 * {@inheritDoc}
 * @see org.teiid.designer.ui.common.table.ResourceEditingSupport#setElementValue(java.lang.Object,java.lang.String)
 */
@Override protected void setElementValue(Object element,String newValue){
  if (newValue == null) {
    newValue="String_Node_Str";
  }
  ((VdbSource)element).setJndiName(newValue);
  refreshModelDetails();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 * @see org.teiid.designer.ui.common.table.ResourceEditingSupport#setElementValue(java.lang.Object,java.lang.String)
 */
@Override protected void setElementValue(Object element,String newValue){
  if (newValue == null) {
    newValue="String_Node_Str";
  }
  ((VdbSource)element).setJndiName(newValue);
  refreshModelDetails();
  bindingsViewer.setSelection(new StructuredSelection(element));
}
Program: 102162
Project: 102162
Buggy source:
/** 
 * @param name
 * @param jndiName
 * @param translatorName
 * @return true if new VdbSource added
 */
public boolean add(String name,String jndiName,String translatorName){
  if (this.sources.get(name) == null) {
    this.sources.put(name,new VdbSource(getVdb(),name,jndiName,translatorName));
    getVdb().setModified(this,MODEL_SOURCES,null,this.sources.get(name));
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * @param name
 * @param jndiName
 * @param translatorName
 * @return true if new VdbSource added
 */
public boolean add(String name,String jndiName,String translatorName){
  if (getSource(name) == null) {
    VdbSource vdbSource=new VdbSource(getVdb(),name,jndiName,translatorName);
    this.sources.add(vdbSource);
    getVdb().setModified(this,MODEL_SOURCES,null,vdbSource);
    return true;
  }
  return false;
}
Program: 102163
Project: 102163
Buggy source:
/** 
 * @param source
 * @return true if new VdbSource removed
 */
public boolean removeSource(VdbSource source){
  CoreArgCheck.isNotNull(source,"String_Node_Str");
  if (this.sources.get(source.getName()) != null) {
    this.sources.remove(source.getName());
    getVdb().setModified(this,MODEL_SOURCES,source,null);
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * @param source
 * @return true if new VdbSource removed
 */
public boolean removeSource(VdbSource source){
  CoreArgCheck.isNotNull(source,"String_Node_Str");
  Iterator iter=this.sources.iterator();
  while (iter.hasNext()) {
    VdbSource theSource=(VdbSource)iter.next();
    if (theSource.getName().equalsIgnoreCase(source.getName())) {
      iter.remove();
      getVdb().setModified(this,MODEL_SOURCES,theSource,null);
      return true;
    }
  }
  return false;
}
Program: 102164
Project: 102164
Buggy source:
/** 
 * @return the sources
 */
public Collection<VdbSource> getSources(){
  return this.sources.values();
}

Fixed version (ground truth):
/** 
 * @return the sources
 */
public Collection<VdbSource> getSources(){
  return this.sources;
}
Program: 102165
Project: 102165
Buggy source:
/** 
 * @param index the source array index
 * @return the VdbSource instance if it exists in the sources map
 */
public VdbSource getSource(int index){
  if (sources.isEmpty()) {
    add(DEFAULT_SOURCE_NAME,null,null);
  }
  if (index < sources.size()) {
    for (int i=0; i < sources.size(); i++) {
      VdbSource source=sources.values().iterator().next();
      if (i == index)       return source;
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * @param index the source array index
 * @return the VdbSource instance if it exists in the sources map
 */
public VdbSource getSource(int index){
  if (sources.isEmpty()) {
    add(DEFAULT_SOURCE_NAME,null,null);
  }
  if (index >= 0 && index < sources.size()) {
    VdbSource source=sources.get(index);
    return source;
  }
  return null;
}
Program: 102166
Project: 102166
Buggy source:
/** 
 * @param vdb
 * @param sources
 */
public VdbSourceInfo(final Vdb vdb,final Collection<SourceElement> sources){
  this(vdb);
  for (  SourceElement element : sources) {
    sources.add(element);
  }
}

Fixed version (ground truth):
/** 
 * @param vdb 
 */
public VdbSourceInfo(final Vdb vdb){
  super();
  this.vdb=vdb;
  this.sources=new ArrayList<VdbSource>();
}
Program: 102167
Project: 102167
Buggy source:
/** 
 * @return dataFile the teiid-formatted data <code>File</code>
 */
public File getDataFile(){
  return this.dataFile;
}

Fixed version (ground truth):
/** 
 * @return dataFile the teiid-formatted data <code>File</code>
 */
@Override public File getDataFile(){
  return this.dataFile;
}
Program: 102168
Project: 102168
Buggy source:
public String getModelNameWithoutExtension(String fullModelName){
  String modelName=fullModelName;
  if (modelName.toUpperCase().endsWith("String_Node_Str")) {
    modelName=modelName.substring(0,modelName.length() - 4);
  }
  return modelName;
}

Fixed version (ground truth):
public String getModelNameWithoutExtension(String fullModelName){
  IPath filePath=new Path(fullModelName);
  String modelName=filePath.removeFileExtension().lastSegment();
  return modelName;
}
Program: 102169
Project: 102169
Buggy source:
private void initialize(){
  setStatus(Status.OK_STATUS);
  this.cachedFirstLines=new String[0];
  this.columnInfoList=new ArrayList<ITeiidColumnInfo>();
  String fileName=getDataFile().getName();
  if (fileName.toLowerCase().endsWith("String_Node_Str")) {
    fileName=fileName.substring(0,fileName.length() - 4);
  }
  setViewTableName(fileName + "String_Node_Str");
}

Fixed version (ground truth):
private void initialize(){
  setStatus(Status.OK_STATUS);
  this.cachedFirstLines=new String[0];
  this.columnInfoList=new ArrayList<ITeiidColumnInfo>();
  IPath filePath=new Path(getDataFile().getName());
  String fileName=filePath.removeFileExtension().lastSegment();
  setViewTableName(fileName + "String_Node_Str");
}
Program: 102170
Project: 102170
Buggy source:
/** 
 */
private void initControls(){
  IConnectionProfile profile=getConnectionProfile();
  Properties props=profile.getBaseProperties();
  String url=props.getProperty(IWSProfileConstants.WSDL_URI_PROP_ID);
  if (null != url) {
    urlText.setText(url);
  }
  String securityType=props.getProperty(ICredentialsCommon.SECURITY_TYPE_ID);
  if (null != securityType) {
    credentialsComposite.setSecurityOption(securityType);
  }
  String username=props.getProperty(ICredentialsCommon.USERNAME_PROP_ID);
  if (null != username) {
    credentialsComposite.setUserName(username);
  }
  String password=props.getProperty(ICredentialsCommon.PASSWORD_PROP_ID);
  if (null != password) {
    credentialsComposite.setPassword(password);
  }
  String endPoint=ConnectionInfoHelper.readEndPointProperty(props);
  if (null != endPoint) {
    endPointText.setText(endPoint);
  }
}

Fixed version (ground truth):
/** 
 */
private void initControls(){
  IConnectionProfile profile=getConnectionProfile();
  Properties props=profile.getBaseProperties();
  String url=props.getProperty(IWSProfileConstants.WSDL_URI_PROP_ID);
  if (null != url) {
    urlText.setText(url);
  }
  String securityType=props.getProperty(ICredentialsCommon.SECURITY_TYPE_ID);
  if (null != securityType) {
    credentialsComposite.setSecurityOption(securityType);
  }
  String username=props.getProperty(ICredentialsCommon.USERNAME_PROP_ID);
  if (null != username) {
    credentialsComposite.setUserName(username);
  }
  String password=props.getProperty(ICredentialsCommon.PASSWORD_PROP_ID);
  if (null != password) {
    credentialsComposite.setPassword(password);
  }
  String endPoint=ConnectionInfoHelper.readEndPointProperty(props);
  if (null != endPoint) {
    endPointText.setText(endPoint);
  }
  String endPointName=props.getProperty(IWSProfileConstants.END_POINT_NAME_PROP_ID);
  if (null != endPointName) {
    endPointNameText.setText(endPointName);
  }
  String bindingType=props.getProperty(IWSProfileConstants.SOAP_BINDING);
  if (null != bindingType) {
    bindingTypeText.setText(bindingType);
  }
}
Program: 102171
Project: 102171
Buggy source:
/** 
 * {@inheritDoc}
 * @see org.eclipse.datatools.connectivity.ui.wizards.ProfileDetailsPropertyPage#collectProperties()
 */
@Override protected Properties collectProperties(){
  Properties result=super.collectProperties();
  if (null == result) {
    result=new Properties();
  }
  result.setProperty(IWSProfileConstants.WSDL_URI_PROP_ID,urlText.getText());
  result.setProperty(ICredentialsCommon.SECURITY_TYPE_ID,credentialsComposite.getSecurityOption().name());
  if (credentialsComposite.getUserName() != null) {
    result.setProperty(ICredentialsCommon.USERNAME_PROP_ID,credentialsComposite.getUserName());
  }
  if (credentialsComposite.getPassword() != null) {
    result.setProperty(ICredentialsCommon.PASSWORD_PROP_ID,credentialsComposite.getPassword());
  }
  result.setProperty(IWSProfileConstants.END_POINT_URI_PROP_ID,endPointText.getText());
  return result;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 * @see org.eclipse.datatools.connectivity.ui.wizards.ProfileDetailsPropertyPage#collectProperties()
 */
@Override protected Properties collectProperties(){
  Properties result=super.collectProperties();
  if (null == result) {
    IConnectionProfile profile=getConnectionProfile();
    result=(Properties)profile.getBaseProperties().clone();
  }
  result.setProperty(IWSProfileConstants.WSDL_URI_PROP_ID,urlText.getText());
  result.setProperty(ICredentialsCommon.SECURITY_TYPE_ID,credentialsComposite.getSecurityOption().name());
  if (credentialsComposite.getUserName() != null) {
    result.setProperty(ICredentialsCommon.USERNAME_PROP_ID,credentialsComposite.getUserName());
  }
  if (credentialsComposite.getPassword() != null) {
    result.setProperty(ICredentialsCommon.PASSWORD_PROP_ID,credentialsComposite.getPassword());
  }
  result.setProperty(IWSProfileConstants.END_POINT_URI_PROP_ID,endPointText.getText());
  result.setProperty(IWSProfileConstants.END_POINT_NAME_PROP_ID,endPointNameText.getText());
  result.setProperty(IWSProfileConstants.SOAP_BINDING,bindingTypeText.getText());
  return result;
}
Program: 102173
Project: 102173
Buggy source:
private void addlisteners(){
  Listener listener=new Listener(){
    @Override public void handleEvent(    Event event){
      validate();
    }
  }
;
  urlText.addListener(SWT.Modify,listener);
  endPointText.addListener(SWT.Modify,listener);
  credentialsComposite.addSecurityOptionListener(SWT.Modify,listener);
  credentialsComposite.addUserNameListener(SWT.Modify,listener);
  credentialsComposite.addPasswordListener(SWT.Modify,listener);
}

Fixed version (ground truth):
private void addlisteners(){
  Listener listener=new Listener(){
    @Override public void handleEvent(    Event event){
      validate();
    }
  }
;
  urlText.addListener(SWT.Modify,listener);
  endPointText.addListener(SWT.Modify,listener);
  endPointNameText.addListener(SWT.Modify,listener);
  bindingTypeText.addListener(SWT.Modify,listener);
  credentialsComposite.addSecurityOptionListener(SWT.Modify,listener);
  credentialsComposite.addUserNameListener(SWT.Modify,listener);
  credentialsComposite.addPasswordListener(SWT.Modify,listener);
}
Program: 102174
Project: 102174
Buggy source:
protected void validate(){
  String errorMessage=null;
  boolean valid=true;
  if (null == urlText.getText() || urlText.getText().isEmpty()) {
    errorMessage=UTIL.getString("String_Node_Str");
    valid=false;
  }
  if (valid && (null == endPointText.getText() || endPointText.getText().isEmpty())) {
    errorMessage=UTIL.getString("String_Node_Str");
    valid=false;
  }
  setErrorMessage(errorMessage);
  setValid(valid);
}

Fixed version (ground truth):
protected void validate(){
  String errorMessage=null;
  boolean valid=true;
  if (null == urlText.getText() || urlText.getText().isEmpty()) {
    errorMessage=UTIL.getString("String_Node_Str");
    valid=false;
  }
  if (valid && (null == endPointText.getText() || endPointText.getText().isEmpty())) {
    errorMessage=UTIL.getString("String_Node_Str");
    valid=false;
  }
  if (valid && (null == endPointNameText.getText() || endPointNameText.getText().isEmpty())) {
    errorMessage=UTIL.getString("String_Node_Str");
    valid=false;
  }
  if (valid && (null == bindingTypeText.getText() || bindingTypeText.getText().isEmpty())) {
    errorMessage=UTIL.getString("String_Node_Str");
    valid=false;
  }
  setErrorMessage(errorMessage);
  setValid(valid);
}
Program: 102175
Project: 102175
Buggy source:
@Override public IFile getKey(VdbResourceChange value){
  return value.getVdb();
}

Fixed version (ground truth):
@Override public String getKey(VdbResourceChange value){
  return value.getParentFolder() + value.getVdbName();
}
Program: 102176
Project: 102176
Buggy source:
protected void addVdbChange(IFile vdbFile,IPath invalidResourcePath,IPath newResourcePath){
  VdbResourceChange change=vdbChanges.get(vdbFile);
  if (change == null) {
    change=new VdbResourceChange(vdbFile);
  }
  change.addReplacement(invalidResourcePath.toOSString(),newResourcePath.toOSString());
  vdbChanges.add(change);
}

Fixed version (ground truth):
protected void addVdbChange(IFile vdbFile,IPath invalidResourcePath,IPath newResourcePath){
  VdbResourceChange change=vdbChanges.get(vdbFile.getParent().getName() + vdbFile.getName());
  if (change == null) {
    change=new VdbResourceChange(vdbFile);
  }
  change.addReplacement(invalidResourcePath.toOSString(),newResourcePath.toOSString());
  vdbChanges.add(change);
}
Program: 102177
Project: 102177
Buggy source:
/** 
 * Create new instance
 * @param name
 * @param resources
 */
public AbstractResourcesRefactoring(String name,List<IResource> resources){
  super();
  this.name=name;
  this.resources=resources;
  this.vdbChanges=new KeyInValueHashMap<IFile,VdbResourceChange>(new VdbResourceChangeAdapter());
}

Fixed version (ground truth):
/** 
 * Create new instance
 * @param name
 * @param resources
 */
public AbstractResourcesRefactoring(String name,List<IResource> resources){
  super();
  this.name=name;
  this.resources=resources;
  this.vdbChanges=new KeyInValueHashMap<String,VdbResourceChange>(new VdbResourceChangeAdapter());
}
Program: 102178
Project: 102178
Buggy source:
/** 
 * Calculates a   {@link TextFileChange} for all the substitutions that need to take place in thegiven file based on the collection of path pairs.
 * @param file
 * @param pathPairs
 * @return text file change
 * @throws Exception
 */
public static TextFileChange calculateTextChanges(IFile file,Collection<PathPair> pathPairs) throws Exception {
  File nativeFile=ModelUtil.getLocation(file).makeAbsolute().toFile();
  if (nativeFile == null || !nativeFile.exists())   throw new Exception(getString("String_Node_Str",file.getFullPath()));
  TextFileChange textFileChange=new TextFileChange(file.getName(),file);
  TextEdit fileChangeRootEdit=setRootEdit(textFileChange);
  if (pathPairs.isEmpty()) {
    return textFileChange;
  }
  BufferedReader reader=null;
  String line;
  int docOffset=0;
  try {
    reader=new BufferedReader(new FileReader(nativeFile));
    while ((line=reader.readLine()) != null) {
      for (      PathPair pathPair : pathPairs) {
        int lineOffset=line.indexOf(pathPair.getSourcePath());
        if (lineOffset < 0)         continue;
        int offset=docOffset + lineOffset;
        ReplaceEdit edit=new ReplaceEdit(offset,pathPair.getSourcePath().length(),pathPair.getTargetPath());
        fileChangeRootEdit.addChild(edit);
      }
      docOffset+=line.length() + 1;
    }
  }
  finally {
    if (reader != null)     reader.close();
  }
  return textFileChange;
}

Fixed version (ground truth):
/** 
 * Calculates a   {@link TextFileChange} for all the substitutions that need to take place in thegiven file based on the collection of path pairs.
 * @param file
 * @param pathPairs
 * @return text file change
 * @throws Exception
 */
public static TextFileChange calculateTextChanges(IFile file,Collection<PathPair> pathPairs) throws Exception {
  File nativeFile=ModelUtil.getLocation(file).makeAbsolute().toFile();
  if (nativeFile == null || !nativeFile.exists())   throw new Exception(getString("String_Node_Str",file.getFullPath()));
  TextFileChange textFileChange=new TextFileChange(file.getName(),file);
  TextEdit fileChangeRootEdit=setRootEdit(textFileChange);
  if (pathPairs.isEmpty()) {
    return textFileChange;
  }
  BufferedReader reader=null;
  String line;
  int docOffset=0;
  try {
    reader=new BufferedReader(new FileReader(nativeFile));
    while ((line=reader.readLine()) != null) {
      for (      PathPair pathPair : pathPairs) {
        if (pathPair.getSourcePath().equals(pathPair.getTargetPath())) {
          continue;
        }
        int lineOffset=line.indexOf(pathPair.getSourcePath());
        if (lineOffset < 0)         continue;
        int offset=docOffset + lineOffset;
        ReplaceEdit edit=new ReplaceEdit(offset,pathPair.getSourcePath().length(),pathPair.getTargetPath());
        fileChangeRootEdit.addChild(edit);
      }
      docOffset+=line.length() + 1;
    }
  }
  finally {
    if (reader != null)     reader.close();
  }
  return textFileChange;
}
Program: 102179
Project: 102179
Buggy source:
@Override public void indexVdb(IResource resource,IFile vdbFile,RefactoringStatus status){
  IPath oldResourcePath=resource.getFullPath();
  IPath newResourcePath=oldResourcePath.removeLastSegments(1).append(getNewResourceName());
  addVdbChange(vdbFile,oldResourcePath,newResourcePath);
}

Fixed version (ground truth):
@Override public void indexVdb(IResource resource,IFile vdbFile,RefactoringStatus status){
  IPath oldResourcePath=resource.getFullPath();
  IPath newResourcePath=null;
  if (getResource().equals(resource)) {
    newResourcePath=oldResourcePath.removeLastSegments(1).append(getNewResourceName());
  }
 else   if (getResource().getFullPath().isPrefixOf(oldResourcePath)) {
    IPath oldRResPath=getResource().getFullPath();
    IPath newRResPath=oldRResPath.removeLastSegments(1).append(getNewResourceName());
    int segmentCount=oldRResPath.matchingFirstSegments(oldResourcePath);
    newResourcePath=oldResourcePath.removeFirstSegments(segmentCount);
    newResourcePath=newRResPath.append(newResourcePath);
  }
 else {
    newResourcePath=oldResourcePath;
  }
  addVdbChange(vdbFile,oldResourcePath,newResourcePath);
}
Program: 102180
Project: 102180
Buggy source:
@Override public void indexFile(IResource resource,IFile relatedFile,RefactoringStatus status) throws Exception {
  RefactorResourcesUtils.unloadModelResource(relatedFile);
  IPath relatedFilePath=ModelUtil.getLocation(relatedFile).makeAbsolute();
  IPath relatedParentPath=relatedFilePath.removeLastSegments(1);
  PathPair relativePathPair=RefactorResourcesUtils.getRelativePath(relatedParentPath.toOSString(),pathPair);
  TextFileChange textFileChange=RefactorResourcesUtils.calculateTextChanges(relatedFile,Collections.singleton(relativePathPair));
  if (ModelUtil.isModelFile(getResource())) {
    RefactorResourcesUtils.calculateSQLChanges(relatedFile,relativePathPair,textFileChange);
  }
  if (addTextChange(relatedFile,textFileChange)) {
    RefactorResourcesUtils.calculateRelatedVdbResources(relatedFile,status,this);
  }
}

Fixed version (ground truth):
@Override public void indexFile(IResource resource,IFile relatedFile,RefactoringStatus status) throws Exception {
  RefactorResourcesUtils.unloadModelResource(relatedFile);
  IPath relatedFilePath=ModelUtil.getLocation(relatedFile).makeAbsolute();
  IPath relatedParentPath=relatedFilePath.removeLastSegments(1);
  PathPair relativePathPair=RefactorResourcesUtils.getRelativePath(relatedParentPath.toOSString(),pathPair);
  TextFileChange textFileChange=RefactorResourcesUtils.calculateTextChanges(relatedFile,Collections.singleton(relativePathPair));
  if (ModelUtil.isModelFile(getResource())) {
    RefactorResourcesUtils.calculateSQLChanges(relatedFile,relativePathPair,textFileChange);
  }
  if (addTextChange(relatedFile,textFileChange) || getResource() instanceof IContainer) {
    RefactorResourcesUtils.calculateRelatedVdbResources(relatedFile,status,this);
  }
}
Program: 102184
Project: 102184
Buggy source:
public TeiidDataSourceInfo getTeiidDataSourceInfo(){
  TeiidDataSourceInfo info=new TeiidDataSourceInfo(dataSourceName,dataSourceName,teiidDataSourceProperties,currentProvider);
  return info;
}

Fixed version (ground truth):
public TeiidDataSourceInfo getTeiidDataSourceInfo(){
  TeiidDataSourceInfo info=new TeiidDataSourceInfo(dataSourceName,dataSourceName,teiidDataSourceProperties,currentProvider,connRequiresPassword);
  return info;
}
Program: 102185
Project: 102185
Buggy source:
/** 
 * @param displayName
 * @param jndiName
 * @param properties
 * @param connectionInfoProvider
 */
public TeiidDataSourceInfo(String displayName,String jndiName,Properties properties,IConnectionInfoProvider connectionInfoProvider){
  super();
  this.displayName=displayName;
  this.jndiName=jndiName;
  this.properties=properties;
  this.connectionInfoProvider=connectionInfoProvider;
}

Fixed version (ground truth):
/** 
 * @param displayName
 * @param jndiName
 * @param properties
 * @param connectionInfoProvider
 * @param requiresPassword
 */
public TeiidDataSourceInfo(String displayName,String jndiName,Properties properties,IConnectionInfoProvider connectionInfoProvider,boolean requiresPassword){
  super();
  this.displayName=displayName;
  this.jndiName=jndiName;
  this.properties=properties;
  this.connectionInfoProvider=connectionInfoProvider;
  this.requiresPassword=requiresPassword;
}
Program: 102189
Project: 102189
Buggy source:
private void setUiState(){
  if (getRelationalReference().isFunction()) {
    boolean functionState=true;
    if (this.deterministicCB != null)     this.deterministicCB.setEnabled(functionState);
    if (this.returnsNullCB != null)     this.returnsNullCB.setEnabled(functionState);
    if (this.variableArgsCB != null)     this.variableArgsCB.setEnabled(functionState);
    if (this.aggregateCB != null) {
      this.aggregateCB.setEnabled(functionState);
      boolean aggregateState=functionState;
      if (aggregateState) {
        aggregateState=aggregateCB.getSelection();
      }
      if (this.allowsDistinctCB != null)       this.allowsDistinctCB.setEnabled(aggregateState);
      if (this.allowsOrderByCB != null)       this.allowsOrderByCB.setEnabled(aggregateState);
      if (this.analyticCB != null)       this.analyticCB.setEnabled(aggregateState);
      if (this.decomposableCB != null)       this.decomposableCB.setEnabled(aggregateState);
      if (this.useDistinctRowsCB != null)       this.useDistinctRowsCB.setEnabled(aggregateState);
    }
  }
}

Fixed version (ground truth):
private void setUiState(){
  if (getRelationalReference().isFunction()) {
    boolean functionState=true;
    if (this.deterministicCB != null)     this.deterministicCB.setEnabled(functionState);
    if (this.returnsNullCB != null)     this.returnsNullCB.setEnabled(functionState);
    if (this.variableArgsCB != null)     this.variableArgsCB.setEnabled(functionState);
    if (this.aggregateCB != null) {
      this.aggregateCB.setEnabled(functionState);
      boolean aggregateState=functionState;
      if (aggregateState) {
        aggregateState=aggregateCB.getSelection();
      }
      if (this.allowsDistinctCB != null)       this.allowsDistinctCB.setEnabled(aggregateState);
      if (this.allowsOrderByCB != null)       this.allowsOrderByCB.setEnabled(aggregateState);
      if (this.analyticCB != null)       this.analyticCB.setEnabled(aggregateState);
      if (this.decomposableCB != null)       this.decomposableCB.setEnabled(aggregateState);
      if (this.useDistinctRowsCB != null)       this.useDistinctRowsCB.setEnabled(aggregateState);
    }
  }
 else {
    if (this.addColumnButton != null && this.includeResultSetCB != null) {
      boolean enable=this.includeResultSetCB.getSelection();
      this.addColumnButton.setEnabled(enable);
      if (!enable) {
        this.deleteColumnButton.setEnabled(false);
        this.downColumnButton.setEnabled(false);
        this.upColumnButton.setEnabled(false);
      }
    }
  }
}
Program: 102190
Project: 102190
Buggy source:
private void launchGuidesAction(String actionId){
  String guideId=actionGroupCombo.getText();
  Properties properties=propertiesManager.getProperties(guideId);
  AdvisorActionFactory.executeAction(actionId,properties,true);
}

Fixed version (ground truth):
private void launchGuidesAction(String actionId){
  String guideId=actionGroupCombo.getText();
  Properties properties=propertiesManager.getProperties(guideId);
  if (properties != null && !properties.isEmpty()) {
    cleanProperties(properties);
  }
  AdvisorActionFactory.executeAction(actionId,properties,true);
}
Program: 102191
Project: 102191
Buggy source:
@Override public void setProperties(Properties props){
  this.designerProperties=props;
  if (this.folder == null) {
    IContainer project=DesignerPropertiesUtil.getProject(designerProperties);
    IContainer srcFolder=DesignerPropertiesUtil.getSourcesFolder(this.designerProperties);
    if (srcFolder != null) {
      setFolder(srcFolder);
    }
 else     if (project != null) {
      setFolder(project);
    }
  }
  if (this.connectionProfile == null) {
    String profileName=DesignerPropertiesUtil.getConnectionProfileName(this.designerProperties);
    if (profileName != null && !profileName.isEmpty()) {
      srcPg.selectConnectionProfile(profileName);
    }
  }
  if (this.designerProperties != null && !this.openProjectExists) {
    DesignerPropertiesUtil.setProjectStatus(this.designerProperties,IPropertiesContext.NO_OPEN_PROJECT);
  }
}

Fixed version (ground truth):
@Override public void setProperties(Properties props){
  this.designerProperties=props;
  if (this.folder == null) {
    IContainer project=DesignerPropertiesUtil.getProject(designerProperties);
    IContainer srcFolder=DesignerPropertiesUtil.getSourcesFolder(this.designerProperties);
    if (srcFolder != null) {
      setFolder(srcFolder);
    }
 else     if (project != null) {
      setFolder(project);
    }
  }
  if (this.connectionProfile == null) {
    String profileName=DesignerPropertiesUtil.getConnectionProfileName(this.designerProperties);
    if (profileName != null && !profileName.isEmpty()) {
      srcPg.selectConnectionProfile(profileName);
    }
  }
}
Program: 102192
Project: 102192
Buggy source:
@Override public boolean finish(){
  final TeiidXmlFileImportProcessor processor=new TeiidXmlFileImportProcessor(getFileInfo(),this.getShell());
  UiUtil.runInSwtThread(new Runnable(){
    @Override public void run(){
      processor.execute();
    }
  }
,false);
  if (this.designerProperties != null) {
    DesignerPropertiesUtil.setSourceModelName(this.designerProperties,getFileInfo().getSourceModelName());
    DesignerPropertiesUtil.setViewModelName(this.designerProperties,getFileInfo().getViewModelName());
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean finish(){
  final TeiidXmlFileImportProcessor processor=new TeiidXmlFileImportProcessor(getFileInfo(),this.getShell());
  UiUtil.runInSwtThread(new Runnable(){
    @Override public void run(){
      processor.execute();
    }
  }
,false);
  if (getDesignerProperties() != null) {
    DesignerPropertiesUtil.setSourceModelName(getDesignerProperties(),getFileInfo().getSourceModelName());
    DesignerPropertiesUtil.setViewModelName(getDesignerProperties(),getFileInfo().getViewModelName());
  }
  return true;
}
Program: 102193
Project: 102193
Buggy source:
@Override protected void updateForProperties(){
  if (this.designerProperties == null || this.designerProperties.isEmpty()) {
    return;
  }
  IContainer project=DesignerPropertiesUtil.getProject(designerProperties);
  IContainer srcFolderResrc=DesignerPropertiesUtil.getSourcesFolder(this.designerProperties);
  IContainer viewFolderResrc=DesignerPropertiesUtil.getViewsFolder(this.designerProperties);
  if (srcFolderResrc != null) {
    getFileInfo().setSourceModelLocation(srcFolderResrc.getFullPath());
  }
 else   if (project != null) {
    getFileInfo().setSourceModelLocation(project.getFullPath());
  }
  if (viewFolderResrc != null) {
    getFileInfo().setViewModelLocation(viewFolderResrc.getFullPath());
  }
 else   if (project != null) {
    getFileInfo().setViewModelLocation(project.getFullPath());
  }
  String profileName=DesignerPropertiesUtil.getConnectionProfileName(this.designerProperties);
  if (profileName != null && !profileName.isEmpty()) {
    sourcePage.setDesignerProperties(this.designerProperties);
  }
  this.optionsPage.setDesignerProperties(this.designerProperties);
  if (!openProjectExists()) {
    DesignerPropertiesUtil.setProjectStatus(this.designerProperties,IPropertiesContext.NO_OPEN_PROJECT);
  }
}

Fixed version (ground truth):
@Override protected void updateForProperties(){
  Properties desProps=getDesignerProperties();
  if (desProps == null || desProps.isEmpty()) {
    return;
  }
  IContainer project=DesignerPropertiesUtil.getProject(getDesignerProperties());
  IContainer srcFolderResrc=DesignerPropertiesUtil.getSourcesFolder(desProps);
  IContainer viewFolderResrc=DesignerPropertiesUtil.getViewsFolder(desProps);
  if (srcFolderResrc != null) {
    getFileInfo().setSourceModelLocation(srcFolderResrc.getFullPath());
  }
 else   if (project != null) {
    getFileInfo().setSourceModelLocation(project.getFullPath());
  }
  if (viewFolderResrc != null) {
    getFileInfo().setViewModelLocation(viewFolderResrc.getFullPath());
  }
 else   if (project != null) {
    getFileInfo().setViewModelLocation(project.getFullPath());
  }
  String profileName=DesignerPropertiesUtil.getConnectionProfileName(desProps);
  if (profileName != null && !profileName.isEmpty()) {
    sourcePage.setDesignerProperties(desProps);
  }
  this.optionsPage.setDesignerProperties(desProps);
  if (!openProjectExists()) {
    DesignerPropertiesUtil.setProjectStatus(desProps,IPropertiesContext.NO_OPEN_PROJECT);
  }
}
Program: 102194
Project: 102194
Buggy source:
private void handleBrowseWorkspaceForObjectPressed(){
  ModelWorkspaceDialog sdDialog=createProjectSelector();
  sdDialog.addFilter(new ClosedProjectFilter());
  sdDialog.open();
  if (sdDialog.getReturnCode() == Window.OK) {
    Object[] selections=sdDialog.getResult();
    IProject selectedProject=(IProject)selections[0];
    if (this.project != null && selectedProject != null && selectedProject.getName().equals(this.project.getName())) {
      return;
    }
    this.designerProperties.clear();
    this.project=selectedProject;
    String pName=(this.project != null) ? this.project.getName() : "String_Node_Str";
    this.selectedProjectText.setText(pName);
    DesignerPropertiesUtil.setProjectName(this.designerProperties,pName);
    if (this.project != null) {
      try {
        for (        IResource res : project.members()) {
          if (res instanceof IContainer) {
            if (((IContainer)res).getName().equalsIgnoreCase("String_Node_Str")) {
              DesignerPropertiesUtil.setSourcesFolderName(this.designerProperties,"String_Node_Str");
            }
 else             if (((IContainer)res).getName().equalsIgnoreCase("String_Node_Str")) {
              DesignerPropertiesUtil.setViewsFolderName(this.designerProperties,"String_Node_Str");
            }
          }
        }
      }
 catch (      CoreException ex) {
        ex.printStackTrace();
      }
    }
    updateState();
  }
}

Fixed version (ground truth):
private void handleBrowseWorkspaceForObjectPressed(){
  ModelWorkspaceDialog sdDialog=createProjectSelector();
  sdDialog.addFilter(new ClosedProjectFilter());
  sdDialog.open();
  if (sdDialog.getReturnCode() == Window.OK) {
    Object[] selections=sdDialog.getResult();
    IProject selectedProject=(IProject)selections[0];
    if (this.project != null && selectedProject != null && selectedProject.getName().equals(this.project.getName())) {
      return;
    }
    this.designerProperties.clear();
    this.project=selectedProject;
    String pName=(this.project != null) ? this.project.getName() : "String_Node_Str";
    this.selectedProjectText.setText(pName);
    DesignerPropertiesUtil.setProjectName(this.designerProperties,pName);
    if (this.project != null) {
      DesignerPropertiesUtil.setProjectStatus(this.designerProperties,IPropertiesContext.OPEN_PROJECTS_EXIST);
      try {
        for (        IResource res : project.members()) {
          if (res instanceof IContainer) {
            if (((IContainer)res).getName().equalsIgnoreCase("String_Node_Str")) {
              DesignerPropertiesUtil.setSourcesFolderName(this.designerProperties,"String_Node_Str");
            }
 else             if (((IContainer)res).getName().equalsIgnoreCase("String_Node_Str")) {
              DesignerPropertiesUtil.setViewsFolderName(this.designerProperties,"String_Node_Str");
            }
          }
        }
      }
 catch (      CoreException ex) {
        ex.printStackTrace();
      }
    }
    updateState();
  }
}
Program: 102195
Project: 102195
Buggy source:
public static void setProjectName(Properties properties,String projectName){
  properties.put(IPropertiesContext.KEY_PROJECT_NAME,projectName);
}

Fixed version (ground truth):
public static void setProjectName(Properties properties,String projectName){
  if (projectName == null) {
    properties.remove(IPropertiesContext.KEY_PROJECT_NAME);
  }
 else {
    properties.put(IPropertiesContext.KEY_PROJECT_NAME,projectName);
  }
}
Program: 102196
Project: 102196
Buggy source:
public static void setProjectStatus(Properties properties,String status){
  properties.put(IPropertiesContext.KEY_PROJECT_STATUS,status);
}

Fixed version (ground truth):
public static void setProjectStatus(Properties properties,String status){
  if (status == null) {
    properties.remove(IPropertiesContext.KEY_PROJECT_STATUS);
  }
 else {
    properties.put(IPropertiesContext.KEY_PROJECT_STATUS,status);
  }
}
Program: 102198
Project: 102198
Buggy source:
/** 
 * Method to check if the uer's workspace has any Open Teiid Model Projects
 * @return true if one or more projects exists and are open
 */
public static boolean workspaceHasOpenModelProjects(){
  try {
    ModelProject[] mProjects=ModelWorkspaceManager.getModelWorkspaceManager().getModelWorkspace().getModelProjects();
    for (    ModelProject proj : mProjects) {
      if (proj.isOpen()) {
        return true;
      }
    }
  }
 catch (  ModelWorkspaceException ex) {
    ex.printStackTrace();
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Method to check if the uer's workspace has any Open Teiid Model Projects
 * @return true if one or more projects exists and are open
 */
public static boolean workspaceHasOpenModelProjects(){
  return !getOpenModelProjects().isEmpty();
}
Program: 102200
Project: 102200
Buggy source:
/** 
 * Get the SingleElementSymbol type. The "type" will be one of three things (1) null - When the SingleElementSymbol is not resolve / no type (2) Datatype - SingleElementSymbol is not resolved - Datatype of the SqlColumn (3) java class type - SingleElementSymbol is IExpression, etc, type is Class
 * @param symbol the SingleElementSymbol
 * @return the symbols type
 */
public static Object getElementSymbolType(IExpression symbol){
  Object datatype=null;
  if (symbol instanceof IAliasSymbol) {
    symbol=((IAliasSymbol)symbol).getSymbol();
  }
  if (symbol instanceof IElementSymbol) {
    IElementSymbol eSymbol=(IElementSymbol)symbol;
    Object idObj=eSymbol.getMetadataID();
    if (idObj instanceof MetadataRecord) {
      EObject recordEObj=(EObject)((MetadataRecord)idObj).getEObject();
      if (recordEObj != null && TransformationHelper.isSqlColumn(recordEObj)) {
        SqlColumnAspect columnAspect=((SqlColumnAspect)AspectManager.getSqlAspect(recordEObj));
        datatype=columnAspect.getDatatype(recordEObj);
      }
    }
 else     if (idObj instanceof IMetadataID) {
      datatype=((IMetadataID)idObj).getType();
    }
 else     if (idObj == null) {
      datatype=eSymbol.getType();
    }
  }
 else   if (symbol instanceof IExpressionSymbol) {
    IExpressionSymbol exSymbol=(IExpressionSymbol)symbol;
    datatype=exSymbol.getType();
  }
  return datatype;
}

Fixed version (ground truth):
/** 
 * Get the SingleElementSymbol type. The "type" will be one of three things (1) null - When the SingleElementSymbol is not resolve / no type (2) Datatype - SingleElementSymbol is not resolved - Datatype of the SqlColumn (3) java class type - SingleElementSymbol is IExpression, etc, type is Class
 * @param symbol the SingleElementSymbol
 * @return the symbols type
 */
public static Object getElementSymbolType(IExpression symbol){
  Object datatype=null;
  if (symbol instanceof IAliasSymbol) {
    symbol=((IAliasSymbol)symbol).getSymbol();
  }
  if (symbol instanceof IElementSymbol) {
    IElementSymbol eSymbol=(IElementSymbol)symbol;
    Object idObj=eSymbol.getMetadataID();
    if (idObj instanceof MetadataRecord) {
      EObject recordEObj=(EObject)((MetadataRecord)idObj).getEObject();
      if (recordEObj != null && TransformationHelper.isSqlColumn(recordEObj)) {
        SqlColumnAspect columnAspect=((SqlColumnAspect)AspectManager.getSqlAspect(recordEObj));
        datatype=columnAspect.getDatatype(recordEObj);
      }
    }
 else     if (idObj instanceof IMetadataID) {
      datatype=((IMetadataID)idObj).getType();
    }
 else     if (idObj == null) {
      datatype=eSymbol.getType();
    }
  }
 else {
    datatype=symbol.getType();
  }
  return datatype;
}
Program: 102201
Project: 102201
Buggy source:
public Collection<IFile> findRelatedResources(Relationship typeOfRelationship){
switch (typeOfRelationship) {
case DEPENDENT:
    return findDependentResources();
case DEPENDENCY:
  return findDependencyResources();
case ALL:
Set<IFile> files=new HashSet<IFile>();
files.addAll(findDependentResources());
files.addAll(findDependentResources());
return files;
}
throw new IllegalStateException();
}

Fixed version (ground truth):
public Collection<IFile> findRelatedResources(Relationship typeOfRelationship){
switch (typeOfRelationship) {
case DEPENDENT:
    return findDependentResources();
case DEPENDENCY:
  return findDependencyResources();
case ALL:
Set<IFile> files=new HashSet<IFile>();
files.addAll(findDependentResources());
files.addAll(findDependencyResources());
return files;
}
throw new IllegalStateException();
}
Program: 102204
Project: 102204
Buggy source:
/** 
 * @return <code>true</code> if a connection to this server exists and is working
 */
@Override public boolean isConnected(){
  if (!isParentConnected() && this.admin == null) {
    return false;
  }
  return ping().isOK();
}

Fixed version (ground truth):
/** 
 * @return <code>true</code> if a connection to this server exists and is working
 */
@Override public boolean isConnected(){
  if (!isParentConnected() || this.admin == null) {
    return false;
  }
  return ping().isOK();
}
Program: 102205
Project: 102205
Buggy source:
/** 
 * @param iFile the model file
 * @param key the property key including ns prefix (i.e. core:vdb-name)
 * @return the string property value
 * @throws ModelWorkspaceException if problem finding model resource or finding property value
 */
public static String getModelAnnotationPropertyValue(final IFile iFile,final String key) throws ModelWorkspaceException {
  ModelResource mr=getModelResource(iFile,true);
  if (mr != null) {
    ResourceAnnotationHelper helper=new ResourceAnnotationHelper();
    return (String)helper.getPropertyValue(mr,key);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Get a Model Annotation property value
 * @param modelResource the model resource
 * @param propertyKey the property key including ns prefix (i.e. core:vdb-name)
 * @return the string property value
 * @throws ModelWorkspaceException if problem finding property value
 */
public static String getModelAnnotationPropertyValue(final ModelResource modelResource,final String propertyKey) throws ModelWorkspaceException {
  CoreArgCheck.isNotNull(modelResource,"String_Node_Str");
  CoreArgCheck.isNotEmpty(propertyKey,"String_Node_Str");
  ResourceAnnotationHelper helper=new ResourceAnnotationHelper();
  return (String)helper.getPropertyValue(modelResource,propertyKey);
}
Program: 102206
Project: 102206
Buggy source:
@Override public void run(){
  if (vdbModelEntry != null) {
    String transName=vdbModelEntry.getSourceInfo().getSource().getTranslatorName();
    SelectTranslatorDialog dialog=new SelectTranslatorDialog(Display.getCurrent().getActiveShell());
    ITeiidTranslator initialSelection=null;
    ITeiidServer defServer=getDefaultServer();
    if (defServer != null && defServer.isConnected()) {
      try {
        initialSelection=defServer.getTranslator(transName);
      }
 catch (      Exception e) {
        UTIL.log(IStatus.ERROR,e,UTIL.getString("String_Node_Str",transName));
      }
      dialog.setInitialSelection(initialSelection);
    }
    dialog.open();
    if (dialog.getReturnCode() == Window.OK) {
      Object result=dialog.getFirstResult();
      if (result != null && result instanceof ITeiidTranslator) {
        vdbModelEntry.setTranslatorName(0,((ITeiidTranslator)result).getName());
      }
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  if (vdbModelEntry != null) {
    String transName=vdbModelEntry.getSourceInfo().getSource(0).getTranslatorName();
    SelectTranslatorDialog dialog=new SelectTranslatorDialog(Display.getCurrent().getActiveShell());
    ITeiidTranslator initialSelection=null;
    ITeiidServer defServer=getDefaultServer();
    if (defServer != null && defServer.isConnected()) {
      try {
        initialSelection=defServer.getTranslator(transName);
      }
 catch (      Exception e) {
        UTIL.log(IStatus.ERROR,e,UTIL.getString("String_Node_Str",transName));
      }
      dialog.setInitialSelection(initialSelection);
    }
    dialog.open();
    if (dialog.getReturnCode() == Window.OK) {
      Object result=dialog.getFirstResult();
      if (result != null && result instanceof ITeiidTranslator) {
        vdbModelEntry.setTranslatorName(0,((ITeiidTranslator)result).getName());
      }
    }
  }
}
Program: 102207
Project: 102207
Buggy source:
/** 
 * @param modelEntry the model entry whose translator entry is being validated
 * @return <code>true</code> if model entry has a valid translator
 * @throws Exception
 */
private boolean hasValidTranslator(VdbModelEntry modelEntry) throws Exception {
  String translatorName=modelEntry.getSourceInfo().getSource().getTranslatorName();
  if (StringUtilities.isEmpty(translatorName)) {
    return false;
  }
  boolean isValid=(teiidServer.getTranslator(translatorName) != null);
  if (!isValid && !this.vdb.getTranslators().isEmpty()) {
    for (    TranslatorOverride override : this.vdb.getTranslators()) {
      if (override.getName().equalsIgnoreCase(translatorName)) {
        isValid=(teiidServer.getTranslator(override.getType()) != null);
        break;
      }
    }
  }
  return isValid;
}

Fixed version (ground truth):
/** 
 * @param modelEntry the model entry whose translator entry is being validated
 * @return <code>true</code> if model entry has a valid translator
 * @throws Exception
 */
private boolean hasValidTranslator(VdbModelEntry modelEntry) throws Exception {
  String translatorName=modelEntry.getSourceInfo().getSource(0).getTranslatorName();
  if (StringUtilities.isEmpty(translatorName)) {
    return false;
  }
  boolean isValid=(teiidServer.getTranslator(translatorName) != null);
  if (!isValid && !this.vdb.getTranslators().isEmpty()) {
    for (    TranslatorOverride override : this.vdb.getTranslators()) {
      if (override.getName().equalsIgnoreCase(translatorName)) {
        isValid=(teiidServer.getTranslator(override.getType()) != null);
        break;
      }
    }
  }
  return isValid;
}
Program: 102208
Project: 102208
Buggy source:
/** 
 * Test the jdbc connection
 * @param host
 * @param port
 * @param username
 * @param password
 * @return status as to the ping's success
 */
@Override public IStatus testJDBCPing(String host,String port,String username,String password){
  try {
    boolean testCausesConnect=false;
    if (admin == null) {
      connect();
      testCausesConnect=true;
    }
    admin.ping(PingType.JDBC);
    if (testCausesConnect) {
      disconnect();
    }
  }
 catch (  Exception e) {
    String msg=Util.getString("String_Node_Str",this);
    return new Status(IStatus.ERROR,PLUGIN_ID,msg,e);
  }
  return Status.OK_STATUS;
}

Fixed version (ground truth):
/** 
 * Test the jdbc connection
 * @param host
 * @param port
 * @param username
 * @param password
 * @return status as to the ping's success
 */
@Override public IStatus testJDBCPing(String host,String port,String username,String password){
  IStatus pingStatus=Status.OK_STATUS;
  try {
    boolean testCausesConnect=false;
    if (admin == null) {
      connect();
      testCausesConnect=true;
    }
    pingStatus=admin.ping(PingType.JDBC);
    if (testCausesConnect) {
      disconnect();
    }
  }
 catch (  Exception e) {
    String msg=Util.getString("String_Node_Str",this);
    return new Status(IStatus.ERROR,PLUGIN_ID,msg,e);
  }
  return pingStatus;
}
Program: 102210
Project: 102210
Buggy source:
/** 
 * @param index
 * @param name
 */
public final void setTranslatorName(int index,String name){
  CoreArgCheck.isTrue(index < sourceInfo.getSourceCount(),"String_Node_Str");
  if (StringUtilities.isEmpty(name))   name=null;
  String oldName=sourceInfo.getSource().getTranslatorName();
  if (StringUtilities.equals(name,oldName))   return;
  sourceInfo.getSource(index).setTranslatorName(name);
}

Fixed version (ground truth):
/** 
 * @param index
 * @param name
 */
public final void setTranslatorName(int index,String name){
  CoreArgCheck.isTrue(index < sourceInfo.getSourceCount(),"String_Node_Str");
  if (StringUtilities.isEmpty(name))   name=null;
  String oldName=sourceInfo.getSource(index).getTranslatorName();
  if (StringUtilities.equals(name,oldName))   return;
  sourceInfo.getSource(index).setTranslatorName(name);
}