use of org.talend.mdm.repository.model.mdmserverobject.MDMServerObject in project tmdm-studio-se by Talend.
the class ConsistencyService method calculateDigestValueByObjectResource.
private String calculateDigestValueByObjectResource(Item item) {
EObject copy = null;
if (item instanceof ProcessItem) {
copy = EcoreUtil.copy(((ProcessItem) item).getProcess());
} else if (item instanceof MDMServerObjectItem) {
MDMServerObject mdmServerObject = ((MDMServerObjectItem) item).getMDMServerObject();
copy = EcoreUtil.copy(mdmServerObject);
// remove server def property
MDMServerObject copiedMdmObj = (MDMServerObject) copy;
copiedMdmObj.setLastServerDef(null);
copiedMdmObj.setLastServerName(null);
copiedMdmObj.setCurrentDigestValue(null);
copiedMdmObj.setDigestValue(null);
// restore the timestamp to default
copiedMdmObj.setTimestamp(0L);
} else {
// unsupport to caculate object md5 which not belong to MDM
throw new UnsupportedOperationException();
}
if (copy != null) {
//
Resource resource = new SortResourceImpl();
resource.getContents().add(copy);
return calculateDigestValueByEMFResource(resource);
}
return null;
}
use of org.talend.mdm.repository.model.mdmserverobject.MDMServerObject in project tmdm-studio-se by Talend.
the class RepositoryResourceUtil method getLastServerDef.
/**
* @param item
* @return A decrypted serverDef
*/
public static MDMServerDef getLastServerDef(Item item) {
if (item != null) {
if (item instanceof MDMServerObjectItem) {
MDMServerObject mdmServerObject = ((MDMServerObjectItem) item).getMDMServerObject();
String lastServerName = mdmServerObject.getLastServerName();
if (lastServerName == null) {
MDMServerDef lastServerDef = mdmServerObject.getLastServerDef();
if (lastServerDef != null) {
lastServerName = lastServerDef.getName();
}
}
if (lastServerName != null) {
return ServerDefService.findServerDefByName(lastServerName);
}
} else {
Property property = item.getProperty();
if (property != null) {
Object value = property.getAdditionalProperties().get(PROP_LAST_SERVER_DEF);
if (value != null) {
return ServerDefService.findServerDefByName((String) value);
}
}
}
}
return null;
}
use of org.talend.mdm.repository.model.mdmserverobject.MDMServerObject in project tmdm-studio-se by Talend.
the class RepositoryResourceUtil method setLastServerDef.
/**
* @param item
* @param def need A decrypted serverDef
*/
@SuppressWarnings("unchecked")
public static void setLastServerDef(Item item, MDMServerDef def) {
if (item == null) {
return;
}
if (item instanceof MDMServerObjectItem) {
MDMServerObject mdmServerObject = ((MDMServerObjectItem) item).getMDMServerObject();
mdmServerObject.setLastServerName(def != null ? def.getName() : null);
// Not use lastServerDef property any more
mdmServerObject.setLastServerDef(null);
return;
}
Property property = item.getProperty();
if (property != null) {
if (def != null) {
property.getAdditionalProperties().put(PROP_LAST_SERVER_DEF, def.getName());
} else {
property.getAdditionalProperties().remove(PROP_LAST_SERVER_DEF);
}
}
}
use of org.talend.mdm.repository.model.mdmserverobject.MDMServerObject in project tmdm-studio-se by Talend.
the class Bean2EObjUtil method wrapEObjWithTreeObject.
public TreeObject wrapEObjWithTreeObject(EObject eobj) {
if (eobj instanceof MDMServerObject) {
MDMServerObject serverObject = (MDMServerObject) eobj;
Object wsObj = convertFromEObj2Bean(eobj);
return wrapEObjWithTreeObject(eobj, wsObj);
}
return null;
}
use of org.talend.mdm.repository.model.mdmserverobject.MDMServerObject in project tmdm-studio-se by Talend.
the class CommonMdmImportHandler method update.
protected void update(IRepositoryViewObject object, ImportItem selectedImportItem) throws PersistenceException {
Property property = object.getProperty();
Item item = property.getItem();
boolean needSave = false;
if (item instanceof MDMServerObjectItem) {
MDMServerObject serverObj = ((MDMServerObjectItem) item).getMDMServerObject();
if (serverObj.getLastServerName() != null) {
serverObj.setLastServerName(null);
needSave = true;
}
if (serverObj.getLastServerDef() != null) {
serverObj.setLastServerDef(null);
needSave = true;
}
} else {
EMap<?, ?> additionalProperties = property.getAdditionalProperties();
if (additionalProperties != null) {
additionalProperties.remove(RepositoryResourceUtil.PROP_LAST_SERVER_DEF);
needSave = true;
}
}
if (needSave) {
factory.save(item, true);
}
if (selectedImportItem.isValid()) {
// $NON-NLS-1$
String[] split = selectedImportItem.getLabel().split(" ");
String name = split.length > 0 ? split[0] : null;
if (name != null) {
CommandManager.getInstance().pushCommand(ICommand.CMD_ADD, selectedImportItem.getItemId(), name);
}
}
// update cache
ContainerCacheService.put(object);
}
Aggregations