use of org.talend.mdm.repository.core.IRepositoryNodeConfiguration in project tmdm-studio-se by Talend.
the class RepositoryViewObjectCheckedWidget method initInput.
/**
* DOC hbhong Comment method "initInput".
*
* @param type
* @return
*/
private IRepositoryViewObject[] initInput(ERepositoryObjectType type) {
if (type != null) {
IRepositoryViewObject[] elements = RepositoryResourceUtil.getCategoryViewObjects(type);
List<IRepositoryViewObject> objs = new ArrayList<IRepositoryViewObject>();
objs.addAll(Arrays.asList(elements));
// missing transformer2, routingrule
if (type.getKey().equals(IServerObjectRepositoryType.TYPE_TRANSFORMERV2.getKey()) || type.getKey().equals(IServerObjectRepositoryType.TYPE_ROUTINGRULE.getKey())) {
IRepositoryNodeConfiguration typeConf = RepositoryNodeConfigurationManager.getConfiguration(type);
addCategoryViewObject(objs, typeConf);
}
if (type.getKey().equals(IServerObjectRepositoryType.TYPE_EVENTMANAGER.getKey())) {
IRepositoryNodeConfiguration processConf = RepositoryNodeConfigurationManager.getConfiguration(IServerObjectRepositoryType.TYPE_TRANSFORMERV2);
IRepositoryNodeConfiguration triggerConf = RepositoryNodeConfigurationManager.getConfiguration(IServerObjectRepositoryType.TYPE_ROUTINGRULE);
addCategoryViewObject(objs, processConf);
addCategoryViewObject(objs, triggerConf);
}
return objs.toArray(new IRepositoryViewObject[0]);
} else {
IRepositoryViewObject[] elements = RepositoryResourceUtil.getCategoryViewObjects();
List<IRepositoryViewObject> objs = new ArrayList<IRepositoryViewObject>();
for (IRepositoryViewObject folderObj : elements) {
ERepositoryObjectType objType = folderObj.getRepositoryObjectType();
if (objType == IServerObjectRepositoryType.TYPE_EVENTMANAGER) {
IRepositoryNodeConfiguration processConf = RepositoryNodeConfigurationManager.getConfiguration(IServerObjectRepositoryType.TYPE_TRANSFORMERV2);
IRepositoryNodeConfiguration triggerConf = RepositoryNodeConfigurationManager.getConfiguration(IServerObjectRepositoryType.TYPE_ROUTINGRULE);
addCategoryViewObject(objs, processConf);
addCategoryViewObject(objs, triggerConf);
} else if (objType != IServerObjectRepositoryType.TYPE_MATCH_RULE) {
objs.add(folderObj);
}
}
Collections.sort(objs, new Comparator() {
public int compare(Object o1, Object o2) {
String name1 = ((IRepositoryViewObject) o1).getRepositoryObjectType().getLabel();
String name2 = ((IRepositoryViewObject) o2).getRepositoryObjectType().getLabel();
return name1.compareTo(name2);
}
});
return objs.toArray(new IRepositoryViewObject[0]);
}
}
use of org.talend.mdm.repository.core.IRepositoryNodeConfiguration in project tmdm-studio-se by Talend.
the class OpenObjectAction method openItem.
private void openItem(IRepositoryViewObject viewObject) {
Item item = viewObject.getProperty().getItem();
item = RepositoryResourceUtil.assertItem(item);
IRepositoryNodeConfiguration configuration = RepositoryNodeConfigurationManager.getConfiguration(item);
if (configuration != null) {
IRepositoryNodeActionProvider actionProvider = configuration.getActionProvider();
if (actionProvider != null) {
IRepositoryViewEditorInput editorInput = actionProvider.getOpenEditorInput(viewObject);
if (editorInput != null) {
if (page == null) {
this.page = getCommonViewer().getCommonNavigator().getSite().getWorkbenchWindow().getActivePage();
}
// do extra action
MDMServerObject serverObject = ((MDMServerObjectItem) item).getMDMServerObject();
if (!checkMissingJar(serverObject)) {
return;
}
boolean selected = doSelectServer(item, editorInput);
if (!selected) {
return;
}
try {
// svn lock
ERepositoryStatus status = factory.getStatus(item);
boolean isEditable = factory.isEditableAndLockIfPossible(item);
if (isEditable) {
getCommonViewer().refresh(viewObject);
}
//
editorInput.setReadOnly(status == ERepositoryStatus.LOCK_BY_OTHER || status == ERepositoryStatus.READ_ONLY || !isEditable);
if (!editorInput.isReadOnly()) {
editorInput.setReadOnly(item.getState().isDeleted());
}
updateEditorInputVersionInfo(editorInput, viewObject);
activeEditor = this.page.openEditor(editorInput, editorInput.getEditorId());
if (marker != null) {
IDE.gotoMarker(activeEditor, marker);
}
} catch (PartInitException e) {
log.error(e.getMessage(), e);
}
} else {
AbstractRepositoryAction openAction = actionProvider.getOpenAction(viewObject);
if (openAction != null) {
openAction.selectionChanged(getStructuredSelection());
openAction.run();
}
}
}
}
}
use of org.talend.mdm.repository.core.IRepositoryNodeConfiguration 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.core.IRepositoryNodeConfiguration in project tmdm-studio-se by Talend.
the class RepositoryResourceUtil method saveItem.
public static void saveItem(Item item, boolean triggerEvent) {
IRepositoryNodeConfiguration configuration = RepositoryNodeConfigurationManager.getConfiguration(item);
if (configuration != null) {
IRepositoryNodeResourceProvider resourceProvider = configuration.getResourceProvider();
if (resourceProvider.needSaveReferenceFile()) {
item = assertItem(item);
resourceProvider.handleReferenceFile(item);
}
// save
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
try {
item = assertItem(item);
factory.save(item, !triggerEvent);
} catch (PersistenceException e) {
log.error(e);
}
}
}
Aggregations