Search in sources :

Example 16 with RoutineItem

use of org.talend.core.model.properties.RoutineItem in project tdi-studio-se by Talend.

the class RemoveRoutineJarDependencyTask method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
     */
@Override
public ExecutionResult execute(Item item) {
    if (getProject().getLanguage() == ECodeLanguage.JAVA) {
        RoutineItem routineItem = (RoutineItem) item;
        if (routineItem.isBuiltIn()) {
            return ExecutionResult.NOTHING_TO_DO;
        }
        try {
            EList<IMPORTType> imports = routineItem.getImports();
            List<Object> toRemove = new ArrayList<Object>();
            for (IMPORTType importElement : imports) {
                if ("org.talend.dataquality.parser.jar".equals(importElement.getMODULE())) {
                    //$NON-NLS-1$
                    toRemove.add(importElement);
                }
            }
            if (toRemove.size() > 0) {
                imports.removeAll(toRemove);
                ProxyRepositoryFactory.getInstance().save(routineItem);
            }
            return ExecutionResult.SUCCESS_NO_ALERT;
        } catch (Exception e) {
            ExceptionHandler.process(e);
            return ExecutionResult.FAILURE;
        }
    } else {
        return ExecutionResult.NOTHING_TO_DO;
    }
}
Also used : ArrayList(java.util.ArrayList) IMPORTType(org.talend.designer.core.model.utils.emf.component.IMPORTType) RoutineItem(org.talend.core.model.properties.RoutineItem)

Example 17 with RoutineItem

use of org.talend.core.model.properties.RoutineItem 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 18 with RoutineItem

use of org.talend.core.model.properties.RoutineItem in project tdi-studio-se by Talend.

the class EditRoutineAction method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
protected void doRun() {
    if (repositoryNode == null) {
        repositoryNode = (RepositoryNode) ((IStructuredSelection) getSelection()).getFirstElement();
    }
    RoutineItem routineItem = (RoutineItem) repositoryNode.getObject().getProperty().getItem();
    try {
        openRoutineEditor(routineItem, false);
        refresh(repositoryNode);
        // CorePlugin.getDefault().getLibrariesService().resetModulesNeeded();
        CorePlugin.getDefault().getRunProcessService().updateLibraries(new HashSet<ModuleNeeded>(), null);
    } catch (PartInitException e) {
        MessageBoxExceptionHandler.process(e);
    } catch (SystemException e) {
        MessageBoxExceptionHandler.process(e);
    }
}
Also used : SystemException(org.talend.commons.exception.SystemException) RoutineItem(org.talend.core.model.properties.RoutineItem) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PartInitException(org.eclipse.ui.PartInitException) ModuleNeeded(org.talend.core.model.general.ModuleNeeded)

Example 19 with RoutineItem

use of org.talend.core.model.properties.RoutineItem in project tdi-studio-se by Talend.

the class ReadRoutineAction method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
protected void doRun() {
    if (repositoryNode == null && getSelection() != null) {
        repositoryNode = (RepositoryNode) ((IStructuredSelection) getSelection()).getFirstElement();
    }
    RoutineItem routineItem = (RoutineItem) repositoryNode.getObject().getProperty().getItem();
    Property updatedProperty = null;
    try {
        updatedProperty = ProxyRepositoryFactory.getInstance().getLastVersion(new Project(ProjectManager.getInstance().getProject(routineItem)), routineItem.getProperty().getId()).getProperty();
    // repositoryNode.getObject().setProperty(updatedProperty);
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
    routineItem = (RoutineItem) repositoryNode.getObject().getProperty().getItem();
    try {
        openRoutineEditor(routineItem, true);
    } catch (PartInitException e) {
        MessageBoxExceptionHandler.process(e);
    } catch (SystemException e) {
        MessageBoxExceptionHandler.process(e);
    }
}
Also used : Project(org.talend.core.model.general.Project) SystemException(org.talend.commons.exception.SystemException) PersistenceException(org.talend.commons.exception.PersistenceException) RoutineItem(org.talend.core.model.properties.RoutineItem) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PartInitException(org.eclipse.ui.PartInitException) Property(org.talend.core.model.properties.Property)

Example 20 with RoutineItem

use of org.talend.core.model.properties.RoutineItem in project tdi-studio-se by Talend.

the class ConfigExternalLibPage method getSelectedRoutine.

public RoutineItem getSelectedRoutine() {
    RepositoryNode node = getSelectedRepositoryNode();
    Item item = node.getObject().getProperty().getItem();
    return (RoutineItem) item;
}
Also used : RoutineItem(org.talend.core.model.properties.RoutineItem) Item(org.talend.core.model.properties.Item) RoutineItem(org.talend.core.model.properties.RoutineItem) RepositoryNode(org.talend.repository.model.RepositoryNode)

Aggregations

RoutineItem (org.talend.core.model.properties.RoutineItem)39 PersistenceException (org.talend.commons.exception.PersistenceException)15 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)15 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)13 Item (org.talend.core.model.properties.Item)12 Property (org.talend.core.model.properties.Property)12 ArrayList (java.util.ArrayList)11 IOException (java.io.IOException)9 CoreException (org.eclipse.core.runtime.CoreException)8 ProcessItem (org.talend.core.model.properties.ProcessItem)8 SQLPatternItem (org.talend.core.model.properties.SQLPatternItem)8 File (java.io.File)7 IFile (org.eclipse.core.resources.IFile)7 IMPORTType (org.talend.designer.core.model.utils.emf.component.IMPORTType)7 Project (org.talend.core.model.general.Project)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 HashSet (java.util.HashSet)5 PartInitException (org.eclipse.ui.PartInitException)5 SystemException (org.talend.commons.exception.SystemException)5 List (java.util.List)4