Search in sources :

Example 1 with PaloDimensionLevel

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

the class PaloDimInputMeta 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.dimension = XMLHandler.getTagValue(stepnode, "dimension");
        baseElementsOnly = (XMLHandler.getTagValue(stepnode, "baseElementsOnly") == null ? false : XMLHandler.getTagValue(stepnode, "baseElementsOnly").equals("Y") ? true : false);
        this.levels = new ArrayList<PaloDimensionLevel>();
        Node levels = XMLHandler.getSubNode(stepnode, "levels");
        int nrLevels = XMLHandler.countNodes(levels, "level");
        for (int i = 0; i < nrLevels; i++) {
            Node fnode = XMLHandler.getSubNodeByNr(levels, "level", i);
            String levelName = XMLHandler.getTagValue(fnode, "levelname");
            String levelNumber = XMLHandler.getTagValue(fnode, "levelnumber");
            String fieldName = XMLHandler.getTagValue(fnode, "fieldname");
            String fieldType = XMLHandler.getTagValue(fnode, "fieldtype");
            this.levels.add(new PaloDimensionLevel(levelName, Integer.parseInt(levelNumber), fieldName, fieldType));
        }
    } catch (Exception e) {
        throw new KettleXMLException("Unable to load step info from XML", e);
    }
}
Also used : PaloDimensionLevel(org.pentaho.di.palo.core.PaloDimensionLevel) 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 2 with PaloDimensionLevel

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

the class PaloDimInputMeta method check.

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(dimension)) {
                cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, "The name of the dimension is entered", stepMeta);
                remarks.add(cr);
            } else {
                cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "The name of the dimension is missing.", stepMeta);
                remarks.add(cr);
            }
            if (this.levels == null || this.levels.size() == 0) {
                cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "Dimension Input Fields are empty.", stepMeta);
                remarks.add(cr);
            } else {
                for (PaloDimensionLevel level : this.levels) {
                    if (Utils.isEmpty(level.getLevelName())) {
                        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "Level Name for Level " + level.getLevelNumber() + " is empty.", stepMeta);
                        remarks.add(cr);
                    }
                    if (Utils.isEmpty(level.getFieldName())) {
                        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "Output Field Name for Level " + level.getLevelNumber() + " is empty.", stepMeta);
                        remarks.add(cr);
                    }
                    if (Utils.isEmpty(level.getFieldType())) {
                        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "Level Type for Level " + level.getLevelNumber() + " 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) PaloDimensionLevel(org.pentaho.di.palo.core.PaloDimensionLevel) CheckResult(org.pentaho.di.core.CheckResult)

Example 3 with PaloDimensionLevel

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

the class PaloDimInputMeta method getXML.

public String getXML() {
    StringBuffer retval = new StringBuffer();
    retval.append("    ").append(XMLHandler.addTagValue("connection", databaseMeta == null ? "" : databaseMeta.getName()));
    retval.append("    ").append(XMLHandler.addTagValue("dimension", dimension));
    retval.append("    ").append(XMLHandler.addTagValue("baseElementsOnly", baseElementsOnly));
    retval.append("    <levels>").append(Const.CR);
    for (PaloDimensionLevel level : levels) {
        retval.append("      <level>").append(Const.CR);
        retval.append("        ").append(XMLHandler.addTagValue("levelname", level.getLevelName()));
        retval.append("        ").append(XMLHandler.addTagValue("levelnumber", level.getLevelNumber()));
        retval.append("        ").append(XMLHandler.addTagValue("fieldname", level.getFieldName()));
        retval.append("        ").append(XMLHandler.addTagValue("fieldtype", level.getFieldType()));
        retval.append("      </level>").append(Const.CR);
    }
    retval.append("    </levels>").append(Const.CR);
    return retval.toString();
}
Also used : PaloDimensionLevel(org.pentaho.di.palo.core.PaloDimensionLevel)

Example 4 with PaloDimensionLevel

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

the class PaloDimOutputMeta 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("dimension", dimension));
    retval.append("    ").append(XMLHandler.addTagValue("elementtype", elementType));
    retval.append("    ").append(XMLHandler.addTagValue("createdimension", createNewDimension));
    retval.append("    ").append(XMLHandler.addTagValue("cleardimension", clearDimension));
    retval.append("    ").append(XMLHandler.addTagValue("clearconsolidations", clearConsolidations));
    retval.append("    ").append(XMLHandler.addTagValue("recreatedimension", recreateDimension));
    retval.append("    ").append(XMLHandler.addTagValue("enableElementCache", enableElementCache));
    retval.append("    ").append(XMLHandler.addTagValue("preloadElementCache", preloadElementCache));
    retval.append("    <levels>").append(Const.CR);
    for (PaloDimensionLevel level : levels) {
        retval.append("      <level>").append(Const.CR);
        retval.append("        ").append(XMLHandler.addTagValue("levelname", level.getLevelName()));
        retval.append("        ").append(XMLHandler.addTagValue("levelnumber", level.getLevelNumber()));
        retval.append("        ").append(XMLHandler.addTagValue("fieldname", level.getFieldName()));
        retval.append("        ").append(XMLHandler.addTagValue("consolidationfieldname", level.getConsolidationFieldName()));
        retval.append("      </level>").append(Const.CR);
    }
    retval.append("    </levels>").append(Const.CR);
    return retval.toString();
}
Also used : PaloDimensionLevel(org.pentaho.di.palo.core.PaloDimensionLevel)

Example 5 with PaloDimensionLevel

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

the class PaloDimOutputMeta 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(dimension)) {
                cr = new CheckResult(CheckResultInterface.TYPE_RESULT_OK, "The name of the dimension is entered", stepMeta);
                remarks.add(cr);
            } else {
                cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "The name of the dimension is missing.", stepMeta);
                remarks.add(cr);
            }
            if (this.levels == null || this.levels.size() == 0) {
                cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "Dimension Output Fields are empty.", stepMeta);
                remarks.add(cr);
            } else {
                for (PaloDimensionLevel level : this.levels) {
                    if (Utils.isEmpty(level.getLevelName())) {
                        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "Level Name for Level " + level.getLevelNumber() + " is empty.", stepMeta);
                        remarks.add(cr);
                    }
                    if (Utils.isEmpty(level.getFieldName())) {
                        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "Input Field Name for Level " + level.getLevelNumber() + " is empty.", stepMeta);
                        remarks.add(cr);
                    }
                    if (Utils.isEmpty(level.getFieldType())) {
                        cr = new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "Level Type for Level " + level.getLevelNumber() + " 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) PaloDimensionLevel(org.pentaho.di.palo.core.PaloDimensionLevel) CheckResult(org.pentaho.di.core.CheckResult)

Aggregations

PaloDimensionLevel (org.pentaho.di.palo.core.PaloDimensionLevel)14 KettleException (org.pentaho.di.core.exception.KettleException)8 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)4 ArrayList (java.util.ArrayList)3 CheckResult (org.pentaho.di.core.CheckResult)2 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)2 KettleStepException (org.pentaho.di.core.exception.KettleStepException)2 PaloHelper (org.pentaho.di.palo.core.PaloHelper)2 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)2 Node (org.w3c.dom.Node)2 List (java.util.List)1 PaloDimInputData (org.pentaho.di.trans.steps.palo.diminput.PaloDimInputData)1 PaloDimOutputData (org.pentaho.di.trans.steps.palo.dimoutput.PaloDimOutputData)1