Search in sources :

Example 1 with IContainerEntry

use of org.talend.core.model.process.IContainerEntry 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)

Aggregations

ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 IFile (org.eclipse.core.resources.IFile)1 CoreException (org.eclipse.core.runtime.CoreException)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 SystemException (org.talend.commons.exception.SystemException)1 IContainerEntry (org.talend.core.model.process.IContainerEntry)1 JobInfo (org.talend.core.model.process.JobInfo)1 Problem (org.talend.core.model.process.Problem)1 TalendProblem (org.talend.core.model.process.TalendProblem)1 Item (org.talend.core.model.properties.Item)1 Property (org.talend.core.model.properties.Property)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 ITalendSynchronizer (org.talend.designer.codegen.ITalendSynchronizer)1 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)1