Search in sources :

Example 1 with IExternalData

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

the class DbMapComponent method inputMetadataColumnAmountChanged.

private void inputMetadataColumnAmountChanged(IODataComponent dataComponent, IExternalNode externalNode) {
    List<ColumnNameChanged> removedMetadataColumns = dataComponent.getRemoveMetadataColumns();
    IExternalData iExternalData = externalNode.getExternalData();
    if (iExternalData == null || removedMetadataColumns == null || removedMetadataColumns.size() == 0) {
        return;
    }
    List<ExternalDbMapTable> metaTableList = (List<ExternalDbMapTable>) iExternalData.getInputTables();
    if (metaTableList == null || metaTableList.size() == 0) {
        return;
    }
    // in the eltmap, the input table name is same with it's input connection name
    String tableName = dataComponent.getName();
    if (StringUtils.isEmpty(tableName)) {
        return;
    }
    for (ExternalDbMapTable metaTable : metaTableList) {
        if (tableName.equals(metaTable.getTableName())) {
            List<IExternalMapEntry> externalMapEntryList = (List<IExternalMapEntry>) metaTable.returnTableEntries();
            if (externalMapEntryList == null || externalMapEntryList.size() == 0) {
                continue;
            }
            if (removedMetadataColumns != null && 0 < removedMetadataColumns.size()) {
                for (ColumnNameChanged removedMetadataColumn : removedMetadataColumns) {
                    if ("".equals(removedMetadataColumn.getNewName())) {
                        //$NON-NLS-1$
                        String columnName = removedMetadataColumn.getOldName();
                        for (int i = externalMapEntryList.size() - 1; 0 <= i; i--) {
                            IExternalMapEntry mapEntry = externalMapEntryList.get(i);
                            if (columnName.equals(mapEntry.getName())) {
                                externalMapEntryList.remove(i);
                                break;
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : ColumnNameChanged(org.talend.core.model.metadata.ColumnNameChanged) ExternalDbMapTable(org.talend.designer.dbmap.external.data.ExternalDbMapTable) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) IExternalData(org.talend.core.model.process.IExternalData) IExternalMapEntry(org.talend.core.model.process.node.IExternalMapEntry)

Example 2 with IExternalData

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

the class MapperManager method isDataChanged.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.abstractmap.managers.AbstractMapperManager#isMapperChanged()
     */
@Override
public boolean isDataChanged() {
    getAbstractMapComponent().restoreMapperModelFromInternalData();
    IExternalData originalExternalData = getOriginalExternalData();
    IExternalData currentExternalData = getAbstractMapComponent().getExternalData();
    if (originalExternalData == null && currentExternalData == null) {
        return false;
    }
    if (originalExternalData == null && currentExternalData != null) {
        return true;
    }
    return !originalExternalData.equals(currentExternalData) || MapperSettingsManager.getInstance(this).isMapperSettingChanged();
}
Also used : IExternalData(org.talend.core.model.process.IExternalData)

Example 3 with IExternalData

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

the class NodePart method performRequest.

@Override
public void performRequest(Request req) {
    Node node = (Node) getModel();
    IExternalData oldExternalData = node.getExternalData();
    if (req.getType().equals(RequestConstants.REQ_OPEN)) {
        IExternalNode externalNode = null;
        if (node.isExternalNode()) {
            IElementParameter externalParam = node.getElementParameterFromField(EParameterFieldType.EXTERNAL);
            if (externalParam != null && externalParam.isShow(node.getElementParameters())) {
                externalNode = ExternalUtilities.getExternalNodeReadyToOpen(node);
            }
        }
        IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
        if (externalNode != null && (part instanceof AbstractMultiPageTalendEditor)) {
            boolean isOriginalNode = false;
            ITestContainerProviderService testContainerService = null;
            if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
                testContainerService = (ITestContainerProviderService) GlobalServiceRegister.getDefault().getService(ITestContainerProviderService.class);
                if (testContainerService != null) {
                    isOriginalNode = testContainerService.isOriginalNode(node);
                    if (isOriginalNode) {
                        testContainerService.renameConnection(node, true);
                    }
                }
            }
            int returnValue = externalNode.open(getViewer().getControl().getShell());
            if (!node.isReadOnly()) {
                if (returnValue == SWT.OK) {
                    Command cmd = new ExternalNodeChangeCommand(node, externalNode, oldExternalData);
                    CommandStack cmdStack = (CommandStack) part.getAdapter(CommandStack.class);
                    cmdStack.execute(cmd);
                } else {
                    externalNode.setExternalData(oldExternalData);
                }
            }
            if (isOriginalNode && (testContainerService != null)) {
                testContainerService.renameConnection(node, false);
            }
        } else {
            // add for feature 13361
            boolean isJoblet = false;
            if (PluginChecker.isJobLetPluginLoaded()) {
                AbstractProcessProvider jobletProcessProvider = AbstractProcessProvider.findProcessProviderFromPID(IComponent.JOBLET_PID);
                final IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
                boolean isAvoidShowJobletAfterDoubleClick = false;
                if (GlobalServiceRegister.getDefault().isServiceRegistered(IComponentsLocalProviderService.class)) {
                    IComponentsLocalProviderService componentService = (IComponentsLocalProviderService) GlobalServiceRegister.getDefault().getService(IComponentsLocalProviderService.class);
                    if (componentService != null) {
                        isAvoidShowJobletAfterDoubleClick = componentService.isAvoidToShowJobletAfterDoubleClick();
                    }
                }
                if (service != null && service.isJobletComponent(node) && !isAvoidShowJobletAfterDoubleClick) {
                    isJoblet = true;
                    String version = (String) node.getPropertyValue(EParameterName.PROCESS_TYPE_VERSION.getName());
                    final Item jobletItem = jobletProcessProvider.getJobletItem(node, version);
                    RepositoryWorkUnit<Object> repositoryWorkUnit = new RepositoryWorkUnit<Object>("", this) {

                        @Override
                        protected void run() throws LoginException, PersistenceException {
                            if (jobletItem != null) {
                                service.openJobletItem((JobletProcessItem) jobletItem);
                            }
                        }
                    };
                    repositoryWorkUnit.setAvoidUnloadResources(true);
                    CoreRuntimePlugin.getInstance().getProxyRepositoryFactory().executeRepositoryWorkUnit(repositoryWorkUnit);
                }
            }
            if (!isJoblet) {
                IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
                String processName = (String) node.getPropertyValue(EParameterName.PROCESS_TYPE_PROCESS.getName());
                String version = (String) node.getPropertyValue(EParameterName.PROCESS_TYPE_VERSION.getName());
                boolean isAvoidShowJobAfterDoubleClick = false;
                if (GlobalServiceRegister.getDefault().isServiceRegistered(IComponentsLocalProviderService.class)) {
                    IComponentsLocalProviderService service = (IComponentsLocalProviderService) GlobalServiceRegister.getDefault().getService(IComponentsLocalProviderService.class);
                    if (service != null) {
                        isAvoidShowJobAfterDoubleClick = service.isAvoidToShowJobAfterDoubleClick();
                    }
                }
                // bug 20796
                boolean isSelectUseDynamic = false;
                Object useDynamicJobValue = node.getPropertyValue(EParameterName.USE_DYNAMIC_JOB.getName());
                if (useDynamicJobValue != null && useDynamicJobValue instanceof Boolean) {
                    isSelectUseDynamic = (Boolean) useDynamicJobValue;
                }
                if (processName != null && !"".equals(processName) && !isAvoidShowJobAfterDoubleClick && !isSelectUseDynamic) {
                    //$NON-NLS-1$
                    ItemCacheManager.clearCache();
                    ProcessItem processItem = ItemCacheManager.getProcessItem(processName, version);
                    if (processItem == null) {
                        return;
                    }
                    Property updatedProperty = null;
                    try {
                        updatedProperty = ProxyRepositoryFactory.getInstance().getLastVersion(new Project(ProjectManager.getInstance().getProject(processItem)), processName).getProperty();
                    } catch (PersistenceException e) {
                        CommonExceptionHandler.process(e);
                    }
                    // update the property of the node repository object
                    // node.getObject().setProperty(updatedProperty);
                    processItem = (ProcessItem) updatedProperty.getItem();
                    final ProcessItem item = processItem;
                    RepositoryWorkUnit<Object> repositoryWorkUnit = new RepositoryWorkUnit<Object>("", this) {

                        @Override
                        protected void run() throws LoginException, PersistenceException {
                            try {
                                if (item != null) {
                                    ERepositoryObjectType repObjType = ERepositoryObjectType.getItemType(item);
                                    IJobEditorHandler editorInputFactory = JobEditorHandlerManager.getInstance().extractEditorInputFactory(repObjType.getType());
                                    editorInputFactory.openJobEditor(editorInputFactory.createJobEditorInput(item, true));
                                }
                            } catch (PartInitException e) {
                                MessageBoxExceptionHandler.process(e);
                            }
                        }
                    };
                    repositoryWorkUnit.setAvoidUnloadResources(true);
                    CoreRuntimePlugin.getInstance().getProxyRepositoryFactory().executeRepositoryWorkUnit(repositoryWorkUnit);
                } else {
                    try {
                        // modified for feature 2454.
                        page.showView(ComponentSettingsView.ID);
                    } catch (PartInitException e) {
                        CommonExceptionHandler.process(e);
                    }
                }
            }
        }
    }
    super.performRequest(req);
}
Also used : IExternalNode(org.talend.core.model.process.IExternalNode) INode(org.talend.core.model.process.INode) IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) RepositoryWorkUnit(org.talend.repository.RepositoryWorkUnit) AbstractProcessProvider(org.talend.designer.core.model.process.AbstractProcessProvider) IComponentsLocalProviderService(org.talend.core.ui.services.IComponentsLocalProviderService) Item(org.talend.core.model.properties.Item) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IElementParameter(org.talend.core.model.process.IElementParameter) PartInitException(org.eclipse.ui.PartInitException) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) Property(org.talend.core.model.properties.Property) IExternalNode(org.talend.core.model.process.IExternalNode) CommandStack(org.eclipse.gef.commands.CommandStack) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) IJobEditorHandler(org.talend.core.ui.editor.IJobEditorHandler) ITestContainerProviderService(org.talend.core.ui.ITestContainerProviderService) Point(org.eclipse.draw2d.geometry.Point) ExternalNodeChangeCommand(org.talend.designer.core.ui.editor.cmd.ExternalNodeChangeCommand) IJobletProviderService(org.talend.core.ui.IJobletProviderService) Project(org.talend.core.model.general.Project) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) ExternalNodeChangeCommand(org.talend.designer.core.ui.editor.cmd.ExternalNodeChangeCommand) Command(org.eclipse.gef.commands.Command) PersistenceException(org.talend.commons.exception.PersistenceException) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IExternalData(org.talend.core.model.process.IExternalData)

Example 4 with IExternalData

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

the class DesignerMapperService method isSameMetadata.

public boolean isSameMetadata(IExternalNode externalNode, String schemaId, IMetadataTable metadataTable) {
    boolean isSame = true;
    if (externalNode == null || schemaId == null || metadataTable == null) {
        return false;
    }
    if (externalNode instanceof MapperComponent) {
        MapperComponent component = (MapperComponent) externalNode;
        IExternalData nodeData = externalNode.getExternalData();
        if (nodeData != null && nodeData instanceof ExternalMapperData) {
            ExternalMapperData mapperData = (ExternalMapperData) nodeData;
            List<ExternalMapperTable> outputTables = mapperData.getOutputTables();
            if (outputTables != null && outputTables.size() > 0) {
                for (ExternalMapperTable outputTable : outputTables) {
                    if (schemaId.equals(outputTable.getId())) {
                        final IMetadataTable mapperTable = getMetadataTable(component, outputTable.getName());
                        if (mapperTable == null || !mapperTable.sameMetadataAs(metadataTable, IMetadataColumn.OPTIONS_NONE)) {
                            return false;
                        }
                    }
                }
            }
        // for (ExternalMapperTable extTable : extTables) {
        // isSame = isMetadataSame(extTable, metadataTable);
        // if (!isSame)
        // return isSame;
        // }
        }
    }
    return isSame;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IExternalData(org.talend.core.model.process.IExternalData) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) ExternalMapperData(org.talend.designer.mapper.external.data.ExternalMapperData)

Example 5 with IExternalData

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

the class DesignerMapperService method renameMapperTable.

public void renameMapperTable(IExternalNode externalNode, String schemaId, String newSchemaId, IMetadataTable metadataTable) {
    if (externalNode == null || schemaId == null || metadataTable == null) {
        return;
    }
    if (externalNode instanceof MapperComponent) {
        MapperComponent component = (MapperComponent) externalNode;
        IExternalData nodeData = externalNode.getExternalData();
        if (nodeData != null && nodeData instanceof ExternalMapperData) {
            ExternalMapperData mapperData = (ExternalMapperData) nodeData;
            List<ExternalMapperTable> outputTables = mapperData.getOutputTables();
            if (outputTables != null && outputTables.size() > 0) {
                for (ExternalMapperTable outputTable : outputTables) {
                    if (!schemaId.equals(outputTable.getId())) {
                        continue;
                    }
                    outputTable.setId(newSchemaId);
                    updateEntriesByMetaColumns(newSchemaId, metadataTable, outputTable, component);
                }
            }
        }
    }
}
Also used : IExternalData(org.talend.core.model.process.IExternalData) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) ExternalMapperData(org.talend.designer.mapper.external.data.ExternalMapperData)

Aggregations

IExternalData (org.talend.core.model.process.IExternalData)9 ExternalMapperTable (org.talend.designer.mapper.external.data.ExternalMapperTable)4 ExternalMapperData (org.talend.designer.mapper.external.data.ExternalMapperData)3 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Point (org.eclipse.draw2d.geometry.Point)1 EList (org.eclipse.emf.common.util.EList)1 Command (org.eclipse.gef.commands.Command)1 CommandStack (org.eclipse.gef.commands.CommandStack)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)1 PartInitException (org.eclipse.ui.PartInitException)1 Test (org.junit.Test)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 Project (org.talend.core.model.general.Project)1 ColumnNameChanged (org.talend.core.model.metadata.ColumnNameChanged)1 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)1 IElementParameter (org.talend.core.model.process.IElementParameter)1 IExternalNode (org.talend.core.model.process.IExternalNode)1 INode (org.talend.core.model.process.INode)1