Search in sources :

Example 21 with BusinessException

use of org.talend.commons.exception.BusinessException in project tdq-studio-se by Talend.

the class DuplicateAction method getSelctionNode.

private RepositoryNode getSelctionNode(String newLabel, Property property) throws BusinessException {
    RepositoryNode recursiveFind = null;
    if (property != null) {
        if (property.getItem() instanceof TDQFileItem) {
            // if the model element is null, means that it is a file item.
            recursiveFind = findNodeForTDQFileItem(newLabel);
        } else {
            // find the related node by the model element
            recursiveFind = RepositoryNodeHelper.recursiveFind(property);
        }
    }
    if (recursiveFind == null) {
        BusinessException createBusinessException = ExceptionFactory.getInstance().createBusinessException(// $NON-NLS-1$
        DefaultMessagesImpl.getString("DuplicateAction.NodeNull", newLabel));
        throw createBusinessException;
    }
    RepositoryNode parent = recursiveFind.getParent();
    CommonViewer dqCommonViewer = RepositoryNodeHelper.getDQCommonViewer();
    if (dqCommonViewer != null && !dqCommonViewer.getExpandedState(parent)) {
        dqCommonViewer.setExpandedState(parent, true);
    }
    return recursiveFind;
}
Also used : TDQFileItem(org.talend.dataquality.properties.TDQFileItem) BusinessException(org.talend.commons.exception.BusinessException) CommonViewer(org.eclipse.ui.navigator.CommonViewer) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 22 with BusinessException

use of org.talend.commons.exception.BusinessException in project tesb-studio-se by Talend.

the class ESBService method copyJobForService.

private Item copyJobForService(final Item item, final IPath path, final String newName) {
    try {
        final Item newItem = ProxyRepositoryFactory.getInstance().copy(item, path, newName);
        if (newItem instanceof ConnectionItem) {
            Connection connection = ((ConnectionItem) newItem).getConnection();
            if (connection != null) {
                connection.setLabel(newName);
                connection.setName(newName);
                connection.getSupplierDependency().clear();
            }
        }
        ProxyRepositoryFactory.getInstance().save(newItem);
        return newItem;
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    } catch (BusinessException e) {
        ExceptionHandler.process(e);
    }
    return null;
}
Also used : CamelProcessItem(org.talend.camel.core.model.camelProperties.CamelProcessItem) Item(org.talend.core.model.properties.Item) ConnectionItem(org.talend.core.model.properties.ConnectionItem) RouteletProcessItem(org.talend.camel.core.model.camelProperties.RouteletProcessItem) ServiceItem(org.talend.repository.services.model.services.ServiceItem) ProcessItem(org.talend.core.model.properties.ProcessItem) BusinessException(org.talend.commons.exception.BusinessException) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Connection(org.talend.core.model.metadata.builder.connection.Connection) ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 23 with BusinessException

use of org.talend.commons.exception.BusinessException in project tdi-studio-se by Talend.

the class ComponentsUtils method loadComponent.

private static void loadComponent(Set<IComponent> componentsList, ComponentDefinition componentDefinition, String paletteType) {
    try {
        Component currentComponent = new Component(componentDefinition, paletteType);
        Collection<IComponentFactoryFilter> filters = ComponentsFactoryProviderManager.getInstance().getProviders();
        boolean hiddenComponent = false;
        for (IComponentFactoryFilter filter : filters) {
            if (!filter.isAvailable(currentComponent.getName())) {
                hiddenComponent = true;
                break;
            }
        }
        // just don't load it
        if (hiddenComponent && !(currentComponent.getOriginalFamilyName().contains("Technical") || currentComponent.isTechnical())) {
            return;
        }
        // hide it
        if (hiddenComponent && (currentComponent.getOriginalFamilyName().contains("Technical") || currentComponent.isTechnical())) {
            currentComponent.setVisible(false);
            currentComponent.setTechnical(true);
        }
        componentsList.add(currentComponent);
    } catch (BusinessException e) {
        ExceptionHandler.process(e);
    }
}
Also used : BusinessException(org.talend.commons.exception.BusinessException) IComponentFactoryFilter(org.talend.core.model.components.filters.IComponentFactoryFilter) IComponent(org.talend.core.model.components.IComponent) Component(org.talend.designer.core.generic.model.Component)

Example 24 with BusinessException

use of org.talend.commons.exception.BusinessException in project tdi-studio-se by Talend.

the class SelectDeleteProjectDialog method getProjectItem.

private List<Project> getProjectItem() {
    if (login) {
        List<Project> projectList = new ArrayList<Project>();
        if (projectItemList != null && !projectItemList.isEmpty()) {
            Iterator<Object> iter = projectItemList.iterator();
            while (iter.hasNext()) {
                Object project = iter.next();
                if (project instanceof Project) {
                    projectList.add((Project) project);
                }
            }
        }
        return projectList;
    }
    if (!projects.isEmpty()) {
        return projects;
    }
    ProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
    Project[] projects = null;
    try {
        projects = repositoryFactory.readProject();
    } catch (PersistenceException e) {
        CommonExceptionHandler.process(e);
    } catch (BusinessException e) {
        CommonExceptionHandler.process(e);
    }
    for (Project p : projects) {
        this.projects.add(p);
    }
    if (projects != null) {
        return this.projects;
    }
    return Collections.emptyList();
}
Also used : IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) BusinessException(org.talend.commons.exception.BusinessException) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) ArrayList(java.util.ArrayList) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 25 with BusinessException

use of org.talend.commons.exception.BusinessException in project tdi-studio-se by Talend.

the class DBTreeProvider method getMetadataConnection.

/**
     * @return MetadataConnection
     */
@SuppressWarnings("unchecked")
private Container getMetadataConnection() {
    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    ProjectManager pManager = ProjectManager.getInstance();
    Container container = null;
    try {
        container = factory.getMetadata(pManager.getCurrentProject(), ERepositoryObjectType.METADATA_CONNECTIONS);
        pManager.retrieveReferencedProjects();
        for (Project p : pManager.getAllReferencedProjects()) {
            RootContainer rContainer = factory.getMetadata(p, ERepositoryObjectType.METADATA_CONNECTIONS);
            if (container == null) {
                container = rContainer;
            } else if (rContainer != null) {
                Iterator iterator = rContainer.absoluteKeySet().iterator();
                while (iterator.hasNext()) {
                    Object id = iterator.next();
                    container.addMember(id, rContainer.getAbsoluteMember(id));
                }
            }
        }
    } catch (PersistenceException e) {
        //$NON-NLS-1$
        SqlBuilderPlugin.log(Messages.getString("DBTreeProvider.logMessage"), e);
    } catch (BusinessException e) {
        //$NON-NLS-1$
        SqlBuilderPlugin.log(Messages.getString("DBTreeProvider.logMessage"), e);
    }
    return container;
}
Also used : Project(org.talend.core.model.general.Project) Container(org.talend.commons.utils.data.container.Container) RootContainer(org.talend.commons.utils.data.container.RootContainer) BusinessException(org.talend.commons.exception.BusinessException) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) Iterator(java.util.Iterator) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryObject(org.talend.core.model.repository.RepositoryObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) RootContainer(org.talend.commons.utils.data.container.RootContainer) ProjectManager(org.talend.repository.ProjectManager)

Aggregations

BusinessException (org.talend.commons.exception.BusinessException)46 PersistenceException (org.talend.commons.exception.PersistenceException)21 IPath (org.eclipse.core.runtime.IPath)9 Path (org.eclipse.core.runtime.Path)9 Project (org.talend.core.model.general.Project)9 Item (org.talend.core.model.properties.Item)9 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)9 ArrayList (java.util.ArrayList)8 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)8 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)7 IFile (org.eclipse.core.resources.IFile)6 IProject (org.eclipse.core.resources.IProject)6 MDMServerObjectItem (org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem)5 File (java.io.File)4 HashMap (java.util.HashMap)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 ReturnCode (org.talend.utils.sugars.ReturnCode)4 IOException (java.io.IOException)3 IWorkspace (org.eclipse.core.resources.IWorkspace)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3