Search in sources :

Example 11 with DimensionField

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

the class PaloCellInputMeta method check.

@Override
public 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(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.cubeMeasure == null) {
                cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "Measure field is empty.", stepMeta);
                remarks.add(cr);
            } else {
                if (Utils.isEmpty(this.cubeMeasure.getFieldName())) {
                    cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "Measure field Name is empty.", stepMeta);
                    remarks.add(cr);
                }
                if (Utils.isEmpty(this.cubeMeasure.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 Input 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, "Output field for dimension " + field.getDimensionName() + " is empty.", stepMeta);
                        remarks.add(cr);
                    }
                    if (Utils.isEmpty(field.getFieldType())) {
                        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "Output 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 12 with DimensionField

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

the class PaloCellInputMeta method readData.

private void readData(final Node stepnode, final List<? extends SharedObjectInterface> databases) throws KettleXMLException {
    try {
        this.databaseMeta = DatabaseMeta.findDatabase(databases, XMLHandler.getTagValue(stepnode, "connection"));
        this.cube = XMLHandler.getTagValue(stepnode, "cube");
        String cubeMeasureName = XMLHandler.getTagValue(stepnode, "cubemeasurename");
        String cubeMeasureType = XMLHandler.getTagValue(stepnode, "cubemeasuretype");
        this.cubeMeasure = new DimensionField("Measure", cubeMeasureName, cubeMeasureType);
        this.fields = new ArrayList<DimensionField>();
        Node levels = XMLHandler.getSubNode(stepnode, "fields");
        int nrLevels = XMLHandler.countNodes(levels, "field");
        for (int i = 0; i < nrLevels; i++) {
            Node fnode = XMLHandler.getSubNodeByNr(levels, "field", i);
            String dimensionName = XMLHandler.getTagValue(fnode, "dimensionname");
            String fieldName = XMLHandler.getTagValue(fnode, "fieldname");
            String fieldType = XMLHandler.getTagValue(fnode, "fieldtype");
            this.fields.add(new DimensionField(dimensionName, fieldName, fieldType));
        }
    } catch (Exception e) {
        throw new KettleXMLException("Unable to load step info from XML", e);
    }
}
Also used : DimensionField(org.pentaho.di.palo.core.DimensionField) Node(org.w3c.dom.Node) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleException(org.pentaho.di.core.exception.KettleException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleStepException(org.pentaho.di.core.exception.KettleStepException)

Example 13 with DimensionField

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

the class PaloCellOutputMeta method readData.

private void readData(final Node stepnode, final List<? extends SharedObjectInterface> databases) throws KettleXMLException {
    try {
        databaseMeta = DatabaseMeta.findDatabase(databases, XMLHandler.getTagValue(stepnode, "connection"));
        this.cube = XMLHandler.getTagValue(stepnode, "cube");
        measureType = XMLHandler.getTagValue(stepnode, "measuretype");
        updateMode = XMLHandler.getTagValue(stepnode, "updateMode");
        splashMode = XMLHandler.getTagValue(stepnode, "splashMode");
        clearCube = XMLHandler.getTagValue(stepnode, "clearcube").equals("Y") ? true : false;
        /* For backwards compatibility */
        try {
            enableDimensionCache = XMLHandler.getTagValue(stepnode, "enableDimensionCache").equals("Y") ? true : false;
            preloadDimensionCache = XMLHandler.getTagValue(stepnode, "preloadDimensionCache").equals("Y") ? true : false;
            commitSize = Integer.parseInt(XMLHandler.getTagValue(stepnode, "commitSize"));
        } catch (Exception e) {
            enableDimensionCache = false;
            preloadDimensionCache = false;
            commitSize = 1000;
        }
        this.fields = new ArrayList<DimensionField>();
        Node fields = XMLHandler.getSubNode(stepnode, "fields");
        int nrFields = XMLHandler.countNodes(fields, "field");
        for (int i = 0; i < nrFields; i++) {
            Node fnode = XMLHandler.getSubNodeByNr(fields, "field", i);
            String dimensionName = XMLHandler.getTagValue(fnode, "dimensionname");
            String fieldName = XMLHandler.getTagValue(fnode, "fieldname");
            String fieldType = XMLHandler.getTagValue(fnode, "fieldtype");
            this.fields.add(new DimensionField(dimensionName, fieldName, fieldType));
        }
        Node measures = XMLHandler.getSubNode(stepnode, "measures");
        int nrMeasures = XMLHandler.countNodes(measures, "measure");
        // 
        for (int i = 0; i < nrMeasures; ) {
            Node fnode = XMLHandler.getSubNodeByNr(measures, "measure", i);
            String measureName = XMLHandler.getTagValue(fnode, "measurename");
            String fieldName = XMLHandler.getTagValue(fnode, "measurefieldname");
            String fieldType = XMLHandler.getTagValue(fnode, "measurefieldtype");
            this.measureField = new DimensionField(measureName, fieldName, fieldType);
            break;
        }
        setDefault();
    } catch (Exception e) {
        throw new KettleXMLException("Unable to load step info from XML", e);
    }
}
Also used : DimensionField(org.pentaho.di.palo.core.DimensionField) Node(org.w3c.dom.Node) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleException(org.pentaho.di.core.exception.KettleException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException)

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