use of org.talend.core.model.process.IContext in project tesb-studio-se by Talend.
the class BaseNodeAdapter method parseContextParameter.
private String parseContextParameter(final String contextValue) {
IContextManager contextManager = node.getProcess().getContextManager();
String currentDefaultName = contextManager.getDefaultContext().getName();
List<IContext> contextList = contextManager.getListContext();
if (contextList != null && contextList.size() > 1) {
currentDefaultName = ConnectionContextHelper.getContextTypeForJob(Display.getDefault().getActiveShell(), contextManager, false);
}
IContext context = contextManager.getContext(currentDefaultName);
return ContextParameterUtils.parseScriptContextCode(contextValue, context);
}
use of org.talend.core.model.process.IContext in project tdi-studio-se by Talend.
the class TestComponentsAction method setDefaultProperties.
/**
* DOC qwei Comment method "setDefaultProperties".
*
* @param process
*/
private void setDefaultProperties(IProcess process, String componentPath) {
// input_path / output_path
IContext context = process.getContextManager().getDefaultContext();
List<IContextParameter> tempContextParameter = context.getContextParameterList();
for (IContextParameter parameter : tempContextParameter) {
fillParameter(parameter, componentPath);
}
}
use of org.talend.core.model.process.IContext in project tdi-studio-se by Talend.
the class ComponentContextPropertyValueEvaluator method evaluate.
@Override
public Object evaluate(Property property, Object storedValue) {
if (storedValue == null) {
return storedValue;
}
if (storedValue instanceof Schema || storedValue instanceof List || storedValue instanceof Enum || storedValue instanceof Boolean) {
return storedValue;
}
IContext context = null;
if (node != null) {
IProcess process = node.getProcess();
if (process != null) {
IContextManager cm = process.getContextManager();
if (cm != null) {
context = cm.getDefaultContext();
}
}
}
String stringStoredValue = String.valueOf(storedValue);
if (context != null && ContextParameterUtils.isContainContextParam(stringStoredValue)) {
stringStoredValue = ContextParameterUtils.parseScriptContextCode(stringStoredValue, context);
}
return getTypedValue(property, stringStoredValue);
}
use of org.talend.core.model.process.IContext in project tdi-studio-se by Talend.
the class ContextModifyCommand method propagateType.
private void propagateType(IContextManager contextManager, IContextParameter param) {
for (IContext context : contextManager.getListContext()) {
IContextParameter paramToModify = context.getContextParameter(param.getName());
paramToModify.setType(param.getType());
}
}
use of org.talend.core.model.process.IContext in project tdi-studio-se by Talend.
the class QueryGuessCommand method generateNewQueryFromDQRuler.
private String generateNewQueryFromDQRuler(IElementParameter dqRulerParam) {
ITDQRuleService rulerService = null;
try {
rulerService = (ITDQRuleService) GlobalServiceRegister.getDefault().getService(ITDQRuleService.class);
} catch (RuntimeException e) {
// nothing to do
}
if (rulerService != null) {
//$NON-NLS-1$
IElementParameter existConnection = node.getElementParameter("USE_EXISTING_CONNECTION");
boolean useExistConnection = (existConnection == null ? false : (Boolean) existConnection.getValue());
INode connectionNode = null;
if (node != null && node instanceof INode) {
process = ((INode) node).getProcess();
}
if (useExistConnection && process != null) {
IElementParameter connector = node.getElementParameter("CONNECTION");
if (connector != null) {
String connectorValue = connector.getValue().toString();
List<? extends INode> graphicalNodes = process.getGeneratingNodes();
for (INode node : graphicalNodes) {
if (node.getUniqueName().equals(connectorValue)) {
connectionNode = node;
break;
}
}
}
}
//$NON-NLS-1$
IElementParameter typeParam = node.getElementParameter("TYPE");
IElementParameter dbParam = node.getElementParameter(EParameterName.DBNAME.getName());
IContext lastRunContext = ((IProcess2) process).getLastRunContext();
String dbName = JavaProcessUtil.getRealParamValue(process, dbParam.getValue().toString(), lastRunContext);
IElementParameter schemaParam = node.getElementParameter(EParameterName.SCHEMA_DB.getName());
String schemaName = JavaProcessUtil.getRealParamValue(process, schemaParam == null ? org.apache.commons.lang.StringUtils.EMPTY : schemaParam.getValue().toString(), lastRunContext);
IElementParameter tableParam = node.getElementParameterFromField(EParameterFieldType.DBTABLE);
String tableName = JavaProcessUtil.getRealParamValue(process, tableParam.getValue().toString(), lastRunContext);
//$NON-NLS-1$
IElementParameter whereClause = node.getElementParameter("WHERE_CLAUSE");
String whereStr = org.apache.commons.lang.StringUtils.EMPTY;
if (whereClause.getValue() != null) {
whereStr = JavaProcessUtil.getRealParamValue(process, whereClause.getValue().toString(), lastRunContext);
}
if (connectionNode != null) {
//$NON-NLS-1$
typeParam = connectionNode.getElementParameter("TYPE");
dbParam = connectionNode.getElementParameter(EParameterName.DBNAME.getName());
dbName = JavaProcessUtil.getRealParamValue(process, dbParam.getValue().toString(), lastRunContext);
schemaParam = connectionNode.getElementParameter(EParameterName.SCHEMA_DB.getName());
schemaName = JavaProcessUtil.getRealParamValue(process, schemaParam == null ? org.apache.commons.lang.StringUtils.EMPTY : schemaParam.getValue().toString(), lastRunContext);
}
List<IMetadataTable> metadataList = null;
IMetadataTable metadataTable = null;
if (node instanceof Node) {
metadataList = ((Node) node).getMetadataList();
if (metadataList != null && !metadataList.isEmpty()) {
metadataTable = metadataList.get(0);
}
}
return rulerService.getQueryByRule(dqRulerParam, typeParam, dbName, schemaName, tableName, metadataTable, node.getElementName().contains("Invalid"), //$NON-NLS-1$
whereStr);
}
return org.apache.commons.lang.StringUtils.EMPTY;
}
Aggregations