use of org.pentaho.di.trans.steps.userdefinedjavaclass.TargetStepDefinition in project pentaho-kettle by pentaho.
the class UserDefinedJavaClassDialog method getData.
/**
* Copy information from the meta-data input to the dialog fields.
*/
public void getData() {
int i = 0;
for (FieldInfo fi : input.getFieldInfo()) {
TableItem item = wFields.table.getItem(i);
i++;
item.setText(1, fi.name);
item.setText(2, ValueMetaFactory.getValueMetaName(fi.type));
if (fi.length >= 0) {
item.setText(3, "" + fi.length);
}
if (fi.precision >= 0) {
item.setText(4, "" + fi.precision);
}
}
List<UserDefinedJavaClassDef> definitions = input.getDefinitions();
if (definitions.size() == 0) {
try {
definitions = new ArrayList<UserDefinedJavaClassDef>();
// Note the tab name isn't i18n because it is a Java Class name and i18n characters might make it choke.
definitions.add(new UserDefinedJavaClassDef(UserDefinedJavaClassDef.ClassType.TRANSFORM_CLASS, "Processor", UserDefinedJavaClassCodeSnippits.getSnippitsHelper().getDefaultCode()));
input.replaceDefinitions(definitions);
} catch (KettleXMLException e) {
e.printStackTrace();
new ErrorDialog(shell, BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.Plugin.CreateErrorTitle"), BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.Plugin.CreateErrorMessage", stepname), e);
}
}
for (UserDefinedJavaClassDef def : definitions) {
if (def.isTransformClass()) {
strActiveScript = def.getClassName();
}
addCtab(def.getClassName(), def.getSource(), TabAddActions.ADD_DEFAULT);
}
setActiveCtab(strActiveScript);
refresh();
wClearResultFields.setSelection(input.isClearingResultFields());
wFields.setRowNums();
wFields.optWidth(true);
int rowNr = 0;
for (InfoStepDefinition stepDefinition : input.getInfoStepDefinitions()) {
TableItem item = wInfoSteps.table.getItem(rowNr++);
int colNr = 1;
item.setText(colNr++, Const.NVL(stepDefinition.tag, ""));
item.setText(colNr++, stepDefinition.stepMeta != null ? stepDefinition.stepMeta.getName() : "");
item.setText(colNr++, Const.NVL(stepDefinition.description, ""));
}
wInfoSteps.setRowNums();
wInfoSteps.optWidth(true);
rowNr = 0;
for (TargetStepDefinition stepDefinition : input.getTargetStepDefinitions()) {
TableItem item = wTargetSteps.table.getItem(rowNr++);
int colNr = 1;
item.setText(colNr++, Const.NVL(stepDefinition.tag, ""));
item.setText(colNr++, stepDefinition.stepMeta != null ? stepDefinition.stepMeta.getName() : "");
item.setText(colNr++, Const.NVL(stepDefinition.description, ""));
}
wTargetSteps.setRowNums();
wTargetSteps.optWidth(true);
rowNr = 0;
for (UsageParameter usageParameter : input.getUsageParameters()) {
TableItem item = wParameters.table.getItem(rowNr++);
int colNr = 1;
item.setText(colNr++, Const.NVL(usageParameter.tag, ""));
item.setText(colNr++, Const.NVL(usageParameter.value, ""));
item.setText(colNr++, Const.NVL(usageParameter.description, ""));
}
wParameters.setRowNums();
wParameters.optWidth(true);
wStepname.selectAll();
wStepname.setFocus();
}
use of org.pentaho.di.trans.steps.userdefinedjavaclass.TargetStepDefinition in project pentaho-kettle by pentaho.
the class UserDefinedJavaClassDialog method getInfo.
private void getInfo(UserDefinedJavaClassMeta meta) {
int nrfields = wFields.nrNonEmpty();
List<FieldInfo> newFields = new ArrayList<FieldInfo>(nrfields);
for (int i = 0; i < nrfields; i++) {
TableItem item = wFields.getNonEmpty(i);
newFields.add(new FieldInfo(item.getText(1), ValueMetaFactory.getIdForValueMeta(item.getText(2)), Const.toInt(item.getText(3), -1), Const.toInt(item.getText(4), -1)));
}
meta.replaceFields(newFields);
CTabItem[] cTabs = folder.getItems();
if (cTabs.length > 0) {
List<UserDefinedJavaClassDef> definitions = new ArrayList<UserDefinedJavaClassDef>(cTabs.length);
for (int i = 0; i < cTabs.length; i++) {
UserDefinedJavaClassDef def = new UserDefinedJavaClassDef(ClassType.NORMAL_CLASS, cTabs[i].getText(), getStyledTextComp(cTabs[i]).getText());
if (cTabs[i].getImage().equals(imageActiveScript)) {
def.setClassType(ClassType.TRANSFORM_CLASS);
}
definitions.add(def);
}
meta.replaceDefinitions(definitions);
}
meta.setClearingResultFields(wClearResultFields.getSelection());
int nrInfos = wInfoSteps.nrNonEmpty();
meta.getInfoStepDefinitions().clear();
for (int i = 0; i < nrInfos; i++) {
TableItem item = wInfoSteps.getNonEmpty(i);
InfoStepDefinition stepDefinition = new InfoStepDefinition();
int colNr = 1;
stepDefinition.tag = item.getText(colNr++);
stepDefinition.stepMeta = transMeta.findStep(item.getText(colNr++));
stepDefinition.description = item.getText(colNr++);
meta.getInfoStepDefinitions().add(stepDefinition);
}
int nrTargets = wTargetSteps.nrNonEmpty();
meta.getTargetStepDefinitions().clear();
for (int i = 0; i < nrTargets; i++) {
TableItem item = wTargetSteps.getNonEmpty(i);
TargetStepDefinition stepDefinition = new TargetStepDefinition();
int colNr = 1;
stepDefinition.tag = item.getText(colNr++);
stepDefinition.stepMeta = transMeta.findStep(item.getText(colNr++));
stepDefinition.description = item.getText(colNr++);
meta.getTargetStepDefinitions().add(stepDefinition);
}
int nrParameters = wParameters.nrNonEmpty();
meta.getUsageParameters().clear();
for (int i = 0; i < nrParameters; i++) {
TableItem item = wParameters.getNonEmpty(i);
UsageParameter usageParameter = new UsageParameter();
int colNr = 1;
usageParameter.tag = item.getText(colNr++);
usageParameter.value = item.getText(colNr++);
usageParameter.description = item.getText(colNr++);
meta.getUsageParameters().add(usageParameter);
}
}
Aggregations