Search in sources :

Example 1 with EUpdateResult

use of org.talend.core.model.update.EUpdateResult in project tdi-studio-se by Talend.

the class GenericUpdateManager method getDeletedOrReselectTablesMap.

@Override
public Map<String, EUpdateResult> getDeletedOrReselectTablesMap() {
    Map<String, EUpdateResult> drMap = new HashMap<>();
    List<IMetadataTable> newTables = getConversionMetadataTables(connectionItem.getConnection());
    for (IMetadataTable oldTable : oldMetadataTable) {
        String prefix = connectionItem.getProperty().getId() + UpdatesConstants.SEGMENT_LINE;
        boolean isDeleted = true;
        String oldtableLabel = oldTable.getLabel();
        String oldtableId = oldTable.getId();
        for (IMetadataTable newTable : newTables) {
            String tableLabel = newTable.getLabel();
            String tableId = newTable.getId();
            if (tableLabel.equals(oldtableLabel)) {
                isDeleted = false;
                /* if table name is same but tableId is not same,means table has been deselect and reselect */
                if (!tableId.equals(oldtableId)) {
                // don't handle reload for generic
                // drMap.put(prefix + tableLabel, EUpdateResult.RELOAD);
                }
            }
        }
        /* if can't find the name when looping the new tables,means the table has been removed */
        if (isDeleted) {
            drMap.put(prefix + oldtableLabel, EUpdateResult.DELETE);
        }
    }
    return drMap;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) EUpdateResult(org.talend.core.model.update.EUpdateResult) HashMap(java.util.HashMap)

Example 2 with EUpdateResult

use of org.talend.core.model.update.EUpdateResult in project tdi-studio-se by Talend.

the class UpdateCheckResult method getName.

@Override
@SuppressWarnings("unchecked")
public String getName() {
    IUpdateItemType updateType = getUpdateType();
    String displayName = updateType.getDisplayLabel();
    if (updateType instanceof EUpdateItemType) {
        switch((EUpdateItemType) updateType) {
            case NODE_SCHEMA:
                if (getResultType() == EUpdateResult.RENAME) {
                    List<Object> param = (List<Object>) getParameter();
                    String[] oldSourceIdAndChildName = UpdateManagerUtils.getSourceIdAndChildName((String) param.get(1));
                    String[] newSourceIdAndChildName = UpdateManagerUtils.getSourceIdAndChildName((String) param.get(2));
                    String display = UpdateManagerHelper.getRenamedDisplay(oldSourceIdAndChildName[1], newSourceIdAndChildName[1]);
                    if (display != null) {
                        displayName = display;
                    }
                } else if (getResultType() == EUpdateResult.DELETE) {
                    // table delete by deselect
                    List<Object> param = (List<Object>) getParameter();
                    String tableDeleted = (String) param.get(0);
                    EUpdateResult status = (EUpdateResult) param.get(1);
                    String display = getDeleteOrReloadDisplay(tableDeleted, status);
                    if (display != null) {
                        displayName = display;
                    }
                } else if (getResultType() == EUpdateResult.RELOAD) {
                    // table reload by deselect and reselect
                    List<Object> param = (List<Object>) getParameter();
                    String tableReload = (String) param.get(0);
                    EUpdateResult status = (EUpdateResult) param.get(1);
                    String display = getDeleteOrReloadDisplay(tableReload, status);
                    if (display != null) {
                        displayName = display;
                    }
                } else {
                    if (getUpdateObject() instanceof INode && getParameter() instanceof List && PluginChecker.isEBCDICPluginLoaded()) {
                        IEBCDICProviderService service = (IEBCDICProviderService) GlobalServiceRegister.getDefault().getService(IEBCDICProviderService.class);
                        if (service != null && service.isEbcdicNode((INode) getUpdateObject())) {
                            List<Object> paramObjs = (List<Object>) getParameter();
                            if (paramObjs.size() >= 2) {
                                Object schemaName = paramObjs.get(1);
                                if (schemaName instanceof String) {
                                    displayName = displayName + UpdateManagerUtils.addBrackets((String) schemaName);
                                }
                            }
                        }
                    }
                }
                break;
            case NODE_PROPERTY:
            case NODE_QUERY:
            case JOBLET_SCHEMA:
            case NODE_VALIDATION_RULE:
                break;
            case JOB_PROPERTY_EXTRA:
                displayName = displayName + UpdateManagerUtils.addBrackets(EComponentCategory.EXTRA.getTitle());
                break;
            case JOB_PROPERTY_STATS_LOGS:
                displayName = displayName + UpdateManagerUtils.addBrackets(EComponentCategory.STATSANDLOGS.getTitle());
                break;
            case JOB_PROPERTY_HEADERFOOTER:
                displayName = displayName + UpdateManagerUtils.addBrackets(EComponentCategory.HEADERFOOTER.getTitle());
                break;
            case CONTEXT_GROUP:
                if (getUpdateObject() != null && getUpdateObject() instanceof IContext) {
                    displayName = ((IContext) getUpdateObject()).getName();
                }
                break;
            case CONTEXT:
                // case JOBLET_CONTEXT:
                {
                    String display = null;
                    switch(getResultType()) {
                        case RENAME:
                            List<Object> param = (List<Object>) getParameter();
                            display = UpdateManagerHelper.getRenamedDisplay((String) param.get(1), (String) param.get(2));
                            break;
                        default:
                            if (getUpdateObject() instanceof Collection) {
                                display = UpdateManagerHelper.getCollectionsDisplay(getUpdateObject(), false);
                            }
                            break;
                    }
                    if (display != null) {
                        displayName = display;
                    }
                    break;
                }
            case JOBLET_RENAMED:
                {
                    List<Object> param = (List<Object>) getParameter();
                    String display = UpdateManagerHelper.getRenamedDisplay((String) param.get(1), (String) param.get(2));
                    if (display != null) {
                        displayName = display;
                    }
                    break;
                }
            case RELOAD:
            case JUNIT_RELOAD:
                if (getParameter() != null && getParameter() instanceof PropertyChangeEvent) {
                    PropertyChangeEvent event = (PropertyChangeEvent) getParameter();
                    // reload all compoennts.
                    if (event.getSource() != null && !(event.getSource() instanceof IProcess)) {
                        displayName = updateType.getDisplayLabel();
                        break;
                    }
                }
                break;
            default:
        }
        return displayName;
    } else {
        return UpdateManagerProviderDetector.INSTANCE.getResultName(this);
    }
}
Also used : EUpdateResult(org.talend.core.model.update.EUpdateResult) INode(org.talend.core.model.process.INode) PropertyChangeEvent(java.beans.PropertyChangeEvent) IContext(org.talend.core.model.process.IContext) EUpdateItemType(org.talend.core.model.update.EUpdateItemType) IEBCDICProviderService(org.talend.core.service.IEBCDICProviderService) Collection(java.util.Collection) IUpdateItemType(org.talend.core.model.update.IUpdateItemType) List(java.util.List) IProcess(org.talend.core.model.process.IProcess)

Example 3 with EUpdateResult

use of org.talend.core.model.update.EUpdateResult in project tdi-studio-se by Talend.

the class UpdateViewerHelper method checkItemResultState.

private void checkItemResultState(Item item, boolean state) {
    if (item == null) {
        return;
    }
    List<IProcess2> openedProcesses = UpdateManagerUtils.getOpenedProcess();
    boolean isOpened = openedProcesses.contains(item.getResultObject().getJob());
    boolean jobletUpdate = false;
    boolean jobletContext = false;
    if (item.getParent() != null && item.getParent().getNode() != null && (item.getParent().getNode() instanceof Node) && ((Node) item.getParent().getNode()).isJoblet()) {
        jobletUpdate = true;
    }
    IUpdateItemType jobletContextType = UpdateManagerProviderDetector.INSTANCE.getUpdateItemType(UpdateManagerHelper.TYPE_JOBLET_CONTEXT);
    if (jobletContextType != null && item.getParent() != null && jobletContextType.equals(item.getParent().getType())) {
        jobletContext = true;
    }
    // not checked
    if (!state && !item.getResultObject().isReadOnly()) {
        EUpdateResult resultType = item.getResultObject().getResultType();
        if (resultType == EUpdateResult.UPDATE || resultType == EUpdateResult.ADD || resultType == EUpdateResult.DELETE) {
            item.setChecked(false);
        } else if ((jobletUpdate || jobletContext) && !isOpened && (resultType == EUpdateResult.JOBLET_UPDATE || resultType == EUpdateResult.RELOAD)) {
            item.setChecked(state);
        }
    } else if (item.getResultObject().isReadOnly() && jobletUpdate) {
        return;
    } else {
        // keep the checked
        item.setChecked(true);
    }
}
Also used : EUpdateResult(org.talend.core.model.update.EUpdateResult) Node(org.talend.designer.core.ui.editor.nodes.Node) IProcess2(org.talend.core.model.process.IProcess2) IUpdateItemType(org.talend.core.model.update.IUpdateItemType)

Aggregations

EUpdateResult (org.talend.core.model.update.EUpdateResult)3 IUpdateItemType (org.talend.core.model.update.IUpdateItemType)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 List (java.util.List)1 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)1 IContext (org.talend.core.model.process.IContext)1 INode (org.talend.core.model.process.INode)1 IProcess (org.talend.core.model.process.IProcess)1 IProcess2 (org.talend.core.model.process.IProcess2)1 EUpdateItemType (org.talend.core.model.update.EUpdateItemType)1 IEBCDICProviderService (org.talend.core.service.IEBCDICProviderService)1 Node (org.talend.designer.core.ui.editor.nodes.Node)1