Search in sources :

Example 66 with ProcessItem

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

the class JobJavaScriptsManager method collectRoutines.

protected Collection<IRepositoryViewObject> collectRoutines(ExportFileResource[] process, String type) {
    List<IRepositoryViewObject> toReturn = new ArrayList<IRepositoryViewObject>();
    if (USER_BEANS_PATH.equals(type)) {
        ERepositoryObjectType beansType = null;
        if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
            ICamelDesignerCoreService service = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
            beansType = service.getBeansType();
        }
        try {
            toReturn = ProxyRepositoryFactory.getInstance().getAll(beansType);
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
            toReturn = Collections.emptyList();
        }
    } else {
        Set<String> allRoutinesNames = new HashSet<String>();
        ERepositoryObjectType objectType = ERepositoryObjectType.ROUTINES;
        if (USER_PIGUDF_PATH.equals(type)) {
            objectType = ERepositoryObjectType.PIG_UDF;
        }
        if (ERepositoryObjectType.ROUTINES == objectType) {
            for (ExportFileResource resource : process) {
                if (resource.getItem() instanceof ProcessItem) {
                    Set<String> routinesNeededForJob = LastGenerationInfo.getInstance().getRoutinesNeededWithSubjobPerJob(resource.getItem().getProperty().getId(), resource.getItem().getProperty().getVersion());
                    if (routinesNeededForJob != null) {
                        allRoutinesNames.addAll(routinesNeededForJob);
                    }
                }
            }
        } else {
            for (ExportFileResource resource : process) {
                if (resource.getItem() instanceof ProcessItem) {
                    Set<String> routinesNeededForJob = LastGenerationInfo.getInstance().getPigudfNeededWithSubjobPerJob(resource.getItem().getProperty().getId(), resource.getItem().getProperty().getVersion());
                    if (routinesNeededForJob != null) {
                        allRoutinesNames.addAll(routinesNeededForJob);
                    }
                }
            }
        }
        if (allRoutinesNames.isEmpty()) {
            toReturn.addAll(RoutinesUtil.getCurrentSystemRoutines());
        } else {
            toReturn.addAll(collectRoutinesFromRepository(allRoutinesNames, objectType));
        }
    }
    return toReturn;
}
Also used : ICamelDesignerCoreService(org.talend.designer.core.ICamelDesignerCoreService) ProcessItem(org.talend.core.model.properties.ProcessItem) ExportFileResource(org.talend.repository.documentation.ExportFileResource) ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet)

Example 67 with ProcessItem

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

the class AbstractStandardJobBuildProviderTest method createJobItem.

protected Item createJobItem() throws PersistenceException {
    final IProxyRepositoryFactory repositoryFactory = DesignerPlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
    final String testJobId = repositoryFactory.getNextId();
    final String testJobLabel = StandardJobStandaloneBuildProvider.class.getSimpleName() + System.currentTimeMillis();
    // copied from NewProcessWizard
    Property property = PropertiesFactory.eINSTANCE.createProperty();
    property.setAuthor(((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
    property.setVersion(VersionUtils.DEFAULT_VERSION);
    property.setStatusCode("");
    property.setId(testJobId);
    property.setDisplayName(testJobLabel);
    property.setLabel(property.getDisplayName());
    ProcessItem processItem = PropertiesFactory.eINSTANCE.createProcessItem();
    processItem.setProperty(property);
    property.setItem(processItem);
    ProcessType process = TalendFileFactory.eINSTANCE.createProcessType();
    ParametersType parameterType = TalendFileFactory.eINSTANCE.createParametersType();
    List<RoutinesParameterType> dependenciesInPreference = RoutinesUtil.createDependenciesInPreference();
    parameterType.getRoutinesParameter().addAll(dependenciesInPreference);
    process.setParameters(parameterType);
    processItem.setProcess(process);
    repositoryFactory.create(processItem, new Path(""));
    return processItem;
}
Also used : Path(org.eclipse.core.runtime.Path) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) ProcessItem(org.talend.core.model.properties.ProcessItem) RoutinesParameterType(org.talend.designer.core.model.utils.emf.talendfile.RoutinesParameterType) ParametersType(org.talend.designer.core.model.utils.emf.talendfile.ParametersType) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 68 with ProcessItem

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

the class BuildJobHandlerTest method setUp.

@Before
public void setUp() throws Exception {
    // Fix the NPE for org.talend.designer.core.ui.editor.process.Process.createMainParameters(Process.java:401)
    bridgeProject = ReponsitoryContextBridge.getProject();
    ReponsitoryContextBridge.setProject(ProjectManager.getInstance().getCurrentProject().getEmfProject());
    ImportExportHandlersManager importManager = new ImportExportHandlersManager();
    // job with tdm and tdq component.
    URL testJobURL = FileLocator.find(Platform.getBundle("org.talend.repository.test"), new Path("/resources/testBuildJob.zip"), null);
    if (testJobURL != null) {
        testJobURL = FileLocator.toFileURL(testJobURL);
    }
    File srcFile = new File(testJobURL.getFile());
    FileResourcesUnityManager fileUnityManager = ResourcesManagerFactory.getInstance().createFileUnityManager(srcFile);
    ResourcesManager resManager = fileUnityManager.doUnify();
    List<ImportItem> projectRecords = importManager.populateImportingItems(resManager, true, new NullProgressMonitor());
    assertTrue(projectRecords.size() > 0);
    importManager.importItemRecords(new NullProgressMonitor(), resManager, projectRecords, true, projectRecords.toArray(new ImportItem[0]), null);
    IRepositoryViewObject obj = ProxyRepositoryFactory.getInstance().getLastVersion("_bWyBUAYbEeapTZ0aKwL_YA");
    Item item = obj.getProperty().getItem();
    assertTrue(item instanceof ProcessItem);
    processItem = (ProcessItem) item;
}
Also used : ImportExportHandlersManager(org.talend.repository.items.importexport.handlers.ImportExportHandlersManager) Path(org.eclipse.core.runtime.Path) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ImportItem(org.talend.repository.items.importexport.handlers.model.ImportItem) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) ImportItem(org.talend.repository.items.importexport.handlers.model.ImportItem) ProcessItem(org.talend.core.model.properties.ProcessItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) FileResourcesUnityManager(org.talend.repository.items.importexport.ui.managers.FileResourcesUnityManager) ResourcesManager(org.talend.repository.items.importexport.manager.ResourcesManager) ZipFile(java.util.zip.ZipFile) File(java.io.File) URL(java.net.URL) Before(org.junit.Before)

Example 69 with ProcessItem

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

the class FixUnevenItemContextParametersMigrationTaskTest method createTempProcessItem.

private ProcessItem createTempProcessItem() throws PersistenceException {
    ProcessItem processItem = PropertiesFactory.eINSTANCE.createProcessItem();
    Property myProperty = PropertiesFactory.eINSTANCE.createProperty();
    myProperty.setId(ProxyRepositoryFactory.getInstance().getNextId());
    ItemState itemState = PropertiesFactory.eINSTANCE.createItemState();
    itemState.setDeleted(false);
    itemState.setPath("");
    processItem.setState(itemState);
    processItem.setProperty(myProperty);
    myProperty.setLabel("myJob");
    myProperty.setVersion("0.1");
    processItem.setProcess(TalendFileFactory.eINSTANCE.createProcessType());
    ProxyRepositoryFactory.getInstance().create(processItem, new Path(""));
    return processItem;
}
Also used : Path(org.eclipse.core.runtime.Path) ProcessItem(org.talend.core.model.properties.ProcessItem) ItemState(org.talend.core.model.properties.ItemState) Property(org.talend.core.model.properties.Property)

Example 70 with ProcessItem

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

the class BuildJobFactoryTest method test_createBuildJobHandler_JobExportType_null.

@Test
public void test_createBuildJobHandler_JobExportType_null() {
    Property property = PropertiesFactory.eINSTANCE.createProperty();
    property.setAuthor(((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
    property.setLabel("ABC");
    property.setVersion(VersionUtils.DEFAULT_VERSION);
    //$NON-NLS-1$
    property.setStatusCode("");
    ProcessItem processItem = PropertiesFactory.eINSTANCE.createProcessItem();
    processItem.setProperty(property);
    IBuildJobHandler handler = BuildJobFactory.createBuildJobHandler(processItem, "Default", property.getVersion(), JobScriptsManagerFactory.getDefaultExportChoiceMap(), (JobExportType) null);
    Assert.assertNotNull("Can't build job for standalone job", handler);
    Assert.assertEquals(BuildJobHandler.class.getName(), handler.getClass().getName());
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) IBuildJobHandler(org.talend.core.runtime.process.IBuildJobHandler) BuildJobHandler(org.talend.repository.ui.wizards.exportjob.handler.BuildJobHandler) IBuildJobHandler(org.talend.core.runtime.process.IBuildJobHandler) Property(org.talend.core.model.properties.Property) Test(org.junit.Test)

Aggregations

ProcessItem (org.talend.core.model.properties.ProcessItem)160 PersistenceException (org.talend.commons.exception.PersistenceException)49 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)49 ArrayList (java.util.ArrayList)44 Item (org.talend.core.model.properties.Item)40 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)37 Property (org.talend.core.model.properties.Property)30 IProcess2 (org.talend.core.model.process.IProcess2)24 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)24 IProcess (org.talend.core.model.process.IProcess)23 File (java.io.File)22 IDesignerCoreService (org.talend.designer.core.IDesignerCoreService)21 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)21 ExportFileResource (org.talend.repository.documentation.ExportFileResource)21 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)21 IOException (java.io.IOException)20 INode (org.talend.core.model.process.INode)20 List (java.util.List)19 EList (org.eclipse.emf.common.util.EList)19 ProcessorException (org.talend.designer.runprocess.ProcessorException)17