Search in sources :

Example 1 with DimensionField

use of org.pentaho.di.palo.core.DimensionField in project pentaho-kettle by pentaho.

the class PaloCellInputMeta method readRep.

@Override
public void readRep(Repository rep, IMetaStore metaStore, ObjectId idStep, List<DatabaseMeta> databases) throws KettleException {
    try {
        this.databaseMeta = rep.loadDatabaseMetaFromStepAttribute(idStep, "connection", databases);
        this.cube = rep.getStepAttributeString(idStep, "cube");
        String cubeMeasureName = rep.getStepAttributeString(idStep, "cubemeasurename");
        String cubeMeasureType = rep.getStepAttributeString(idStep, "cubemeasuretype");
        this.cubeMeasure = new DimensionField("Measure", cubeMeasureName, cubeMeasureType);
        int nrFields = rep.countNrStepAttributes(idStep, "dimensionname");
        for (int i = 0; i < nrFields; i++) {
            String dimensionName = rep.getStepAttributeString(idStep, i, "dimensionname");
            String fieldName = rep.getStepAttributeString(idStep, i, "fieldname");
            String fieldType = rep.getStepAttributeString(idStep, i, "fieldtype");
            this.fields.add(new DimensionField(dimensionName, fieldName, fieldType));
        }
    } catch (Exception e) {
        throw new KettleException("Unexpected error reading step" + " information from the repository", e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) DimensionField(org.pentaho.di.palo.core.DimensionField) KettleException(org.pentaho.di.core.exception.KettleException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleStepException(org.pentaho.di.core.exception.KettleStepException)

Example 2 with DimensionField

use of org.pentaho.di.palo.core.DimensionField in project pentaho-kettle by pentaho.

the class PaloCellOutputMeta method getXML.

public final String getXML() {
    StringBuffer retval = new StringBuffer();
    retval.append("    ").append(XMLHandler.addTagValue("connection", databaseMeta == null ? "" : databaseMeta.getName()));
    retval.append("    ").append(XMLHandler.addTagValue("cube", this.cube));
    retval.append("    ").append(XMLHandler.addTagValue("measuretype", measureType));
    retval.append("    ").append(XMLHandler.addTagValue("updateMode", updateMode));
    retval.append("    ").append(XMLHandler.addTagValue("splashMode", splashMode));
    retval.append("    ").append(XMLHandler.addTagValue("clearcube", clearCube));
    retval.append("    ").append(XMLHandler.addTagValue("enableDimensionCache", enableDimensionCache));
    retval.append("    ").append(XMLHandler.addTagValue("preloadDimensionCache", preloadDimensionCache));
    retval.append("    ").append(XMLHandler.addTagValue("commitSize", commitSize));
    retval.append("    <fields>").append(Const.CR);
    for (DimensionField field : this.fields) {
        retval.append("      <field>").append(Const.CR);
        retval.append("        ").append(XMLHandler.addTagValue("dimensionname", field.getDimensionName()));
        retval.append("        ").append(XMLHandler.addTagValue("fieldname", field.getFieldName()));
        retval.append("        ").append(XMLHandler.addTagValue("fieldtype", field.getFieldType()));
        retval.append("      </field>").append(Const.CR);
    }
    retval.append("    </fields>").append(Const.CR);
    retval.append("    <measures>").append(Const.CR);
    // then Kettle displayed an error saying the argument can not be null.
    if (measureField.getDimensionName() != "") {
        retval.append("      <measure>").append(Const.CR);
        retval.append("        ").append(XMLHandler.addTagValue("measurename", measureField.getDimensionName()));
        if (measureField.getFieldName() == "") {
            retval.append("        ").append(XMLHandler.addTagValue("measurefieldname", "CHOOSE FIELD"));
        } else {
            retval.append("        ").append(XMLHandler.addTagValue("measurefieldname", measureField.getFieldName()));
        }
        retval.append("        ").append(XMLHandler.addTagValue("measurefieldtype", measureField.getFieldType()));
        retval.append("      </measure>").append(Const.CR);
    }
    retval.append("    </measures>").append(Const.CR);
    return retval.toString();
}
Also used : DimensionField(org.pentaho.di.palo.core.DimensionField)

Example 3 with DimensionField

use of org.pentaho.di.palo.core.DimensionField in project pentaho-kettle by pentaho.

the class PaloCellOutputMeta method check.

public final void check(final List<CheckResultInterface> remarks, final TransMeta transMeta, final StepMeta stepMeta, final RowMetaInterface prev, final String[] input, final String[] output, final RowMetaInterface info, VariableSpace space, Repository repository, IMetaStore metaStore) {
    CheckResult cr;
    if (databaseMeta != null) {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, "Connection exists", stepMeta);
        remarks.add(cr);
        final PaloHelper helper = new PaloHelper(databaseMeta, DefaultLogLevel.getLogLevel());
        try {
            helper.connect();
            cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, "Connection to database OK", stepMeta);
            remarks.add(cr);
            if (!Utils.isEmpty(this.cube)) {
                cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, "The name of the cube is entered", stepMeta);
                remarks.add(cr);
            } else {
                cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "The name of the cube is missing.", stepMeta);
                remarks.add(cr);
            }
            if (this.measureField == null || Utils.isEmpty(this.measureField.getFieldName())) {
                cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "Measure field is empty.", stepMeta);
                remarks.add(cr);
            } else {
                if (Utils.isEmpty(this.measureField.getFieldType())) {
                    cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "Measure field type is empty.", stepMeta);
                    remarks.add(cr);
                }
            }
            if (this.fields == null || this.fields.size() == 0) {
                cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "Cell Output Fields are empty.", stepMeta);
                remarks.add(cr);
            } else {
                for (DimensionField field : this.fields) {
                    if (Utils.isEmpty(field.getFieldName())) {
                        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "Input field for dimension " + field.getDimensionName() + " is empty.", stepMeta);
                        remarks.add(cr);
                    }
                    if (Utils.isEmpty(field.getFieldType())) {
                        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "Input field type for dimension " + field.getDimensionName() + " is empty.", stepMeta);
                        remarks.add(cr);
                    }
                }
            }
        } catch (KettleException e) {
            cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "An error occurred: " + e.getMessage(), stepMeta);
            remarks.add(cr);
        } finally {
            helper.disconnect();
        }
    } else {
        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "Please select or create a connection to use", stepMeta);
        remarks.add(cr);
    }
}
Also used : PaloHelper(org.pentaho.di.palo.core.PaloHelper) KettleException(org.pentaho.di.core.exception.KettleException) DimensionField(org.pentaho.di.palo.core.DimensionField) CheckResult(org.pentaho.di.core.CheckResult)

Example 4 with DimensionField

use of org.pentaho.di.palo.core.DimensionField in project pentaho-kettle by pentaho.

the class PaloCellOutputMeta method readRep.

public void readRep(Repository rep, IMetaStore metaStore, ObjectId idStep, List<DatabaseMeta> databases) throws KettleException {
    try {
        this.databaseMeta = rep.loadDatabaseMetaFromStepAttribute(idStep, "connection", databases);
        this.cube = rep.getStepAttributeString(idStep, "cube");
        this.measureType = rep.getStepAttributeString(idStep, "measuretype");
        this.updateMode = rep.getStepAttributeString(idStep, "updateMode");
        this.splashMode = rep.getStepAttributeString(idStep, "splashMode");
        this.clearCube = rep.getStepAttributeBoolean(idStep, "clearcube");
        /* For backwards compatibility */
        try {
            this.enableDimensionCache = rep.getStepAttributeBoolean(idStep, "enableDimensionCache");
            this.preloadDimensionCache = rep.getStepAttributeBoolean(idStep, "preloadDimensionCache");
            this.commitSize = (int) rep.getStepAttributeInteger(idStep, "commitSize");
            if (this.commitSize <= 0) {
                this.setCommitSize(1000);
            }
        } catch (Exception e) {
            enableDimensionCache = false;
            preloadDimensionCache = false;
            commitSize = 1000;
        }
        int nrFields = rep.countNrStepAttributes(idStep, "dimensionname");
        for (int i = 0; i < nrFields; i++) {
            String dimensionName = rep.getStepAttributeString(idStep, i, "dimensionname");
            String fieldName = rep.getStepAttributeString(idStep, i, "fieldname");
            String fieldType = rep.getStepAttributeString(idStep, i, "fieldtype");
            this.fields.add(new DimensionField(dimensionName, fieldName, fieldType));
        }
        String measureName = rep.getStepAttributeString(idStep, "measurename");
        String measureFieldName = rep.getStepAttributeString(idStep, "measurefieldname");
        String measureFieldType = rep.getStepAttributeString(idStep, "measurefieldtype");
        this.measureField = new DimensionField(measureName, measureFieldName, measureFieldType);
        setDefault();
    } catch (Exception e) {
        throw new KettleException("Unexpected error reading step information from the repository", e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) DimensionField(org.pentaho.di.palo.core.DimensionField) KettleException(org.pentaho.di.core.exception.KettleException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException)

Example 5 with DimensionField

use of org.pentaho.di.palo.core.DimensionField in project pentaho-kettle by pentaho.

the class PaloCellInputDialog method preview.

private void preview() {
    PaloCellInputMeta oneMeta = new PaloCellInputMeta();
    try {
        getInfo(oneMeta);
        if (oneMeta.getFields() == null || oneMeta.getFields().size() == 0) {
            throw new KettleException("Fields must be defined to do a preview");
        } else {
            for (DimensionField field : oneMeta.getFields()) {
                if (Utils.isEmpty(field.getFieldType())) {
                    throw new KettleException("All fields must have an output type to do the preview");
                }
            }
        }
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "RowGeneratorDialog.Illegal.Dialog.Settings.Title"), BaseMessages.getString(PKG, "RowGeneratorDialog.Illegal.Dialog.Settings.Message"), e);
        return;
    }
    TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, textStepName.getText());
    EnterNumberDialog numberDialog = new EnterNumberDialog(shell, 500, BaseMessages.getString(PKG, "System.Dialog.EnterPreviewSize.Title"), BaseMessages.getString(PKG, "System.Dialog.EnterPreviewSize.Message"));
    int previewSize = numberDialog.open();
    if (previewSize > 0) {
        TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, previewMeta, new String[] { textStepName.getText() }, new int[] { previewSize });
        progressDialog.open();
        Trans trans = progressDialog.getTrans();
        String loggingText = progressDialog.getLoggingText();
        if (!progressDialog.isCancelled()) {
            if (trans.getResult() != null && trans.getResult().getNrErrors() > 0) {
                EnterTextDialog etd = new EnterTextDialog(shell, BaseMessages.getString(PKG, "System.Dialog.PreviewError.Title"), BaseMessages.getString(PKG, "System.Dialog.PreviewError.Message"), loggingText, true);
                etd.setReadOnly();
                etd.open();
            }
        }
        PreviewRowsDialog prd = new PreviewRowsDialog(shell, transMeta, SWT.NONE, textStepName.getText(), progressDialog.getPreviewRowsMeta(textStepName.getText()), progressDialog.getPreviewRows(textStepName.getText()), loggingText);
        prd.open();
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) PaloCellInputMeta(org.pentaho.di.trans.steps.palo.cellinput.PaloCellInputMeta) DimensionField(org.pentaho.di.palo.core.DimensionField) TransPreviewProgressDialog(org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog) TransMeta(org.pentaho.di.trans.TransMeta) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) EnterNumberDialog(org.pentaho.di.ui.core.dialog.EnterNumberDialog) Trans(org.pentaho.di.trans.Trans)

Aggregations

DimensionField (org.pentaho.di.palo.core.DimensionField)13 KettleException (org.pentaho.di.core.exception.KettleException)9 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)4 ArrayList (java.util.ArrayList)2 CheckResult (org.pentaho.di.core.CheckResult)2 KettleStepException (org.pentaho.di.core.exception.KettleStepException)2 PaloHelper (org.pentaho.di.palo.core.PaloHelper)2 Node (org.w3c.dom.Node)2 TableItem (org.eclipse.swt.widgets.TableItem)1 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)1 PaloOption (org.pentaho.di.palo.core.PaloOption)1 Trans (org.pentaho.di.trans.Trans)1 TransMeta (org.pentaho.di.trans.TransMeta)1 PaloCellInputMeta (org.pentaho.di.trans.steps.palo.cellinput.PaloCellInputMeta)1 EnterNumberDialog (org.pentaho.di.ui.core.dialog.EnterNumberDialog)1 EnterTextDialog (org.pentaho.di.ui.core.dialog.EnterTextDialog)1 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)1 PreviewRowsDialog (org.pentaho.di.ui.core.dialog.PreviewRowsDialog)1 ColumnInfo (org.pentaho.di.ui.core.widget.ColumnInfo)1 TransPreviewProgressDialog (org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog)1