use of org.talend.mdm.repository.model.mdmproperties.ContainerItem in project tmdm-studio-se by Talend.
the class RemoveFromRepositoryAction method removeFolderObject.
private void removeFolderObject(IRepositoryViewObject viewObj) {
if (removed.contains(viewObj.getId())) {
return;
}
for (IRepositoryViewObject childObj : viewObj.getChildren()) {
if (childObj instanceof FolderRepositoryObject) {
removeFolderObject(childObj);
} else {
removeServerObject(childObj);
}
}
removed.add(viewObj.getId());
//
ContainerItem containerItem = (ContainerItem) viewObj.getProperty().getItem();
String path = containerItem.getState().getPath();
ERepositoryObjectType repObjType = containerItem.getRepObjType();
ContainerCacheService.removeContainer(repObjType, path);
FolderItem folderItem = factory.getFolderItem(ProjectManager.getInstance().getCurrentProject(), repObjType, new Path(path));
folderItem.getState().setDeleted(true);
}
use of org.talend.mdm.repository.model.mdmproperties.ContainerItem in project tmdm-studio-se by Talend.
the class RepositoryDropAssistant method validate.
public boolean validate(int operation, IRepositoryViewObject dragViewObj, IRepositoryViewObject dropViewObj) {
if (dragViewObj == null || dropViewObj == null) {
return false;
}
//
if (dragViewObj instanceof FolderRepositoryObject) {
return false;
}
ERepositoryObjectType dragType = dragViewObj.getRepositoryObjectType();
// can't support job object
if (dragType == ERepositoryObjectType.PROCESS) {
return false;
}
if (dropViewObj instanceof FolderRepositoryObject) {
if (((ContainerItem) dropViewObj.getProperty().getItem()).getType().getValue() == FolderType.STABLE_SYSTEM_FOLDER) {
return false;
}
} else {
return false;
}
// can't move to self folder
if (operation == DND.DROP_MOVE) {
IRepositoryViewObject dragParent = getParentRepositoryViewObject(dragViewObj);
if (dragParent.equals(dropViewObj)) {
return false;
}
}
// can't move/copy to different node folder
ERepositoryObjectType dropType = dropViewObj.getRepositoryObjectType();
if (dragType != null && !dragType.equals(dropType)) {
return false;
}
if (dragType == IServerObjectRepositoryType.TYPE_VIEW) {
boolean viewValid = validateForView(dragViewObj, dropViewObj);
return viewValid;
}
if (dragType == IServerObjectRepositoryType.TYPE_TRANSFORMERV2) {
boolean processValid = validateForProcess(dragViewObj, dropViewObj);
return processValid;
}
return true;
}
use of org.talend.mdm.repository.model.mdmproperties.ContainerItem 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.ContainerItem in project tmdm-studio-se by Talend.
the class RepositoryResourceUtil method createDeletedFolderViewObject.
public static FolderRepositoryObject createDeletedFolderViewObject(ERepositoryObjectType type, String path, String folderName, FolderRepositoryObject parentConObj) {
Property prop = PropertiesFactory.eINSTANCE.createProperty();
prop.setId(EcoreUtil.generateUUID());
//
ContainerItem item = MdmpropertiesFactory.eINSTANCE.createContainerItem();
item.setType(FolderType.FOLDER_LITERAL);
item.setLabel(folderName);
item.setRepObjType(type);
ItemState itemState = PropertiesFactory.eINSTANCE.createItemState();
itemState.setPath(path);
item.setState(itemState);
//
prop.setItem(item);
prop.setLabel(folderName);
itemState.setDeleted(true);
FolderRepositoryObject containerRepositoryObject = new FolderRepositoryObject(prop);
// update cache
ContainerCacheService.putContainer(containerRepositoryObject);
//
parentConObj.getChildren().add(containerRepositoryObject);
return containerRepositoryObject;
}
use of org.talend.mdm.repository.model.mdmproperties.ContainerItem in project tmdm-studio-se by Talend.
the class RepositoryResourceUtil method getCategoryViewObject.
public static IRepositoryViewObject getCategoryViewObject(IRepositoryNodeConfiguration conf) {
Property prop = PropertiesFactory.eINSTANCE.createProperty();
prop.setId(EcoreUtil.generateUUID());
//
ContainerItem item = MdmpropertiesFactory.eINSTANCE.createContainerItem();
item.setType(FolderType.SYSTEM_FOLDER_LITERAL);
ERepositoryObjectType type = conf.getResourceProvider().getRepositoryObjectType(item);
if (type == null) {
return null;
}
item.setRepObjType(type);
ItemState itemState = PropertiesFactory.eINSTANCE.createItemState();
itemState.setDeleted(false);
// $NON-NLS-1$
itemState.setPath("");
item.setState(itemState);
item.setLabel(conf.getLabelProvider().getCategoryLabel(item.getRepObjType()));
//
prop.setItem(item);
//
FolderRepositoryObject containerObject = new FolderRepositoryObject(prop);
ContainerCacheService.putContainer(containerObject);
return containerObject;
}
Aggregations