nus-yam/ex-repair huggingface dataset:
Program: 118704
Project: 118704
Buggy source:
public boolean isGenericRepositoryValue(GenericConnection connection,String paramName){
  if (connection == null) {
    return false;
  }
  ComponentProperties componentProperties=ComponentsUtils.getComponentPropertiesFromSerialized(connection.getCompProperties());
  List<Property> propertyValues=ComponentsUtils.getAllValuedProperties(componentProperties);
  for (  Property property : propertyValues) {
    paramName=ComponentsUtils.getPropertyName(paramName);
    if (property.getName().equals(paramName)) {
      return property.getTaggedValue(IGenericConstants.REPOSITORY_VALUE) != null;
    }
  }
  for (  ModelElement modelElement : connection.getOwnedElement()) {
    ComponentProperties subComponentProperties=null;
    if (modelElement instanceof SubContainer) {
      SubContainer subContainer=(SubContainer)modelElement;
      subComponentProperties=ComponentsUtils.getComponentPropertiesFromSerialized(subContainer.getCompProperties());
    }
 else     if (modelElement instanceof MetadataTable) {
      MetadataTable metadataTable=(MetadataTable)modelElement;
      for (      TaggedValue taggedValue : metadataTable.getTaggedValue()) {
        if (IComponentConstants.COMPONENT_PROPERTIES_TAG.equals(taggedValue.getTag())) {
          subComponentProperties=ComponentsUtils.getComponentPropertiesFromSerialized(taggedValue.getValue());
          break;
        }
      }
    }
    if (subComponentProperties != null) {
      List<Property> subPropertyValues=ComponentsUtils.getAllValuedProperties(subComponentProperties);
      for (      Property subProperty : subPropertyValues) {
        paramName=ComponentsUtils.getPropertyName(paramName);
        if (subProperty.getName().equals(paramName)) {
          return subProperty.getTaggedValue(IGenericConstants.REPOSITORY_VALUE) != null;
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean isGenericRepositoryValue(List<ComponentProperties> componentProperties,String paramName){
  if (componentProperties != null && paramName != null) {
    for (    ComponentProperties compPro : componentProperties) {
      Property property=compPro.getValuedProperty(paramName);
      if (property != null) {
        return property.getTaggedValue(IGenericConstants.REPOSITORY_VALUE) != null;
      }
    }
  }
  return false;
}
Program: 118705
Project: 118705
Buggy source:
@Test public void testIsGenericRepositoryValue(){
  Connection connection=mock(Connection.class);
  AbstractDragAndDropServiceHandler abstractDragAndDropServiceHandler=mock(AbstractDragAndDropServiceHandler.class);
  boolean isGenericRepositoryValue=abstractDragAndDropServiceHandler.isGenericRepositoryValue(connection,"String_Node_Str");
  assertEquals(false,isGenericRepositoryValue);
  connection=mock(GenericConnection.class);
  GenericDragAndDropHandler genericDragAndDropHandler=mock(GenericDragAndDropHandler.class);
  when(genericDragAndDropHandler.canHandle(connection)).thenReturn(true);
  isGenericRepositoryValue=genericDragAndDropHandler.isGenericRepositoryValue(null,"String_Node_Str");
  assertEquals(false,isGenericRepositoryValue);
}

Fixed version (ground truth):
@Test public void testIsGenericRepositoryValue(){
  Connection connection=mock(Connection.class);
  AbstractDragAndDropServiceHandler abstractDragAndDropServiceHandler=mock(AbstractDragAndDropServiceHandler.class);
  List<ComponentProperties> componentProsList=new ArrayList<>();
  boolean isGenericRepositoryValue=abstractDragAndDropServiceHandler.isGenericRepositoryValue(componentProsList,"String_Node_Str");
  assertEquals(false,isGenericRepositoryValue);
  connection=mock(GenericConnection.class);
  GenericDragAndDropHandler genericDragAndDropHandler=mock(GenericDragAndDropHandler.class);
  when(genericDragAndDropHandler.canHandle(connection)).thenReturn(true);
  isGenericRepositoryValue=genericDragAndDropHandler.isGenericRepositoryValue(null,"String_Node_Str");
  assertEquals(false,isGenericRepositoryValue);
}
Program: 118706
Project: 118706
Buggy source:
@Override public Composite creatDynamicComposite(Composite composite,Element element,EComponentCategory sectionCategory,boolean isCompactView){
  DynamicComposite dynamicComposite=null;
  if (element != null && element instanceof INode) {
    INode node=(INode)element;
    ComponentProperties props=null;
    if (node.getComponentProperties() == null) {
      props=ComponentsUtils.getComponentProperties(node.getComponent().getName());
    }
 else {
      props=node.getComponentProperties();
    }
    if (props != null) {
      Form form=props.getForm(EComponentCategory.ADVANCED.equals(sectionCategory) ? Form.ADVANCED : Form.MAIN);
      dynamicComposite=new DynamicComposite(composite,SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS,sectionCategory,element,isCompactView,composite.getBackground(),form);
      List<ElementParameter> elementParameters=(List<ElementParameter>)node.getElementParameters();
      for (      ElementParameter parameter : elementParameters) {
        if (parameter instanceof GenericElementParameter) {
          GenericElementParameter genericElementParameter=(GenericElementParameter)parameter;
          genericElementParameter.addPropertyChangeListener(dynamicComposite);
        }
      }
    }
  }
  return dynamicComposite;
}

Fixed version (ground truth):
@Override public Composite creatDynamicComposite(Composite composite,Element element,EComponentCategory sectionCategory,boolean isCompactView){
  DynamicComposite dynamicComposite=null;
  if (element != null && element instanceof INode) {
    INode node=(INode)element;
    ComponentProperties props=null;
    if (node.getComponentProperties() == null) {
      props=ComponentsUtils.getComponentProperties(node.getComponent().getName());
    }
 else {
      props=node.getComponentProperties();
    }
    if (props != null) {
      Form form=props.getForm(EComponentCategory.ADVANCED.equals(sectionCategory) ? Form.ADVANCED : Form.MAIN);
      dynamicComposite=new DynamicComposite(composite,SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS,sectionCategory,element,isCompactView,composite.getBackground(),form);
      List<ElementParameter> elementParameters=(List<ElementParameter>)node.getElementParameters();
      for (      ElementParameter parameter : elementParameters) {
        if (parameter instanceof GenericElementParameter) {
          GenericElementParameter genericElementParameter=(GenericElementParameter)parameter;
          genericElementParameter.callBeforePresent();
          genericElementParameter.addPropertyChangeListener(dynamicComposite);
        }
      }
    }
  }
  return dynamicComposite;
}
Program: 118708
Project: 118708
Buggy source:
private void reset(boolean refresh){
  if (element instanceof FakeElement) {
    resetParameters();
  }
 else {
    resetElementParameters();
  }
  if (refresh) {
    Display.getDefault().asyncExec(new Runnable(){
      @Override public void run(){
        refresh();
      }
    }
);
  }
}

Fixed version (ground truth):
private void reset(boolean refresh){
  resetParameters();
  if (refresh) {
    Display.getDefault().asyncExec(new Runnable(){
      @Override public void run(){
        refresh();
      }
    }
);
  }
}
Program: 118713
Project: 118713
Buggy source:
public static Object getParameterValue(Property property){
  Object paramValue=property.getValue() != null ? property.getValue() : property.getDefaultValue();
  Property.Type propertyType=property.getType();
switch (propertyType) {
case STRING:
    paramValue=TalendQuoteUtils.addQuotesIfNotExist((String)paramValue);
  break;
case ENUM:
if (paramValue == null) {
  List<?> possibleValues=property.getPossibleValues();
  if (possibleValues != null && possibleValues.size() > 0) {
    paramValue=possibleValues.get(0);
  }
}
break;
default :
break;
}
return paramValue;
}

Fixed version (ground truth):
public static Object getParameterValue(IElement element,Property property){
  Object paramValue=property.getValue() != null ? property.getValue() : property.getDefaultValue();
  Property.Type propertyType=property.getType();
switch (propertyType) {
case STRING:
    if (!(element instanceof FakeElement)) {
      paramValue=TalendQuoteUtils.addQuotesIfNotExist((String)paramValue);
    }
  break;
case ENUM:
if (paramValue == null) {
  List<?> possibleValues=property.getPossibleValues();
  if (possibleValues != null && possibleValues.size() > 0) {
    paramValue=possibleValues.get(0);
  }
}
break;
default :
break;
}
return paramValue;
}
Program: 118715
Project: 118715
Buggy source:
public static Object getParameterValue(Property property){
  Object paramValue=property.getValue() != null ? property.getValue() : property.getDefaultValue();
  Property.Type propertyType=property.getType();
switch (propertyType) {
case STRING:
    paramValue=TalendQuoteUtils.addQuotesIfNotExist((String)paramValue);
  break;
case ENUM:
if (paramValue == null) {
  List<?> possibleValues=property.getPossibleValues();
  if (possibleValues != null && possibleValues.size() > 0) {
    paramValue=possibleValues.get(0);
  }
}
break;
default :
break;
}
return paramValue;
}

Fixed version (ground truth):
public static Object getParameterValue(IElement element,Property property){
  Object paramValue=property.getValue() != null ? property.getValue() : property.getDefaultValue();
  Property.Type propertyType=property.getType();
switch (propertyType) {
case STRING:
    if (!(element instanceof FakeElement)) {
      paramValue=TalendQuoteUtils.addQuotesIfNotExist((String)paramValue);
    }
  break;
case ENUM:
if (paramValue == null) {
  List<?> possibleValues=property.getPossibleValues();
  if (possibleValues != null && possibleValues.size() > 0) {
    paramValue=possibleValues.get(0);
  }
}
break;
default :
break;
}
return paramValue;
}
Program: 118718
Project: 118718
Buggy source:
private ComponentWizardDefinition getWizardDefinition(ComponentProperties componentProperties){
  if (componentProperties == null) {
    return null;
  }
  ComponentService service=ComponentsUtils.getComponentService();
  List<ComponentWizard> componentWizards=service.getComponentWizardsForProperties(componentProperties,null);
  for (  ComponentWizard componentWizard : componentWizards) {
    ComponentWizardDefinition definition=componentWizard.getDefinition();
    if (definition.isTopLevel()) {
      return definition;
    }
  }
  List<NamedThing> namedThings=componentProperties.getProperties();
  for (  NamedThing namedThing : namedThings) {
    if (namedThing instanceof ComponentProperties) {
      return getWizardDefinition((ComponentProperties)namedThing);
    }
  }
  return null;
}

Fixed version (ground truth):
private ComponentWizardDefinition getWizardDefinition(ComponentProperties componentProperties){
  ComponentWizardDefinition definition=null;
  if (componentProperties == null) {
    return null;
  }
  ComponentService service=ComponentsUtils.getComponentService();
  List<ComponentWizard> componentWizards=service.getComponentWizardsForProperties(componentProperties,null);
  for (  ComponentWizard componentWizard : componentWizards) {
    definition=componentWizard.getDefinition();
    if (definition.isTopLevel()) {
      return definition;
    }
  }
  List<NamedThing> namedThings=componentProperties.getProperties();
  for (  NamedThing namedThing : namedThings) {
    if (namedThing instanceof ComponentProperties) {
      definition=getWizardDefinition((ComponentProperties)namedThing);
      if (definition != null && definition.isTopLevel()) {
        return definition;
      }
    }
  }
  return null;
}
Program: 118719
Project: 118719
Buggy source:
public static Object getParameterValue(IElement element,Property property){
  Object paramValue=property.getValue() != null ? property.getValue() : property.getDefaultValue();
  Property.Type propertyType=property.getType();
switch (propertyType) {
case STRING:
    if (!(element instanceof FakeElement)) {
      paramValue=TalendQuoteUtils.addQuotesIfNotExist((String)paramValue);
    }
  break;
case ENUM:
if (paramValue == null) {
  List<?> possibleValues=property.getPossibleValues();
  if (possibleValues != null && possibleValues.size() > 0) {
    paramValue=possibleValues.get(0);
  }
}
break;
default :
break;
}
return paramValue;
}

Fixed version (ground truth):
public static Object getParameterValue(IElement element,Property property){
  Object paramValue=property.getValue() != null ? property.getValue() : property.getDefaultValue();
  Property.Type propertyType=property.getType();
switch (propertyType) {
case STRING:
    if (!(element instanceof FakeElement)) {
      paramValue=TalendQuoteUtils.addQuotesIfNotExist((String)paramValue);
    }
  break;
case ENUM:
if (paramValue == null) {
  List<?> possibleValues=property.getPossibleValues();
  if (possibleValues != null && possibleValues.size() > 0) {
    paramValue=possibleValues.get(0);
    property.setValue(paramValue);
  }
}
break;
default :
break;
}
return paramValue;
}
Program: 118720
Project: 118720
Buggy source:
public static Object getGenericPropertyValue(ComponentProperties componentProperties,String paramName){
  Object obj=null;
  if (componentProperties == null || paramName == null) {
    return null;
  }
  ComponentProperties currentComponentProperties=getCurrentComponentProperties(componentProperties,paramName);
  if (currentComponentProperties == null) {
    return null;
  }
  Property property=componentProperties.getValuedProperty(paramName);
  if (property != null) {
    obj=property.getValue();
  }
  return obj;
}

Fixed version (ground truth):
public static Object getGenericPropertyValue(ComponentProperties componentProperties,String paramName){
  if (componentProperties == null || paramName == null) {
    return null;
  }
  ComponentProperties currentComponentProperties=getCurrentComponentProperties(componentProperties,paramName);
  if (currentComponentProperties == null) {
    return null;
  }
  Property property=componentProperties.getValuedProperty(paramName);
  if (property != null) {
    return property.getValue() != null ? property.getValue() : property.getDefaultValue();
  }
  return null;
}
Program: 118723
Project: 118723
Buggy source:
/** 
 * This method determine if the 'Finish' button is enable This method is called when 'Finish' button is pressed in the wizard. We will create an operation and run it using wizard as execution context.
 */
@Override public boolean performFinish(){
  if (tableWizardPage.isPageComplete()) {
    GenericUpdateManager.updateSingleSchema(connectionItem,metadataTable,oldMetadataTable,oldTableMap);
    IProxyRepositoryFactory factory=CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
    try {
      factory.save(connectionItem);
      closeLockStrategy();
    }
 catch (    PersistenceException e) {
      new ErrorDialogWidthDetailArea(getShell(),IGenericConstants.REPOSITORY_PLUGIN_ID,Messages.getString("String_Node_Str"),ExceptionUtils.getFullStackTrace(e));
      ExceptionHandler.process(e);
    }
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
/** 
 * This method determine if the 'Finish' button is enable This method is called when 'Finish' button is pressed in the wizard. We will create an operation and run it using wizard as execution context.
 */
@Override public boolean performFinish(){
  if (tableWizardPage.isPageComplete()) {
    GenericUpdateManager.updateSingleSchema(connectionItem,metadataTable,oldMetadataTable,oldTableMap);
    IMetadataTable newTable=MetadataToolHelper.convert(metadataTable);
    if (!newTable.sameMetadataAs(oldMetadataTable)) {
      SchemaUtils.updateComponentSchema(metadataTable);
    }
    IProxyRepositoryFactory factory=CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
    try {
      factory.save(connectionItem);
      closeLockStrategy();
    }
 catch (    PersistenceException e) {
      new ErrorDialogWidthDetailArea(getShell(),IGenericConstants.REPOSITORY_PLUGIN_ID,Messages.getString("String_Node_Str"),ExceptionUtils.getFullStackTrace(e));
      ExceptionHandler.process(e);
    }
    return true;
  }
 else {
    return false;
  }
}
Program: 118724
Project: 118724
Buggy source:
@Override public Control createDialogArea(Composite parent){
  return createDialogArea(parent,null);
}

Fixed version (ground truth):
@Override protected Control createDialogArea(Composite parent){
  return createDialogArea(parent,null);
}
Program: 118725
Project: 118725
Buggy source:
@Override public boolean select(Viewer viewer,Object parentElement,Object element){
  if (jobTopTester.isStandardNode(element) && RepositoryNodeFilterHelper.isActivedFilter()) {
    final String filterByNodeKey=RepositoryNodeFilterHelper.getFilterByNodeKey(RepositoryNodeFilterHelper.getPerspectiveId(),PerspectiveFilterHelper.isActivedPerspectiveFilter());
    String[] filterByNode=RepositoryNodeFilterHelper.getFiltersByPreferenceKey(filterByNodeKey);
    if (filterByNode != null) {
      List<String> filterList=Arrays.asList(filterByNode);
      if (filterList.contains(element.getClass().getName())) {
        return false;
      }
    }
  }
 else   if (element instanceof RepositoryNode) {
    RepositoryNode repositoryNode=(RepositoryNode)element;
    if (repositoryNode.getParent() != null && jobTopTester.isJobDesignsNode(repositoryNode.getParent())) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * only check for standard node only,when the repository filter was enabled
 */
@Override public boolean select(Viewer viewer,Object parentElement,Object element){
  if (jobTopTester.isStandardNode(element) && RepositoryNodeFilterHelper.isActivedFilter()) {
    final String filterByNodeKey=RepositoryNodeFilterHelper.getFilterByNodeKey(RepositoryNodeFilterHelper.getPerspectiveId(),PerspectiveFilterHelper.isActivedPerspectiveFilter());
    String[] filterByNode=RepositoryNodeFilterHelper.getFiltersByPreferenceKey(filterByNodeKey);
    if (filterByNode != null) {
      List<String> filterList=Arrays.asList(filterByNode);
      if (filterList.contains(element.getClass().getName())) {
        return false;
      }
    }
  }
  return true;
}
Program: 118726
Project: 118726
Buggy source:
public RepositoryChangeMetadataCommand(Node node,String propName,Object propValue,IMetadataTable newOutputMetadata,String newRepositoryIdValue,Connection connection){
  super(node,node.getElementParameter(propName) == null ? null : node.getElementParameter(propName).getParentParameter(),null,newOutputMetadata,node.getElementParameter(propName) == null ? null : node.getElementParameter(propName).getParentParameter());
  this.propName=propName;
  oldPropValue=node.getPropertyValue(propName);
  newPropValue=propValue;
  this.node=node;
  this.newRepositoryIdValue=newRepositoryIdValue;
  this.setRepositoryMode(true);
  this.connection=connection;
}

Fixed version (ground truth):
public RepositoryChangeMetadataCommand(Node node,String propName,Object propValue,IMetadataTable newOutputMetadata,String newRepositoryIdValue,Connection connection,MetadataTable orginalTable){
  this(node,propName,propValue,newOutputMetadata,newRepositoryIdValue,connection);
  this.orginalTable=orginalTable;
}
Program: 118730
Project: 118730
Buggy source:
@Override public List<NodeReturn> createReturns(){
  List<NodeReturn> listReturn=new ArrayList<NodeReturn>();
  NodeReturn nodeRet=new NodeReturn();
  nodeRet.setAvailability("String_Node_Str");
  nodeRet.setType(STRING_TYPE);
  nodeRet.setVarName("String_Node_Str");
  nodeRet.setDisplayName("String_Node_Str");
  nodeRet.setName("String_Node_Str");
  listReturn.add(nodeRet);
  return listReturn;
}

Fixed version (ground truth):
@Override public List<NodeReturn> createReturns(){
  List<NodeReturn> listReturn=new ArrayList<>();
  ComponentProperties props=ComponentsUtils.getComponentProperties(getName());
  Property returns=props.returns;
  if (returns != null) {
    NodeReturn nodeRet=null;
    for (    Property children : returns.getChildren()) {
      nodeRet=new NodeReturn();
      nodeRet.setType(children.getType().name());
      nodeRet.setDisplayName(children.getDisplayName());
      nodeRet.setName(children.getName());
      Object object=children.getTaggedValue(IGenericConstants.AVAILABILITY);
      if (object != null) {
        nodeRet.setAvailability(object.toString());
      }
 else {
        nodeRet.setAvailability("String_Node_Str");
      }
      listReturn.add(nodeRet);
    }
  }
  return listReturn;
}
Program: 118731
Project: 118731
Buggy source:
/** 
 * Getter for log. Will be used by ComponentUtil.
 * @return the log
 */
static Logger getLog(){
  return log;
}

Fixed version (ground truth):
/** 
 * Getter for log. Will be used by ComponentUtil.
 * @return the log
 */
public static Logger getLog(){
  return log;
}
Program: 118733
Project: 118733
Buggy source:
@Override protected Control createDialogArea(Composite parent){
  return createDialogArea(parent,null);
}

Fixed version (ground truth):
@Override public Control createDialogArea(Composite parent){
  return createDialogArea(parent,null);
}
Program: 118735
Project: 118735
Buggy source:
@Override public List<ElementParameter> createElementParameters(INode node){
  List<ElementParameter> listParam;
  listParam=new ArrayList<>();
  addMainParameters(listParam,node);
  addPropertyParameters(listParam,node,Form.MAIN,EComponentCategory.BASIC);
  addPropertyParameters(listParam,node,Form.ADVANCED,EComponentCategory.ADVANCED);
  initializePropertyParameters(listParam,node);
  addViewParameters(listParam,node);
  addDocParameters(listParam,node);
  addValidationRulesParameters(listParam,node);
  return listParam;
}

Fixed version (ground truth):
@Override public List<ElementParameter> createElementParameters(INode node){
  node.setComponentProperties(ComponentsUtils.getComponentProperties(getName()));
  List<ElementParameter> listParam;
  listParam=new ArrayList<>();
  addMainParameters(listParam,node);
  addPropertyParameters(listParam,node,Form.MAIN,EComponentCategory.BASIC);
  addPropertyParameters(listParam,node,Form.ADVANCED,EComponentCategory.ADVANCED);
  initializePropertyParameters(listParam,node);
  addViewParameters(listParam,node);
  addDocParameters(listParam,node);
  addValidationRulesParameters(listParam,node);
  return listParam;
}
Program: 118737
Project: 118737
Buggy source:
private boolean checkAssociatedFromComponentProperties(ComponentProperties componentProperties,ComponentService service){
  if (componentProperties == null || service == null) {
    return false;
  }
  List componentWizards=service.getComponentWizardsForProperties(componentProperties,null);
  if (componentWizards != null && !componentWizards.isEmpty()) {
    return true;
  }
  List<NamedThing> namedThings=componentProperties.getProperties();
  for (  NamedThing namedThing : namedThings) {
    if (namedThing instanceof ComponentProperties) {
      boolean associated=checkAssociatedFromComponentProperties((ComponentProperties)namedThing,service);
      if (associated) {
        return true;
      }
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean checkAssociatedFromComponentProperties(ComponentProperties componentProperties){
  if (componentProperties == null) {
    return false;
  }
  ComponentService service=ComponentsUtils.getComponentService();
  List<ComponentWizard> componentWizards=service.getComponentWizardsForProperties(componentProperties,null);
  if (componentWizards != null && !componentWizards.isEmpty()) {
    return true;
  }
  List<NamedThing> namedThings=componentProperties.getProperties();
  for (  NamedThing namedThing : namedThings) {
    if (namedThing instanceof ComponentProperties) {
      boolean associated=checkAssociatedFromComponentProperties((ComponentProperties)namedThing);
      if (associated) {
        return true;
      }
    }
  }
  return false;
}
Program: 118738
Project: 118738
Buggy source:
private void addPropertyParameters(final List<ElementParameter> listParam,final INode node,String formName,EComponentCategory category){
  ComponentProperties props=ComponentsUtils.getComponentProperties(getName());
  Form form=props.getForm(formName);
  if (node.getComponentProperties() != null) {
    props=node.getComponentProperties();
    form=props.getForm(formName);
  }
  List<ElementParameter> parameters=ComponentsUtils.getParametersFromForm(node,category,node.getComponentProperties(),null,form,null,null);
  ComponentService componentService=new ComponentServiceWithValueEvaluator(ComponentsUtils.getComponentService(),new ComponentContextPropertyValueEvaluator(node));
  for (  ElementParameter parameter : parameters) {
    if (parameter instanceof GenericElementParameter) {
      GenericElementParameter genericElementParameter=(GenericElementParameter)parameter;
      genericElementParameter.setComponentService(componentService);
    }
  }
  listParam.addAll(parameters);
}

Fixed version (ground truth):
private void addPropertyParameters(final List<ElementParameter> listParam,final INode node,String formName,EComponentCategory category){
  ComponentProperties props=node.getComponentProperties();
  Form form=props.getForm(formName);
  List<ElementParameter> parameters=ComponentsUtils.getParametersFromForm(node,category,node.getComponentProperties(),null,form,null,null);
  ComponentService componentService=new ComponentServiceWithValueEvaluator(ComponentsUtils.getComponentService(),new ComponentContextPropertyValueEvaluator(node));
  for (  ElementParameter parameter : parameters) {
    if (parameter instanceof GenericElementParameter) {
      GenericElementParameter genericElementParameter=(GenericElementParameter)parameter;
      genericElementParameter.setComponentService(componentService);
    }
  }
  listParam.addAll(parameters);
}
Program: 118739
Project: 118739
Buggy source:
private String getParameterName(){
  String paramName=getName();
  if (paramName.indexOf(IGenericConstants.UNDERLINE_SEPARATOR) != -1) {
    paramName=paramName.substring(paramName.lastIndexOf(IGenericConstants.UNDERLINE_SEPARATOR) + 1);
  }
  Properties currentComponentProperties=ComponentsUtils.getCurrentComponentProperties(componentProperties,paramName);
  if (currentComponentProperties == null) {
    if (paramName.startsWith(componentProperties.getName())) {
      paramName=ComponentsUtils.getPropertyName(paramName);
    }
  }
  return paramName;
}

Fixed version (ground truth):
private String getParameterName(){
  String paramName=getName();
  if (paramName.indexOf(IGenericConstants.EXP_SEPARATOR) != -1) {
    paramName=paramName.substring(paramName.lastIndexOf(IGenericConstants.EXP_SEPARATOR) + 1);
  }
  return paramName;
}
Program: 118740
Project: 118740
Buggy source:
public boolean callBeforePresent(){
  if (widget.isCallBeforePresent()) {
    try {
      componentProperties=componentService.beforePropertyPresent(getParameterName(),componentProperties);
      return true;
    }
 catch (    Throwable e) {
      ExceptionHandler.process(e);
    }
  }
  return false;
}

Fixed version (ground truth):
public boolean callBeforePresent(){
  if (widget.isCallBeforePresent() && hasPropertyChangeListener()) {
    return new ComponentServiceCaller(widget.getContent().getDisplayName(),widget.isLongRunning()){
      @Override protected void doWork() throws Throwable {
        componentProperties=componentService.beforePropertyPresent(getParameterName(),componentProperties);
      }
    }
.call();
  }
  return false;
}
Program: 118741
Project: 118741
Buggy source:
private boolean callValidate(){
  if (widget.isCallValidate()) {
    if (widget.isLongRunning()) {
      return new RunWithProgress(widget.getContent().getDisplayName()){
        @Override protected void toDo() throws Throwable {
          componentProperties=componentService.validateProperty(getParameterName(),componentProperties);
        }
      }
.run();
    }
 else {
      try {
        componentProperties=componentService.validateProperty(getParameterName(),componentProperties);
        return true;
      }
 catch (      Throwable e) {
        ExceptionHandler.process(e);
      }
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean callValidate(){
  if (widget.isCallValidate() && hasPropertyChangeListener()) {
    return new ComponentServiceCaller(widget.getContent().getDisplayName(),widget.isLongRunning()){
      @Override protected void doWork() throws Throwable {
        componentProperties=componentService.validateProperty(getParameterName(),componentProperties);
      }
    }
.call();
  }
  return false;
}
Program: 118742
Project: 118742
Buggy source:
public boolean callBeforeActivate(){
  if (widget.isCallBeforeActivate()) {
    try {
      componentProperties=componentService.beforePropertyActivate(getParameterName(),componentProperties);
      update();
      return true;
    }
 catch (    Throwable e) {
      ExceptionHandler.process(e);
    }
  }
  return false;
}

Fixed version (ground truth):
public boolean callBeforeActivate(){
  if (widget.isCallBeforeActivate() && hasPropertyChangeListener()) {
    return new ComponentServiceCaller(widget.getContent().getDisplayName(),widget.isLongRunning()){
      @Override protected void doWork() throws Throwable {
        componentProperties=componentService.beforePropertyActivate(getParameterName(),componentProperties);
        update();
      }
    }
.call();
  }
  return false;
}
Program: 118743
Project: 118743
Buggy source:
private boolean callAfter(){
  if (widget.isCallAfter() && hasPropertyChangeListener()) {
    try {
      componentProperties=componentService.afterProperty(getParameterName(),componentProperties);
      updateSchema();
      return true;
    }
 catch (    Throwable e) {
      ExceptionHandler.process(e);
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean callAfter(){
  if (widget.isCallAfter() && hasPropertyChangeListener()) {
    return new ComponentServiceCaller(widget.getContent().getDisplayName(),widget.isLongRunning()){
      @Override protected void doWork() throws Throwable {
        componentProperties=componentService.afterProperty(getParameterName(),componentProperties);
        updateSchema();
      }
    }
.call();
  }
  return false;
}
Program: 118744
Project: 118744
Buggy source:
private void fireValueChangedEvent(){
  if (hasPropertyChangeListener()) {
    List<Form> forms=componentProperties.getForms();
    for (    Form form : forms) {
      if (form.isRefreshUI()) {
        this.pcs.firePropertyChange(IElementParameterEventProperties.EVENT_PROPERTY_VALUE_CHANGED,null,null);
        return;
      }
    }
  }
}

Fixed version (ground truth):
private void fireValueChangedEvent(){
  if (hasPropertyChangeListener()) {
    List<Form> forms=componentProperties.getForms();
    for (    Form f : forms) {
      if (f.isRefreshUI()) {
        this.pcs.firePropertyChange(IElementParameterEventProperties.EVENT_PROPERTY_VALUE_CHANGED,null,null);
        return;
      }
    }
  }
}
Program: 118753
Project: 118753
Buggy source:
private Object getGenericRepositoryValue(GenericConnection connection,String value,IMetadataTable table){
  if (connection == null) {
    return null;
  }
  ComponentProperties componentProperties=ComponentsUtils.getComponentPropertiesFromSerialized(connection.getCompProperties());
  String paramName=ComponentsUtils.getPropertyName(value);
  if (value != null && value.startsWith(componentProperties.getName())) {
    if (value.indexOf(IGenericConstants.EXP_SEPARATOR) != -1) {
      value=value.substring(componentProperties.getName().length() + 1,value.length());
    }
  }
  Object object=ComponentsUtils.getGenericPropertyValue(componentProperties,value);
  if (object != null && object instanceof String) {
    return getRepositoryValueOfStringType(connection,StringUtils.trimToNull(object.toString()));
  }
  return ComponentsUtils.getGenericPropertyValue(componentProperties,value);
}

Fixed version (ground truth):
private Object getGenericRepositoryValue(GenericConnection connection,String value,IMetadataTable table){
  ComponentProperties componentProperties=ComponentsUtils.getComponentPropertiesFromSerialized(connection.getCompProperties());
  String paramName=ComponentsUtils.getPropertyName(value);
  if (value != null && value.startsWith(componentProperties.getName())) {
    if (value.indexOf(IGenericConstants.EXP_SEPARATOR) != -1) {
      value=value.substring(componentProperties.getName().length() + 1,value.length());
    }
  }
  boolean found=false;
  List<Property> allValuedProperties=ComponentsUtils.getAllValuedProperties(componentProperties);
  for (  Property property : allValuedProperties) {
    if (paramName != null && paramName.equals(property.getName())) {
      found=true;
    }
  }
  Object object=null;
  if (found) {
    object=ComponentsUtils.getGenericPropertyValue(componentProperties,value);
  }
 else {
    for (    ModelElement modelElement : connection.getOwnedElement()) {
      if (modelElement instanceof SubContainer) {
        SubContainer subContainer=(SubContainer)modelElement;
        ComponentProperties subComponentProperties=ComponentsUtils.getComponentPropertiesFromSerialized(subContainer.getCompProperties());
        if (value.indexOf(IGenericConstants.EXP_SEPARATOR) != -1) {
          value=value.substring(value.indexOf(IGenericConstants.EXP_SEPARATOR) + 1,value.length());
        }
        return ComponentsUtils.getGenericPropertyValue(subComponentProperties,value);
      }
    }
  }
  if (object != null) {
    if (object instanceof String && value != null && value.indexOf(IGenericConstants.EXP_SEPARATOR) != -1) {
      return getRepositoryValueOfStringType(connection,StringUtils.trimToNull(object.toString()));
    }
  }
  return ComponentsUtils.getGenericPropertyValue(componentProperties,value);
}
Program: 118754
Project: 118754
Buggy source:
@Override public Object getElementParameterValueFromComponentProperties(INode iNode,IElementParameter param){
  if (iNode != null) {
    ComponentProperties iNodeComponentProperties=iNode.getComponentProperties();
    if (iNodeComponentProperties != null && param instanceof GenericElementParameter) {
      ComponentProperties paramComponentProperties=ComponentsUtils.getCurrentComponentProperties(iNodeComponentProperties,param.getName());
      if (paramComponentProperties != null) {
        ((GenericElementParameter)param).setComponentProperties(paramComponentProperties);
        return ComponentsUtils.getGenericPropertyValue(iNodeComponentProperties,param.getName());
      }
    }
  }
  return null;
}

Fixed version (ground truth):
@Override public Object getElementParameterValueFromComponentProperties(INode iNode,IElementParameter param){
  if (iNode != null) {
    ComponentProperties iNodeComponentProperties=iNode.getComponentProperties();
    if (iNodeComponentProperties != null && param instanceof GenericElementParameter) {
      ComponentProperties paramComponentProperties=ComponentsUtils.getCurrentComponentProperties(iNodeComponentProperties,param.getName());
      if (paramComponentProperties != null) {
        ((GenericElementParameter)param).setComponentProperties(paramComponentProperties);
        Property property=iNodeComponentProperties.getValuedProperty(param.getName());
        if (property != null) {
          if (property.getTaggedValue(IComponentConstants.REPOSITORY_VALUE) != null) {
            param.setRepositoryValue(param.getName());
            param.setRepositoryValueUsed(true);
          }
        }
        return ComponentsUtils.getGenericPropertyValue(iNodeComponentProperties,param.getName());
      }
    }
  }
  return null;
}
Program: 118759
Project: 118759
Buggy source:
@Override public ERepositoryObjectType findParentItemType(RepositoryNode repositoryNode){
  final ERepositoryObjectType objectType=repositoryNode.getObjectType();
  if (objectType == ERepositoryObjectType.METADATA_CON_TABLE) {
    if (repositoryNode.getObject() != null) {
      ERepositoryObjectType parentType=ERepositoryObjectType.getItemType(repositoryNode.getObject().getProperty().getItem());
      return parentType;
    }
  }
  return null;
}

Fixed version (ground truth):
@Override public ERepositoryObjectType findParentItemType(RepositoryNode repositoryNode){
  final ERepositoryObjectType objectType=repositoryNode.getObjectType();
  if (objectType == ERepositoryObjectType.METADATA_CON_TABLE) {
    if (repositoryNode.getObject() != null) {
      ERepositoryObjectType parentType=null;
      if (repositoryNode.getObject() instanceof MetadataTableRepositoryObject) {
        MetadataTableRepositoryObject object=(MetadataTableRepositoryObject)repositoryNode.getObject();
        String itemId=object.getViewObject().getId();
        parentType=ERepositoryObjectType.getTypeCacheById().get(itemId);
        if (parentType == null) {
          parentType=ERepositoryObjectType.getType(object.getViewObject().getProperty());
        }
      }
 else {
        parentType=ERepositoryObjectType.getType(repositoryNode.getObject().getProperty());
      }
      return parentType;
    }
  }
  return null;
}
Program: 118760
Project: 118760
Buggy source:
/** 
 * Test method for  {@link org.talend.designer.core.model.process.ConnectionManager#canRename(org.talend.designer.core.ui.editor.nodes.Node,org.talend.designer.core.ui.editor.nodes.Node,org.talend.core.model.process.EConnectionType,java.lang.String)}.
 */
@Test public void testCanRename(){
  try {
    connection=new Connection(source,target,EConnectionType.FLOW_MAIN,EConnectionType.FLOW_MAIN.getName(),"String_Node_Str","String_Node_Str","String_Node_Str",false);
    boolean canRename=ConnectionManager.canRename(source,target,EConnectionType.FLOW_MAIN,"String_Node_Str");
    assertTrue(canRename);
    canRename=ConnectionManager.canRename(source,target,EConnectionType.FLOW_MAIN,"String_Node_Str");
    assertTrue(!canRename);
  }
 catch (  Exception e) {
    e.printStackTrace();
    fail("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Test method for  {@link org.talend.designer.core.model.process.ConnectionManager#canRename(org.talend.designer.core.ui.editor.nodes.Node,org.talend.designer.core.ui.editor.nodes.Node,org.talend.core.model.process.EConnectionType,java.lang.String)}.
 */
@Test public void testCanRename(){
  try {
    connection=new Connection(source,target,EConnectionType.FLOW_MAIN,EConnectionType.FLOW_MAIN.getName(),"String_Node_Str","String_Node_Str","String_Node_Str",false);
    boolean canRename=ConnectionManager.canRename(source,target,EConnectionType.FLOW_MAIN,"String_Node_Str");
    assertTrue(canRename);
    canRename=ConnectionManager.canRename(source,target,EConnectionType.FLOW_MAIN,"String_Node_Str");
    assertTrue(canRename);
  }
 catch (  Exception e) {
    e.printStackTrace();
    fail("String_Node_Str");
  }
}
Program: 118761
Project: 118761
Buggy source:
@Test public void testformatTimeNull(){
  String result=NodeContainerUtils.formatTime(null);
  assertNull(result);
}

Fixed version (ground truth):
@Test public void testformatTimeNull(){
  String result=NodeContainerUtils.formatTime(null);
  assertEquals(result,"String_Node_Str");
}
Program: 118762
Project: 118762
Buggy source:
@Override public Object evaluate(Property property,Object storedValue){
  IContext context=null;
  if (node != null) {
    IProcess process=node.getProcess();
    if (process != null) {
      IContextManager cm=process.getContextManager();
      if (cm != null) {
        context=cm.getDefaultContext();
      }
    }
  }
  if (context != null) {
    return ContextParameterUtils.parseScriptContextCode(String.valueOf(storedValue),context);
  }
  return storedValue;
}

Fixed version (ground truth):
@Override public Object evaluate(Property property,Object storedValue){
  if (storedValue == null) {
    return storedValue;
  }
  IContext context=null;
  if (node != null) {
    IProcess process=node.getProcess();
    if (process != null) {
      IContextManager cm=process.getContextManager();
      if (cm != null) {
        context=cm.getDefaultContext();
      }
    }
  }
  if (context != null) {
    return ContextParameterUtils.parseScriptContextCode(String.valueOf(storedValue),context);
  }
  return storedValue;
}
Program: 118763
Project: 118763
Buggy source:
protected void collectConnParams(){
  if (getConnection().isInputModel()) {
    addContextParams(EFileParamName.File,true);
    addContextParams(EFileParamName.Encoding,true);
    addContextParams(EParamName.XPathQuery,true);
  }
 else {
    addContextParams(EParamName.OutputFilePath,true);
  }
}

Fixed version (ground truth):
protected void collectConnParams(){
  if (getConnection().isInputModel()) {
    addContextParams(EParamName.FilePath,true);
    addContextParams(EParamName.Encoding,true);
    addContextParams(EParamName.XPathQuery,true);
  }
 else {
    addContextParams(EParamName.OutputFilePath,true);
  }
}
Program: 118764
Project: 118764
Buggy source:
/** 
 * Initialize value, forceFocus first field.
 */
@Override protected void initialize(){
  availableJSONTreeViewer=new TreeViewer(availableJSONTree);
  currentReadbyMode=this.wizard.getReadbyMode();
  initTreePopulator();
  checkFieldsValue();
  if (jsonXPathLoopDescriptor == null) {
    if (getConnection().getSchema() != null && !getConnection().getSchema().isEmpty()) {
      jsonXPathLoopDescriptor=getConnection().getSchema().get(0);
      jsonFilePath=getConnection().getJSONFilePath();
      if (isContextMode()) {
        ContextType contextType=ConnectionContextHelper.getContextTypeForContextMode(connectionItem.getConnection(),connectionItem.getConnection().getContextName());
        jsonFilePath=TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType,jsonFilePath));
      }
    }
 else {
      jsonXPathLoopDescriptor=JsonFactory.eINSTANCE.createJSONXPathLoopDescriptor();
      getConnection().getSchema().add(jsonXPathLoopDescriptor);
    }
  }
  loopModel.setJSONXPathLoopDescriptor(jsonXPathLoopDescriptor);
  if (jsonXPathLoopDescriptor.getLimitBoucle() == null) {
    jsonXPathLoopDescriptor.setLimitBoucle(-1);
    XmlArray.setLimitToDefault();
    jsonXPathLoopDescriptor.setLimitBoucle(XmlArray.getRowLimit());
  }
  fieldsModel.setJSONXPathLoopDescriptor(jsonXPathLoopDescriptor.getSchemaTargets());
  fieldsTableEditorView.getTableViewerCreator().layout();
  if (isContextMode()) {
    adaptFormToEditable();
  }
}

Fixed version (ground truth):
/** 
 * Initialize value, forceFocus first field.
 */
@Override protected void initialize(){
  availableJSONTreeViewer=new TreeViewer(availableJSONTree);
  currentReadbyMode=this.wizard.getReadbyMode();
  initTreePopulator();
  checkFieldsValue();
  if (jsonXPathLoopDescriptor == null) {
    if (getConnection().getSchema() != null && !getConnection().getSchema().isEmpty()) {
      jsonXPathLoopDescriptor=getConnection().getSchema().get(0);
      jsonFilePath=getConnection().getJSONFilePath();
      if (isContextMode()) {
        ContextType contextType=ConnectionContextHelper.getContextTypeForContextMode(connectionItem.getConnection(),connectionItem.getConnection().getContextName());
        jsonFilePath=TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType,jsonFilePath));
      }
    }
 else {
      jsonXPathLoopDescriptor=JsonFactory.eINSTANCE.createJSONXPathLoopDescriptor();
      getConnection().getSchema().add(jsonXPathLoopDescriptor);
    }
  }
  loopModel.setJSONXPathLoopDescriptor(jsonXPathLoopDescriptor);
  if (jsonXPathLoopDescriptor.getLimitBoucle() == null) {
    jsonXPathLoopDescriptor.setLimitBoucle(-1);
    XmlArray.setLimitToDefault();
    jsonXPathLoopDescriptor.setLimitBoucle(XmlArray.getRowLimit());
  }
  treePopulator.populateTree(wizard.getTempJsonPath(),treeNode);
  fieldsModel.setJSONXPathLoopDescriptor(jsonXPathLoopDescriptor.getSchemaTargets());
  fieldsTableEditorView.getTableViewerCreator().layout();
  if (isContextMode()) {
    adaptFormToEditable();
  }
}
Program: 118765
Project: 118765
Buggy source:
@Override protected TreeItem getTreeItem(Tree tree,Object dataOfTreeItem,Object dataOfTableItem){
  String path=null;
  if (dataOfTableItem instanceof SchemaTarget) {
    SchemaTarget target=(SchemaTarget)dataOfTableItem;
    path=target.getRelativeXPathQuery();
  }
 else   if (dataOfTableItem instanceof JSONXPathLoopDescriptor) {
    JSONXPathLoopDescriptor target=(JSONXPathLoopDescriptor)dataOfTableItem;
    path=target.getAbsoluteXPathQuery();
  }
  if (path == null) {
    return super.getTreeItem(tree,dataOfTreeItem,dataOfTableItem);
  }
  boolean expressionIsAbsolute=false;
  if (path.trim().startsWith(getRootSeperator())) {
    expressionIsAbsolute=true;
  }
  String fullPath="String_Node_Str";
  if (!expressionIsAbsolute) {
    if (0 < loopXpathNodes.size()) {
      fullPath=loopXpathNodes.get(0) + getFieldSeperator();
    }
    fullPath=fullPath + path;
  }
 else {
    fullPath=path;
  }
  TreeItem treeItem=treePopulator.getTreeItem(fullPath);
  if (treeItem != null) {
    return treeItem;
  }
 else {
    return super.getTreeItem(tree,dataOfTreeItem,dataOfTableItem);
  }
}

Fixed version (ground truth):
@Override protected TreeItem getTreeItem(Tree tree,Object dataOfTreeItem,Object dataOfTableItem){
  String path=null;
  if (dataOfTableItem instanceof SchemaTarget) {
    SchemaTarget target=(SchemaTarget)dataOfTableItem;
    path=target.getRelativeXPathQuery();
  }
 else   if (dataOfTableItem instanceof JSONXPathLoopDescriptor) {
    JSONXPathLoopDescriptor target=(JSONXPathLoopDescriptor)dataOfTableItem;
    path=target.getAbsoluteXPathQuery();
    if (target.getConnection().isContextMode()) {
      ContextType contextType=ConnectionContextHelper.getContextTypeForContextMode(target.getConnection(),target.getConnection().getContextName());
      path=TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType,path));
    }
  }
  if (path == null) {
    return super.getTreeItem(tree,dataOfTreeItem,dataOfTableItem);
  }
  boolean expressionIsAbsolute=false;
  if (path.trim().startsWith(getRootSeperator())) {
    expressionIsAbsolute=true;
  }
  String fullPath="String_Node_Str";
  if (!expressionIsAbsolute) {
    if (0 < loopXpathNodes.size()) {
      fullPath=loopXpathNodes.get(0) + getFieldSeperator();
    }
    fullPath=fullPath + path;
  }
 else {
    fullPath=path;
  }
  TreeItem treeItem=treePopulator.getTreeItem(fullPath);
  if (treeItem != null) {
    return treeItem;
  }
 else {
    return super.getTreeItem(tree,dataOfTreeItem,dataOfTableItem);
  }
}
Program: 118766
Project: 118766
Buggy source:
static void setJSONFilePropertiesForContextMode(String prefixName,JSONFileConnection conn){
  if (conn == null || prefixName == null) {
    return;
  }
  prefixName=prefixName + LINE;
  String paramName=null;
  if (conn.isInputModel()) {
    paramName=prefixName + EParamName.XmlFilePath;
    conn.setJSONFilePath(ContextParameterUtils.getNewScriptCode(paramName,LANGUAGE));
    paramName=prefixName + EParamName.Encoding;
    conn.setEncoding(ContextParameterUtils.getNewScriptCode(paramName,LANGUAGE));
    EList schema=conn.getSchema();
    if (schema != null) {
      if (schema.get(0) instanceof JSONXPathLoopDescriptor) {
        JSONXPathLoopDescriptor descriptor=(JSONXPathLoopDescriptor)schema.get(0);
        paramName=prefixName + EParamName.XPathQuery;
        descriptor.setAbsoluteXPathQuery(ContextParameterUtils.getNewScriptCode(paramName,LANGUAGE));
      }
    }
  }
 else {
    paramName=prefixName + EParamName.OutputFilePath;
    conn.setOutputFilePath(ContextParameterUtils.getNewScriptCode(paramName,LANGUAGE));
  }
}

Fixed version (ground truth):
static void setJSONFilePropertiesForContextMode(String prefixName,JSONFileConnection conn){
  if (conn == null || prefixName == null) {
    return;
  }
  prefixName=prefixName + LINE;
  String paramName=null;
  if (conn.isInputModel()) {
    paramName=prefixName + EParamName.FilePath;
    conn.setJSONFilePath(ContextParameterUtils.getNewScriptCode(paramName,LANGUAGE));
    paramName=prefixName + EParamName.Encoding;
    conn.setEncoding(ContextParameterUtils.getNewScriptCode(paramName,LANGUAGE));
    EList schema=conn.getSchema();
    if (schema != null) {
      if (schema.get(0) instanceof JSONXPathLoopDescriptor) {
        JSONXPathLoopDescriptor descriptor=(JSONXPathLoopDescriptor)schema.get(0);
        paramName=prefixName + EParamName.XPathQuery;
        descriptor.setAbsoluteXPathQuery(ContextParameterUtils.getNewScriptCode(paramName,LANGUAGE));
      }
    }
  }
 else {
    paramName=prefixName + EParamName.OutputFilePath;
    conn.setOutputFilePath(ContextParameterUtils.getNewScriptCode(paramName,LANGUAGE));
  }
}