use of org.talend.mdm.repository.model.mdmserverobject.MDMServerObject in project tmdm-studio-se by Talend.
the class RenameViewAction method renameViewObject.
private void renameViewObject(IRepositoryViewObject viewObj) {
MDMServerObjectItem item = (MDMServerObjectItem) viewObj.getProperty().getItem();
MDMServerObject serverObject = item.getMDMServerObject();
IProxyRepositoryFactory factory = getFactory();
try {
if (serverObject != null) {
String oldName = serverObject.getName();
RenameViewDialog dialog = getRenameDialog(oldName);
int returnCode = dialog.open();
if (returnCode == IDialogConstants.OK_ID) {
String newName = dialog.getValue();
if (RepositoryTransformUtil.getInstance().getViewType(oldName) == TYPE_WEBFILTER) {
newName = PREFIX_VIEW_UPPER + newName;
} else {
if (newName.startsWith(PREFIX_VIEW_UPPER)) {
viewTypeChanged = true;
item.getState().setPath(IPath.SEPARATOR + PATH_WEBFILTER);
}
}
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(viewObj);
}
}
} 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.mdmserverobject.MDMServerObject in project tmdm-studio-se by Talend.
the class AbstractLabelProvider method getServerObjectItemText.
protected String getServerObjectItemText(Item item) {
item = RepositoryResourceUtil.assertItem(item);
MDMServerObject serverObject = ((MDMServerObjectItem) item).getMDMServerObject();
if (serverObject != null) {
return serverObject.getName();
}
return null;
}
use of org.talend.mdm.repository.model.mdmserverobject.MDMServerObject in project tmdm-studio-se by Talend.
the class RepositoryNodeActionProviderAdapter method getOpenEditorInput.
/**
* The child class can override this method, current implement is adapt to most of MDMServerobject
*/
@Override
public IRepositoryViewEditorInput getOpenEditorInput(IRepositoryViewObject viewObj) {
Item item = viewObj.getProperty().getItem();
MDMServerObject serverObject = ((MDMServerObjectItem) item).getMDMServerObject();
if (serverObject.getType() == TreeObject.DATA_CLUSTER) {
// Data Cluster
return new XObjectBrowserInput2(viewObj);
}
return new XObjectEditorInput2(viewObj);
}
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, Object wsObj) {
if (eobj instanceof MDMServerObject) {
MDMServerObject serverObject = (MDMServerObject) eobj;
TreeObject treeObj = new TreeObject(serverObject.getName(), null, serverObject.getType(), serverObject.getName(), wsObj);
return treeObj;
}
return null;
}
use of org.talend.mdm.repository.model.mdmserverobject.MDMServerObject in project tmdm-studio-se by Talend.
the class ImportServerObjectWizard method doImport.
public List<String> doImport(Object[] objs, IProgressMonitor monitor) {
monitor.beginTask(Messages.Import_Objects, objs.length);
List<String> importedIds = new LinkedList<String>();
ImportService.setImporting(true);
List<Integer> types = new ArrayList<Integer>();
types.add(TreeObject.CUSTOM_FORM);
types.add(TreeObject.DATA_CLUSTER);
types.add(TreeObject.DATA_MODEL);
types.add(TreeObject.TRANSFORMER);
types.add(TreeObject.ROUTING_RULE);
types.add(TreeObject.MENU);
types.add(TreeObject.ROLE);
types.add(TreeObject.STORED_PROCEDURE);
types.add(TreeObject.VIEW);
types.add(TreeObject.WORKFLOW_PROCESS);
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
for (Object obj : objs) {
try {
TreeObject treeObj = (TreeObject) obj;
monitor.subTask(treeObj.getDisplayName());
String treeObjName = treeObj.getName();
MDMServerObject eobj = handleSpecialTreeObject(treeObj);
if (treeObj.getType() == TreeObject.WORKFLOW_PROCESS) {
continue;
}
if (eobj == null) {
if (!types.contains(treeObj.getType()) || treeObj.getWsObject() == null || ("JCAAdapers".equals(treeObj.getName()) && treeObj.getType() == TreeObject.DATA_CLUSTER)) {
// $NON-NLS-1$
continue;
}
eobj = (MDMServerObject) Bean2EObjUtil.getInstance().convertFromBean2EObj(treeObj.getWsObject(), null);
}
eobj.setLastServerName(serverDef.getName());
ERepositoryObjectType type = RepositoryQueryService.getRepositoryObjectType(treeObj.getType());
String uniqueName = getUniqueName(treeObj, treeObjName);
MDMServerObjectItem item = RepositoryQueryService.findServerObjectItemByNameWithDeleted(type, uniqueName, true);
if (item != null) {
if (!isOverrideAll) {
int result = isOveride(treeObj.getName(), TreeObject.getTypeName(treeObj.getType()));
if (result == IDialogConstants.CANCEL_ID) {
ImportService.setImporting(false);
return importedIds;
}
if (result == IDialogConstants.YES_TO_ALL_ID) {
isOverrideAll = true;
}
if (result == IDialogConstants.NO_ID) {
break;
}
}
if (!RepositoryResourceUtil.isLockedItem(item)) {
try {
factory.lock(item);
} catch (PersistenceException e1) {
log.error(e1.getMessage(), e1);
} catch (LoginException e1) {
log.error(e1.getMessage(), e1);
}
item.setMDMServerObject(eobj);
item.getState().setDeleted(false);
// save
RepositoryResourceUtil.saveItem(item, false);
try {
factory.unlock(item);
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
} catch (LoginException e) {
log.error(e.getMessage(), e);
}
importedIds.add(item.getProperty().getId());
}
CommandManager.getInstance().removeCommandStack(item.getProperty().getId());
} else {
IRepositoryNodeConfiguration config = RepositoryNodeConfigurationManager.getConfiguration(type);
item = (MDMServerObjectItem) config.getResourceProvider().createNewItem(type);
item.setMDMServerObject(eobj);
ItemState itemState = PropertiesFactory.eINSTANCE.createItemState();
itemState.setPath(caculatePath(treeObj));
handlePath(itemState, type);
item.setState(itemState);
String version = getVersion(treeObj);
if (RepositoryResourceUtil.createItem(item, uniqueName, version, false, false)) {
importedIds.add(item.getProperty().getId());
}
}
} catch (IOException e) {
log.error(e.getMessage(), e);
}
monitor.worked(1);
}
ImportService.setImporting(false);
monitor.done();
return importedIds;
}
Aggregations