Search in sources :

Example 61 with ElementParameterType

use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType in project tdi-studio-se by Talend.

the class UnifyPasswordEncryption4ProjectSettingsMigrationTask method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.migration.IProjectMigrationTask#execute(org.talend.core.model.general.Project)
     */
@Override
public ExecutionResult execute(Project project) {
    org.talend.core.model.properties.Project emfProject = project.getEmfProject();
    StatAndLogsSettings statAndLogs = emfProject.getStatAndLogsSettings();
    boolean modified = false;
    if (statAndLogs != null && statAndLogs.getParameters() != null) {
        ParametersType parameters = statAndLogs.getParameters();
        List elementParameter = parameters.getElementParameter();
        for (int i = 0; i < elementParameter.size(); i++) {
            final Object object = elementParameter.get(i);
            if (object instanceof ElementParameterType) {
                ElementParameterType parameterType = (ElementParameterType) object;
                String name = parameterType.getName();
                // variable name used for Stat&Logs
                if ("PASS".equals(name)) {
                    //$NON-NLS-1$
                    parameterType.setField(EParameterFieldType.PASSWORD.getName());
                    try {
                        if (reencryptValueIfNeeded(parameterType)) {
                            modified = true;
                        }
                    } catch (Exception e) {
                        ExceptionHandler.process(e);
                        return ExecutionResult.FAILURE;
                    }
                }
            }
        }
    }
    ImplicitContextSettings implicitContext = emfProject.getImplicitContextSettings();
    if (implicitContext != null && implicitContext.getParameters() != null) {
        ParametersType parameters = implicitContext.getParameters();
        List elementParameter = parameters.getElementParameter();
        for (int i = 0; i < elementParameter.size(); i++) {
            final Object object = elementParameter.get(i);
            if (object instanceof ElementParameterTypeImpl) {
                ElementParameterType parameterType = (ElementParameterType) object;
                String name = parameterType.getName();
                // variable name used for implicit context
                if ("PASS_IMPLICIT_CONTEXT".equals(name)) {
                    //$NON-NLS-1$
                    parameterType.setField(EParameterFieldType.PASSWORD.getName());
                    try {
                        if (reencryptValueIfNeeded(parameterType)) {
                            modified = true;
                        }
                    } catch (Exception e) {
                        ExceptionHandler.process(e);
                        return ExecutionResult.FAILURE;
                    }
                }
            }
        }
    }
    if (modified) {
        try {
            factory.saveProject(project);
            return ExecutionResult.SUCCESS_NO_ALERT;
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
            return ExecutionResult.FAILURE;
        }
    }
    return ExecutionResult.NOTHING_TO_DO;
}
Also used : PersistenceException(org.talend.commons.exception.PersistenceException) ImplicitContextSettings(org.talend.core.model.properties.ImplicitContextSettings) ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) StatAndLogsSettings(org.talend.core.model.properties.StatAndLogsSettings) PersistenceException(org.talend.commons.exception.PersistenceException) List(java.util.List) ParametersType(org.talend.designer.core.model.utils.emf.talendfile.ParametersType) ElementParameterTypeImpl(org.talend.designer.core.model.utils.emf.talendfile.impl.ElementParameterTypeImpl)

Example 62 with ElementParameterType

use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType in project tdi-studio-se by Talend.

the class UnifyParameterOfDatastaxAndHectorForCassandra method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
     */
@Override
public ExecutionResult execute(Item item) {
    final ProcessType processType = getProcessType(item);
    //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ 
    String[] compNames = { "tCassandraInput", "tCassandraOutput", "tCassandraRow", "tCassandraLookupInput" };
    IComponentConversion conversion = new IComponentConversion() {

        @Override
        public void transform(NodeType node) {
            if (node == null) {
                return;
            }
            //$NON-NLS-1$
            ElementParameterType cf = ComponentUtilities.getNodeProperty(node, "TABLE");
            if (cf != null) {
                if (ComponentUtilities.getNodeProperty(node, "COLUMN_FAMILY") == null) {
                    //$NON-NLS-1$
                    //$NON-NLS-1$ //$NON-NLS-2$
                    ComponentUtilities.addNodeProperty(node, "COLUMN_FAMILY", "TEXT");
                }
                //$NON-NLS-1$ 
                ComponentUtilities.getNodeProperty(node, "COLUMN_FAMILY").setValue(cf.getValue());
            }
            //$NON-NLS-1$
            ElementParameterType actionForCF = ComponentUtilities.getNodeProperty(node, "TABLE_ACTION");
            if (actionForCF != null) {
                if (ComponentUtilities.getNodeProperty(node, "ACTION_ON_COLUMN_FAMILY") == null) {
                    //$NON-NLS-1$
                    //$NON-NLS-1$ //$NON-NLS-2$
                    ComponentUtilities.addNodeProperty(node, "ACTION_ON_COLUMN_FAMILY", "TEXT");
                }
                //$NON-NLS-1$ 
                ComponentUtilities.getNodeProperty(node, "ACTION_ON_COLUMN_FAMILY").setValue(actionForCF.getValue());
            }
        }
    };
    for (String name : compNames) {
        IComponentFilter filter = new NameComponentFilter(name);
        try {
            ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(conversion));
        } catch (PersistenceException e) {
            // TODO Auto-generated catch block
            ExceptionHandler.process(e);
            return ExecutionResult.FAILURE;
        }
    }
    return ExecutionResult.SUCCESS_NO_ALERT;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) PersistenceException(org.talend.commons.exception.PersistenceException) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 63 with ElementParameterType

use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType in project tdi-studio-se by Talend.

the class UpdateCheckResult method getCategory.

@Override
@SuppressWarnings("unchecked")
public String getCategory() {
    String category = null;
    if (getUpdateType() instanceof EUpdateItemType) {
        switch((EUpdateItemType) getUpdateType()) {
            case NODE_PROPERTY:
            case NODE_SCHEMA:
            case NODE_QUERY:
            case NODE_VALIDATION_RULE:
            case JOBLET_SCHEMA:
                if (getUpdateObject() != null) {
                    if (getUpdateObject() instanceof Node) {
                        Node node = (Node) getUpdateObject();
                        if (node.getUniqueName().equals(node.getLabel())) {
                            category = node.getUniqueName();
                        } else {
                            category = node.getLabel() + UpdateManagerUtils.addBrackets(node.getUniqueName());
                        }
                    }
                    if (getUpdateObject() instanceof NodeType) {
                        NodeType node = (NodeType) getUpdateObject();
                        String uniqueName = null;
                        for (ElementParameterType param : (List<ElementParameterType>) node.getElementParameter()) {
                            if (EParameterName.UNIQUE_NAME.getName().equals(param.getName())) {
                                uniqueName = param.getValue();
                                break;
                            }
                        }
                        if (uniqueName != null) {
                            category = uniqueName;
                        }
                    }
                }
                break;
            case JOB_PROPERTY_EXTRA:
            case JOB_PROPERTY_STATS_LOGS:
            case JOB_PROPERTY_HEADERFOOTER:
            case JOB_PROPERTY_MAPREDUCE:
                boolean isJoblet = false;
                boolean isMR = false;
                if (getUpdateObject() != null) {
                    if (getUpdateObject() instanceof org.talend.designer.core.ui.editor.process.Process) {
                        if (AbstractProcessProvider.isExtensionProcessForJoblet((IProcess) getUpdateObject())) {
                            isJoblet = true;
                        } else if (GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class)) {
                            IMRProcessService mrProcessService = (IMRProcessService) GlobalServiceRegister.getDefault().getService(IMRProcessService.class);
                            org.talend.core.model.properties.Item item = ((org.talend.designer.core.ui.editor.process.Process) getUpdateObject()).getProperty().getItem();
                            isMR = mrProcessService.isMapReduceItem(item);
                        }
                    }
                }
                if (isMR) {
                    //
                    category = JobSettingsView.VIEW_NAME_BATCH;
                } else if (isJoblet) {
                    // joblet
                    category = JobSettingsView.VIEW_NAME_JOBLET;
                } else {
                    category = JobSettingsView.getViewNameLable();
                }
                break;
            case JOB_PROPERTY_STORM:
                boolean isStreaming = false;
                if (getUpdateObject() != null && getUpdateObject() instanceof org.talend.designer.core.ui.editor.process.Process) {
                    if (GlobalServiceRegister.getDefault().isServiceRegistered(IStormProcessService.class)) {
                        IStormProcessService streamingService = (IStormProcessService) GlobalServiceRegister.getDefault().getService(IStormProcessService.class);
                        org.talend.core.model.properties.Item item = ((org.talend.designer.core.ui.editor.process.Process) getUpdateObject()).getProperty().getItem();
                        isStreaming = streamingService.isStormItem(item);
                    }
                }
                if (isStreaming) {
                    //
                    category = JobSettingsView.VIEW_NAME_STREAMING;
                } else {
                    category = JobSettingsView.getViewNameLable();
                }
                break;
            case CONTEXT:
                // case JOBLET_CONTEXT:
                category = UpdatesConstants.CONTEXT;
                break;
            case CONTEXT_GROUP:
                category = UpdatesConstants.CONTEXT_GROUP;
                break;
            case JOBLET_RENAMED:
            case RELOAD:
            case JUNIT_RELOAD:
                if (getUpdateObject() != null && getUpdateObject() instanceof List) {
                    String display = UpdateManagerHelper.getCollectionsDisplay(getUpdateObject(), true);
                    if (display != null) {
                        category = display;
                    }
                } else if (getParameter() != null && getParameter() instanceof PropertyChangeEvent) {
                    PropertyChangeEvent event = (PropertyChangeEvent) getParameter();
                    // reload all compoennts.
                    if (event.getSource() != null && !(event.getSource() instanceof IProcess)) {
                        category = UpdatesConstants.COMPONENT;
                        break;
                    }
                } else {
                    category = UpdatesConstants.JOBLET;
                }
                break;
            default:
        }
    } else {
        category = UpdateManagerProviderDetector.INSTANCE.getDisplayCategory(this);
    }
    return category == null ? UpdatesConstants.EMPTY : category;
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) IMRProcessService(org.talend.core.service.IMRProcessService) Item(org.talend.core.model.properties.Item) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) IStormProcessService(org.talend.core.service.IStormProcessService) IProcess(org.talend.core.model.process.IProcess) EUpdateItemType(org.talend.core.model.update.EUpdateItemType) ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) Item(org.talend.core.model.properties.Item) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) List(java.util.List) IProcess(org.talend.core.model.process.IProcess)

Example 64 with ElementParameterType

use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType in project tdi-studio-se by Talend.

the class JobletUtil method isJobletInput.

public boolean isJobletInput(Node connNode, IProcess2 process) {
    if (process.getProperty().getItem() instanceof JobletProcessItem) {
        JobletProcess jobletProcess = ((JobletProcessItem) process.getProperty().getItem()).getJobletProcess();
        List<JobletNode> jobletNodes = jobletProcess.getJobletNodes();
        for (JobletNode jnode : jobletNodes) {
            List list = jnode.getElementParameter();
            for (Object obj : list) {
                if (obj instanceof ElementParameterType) {
                    if (((ElementParameterType) obj).getValue().equals(connNode.getJoblet_unique_name())) {
                        return jnode.isInput();
                    }
                }
            }
        }
    }
    return false;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) JobletNode(org.talend.designer.joblet.model.JobletNode) JobletProcess(org.talend.designer.joblet.model.JobletProcess)

Example 65 with ElementParameterType

use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType in project tdi-studio-se by Talend.

the class UpgradeParameterHelper method upgradeRelatedParameters.

/**
     * 
     * ggu Comment method "upgradeRelatedParameters".
     * 
     * "type =null" is only for property type parameter.
     */
private static boolean upgradeRelatedParameters(ElementParameterType repositoryParam, String repositoryParamName, final String oleTypeParamName, String newTypeParamName, final String parentName, List<ElementParameterType> elemParamList, ERepositoryObjectType type) {
    if (repositoryParam == null || oleTypeParamName == null || parentName == null || elemParamList == null || elemParamList.isEmpty()) {
        return false;
    }
    if (repositoryParamName == null) {
        repositoryParamName = repositoryParam.getName();
    }
    if (newTypeParamName == null) {
        newTypeParamName = oleTypeParamName;
    }
    // related paramter
    // such as PROPERTY_TYPE, QUERYSTORE_TYPE, SCHEMA_TYPE
    ElementParameterType typeParam = findParameter(oleTypeParamName, elemParamList);
    if (typeParam != null) {
        repositoryParam.setName(parentName + COLON + repositoryParamName);
        repositoryParam.setField(EParameterFieldType.TECHNICAL.getName());
        typeParam.setName(parentName + COLON + newTypeParamName);
        typeParam.setField(EParameterFieldType.TECHNICAL.getName());
        // update the value
        updateParameterValue(repositoryParam, typeParam, parentName, type);
        return true;
    }
    return false;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)

Aggregations

ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)197 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)126 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)114 PersistenceException (org.talend.commons.exception.PersistenceException)86 IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)85 IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)83 NameComponentFilter (org.talend.core.model.components.filters.NameComponentFilter)83 EList (org.eclipse.emf.common.util.EList)40 ElementValueType (org.talend.designer.core.model.utils.emf.talendfile.ElementValueType)28 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)25 List (java.util.List)22 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)19 ArrayList (java.util.ArrayList)16 ProcessItem (org.talend.core.model.properties.ProcessItem)16 ParametersType (org.talend.designer.core.model.utils.emf.talendfile.ParametersType)15 ConnectionType (org.talend.designer.core.model.utils.emf.talendfile.ConnectionType)13 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)9 HashMap (java.util.HashMap)7 IOException (java.io.IOException)6 IElementParameter (org.talend.core.model.process.IElementParameter)6