Search in sources :

Example 1 with DataFormat

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;
}
Also used : DataFormat(com.infobright.etl.model.DataFormat) Charset(java.nio.charset.Charset)

Example 2 with DataFormat

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);
    }
}
Also used : InfobrightNamedPipeLoader(com.infobright.io.InfobrightNamedPipeLoader) SQLException(java.sql.SQLException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) Connection(java.sql.Connection) Charset(java.nio.charset.Charset) KettleException(org.pentaho.di.core.exception.KettleException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) SQLException(java.sql.SQLException) EtlLogger(com.infobright.logging.EtlLogger) FileOutputStream(java.io.FileOutputStream) Database(org.pentaho.di.core.database.Database) DataFormat(com.infobright.etl.model.DataFormat)

Example 3 with DataFormat

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);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) DataFormat(com.infobright.etl.model.DataFormat) KettleException(org.pentaho.di.core.exception.KettleException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException)

Example 4 with DataFormat

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);
    }
}
Also used : DataFormat(com.infobright.etl.model.DataFormat) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleException(org.pentaho.di.core.exception.KettleException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException)

Aggregations

DataFormat (com.infobright.etl.model.DataFormat)4 KettleException (org.pentaho.di.core.exception.KettleException)3 Charset (java.nio.charset.Charset)2 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)2 InfobrightNamedPipeLoader (com.infobright.io.InfobrightNamedPipeLoader)1 EtlLogger (com.infobright.logging.EtlLogger)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 Database (org.pentaho.di.core.database.Database)1 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)1