Search in sources :

Example 1 with JobInfo

use of org.talend.core.model.process.JobInfo in project tdi-studio-se by Talend.

the class AbstractTalendEditor method setInput.

// ------------------------------------------------------------------------
// Overridden from EditorPart
@Override
protected void setInput(final IEditorInput input) {
    super.setInput(input);
    try {
        if (input instanceof JobEditorInput) {
            // process = ((JobEditorInput) input).getLoadedProcess();
            projectName = CorePlugin.getDefault().getProxyRepositoryFactory().getProject(((RepositoryEditorInput) input).getItem()).getLabel();
        }
    } catch (Exception e) {
        MessageBoxExceptionHandler.process(e);
        return;
    }
    IProcess2 process = getProcess();
    if (process != null && process.getProperty().getItem() instanceof ProcessItem) {
        currentJobResource.setJobInfo(new JobInfo((ProcessItem) process.getProperty().getItem(), process.getProperty(), process.getContextManager().getDefaultContext().getName()));
        currentJobResource.setProjectName(projectName);
        JobResourceManager.getInstance().addProtection(this);
    }
}
Also used : JobEditorInput(org.talend.core.ui.editor.JobEditorInput) ProcessItem(org.talend.core.model.properties.ProcessItem) JobInfo(org.talend.core.model.process.JobInfo) IProcess2(org.talend.core.model.process.IProcess2) CoreException(org.eclipse.core.runtime.CoreException) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 2 with JobInfo

use of org.talend.core.model.process.JobInfo in project tdi-studio-se by Talend.

the class JobErrorsChecker method getErrors.

public static List<IContainerEntry> getErrors() {
    List<IContainerEntry> input = new ArrayList<IContainerEntry>();
    try {
        Item item = null;
        IProxyRepositoryFactory proxyRepositoryFactory = CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
        ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
        Set<String> jobIds = new HashSet<String>();
        for (JobInfo jobInfo : LastGenerationInfo.getInstance().getLastGeneratedjobs()) {
            // TDI-28198:get right process item no matter the job open or close
            List<IRepositoryViewObject> allVersions = proxyRepositoryFactory.getAllVersion(jobInfo.getJobId());
            for (IRepositoryViewObject repositoryObject2 : allVersions) {
                Property property2 = repositoryObject2.getProperty();
                if (jobInfo.getJobVersion().equals(property2.getVersion())) {
                    item = property2.getItem();
                    break;
                }
            }
            if (item == null) {
                continue;
            }
            // get source file
            IFile sourceFile = synchronizer.getFile(item);
            if (sourceFile == null) {
                continue;
            }
            jobIds.add(item.getProperty().getId());
            // Property property = process.getProperty();
            Problems.addJobRoutineFile(sourceFile, ProblemType.JOB, item, true);
        }
        if (!CommonsPlugin.isHeadless()) {
            List<IRepositoryViewObject> routinesObjects = proxyRepositoryFactory.getAll(ERepositoryObjectType.ROUTINES, false);
            Set<String> dependentRoutines = LastGenerationInfo.getInstance().getRoutinesNeededWithSubjobPerJob(LastGenerationInfo.getInstance().getLastMainJob().getJobId(), LastGenerationInfo.getInstance().getLastMainJob().getJobVersion());
            if (routinesObjects != null) {
                for (IRepositoryViewObject obj : routinesObjects) {
                    Property property = obj.getProperty();
                    if (dependentRoutines.contains(property.getLabel())) {
                        Item routinesitem = property.getItem();
                        IFile routineFile = synchronizer.getFile(routinesitem);
                        Problems.addJobRoutineFile(routineFile, ProblemType.ROUTINE, routinesitem, true);
                    } else {
                        Problems.clearAllComliationError(property.getLabel());
                    }
                }
            }
        }
        Problems.refreshProblemTreeView();
        // collect error
        List<Problem> errors = Problems.getProblemList().getProblemsBySeverity(ProblemStatus.ERROR);
        ErrorDetailTreeBuilder builder = new ErrorDetailTreeBuilder();
        input.addAll(builder.createTreeInput(errors, jobIds));
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
    return input;
}
Also used : ITalendSynchronizer(org.talend.designer.codegen.ITalendSynchronizer) IFile(org.eclipse.core.resources.IFile) ArrayList(java.util.ArrayList) CoreException(org.eclipse.core.runtime.CoreException) SystemException(org.talend.commons.exception.SystemException) PersistenceException(org.talend.commons.exception.PersistenceException) Item(org.talend.core.model.properties.Item) JobInfo(org.talend.core.model.process.JobInfo) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TalendProblem(org.talend.core.model.process.TalendProblem) Problem(org.talend.core.model.process.Problem) IContainerEntry(org.talend.core.model.process.IContainerEntry) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) HashSet(java.util.HashSet)

Example 3 with JobInfo

use of org.talend.core.model.process.JobInfo in project tdi-studio-se by Talend.

the class JavaProcessor method getExportJarsStr.

protected String getExportJarsStr() {
    final String rootWorkingDir = getRootWorkingDir(true);
    final String classPathSeparator = extractClassPathSeparator();
    String jarName = JavaResourcesHelper.getJobFolderName(process.getName(), process.getVersion());
    String exportJar = rootWorkingDir + jarName + FileExtensions.JAR_FILE_SUFFIX;
    Set<JobInfo> infos = getBuildChildrenJobs();
    for (JobInfo jobInfo : infos) {
        String childJarName = JavaResourcesHelper.getJobFolderName(jobInfo.getJobName(), jobInfo.getJobVersion());
        exportJar += classPathSeparator + rootWorkingDir + childJarName + FileExtensions.JAR_FILE_SUFFIX;
    }
    return exportJar;
}
Also used : JobInfo(org.talend.core.model.process.JobInfo)

Example 4 with JobInfo

use of org.talend.core.model.process.JobInfo in project tdi-studio-se by Talend.

the class JobJavaScriptsManager method addXmlMapping.

protected void addXmlMapping(ExportFileResource resource, boolean needSource) {
    try {
        boolean hasDynamicMetadata = false;
        if (resource.getItem() instanceof ProcessItem) {
            List<JobInfo> list = new ArrayList<JobInfo>();
            hasDynamicMetadata = LastGenerationInfo.getInstance().isUseDynamic(resource.getItem().getProperty().getId(), resource.getItem().getProperty().getVersion());
        }
        if (hasDynamicMetadata) {
            needMappingInSystemRoutine = true;
            if (needSource) {
                IRunProcessService service = CorePlugin.getDefault().getRunProcessService();
                ITalendProcessJavaProject talendProcessJavaProject = service.getTalendProcessJavaProject();
                if (talendProcessJavaProject == null) {
                    return;
                }
                // for db mapping xml
                IFolder xmlMappingFolder = talendProcessJavaProject.getResourcesFolder().getFolder(JavaUtils.JAVA_XML_MAPPING);
                if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreService.class)) {
                    ICoreService coreService = (ICoreService) GlobalServiceRegister.getDefault().getService(ICoreService.class);
                    coreService.synchronizeMapptingXML();
                    coreService.syncLog4jSettings();
                }
                List<URL> xmlMappingFileUrls = new ArrayList<URL>();
                if (xmlMappingFolder.exists()) {
                    for (IResource fileResource : xmlMappingFolder.members()) {
                        if (XmlUtil.isXMLFile(fileResource.getName())) {
                            xmlMappingFileUrls.add(fileResource.getLocationURI().toURL());
                        }
                    }
                    resource.addResources(JOB_SOURCE_FOLDER_NAME + PATH_SEPARATOR + JavaUtils.JAVA_XML_MAPPING, xmlMappingFileUrls);
                }
            }
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
}
Also used : IRunProcessService(org.talend.designer.runprocess.IRunProcessService) ArrayList(java.util.ArrayList) ICoreService(org.talend.core.ICoreService) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) URL(java.net.URL) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) DocumentException(org.dom4j.DocumentException) ProcessorException(org.talend.designer.runprocess.ProcessorException) MalformedURLException(java.net.MalformedURLException) PersistenceException(org.talend.commons.exception.PersistenceException) ProcessItem(org.talend.core.model.properties.ProcessItem) JobInfo(org.talend.core.model.process.JobInfo) IResource(org.eclipse.core.resources.IResource) IFolder(org.eclipse.core.resources.IFolder)

Example 5 with JobInfo

use of org.talend.core.model.process.JobInfo in project tdi-studio-se by Talend.

the class JobJavaScriptsManager method getChildrenJobAndContextName.

protected void getChildrenJobAndContextName(ExportFileResource[] allResources, String rootName, List<JobInfo> list, ProcessItem process, String projectName, List<ProcessItem> processedJob, List<URL> allJobScripts, ExportFileResource resource, Map<ExportChoice, Object> exportChoice, String... selectedJobVersion) {
    if (processedJob.contains(process)) {
        // prevent circle
        return;
    }
    processedJob.add(process);
    ProjectManager projectManager = ProjectManager.getInstance();
    Project project = projectManager.getProject(process);
    String childProjectName = projectName;
    if (project != null) {
        // hywang modify for 7932
        childProjectName = project.getTechnicalLabel().toLowerCase();
    }
    allJobScripts.addAll(getJobScripts(childProjectName, process.getProperty().getLabel(), process.getProperty().getVersion(), isOptionChoosed(ExportChoice.needJobScript)));
    addContextScripts(process, process.getProperty().getLabel(), process.getProperty().getVersion(), resource, isOptionChoosed(ExportChoice.needContext));
    addJobItem(allResources, process, isOptionChoosed(ExportChoice.needJobItem), resource);
    addDependencies(allResources, process, isOptionChoosed(ExportChoice.needDependencies) && isOptionChoosed(ExportChoice.needJobItem), resource);
    addSourceCode(allResources, process, isOptionChoosed(ExportChoice.needSourceCode), resource);
    addDependenciesSourceCode(allResources, resource, isOptionChoosed(ExportChoice.needSourceCode));
    Set<JobInfo> subjobInfos = ProcessorUtilities.getChildrenJobInfo(process);
    for (JobInfo subjobInfo : subjobInfos) {
        if (list.contains(subjobInfo)) {
            continue;
        }
        list.add(subjobInfo);
        getChildrenJobAndContextName(allResources, rootName, list, subjobInfo.getProcessItem(), projectName, processedJob, allJobScripts, resource, exportChoice);
    }
}
Also used : IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.properties.Project) IJavaProject(org.eclipse.jdt.core.IJavaProject) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) JobInfo(org.talend.core.model.process.JobInfo) ProjectManager(org.talend.repository.ProjectManager)

Aggregations

JobInfo (org.talend.core.model.process.JobInfo)16 ProcessItem (org.talend.core.model.properties.ProcessItem)8 PersistenceException (org.talend.commons.exception.PersistenceException)7 ArrayList (java.util.ArrayList)6 CoreException (org.eclipse.core.runtime.CoreException)6 ProcessorException (org.talend.designer.runprocess.ProcessorException)4 HashSet (java.util.HashSet)3 IFile (org.eclipse.core.resources.IFile)3 Property (org.talend.core.model.properties.Property)3 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)3 JobResourceManager (org.talend.core.model.repository.job.JobResourceManager)3 File (java.io.File)2 IOException (java.io.IOException)2 IResource (org.eclipse.core.resources.IResource)2 SystemException (org.talend.commons.exception.SystemException)2 Item (org.talend.core.model.properties.Item)2 JobResource (org.talend.core.model.repository.job.JobResource)2 ITalendProcessJavaProject (org.talend.core.runtime.process.ITalendProcessJavaProject)2 ITalendSynchronizer (org.talend.designer.codegen.ITalendSynchronizer)2 ExportFileResource (org.talend.repository.documentation.ExportFileResource)2