Program: 121915
Project: 121915
Buggy source:
/** 
 * qzhang Comment method "setOtherProperties".
 */
private void setOtherProperties(){
  boolean metadataInput=false;
  IElementParameter currentParam=elem.getElementParameter(propertyName);
  Item item=null;
  IElementParameter repositoryParam=elem.getElementParameter(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
  if (repositoryParam != null) {
    item=UpdateRepositoryUtils.getConnectionItemByItemId((String)repositoryParam.getValue());
  }
  if (elem instanceof Node) {
    Node node=(Node)elem;
    if (node.getCurrentActiveLinksNbInput(EConnectionType.FLOW_MAIN) > 0 || node.getCurrentActiveLinksNbInput(EConnectionType.FLOW_REF) > 0 || node.getCurrentActiveLinksNbInput(EConnectionType.TABLE) > 0) {
      metadataInput=true;
    }
    boolean hasSchema=elem.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE) != null;
    if (value.equals(EmfComponent.BUILTIN)) {
      if (!metadataInput && hasSchema) {
        elem.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(),value);
      }
      elem.setPropertyValue(EParameterName.QUERYSTORE_TYPE.getName(),value);
    }
 else {
      if (hasSchema) {
        for (        IElementParameter param : elem.getElementParameters()) {
          if (param.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE)) {
            if (!metadataInput) {
              IElementParameter repositorySchemaTypeParameter=param.getChildParameters().get(EParameterName.REPOSITORY_SCHEMA_TYPE.getName());
              String repositoryTable=null;
              if (propertyName.split("String_Node_Str")[1].equals(EParameterName.PROPERTY_TYPE.getName())) {
                repositoryTable=(String)repositorySchemaTypeParameter.getValue();
              }
 else               if (item != null) {
                if (item instanceof SAPConnectionItem) {
                  if (getCurrentTableName() != null)                   repositoryTable=item.getProperty().getId() + "String_Node_Str" + getCurrentTableName();
                }
 else                 repositoryTable=item.getProperty().getId() + "String_Node_Str" + getFirstRepositoryTable(item);
                repositorySchemaTypeParameter.setValue(repositoryTable);
              }
              if (isNotSim) {
                if (item != null && UpdateRepositoryUtils.getMetadataTablesFromItem(item) != null) {
                  if (repositoryTable != null && !"String_Node_Str".equals(repositoryTable)) {
                    param.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
                    IMetadataTable table=MetadataToolHelper.getMetadataFromRepository(repositoryTable);
                    if (table != null) {
                      table=table.clone();
                      setDBTableFieldValue(node,table.getTableName(),null);
                      setSAPFunctionName(node,table.getLabel());
                      table.setTableName(node.getMetadataList().get(0).getTableName());
                      if (!table.sameMetadataAs(node.getMetadataList().get(0))) {
                        ChangeMetadataCommand cmd=new ChangeMetadataCommand(node,param,null,table,param);
                        cmd.setConnection(connection);
                        cmd.setRepositoryMode(true);
                        cmd.execute(true);
                      }
                    }
                  }
                }
              }
 else               if (isMdmOutput()) {
                if (item != null && UpdateRepositoryUtils.getMetadataTablesFromItem(item) != null && UpdateRepositoryUtils.getMetadataTablesFromItem(item).size() > 0) {
                  if (repositoryTable != null && !"String_Node_Str".equals(repositoryTable)) {
                    param.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
                    IMetadataTable table=MetadataToolHelper.getMetadataFromRepository(repositoryTable);
                    if (table != null) {
                      table=table.clone();
                      setDBTableFieldValue(node,table.getTableName(),null);
                      setSAPFunctionName(node,table.getLabel());
                      table.setTableName(node.getMetadataList().get(0).getTableName());
                      ChangeMetadataCommand cmd=new ChangeMetadataCommand(node,param,null,table,param);
                      cmd.setConnection(connection);
                      cmd.setRepositoryMode(true);
                      cmd.execute(true);
                    }
                  }
                }
              }
 else {
                if (item != null && UpdateRepositoryUtils.getMetadataTablesFromItem(item) != null && UpdateRepositoryUtils.getMetadataTablesFromItem(item).size() == 1) {
                  if (repositoryTable != null && !"String_Node_Str".equals(repositoryTable)) {
                    param.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
                    IMetadataTable table=MetadataToolHelper.getMetadataFromRepository(repositoryTable);
                    if (table != null) {
                      table=table.clone();
                      setDBTableFieldValue(node,table.getTableName(),null);
                      setSAPFunctionName(node,table.getLabel());
                      table.setTableName(node.getMetadataList().get(0).getTableName());
                      if (!table.sameMetadataAs(node.getMetadataList().get(0))) {
                        ChangeMetadataCommand cmd=new ChangeMetadataCommand(node,param,null,table,param);
                        cmd.setConnection(connection);
                        cmd.setRepositoryMode(true);
                        cmd.execute(true);
                      }
                    }
                  }
                }
 else                 if (item != null && UpdateRepositoryUtils.getMetadataTablesFromItem(item) != null && ((INode)elem).getComponent().getName().equals("String_Node_Str") && UpdateRepositoryUtils.getMetadataTablesFromItem(item).size() == 2) {
                  final List<MetadataTable> tables=UpdateRepositoryUtils.getMetadataTablesFromItem(item);
                  if (tables != null && !tables.isEmpty()) {
                    if (param.getName().equals("String_Node_Str")) {
                      repositoryTable=item.getProperty().getId() + "String_Node_Str" + "String_Node_Str";
                      repositorySchemaTypeParameter.setValue(repositoryTable);
                    }
 else {
                      repositoryTable=item.getProperty().getId() + "String_Node_Str" + "String_Node_Str";
                      repositorySchemaTypeParameter.setValue(repositoryTable);
                    }
                    if (repositoryTable != null && !"String_Node_Str".equals(repositoryTable)) {
                      param.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
                      IMetadataTable table=MetadataToolHelper.getMetadataFromRepository(repositoryTable);
                      if (table != null) {
                        table=table.clone();
                        setDBTableFieldValue(node,table.getTableName(),null);
                        setSAPFunctionName(node,table.getLabel());
                        INodeConnector mainConnector=node.getConnectorFromType(EConnectionType.FLOW_MAIN);
                        IMetadataTable stable=null;
                        INodeConnector outputConnector=mainConnector;
                        if (mainConnector.getMaxLinkOutput() == 0) {
                          for (                          INodeConnector currentConnector : node.getListConnector()) {
                            if (!currentConnector.getBaseSchema().equals(EConnectionType.FLOW_MAIN.getName()) && currentConnector.getMaxLinkOutput() > 0) {
                              outputConnector=currentConnector;
                            }
                          }
                        }
                        if (param.getName().equals("String_Node_Str")) {
                          stable=node.getMetadataFromConnector("String_Node_Str");
                        }
 else                         if (param.getName().equals("String_Node_Str")) {
                          stable=node.getMetadataFromConnector("String_Node_Str");
                        }
                        if (stable != null) {
                          table.setTableName(stable.getTableName());
                          if (!table.sameMetadataAs(stable)) {
                            ChangeMetadataCommand cmd=new ChangeMetadataCommand(node,param,null,table,param);
                            cmd.setConnection(connection);
                            cmd.setRepositoryMode(true);
                            cmd.execute(true);
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
 else {
              Node sourceNode=getRealSourceNode((INode)elem);
              if (sourceNode != null) {
                IMetadataTable sourceMetadataTable=sourceNode.getMetadataList().get(0);
                Object sourceSchema=sourceNode.getPropertyValue(EParameterName.SCHEMA_TYPE.getName());
                boolean isTake=!sourceNode.isExternalNode() && sourceSchema != null && elem.getPropertyValue(EParameterName.SCHEMA_TYPE.getName()) != null;
                if (isTake && getTake()) {
                  ChangeMetadataCommand cmd=new ChangeMetadataCommand((Node)elem,param,null,sourceMetadataTable,param);
                  cmd.setConnection(connection);
                  cmd.execute(true);
                  elem.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(),sourceSchema);
                  if (sourceSchema.equals(EmfComponent.REPOSITORY)) {
                    elem.setPropertyValue(EParameterName.REPOSITORY_SCHEMA_TYPE.getName(),sourceNode.getPropertyValue(EParameterName.REPOSITORY_SCHEMA_TYPE.getName()));
                  }
                }
              }
            }
          }
        }
      }
    }
    IElementParameter queryParam=elem.getElementParameterFromField(EParameterFieldType.QUERYSTORE_TYPE,currentParam.getCategory());
    IElementParameter queryStoreType=null;
    if (queryParam != null) {
      queryStoreType=queryParam.getChildParameters().get(EParameterName.QUERYSTORE_TYPE.getName());
    }
    if (item != null) {
      final List<Query> queries=UpdateRepositoryUtils.getQueriesFromItem(item);
      if (propertyName.split("String_Node_Str")[1].equals(EParameterName.PROPERTY_TYPE.getName())) {
        if (queries != null && !queries.isEmpty()) {
          if (queryParam != null) {
            queryStoreType.setValue(value);
            if (value.equals(EmfComponent.REPOSITORY)) {
              setQueryToRepositoryMode(queryParam,queries,item);
            }
          }
        }
      }
 else {
        if (queryParam != null) {
          if (this.isGuessQuery || queries == null || (queries != null && queries.isEmpty())) {
            queryStoreType.setValue(EmfComponent.BUILTIN);
          }
 else {
            queryStoreType.setValue(EmfComponent.REPOSITORY);
            setQueryToRepositoryMode(queryParam,queries,item);
          }
        }
        List<MetadataTable> tables=UpdateRepositoryUtils.getMetadataTablesFromItem(item);
        if (tables == null || tables.isEmpty()) {
          elem.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(),EmfComponent.BUILTIN);
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * qzhang Comment method "setOtherProperties".
 */
private void setOtherProperties(){
  boolean metadataInput=false;
  IElementParameter currentParam=elem.getElementParameter(propertyName);
  Item item=null;
  IElementParameter repositoryParam=elem.getElementParameter(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
  if (repositoryParam != null) {
    item=UpdateRepositoryUtils.getConnectionItemByItemId((String)repositoryParam.getValue());
  }
  if (elem instanceof Node) {
    Node node=(Node)elem;
    if (node.getCurrentActiveLinksNbInput(EConnectionType.FLOW_MAIN) > 0 || node.getCurrentActiveLinksNbInput(EConnectionType.FLOW_REF) > 0 || node.getCurrentActiveLinksNbInput(EConnectionType.TABLE) > 0) {
      metadataInput=true;
    }
    boolean hasSchema=elem.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE) != null;
    if (value.equals(EmfComponent.BUILTIN)) {
      if (!metadataInput && hasSchema) {
        elem.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(),value);
      }
      elem.setPropertyValue(EParameterName.QUERYSTORE_TYPE.getName(),value);
    }
 else {
      if (hasSchema) {
        for (        IElementParameter param : elem.getElementParameters()) {
          if (param.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE)) {
            if (!metadataInput) {
              IElementParameter repositorySchemaTypeParameter=param.getChildParameters().get(EParameterName.REPOSITORY_SCHEMA_TYPE.getName());
              String repositoryTable=null;
              if (propertyName.split("String_Node_Str")[1].equals(EParameterName.PROPERTY_TYPE.getName())) {
                repositoryTable=(String)repositorySchemaTypeParameter.getValue();
              }
 else               if (item != null) {
                if (item instanceof SAPConnectionItem) {
                  if (getCurrentTableName() != null) {
                    repositoryTable=item.getProperty().getId() + "String_Node_Str" + getCurrentTableName();
                  }
                }
 else {
                  repositoryTable=item.getProperty().getId() + "String_Node_Str" + getFirstRepositoryTable(item);
                }
                repositorySchemaTypeParameter.setValue(repositoryTable);
              }
              if (isNotSim) {
                if (item != null && UpdateRepositoryUtils.getMetadataTablesFromItem(item) != null) {
                  if (repositoryTable != null && !"String_Node_Str".equals(repositoryTable)) {
                    param.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
                    IMetadataTable table=MetadataToolHelper.getMetadataFromRepository(repositoryTable);
                    if (table != null) {
                      table=table.clone();
                      setDBTableFieldValue(node,table.getTableName(),null);
                      setSAPFunctionName(node,table.getLabel());
                      table.setTableName(node.getMetadataList().get(0).getTableName());
                      if (!table.sameMetadataAs(node.getMetadataList().get(0))) {
                        ChangeMetadataCommand cmd=new ChangeMetadataCommand(node,param,null,table,param);
                        cmd.setConnection(connection);
                        cmd.setRepositoryMode(true);
                        cmd.execute(true);
                      }
                    }
                  }
                }
              }
 else               if (isMdmOutput()) {
                if (item != null && UpdateRepositoryUtils.getMetadataTablesFromItem(item) != null && UpdateRepositoryUtils.getMetadataTablesFromItem(item).size() > 0) {
                  if (repositoryTable != null && !"String_Node_Str".equals(repositoryTable)) {
                    param.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
                    IMetadataTable table=MetadataToolHelper.getMetadataFromRepository(repositoryTable);
                    if (table != null) {
                      table=table.clone();
                      setDBTableFieldValue(node,table.getTableName(),null);
                      setSAPFunctionName(node,table.getLabel());
                      table.setTableName(node.getMetadataList().get(0).getTableName());
                      ChangeMetadataCommand cmd=new ChangeMetadataCommand(node,param,null,table,param);
                      cmd.setConnection(connection);
                      cmd.setRepositoryMode(true);
                      cmd.execute(true);
                    }
                  }
                }
              }
 else {
                if (item != null && UpdateRepositoryUtils.getMetadataTablesFromItem(item) != null && UpdateRepositoryUtils.getMetadataTablesFromItem(item).size() == 1) {
                  if (repositoryTable != null && !"String_Node_Str".equals(repositoryTable)) {
                    param.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
                    IMetadataTable table=MetadataToolHelper.getMetadataFromRepository(repositoryTable);
                    if (table != null) {
                      table=table.clone();
                      setDBTableFieldValue(node,table.getTableName(),null);
                      setSAPFunctionName(node,table.getLabel());
                      table.setTableName(node.getMetadataList().get(0).getTableName());
                      if (!table.sameMetadataAs(node.getMetadataList().get(0))) {
                        ChangeMetadataCommand cmd=new ChangeMetadataCommand(node,param,null,table,param);
                        cmd.setConnection(connection);
                        cmd.setRepositoryMode(true);
                        cmd.execute(true);
                      }
                    }
                  }
                }
 else                 if (item != null && UpdateRepositoryUtils.getMetadataTablesFromItem(item) != null && ((INode)elem).getComponent().getName().equals("String_Node_Str") && UpdateRepositoryUtils.getMetadataTablesFromItem(item).size() == 2) {
                  final List<MetadataTable> tables=UpdateRepositoryUtils.getMetadataTablesFromItem(item);
                  if (tables != null && !tables.isEmpty()) {
                    if (param.getName().equals("String_Node_Str")) {
                      repositoryTable=item.getProperty().getId() + "String_Node_Str" + "String_Node_Str";
                      repositorySchemaTypeParameter.setValue(repositoryTable);
                    }
 else {
                      repositoryTable=item.getProperty().getId() + "String_Node_Str" + "String_Node_Str";
                      repositorySchemaTypeParameter.setValue(repositoryTable);
                    }
                    if (repositoryTable != null && !"String_Node_Str".equals(repositoryTable)) {
                      param.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
                      IMetadataTable table=MetadataToolHelper.getMetadataFromRepository(repositoryTable);
                      if (table != null) {
                        table=table.clone();
                        setDBTableFieldValue(node,table.getTableName(),null);
                        setSAPFunctionName(node,table.getLabel());
                        INodeConnector mainConnector=node.getConnectorFromType(EConnectionType.FLOW_MAIN);
                        IMetadataTable stable=null;
                        INodeConnector outputConnector=mainConnector;
                        if (mainConnector.getMaxLinkOutput() == 0) {
                          for (                          INodeConnector currentConnector : node.getListConnector()) {
                            if (!currentConnector.getBaseSchema().equals(EConnectionType.FLOW_MAIN.getName()) && currentConnector.getMaxLinkOutput() > 0) {
                              outputConnector=currentConnector;
                            }
                          }
                        }
                        if (param.getName().equals("String_Node_Str")) {
                          stable=node.getMetadataFromConnector("String_Node_Str");
                        }
 else                         if (param.getName().equals("String_Node_Str")) {
                          stable=node.getMetadataFromConnector("String_Node_Str");
                        }
                        if (stable != null) {
                          table.setTableName(stable.getTableName());
                          if (!table.sameMetadataAs(stable)) {
                            ChangeMetadataCommand cmd=new ChangeMetadataCommand(node,param,null,table,param);
                            cmd.setConnection(connection);
                            cmd.setRepositoryMode(true);
                            cmd.execute(true);
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
 else {
              Node sourceNode=getRealSourceNode((INode)elem);
              if (sourceNode != null) {
                IMetadataTable sourceMetadataTable=sourceNode.getMetadataList().get(0);
                Object sourceSchema=sourceNode.getPropertyValue(EParameterName.SCHEMA_TYPE.getName());
                boolean isTake=!sourceNode.isExternalNode() && sourceSchema != null && elem.getPropertyValue(EParameterName.SCHEMA_TYPE.getName()) != null;
                if (isTake && getTake()) {
                  ChangeMetadataCommand cmd=new ChangeMetadataCommand((Node)elem,param,null,sourceMetadataTable,param);
                  cmd.setConnection(connection);
                  cmd.execute(true);
                  elem.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(),sourceSchema);
                  if (sourceSchema.equals(EmfComponent.REPOSITORY)) {
                    elem.setPropertyValue(EParameterName.REPOSITORY_SCHEMA_TYPE.getName(),sourceNode.getPropertyValue(EParameterName.REPOSITORY_SCHEMA_TYPE.getName()));
                  }
                }
              }
            }
          }
        }
      }
    }
    IElementParameter queryParam=elem.getElementParameterFromField(EParameterFieldType.QUERYSTORE_TYPE,currentParam.getCategory());
    IElementParameter queryStoreType=null;
    if (queryParam != null) {
      queryStoreType=queryParam.getChildParameters().get(EParameterName.QUERYSTORE_TYPE.getName());
    }
    if (item != null) {
      final List<Query> queries=UpdateRepositoryUtils.getQueriesFromItem(item);
      if (propertyName.split("String_Node_Str")[1].equals(EParameterName.PROPERTY_TYPE.getName())) {
        if (queries != null && !queries.isEmpty()) {
          if (queryParam != null) {
            queryStoreType.setValue(value);
            if (value.equals(EmfComponent.REPOSITORY)) {
              setQueryToRepositoryMode(queryParam,queries,item);
            }
          }
        }
      }
 else {
        if (queryParam != null) {
          if (this.isGuessQuery || queries == null || (queries != null && queries.isEmpty())) {
            queryStoreType.setValue(EmfComponent.BUILTIN);
          }
 else {
            queryStoreType.setValue(EmfComponent.REPOSITORY);
            setQueryToRepositoryMode(queryParam,queries,item);
          }
        }
        List<MetadataTable> tables=UpdateRepositoryUtils.getMetadataTablesFromItem(item);
        if (tables == null || tables.isEmpty()) {
          elem.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(),EmfComponent.BUILTIN);
        }
      }
    }
  }
}