Search in sources :

Example 1 with Properties

use of org.talend.daikon.properties.Properties in project tdi-studio-se by Talend.

the class Component method getElementParameterValueFromComponentProperties.

@Override
public Object getElementParameterValueFromComponentProperties(INode iNode, IElementParameter param) {
    if (iNode != null) {
        ComponentProperties iNodeComponentProperties = iNode.getComponentProperties();
        if (iNodeComponentProperties != null && param instanceof GenericElementParameter) {
            Properties paramProperties = ComponentsUtils.getCurrentProperties(iNodeComponentProperties, param.getName());
            if (paramProperties != null) {
                // update repository value
                Property property = iNodeComponentProperties.getValuedProperty(param.getName());
                if (property != null) {
                    if (property.getTaggedValue(IGenericConstants.REPOSITORY_VALUE) != null) {
                        param.setRepositoryValue(param.getName());
                        param.setRepositoryValueUsed(true);
                    }
                }
                Object value = ComponentsUtils.getGenericPropertyValue(iNodeComponentProperties, param.getName());
                if (value == null && EParameterFieldType.TABLE.equals(param.getFieldType())) {
                    value = GenericTableUtils.getTableValues(iNodeComponentProperties.getProperties(param.getName()), param);
                }
                return value;
            }
        }
    }
    return null;
}
Also used : ComponentProperties(org.talend.components.api.properties.ComponentProperties) ComponentProperties(org.talend.components.api.properties.ComponentProperties) ComponentReferenceProperties(org.talend.components.api.properties.ComponentReferenceProperties) Properties(org.talend.daikon.properties.Properties) Property(org.talend.daikon.properties.property.Property) SchemaProperty(org.talend.daikon.properties.property.SchemaProperty)

Example 2 with Properties

use of org.talend.daikon.properties.Properties in project tdi-studio-se by Talend.

the class Component method setGenericPropertyValue.

@Override
public boolean setGenericPropertyValue(IElementParameter param) {
    if (param == null || param.getName() == null) {
        return false;
    }
    if (param instanceof GenericElementParameter) {
        ComponentProperties componentProperties = ((Node) ((GenericElementParameter) param).getElement()).getComponentProperties();
        Properties currentProperties = ComponentsUtils.getCurrentProperties(componentProperties, param.getName());
        if (currentProperties == null) {
            return false;
        }
        Property<?> property = componentProperties.getValuedProperty(param.getName());
        if (property != null) {
            property.setTaggedValue(IGenericConstants.REPOSITORY_VALUE, param.getName());
            return true;
        }
    }
    return false;
}
Also used : ComponentProperties(org.talend.components.api.properties.ComponentProperties) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) ComponentProperties(org.talend.components.api.properties.ComponentProperties) ComponentReferenceProperties(org.talend.components.api.properties.ComponentReferenceProperties) Properties(org.talend.daikon.properties.Properties)

Example 3 with Properties

use of org.talend.daikon.properties.Properties in project components by Talend.

the class SalesforceTestBase method setupProps.

public static SalesforceConnectionProperties setupProps(SalesforceConnectionProperties props, boolean addQuotes) {
    if (props == null) {
        props = (SalesforceConnectionProperties) new SalesforceConnectionProperties("foo").init();
    }
    Properties userPassword = (Properties) props.getProperty("userPassword");
    ((Property) userPassword.getProperty("userId")).setValue(addQuotes ? "\"" + userId + "\"" : userId);
    ((Property) userPassword.getProperty("password")).setValue(addQuotes ? "\"" + password + "\"" : password);
    ((Property) userPassword.getProperty("securityKey")).setValue(addQuotes ? "\"" + securityKey + "\"" : securityKey);
    return props;
}
Also used : SalesforceConnectionProperties(org.talend.components.salesforce.SalesforceConnectionProperties) SalesforceConnectionModuleProperties(org.talend.components.salesforce.SalesforceConnectionModuleProperties) SalesforceModuleProperties(org.talend.components.salesforce.SalesforceModuleProperties) TSalesforceOutputProperties(org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties) ComponentProperties(org.talend.components.api.properties.ComponentProperties) TSalesforceInputProperties(org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties) SalesforceConnectionProperties(org.talend.components.salesforce.SalesforceConnectionProperties) Properties(org.talend.daikon.properties.Properties) Property(org.talend.daikon.properties.property.Property)

Example 4 with Properties

use of org.talend.daikon.properties.Properties in project components by Talend.

the class PropertiesControllerImpl method serialize.

@Override
public SerPropertiesDto serialize(UiSpecsPropertiesDto propertiesContainer) {
    Properties properties = propertiesHelpers.propertiesFromDto(propertiesContainer);
    if (properties == null) {
        return new SerPropertiesDto();
    }
    SerPropertiesDto serPropertiesDto = new SerPropertiesDto();
    serPropertiesDto.setProperties(properties.toSerialized());
    return serPropertiesDto;
}
Also used : DatasetProperties(org.talend.components.common.dataset.DatasetProperties) DatastoreProperties(org.talend.components.common.datastore.DatastoreProperties) Properties(org.talend.daikon.properties.Properties) SerPropertiesDto(org.talend.components.service.rest.dto.SerPropertiesDto)

Example 5 with Properties

use of org.talend.daikon.properties.Properties in project components by Talend.

the class RuntimeControllerImpl method writeData.

@Override
public void writeData(InputStream rawPayload) throws IOException {
    // 1) Read payload (with data as a stream of course)
    DatasetWritePayload payload = DatasetWritePayload.readData(rawPayload, mapper);
    String definitionName = payload.getConfiguration().getDefinitionName();
    // 2) Create properties
    Properties properties = propertiesHelpers.propertiesFromDto(payload.getConfiguration());
    if (properties instanceof ComponentProperties) {
        ComponentProperties componentProperties = (ComponentProperties) properties;
        // 3) Retrieve component definition to be able to create the runtime
        final ComponentDefinition definition = propertiesHelpers.getDefinition(ComponentDefinition.class, definitionName);
        // 4) Get the execution engine
        ExecutionEngine executionEngine;
        if (definition.isSupportingExecutionEngines(DI)) {
            executionEngine = DI;
            // 5) Create the sandbox
            try (SandboxedInstance instance = RuntimeUtil.createRuntimeClass(definition.getRuntimeInfo(executionEngine, componentProperties, INCOMING), definition.getClass().getClassLoader())) {
                Sink datasetRuntimeInstance = (Sink) instance.getInstance();
                datasetRuntimeInstance.initialize(null, componentProperties);
                Iterator<IndexedRecord> data = payload.getData();
                WriteOperation writeOperation = datasetRuntimeInstance.createWriteOperation();
                // Supplier return null to signify end of data stream => see WriterDataSupplier.writeData
                WriterDataSupplier<?, IndexedRecord> stringWriterDataSupplier = new WriterDataSupplier<Object, IndexedRecord>(writeOperation, () -> data.hasNext() ? data.next() : null, null);
                stringWriterDataSupplier.writeData();
            }
        } else if (definition.isSupportingExecutionEngines(BEAM)) {
            throw new UnsupportedOperationException("Beam runtime is not available for dataset write through HTTP API.");
        } else {
            throw new TalendRuntimeException(CommonErrorCodes.UNREGISTERED_DEFINITION);
        }
    } else if (properties instanceof DatasetProperties) {
        throw new UnsupportedOperationException("HTTP API is only able to write using component implementations. Not " + properties.getClass());
    }
}
Also used : ComponentProperties(org.talend.components.api.properties.ComponentProperties) IndexedRecord(org.apache.avro.generic.IndexedRecord) DatasetProperties(org.talend.components.common.dataset.DatasetProperties) DatasetProperties(org.talend.components.common.dataset.DatasetProperties) DatastoreProperties(org.talend.components.common.datastore.DatastoreProperties) ComponentProperties(org.talend.components.api.properties.ComponentProperties) Properties(org.talend.daikon.properties.Properties) SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) TalendRuntimeException(org.talend.daikon.exception.TalendRuntimeException) ExecutionEngine(org.talend.components.api.component.runtime.ExecutionEngine) Sink(org.talend.components.api.component.runtime.Sink) WriteOperation(org.talend.components.api.component.runtime.WriteOperation) WriterDataSupplier(org.talend.components.api.component.runtime.WriterDataSupplier) ComponentDefinition(org.talend.components.api.component.ComponentDefinition)

Aggregations

Properties (org.talend.daikon.properties.Properties)24 ComponentProperties (org.talend.components.api.properties.ComponentProperties)15 Test (org.junit.Test)7 NamedThing (org.talend.daikon.NamedThing)7 ComponentReferenceProperties (org.talend.components.api.properties.ComponentReferenceProperties)6 Property (org.talend.daikon.properties.property.Property)6 SimpleNamedThing (org.talend.daikon.SimpleNamedThing)5 SchemaProperty (org.talend.daikon.properties.property.SchemaProperty)4 ArrayList (java.util.ArrayList)3 DatasetProperties (org.talend.components.common.dataset.DatasetProperties)3 DatastoreProperties (org.talend.components.common.datastore.DatastoreProperties)3 INode (org.talend.core.model.process.INode)3 List (java.util.List)2 Schema (org.apache.avro.Schema)2 AbstractComponentTest (org.talend.components.api.test.AbstractComponentTest)2 SalesforceConnectionModuleProperties (org.talend.components.salesforce.SalesforceConnectionModuleProperties)2 SalesforceConnectionProperties (org.talend.components.salesforce.SalesforceConnectionProperties)2 SalesforceModuleProperties (org.talend.components.salesforce.SalesforceModuleProperties)2 TSalesforceInputProperties (org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties)2 TSalesforceOutputProperties (org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties)2