use of com.infobright.etl.model.DataFormat in project pentaho-kettle by pentaho.
the class InfobrightLoaderDialog method addCustomInputs.
/**
* Adds any custom inputs
*
* @param prevControl
* @return the last control
*/
protected Control addCustomInputs(Control prevControl) {
String[] dataformats = new String[DataFormat.values().length];
int i = 0;
for (DataFormat format : DataFormat.values()) {
dataformats[i++] = format.getDisplayText();
}
Map<String, Charset> availableCharsetsMap = Charset.availableCharsets();
String[] availableCharsets = new String[availableCharsetsMap.size()];
int j = 0;
for (String charsetName : availableCharsetsMap.keySet()) {
availableCharsets[j++] = charsetName;
}
dataFormatSelect = addStandardSelect(BaseMessages.getString(PKG, "InfobrightLoaderDialog.Dataformat.Label"), prevControl, dataformats);
targetSchemaText = addStandardTextVar(BaseMessages.getString(PKG, "InfobrightLoaderDialog.TargetSchema.Label"), dataFormatSelect);
targetTableText = addStandardTextVar(BaseMessages.getString(PKG, "InfobrightLoaderDialog.TargetTable.Label"), targetSchemaText);
charsetSelect = addStandardSelect(BaseMessages.getString(PKG, "InfobrightLoaderDialog.Charset.Label"), targetTableText, availableCharsets);
agentPortText = addStandardTextVar(BaseMessages.getString(PKG, "InfobrightLoaderDialog.AgentPort.Label"), charsetSelect);
debugFileText = addStandardTextVar(BaseMessages.getString(PKG, "InfobrightLoaderDialog.DebugFile.Label"), agentPortText);
return debugFileText;
}
use of com.infobright.etl.model.DataFormat in project pentaho-kettle by pentaho.
the class InfobrightLoaderData method databaseSetup.
void databaseSetup(InfobrightLoaderMeta meta, InfobrightLoader step) throws KettleException {
db = new Database(step, meta.getDatabaseMeta());
db.connect();
// FIXME: This will fail if the first row of the table contains a value that
// cannot be read by Java. For example, a DATE field that contains the value
// '0000-00-00'. In this case, the Kettle error message will misleadingly say
// that the table doesn't exist. There doesn't seem to be any workaround.
// See Pentaho JIRA: PDI-2117.
//
requiredRowMeta = meta.getRequiredFields(step);
requiredFields = requiredRowMeta.getFieldNames();
try {
// the loader is using it and any other uses of the connection will block.
if (meta.getInfobrightProductType() == null) {
// default for ICE
meta.setDataFormat(DataFormat.TXT_VARIABLE);
}
DataFormat dataFormat = DataFormat.valueForDisplayName(meta.getInfobrightProductType());
int agentPort = meta.getAgentPort();
Charset charset = meta.getCharset();
Connection conn = db.getConnection();
String tableName = meta.getDatabaseMeta().getQuotedSchemaTableCombination(step.environmentSubstitute(meta.getSchemaName()), step.environmentSubstitute(meta.getTableName()));
EtlLogger logger = new KettleEtlLogger(step);
loader = new InfobrightNamedPipeLoader(tableName, conn, logger, dataFormat, charset, agentPort);
loader.setTimeout(30);
String debugFile = meta.getDebugFile();
if (debugFile != null) {
OutputStream debugOutputStream = new FileOutputStream(debugFile);
loader.setDebugOutputStream(debugOutputStream);
}
// TODO set to true to support error path
record = loader.createRecord(false);
loader.start();
} catch (Exception e) {
db.disconnect();
db = null;
if (loader != null) {
try {
loader.killQuery();
} catch (SQLException e1) {
throw new KettleDatabaseException(e1);
}
}
throw new KettleDatabaseException(e);
}
}
use of com.infobright.etl.model.DataFormat in project pentaho-kettle by pentaho.
the class InfobrightLoaderMeta method readRep.
@Override
public void readRep(Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases) throws KettleException {
super.readRep(rep, metaStore, id_step, databases);
try {
dataFormat = Enum.valueOf(DataFormat.class, rep.getStepAttributeString(id_step, TAG_DATA_FORMAT));
String agentPortStr = rep.getStepAttributeString(id_step, TAG_AGENT_PORT);
if (agentPortStr == null) {
agentPort = InfobrightNamedPipeLoader.AGENT_DEFAULT_PORT;
} else {
agentPort = Integer.parseInt(agentPortStr);
}
String charsetName = rep.getStepAttributeString(id_step, TAG_CHARSET);
charset = (charsetName == null ? InfobrightNamedPipeLoader.DEFAULT_CHARSET : Charset.forName(charsetName));
debugFile = rep.getStepAttributeString(id_step, TAG_DEBUG_FILE);
} catch (Exception e) {
throw new KettleException("Unexpected error reading step information from the repository", e);
}
}
use of com.infobright.etl.model.DataFormat in project pentaho-kettle by pentaho.
the class InfobrightLoaderMeta method loadXML.
// @SuppressWarnings("unchecked")
@Override
public void loadXML(Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore) throws KettleXMLException {
super.loadXML(stepnode, databases, metaStore);
try {
dataFormat = Enum.valueOf(DataFormat.class, XMLHandler.getTagValue(stepnode, TAG_DATA_FORMAT));
agentPort = Integer.parseInt(Const.NVL(XMLHandler.getTagValue(stepnode, TAG_AGENT_PORT), Integer.toString(InfobrightNamedPipeLoader.AGENT_DEFAULT_PORT)));
String charsetName = XMLHandler.getTagValue(stepnode, TAG_CHARSET);
charset = (charsetName == null ? InfobrightNamedPipeLoader.DEFAULT_CHARSET : Charset.forName(charsetName));
debugFile = XMLHandler.getTagValue(stepnode, TAG_DEBUG_FILE);
} catch (Exception e) {
throw new KettleXMLException("Unable to load step info from XML", e);
}
}
Aggregations