Search in sources :

Example 6 with WSDigest

use of com.amalto.workbench.webservices.WSDigest in project tmdm-studio-se by Talend.

the class ConsistencyService method getCheckResultByStrategy.

private ConsistencyCheckResult getCheckResultByStrategy(int strategy, Map<IRepositoryViewObject, WSDigest> viewObjMap, Map<IRepositoryViewObject, Integer> viewObCmdOpjMap) {
    List<IRepositoryViewObject> toDeployObjs = new LinkedList<IRepositoryViewObject>();
    List<IRepositoryViewObject> toSkipObjs = new LinkedList<IRepositoryViewObject>();
    for (IRepositoryViewObject viewObj : viewObjMap.keySet()) {
        WSDigest dt = viewObjMap.get(viewObj);
        if (dt == null) {
            toDeployObjs.add(viewObj);
        } else {
            Item item = viewObj.getProperty().getItem();
            String ld = getLocalDigestValue(item);
            String rd = dt.getDigestValue();
            String cd = getCurrentDigestValue(item);
            CompareResultEnum result = getCompareResult(cd, ld, rd);
            // update isDeleteOp
            boolean isDeletedOp = false;
            Integer cmdOp = viewObCmdOpjMap.get(viewObj);
            if (cmdOp != null) {
                isDeletedOp = cmdOp == ICommand.CMD_DELETE;
            }
            // 
            if (result == CompareResultEnum.SAME) {
                if (strategy == CONFLICT_STRATEGY_DEFAULT || strategy == CONFLICT_STRATEGY_SKIP_DIFFERENCE) {
                    if (isDeletedOp) {
                        toDeployObjs.add(viewObj);
                    } else {
                        toSkipObjs.add(viewObj);
                    }
                } else if (strategy == CONFLICT_STRATEGY_OVERWRITE) {
                    toDeployObjs.add(viewObj);
                }
            } else if (result == CompareResultEnum.CONFLICT || result == CompareResultEnum.MODIFIED_LOCALLY || result == CompareResultEnum.POTENTIAL_CONFLICT) {
                if (strategy == CONFLICT_STRATEGY_SKIP_DIFFERENCE) {
                    toSkipObjs.add(viewObj);
                } else if (strategy == CONFLICT_STRATEGY_DEFAULT || strategy == CONFLICT_STRATEGY_OVERWRITE) {
                    toDeployObjs.add(viewObj);
                }
            }
        }
    }
    return new ConsistencyCheckResult(toDeployObjs, toSkipObjs);
}
Also used : ReferenceFileItem(org.talend.core.model.properties.ReferenceFileItem) Item(org.talend.core.model.properties.Item) ProcessItem(org.talend.core.model.properties.ProcessItem) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) WSDigest(com.amalto.workbench.webservices.WSDigest) LinkedList(java.util.LinkedList)

Example 7 with WSDigest

use of com.amalto.workbench.webservices.WSDigest in project tmdm-studio-se by Talend.

the class ConsistencyService method updateDigestValue.

public void updateDigestValue(MDMServerDef serverDef, IRepositoryViewObject viewObj) throws XtentisException {
    Item item = viewObj.getProperty().getItem();
    if (item instanceof MDMServerObjectItem) {
        TMDMService service = RepositoryWebServiceAdapter.getMDMService(serverDef);
        updateLocalDigestValue(viewObj);
        // key
        String type = viewObj.getRepositoryObjectType().getKey();
        String objectName = getObjectName(viewObj);
        WSDigestKey key = new WSDigestKey(objectName, type);
        // value
        WSDigest value = new WSDigest(getLocalDigestValue(item), 0L, key);
        WSLong timeValue = service.updateDigest(value);
        // 
        if (timeValue != null) {
            updateLocalTimestamp(item, timeValue.getValue());
        }
        if (!viewObj.getRepositoryObjectType().equals(IServerObjectRepositoryType.TYPE_MATCH_RULE_MAPINFO)) {
            item = RepositoryResourceUtil.assertItem(item);
            Property property = item.getProperty();
            boolean eDeliver = property.eDeliver();
            property.eSetDeliver(false);
            RepositoryResourceUtil.saveItem(item);
            property.eSetDeliver(eDeliver);
        }
    }
}
Also used : ReferenceFileItem(org.talend.core.model.properties.ReferenceFileItem) Item(org.talend.core.model.properties.Item) ProcessItem(org.talend.core.model.properties.ProcessItem) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) WSLong(com.amalto.workbench.webservices.WSLong) TMDMService(com.amalto.workbench.webservices.TMDMService) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) WSDigestKey(com.amalto.workbench.webservices.WSDigestKey) WSDigest(com.amalto.workbench.webservices.WSDigest) Property(org.talend.core.model.properties.Property)

Example 8 with WSDigest

use of com.amalto.workbench.webservices.WSDigest in project tmdm-studio-se by Talend.

the class RepositoryViewObjectCheckedWidget method getConsistencyData.

private synchronized ConsistencyData getConsistencyData(MDMServerDef serverDef, IRepositoryViewObject viewObj) {
    if (!isServerOk) {
        return null;
    }
    ConsistencyData consistencyData = consistencyMap.get(viewObj);
    if (consistencyData != null) {
        return consistencyData;
    }
    try {
        ConsistencyService consistencyService = ConsistencyService.getInstance();
        consistencyData = new ConsistencyData();
        ERepositoryObjectType viewType = viewObj.getRepositoryObjectType();
        if (viewType == null) {
            return null;
        }
        if (viewType == IServerObjectRepositoryType.TYPE_RESOURCE || viewType == IServerObjectRepositoryType.TYPE_JOB || viewType == IServerObjectRepositoryType.TYPE_WORKFLOW) {
            consistencyData.setCompareResult(CompareResultEnum.NOT_SUPPORT);
        } else {
            List<IRepositoryViewObject> viewObjs = new ArrayList<IRepositoryViewObject>();
            viewObjs.add(viewObj);
            Map<IRepositoryViewObject, WSDigest> digestValueResult = consistencyService.queryServerDigestValue(serverDef, viewObjs);
            WSDigest serverDigestTime = digestValueResult.get(viewObj);
            consistencyData.setServerDigestTime(serverDigestTime);
            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);
        }
        consistencyMap.put(viewObj, consistencyData);
    } catch (WebServiceException e) {
        log.error(e.getMessage(), e);
    } catch (XtentisException e) {
        log.error(e.getMessage(), e);
    }
    return consistencyData;
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) ArrayList(java.util.ArrayList) 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) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) TreeItem(org.eclipse.swt.widgets.TreeItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) 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)

Aggregations

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