Search in sources :

Example 56 with ComponentException

use of org.talend.components.api.exception.ComponentException in project components by Talend.

the class BigQueryOutputDefinition method getRuntimeInfo.

@Override
public RuntimeInfo getRuntimeInfo(ExecutionEngine engine, ComponentProperties properties, ConnectorTopology connectorTopology) {
    assertEngineCompatibility(engine);
    assertConnectorTopologyCompatibility(connectorTopology);
    try {
        return new JarRuntimeInfo(new URL("mvn:org.talend.components/bigquery-runtime"), DependenciesReader.computeDependenciesFilePath("org.talend.components", "bigquery-runtime"), RUNTIME);
    } catch (MalformedURLException e) {
        throw new ComponentException(e);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) ComponentException(org.talend.components.api.exception.ComponentException) JarRuntimeInfo(org.talend.components.api.component.runtime.JarRuntimeInfo) URL(java.net.URL)

Example 57 with ComponentException

use of org.talend.components.api.exception.ComponentException in project components by Talend.

the class BigQueryInputDefinition method getRuntimeInfo.

@Override
public RuntimeInfo getRuntimeInfo(ExecutionEngine engine, ComponentProperties properties, ConnectorTopology connectorTopology) {
    assertEngineCompatibility(engine);
    assertConnectorTopologyCompatibility(connectorTopology);
    try {
        return new JarRuntimeInfo(new URL("mvn:org.talend.components/bigquery-runtime"), DependenciesReader.computeDependenciesFilePath("org.talend.components", "bigquery-runtime"), RUNTIME);
    } catch (MalformedURLException e) {
        throw new ComponentException(e);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) ComponentException(org.talend.components.api.exception.ComponentException) JarRuntimeInfo(org.talend.components.api.component.runtime.JarRuntimeInfo) URL(java.net.URL)

Example 58 with ComponentException

use of org.talend.components.api.exception.ComponentException in project components by Talend.

the class AzureStorageTableWriter method createDynamicEntityFromInputRecord.

private DynamicTableEntity createDynamicEntityFromInputRecord(IndexedRecord indexedRecord, Schema schema) {
    DynamicTableEntity entity = new DynamicTableEntity();
    HashMap<String, EntityProperty> entityProps = new HashMap<>();
    for (Field f : schema.getFields()) {
        if (indexedRecord.get(f.pos()) == null) {
            // record value may be null, No need to set the property in azure in this case
            continue;
        }
        // schema name
        String sName = f.name();
        // mapped name
        String mName = getMappedNameIfNecessary(sName);
        Schema fSchema = f.schema();
        if (fSchema.getType() == Type.UNION) {
            for (Schema s : f.schema().getTypes()) {
                if (s.getType() != Type.NULL) {
                    fSchema = s;
                    break;
                }
            }
        }
        if (sName.equals(partitionKey)) {
            entity.setPartitionKey((String) indexedRecord.get(f.pos()));
        } else if (sName.equals(rowKey)) {
            entity.setRowKey((String) indexedRecord.get(f.pos()));
        } else if (mName.equals(AzureStorageTableProperties.TABLE_TIMESTAMP)) {
        // nop : managed by server
        } else {
            // that's some properties !
            if (fSchema.getType().equals(Type.BOOLEAN)) {
                entityProps.put(mName, new EntityProperty((Boolean) indexedRecord.get(f.pos())));
            } else if (fSchema.getType().equals(Type.DOUBLE)) {
                entityProps.put(mName, new EntityProperty((Double) indexedRecord.get(f.pos())));
            } else if (fSchema.getType().equals(Type.INT)) {
                entityProps.put(mName, new EntityProperty((Integer) indexedRecord.get(f.pos())));
            } else if (fSchema.getType().equals(Type.BYTES)) {
                entityProps.put(mName, new EntityProperty((byte[]) indexedRecord.get(f.pos())));
            } else // 
            if (fSchema.getType().equals(Type.LONG)) {
                String clazz = fSchema.getProp(SchemaConstants.JAVA_CLASS_FLAG);
                if (clazz != null && clazz.equals(Date.class.getCanonicalName())) {
                    Date dt = null;
                    String pattern = fSchema.getProp(SchemaConstants.TALEND_COLUMN_PATTERN);
                    if (pattern != null && !pattern.isEmpty()) {
                        try {
                            dt = new SimpleDateFormat(pattern).parse(indexedRecord.get(f.pos()).toString());
                        } catch (ParseException e) {
                            LOGGER.error(i18nMessages.getMessage("error.ParseError", e));
                            if (dieOnError) {
                                throw new ComponentException(e);
                            }
                        }
                    } else {
                        dt = (Date) indexedRecord.get(f.pos());
                    }
                    entityProps.put(mName, new EntityProperty(dt));
                } else {
                    entityProps.put(mName, new EntityProperty((Long) indexedRecord.get(f.pos())));
                }
            } else // 
            if (fSchema.getType().equals(Type.STRING)) {
                entityProps.put(mName, new EntityProperty((String) indexedRecord.get(f.pos())));
            } else {
                // use string as default type...
                entityProps.put(mName, new EntityProperty((String) indexedRecord.get(f.pos())));
            }
        }
    }
    // Etag is needed for some operations (delete, merge, replace) but we rely only on PK and RK for those ones.
    entity.setEtag("*");
    entity.setProperties(entityProps);
    return entity;
}
Also used : HashMap(java.util.HashMap) Schema(org.apache.avro.Schema) Date(java.util.Date) DynamicTableEntity(com.microsoft.azure.storage.table.DynamicTableEntity) EntityProperty(com.microsoft.azure.storage.table.EntityProperty) Field(org.apache.avro.Schema.Field) ComponentException(org.talend.components.api.exception.ComponentException) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat)

Example 59 with ComponentException

use of org.talend.components.api.exception.ComponentException in project components by Talend.

the class AzureStorageTableWriter method open.

@Override
public void open(String uId) throws IOException {
    try {
        this.result = new Result(uId);
        tableservice.handleActionOnTable(tableName, actionOnTable);
    } catch (InvalidKeyException | URISyntaxException | StorageException e) {
        LOGGER.error(e.getLocalizedMessage());
        throw new ComponentException(e);
    }
}
Also used : ComponentException(org.talend.components.api.exception.ComponentException) URISyntaxException(java.net.URISyntaxException) InvalidKeyException(java.security.InvalidKeyException) StorageException(com.microsoft.azure.storage.StorageException) Result(org.talend.components.api.component.runtime.Result)

Example 60 with ComponentException

use of org.talend.components.api.exception.ComponentException in project components by Talend.

the class S3InputDefinition method getRuntimeInfo.

@Override
public RuntimeInfo getRuntimeInfo(ExecutionEngine engine, ComponentProperties properties, ConnectorTopology connectorTopology) {
    assertEngineCompatibility(engine);
    assertConnectorTopologyCompatibility(connectorTopology);
    try {
        return new JarRuntimeInfo(new URL(SimpleFileIOComponentFamilyDefinition.MAVEN_DEFAULT_RUNTIME_URI), DependenciesReader.computeDependenciesFilePath(SimpleFileIOComponentFamilyDefinition.MAVEN_GROUP_ID, SimpleFileIOComponentFamilyDefinition.MAVEN_DEFAULT_RUNTIME_ARTIFACT_ID), RUNTIME);
    } catch (MalformedURLException e) {
        throw new ComponentException(e);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) ComponentException(org.talend.components.api.exception.ComponentException) JarRuntimeInfo(org.talend.components.api.component.runtime.JarRuntimeInfo) URL(java.net.URL)

Aggregations

ComponentException (org.talend.components.api.exception.ComponentException)101 URL (java.net.URL)32 MalformedURLException (java.net.MalformedURLException)30 JarRuntimeInfo (org.talend.components.api.component.runtime.JarRuntimeInfo)27 IOException (java.io.IOException)18 ArrayList (java.util.ArrayList)17 InvalidKeyException (java.security.InvalidKeyException)14 Schema (org.apache.avro.Schema)14 URISyntaxException (java.net.URISyntaxException)12 StorageException (com.microsoft.azure.storage.StorageException)11 NamedThing (org.talend.daikon.NamedThing)11 ValidationResult (org.talend.daikon.properties.ValidationResult)10 SandboxedInstance (org.talend.daikon.sandbox.SandboxedInstance)10 IndexedRecord (org.apache.avro.generic.IndexedRecord)8 Test (org.junit.Test)8 SimpleNamedThing (org.talend.daikon.SimpleNamedThing)8 NetSuiteException (org.talend.components.netsuite.client.NetSuiteException)6 GeneralSecurityException (java.security.GeneralSecurityException)5 JDBCSource (org.talend.components.jdbc.runtime.JDBCSource)5 TJDBCInputDefinition (org.talend.components.jdbc.tjdbcinput.TJDBCInputDefinition)5