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);
}
}
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);
}
}
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;
}
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);
}
}
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);
}
}
Aggregations