Search in sources :

Example 11 with FolderRepositoryObject

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;
}
Also used : Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) ItemState(org.talend.core.model.properties.ItemState) PersistenceException(org.talend.commons.exception.PersistenceException) Property(org.talend.core.model.properties.Property) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject)

Example 12 with FolderRepositoryObject

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);
    }
}
Also used : IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject)

Example 13 with FolderRepositoryObject

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);
                }
            }
        }
    }
}
Also used : IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) Matcher(java.util.regex.Matcher) PersistenceException(org.talend.commons.exception.PersistenceException) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject)

Example 14 with FolderRepositoryObject

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);
        }
    }
}
Also used : ItemState(org.talend.core.model.properties.ItemState) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) Property(org.talend.core.model.properties.Property) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject)

Example 15 with FolderRepositoryObject

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;
}
Also used : IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryNodeConfiguration(org.talend.mdm.repository.core.IRepositoryNodeConfiguration) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) IRepositoryNodeLabelProvider(org.talend.mdm.repository.core.IRepositoryNodeLabelProvider) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject)

Aggregations

FolderRepositoryObject (org.talend.mdm.repository.models.FolderRepositoryObject)37 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)32 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)16 ContainerItem (org.talend.mdm.repository.model.mdmproperties.ContainerItem)14 ArrayList (java.util.ArrayList)7 Item (org.talend.core.model.properties.Item)7 Property (org.talend.core.model.properties.Property)7 PersistenceException (org.talend.commons.exception.PersistenceException)6 ItemState (org.talend.core.model.properties.ItemState)6 TreeItem (org.eclipse.swt.widgets.TreeItem)5 LinkedList (java.util.LinkedList)4 Project (org.talend.core.model.general.Project)4 RepositoryViewObject (org.talend.core.model.repository.RepositoryViewObject)4 IProject (org.eclipse.core.resources.IProject)3 Path (org.eclipse.core.runtime.Path)3 FolderItem (org.talend.core.model.properties.FolderItem)3 WSRootRepositoryObject (org.talend.mdm.repository.models.WSRootRepositoryObject)3 List (java.util.List)2 Matcher (java.util.regex.Matcher)2 IFolder (org.eclipse.core.resources.IFolder)2