Search in sources :

Example 1 with AzureStorageTableProperties

use of org.talend.components.azurestorage.table.AzureStorageTableProperties 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;
}
Also used : AzureStorageContainerProperties(org.talend.components.azurestorage.blob.AzureStorageContainerProperties) Schema(org.apache.avro.Schema) IOException(java.io.IOException) NamedThing(org.talend.daikon.NamedThing) AzureStorageQueueProperties(org.talend.components.azurestorage.queue.AzureStorageQueueProperties) AzureStorageTableProperties(org.talend.components.azurestorage.table.AzureStorageTableProperties)

Example 2 with AzureStorageTableProperties

use of org.talend.components.azurestorage.table.AzureStorageTableProperties in project components by Talend.

the class AzureStorageTableSourceOrSink method validate.

@Override
public ValidationResult validate(RuntimeContainer container) {
    ValidationResult vr = super.validate(container);
    if (vr.getStatus() == ValidationResult.Result.ERROR) {
        return vr;
    }
    AzureStorageTableProperties p = (AzureStorageTableProperties) properties;
    String tn = p.tableName.getValue();
    if (tn.isEmpty()) {
        return new ValidationResult(ValidationResult.Result.ERROR, i18nMessages.getMessage("message.VacantName"));
    }
    if (!tableCheckNamePattern.matcher(tn).matches()) {
        return new ValidationResult(ValidationResult.Result.ERROR, i18nMessages.getMessage("message.IncorrectName"));
    }
    return ValidationResult.OK;
}
Also used : ValidationResult(org.talend.daikon.properties.ValidationResult) AzureStorageTableProperties(org.talend.components.azurestorage.table.AzureStorageTableProperties)

Aggregations

AzureStorageTableProperties (org.talend.components.azurestorage.table.AzureStorageTableProperties)2 IOException (java.io.IOException)1 Schema (org.apache.avro.Schema)1 AzureStorageContainerProperties (org.talend.components.azurestorage.blob.AzureStorageContainerProperties)1 AzureStorageQueueProperties (org.talend.components.azurestorage.queue.AzureStorageQueueProperties)1 NamedThing (org.talend.daikon.NamedThing)1 ValidationResult (org.talend.daikon.properties.ValidationResult)1