use of org.talend.daikon.NamedThing in project components by Talend.
the class FixedConnectorsComponentProperties method setConnectedSchema.
@SuppressWarnings("unchecked")
@Override
public void setConnectedSchema(Connector connector, Schema schema, boolean isOutputConnection) {
if (connector instanceof PropertyPathConnector) {
NamedThing property = getProperty(((PropertyPathConnector) connector).getPropertyPath());
if (property != null) {
if (property instanceof SchemaProperties) {
SchemaProperties schemaProperties = (SchemaProperties) property;
schemaProperties.schema.setValue(schema);
} else if (property instanceof Property) {
((Property<Schema>) property).setValue(schema);
}
} else {
// else path not found so throw exception
throw new ComponentException(ComponentsErrorCode.WRONG_CONNECTOR, ExceptionContext.build().put("properties", this.getClass().getCanonicalName()));
}
}
// not a connector handled by this class
}
use of org.talend.daikon.NamedThing in project components by Talend.
the class FixedConnectorsComponentProperties method getSchema.
/**
* This default implementation uses {@link PropertyPathConnector} to find the SchemaProperties or Property of type
* Schema instances avaialble in this Object. It return null if none found
*/
@SuppressWarnings("unchecked")
@Override
public Schema getSchema(Connector connector, boolean isOutputConnection) {
if (connector instanceof PropertyPathConnector) {
NamedThing property = getProperty(((PropertyPathConnector) connector).getPropertyPath());
if (property != null) {
Property<Schema> schemaProp = null;
if (property instanceof SchemaProperties) {
SchemaProperties schemaProperties = (SchemaProperties) property;
schemaProp = schemaProperties.schema;
} else if (property instanceof Property) {
schemaProp = (Property<Schema>) property;
}
return schemaProp != null ? schemaProp.getValue() : null;
} else {
// else path not found so throw exception
throw new ComponentException(ComponentsErrorCode.WRONG_CONNECTOR, ExceptionContext.build().put("properties", this.getClass().getCanonicalName()));
}
}
// else not a connector handled by this class so return null
return null;
}
use of org.talend.daikon.NamedThing in project components by Talend.
the class AzureStorageComponentListProperties method afterFormFinishTable.
public ValidationResult afterFormFinishTable(Repository<Properties> repo) throws Exception {
connection.BlobSchema = selectedContainerNames.getValue();
connection.QueueSchema = selectedQueueNames.getValue();
connection.TableSchema = selectedTableNames.getValue();
String repoLoc = repo.storeProperties(connection, connection.name.getValue(), repositoryLocation, null);
String storeId;
if (selectedContainerNames.getValue() != null) {
for (NamedThing nl : selectedContainerNames.getValue()) {
String containerId = nl.getName();
AzureStorageContainerProperties containerProps = new AzureStorageContainerProperties(containerId);
containerProps.init();
containerProps.connection = connection;
containerProps.container.setValue(containerId);
containerProps.schema.schema.setValue(getContainerSchema());
repo.storeProperties(containerProps, formatSchemaName(containerId), repoLoc, "schema.schema");
}
}
if (selectedQueueNames.getValue() != null) {
for (NamedThing nl : selectedQueueNames.getValue()) {
String queueId = nl.getName();
AzureStorageQueueProperties queueProps = new AzureStorageQueueProperties(queueId);
queueProps.init();
queueProps.connection = connection;
queueProps.queueName.setValue(queueId);
queueProps.schema.schema.setValue(getQueueSchema());
repo.storeProperties(queueProps, formatSchemaName(queueId), repoLoc, "schema.schema");
}
}
if (selectedTableNames.getValue() != null) {
for (NamedThing nl : selectedTableNames.getValue()) {
String tableId = nl.getName();
AzureStorageTableProperties tableProps = new AzureStorageTableProperties(tableId);
tableProps.init();
tableProps.connection = connection;
tableProps.tableName.setValue(tableId);
try {
Schema schema = AzureStorageTableSourceOrSink.getSchema(null, connection, tableId);
tableProps.schema.schema.setValue(schema);
repo.storeProperties(tableProps, formatSchemaName(tableId), repoLoc, "schema.schema");
} catch (IOException e) {
LOGGER.error(e.getLocalizedMessage());
}
}
}
return ValidationResult.OK;
}
use of org.talend.daikon.NamedThing in project components by Talend.
the class AzureStorageComponentListPropertiesTest method afterFormFinishTable2.
@Test(expected = NoSuchElementException.class)
public void afterFormFinishTable2() throws Exception {
TAzureStorageConnectionProperties connection = new TAzureStorageConnectionProperties("test");
connection.setupProperties();
connection.setupLayout();
connection.useSharedAccessSignature.setValue(true);
connection.sharedAccessSignature.setValue("https://talendrd.blob.core.windows.net/?sv=2016-05-31&ss=f&srt=sco&sp=rwdlacup&se=2017-06-07T23:50:05Z&st=2017-05-24T15:50:05Z&spr=https&sig=fakeSASfakeSASfakeSASfakeSASfakeSASfakeSASfakeSASfakeSAS");
properties.setConnection(connection);
List<NamedThing> nameWithNumeric = new ArrayList<NamedThing>();
nameWithNumeric.add(new SimpleNamedThing("2Name_with_numeric2", "2Name_with_numeric2"));
properties.selectedTableNames.setStoredValue(nameWithNumeric);
@SuppressWarnings("unused") ValidationResult result = properties.afterFormFinishTable(repo);
}
use of org.talend.daikon.NamedThing in project components by Talend.
the class BigQueryDatasetProperties method beforeBqDataset.
public ValidationResult beforeBqDataset() {
BigQueryDatasetDefinition definition = new BigQueryDatasetDefinition();
RuntimeInfo runtimeInfo = definition.getRuntimeInfo(this);
try (SandboxedInstance sandboxedInstance = RuntimeUtil.createRuntimeClass(runtimeInfo, getClass().getClassLoader())) {
IBigQueryDatasetRuntime runtime = (IBigQueryDatasetRuntime) sandboxedInstance.getInstance();
runtime.initialize(null, this);
List<NamedThing> datasets = new ArrayList<>();
for (String dataset : runtime.listDatasets()) {
datasets.add(new SimpleNamedThing(dataset, dataset));
}
bqDataset.setPossibleValues(datasets);
return ValidationResult.OK;
} catch (Exception e) {
return new ValidationResult(new ComponentException(e));
}
}
Aggregations