Search in sources :

Example 1 with CompareResultEnum

use of org.talend.mdm.repository.core.service.ConsistencyService.CompareResultEnum in project tmdm-studio-se by Talend.

the class ConsistencyConflictDialog method getCompareResult.

private CompareResultEnum getCompareResult(IRepositoryViewObject viewObj) {
    CompareResultEnum result = compareResultMap.get(viewObj);
    if (result == null) {
        ERepositoryObjectType viewType = viewObj.getRepositoryObjectType();
        if (viewType == IServerObjectRepositoryType.TYPE_RESOURCE || viewType == IServerObjectRepositoryType.TYPE_JOB || viewType == IServerObjectRepositoryType.TYPE_WORKFLOW) {
            result = CompareResultEnum.NOT_SUPPORT;
        } else {
            WSDigest dt = viewObjMap.get(viewObj);
            if (dt == null) {
                result = CompareResultEnum.NOT_EXIST_IN_SERVER;
            } else {
                Item item = viewObj.getProperty().getItem();
                ConsistencyService service = ConsistencyService.getInstance();
                String ld = service.getLocalDigestValue(item);
                String cd = service.getCurrentDigestValue(item);
                String rd = dt.getDigestValue();
                result = service.getCompareResult(cd, ld, rd);
            }
        }
        compareResultMap.put(viewObj, result);
    }
    return result;
}
Also used : Item(org.talend.core.model.properties.Item) TreeItem(org.eclipse.swt.widgets.TreeItem) CompareResultEnum(org.talend.mdm.repository.core.service.ConsistencyService.CompareResultEnum) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) WSDigest(com.amalto.workbench.webservices.WSDigest) ConsistencyService(org.talend.mdm.repository.core.service.ConsistencyService)

Example 2 with CompareResultEnum

use of org.talend.mdm.repository.core.service.ConsistencyService.CompareResultEnum in project tmdm-studio-se by Talend.

the class ConsistencyConflictDialog method skipObjects.

protected void skipObjects(CompareResultEnum... skipEnums) {
    for (Iterator<IRepositoryViewObject> il = toDeployObjs.iterator(); il.hasNext(); ) {
        IRepositoryViewObject viewObj = il.next();
        CompareResultEnum compareResult = getCompareResult(viewObj);
        for (CompareResultEnum skipEnum : skipEnums) {
            if (compareResult == skipEnum) {
                toSkipObjs.add(viewObj);
                il.remove();
            }
        }
    }
    treeViewer.refresh();
}
Also used : IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) CompareResultEnum(org.talend.mdm.repository.core.service.ConsistencyService.CompareResultEnum)

Example 3 with CompareResultEnum

use of org.talend.mdm.repository.core.service.ConsistencyService.CompareResultEnum in project tmdm-studio-se by Talend.

the class TreeObjectCheckTreeViewer method initConsistencyData.

private Map<TreeObject, ConsistencyData> initConsistencyData(MDMServerDef serverDef, List<TreeObject> treeObjs) {
    Map<TreeObject, ConsistencyData> map = new HashMap<TreeObject, ConsistencyData>();
    try {
        ConsistencyService consistencyService = ConsistencyService.getInstance();
        Map<TreeObject, WSDigest> serverDigestValues = consistencyService.queryServerDigestValue(serverDef, treeObjs);
        if (treeObjs.size() > 0 && serverDigestValues.isEmpty()) {
            return map;
        }
        for (TreeObject treeObject : treeObjs) {
            ConsistencyData consistencyData = new ConsistencyData();
            WSDigest serverDigestTime = serverDigestValues.get(treeObject);
            consistencyData.setServerDigestTime(serverDigestTime);
            String objName = getTreeObjectName(treeObject);
            ERepositoryObjectType viewType = RepositoryQueryService.getRepositoryObjectType(treeObject.getType());
            if (viewType == null) {
                continue;
            }
            if (viewType == IServerObjectRepositoryType.TYPE_RESOURCE || viewType == IServerObjectRepositoryType.TYPE_JOB || viewType == IServerObjectRepositoryType.TYPE_WORKFLOW) {
                consistencyData.setCompareResult(CompareResultEnum.NOT_SUPPORT);
            } else {
                IRepositoryViewObject viewObj = RepositoryResourceUtil.findViewObjectByName(viewType, objName);
                if (viewObj == null) {
                    consistencyData.setCompareResult(CompareResultEnum.NOT_EXIST_IN_LOCAL);
                } else {
                    consistencyService.updateCurrentDigestValue(viewObj);
                    Item item = viewObj.getProperty().getItem();
                    String ld = consistencyService.getLocalDigestValue(item);
                    String cd = consistencyService.getCurrentDigestValue(item);
                    long localTimestamp = consistencyService.getLocalTimestamp(item);
                    // key
                    String type = viewObj.getRepositoryObjectType().getKey();
                    String objectName = viewObj.getLabel();
                    WSDigestKey key = new WSDigestKey(objectName, type);
                    consistencyData.setLocalDigestTime(new WSDigest(ld, localTimestamp, key));
                    // init compare result;
                    CompareResultEnum result;
                    if (serverDigestTime == null || serverDigestTime.getDigestValue() == null) {
                        result = CompareResultEnum.NOT_EXIST_IN_SERVER;
                    } else {
                        String rd = serverDigestTime.getDigestValue();
                        result = consistencyService.getCompareResult(cd, ld, rd);
                    }
                    consistencyData.setCompareResult(result);
                }
            }
            map.put(treeObject, consistencyData);
        }
    } catch (WebServiceException e) {
        log.error(e.getMessage(), e);
    } catch (XtentisException e) {
        log.error(e.getMessage(), e);
    }
    return map;
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) HashMap(java.util.HashMap) WSDigestKey(com.amalto.workbench.webservices.WSDigestKey) WSDigest(com.amalto.workbench.webservices.WSDigest) ConsistencyService(org.talend.mdm.repository.core.service.ConsistencyService) Item(org.talend.core.model.properties.Item) TreeItem(org.eclipse.swt.widgets.TreeItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TreeObject(com.amalto.workbench.models.TreeObject) CompareResultEnum(org.talend.mdm.repository.core.service.ConsistencyService.CompareResultEnum) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) ConsistencyData(org.talend.mdm.repository.core.service.ConsistencyService.ConsistencyData) XtentisException(com.amalto.workbench.utils.XtentisException)

Example 4 with CompareResultEnum

use of org.talend.mdm.repository.core.service.ConsistencyService.CompareResultEnum in project tmdm-studio-se by Talend.

the class RepositoryViewObjectCheckedWidget method selectObjects.

public void selectObjects(CheckHandler checkHandler) {
    for (IRepositoryViewObject viewObj : consistencyMap.keySet()) {
        ConsistencyData consistencyData = consistencyMap.get(viewObj);
        if (consistencyData != null) {
            CompareResultEnum compareResult = consistencyData.getCompareResult();
            checkHandler.handle(compareResult, viewObj);
        }
    }
}
Also used : IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) CompareResultEnum(org.talend.mdm.repository.core.service.ConsistencyService.CompareResultEnum) ConsistencyData(org.talend.mdm.repository.core.service.ConsistencyService.ConsistencyData)

Example 5 with CompareResultEnum

use of org.talend.mdm.repository.core.service.ConsistencyService.CompareResultEnum in project tmdm-studio-se by Talend.

the class ConsistencyConflictDialog method initOperations.

private void initOperations() {
    for (IRepositoryViewObject viewObj : viewObjMap.keySet()) {
        boolean isDeletedOp = false;
        Integer cmdOp = viewObCmdOpjMap.get(viewObj);
        if (cmdOp != null) {
            isDeletedOp = cmdOp == ICommand.CMD_DELETE;
        }
        CompareResultEnum compareResult = getCompareResult(viewObj);
        if (isDeletedOp) {
            if (compareResult == CompareResultEnum.SAME || compareResult == CompareResultEnum.MODIFIED_LOCALLY) {
                toDeployObjs.add(viewObj);
            } else {
                toSkipObjs.add(viewObj);
            }
        } else {
            if (compareResult == CompareResultEnum.SAME) {
                toSkipObjs.add(viewObj);
            } else {
                toDeployObjs.add(viewObj);
            }
        }
    }
}
Also used : IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) CompareResultEnum(org.talend.mdm.repository.core.service.ConsistencyService.CompareResultEnum)

Aggregations

CompareResultEnum (org.talend.mdm.repository.core.service.ConsistencyService.CompareResultEnum)6 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)5 WSDigest (com.amalto.workbench.webservices.WSDigest)3 TreeItem (org.eclipse.swt.widgets.TreeItem)3 Item (org.talend.core.model.properties.Item)3 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)3 ConsistencyService (org.talend.mdm.repository.core.service.ConsistencyService)3 ConsistencyData (org.talend.mdm.repository.core.service.ConsistencyService.ConsistencyData)3 XtentisException (com.amalto.workbench.utils.XtentisException)2 WSDigestKey (com.amalto.workbench.webservices.WSDigestKey)2 WebServiceException (javax.xml.ws.WebServiceException)2 TreeObject (com.amalto.workbench.models.TreeObject)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ContainerItem (org.talend.mdm.repository.model.mdmproperties.ContainerItem)1