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);
}
}
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);
}
}
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();
}
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();
}
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);
}
}
Aggregations