Search in sources :

Example 16 with IContext

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);
}
Also used : IContext(org.talend.core.model.process.IContext) IContextManager(org.talend.core.model.process.IContextManager)

Example 17 with IContext

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);
    }
}
Also used : IContext(org.talend.core.model.process.IContext) IContextParameter(org.talend.core.model.process.IContextParameter)

Example 18 with IContext

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);
}
Also used : IContext(org.talend.core.model.process.IContext) Schema(org.apache.avro.Schema) List(java.util.List) IProcess(org.talend.core.model.process.IProcess) IContextManager(org.talend.core.model.process.IContextManager)

Example 19 with IContext

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());
    }
}
Also used : IContext(org.talend.core.model.process.IContext) IContextParameter(org.talend.core.model.process.IContextParameter)

Example 20 with IContext

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;
}
Also used : INode(org.talend.core.model.process.INode) IContext(org.talend.core.model.process.IContext) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IProcess2(org.talend.core.model.process.IProcess2) IElementParameter(org.talend.core.model.process.IElementParameter) ITDQRuleService(org.talend.core.ITDQRuleService)

Aggregations

IContext (org.talend.core.model.process.IContext)46 IContextParameter (org.talend.core.model.process.IContextParameter)14 ArrayList (java.util.ArrayList)13 List (java.util.List)11 IProcess (org.talend.core.model.process.IProcess)10 ProcessorException (org.talend.designer.runprocess.ProcessorException)10 HashMap (java.util.HashMap)9 ProcessItem (org.talend.core.model.properties.ProcessItem)8 IOException (java.io.IOException)7 IElementParameter (org.talend.core.model.process.IElementParameter)7 IProcessor (org.talend.designer.runprocess.IProcessor)7 File (java.io.File)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)6 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 IContextManager (org.talend.core.model.process.IContextManager)6 HashSet (java.util.HashSet)5 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)5 IProcess2 (org.talend.core.model.process.IProcess2)5 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)5 Map (java.util.Map)4