use of org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem in project tmdm-studio-se by Talend.
the class RenameObjectAction method doRun.
@Override
protected void doRun() {
Object obj = getSelectedObject().get(0);
if (obj instanceof IRepositoryViewObject) {
IRepositoryViewObject viewObj = (IRepositoryViewObject) obj;
MDMServerObjectItem item = (MDMServerObjectItem) viewObj.getProperty().getItem();
MDMServerObject serverObject = item.getMDMServerObject();
IRepositoryNodeConfiguration configuration = RepositoryNodeConfigurationManager.getConfiguration(item);
if (configuration != null) {
ERepositoryObjectType type = configuration.getResourceProvider().getRepositoryObjectType(item);
IRepositoryViewObject parentViewObj = ContainerCacheService.get(type, item.getState().getPath());
try {
if (serverObject != null) {
String oldName = serverObject.getName();
String newName = showRenameDlg(type, (ContainerItem) parentViewObj.getProperty().getItem(), oldName);
if (newName != null && factory.isEditableAndLockIfPossible(item)) {
serverObject.setName(newName);
viewObj.getProperty().setLabel(newName);
viewObj.getProperty().setDisplayName(newName);
factory.save(viewObj.getProperty().getItem(), false);
MDMServerDef lastServerDef = RepositoryResourceUtil.getLastServerDef(viewObj);
if (lastServerDef != null) {
CommandManager.getInstance().pushCommand(ICommand.CMD_RENAME, viewObj.getId(), new String[] { oldName, newName });
}
}
}
commonViewer.refresh(obj);
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
} finally {
try {
factory.unlock(item);
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
} catch (LoginException e) {
log.error(e.getMessage(), e);
}
}
}
}
}
use of org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem in project tmdm-studio-se by Talend.
the class MarkNodeAsNewAction method run.
public void run(Project project) {
if (project == null) {
return;
}
List<ERepositoryObjectType> types = new ArrayList<ERepositoryObjectType>();
types.add(IServerObjectRepositoryType.TYPE_DATAMODEL);
types.add(IServerObjectRepositoryType.TYPE_CUSTOM_FORM);
types.add(IServerObjectRepositoryType.TYPE_DATACLUSTER);
types.add(IServerObjectRepositoryType.TYPE_MENU);
types.add(IServerObjectRepositoryType.TYPE_RESOURCE);
types.add(IServerObjectRepositoryType.TYPE_ROLE);
types.add(IServerObjectRepositoryType.TYPE_ROUTINGRULE);
types.add(IServerObjectRepositoryType.TYPE_STOREPROCEDURE);
types.add(IServerObjectRepositoryType.TYPE_TRANSFORMERV2);
types.add(IServerObjectRepositoryType.TYPE_VIEW);
types.add(IServerObjectRepositoryType.TYPE_WORKFLOW);
types.add(ERepositoryObjectType.PROCESS);
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
for (ERepositoryObjectType type : types) {
List<IRepositoryViewObject> objects;
try {
objects = factory.getAll(project, type);
} catch (PersistenceException e1) {
log.error(e1.getLocalizedMessage(), e1);
return;
}
if (objects != null && objects.size() > 0) {
for (IRepositoryViewObject object : objects) {
Property property = object.getProperty();
Item item = property.getItem();
boolean needRemoved = false;
MDMServerObject serverObj = null;
if (item instanceof MDMServerObjectItem) {
serverObj = ((MDMServerObjectItem) item).getMDMServerObject();
if (serverObj.getLastServerName() != null || serverObj.getLastServerDef() != null) {
needRemoved = true;
}
} else {
Object value = property.getAdditionalProperties().get(RepositoryResourceUtil.PROP_LAST_SERVER_DEF);
if (value != null) {
needRemoved = true;
}
}
if (needRemoved) {
RepositoryResourceUtil.setLastServerDef(item, null);
try {
factory.save(project, item);
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
}
}
String name = (serverObj == null || serverObj.getName() == null) ? item.getProperty().getLabel() : serverObj.getName();
// flagged as new
CommandManager.getInstance().pushCommand(ICommand.CMD_ADD, item.getProperty().getId(), name);
}
}
}
}
use of org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem 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.mdmproperties.MDMServerObjectItem in project tmdm-studio-se by Talend.
the class AbstractCommand method init.
@Override
public void init(IRepositoryViewObject viewObj) {
this.viewObject = viewObj;
this.commandId = viewObject.getId();
//
Item item = viewObj.getProperty().getItem();
if (item != null) {
if (item instanceof MDMServerObjectItem) {
objName = ((MDMServerObjectItem) item).getMDMServerObject().getName();
lastName = objName;
} else if (item instanceof ProcessItem) {
objName = viewObj.getLabel();
lastName = objName;
} else if (item instanceof MDMItem) {
objName = viewObj.getLabel();
lastName = objName;
}
}
}
use of org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem 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