use of com.amalto.workbench.webservices.WSDigestKey in project tmdm-studio-se by Talend.
the class ConsistencyService method queryServerDigestValue.
public <T> Map<T, WSDigest> queryServerDigestValue(MDMServerDef serverDef, Collection<T> objs) throws XtentisException {
Map<T, WSDigest> result = new LinkedHashMap<T, WSDigest>();
TMDMService service = RepositoryWebServiceAdapter.getMDMService(serverDef);
if (isSupportConsistency(service)) {
for (T obj : objs) {
String type = null;
String objectName = null;
if (obj instanceof IRepositoryViewObject) {
IRepositoryViewObject viewObj = (IRepositoryViewObject) obj;
type = viewObj.getRepositoryObjectType().getKey();
objectName = viewObj.getLabel();
} else if (obj instanceof TreeObject) {
TreeObject treeObj = (TreeObject) obj;
ERepositoryObjectType repositoryObjectType = RepositoryQueryService.getRepositoryObjectType(treeObj.getType());
if (repositoryObjectType != null) {
type = repositoryObjectType.getKey();
objectName = getObjectName(treeObj);
}
}
if (type != null && objectName != null) {
WSDigest digest = service.getDigest(new WSDigestKey(objectName, type));
result.put(obj, digest);
}
}
}
return result;
}
use of com.amalto.workbench.webservices.WSDigestKey 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;
}
use of com.amalto.workbench.webservices.WSDigestKey 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);
}
}
}
use of com.amalto.workbench.webservices.WSDigestKey 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;
}
Aggregations