use of org.talend.mdm.repository.model.mdmserverobject.MDMServerObject in project tmdm-studio-se by Talend.
the class RepositoryDropAssistant method copyViewObj.
public boolean copyViewObj(IRepositoryViewObject dragViewObj, IRepositoryViewObject dropViewObj) {
if (dropViewObj != null && dragViewObj != null) {
Property dragProp = dragViewObj.getProperty();
Property dropProp = dropViewObj.getProperty();
Item item = dragProp.getItem();
String name;
if (item instanceof MDMServerObjectItem) {
MDMServerObject serverObj = ((MDMServerObjectItem) item).getMDMServerObject();
name = serverObj.getName();
} else {
name = dragProp.getLabel();
}
// show dialog
IRepositoryViewObject dragParentViewObj = getParentRepositoryViewObject(dragViewObj);
ContainerItem dragParentItem = (ContainerItem) dragParentViewObj.getProperty().getItem();
// $NON-NLS-1$
String newName = showPasteDlg(dragParentItem.getRepObjType(), dragParentItem, "Copy_" + name);
if (newName != null) {
String pathStr = dropProp.getItem().getState().getPath();
pathStr = rebuildPath(dragViewObj, name, newName, pathStr);
IPath path = new Path(pathStr);
ERepositoryObjectType type = dropViewObj.getRepositoryObjectType();
if (type == IServerObjectRepositoryType.TYPE_WORKFLOW) {
if (exAdapter != null) {
return exAdapter.copyWorkflowViewObj(item, name, newName);
}
} else {
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
Item copy = null;
try {
copy = factory.copy(item, path, true);
if (factory.isEditableAndLockIfPossible(copy)) {
if (copy instanceof MDMServerObjectItem) {
((MDMServerObjectItem) copy).getMDMServerObject().setName(newName);
((MDMServerObjectItem) copy).getMDMServerObject().setLastServerDef(null);
CommandManager.getInstance().pushCommand(ICommand.CMD_ADD, copy.getProperty().getId(), newName);
}
copy.getProperty().setLabel(newName);
copy.getProperty().setDisplayName(newName);
RepositoryResourceUtil.setLastServerDef(copy, null);
factory.save(copy);
MDMRepositoryView.show().refreshRootNode(type);
return true;
}
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
} catch (BusinessException e) {
log.error(e.getMessage(), e);
} finally {
try {
factory.unlock(copy);
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
} catch (LoginException e) {
log.error(e.getMessage(), e);
}
}
}
}
}
return false;
}
use of org.talend.mdm.repository.model.mdmserverobject.MDMServerObject in project tmdm-studio-se by Talend.
the class RepositoryResourceUtil method findAllServerObjects.
public static List<MDMServerObject> findAllServerObjects(ERepositoryObjectType type) {
List<IRepositoryViewObject> viewObjects = RepositoryResourceUtil.findAllViewObjects(type);
List<MDMServerObject> serverObjects = new LinkedList<MDMServerObject>();
if (viewObjects != null) {
for (IRepositoryViewObject viewObj : viewObjects) {
Item item = viewObj.getProperty().getItem();
if (item instanceof MDMServerObjectItem) {
serverObjects.add(((MDMServerObjectItem) item).getMDMServerObject());
}
}
}
return serverObjects;
}
Aggregations