Search in sources :

Example 1 with EnterMappingDialog

use of org.apache.hop.ui.core.dialog.EnterMappingDialog in project hop by apache.

the class PGBulkLoaderDialog method generateMappings.

/**
 * Reads in the fields from the previous transforms and from the ONE next transform and opens an
 * EnterMappingDialog with this information. After the user did the mapping, those information is
 * put into the Select/Rename table.
 */
private void generateMappings() {
    // Determine the source and target fields...
    // 
    IRowMeta sourceFields;
    IRowMeta targetFields;
    try {
        sourceFields = pipelineMeta.getPrevTransformFields(variables, transformMeta);
    } catch (HopException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "PGBulkLoaderDialog.DoMapping.UnableToFindSourceFields.Title"), BaseMessages.getString(PKG, "PGBulkLoaderDialog.DoMapping.UnableToFindSourceFields.Message"), e);
        return;
    }
    // refresh data
    input.setDatabaseMeta(pipelineMeta.findDatabase(wConnection.getText()));
    input.setTableName(variables.resolve(wTable.getText()));
    ITransformMeta transformMetaInterface = transformMeta.getTransform();
    try {
        targetFields = transformMetaInterface.getRequiredFields(variables);
    } catch (HopException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "PGBulkLoaderDialog.DoMapping.UnableToFindTargetFields.Title"), BaseMessages.getString(PKG, "PGBulkLoaderDialog.DoMapping.UnableToFindTargetFields.Message"), e);
        return;
    }
    String[] inputNames = new String[sourceFields.size()];
    for (int i = 0; i < sourceFields.size(); i++) {
        IValueMeta value = sourceFields.getValueMeta(i);
        inputNames[i] = value.getName();
    }
    // Create the existing mapping list...
    // 
    List<SourceToTargetMapping> mappings = new ArrayList<>();
    StringBuilder missingSourceFields = new StringBuilder();
    StringBuilder missingTargetFields = new StringBuilder();
    int nrFields = wReturn.nrNonEmpty();
    for (int i = 0; i < nrFields; i++) {
        TableItem item = wReturn.getNonEmpty(i);
        String source = item.getText(2);
        String target = item.getText(1);
        int sourceIndex = sourceFields.indexOfValue(source);
        if (sourceIndex < 0) {
            missingSourceFields.append(Const.CR).append("   ").append(source).append(" --> ").append(target);
        }
        int targetIndex = targetFields.indexOfValue(target);
        if (targetIndex < 0) {
            missingTargetFields.append(Const.CR).append("   ").append(source).append(" --> ").append(target);
        }
        if (sourceIndex < 0 || targetIndex < 0) {
            continue;
        }
        SourceToTargetMapping mapping = new SourceToTargetMapping(sourceIndex, targetIndex);
        mappings.add(mapping);
    }
    // 
    if (missingSourceFields.length() > 0 || missingTargetFields.length() > 0) {
        String message = "";
        if (missingSourceFields.length() > 0) {
            message += BaseMessages.getString(PKG, "PGBulkLoaderDialog.DoMapping.SomeSourceFieldsNotFound", missingSourceFields.toString()) + Const.CR;
        }
        if (missingTargetFields.length() > 0) {
            message += BaseMessages.getString(PKG, "PGBulkLoaderDialog.DoMapping.SomeTargetFieldsNotFound", missingSourceFields.toString()) + Const.CR;
        }
        message += Const.CR;
        message += BaseMessages.getString(PKG, "PGBulkLoaderDialog.DoMapping.SomeFieldsNotFoundContinue") + Const.CR;
        int answer = BaseDialog.openMessageBox(shell, BaseMessages.getString(PKG, "PGBulkLoaderDialog.DoMapping.SomeFieldsNotFoundTitle"), message, SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
        boolean goOn = (answer & SWT.OK) != 0;
        if (!goOn) {
            return;
        }
    }
    EnterMappingDialog d = new EnterMappingDialog(PGBulkLoaderDialog.this.shell, sourceFields.getFieldNames(), targetFields.getFieldNames(), mappings);
    mappings = d.open();
    // 
    if (mappings != null) {
        // Clear and re-populate!
        // 
        wReturn.table.removeAll();
        wReturn.table.setItemCount(mappings.size());
        for (int i = 0; i < mappings.size(); i++) {
            SourceToTargetMapping mapping = mappings.get(i);
            TableItem item = wReturn.table.getItem(i);
            item.setText(2, sourceFields.getValueMeta(mapping.getSourcePosition()).getName());
            item.setText(1, targetFields.getValueMeta(mapping.getTargetPosition()).getName());
        }
        wReturn.setRowNums();
        wReturn.optWidth(true);
    }
}
Also used : HopException(org.apache.hop.core.exception.HopException) IRowMeta(org.apache.hop.core.row.IRowMeta) EnterMappingDialog(org.apache.hop.ui.core.dialog.EnterMappingDialog) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) ITransformMeta(org.apache.hop.pipeline.transform.ITransformMeta) IValueMeta(org.apache.hop.core.row.IValueMeta) SourceToTargetMapping(org.apache.hop.core.SourceToTargetMapping)

Example 2 with EnterMappingDialog

use of org.apache.hop.ui.core.dialog.EnterMappingDialog in project hop by apache.

the class InsertUpdateDialog method generateMappings.

/**
 * Reads in the fields from the previous transforms and from the ONE next transform and opens an
 * EnterMappingDialog with this information. After the user did the mapping, those information is
 * put into the Select/Rename table.
 */
private void generateMappings() {
    // Determine the source and target fields...
    // 
    IRowMeta sourceFields;
    IRowMeta targetFields;
    try {
        sourceFields = pipelineMeta.getPrevTransformFields(variables, transformMeta);
    } catch (HopException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "InsertUpdateDialog.DoMapping.UnableToFindSourceFields.Title"), BaseMessages.getString(PKG, "InsertUpdateDialog.DoMapping.UnableToFindSourceFields.Message"), e);
        return;
    }
    // refresh data
    input.setConnection(wConnection.getText());
    input.getInsertUpdateLookupField().setTableName(variables.resolve(wTable.getText()));
    ITransformMeta transformMetaInterface = transformMeta.getTransform();
    try {
        targetFields = transformMetaInterface.getRequiredFields(variables);
    } catch (HopException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "InsertUpdateDialog.DoMapping.UnableToFindTargetFields.Title"), BaseMessages.getString(PKG, "InsertUpdateDialog.DoMapping.UnableToFindTargetFields.Message"), e);
        return;
    }
    String[] inputNames = new String[sourceFields.size()];
    for (int i = 0; i < sourceFields.size(); i++) {
        IValueMeta value = sourceFields.getValueMeta(i);
        inputNames[i] = value.getName();
    }
    // Create the existing mapping list...
    // Also copy the update status of targets in to a hashmap
    // 
    List<SourceToTargetMapping> mappings = new ArrayList<>();
    Map<String, String> targetUpdateStatus = new HashMap<>();
    StringBuilder missingSourceFields = new StringBuilder();
    StringBuilder missingTargetFields = new StringBuilder();
    int nrFields = wReturn.nrNonEmpty();
    for (int i = 0; i < nrFields; i++) {
        TableItem item = wReturn.getNonEmpty(i);
        String source = item.getText(2);
        String target = item.getText(1);
        targetUpdateStatus.put(item.getText(1), item.getText(3));
        int sourceIndex = sourceFields.indexOfValue(source);
        if (sourceIndex < 0) {
            missingSourceFields.append(Const.CR).append("   ").append(source).append(" --> ").append(target);
        }
        int targetIndex = targetFields.indexOfValue(target);
        if (targetIndex < 0) {
            missingTargetFields.append(Const.CR).append("   ").append(source).append(" --> ").append(target);
        }
        if (sourceIndex < 0 || targetIndex < 0) {
            continue;
        }
        SourceToTargetMapping mapping = new SourceToTargetMapping(sourceIndex, targetIndex);
        mappings.add(mapping);
    }
    // 
    if (missingSourceFields.length() > 0 || missingTargetFields.length() > 0) {
        String message = "";
        if (missingSourceFields.length() > 0) {
            message += BaseMessages.getString(PKG, "InsertUpdateDialog.DoMapping.SomeSourceFieldsNotFound", missingSourceFields.toString()) + Const.CR;
        }
        if (missingTargetFields.length() > 0) {
            message += BaseMessages.getString(PKG, "InsertUpdateDialog.DoMapping.SomeTargetFieldsNotFound", missingSourceFields.toString()) + Const.CR;
        }
        message += Const.CR;
        message += BaseMessages.getString(PKG, "InsertUpdateDialog.DoMapping.SomeFieldsNotFoundContinue") + Const.CR;
        int answer = BaseDialog.openMessageBox(shell, BaseMessages.getString(PKG, "InsertUpdateDialog.DoMapping.SomeFieldsNotFoundTitle"), message, SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
        boolean goOn = (answer & SWT.OK) != 0;
        if (!goOn) {
            return;
        }
    }
    EnterMappingDialog d = new EnterMappingDialog(InsertUpdateDialog.this.shell, sourceFields.getFieldNames(), targetFields.getFieldNames(), mappings);
    mappings = d.open();
    // 
    if (mappings != null) {
        // Clear and re-populate!
        // 
        wReturn.table.removeAll();
        wReturn.table.setItemCount(mappings.size());
        for (int i = 0; i < mappings.size(); i++) {
            SourceToTargetMapping mapping = mappings.get(i);
            TableItem item = wReturn.table.getItem(i);
            item.setText(2, sourceFields.getValueMeta(mapping.getSourcePosition()).getName());
            item.setText(1, targetFields.getValueMeta(mapping.getTargetPosition()).getName());
            if (targetUpdateStatus.get(item.getText(1)) == null) {
                item.setText(3, "Y");
            } else {
                item.setText(3, targetUpdateStatus.get(item.getText(1)));
            }
        }
        wReturn.setRowNums();
        wReturn.optWidth(true);
    }
}
Also used : HopException(org.apache.hop.core.exception.HopException) IRowMeta(org.apache.hop.core.row.IRowMeta) EnterMappingDialog(org.apache.hop.ui.core.dialog.EnterMappingDialog) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) ITransformMeta(org.apache.hop.pipeline.transform.ITransformMeta) IValueMeta(org.apache.hop.core.row.IValueMeta) SourceToTargetMapping(org.apache.hop.core.SourceToTargetMapping)

Example 3 with EnterMappingDialog

use of org.apache.hop.ui.core.dialog.EnterMappingDialog in project hop by apache.

the class SalesforceInsertDialog method generateMappings.

/**
 * Reads in the fields from the previous transforms and from the ONE next transform and opens an
 * EnterMappingDialog with this information. After the user did the mapping, those information is
 * put into the Select/Rename table.
 */
private void generateMappings() {
    if (!checkInput()) {
        return;
    }
    // Determine the source and target fields...
    // 
    IRowMeta sourceFields;
    IRowMeta targetFields = new RowMeta();
    try {
        sourceFields = pipelineMeta.getPrevTransformFields(variables, transformMeta);
    } catch (HopException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "SalesforceInsertDialog.DoMapping.UnableToFindSourceFields.Title"), BaseMessages.getString(PKG, "SalesforceInsertDialog.DoMapping.UnableToFindSourceFields.Message"), e);
        return;
    }
    try {
        SalesforceConnection connection = getConnection();
        Field[] fields = connection.getObjectFields(variables.resolve(wModule.getText()));
        String[] fieldNames = connection.getFields(fields);
        FieldType dateType = FieldType.date;
        for (int i = 0; i < fields.length; i++) {
            if (dateType.equals(fields[i].getType())) {
                // Mark date columns as TYPE_DATE to strip time part later
                targetFields.addValueMeta(ValueMetaFactory.createValueMeta(fieldNames[i], IValueMeta.TYPE_DATE));
            } else {
                targetFields.addValueMeta(new ValueMetaNone(fieldNames[i]));
            }
        }
    } catch (Exception e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "SalesforceInsertDialog.DoMapping.UnableToFindTargetFields.Title"), BaseMessages.getString(PKG, "SalesforceInsertDialog.DoMapping.UnableToFindTargetFields.Message"), e);
        return;
    }
    String[] inputNames = new String[sourceFields.size()];
    for (int i = 0; i < sourceFields.size(); i++) {
        IValueMeta value = sourceFields.getValueMeta(i);
        inputNames[i] = value.getName();
    }
    // Create the existing mapping list...
    // 
    List<SourceToTargetMapping> mappings = new ArrayList<>();
    StringBuffer missingSourceFields = new StringBuffer();
    StringBuffer missingTargetFields = new StringBuffer();
    int nrFields = wReturn.nrNonEmpty();
    for (int i = 0; i < nrFields; i++) {
        TableItem item = wReturn.getNonEmpty(i);
        String source = item.getText(2);
        String target = item.getText(1);
        int sourceIndex = sourceFields.indexOfValue(source);
        if (sourceIndex < 0) {
            missingSourceFields.append(Const.CR + "   " + source + " --> " + target);
        }
        int targetIndex = targetFields.indexOfValue(target);
        if (targetIndex < 0) {
            missingTargetFields.append(Const.CR + "   " + source + " --> " + target);
        }
        if (sourceIndex < 0 || targetIndex < 0) {
            continue;
        }
        SourceToTargetMapping mapping = new SourceToTargetMapping(sourceIndex, targetIndex);
        mappings.add(mapping);
    }
    // 
    if (missingSourceFields.length() > 0 || missingTargetFields.length() > 0) {
        String message = "";
        if (missingSourceFields.length() > 0) {
            message += BaseMessages.getString(PKG, "SalesforceInsertDialog.DoMapping.SomeSourceFieldsNotFound", missingSourceFields.toString()) + Const.CR;
        }
        if (missingTargetFields.length() > 0) {
            message += BaseMessages.getString(PKG, "SalesforceInsertDialog.DoMapping.SomeTargetFieldsNotFound", missingSourceFields.toString()) + Const.CR;
        }
        message += Const.CR;
        message += BaseMessages.getString(PKG, "SalesforceInsertDialog.DoMapping.SomeFieldsNotFoundContinue") + Const.CR;
        int answer = BaseDialog.openMessageBox(shell, BaseMessages.getString(PKG, "SalesforceInsertDialog.DoMapping.SomeFieldsNotFoundTitle"), message, SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
        boolean goOn = (answer & SWT.OK) != 0;
        if (!goOn) {
            return;
        }
    }
    EnterMappingDialog d = new EnterMappingDialog(SalesforceInsertDialog.this.shell, sourceFields.getFieldNames(), targetFields.getFieldNames(), mappings);
    mappings = d.open();
    // 
    if (mappings != null) {
        // Clear and re-populate!
        // 
        wReturn.table.removeAll();
        wReturn.table.setItemCount(mappings.size());
        for (int i = 0; i < mappings.size(); i++) {
            SourceToTargetMapping mapping = mappings.get(i);
            TableItem item = wReturn.table.getItem(i);
            item.setText(2, sourceFields.getValueMeta(mapping.getSourcePosition()).getName());
            item.setText(1, targetFields.getValueMeta(mapping.getTargetPosition()).getName());
        }
        wReturn.setRowNums();
        wReturn.optWidth(true);
    }
}
Also used : RowMeta(org.apache.hop.core.row.RowMeta) IRowMeta(org.apache.hop.core.row.IRowMeta) HopException(org.apache.hop.core.exception.HopException) IRowMeta(org.apache.hop.core.row.IRowMeta) EnterMappingDialog(org.apache.hop.ui.core.dialog.EnterMappingDialog) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) SalesforceConnection(org.apache.hop.pipeline.transforms.salesforce.SalesforceConnection) HopException(org.apache.hop.core.exception.HopException) FieldType(com.sforce.soap.partner.FieldType) Field(com.sforce.soap.partner.Field) IValueMeta(org.apache.hop.core.row.IValueMeta) ValueMetaNone(org.apache.hop.core.row.value.ValueMetaNone) SourceToTargetMapping(org.apache.hop.core.SourceToTargetMapping)

Example 4 with EnterMappingDialog

use of org.apache.hop.ui.core.dialog.EnterMappingDialog in project hop by apache.

the class SalesforceUpdateDialog method generateMappings.

/**
 * Reads in the fields from the previous transforms and from the ONE next transform and opens an
 * EnterMappingDialog with this information. After the user did the mapping, those information is
 * put into the Select/Rename table.
 */
private void generateMappings() {
    if (!checkInput()) {
        return;
    }
    // Determine the source and target fields...
    // 
    IRowMeta sourceFields;
    IRowMeta targetFields = new RowMeta();
    try {
        sourceFields = pipelineMeta.getPrevTransformFields(variables, transformMeta);
    } catch (HopException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "SalesforceUpdateDialog.DoMapping.UnableToFindSourceFields.Title"), BaseMessages.getString(PKG, "SalesforceUpdateDialog.DoMapping.UnableToFindSourceFields.Message"), e);
        return;
    }
    try {
        String[] fields = getModuleFields();
        for (int i = 0; i < fields.length; i++) {
            targetFields.addValueMeta(new ValueMetaNone(fields[i]));
        }
    } catch (Exception e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "SalesforceUpdateDialog.DoMapping.UnableToFindTargetFields.Title"), BaseMessages.getString(PKG, "SalesforceUpdateDialog.DoMapping.UnableToFindTargetFields.Message"), e);
        return;
    }
    String[] inputNames = new String[sourceFields.size()];
    for (int i = 0; i < sourceFields.size(); i++) {
        IValueMeta value = sourceFields.getValueMeta(i);
        inputNames[i] = value.getName();
    }
    // Create the existing mapping list...
    // 
    List<SourceToTargetMapping> mappings = new ArrayList<>();
    StringBuffer missingSourceFields = new StringBuffer();
    StringBuffer missingTargetFields = new StringBuffer();
    int nrFields = wReturn.nrNonEmpty();
    for (int i = 0; i < nrFields; i++) {
        TableItem item = wReturn.getNonEmpty(i);
        String source = item.getText(2);
        String target = item.getText(1);
        int sourceIndex = sourceFields.indexOfValue(source);
        if (sourceIndex < 0) {
            missingSourceFields.append(Const.CR + "   " + source + " --> " + target);
        }
        int targetIndex = targetFields.indexOfValue(target);
        if (targetIndex < 0) {
            missingTargetFields.append(Const.CR + "   " + source + " --> " + target);
        }
        if (sourceIndex < 0 || targetIndex < 0) {
            continue;
        }
        SourceToTargetMapping mapping = new SourceToTargetMapping(sourceIndex, targetIndex);
        mappings.add(mapping);
    }
    // 
    if (missingSourceFields.length() > 0 || missingTargetFields.length() > 0) {
        String message = "";
        if (missingSourceFields.length() > 0) {
            message += BaseMessages.getString(PKG, "SalesforceUpdateDialog.DoMapping.SomeSourceFieldsNotFound", missingSourceFields.toString()) + Const.CR;
        }
        if (missingTargetFields.length() > 0) {
            message += BaseMessages.getString(PKG, "SalesforceUpdateDialog.DoMapping.SomeTargetFieldsNotFound", missingSourceFields.toString()) + Const.CR;
        }
        message += Const.CR;
        message += BaseMessages.getString(PKG, "SalesforceUpdateDialog.DoMapping.SomeFieldsNotFoundContinue") + Const.CR;
        int answer = BaseDialog.openMessageBox(shell, BaseMessages.getString(PKG, "SalesforceUpdateDialog.DoMapping.SomeFieldsNotFoundTitle"), message, SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
        boolean goOn = (answer & SWT.OK) != 0;
        if (!goOn) {
            return;
        }
    }
    EnterMappingDialog d = new EnterMappingDialog(SalesforceUpdateDialog.this.shell, sourceFields.getFieldNames(), targetFields.getFieldNames(), mappings);
    mappings = d.open();
    // 
    if (mappings != null) {
        // Clear and re-populate!
        // 
        wReturn.table.removeAll();
        wReturn.table.setItemCount(mappings.size());
        for (int i = 0; i < mappings.size(); i++) {
            SourceToTargetMapping mapping = mappings.get(i);
            TableItem item = wReturn.table.getItem(i);
            item.setText(2, sourceFields.getValueMeta(mapping.getSourcePosition()).getName());
            item.setText(1, targetFields.getValueMeta(mapping.getTargetPosition()).getName());
        }
        wReturn.setRowNums();
        wReturn.optWidth(true);
    }
}
Also used : RowMeta(org.apache.hop.core.row.RowMeta) IRowMeta(org.apache.hop.core.row.IRowMeta) HopException(org.apache.hop.core.exception.HopException) IRowMeta(org.apache.hop.core.row.IRowMeta) EnterMappingDialog(org.apache.hop.ui.core.dialog.EnterMappingDialog) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) HopException(org.apache.hop.core.exception.HopException) IValueMeta(org.apache.hop.core.row.IValueMeta) ValueMetaNone(org.apache.hop.core.row.value.ValueMetaNone) SourceToTargetMapping(org.apache.hop.core.SourceToTargetMapping)

Example 5 with EnterMappingDialog

use of org.apache.hop.ui.core.dialog.EnterMappingDialog in project hop by apache.

the class SalesforceUpsertDialog method generateMappings.

/**
 * Reads in the fields from the previous transforms and from the ONE next transform and opens an
 * EnterMappingDialog with this information. After the user did the mapping, those information is
 * put into the Select/Rename table.
 */
private void generateMappings() {
    if (!checkInput()) {
        return;
    }
    // Determine the source and target fields...
    // 
    IRowMeta sourceFields;
    IRowMeta targetFields = new RowMeta();
    try {
        sourceFields = pipelineMeta.getPrevTransformFields(variables, transformMeta);
    } catch (HopException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "SalesforceUpsertDialog.DoMapping.UnableToFindSourceFields.Title"), BaseMessages.getString(PKG, "SalesforceUpsertDialog.DoMapping.UnableToFindSourceFields.Message"), e);
        return;
    }
    try {
        String[] fields = getModuleFields();
        for (int i = 0; i < fields.length; i++) {
            targetFields.addValueMeta(new ValueMetaNone(fields[i]));
        }
    } catch (Exception e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "SalesforceUpsertDialog.DoMapping.UnableToFindTargetFields.Title"), BaseMessages.getString(PKG, "SalesforceUpsertDialog.DoMapping.UnableToFindTargetFields.Message"), e);
        return;
    }
    String[] inputNames = new String[sourceFields.size()];
    for (int i = 0; i < sourceFields.size(); i++) {
        IValueMeta value = sourceFields.getValueMeta(i);
        inputNames[i] = value.getName();
    }
    // Create the existing mapping list...
    // 
    List<SourceToTargetMapping> mappings = new ArrayList<>();
    StringBuffer missingSourceFields = new StringBuffer();
    StringBuffer missingTargetFields = new StringBuffer();
    int nrFields = wReturn.nrNonEmpty();
    for (int i = 0; i < nrFields; i++) {
        TableItem item = wReturn.getNonEmpty(i);
        String source = item.getText(2);
        String target = item.getText(1);
        int sourceIndex = sourceFields.indexOfValue(source);
        if (sourceIndex < 0) {
            missingSourceFields.append(Const.CR + "   " + source + " --> " + target);
        }
        int targetIndex = targetFields.indexOfValue(target);
        if (targetIndex < 0) {
            missingTargetFields.append(Const.CR + "   " + source + " --> " + target);
        }
        if (sourceIndex < 0 || targetIndex < 0) {
            continue;
        }
        SourceToTargetMapping mapping = new SourceToTargetMapping(sourceIndex, targetIndex);
        mappings.add(mapping);
    }
    // 
    if (missingSourceFields.length() > 0 || missingTargetFields.length() > 0) {
        String message = "";
        if (missingSourceFields.length() > 0) {
            message += BaseMessages.getString(PKG, "SalesforceUpsertDialog.DoMapping.SomeSourceFieldsNotFound", missingSourceFields.toString()) + Const.CR;
        }
        if (missingTargetFields.length() > 0) {
            message += BaseMessages.getString(PKG, "SalesforceUpsertDialog.DoMapping.SomeTargetFieldsNotFound", missingSourceFields.toString()) + Const.CR;
        }
        message += Const.CR;
        message += BaseMessages.getString(PKG, "SalesforceUpsertDialog.DoMapping.SomeFieldsNotFoundContinue") + Const.CR;
        int answer = BaseDialog.openMessageBox(shell, BaseMessages.getString(PKG, "SalesforceUpsertDialog.DoMapping.SomeFieldsNotFoundTitle"), message, SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
        boolean goOn = (answer & SWT.OK) != 0;
        if (!goOn) {
            return;
        }
    }
    EnterMappingDialog d = new EnterMappingDialog(SalesforceUpsertDialog.this.shell, sourceFields.getFieldNames(), targetFields.getFieldNames(), mappings);
    mappings = d.open();
    // 
    if (mappings != null) {
        // Clear and re-populate!
        // 
        wReturn.table.removeAll();
        wReturn.table.setItemCount(mappings.size());
        for (int i = 0; i < mappings.size(); i++) {
            SourceToTargetMapping mapping = mappings.get(i);
            TableItem item = wReturn.table.getItem(i);
            item.setText(2, sourceFields.getValueMeta(mapping.getSourcePosition()).getName());
            item.setText(1, targetFields.getValueMeta(mapping.getTargetPosition()).getName());
        }
        wReturn.setRowNums();
        wReturn.optWidth(true);
    }
}
Also used : RowMeta(org.apache.hop.core.row.RowMeta) IRowMeta(org.apache.hop.core.row.IRowMeta) HopException(org.apache.hop.core.exception.HopException) IRowMeta(org.apache.hop.core.row.IRowMeta) EnterMappingDialog(org.apache.hop.ui.core.dialog.EnterMappingDialog) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) HopException(org.apache.hop.core.exception.HopException) IValueMeta(org.apache.hop.core.row.IValueMeta) ValueMetaNone(org.apache.hop.core.row.value.ValueMetaNone) SourceToTargetMapping(org.apache.hop.core.SourceToTargetMapping)

Aggregations

IRowMeta (org.apache.hop.core.row.IRowMeta)20 EnterMappingDialog (org.apache.hop.ui.core.dialog.EnterMappingDialog)20 HopException (org.apache.hop.core.exception.HopException)18 SourceToTargetMapping (org.apache.hop.core.SourceToTargetMapping)17 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)17 IValueMeta (org.apache.hop.core.row.IValueMeta)13 ArrayList (java.util.ArrayList)6 RowMeta (org.apache.hop.core.row.RowMeta)6 ITransformMeta (org.apache.hop.pipeline.transform.ITransformMeta)6 HopTransformException (org.apache.hop.core.exception.HopTransformException)4 HopExtensionPoint (org.apache.hop.core.extension.HopExtensionPoint)3 ValueMetaNone (org.apache.hop.core.row.value.ValueMetaNone)3 ValueMetaString (org.apache.hop.core.row.value.ValueMetaString)3 TransformMeta (org.apache.hop.pipeline.transform.TransformMeta)3 BaseTransformMeta (org.apache.hop.pipeline.transform.BaseTransformMeta)2 HopGui (org.apache.hop.ui.hopgui.HopGui)2 EditRowsDialog (org.apache.hop.ui.testing.EditRowsDialog)2 Field (com.sforce.soap.partner.Field)1 FieldType (com.sforce.soap.partner.FieldType)1 List (java.util.List)1