Search in sources :

Example 71 with IElementParameter

use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.

the class StatsAndLogsManager method createLogsNode.

private static DataNode createLogsNode(boolean useFile, boolean console, String dbOutput) {
    JobLogsComponent logsComponent = new JobLogsComponent(useFile, console, dbOutput);
    DataNode logsNode = new DataNode(logsComponent, LOG_UNIQUE_NAME);
    logsNode.setStart(true);
    logsNode.setSubProcessStart(true);
    logsNode.setActivate(true);
    logsNode.getMetadataList().clear();
    // load the tLogCatcher to get the schema.
    IComponent tmpComponent = ComponentsFactoryProvider.getInstance().get("tLogCatcher", //$NON-NLS-1$
    ComponentCategory.CATEGORY_4_DI.getName());
    //$NON-NLS-1$
    DataNode tmpNode = new DataNode(tmpComponent, "tmp");
    boolean found = false;
    for (int k = 0; k < tmpNode.getElementParameters().size() && !found; k++) {
        IElementParameter currentParam = tmpNode.getElementParameters().get(k);
        if (currentParam.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE) || currentParam.getFieldType().equals(EParameterFieldType.SCHEMA_REFERENCE)) {
            Object value = currentParam.getValue();
            if (value instanceof IMetadataTable) {
                IMetadataTable table = ((IMetadataTable) value).clone();
                table.setTableName(LOG_UNIQUE_NAME);
                table.setAttachedConnector(currentParam.getContext());
                logsNode.getMetadataList().add(table);
            }
            found = true;
        }
    }
    return logsNode;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) DataNode(org.talend.designer.core.model.process.DataNode) IComponent(org.talend.core.model.components.IComponent) IElementParameter(org.talend.core.model.process.IElementParameter)

Example 72 with IElementParameter

use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.

the class StatsAndLogsManager method statsAndLogsParametersFilePart.

private static List<IElementParameter> statsAndLogsParametersFilePart(IProcess process) {
    ElementParameter param;
    IPreferenceStore preferenceStore = DesignerPlugin.getDefault().getPreferenceStore();
    List<IElementParameter> paramList = new ArrayList<IElementParameter>();
    //$NON-NLS-1$
    String languagePrefix = LanguageManager.getCurrentLanguage().toString() + "_";
    // on files
    param = new ElementParameter(process);
    param.setName(EParameterName.ON_FILES_FLAG.getName());
    param.setValue(preferenceStore.getBoolean(languagePrefix + EParameterName.ON_FILES_FLAG.getName()));
    param.setDisplayName(EParameterName.ON_FILES_FLAG.getDisplayName());
    param.setFieldType(EParameterFieldType.CHECK);
    param.setCategory(EComponentCategory.STATSANDLOGS);
    param.setNumRow(10);
    //$NON-NLS-1$
    param.setShowIf("(ON_STATCATCHER_FLAG == 'true' or ON_LOGCATCHER_FLAG == 'true' or ON_METERCATCHER_FLAG == 'true')");
    paramList.add(param);
    // file path
    param = new ElementParameter(process);
    param.setName(EParameterName.FILE_PATH.getName());
    param.setValue(addQuotes(replaceSlash(preferenceStore.getString(languagePrefix + EParameterName.FILE_PATH.getName()))));
    param.setDisplayName(EParameterName.FILE_PATH.getDisplayName());
    param.setFieldType(EParameterFieldType.DIRECTORY);
    param.setCategory(EComponentCategory.STATSANDLOGS);
    //$NON-NLS-1$
    param.setShowIf("(ON_FILES_FLAG == 'true') and (ON_STATCATCHER_FLAG == 'true' or ON_LOGCATCHER_FLAG == 'true' or ON_METERCATCHER_FLAG == 'true')");
    param.setNumRow(11);
    paramList.add(param);
    // stats file name
    param = new ElementParameter(process);
    param.setName(EParameterName.FILENAME_STATS.getName());
    param.setValue(addQuotes(preferenceStore.getString(languagePrefix + EParameterName.FILENAME_STATS.getName())));
    param.setDisplayName(EParameterName.FILENAME_STATS.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.STATSANDLOGS);
    //$NON-NLS-1$
    param.setShowIf("(ON_FILES_FLAG == 'true' and ON_STATCATCHER_FLAG == 'true')");
    param.setRequired(true);
    param.setNumRow(12);
    paramList.add(param);
    param = new ElementParameter(process);
    param.setName(EParameterName.FILENAME_LOGS.getName());
    param.setValue(addQuotes(preferenceStore.getString(languagePrefix + EParameterName.FILENAME_LOGS.getName())));
    param.setDisplayName(EParameterName.FILENAME_LOGS.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.STATSANDLOGS);
    //$NON-NLS-1$
    param.setShowIf("(ON_FILES_FLAG == 'true' and ON_LOGCATCHER_FLAG == 'true')");
    param.setNumRow(13);
    param.setRequired(true);
    paramList.add(param);
    param = new ElementParameter(process);
    param.setName(EParameterName.FILENAME_METTER.getName());
    param.setValue(addQuotes(preferenceStore.getString(languagePrefix + EParameterName.FILENAME_METTER.getName())));
    param.setDisplayName(EParameterName.FILENAME_METTER.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.STATSANDLOGS);
    //$NON-NLS-1$
    param.setShowIf("(ON_FILES_FLAG == 'true' and ON_METERCATCHER_FLAG == 'true')");
    param.setRequired(true);
    param.setNumRow(14);
    paramList.add(param);
    // stats log encoding
    ElementParameter encodingParam = new ElementParameter(process);
    encodingParam.setName(EParameterName.ENCODING.getName());
    encodingParam.setDisplayName(EParameterName.ENCODING.getDisplayName());
    encodingParam.setCategory(EComponentCategory.STATSANDLOGS);
    encodingParam.setFieldType(EParameterFieldType.ENCODING_TYPE);
    encodingParam.setShowIf(//$NON-NLS-1$
    "(ON_FILES_FLAG == 'true') and (ON_STATCATCHER_FLAG == 'true' or ON_LOGCATCHER_FLAG == 'true' or ON_METERCATCHER_FLAG == 'true')");
    encodingParam.setValue(ENCODING_TYPE_ISO_8859_15);
    encodingParam.setNumRow(15);
    paramList.add(encodingParam);
    ElementParameter childPram = new ElementParameter(process);
    childPram.setName(EParameterName.ENCODING_TYPE.getName());
    childPram.setDisplayName(EParameterName.ENCODING_TYPE.getDisplayName());
    childPram.setFieldType(EParameterFieldType.TECHNICAL);
    childPram.setCategory(EComponentCategory.STATSANDLOGS);
    childPram.setListItemsDisplayName(new String[] { ENCODING_TYPE_ISO_8859_15, ENCODING_TYPE_UTF_8, ENCODING_TYPE_CUSTOM });
    childPram.setListItemsDisplayCodeName(new String[] { ENCODING_TYPE_ISO_8859_15, ENCODING_TYPE_UTF_8, ENCODING_TYPE_CUSTOM });
    childPram.setListItemsValue(new String[] { ENCODING_TYPE_ISO_8859_15, ENCODING_TYPE_UTF_8, ENCODING_TYPE_CUSTOM });
    childPram.setValue(ENCODING_TYPE_ISO_8859_15);
    childPram.setNumRow(15);
    childPram.setShowIf(//$NON-NLS-1$
    "(ON_FILES_FLAG == 'true') and (ON_STATCATCHER_FLAG == 'true' or ON_LOGCATCHER_FLAG == 'true' or ON_METERCATCHER_FLAG == 'true')");
    childPram.setParentParameter(encodingParam);
    return paramList;
}
Also used : IElementParameter(org.talend.core.model.process.IElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) ArrayList(java.util.ArrayList) IElementParameter(org.talend.core.model.process.IElementParameter) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 73 with IElementParameter

use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.

the class AbstractMultiPageTalendEditor method covertJobscriptOnPageChange.

private void covertJobscriptOnPageChange() {
    try {
        boolean isDirty = jobletEditor.isDirty();
        jobletEditor.doSave(null);
        IProcess2 oldProcess = getProcess();
        ICreateXtextProcessService n = CorePlugin.getDefault().getCreateXtextProcessService();
        Item item = oldProcess.getProperty().getItem();
        ProcessType processType = null;
        if (item instanceof ProcessItem) {
            processType = n.convertDesignerEditorInput(((IFile) jobletEditor.getEditorInput().getAdapter(IResource.class)).getLocation().toOSString(), oldProcess.getProperty());
        } else if (item instanceof JobletProcessItem) {
            processType = n.convertJobletDesignerEditorInput(((IFile) jobletEditor.getEditorInput().getAdapter(IResource.class)).getLocation().toOSString(), oldProcess.getProperty());
        }
        if (item instanceof ProcessItem) {
            ((Process) oldProcess).updateProcess(processType);
        } else if (item instanceof JobletProcessItem) {
            ((Process) oldProcess).updateProcess(processType);
        }
        oldProcess.getUpdateManager().updateAll();
        designerEditor.setDirty(isDirty);
        List<Node> nodes = (List<Node>) oldProcess.getGraphicalNodes();
        List<Node> newNodes = new ArrayList<Node>();
        newNodes.addAll(nodes);
        for (Node node : newNodes) {
            node.getProcess().checkStartNodes();
            node.checkAndRefreshNode();
            IElementParameter ep = node.getElementParameter("ACTIVATE");
            if (ep != null && ep.getValue().equals(Boolean.FALSE)) {
                node.setPropertyValue(EParameterName.ACTIVATE.getName(), true);
                node.setPropertyValue(EParameterName.ACTIVATE.getName(), false);
            } else if (ep != null && ep.getValue().equals(Boolean.TRUE)) {
                node.setPropertyValue(EParameterName.ACTIVATE.getName(), false);
                node.setPropertyValue(EParameterName.ACTIVATE.getName(), true);
            }
            for (IElementParameter param : node.getElementParameters()) {
                if (!param.getChildParameters().isEmpty()) {
                    if (param.getValue() != null && param.getValue() instanceof String && ((String) param.getValue()).contains(":")) {
                        String[] splited = ((String) param.getValue()).split(":");
                        String childNameNeeded = splited[0].trim();
                        String valueChild = TalendQuoteUtils.removeQuotes(splited[1].trim());
                        if (param.getChildParameters().containsKey(childNameNeeded)) {
                            param.getChildParameters().get(childNameNeeded).setValue(valueChild);
                        }
                    }
                }
            }
            if (node.getNodeContainer() instanceof JobletContainer) {
                JobletContainer jc = (JobletContainer) node.getNodeContainer();
                if (node.isMapReduceStart()) {
                    //$NON-NLS-1$
                    jc.updateState("UPDATE_STATUS", "", jc.getPercentMap(), jc.getPercentReduce());
                }
            }
        }
    } catch (PersistenceException e) {
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) AbstractJobletContainer(org.talend.designer.core.ui.editor.jobletcontainer.AbstractJobletContainer) JobletContainer(org.talend.designer.core.ui.editor.jobletcontainer.JobletContainer) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) ArrayList(java.util.ArrayList) ICreateXtextProcessService(org.talend.core.services.ICreateXtextProcessService) Process(org.talend.designer.core.ui.editor.process.Process) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) IProcess2(org.talend.core.model.process.IProcess2) PersistenceException(org.talend.commons.exception.PersistenceException) IElementParameter(org.talend.core.model.process.IElementParameter) ArrayList(java.util.ArrayList) List(java.util.List) IResource(org.eclipse.core.resources.IResource)

Example 74 with IElementParameter

use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.

the class AbstractMultiPageTalendEditor method isVirtualNode.

/**
     * 
     * DOC YeXiaowei Comment method "isVirtualNode".
     * 
     * @param node
     * @return
     */
private boolean isVirtualNode(final INode node) {
    boolean isVirtualNode = false;
    //$NON-NLS-1$
    IElementParameter param = node.getElementParameter("IS_VIRTUAL_COMPONENT");
    if (param != null) {
        // now only available for tUniqRow.
        return (Boolean) param.getValue() && param.isRequired(node.getElementParameters());
    }
    final String componentName = node.getComponent().getName();
    if (componentName.equals("tMap")) {
        //$NON-NLS-1$
        isVirtualNode = CorePlugin.getDefault().getMapperService().isVirtualComponent(node);
    } else if (componentName.equals("tXMLMap")) {
        //$NON-NLS-1$
        isVirtualNode = CorePlugin.getDefault().getXMLMapperService().isVirtualComponent(node);
    } else if (componentName.equals("tAvroMap")) {
        //$NON-NLS-1$
        isVirtualNode = CorePlugin.getDefault().getSparkMapperService().isVirtualComponent(node);
    } else {
        List<IMultipleComponentManager> multipleComponentManagers = node.getComponent().getMultipleComponentManagers();
        for (IMultipleComponentManager mcm : multipleComponentManagers) {
            if (!mcm.isLookupMode()) {
                return true;
            }
        }
    }
    if (!isVirtualNode) {
        if (node.getExternalNode() != null) {
            return node.getExternalNode().isGeneratedAsVirtualComponent();
        }
    }
    return isVirtualNode;
}
Also used : IElementParameter(org.talend.core.model.process.IElementParameter) IMultipleComponentManager(org.talend.core.model.components.IMultipleComponentManager)

Example 75 with IElementParameter

use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.

the class AbstractTraceAction method calculateEnabled.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
     */
@Override
protected boolean calculateEnabled() {
    List parts = getSelectedObjects();
    if (parts.size() != 1) {
        return false;
    }
    Object input = parts.get(0);
    if (input instanceof ConnectionPart) {
        ConnectionPart connPart = (ConnectionPart) input;
        List childParts = connPart.getChildren();
        for (Object part : childParts) {
            if (part != null && part instanceof ConnectionTraceEditPart) {
                Connection conn = (Connection) connPart.getModel();
                if (conn.enableTraces() && conn.checkTraceShowEnable()) {
                    IElementParameter element = conn.getElementParameter(EParameterName.TRACES_CONNECTION_ENABLE.getName());
                    Boolean flag = (Boolean) element.getValue();
                    if (flag != isEnableAction()) {
                        return true;
                    }
                }
            }
        }
    }
    if (input instanceof ConnLabelEditPart) {
        ConnLabelEditPart labelPart = (ConnLabelEditPart) input;
        ConnectionPart connPart = (ConnectionPart) labelPart.getParent();
        List childParts = connPart.getChildren();
        for (Object part : childParts) {
            if (part != null && part instanceof ConnectionTraceEditPart) {
                Connection conn = (Connection) connPart.getModel();
                if (conn.enableTraces() && conn.checkTraceShowEnable()) {
                    IElementParameter element = conn.getElementParameter(EParameterName.TRACES_CONNECTION_ENABLE.getName());
                    Boolean flag = (Boolean) element.getValue();
                    if (flag != isEnableAction()) {
                        return true;
                    }
                }
            }
        }
    }
    if (input instanceof ConnectionTraceEditPart) {
        ConnectionTraceEditPart tracePart = (ConnectionTraceEditPart) input;
        ConnectionPart connPart = (ConnectionPart) tracePart.getParent();
        Connection conn = (Connection) connPart.getModel();
        if (conn.enableTraces() && conn.checkTraceShowEnable()) {
            IElementParameter element = conn.getElementParameter(EParameterName.TRACES_CONNECTION_ENABLE.getName());
            Boolean flag = (Boolean) element.getValue();
            if (flag != isEnableAction()) {
                return true;
            }
        }
    }
    return false;
}
Also used : ConnectionTraceEditPart(org.talend.designer.core.ui.editor.connections.ConnectionTraceEditPart) Connection(org.talend.designer.core.ui.editor.connections.Connection) IElementParameter(org.talend.core.model.process.IElementParameter) List(java.util.List) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Aggregations

IElementParameter (org.talend.core.model.process.IElementParameter)439 ArrayList (java.util.ArrayList)165 List (java.util.List)112 Node (org.talend.designer.core.ui.editor.nodes.Node)108 Map (java.util.Map)99 INode (org.talend.core.model.process.INode)94 HashMap (java.util.HashMap)87 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)73 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)69 Point (org.eclipse.swt.graphics.Point)57 ElementParameter (org.talend.designer.core.model.components.ElementParameter)48 ConnectionItem (org.talend.core.model.properties.ConnectionItem)45 IConnection (org.talend.core.model.process.IConnection)40 PersistenceException (org.talend.commons.exception.PersistenceException)39 Item (org.talend.core.model.properties.Item)38 PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)37 IComponent (org.talend.core.model.components.IComponent)36 CCombo (org.eclipse.swt.custom.CCombo)33 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)29 Connection (org.talend.core.model.metadata.builder.connection.Connection)28