use of org.pentaho.di.trans.steps.combinationlookup.CombinationLookupMeta in project pentaho-kettle by pentaho.
the class CombinationLookupDialog method create.
/**
* Generate code for create table. Conversions done by database.
*/
private void create() {
try {
// Gather info...
CombinationLookupMeta info = new CombinationLookupMeta();
getInfo(info);
// new name might not yet be linked to other steps!
String name = stepname;
StepMeta stepMeta = new StepMeta(BaseMessages.getString(PKG, "CombinationLookupDialog.StepMeta.Title"), name, info);
RowMetaInterface prev = transMeta.getPrevStepFields(stepname);
SQLStatement sql = info.getSQLStatements(transMeta, stepMeta, prev, repository, metaStore);
if (!sql.hasError()) {
if (sql.hasSQL()) {
SQLEditor sqledit = new SQLEditor(transMeta, shell, SWT.NONE, info.getDatabaseMeta(), transMeta.getDbCache(), sql.getSQL());
sqledit.open();
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
mb.setMessage(BaseMessages.getString(PKG, "CombinationLookupDialog.NoSQLNeeds.DialogMessage"));
mb.setText(BaseMessages.getString(PKG, "CombinationLookupDialog.NoSQLNeeds.DialogTitle"));
mb.open();
}
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(sql.getError());
mb.setText(BaseMessages.getString(PKG, "CombinationLookupDialog.SQLError.DialogTitle"));
mb.open();
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "CombinationLookupDialog.UnableToCreateSQL.DialogTitle"), BaseMessages.getString(PKG, "CombinationLookupDialog.UnableToCreateSQL.DialogMessage"), ke);
}
}
use of org.pentaho.di.trans.steps.combinationlookup.CombinationLookupMeta in project pentaho-kettle by pentaho.
the class CombinationLookupDialog method ok.
private void ok() {
if (Utils.isEmpty(wStepname.getText())) {
return;
}
CombinationLookupMeta oldMetaState = (CombinationLookupMeta) input.clone();
getInfo(input);
// return value
stepname = wStepname.getText();
if (transMeta.findDatabase(wConnection.getText()) == null) {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "CombinationLookupDialog.NoValidConnection.DialogMessage"));
mb.setText(BaseMessages.getString(PKG, "CombinationLookupDialog.NoValidConnection.DialogTitle"));
mb.open();
}
if (!input.equals(oldMetaState)) {
input.setChanged();
}
dispose();
}
use of org.pentaho.di.trans.steps.combinationlookup.CombinationLookupMeta in project pentaho-kettle by pentaho.
the class JobGenerator method generateCombinationLookupStepFromLogicalTable.
protected StepMeta generateCombinationLookupStepFromLogicalTable(DatabaseMeta databaseMeta, LogicalTable logicalTable) {
String name = ConceptUtil.getName(logicalTable, locale);
String description = ConceptUtil.getDescription(logicalTable, locale);
String phTable = ConceptUtil.getString(logicalTable, DefaultIDs.LOGICAL_TABLE_PHYSICAL_TABLE_NAME);
String schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, Const.NVL(phTable, name));
CombinationLookupMeta meta = new CombinationLookupMeta();
meta.setDatabaseMeta(databaseMeta);
// TODO
meta.setSchemaName(null);
meta.setTablename(schemaTable);
meta.setUseAutoinc(databaseMeta.supportsAutoinc());
meta.setCacheSize(5000);
meta.setCommitSize(500);
// replace attribute fields with a TK
meta.setReplaceFields(true);
// Find the technical key (if any defined)
//
LogicalColumn keyColumn = ConceptUtil.findLogicalColumn(logicalTable, AttributeType.TECHNICAL_KEY);
if (keyColumn != null) {
ValueMetaInterface keyValue = getValueForLogicalColumn(databaseMeta, keyColumn);
meta.setTechnicalKeyField(keyValue.getName());
}
// Simply add all the attributes as key columns...
//
List<LogicalColumn> attributes = ConceptUtil.findLogicalColumns(logicalTable, AttributeType.ATTRIBUTE);
meta.setKeyLookup(new String[attributes.size()]);
meta.setKeyField(new String[attributes.size()]);
for (int i = 0; i < attributes.size(); i++) {
LogicalColumn logicalColumn = attributes.get(i);
ValueMetaInterface valueMeta = getValueForLogicalColumn(databaseMeta, logicalColumn);
meta.getKeyLookup()[i] = valueMeta.getName();
meta.getKeyField()[i] = valueMeta.getName();
}
StepMeta stepMeta = new StepMeta(name, meta);
stepMeta.drawStep();
stepMeta.setDescription(description);
return stepMeta;
}
Aggregations