Program: 118519
Project: 118519
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
 */
private static List<ElementParameter> getParametersFromForm(IElement element,EComponentCategory category,ComponentProperties rootProperty,ComponentProperties compProperties,String parentPropertiesPath,Form form,Widget parentWidget,AtomicInteger lastRowNum){
  List<ElementParameter> elementParameters=new ArrayList<>();
  List<String> parameterNames=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=(ComponentProperties)form.getProperties();
  }
  if (element instanceof INode) {
    INode node=(INode)element;
    if (node.getComponentProperties() == null) {
      node.setComponentProperties(componentProperties);
    }
  }
  componentProperties.setValueEvaluator(null);
  Collection<Widget> formWidgets=form.getWidgets();
  for (  Widget widget : formWidgets) {
    NamedThing widgetProperty=widget.getContent();
    String propertiesPath=getPropertiesPath(parentPropertiesPath,null);
    if (widgetProperty instanceof Form) {
      Form subForm=(Form)widgetProperty;
      ComponentProperties subProperties=(ComponentProperties)subForm.getProperties();
      if (!isSameComponentProperties(componentProperties,widgetProperty)) {
        propertiesPath=getPropertiesPath(parentPropertiesPath,subProperties.getName());
      }
      elementParameters.addAll(getParametersFromForm(element,compCategory,rootProperty,subProperties,propertiesPath,subForm,widget,lastRN));
      continue;
    }
    GenericElementParameter param=new GenericElementParameter(element,rootProperty,form,widget,getComponentService());
    String parameterName=propertiesPath.concat(param.getName());
    param.setName(parameterName);
    param.setCategory(compCategory);
    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);
    EParameterFieldType fieldType=getFieldType(widget,widgetProperty);
    param.setFieldType(fieldType != null ? fieldType : EParameterFieldType.TEXT);
    if (widgetProperty instanceof SchemaProperty) {
      for (      Connector connector : rootProperty.getAvailableConnectors(null,true)) {
        if (!(((SchemaProperty)widgetProperty).getValue() instanceof Schema)) {
          continue;
        }
        Schema schema=(Schema)((SchemaProperty)widgetProperty).getValue();
        if (rootProperty.getSchema(connector,true).equals(schema)) {
          param.setContext(connector.getName());
          IElementParameterDefaultValue defaultValue=new ElementParameterDefaultValue();
          defaultValue.setDefaultValue(new Schema.Parser().parse(schema.toString()));
          param.getDefaultValues().add(defaultValue);
        }
      }
    }
    if (widgetProperty instanceof PresentationItem) {
      param.setValue(widgetProperty.getDisplayName());
    }
 else     if (widgetProperty instanceof Property) {
      Property property=(Property)widgetProperty;
      param.setRequired(property.isRequired());
      if (fieldType != null && fieldType.equals(EParameterFieldType.TABLE)) {
        Object value=property.getValue();
        if (value == null) {
          param.setValue(new ArrayList<Map<String,Object>>());
        }
 else {
          param.setValue(value);
        }
        param.setSupportContext(false);
      }
 else {
        param.setValue(getParameterValue(element,property));
        param.setSupportContext(isSupportContext(property));
      }
      List<?> values=property.getPossibleValues();
      if (values != null) {
        param.setPossibleValues(values);
        List<String> possVals=new ArrayList<>();
        List<String> possValsDisplay=new ArrayList<>();
        for (        Object obj : values) {
          if (obj instanceof NamedThing) {
            NamedThing nal=(NamedThing)obj;
            possVals.add(nal.getName());
            possValsDisplay.add(nal.getDisplayName());
          }
 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]));
      }
      if (fieldType != null && fieldType.equals(EParameterFieldType.TABLE)) {
        List<ElementParameter> possVals=new ArrayList<>();
        List<String> codeNames=new ArrayList<>();
        List<String> possValsDisplay=new ArrayList<>();
        for (        Property curChildProp : property.getChildren()) {
          EParameterFieldType currentField=EParameterFieldType.TEXT;
          ElementParameter newParam=new ElementParameter(element);
          newParam.setName(curChildProp.getName());
          newParam.setFilter(null);
          newParam.setDisplayName("String_Node_Str");
          newParam.setFieldType(currentField);
          newParam.setContext(null);
          newParam.setShowIf(null);
          newParam.setNotShowIf(null);
          newParam.setReadOnlyIf(null);
          newParam.setNotReadOnlyIf(null);
          newParam.setNoContextAssist(false);
          newParam.setRaw(false);
          newParam.setReadOnly(false);
          newParam.setValue(curChildProp.getValue());
          possVals.add(newParam);
          if (isPrevColumnList(curChildProp)) {
            newParam.setFieldType(EParameterFieldType.PREV_COLUMN_LIST);
            newParam.setListItemsDisplayName(new String[0]);
            newParam.setListItemsDisplayCodeName(new String[0]);
            newParam.setListItemsValue(new String[0]);
            newParam.setListRepositoryItems(new String[0]);
            newParam.setListItemsShowIf(new String[0]);
            newParam.setListItemsNotShowIf(new String[0]);
            newParam.setListItemsNotReadOnlyIf(new String[0]);
            newParam.setListItemsReadOnlyIf(new String[0]);
          }
          if (curChildProp.getType().equals(Property.Type.BOOLEAN)) {
            newParam.setFieldType(EParameterFieldType.CHECK);
            if (curChildProp.getValue() == null) {
              newParam.setValue(Boolean.FALSE);
            }
 else {
              newParam.setValue(new Boolean(curChildProp.getValue().toString()));
            }
          }
          codeNames.add(curChildProp.getName());
          possValsDisplay.add(curChildProp.getDisplayName());
        }
        param.setListItemsDisplayName(possValsDisplay.toArray(new String[0]));
        param.setListItemsDisplayCodeName(codeNames.toArray(new String[0]));
        param.setListItemsValue(possVals.toArray(new ElementParameter[0]));
        String[] listItemsShowIf=new String[property.getChildren().size()];
        String[] listItemsNotShowIf=new String[property.getChildren().size()];
        param.setListItemsShowIf(listItemsShowIf);
        param.setListItemsNotShowIf(listItemsNotShowIf);
      }
    }
    param.setReadOnly(false);
    param.setSerialized(true);
    param.setDynamicSettings(true);
    if (!parameterNames.contains(parameterName)) {
      elementParameters.add(param);
      parameterNames.add(parameterName);
    }
  }
  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
 */
private static List<ElementParameter> getParametersFromForm(IElement element,EComponentCategory category,ComponentProperties rootProperty,ComponentProperties compProperties,String parentPropertiesPath,Form form,Widget parentWidget,AtomicInteger lastRowNum){
  List<ElementParameter> elementParameters=new ArrayList<>();
  List<String> parameterNames=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=(ComponentProperties)form.getProperties();
  }
  if (element instanceof INode) {
    INode node=(INode)element;
    if (node.getComponentProperties() == null) {
      node.setComponentProperties(componentProperties);
    }
  }
  componentProperties.setValueEvaluator(null);
  Collection<Widget> formWidgets=form.getWidgets();
  for (  Widget widget : formWidgets) {
    NamedThing widgetProperty=widget.getContent();
    String propertiesPath=getPropertiesPath(parentPropertiesPath,null);
    if (widgetProperty instanceof Form) {
      Form subForm=(Form)widgetProperty;
      ComponentProperties subProperties=(ComponentProperties)subForm.getProperties();
      if (!isSameComponentProperties(componentProperties,widgetProperty)) {
        propertiesPath=getPropertiesPath(parentPropertiesPath,subProperties.getName());
      }
      elementParameters.addAll(getParametersFromForm(element,compCategory,rootProperty,subProperties,propertiesPath,subForm,widget,lastRN));
      continue;
    }
    GenericElementParameter param=new GenericElementParameter(element,rootProperty,form,widget,getComponentService());
    String parameterName=propertiesPath.concat(param.getName());
    param.setName(parameterName);
    param.setCategory(compCategory);
    param.setShow(parentWidget == null ? !widget.isHidden() : !parentWidget.isHidden() && !widget.isHidden());
    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);
    EParameterFieldType fieldType=getFieldType(widget,widgetProperty);
    param.setFieldType(fieldType != null ? fieldType : EParameterFieldType.TEXT);
    if (widgetProperty instanceof SchemaProperty) {
      for (      Connector connector : rootProperty.getAvailableConnectors(null,true)) {
        if (!(((SchemaProperty)widgetProperty).getValue() instanceof Schema)) {
          continue;
        }
        Schema schema=(Schema)((SchemaProperty)widgetProperty).getValue();
        if (rootProperty.getSchema(connector,true).equals(schema)) {
          param.setContext(connector.getName());
          IElementParameterDefaultValue defaultValue=new ElementParameterDefaultValue();
          defaultValue.setDefaultValue(new Schema.Parser().parse(schema.toString()));
          param.getDefaultValues().add(defaultValue);
        }
      }
    }
    if (widgetProperty instanceof PresentationItem) {
      param.setValue(widgetProperty.getDisplayName());
    }
 else     if (widgetProperty instanceof Property) {
      Property property=(Property)widgetProperty;
      param.setRequired(property.isRequired());
      if (fieldType != null && fieldType.equals(EParameterFieldType.TABLE)) {
        Object value=property.getValue();
        if (value == null) {
          param.setValue(new ArrayList<Map<String,Object>>());
        }
 else {
          param.setValue(value);
        }
        param.setSupportContext(false);
      }
 else {
        param.setValue(getParameterValue(element,property));
        param.setSupportContext(isSupportContext(property));
      }
      List<?> values=property.getPossibleValues();
      if (values != null) {
        param.setPossibleValues(values);
        List<String> possVals=new ArrayList<>();
        List<String> possValsDisplay=new ArrayList<>();
        for (        Object obj : values) {
          if (obj instanceof NamedThing) {
            NamedThing nal=(NamedThing)obj;
            possVals.add(nal.getName());
            possValsDisplay.add(nal.getDisplayName());
          }
 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]));
      }
      if (fieldType != null && fieldType.equals(EParameterFieldType.TABLE)) {
        List<ElementParameter> possVals=new ArrayList<>();
        List<String> codeNames=new ArrayList<>();
        List<String> possValsDisplay=new ArrayList<>();
        for (        Property curChildProp : property.getChildren()) {
          EParameterFieldType currentField=EParameterFieldType.TEXT;
          ElementParameter newParam=new ElementParameter(element);
          newParam.setName(curChildProp.getName());
          newParam.setFilter(null);
          newParam.setDisplayName("String_Node_Str");
          newParam.setFieldType(currentField);
          newParam.setContext(null);
          newParam.setShowIf(null);
          newParam.setNotShowIf(null);
          newParam.setReadOnlyIf(null);
          newParam.setNotReadOnlyIf(null);
          newParam.setNoContextAssist(false);
          newParam.setRaw(false);
          newParam.setReadOnly(false);
          newParam.setValue(curChildProp.getValue());
          possVals.add(newParam);
          if (isPrevColumnList(curChildProp)) {
            newParam.setFieldType(EParameterFieldType.PREV_COLUMN_LIST);
            newParam.setListItemsDisplayName(new String[0]);
            newParam.setListItemsDisplayCodeName(new String[0]);
            newParam.setListItemsValue(new String[0]);
            newParam.setListRepositoryItems(new String[0]);
            newParam.setListItemsShowIf(new String[0]);
            newParam.setListItemsNotShowIf(new String[0]);
            newParam.setListItemsNotReadOnlyIf(new String[0]);
            newParam.setListItemsReadOnlyIf(new String[0]);
          }
          if (curChildProp.getType().equals(Property.Type.BOOLEAN)) {
            newParam.setFieldType(EParameterFieldType.CHECK);
            if (curChildProp.getValue() == null) {
              newParam.setValue(Boolean.FALSE);
            }
 else {
              newParam.setValue(new Boolean(curChildProp.getValue().toString()));
            }
          }
          codeNames.add(curChildProp.getName());
          possValsDisplay.add(curChildProp.getDisplayName());
        }
        param.setListItemsDisplayName(possValsDisplay.toArray(new String[0]));
        param.setListItemsDisplayCodeName(codeNames.toArray(new String[0]));
        param.setListItemsValue(possVals.toArray(new ElementParameter[0]));
        String[] listItemsShowIf=new String[property.getChildren().size()];
        String[] listItemsNotShowIf=new String[property.getChildren().size()];
        param.setListItemsShowIf(listItemsShowIf);
        param.setListItemsNotShowIf(listItemsNotShowIf);
      }
    }
    param.setReadOnly(false);
    param.setSerialized(true);
    param.setDynamicSettings(true);
    if (!parameterNames.contains(parameterName)) {
      elementParameters.add(param);
      parameterNames.add(parameterName);
    }
  }
  return elementParameters;
}