use of org.talend.mdm.repository.models.FolderRepositoryObject in project tmdm-studio-se by Talend.
the class RepositoryResourceUtil method createFolderViewObject.
public static IRepositoryViewObject createFolderViewObject(ERepositoryObjectType type, String folderName, Item pItem, boolean isSystem) {
Property prop = PropertiesFactory.eINSTANCE.createProperty();
prop.setId(EcoreUtil.generateUUID());
//
ContainerItem item = MdmpropertiesFactory.eINSTANCE.createContainerItem();
isSystem = isSystemFolder(pItem, folderName);
item.setType(isSystem ? FolderType.STABLE_SYSTEM_FOLDER_LITERAL : FolderType.FOLDER_LITERAL);
item.setLabel(folderName);
item.setRepObjType(type);
ItemState itemState = PropertiesFactory.eINSTANCE.createItemState();
itemState.setDeleted(false);
item.setState(itemState);
//
prop.setItem(item);
prop.setLabel(folderName);
try {
if (!isSystem) {
Project project = ProjectManager.getInstance().getCurrentProject();
IProject fsProject = ResourceUtils.getProject(project);
ItemState state = pItem.getState();
itemState.setPath(state.getPath() + IPath.SEPARATOR + folderName);
String path = ERepositoryObjectType.getFolderName(type);
if (!path.isEmpty()) {
path += itemState.getPath();
}
IFolder folder = fsProject.getFolder(path);
if (!folder.exists()) {
Path parentPath = new Path(pItem.getState().getPath());
ProxyRepositoryFactory.getInstance().createFolder(project, type, parentPath, folderName);
}
} else {
itemState.setPath(folderName);
}
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
}
FolderRepositoryObject containerRepositoryObject = new FolderRepositoryObject(prop);
//
ContainerCacheService.putContainer(containerRepositoryObject);
//
return containerRepositoryObject;
}
use of org.talend.mdm.repository.models.FolderRepositoryObject in project tmdm-studio-se by Talend.
the class AbstractBridgeRepositoryAction method refreshCurrentContainer.
protected void refreshCurrentContainer() {
Object object = getSelectedObject().get(0);
if (object instanceof FolderRepositoryObject) {
commonViewer.refresh(object);
commonViewer.expandToLevel(object, 1);
}
}
use of org.talend.mdm.repository.models.FolderRepositoryObject in project tmdm-studio-se by Talend.
the class RecycleBinContentProvider method buildAllDeletedFolders.
private void buildAllDeletedFolders(FolderRepositoryObject rootViewObj) {
Project currentProject = ProjectManager.getInstance().getCurrentProject();
List<String> paths = currentProject.getEmfProject().getDeletedFolders();
String[] deletedFolderPaths = sortFolderPath(paths);
containerMap.clear();
rootViewObj.getChildren().clear();
IProject fsProject = null;
try {
fsProject = ResourceUtils.getProject(currentProject);
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
}
for (String path : deletedFolderPaths) {
IFolder folder = fsProject.getFolder(path);
if (folder != null && folder.getLocation().toFile().exists()) {
Matcher matcher = null;
if (path.startsWith(MDM_PREFIX)) {
matcher = mdmPattern.matcher(path);
} else if (path.startsWith(JOB_PREFIX)) {
matcher = jobPattern.matcher(path);
} else if (path.startsWith(DQ_PREFIX)) {
matcher = matchRulePattern.matcher(path);
}
if (matcher != null && matcher.find()) {
String parentFolder = matcher.group(1);
String itemPath = matcher.group(2);
String folderName = matcher.group(4);
ERepositoryObjectType type = RepositoryResourceUtil.getTypeByPath(parentFolder);
FolderRepositoryObject parentContainer = getParenContainer(rootViewObj, type, itemPath, true);
if (type != null && itemPath != null && folderName != null) {
FolderRepositoryObject viewObj = RepositoryResourceUtil.createDeletedFolderViewObject(type, itemPath, folderName, parentContainer);
addToMap(viewObj, itemPath);
}
}
}
}
}
use of org.talend.mdm.repository.models.FolderRepositoryObject in project tmdm-studio-se by Talend.
the class RecycleBinContentProvider method buildAllDeletedObjects.
private void buildAllDeletedObjects(FolderRepositoryObject rootViewObj) {
for (ERepositoryObjectType type : IServerObjectRepositoryType.ALL_TYPES) {
try {
List<IRepositoryViewObject> viewObjs = factory.getAll(type, true);
for (IRepositoryViewObject viewObj : viewObjs) {
Property property = viewObj.getProperty();
ItemState state = property.getItem().getState();
if (state.isDeleted()) {
String path = state.getPath();
// $NON-NLS-1$
String prefix = "/";
if (!path.startsWith(prefix)) {
path = prefix + path;
}
FolderRepositoryObject container = getParenContainer(rootViewObj, type, path, false);
// get from cache
IRepositoryViewObject cacheViewObj = ContainerCacheService.get(property);
if (cacheViewObj == null) {
cacheViewObj = new RepositoryViewObject(property);
ContainerCacheService.put(property, cacheViewObj);
}
container.getChildren().add(cacheViewObj);
}
}
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
}
}
}
use of org.talend.mdm.repository.models.FolderRepositoryObject in project tmdm-studio-se by Talend.
the class RecycleBinLabelProvider method getImage.
@Override
public Image getImage(Object element) {
if (element instanceof IRepositoryViewObject) {
IRepositoryViewObject viewObj = (IRepositoryViewObject) element;
ERepositoryObjectType type = viewObj.getRepositoryObjectType();
if (type == IServerObjectRepositoryType.TYPE_RECYCLE_BIN) {
if (viewObj instanceof FolderRepositoryObject) {
return ((FolderRepositoryObject) viewObj).getChildren().isEmpty() ? EMPTY_IMG : FULL_IMG;
}
}
IRepositoryNodeConfiguration configuration = RepositoryNodeConfigurationManager.getConfiguration(type);
if (configuration != null) {
IRepositoryNodeLabelProvider labelProvider = configuration.getLabelProvider();
return labelProvider.getImage(element);
}
}
return null;
}
Aggregations