Search in sources :

Example 76 with IRepositoryViewObject

use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.

the class ExportItemUtil method getOtherVersions.

/**
     * return a collection of items that have the same id as the input items params and a different version. <br>
     * WARNING : when calling this method the global TOS model will be updated with all the items versions
     * 
     * @param items all the items to get the different version of.
     * @return list of all the items with same id as input items and different versions
     * @throws PersistenceException if could not load some items //MOD sgandon 31/03/2010 bug 12229: changed
     * getAllVersions into getOtherVersions.
     */
private Collection<Item> getOtherVersions(Collection<Item> items) throws PersistenceException {
    Collection<Item> itemsVersions = new ArrayList<Item>();
    for (Item item : items) {
        org.talend.core.model.general.Project itemProject = new org.talend.core.model.general.Project(pManager.getProject(item));
        List<IRepositoryViewObject> allVersion = ProxyRepositoryFactory.getInstance().getAllVersion(itemProject, item.getProperty().getId(), false);
        for (IRepositoryViewObject repositoryObject : allVersion) {
            Item anyVersionItem = repositoryObject.getProperty().getItem();
            if (!anyVersionItem.equals(item)) {
                itemsVersions.add(anyVersionItem);
            }
        // else same item so ignor it
        }
    }
    return itemsVersions;
}
Also used : Item(org.talend.core.model.properties.Item) RoutineItem(org.talend.core.model.properties.RoutineItem) Project(org.talend.core.model.properties.Project) IProject(org.eclipse.core.resources.IProject) ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Example 77 with IRepositoryViewObject

use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.

the class ExportProjectsAsAction method getLinksFromProject.

/**
     * DOC zwang Comment method "getLinksFromProject".
     * 
     * @param project
     * @return
     */
private List<LinkTargetStore> getLinksFromProject(Project project) {
    List<IMPORTType> imports = null;
    String linkTarget = null;
    RootContainer<String, IRepositoryViewObject> routines = getRoutineFromProject(project);
    List<LinkTargetStore> paths = new ArrayList<LinkTargetStore>();
    String language = project.getLanguage().getName().trim();
    for (IRepositoryViewObject obj : routines.getMembers()) {
        RoutineItem routine = (RoutineItem) obj.getProperty().getItem();
        imports = routine.getImports();
        if (language != null) {
            if (project != null && ECodeLanguage.JAVA.getName().equals(language)) {
                IPath containerPath = getContainerFullPath(project.getTechnicalLabel());
                for (IMPORTType importType : imports) {
                    try {
                        LinkTargetStore store = new LinkTargetStore();
                        IPath newFilePath = containerPath.append(ExportProjectsAsAction.LIB + java.io.File.separatorChar + ECodeLanguage.JAVA.getName() + java.io.File.separatorChar + importType.getMODULE());
                        linkTarget = EXTERNAL_LIB_JAVA_PATH + java.io.File.separatorChar + importType.getMODULE();
                        URI path = new URI(linkTarget.replace(java.io.File.separatorChar, '/'));
                        store.file = ResourcesPlugin.getWorkspace().getRoot().getFile(newFilePath);
                        store.uri = path;
                        paths.add(store);
                    } catch (Exception e) {
                        ExceptionHandler.process(e);
                    }
                }
            }
        }
    }
    return paths;
}
Also used : IPath(org.eclipse.core.runtime.IPath) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ArrayList(java.util.ArrayList) IMPORTType(org.talend.designer.core.model.utils.emf.component.IMPORTType) RoutineItem(org.talend.core.model.properties.RoutineItem) URI(java.net.URI) CoreException(org.eclipse.core.runtime.CoreException) ExecutionException(org.eclipse.core.commands.ExecutionException) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 78 with IRepositoryViewObject

use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.

the class ExportProjectsAsAction method getRoutineFromProject.

/**
     * DOC bqian Comment method "getRouineFromProject".
     * 
     * @param project
     */
private RootContainer<String, IRepositoryViewObject> getRoutineFromProject(Project project) {
    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    RootContainer<String, IRepositoryViewObject> routines = null;
    try {
        routines = factory.getRoutineFromProject(project);
    } catch (PersistenceException e) {
        // TODO Auto-generated catch block
        // e.printStackTrace();
        ExceptionHandler.process(e);
    }
    return routines;
}
Also used : IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 79 with IRepositoryViewObject

use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.

the class SchemaTypeProcessor method selectRepositoryNode.

@Override
protected boolean selectRepositoryNode(Viewer viewer, RepositoryNode parentNode, RepositoryNode node) {
    if (super.selectRepositoryNode(viewer, parentNode, node)) {
        IRepositoryViewObject object = node.getObject();
        if (object != null) {
            // query
            if (object instanceof Query) {
                return false;
            }
        }
        // cdc
        ICDCProviderService cdcService = null;
        if (PluginChecker.isCDCPluginLoaded()) {
            cdcService = (ICDCProviderService) GlobalServiceRegister.getDefault().getService(ICDCProviderService.class);
        }
        String repositoryType = getRepositoryType();
        if (ERepositoryCategoryType.CDC.getName().equals(repositoryType) && (object != null)) {
            if (object.getRepositoryObjectType() == ERepositoryObjectType.METADATA_CONNECTIONS) {
                DatabaseConnectionItem item = (DatabaseConnectionItem) object.getProperty().getItem();
                DatabaseConnection connection = (DatabaseConnection) item.getConnection();
                if (cdcService != null && cdcService.canCreateCDCConnection(connection)) {
                    return true;
                }
                return false;
            }
            if (object instanceof MetadataTable) {
                return ((MetadataTableRepositoryObject) object).getTable().isActivatedCDC();
            }
        }
        return true;
    }
    return false;
}
Also used : Query(org.talend.core.model.metadata.Query) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataTable(org.talend.core.model.metadata.MetadataTable) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) ICDCProviderService(org.talend.core.ui.ICDCProviderService) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem)

Example 80 with IRepositoryViewObject

use of org.talend.core.model.repository.IRepositoryViewObject in project tesb-studio-se by Talend.

the class CheckCXFNodesService method checkNode.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.talend.designer.core.ICheckNodesService#checkNode(org.talend.designer
	 * .core.ui.editor.nodes.Node)
	 */
public void checkNode(Node node) {
    if (!node.getComponent().getName().equals("cSOAP")) {
        //$NON-NLS-1$
        return;
    }
    //$NON-NLS-1$
    final IElementParameter serviceParam = node.getElementParameter("SERVICE_TYPE");
    // Select WSDL
    if (serviceParam != null && "wsdlURL".equals(serviceParam.getValue())) {
        //$NON-NLS-1$
        //$NON-NLS-1$
        final IElementParameter wsdlFileParam = node.getElementParameter("WSDL_FILE");
        //$NON-NLS-1$
        final IElementParameter wsdlTypeParam = node.getElementParameter("WSDL_TYPE");
        // Select File
        if (wsdlTypeParam != null && "file".equals(wsdlTypeParam.getValue())) {
            // WSDL file is empty
            if (wsdlFileParam == null || wsdlFileParam.getValue() == null || wsdlFileParam.getValue().toString().isEmpty() || wsdlFileParam.getValue().toString().equals("\"\"")) {
                //$NON-NLS-1$
                String errorMessage = //$NON-NLS-1$
                MessageFormat.format(//$NON-NLS-1$
                CamelDesignerMessages.getString("CheckCXFNodesService_emptyError"), wsdlFileParam == null ? "" : wsdlFileParam.getDisplayName());
                Problems.add(ProblemStatus.ERROR, (Element) node, errorMessage);
            }
        } else // Select Repository
        if (wsdlTypeParam != null && "repo".equals(wsdlTypeParam.getValue())) {
            //$NON-NLS-1$
            final IElementParameter resourceParam = node.getElementParameterFromField(EParameterFieldType.ROUTE_RESOURCE_TYPE);
            // WSDL file is empty
            //$NON-NLS-1$
            String errorMessage = "";
            if (resourceParam == null || resourceParam.getValue() == null || resourceParam.getValue().toString().isEmpty()) {
                errorMessage = //$NON-NLS-1$
                MessageFormat.format(//$NON-NLS-1$
                CamelDesignerMessages.getString("CheckCXFNodesService_emptyError"), wsdlFileParam.getDisplayName());
                Problems.add(ProblemStatus.ERROR, (Element) node, errorMessage);
            } else {
                String id = (String) resourceParam.getValue();
                try {
                    IRepositoryViewObject lastVersion = ProxyRepositoryFactory.getInstance().getLastVersion(id);
                    if (lastVersion == null) {
                        errorMessage = //$NON-NLS-1$
                        MessageFormat.format(//$NON-NLS-1$
                        CamelDesignerMessages.getString("CheckCXFNodesService_nonexistError"), wsdlFileParam.getDisplayName());
                        Problems.add(ProblemStatus.ERROR, (Element) node, errorMessage);
                    } else if (lastVersion.isDeleted()) {
                        errorMessage = //$NON-NLS-1$
                        MessageFormat.format(//$NON-NLS-1$
                        CamelDesignerMessages.getString("CheckCXFNodesService_removedError"), resourceParam.getDisplayName());
                        Problems.add(ProblemStatus.ERROR, (Element) node, errorMessage);
                    }
                } catch (PersistenceException e) {
                    errorMessage = //$NON-NLS-1$
                    MessageFormat.format(//$NON-NLS-1$
                    CamelDesignerMessages.getString("CheckCXFNodesService_emptyError"), wsdlFileParam.getDisplayName());
                    Problems.add(ProblemStatus.ERROR, (Element) node, errorMessage);
                }
            }
        }
    } else // Select Service class
    if (serviceParam != null && "serviceClass".equals(serviceParam.getValue())) {
        //$NON-NLS-1$
        //$NON-NLS-1$
        final IElementParameter clazzParam = node.getElementParameter("SERVICE_CLASS");
        // Service class is empty
        if (clazzParam == null || clazzParam.getValue() == null || clazzParam.getValue().toString().isEmpty()) {
            String errorMessage = //$NON-NLS-1$
            MessageFormat.format(//$NON-NLS-1$
            CamelDesignerMessages.getString("CheckCXFNodesService_emptyError"), clazzParam.getDisplayName());
            Problems.add(ProblemStatus.ERROR, (Element) node, errorMessage);
        }
    }
}
Also used : Element(org.talend.core.model.process.Element) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IElementParameter(org.talend.core.model.process.IElementParameter)

Aggregations

IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)222 PersistenceException (org.talend.commons.exception.PersistenceException)115 Item (org.talend.core.model.properties.Item)86 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)67 ArrayList (java.util.ArrayList)63 ConnectionItem (org.talend.core.model.properties.ConnectionItem)54 ProcessItem (org.talend.core.model.properties.ProcessItem)54 RepositoryNode (org.talend.repository.model.RepositoryNode)50 IElementParameter (org.talend.core.model.process.IElementParameter)43 Property (org.talend.core.model.properties.Property)43 IRepositoryNode (org.talend.repository.model.IRepositoryNode)33 List (java.util.List)32 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)32 DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)31 INode (org.talend.core.model.process.INode)30 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)25 Node (org.talend.designer.core.ui.editor.nodes.Node)25 Connection (org.talend.core.model.metadata.builder.connection.Connection)23 CoreException (org.eclipse.core.runtime.CoreException)17 RoutineItem (org.talend.core.model.properties.RoutineItem)17