Search in sources :

Example 11 with UnknownParamException

use of org.pentaho.di.core.parameters.UnknownParamException in project pentaho-kettle by pentaho.

the class MappingMeta method getFields.

public void getFields(RowMetaInterface row, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
    // First load some interesting data...
    // Then see which fields get added to the row.
    // 
    TransMeta mappingTransMeta = null;
    try {
        mappingTransMeta = loadMappingMeta(this, repository, metaStore, space);
    } catch (KettleException e) {
        throw new KettleStepException(BaseMessages.getString(PKG, "MappingMeta.Exception.UnableToLoadMappingTransformation"), e);
    }
    // for instance)
    if (mappingParameters != null) {
        // 
        if (mappingParameters.isInheritingAllVariables()) {
            mappingTransMeta.copyVariablesFrom(space);
        }
        // Just set the variables in the transformation statically.
        // This just means: set a number of variables or parameter values:
        // 
        List<String> subParams = Arrays.asList(mappingTransMeta.listParameters());
        for (int i = 0; i < mappingParameters.getVariable().length; i++) {
            String name = mappingParameters.getVariable()[i];
            String value = space.environmentSubstitute(mappingParameters.getInputField()[i]);
            if (!Utils.isEmpty(name) && !Utils.isEmpty(value)) {
                if (subParams.contains(name)) {
                    try {
                        mappingTransMeta.setParameterValue(name, value);
                    } catch (UnknownParamException e) {
                    // this is explicitly checked for up front
                    }
                }
                mappingTransMeta.setVariable(name, value);
            }
        }
    }
    // Keep track of all the fields that need renaming...
    // 
    List<MappingValueRename> inputRenameList = new ArrayList<MappingValueRename>();
    /*
     * Before we ask the mapping outputs anything, we should teach the mapping input steps in the sub-transformation
     * about the data coming in...
     */
    for (MappingIODefinition definition : inputMappings) {
        RowMetaInterface inputRowMeta;
        if (definition.isMainDataPath() || Utils.isEmpty(definition.getInputStepname())) {
            // The row metadata, what we pass to the mapping input step
            // definition.getOutputStep(), is "row"
            // However, we do need to re-map some fields...
            // 
            inputRowMeta = row.clone();
            if (!inputRowMeta.isEmpty()) {
                for (MappingValueRename valueRename : definition.getValueRenames()) {
                    ValueMetaInterface valueMeta = inputRowMeta.searchValueMeta(valueRename.getSourceValueName());
                    if (valueMeta == null) {
                        throw new KettleStepException(BaseMessages.getString(PKG, "MappingMeta.Exception.UnableToFindField", valueRename.getSourceValueName()));
                    }
                    valueMeta.setName(valueRename.getTargetValueName());
                }
            }
        } else {
            // The row metadata that goes to the info mapping input comes from the
            // specified step
            // In fact, it's one of the info steps that is going to contain this
            // information...
            // 
            String[] infoSteps = getInfoSteps();
            int infoStepIndex = Const.indexOfString(definition.getInputStepname(), infoSteps);
            if (infoStepIndex < 0) {
                throw new KettleStepException(BaseMessages.getString(PKG, "MappingMeta.Exception.UnableToFindMetadataInfo", definition.getInputStepname()));
            }
            if (info[infoStepIndex] != null) {
                inputRowMeta = info[infoStepIndex].clone();
            } else {
                inputRowMeta = null;
            }
        }
        // What is this mapping input step?
        // 
        StepMeta mappingInputStep = mappingTransMeta.findMappingInputStep(definition.getOutputStepname());
        // We're certain it's a MappingInput step...
        // 
        MappingInputMeta mappingInputMeta = (MappingInputMeta) mappingInputStep.getStepMetaInterface();
        // Inform the mapping input step about what it's going to receive...
        // 
        mappingInputMeta.setInputRowMeta(inputRowMeta);
        // What values are we changing names for?
        // 
        mappingInputMeta.setValueRenames(definition.getValueRenames());
        // 
        if (definition.isRenamingOnOutput()) {
            Mapping.addInputRenames(inputRenameList, definition.getValueRenames());
        }
    }
    // All the mapping steps now know what they will be receiving.
    // That also means that the sub-transformation / mapping has everything it
    // needs.
    // So that means that the MappingOutput steps know exactly what the output
    // is going to be.
    // That could basically be anything.
    // It also could have absolutely no resemblance to what came in on the
    // input.
    // The relative old approach is therefore no longer suited.
    // 
    // OK, but what we *can* do is have the MappingOutput step rename the
    // appropriate fields.
    // The mapping step will tell this step how it's done.
    // 
    // Let's look for the mapping output step that is relevant for this actual
    // call...
    // 
    MappingIODefinition mappingOutputDefinition = null;
    if (nextStep == null) {
        // 
        for (MappingIODefinition definition : outputMappings) {
            if (definition.isMainDataPath() || Utils.isEmpty(definition.getOutputStepname())) {
                // This is the definition to use...
                // 
                mappingOutputDefinition = definition;
            }
        }
    } else {
        for (MappingIODefinition definition : outputMappings) {
            if (nextStep.getName().equals(definition.getOutputStepname()) || definition.isMainDataPath() || Utils.isEmpty(definition.getOutputStepname())) {
                mappingOutputDefinition = definition;
            }
        }
    }
    if (mappingOutputDefinition == null) {
        throw new KettleStepException(BaseMessages.getString(PKG, "MappingMeta.Exception.UnableToFindMappingDefinition"));
    }
    // OK, now find the mapping output step in the mapping...
    // This method in TransMeta takes into account a number of things, such as
    // the step not specified, etc.
    // The method never returns null but throws an exception.
    // 
    StepMeta mappingOutputStep = mappingTransMeta.findMappingOutputStep(mappingOutputDefinition.getInputStepname());
    // We know it's a mapping output step...
    MappingOutputMeta mappingOutputMeta = (MappingOutputMeta) mappingOutputStep.getStepMetaInterface();
    // Change a few columns.
    mappingOutputMeta.setOutputValueRenames(mappingOutputDefinition.getValueRenames());
    // Perhaps we need to change a few input columns back to the original?
    // 
    mappingOutputMeta.setInputValueRenames(inputRenameList);
    // Now we know wat's going to come out of there...
    // This is going to be the full row, including all the remapping, etc.
    // 
    RowMetaInterface mappingOutputRowMeta = mappingTransMeta.getStepFields(mappingOutputStep);
    row.clear();
    row.addRowMeta(mappingOutputRowMeta);
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) KettleStepException(org.pentaho.di.core.exception.KettleStepException) TransMeta(org.pentaho.di.trans.TransMeta) ArrayList(java.util.ArrayList) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) StepMeta(org.pentaho.di.trans.step.StepMeta) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) MappingOutputMeta(org.pentaho.di.trans.steps.mappingoutput.MappingOutputMeta) MappingInputMeta(org.pentaho.di.trans.steps.mappinginput.MappingInputMeta) UnknownParamException(org.pentaho.di.core.parameters.UnknownParamException)

Example 12 with UnknownParamException

use of org.pentaho.di.core.parameters.UnknownParamException in project pentaho-kettle by pentaho.

the class ConfigurationDialog method getParamsData.

protected void getParamsData() {
    wParams.clearAll(false);
    ArrayList<String> paramNames = new ArrayList<String>(configuration.getParams().keySet());
    Collections.sort(paramNames);
    for (int i = 0; i < paramNames.size(); i++) {
        String paramName = paramNames.get(i);
        String paramValue = configuration.getParams().get(paramName);
        String defaultValue;
        try {
            defaultValue = abstractMeta.getParameterDefault(paramName);
        } catch (UnknownParamException e) {
            defaultValue = "";
        }
        String description;
        try {
            description = abstractMeta.getParameterDescription(paramName);
        } catch (UnknownParamException e) {
            description = "";
        }
        TableItem tableItem = new TableItem(wParams.table, SWT.NONE);
        tableItem.setText(1, paramName);
        tableItem.setText(2, Const.NVL(defaultValue, ""));
        tableItem.setText(3, Const.NVL(paramValue, ""));
        tableItem.setText(4, Const.NVL(description, ""));
    }
    wParams.removeEmptyRows();
    wParams.setRowNums();
    wParams.optWidth(true);
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) ArrayList(java.util.ArrayList) UnknownParamException(org.pentaho.di.core.parameters.UnknownParamException) Point(org.eclipse.swt.graphics.Point)

Example 13 with UnknownParamException

use of org.pentaho.di.core.parameters.UnknownParamException in project pentaho-kettle by pentaho.

the class Job method activateParameters.

/*
   * (non-Javadoc)
   *
   * @see org.pentaho.di.core.parameters.NamedParams#activateParameters()
   */
public void activateParameters() {
    String[] keys = listParameters();
    for (String key : keys) {
        String value;
        try {
            value = getParameterValue(key);
        } catch (UnknownParamException e) {
            value = "";
        }
        String defValue;
        try {
            defValue = getParameterDefault(key);
        } catch (UnknownParamException e) {
            defValue = "";
        }
        if (Utils.isEmpty(value)) {
            setVariable(key, Const.NVL(defValue, ""));
        } else {
            setVariable(key, Const.NVL(value, ""));
        }
    }
}
Also used : UnknownParamException(org.pentaho.di.core.parameters.UnknownParamException) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString)

Example 14 with UnknownParamException

use of org.pentaho.di.core.parameters.UnknownParamException in project pentaho-kettle by pentaho.

the class JobDialog method getData.

/**
 * Copy information from the meta-data input to the dialog fields.
 */
public void getData() {
    wJobname.setText(Const.NVL(jobMeta.getName(), ""));
    wJobFilename.setText(Const.NVL(jobMeta.getFilename(), ""));
    wJobdescription.setText(Const.NVL(jobMeta.getDescription(), ""));
    wExtendeddescription.setText(Const.NVL(jobMeta.getExtendedDescription(), ""));
    wJobversion.setText(Const.NVL(jobMeta.getJobversion(), ""));
    wJobstatus.select(jobMeta.getJobstatus() - 1);
    wLogTypeList.select(0);
    showJobLogTableOptions((JobLogTable) logTables.get(0));
    if (jobMeta.getRepositoryDirectory() != null) {
        wDirectory.setText(jobMeta.getRepositoryDirectory().getPath());
    }
    if (jobMeta.getCreatedUser() != null) {
        wCreateUser.setText(jobMeta.getCreatedUser());
    }
    if (jobMeta.getCreatedDate() != null && jobMeta.getCreatedDate() != null) {
        wCreateDate.setText(jobMeta.getCreatedDate().toString());
    }
    if (jobMeta.getModifiedUser() != null) {
        wModUser.setText(jobMeta.getModifiedUser());
    }
    if (jobMeta.getModifiedDate() != null && jobMeta.getModifiedDate() != null) {
        wModDate.setText(jobMeta.getModifiedDate().toString());
    }
    wBatchTrans.setSelection(jobMeta.isBatchIdPassed());
    // The named parameters
    String[] parameters = jobMeta.listParameters();
    for (int idx = 0; idx < parameters.length; idx++) {
        TableItem item = wParamFields.table.getItem(idx);
        String description;
        try {
            description = jobMeta.getParameterDescription(parameters[idx]);
        } catch (UnknownParamException e) {
            description = "";
        }
        String defValue;
        try {
            defValue = jobMeta.getParameterDefault(parameters[idx]);
        } catch (UnknownParamException e) {
            defValue = "";
        }
        item.setText(1, parameters[idx]);
        item.setText(2, Const.NVL(defValue, ""));
        item.setText(3, Const.NVL(description, ""));
    }
    wParamFields.setRowNums();
    wParamFields.optWidth(true);
    wSharedObjectsFile.setText(Const.NVL(jobMeta.getSharedObjectsFile(), ""));
    sharedObjectsFileChanged = false;
    for (JobDialogPluginInterface extraTab : extraTabs) {
        extraTab.getData(jobMeta);
    }
    setFlags();
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) UnknownParamException(org.pentaho.di.core.parameters.UnknownParamException)

Example 15 with UnknownParamException

use of org.pentaho.di.core.parameters.UnknownParamException in project pentaho-kettle by pentaho.

the class TransDialog method getData.

/**
 * Copy information from the meta-data input to the dialog fields.
 */
public void getData() {
    wTransname.setText(Const.NVL(transMeta.getName(), ""));
    wTransFilename.setText(Const.NVL(transMeta.getFilename(), ""));
    wTransdescription.setText(Const.NVL(transMeta.getDescription(), ""));
    wExtendeddescription.setText(Const.NVL(transMeta.getExtendedDescription(), ""));
    wTransversion.setText(Const.NVL(transMeta.getTransversion(), ""));
    wTransstatus.select(transMeta.getTransstatus() - 1);
    if (transMeta.getCreatedUser() != null) {
        wCreateUser.setText(transMeta.getCreatedUser());
    }
    if (transMeta.getCreatedDate() != null) {
        wCreateDate.setText(transMeta.getCreatedDate().toString());
    }
    if (transMeta.getModifiedUser() != null) {
        wModUser.setText(transMeta.getModifiedUser());
    }
    if (transMeta.getModifiedDate() != null) {
        wModDate.setText(transMeta.getModifiedDate().toString());
    }
    if (transMeta.getMaxDateConnection() != null) {
        wMaxdateconnection.setText(transMeta.getMaxDateConnection().getName());
    }
    if (transMeta.getMaxDateTable() != null) {
        wMaxdatetable.setText(transMeta.getMaxDateTable());
    }
    if (transMeta.getMaxDateField() != null) {
        wMaxdatefield.setText(transMeta.getMaxDateField());
    }
    wMaxdateoffset.setText(Double.toString(transMeta.getMaxDateOffset()));
    wMaxdatediff.setText(Double.toString(transMeta.getMaxDateDifference()));
    // The dependencies
    for (int i = 0; i < transMeta.nrDependencies(); i++) {
        TableItem item = wFields.table.getItem(i);
        TransDependency td = transMeta.getDependency(i);
        DatabaseMeta conn = td.getDatabase();
        String table = td.getTablename();
        String field = td.getFieldname();
        if (conn != null) {
            item.setText(1, conn.getName());
        }
        if (table != null) {
            item.setText(2, table);
        }
        if (field != null) {
            item.setText(3, field);
        }
    }
    // The named parameters
    String[] parameters = transMeta.listParameters();
    for (int idx = 0; idx < parameters.length; idx++) {
        TableItem item = wParamFields.table.getItem(idx);
        String defValue;
        try {
            defValue = transMeta.getParameterDefault(parameters[idx]);
        } catch (UnknownParamException e) {
            defValue = "";
        }
        String description;
        try {
            description = transMeta.getParameterDescription(parameters[idx]);
        } catch (UnknownParamException e) {
            description = "";
        }
        item.setText(1, parameters[idx]);
        item.setText(2, Const.NVL(defValue, ""));
        item.setText(3, Const.NVL(description, ""));
    }
    wSizeRowset.setText(Integer.toString(transMeta.getSizeRowset()));
    wUniqueConnections.setSelection(transMeta.isUsingUniqueConnections());
    wShowFeedback.setSelection(transMeta.isFeedbackShown());
    wFeedbackSize.setText(Integer.toString(transMeta.getFeedbackSize()));
    wSharedObjectsFile.setText(Const.NVL(transMeta.getSharedObjectsFile(), ""));
    wManageThreads.setSelection(transMeta.isUsingThreadPriorityManagment());
    wTransformationType.setText(transMeta.getTransformationType().getDescription());
    wFields.setRowNums();
    wFields.optWidth(true);
    wParamFields.setRowNums();
    wParamFields.optWidth(true);
    // Directory:
    if (transMeta.getRepositoryDirectory() != null && transMeta.getRepositoryDirectory().getPath() != null) {
        wDirectory.setText(transMeta.getRepositoryDirectory().getPath());
    }
    // Performance monitoring tab:
    // 
    wEnableStepPerfMonitor.setSelection(transMeta.isCapturingStepPerformanceSnapShots());
    wStepPerfInterval.setText(Long.toString(transMeta.getStepPerformanceCapturingDelay()));
    wStepPerfMaxSize.setText(Const.NVL(transMeta.getStepPerformanceCapturingSizeLimit(), ""));
    if (rep == null) {
        wTransname.selectAll();
        wTransname.setFocus();
    }
    for (TransDialogPluginInterface extraTab : extraTabs) {
        try {
            extraTab.getData(transMeta);
        } catch (Exception e) {
            new ErrorDialog(shell, "Error", "Error adding extra plugin tab", e);
        }
    }
    setFlags();
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) TransDependency(org.pentaho.di.trans.TransDependency) UnknownParamException(org.pentaho.di.core.parameters.UnknownParamException) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) DuplicateParamException(org.pentaho.di.core.parameters.DuplicateParamException) UnknownParamException(org.pentaho.di.core.parameters.UnknownParamException) KettleException(org.pentaho.di.core.exception.KettleException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException)

Aggregations

UnknownParamException (org.pentaho.di.core.parameters.UnknownParamException)17 KettleException (org.pentaho.di.core.exception.KettleException)7 Date (java.util.Date)5 ArrayList (java.util.ArrayList)4 ExecutionException (java.util.concurrent.ExecutionException)4 JobMeta (org.pentaho.di.job.JobMeta)4 TransMeta (org.pentaho.di.trans.TransMeta)4 IOException (java.io.IOException)3 TableItem (org.eclipse.swt.widgets.TableItem)3 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)3 Job (org.pentaho.di.job.Job)3 Repository (org.pentaho.di.repository.Repository)3 IParamInfo (org.pentaho.metaverse.api.model.IParamInfo)3 ParamInfo (org.pentaho.metaverse.impl.model.ParamInfo)3 Timestamp (java.sql.Timestamp)2 KettleClientEnvironment (org.pentaho.di.core.KettleClientEnvironment)2 Result (org.pentaho.di.core.Result)2 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)2 KettleStepException (org.pentaho.di.core.exception.KettleStepException)2 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)2