Program: 118793
Project: 118793
Buggy source:
/** 
 * DOC ycbai Comment method "loadParametersFromForm". <p> Get element parameters of <code>element</code> from <code>form</code>.
 * @param node optional, used if there is a component setting up the properties
 * @param element
 * @param category
 * @param form
 * @return parameters list
 */
public static List<ElementParameter> getParametersFromForm(IElement element,EComponentCategory category,ComponentProperties compProperties,String parentPropertiesPath,Form form,Widget parentWidget,AtomicInteger lastRowNum){
  List<ElementParameter> elementParameters=new ArrayList<>();
  EComponentCategory compCategory=category;
  if (compCategory == null) {
    compCategory=EComponentCategory.BASIC;
  }
  AtomicInteger lastRN=lastRowNum;
  if (lastRN == null) {
    lastRN=new AtomicInteger();
  }
  if (form == null) {
    return elementParameters;
  }
  ComponentProperties componentProperties=compProperties;
  if (componentProperties == null) {
    componentProperties=form.getProperties();
  }
  if (element instanceof INode) {
    INode node=(INode)element;
    if (node.getComponentProperties() == null) {
      node.setComponentProperties(componentProperties);
    }
  }
  componentProperties.getProperties();
  List<Widget> formWidgets=form.getWidgets();
  for (  Widget widget : formWidgets) {
    NamedThing[] widgetProperties=widget.getProperties();
    NamedThing widgetProperty=widgetProperties[0];
    String propertiesPath=getPropertiesPath(parentPropertiesPath);
    if (widgetProperty instanceof Form) {
      Form subForm=(Form)widgetProperty;
      ComponentProperties subProperties=subForm.getProperties();
      subProperties=(ComponentProperties)componentProperties.getProperty(subProperties.getClass());
      elementParameters.addAll(getParametersFromForm(element,compCategory,subProperties,propertiesPath,subForm,widget,lastRN));
      continue;
    }
    GenericElementParameter param=new GenericElementParameter(element,componentProperties,widget,getComponentService());
    String parameterName=propertiesPath.concat(param.getName());
    param.setName(parameterName);
    param.setCategory(compCategory);
    param.setRepositoryValue(widgetProperty.getName());
    param.setShow(parentWidget == null ? widget.isVisible() : parentWidget.isVisible() && widget.isVisible());
    int rowNum=0;
    if (widget.getOrder() != 1) {
      rowNum=lastRN.get();
    }
 else {
      rowNum=widget.getRow();
      if (parentWidget != null) {
        rowNum+=parentWidget.getRow();
      }
      rowNum=rowNum + lastRN.get();
    }
    param.setNumRow(rowNum);
    lastRN.set(rowNum);
    SchemaElement se=null;
    if (widgetProperty instanceof SchemaElement) {
      se=(SchemaElement)widgetProperties[0];
      param.setContext("String_Node_Str");
    }
    EParameterFieldType fieldType=getFieldType(widget,widgetProperty,se);
    param.setFieldType(fieldType != null ? fieldType : EParameterFieldType.TEXT);
    if (se == null) {
      param.setValue(widgetProperty.getDisplayName());
    }
 else {
      se=componentProperties.getProperty(se.getName());
      param.setRequired(se.isRequired());
      param.setValue(componentProperties.getValue(se));
      param.setSupportContext(true);
      List<?> values=se.getPossibleValues();
      if (values != null) {
        param.setPossibleValues(values);
        List<String> possVals=new ArrayList<>();
        List<String> possValsDisplay=new ArrayList<>();
        for (        Object obj : values) {
          if (obj instanceof NameAndLabel) {
            NameAndLabel nal=(NameAndLabel)obj;
            possVals.add(nal.getName());
            possValsDisplay.add(nal.getLabel());
          }
 else {
            possVals.add(String.valueOf(obj));
            possValsDisplay.add(String.valueOf(obj));
          }
        }
        param.setListItemsDisplayName(possValsDisplay.toArray(new String[0]));
        param.setListItemsDisplayCodeName(possValsDisplay.toArray(new String[0]));
        param.setListItemsValue(possVals.toArray(new String[0]));
      }
    }
    param.setReadOnly(false);
    param.setSerialized(true);
    elementParameters.add(param);
  }
  return elementParameters;
}

Fixed version (ground truth):
/** 
 * DOC ycbai Comment method "loadParametersFromForm". <p> Get element parameters of <code>element</code> from <code>form</code>.
 * @param node optional, used if there is a component setting up the properties
 * @param element
 * @param category
 * @param form
 * @return parameters list
 */
public static List<ElementParameter> getParametersFromForm(IElement element,EComponentCategory category,ComponentProperties compProperties,String parentPropertiesPath,Form form,Widget parentWidget,AtomicInteger lastRowNum){
  List<ElementParameter> elementParameters=new ArrayList<>();
  EComponentCategory compCategory=category;
  if (compCategory == null) {
    compCategory=EComponentCategory.BASIC;
  }
  AtomicInteger lastRN=lastRowNum;
  if (lastRN == null) {
    lastRN=new AtomicInteger();
  }
  if (form == null) {
    return elementParameters;
  }
  ComponentProperties componentProperties=compProperties;
  if (componentProperties == null) {
    componentProperties=form.getComponentProperties();
  }
  if (element instanceof INode) {
    INode node=(INode)element;
    if (node.getComponentProperties() == null) {
      node.setComponentProperties(componentProperties);
    }
  }
  componentProperties.getProperties();
  List<Widget> formWidgets=form.getWidgets();
  for (  Widget widget : formWidgets) {
    NamedThing[] widgetProperties=widget.getProperties();
    NamedThing widgetProperty=widgetProperties[0];
    String propertiesPath=getPropertiesPath(parentPropertiesPath);
    if (widgetProperty instanceof Form) {
      Form subForm=(Form)widgetProperty;
      ComponentProperties subProperties=subForm.getComponentProperties();
      subProperties=(ComponentProperties)componentProperties.getProperty(subProperties.getClass());
      elementParameters.addAll(getParametersFromForm(element,compCategory,subProperties,propertiesPath,subForm,widget,lastRN));
      continue;
    }
    GenericElementParameter param=new GenericElementParameter(element,componentProperties,widget,getComponentService());
    String parameterName=propertiesPath.concat(param.getName());
    param.setName(parameterName);
    param.setCategory(compCategory);
    param.setRepositoryValue(widgetProperty.getName());
    param.setShow(parentWidget == null ? widget.isVisible() : parentWidget.isVisible() && widget.isVisible());
    int rowNum=0;
    if (widget.getOrder() != 1) {
      rowNum=lastRN.get();
    }
 else {
      rowNum=widget.getRow();
      if (parentWidget != null) {
        rowNum+=parentWidget.getRow();
      }
      rowNum=rowNum + lastRN.get();
    }
    param.setNumRow(rowNum);
    lastRN.set(rowNum);
    SchemaElement se=null;
    if (widgetProperty instanceof SchemaElement) {
      se=(SchemaElement)widgetProperties[0];
      param.setContext("String_Node_Str");
    }
    EParameterFieldType fieldType=getFieldType(widget,widgetProperty,se);
    param.setFieldType(fieldType != null ? fieldType : EParameterFieldType.TEXT);
    if (se == null) {
      param.setValue(widgetProperty.getDisplayName());
    }
 else {
      se=componentProperties.getProperty(se.getName());
      param.setRequired(se.isRequired());
      param.setValue(componentProperties.getValue(se));
      param.setSupportContext(true);
      List<?> values=se.getPossibleValues();
      if (values != null) {
        param.setPossibleValues(values);
        List<String> possVals=new ArrayList<>();
        List<String> possValsDisplay=new ArrayList<>();
        for (        Object obj : values) {
          if (obj instanceof NameAndLabel) {
            NameAndLabel nal=(NameAndLabel)obj;
            possVals.add(nal.getName());
            possValsDisplay.add(nal.getLabel());
          }
 else {
            possVals.add(String.valueOf(obj));
            possValsDisplay.add(String.valueOf(obj));
          }
        }
        param.setListItemsDisplayName(possValsDisplay.toArray(new String[0]));
        param.setListItemsDisplayCodeName(possValsDisplay.toArray(new String[0]));
        param.setListItemsValue(possVals.toArray(new String[0]));
      }
    }
    param.setReadOnly(false);
    param.setSerialized(true);
    elementParameters.add(param);
  }
  return elementParameters;
}