Search in sources :

Example 21 with FolderItem

use of org.talend.core.model.properties.FolderItem in project tdq-studio-se by Talend.

the class RepositoryNodeHelper method getRootNode.

public static RepositoryNode getRootNode(ERepositoryObjectType nodeType, boolean open, org.talend.core.model.general.Project project) {
    DQRepositoryNode node = null;
    FolderItem folderItem = ProxyRepositoryFactory.getInstance().getFolderItem(project, nodeType, Path.EMPTY);
    CommonViewer commonViewer = getDQCommonViewer(open);
    if (commonViewer != null) {
        TreeItem[] items = commonViewer.getTree().getItems();
        for (TreeItem item : items) {
            node = (DQRepositoryNode) item.getData();
            DQRepositoryNode matchNode = getMatchNode(project, node, folderItem);
            if (matchNode != null) {
                return matchNode;
            }
        }
        // $NON-NLS-1$
        log.error(Messages.getString("RepositoryNodeHelper.canNotFindRootNode") + nodeType.getLabel());
    }
    return node;
}
Also used : DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) FolderItem(org.talend.core.model.properties.FolderItem) CommonViewer(org.eclipse.ui.navigator.CommonViewer) TreeItem(org.eclipse.swt.widgets.TreeItem)

Example 22 with FolderItem

use of org.talend.core.model.properties.FolderItem in project tdq-studio-se by Talend.

the class RepositoryNodeHelper method restoreCorruptedConn.

/**
 * restore Connection which is corrupted.
 *
 * @param property
 */
public static void restoreCorruptedConn(Property property) {
    if (!(property.getItem() instanceof ConnectionItem)) {
        return;
    }
    ConnectionItem connItem = (ConnectionItem) property.getItem();
    ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(connItem);
    // connection
    Connection createConnection = RepositoryObjectTypeHelper.CreateConnectionFromType(itemType);
    if (!(ConnectionImpl.class == connItem.getConnection().getClass())) {
        return;
    }
    connItem.setConnection(createConnection);
    try {
        FolderItem folderItem = ProxyRepositoryFactory.getInstance().getFolderItem(ProjectManager.getInstance().getCurrentProject(), itemType, Path.EMPTY);
        Object refreshFolderItem = refreshFolderItem(folderItem, property);
        if (refreshFolderItem == null) {
            // $NON-NLS-1$
            log.debug("Can not replace the connection from it's FolderItem : " + connItem.eResource().getURI());
        }
        ProxyRepositoryFactory.getInstance().save(connItem);
        EMFSharedResources.getInstance().reloadResource(connItem.eResource().getURI());
    } catch (PersistenceException e) {
        log.error(e, e);
    }
}
Also used : FolderItem(org.talend.core.model.properties.FolderItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) DelimitedFileConnection(org.talend.core.model.metadata.builder.connection.DelimitedFileConnection) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) PersistenceException(org.talend.commons.exception.PersistenceException) TdViewRepositoryObject(org.talend.core.repository.model.repositoryObject.TdViewRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ISubRepositoryObject(org.talend.core.model.repository.ISubRepositoryObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) TdTableRepositoryObject(org.talend.core.repository.model.repositoryObject.TdTableRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) EObject(org.eclipse.emf.ecore.EObject) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 23 with FolderItem

use of org.talend.core.model.properties.FolderItem in project tdq-studio-se by Talend.

the class UnitTestBuildHelper method buildRepositoryViewObjectSystemFolder.

/**
 * create a RepositoryViewObject which is a system folder.
 *
 * @param tProject
 * @param author
 * @param type
 * @return
 */
public static IRepositoryViewObject buildRepositoryViewObjectSystemFolder(org.talend.core.model.properties.Project emfProject, User author, ERepositoryObjectType type) {
    ItemState itemState = PropertiesFactory.eINSTANCE.createItemState();
    FolderItem folderItem = PropertiesFactory.eINSTANCE.createFolderItem();
    Property property = PropertiesFactory.eINSTANCE.createProperty();
    itemState.setItemRelated(folderItem);
    folderItem.setState(itemState);
    folderItem.setParent(emfProject);
    folderItem.setType(FolderType.STABLE_SYSTEM_FOLDER_LITERAL);
    folderItem.setProperty(property);
    property.setAuthor(author);
    property.setCreationDate(new Date());
    property.setId(StringUtilities.getRandomString(26));
    property.setItem(folderItem);
    property.setLabel(type.getFolder());
    property.setMaxInformationLevel(InformationLevel.DEBUG_LITERAL);
    // $NON-NLS-1$
    property.setOldStatusCode("");
    // $NON-NLS-1$
    property.setVersion("0.1");
    return new Folder(property, type);
}
Also used : FolderItem(org.talend.core.model.properties.FolderItem) ItemState(org.talend.core.model.properties.ItemState) Folder(org.talend.core.model.repository.Folder) IFolder(org.eclipse.core.resources.IFolder) Property(org.talend.core.model.properties.Property) Date(java.util.Date)

Example 24 with FolderItem

use of org.talend.core.model.properties.FolderItem in project tdq-studio-se by Talend.

the class WorkbenchUtils method getFolderContentType.

/**
 * Add qiongli: get the detail ERepositoryObjectType of folderItem.
 *
 * @param folderItem
 * @return
 */
public static ERepositoryObjectType getFolderContentType(FolderItem folderItem) {
    if (!folderItem.getType().equals(FolderType.SYSTEM_FOLDER_LITERAL)) {
        if (!(folderItem.getParent() instanceof FolderItem)) {
            // appears only for a folder for expression builder !
            return null;
        }
        return getFolderContentType((FolderItem) folderItem.getParent());
    }
    for (ERepositoryObjectType objectType : (ERepositoryObjectType[]) ERepositoryObjectType.values()) {
        String folderName;
        try {
            folderName = ERepositoryObjectType.getFolderName(objectType);
        } catch (Exception e) {
            // just catch exception to avoid the types who don't have folders
            continue;
        }
        if (folderName.contains("/")) {
            // $NON-NLS-1$
            // $NON-NLS-1$
            String[] folders = folderName.split("/");
            FolderItem currentFolderItem = folderItem;
            boolean found = true;
            for (int i = folders.length - 1; i >= 0; i--) {
                if (!currentFolderItem.getProperty().getLabel().equals(folders[i])) {
                    found = false;
                    break;
                }
                if (i > 0) {
                    if (!(currentFolderItem.getParent() instanceof FolderItem)) {
                        found = false;
                        break;
                    }
                    currentFolderItem = (FolderItem) currentFolderItem.getParent();
                }
            }
            if (found) {
                return objectType;
            }
        } else {
            if (folderName.equals(folderItem.getProperty().getLabel())) {
                return objectType;
            }
        }
    }
    if (folderItem.getParent() instanceof FolderItem) {
        return getFolderContentType((FolderItem) folderItem.getParent());
    }
    return null;
}
Also used : FolderItem(org.talend.core.model.properties.FolderItem) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) WorkbenchException(org.eclipse.ui.WorkbenchException) PartInitException(org.eclipse.ui.PartInitException) ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException) BusinessException(org.talend.commons.exception.BusinessException)

Example 25 with FolderItem

use of org.talend.core.model.properties.FolderItem in project tdq-studio-se by Talend.

the class DQRespositoryView method initAllFolders.

/**
 * DOC qiongli Comment method "initAllFolder".
 */
private void initAllFolders() {
    Project newProject = ProjectManager.getInstance().getCurrentProject();
    List<FolderItem> folderItems = ProjectManager.getInstance().getFolders(newProject.getEmfProject());
    try {
        for (FolderItem folder : new ArrayList<FolderItem>(folderItems)) {
            if (WorkbenchUtils.isTDQOrMetadataRootFolder(folder, ProjectManager.getInstance().getCurrentProject().getEmfProject())) {
                ERepositoryObjectType type = WorkbenchUtils.getFolderContentType(folder);
                // MOD by zshen to avoid NullPointerException.
                if (type != null) {
                    ProxyRepositoryFactory.getInstance().getAll(type, true);
                }
            }
        }
    } catch (PersistenceException e) {
        log.error(e, e);
    }
}
Also used : IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) FolderItem(org.talend.core.model.properties.FolderItem) ArrayList(java.util.ArrayList) PersistenceException(org.talend.commons.exception.PersistenceException) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Aggregations

FolderItem (org.talend.core.model.properties.FolderItem)35 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)17 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)16 Item (org.talend.core.model.properties.Item)15 IFolder (org.eclipse.core.resources.IFolder)10 Folder (org.talend.core.model.repository.Folder)10 MetadataTable (org.talend.core.model.metadata.MetadataTable)7 Property (org.talend.core.model.properties.Property)6 ArrayList (java.util.ArrayList)5 IPath (org.eclipse.core.runtime.IPath)5 Path (org.eclipse.core.runtime.Path)5 PersistenceException (org.talend.commons.exception.PersistenceException)5 IFile (org.eclipse.core.resources.IFile)4 IProject (org.eclipse.core.resources.IProject)4 ConnectionItem (org.talend.core.model.properties.ConnectionItem)4 ProcessItem (org.talend.core.model.properties.ProcessItem)4 RepositoryViewObject (org.talend.core.model.repository.RepositoryViewObject)4 ContainerItem (org.talend.mdm.repository.model.mdmproperties.ContainerItem)4 URL (java.net.URL)3 EObject (org.eclipse.emf.ecore.EObject)3