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