Search in sources :

Example 11 with Problem

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

the class ProblemsAnalyser method checkInputLoopTablesProblem.

private void checkInputLoopTablesProblem(OutputXmlTree outputTree, InputXmlTree mainInputTree) {
    if (mainInputTree == null) {
        return;
    }
    if (mainInputTree.isMultiLoops()) {
        if (!XmlMapUtil.hasDocument(outputTree)) {
            if (outputTree.getInputLoopNodesTables().isEmpty() || outputTree.getInputLoopNodesTables().get(0).getInputloopnodes().isEmpty()) {
                String message = outputTree.getName() + " have no source loop";
                addProblem(outputTree, new Problem(null, message, ProblemStatus.ERROR));
            }
        } else {
            List<TreeNode> loopNodes = new ArrayList<TreeNode>();
            XmlMapUtil.getChildLoops(loopNodes, outputTree.getNodes());
            if (!loopNodes.isEmpty()) {
                for (TreeNode node : loopNodes) {
                    InputLoopNodesTable inutLoopTable = ((OutputTreeNode) node).getInputLoopNodesTable();
                    if (inutLoopTable == null || inutLoopTable.getInputloopnodes().isEmpty()) {
                        String message = node.getXpath() + " have no source loop";
                        addProblem(outputTree, new Problem(null, message, ProblemStatus.ERROR));
                    }
                }
            }
        }
    }
}
Also used : InputLoopNodesTable(org.talend.designer.xmlmap.model.emf.xmlmap.InputLoopNodesTable) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) ArrayList(java.util.ArrayList) Problem(org.talend.core.model.process.Problem) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)

Example 12 with Problem

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

the class ProblemsManager method addLookupProblem.

private void addLookupProblem(IColumnEntry entity) {
    List<Problem> problems = entity.getProblems();
    if (problems == null) {
        problems = new ArrayList<Problem>();
        entity.setProblems(problems);
    }
    // incase other entities already have this problem in list.
    boolean exist = false;
    for (Problem problem : problems) {
        if (problem.equals(lookupProblem)) {
            exist = true;
        }
    }
    if (!exist) {
        problems.add(lookupProblem);
    }
}
Also used : Problem(org.talend.core.model.process.Problem)

Example 13 with Problem

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

the class JavaCodeProblemsChecker method processDetailedProblems.

/**
     * DOC amaumont Comment method "processDetailedProblems".
     * 
     * @param list
     * @return
     */
private ArrayList<Problem> processDetailedProblems(List<DetailedProblem> list) {
    ArrayList<Problem> problems = null;
    if (list != null) {
        problems = new ArrayList<Problem>();
        for (DetailedProblem problemWithLine : list) {
            Problem talendProblem = new Problem();
            talendProblem.setDescription(//$NON-NLS-1$
            Messages.getString(//$NON-NLS-1$
            "JavaCodeProblemsChecker.processDetailError", new Object[] { problemWithLine.getSource(), problemWithLine.getJdtProblem().getMessage() }));
            talendProblem.setStatus(Problem.ProblemStatus.ERROR);
            talendProblem.setKey(problemWithLine.getKey());
            problems.add(talendProblem);
        }
    }
    return problems;
}
Also used : DetailedProblem(org.talend.designer.core.ui.editor.DetailedProblem) DetailedProblem(org.talend.designer.core.ui.editor.DetailedProblem) Problem(org.talend.core.model.process.Problem) IProblem(org.eclipse.jdt.core.compiler.IProblem)

Example 14 with Problem

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

the class ProblemsManager method checkProblemsForTableEntry.

public void checkProblemsForTableEntry(ITableEntry tableEntry, boolean forceRefreshData) {
    // if (forceRefreshData) {
    // mapperManager.getComponent().refreshMapperConnectorData();
    // checkProblems();
    // }
    List<Problem> problems = new ArrayList<Problem>(0);
    String expression = tableEntry.getExpression();
    if (tableEntry instanceof InputColumnTableEntry) {
        InputColumnTableEntry inputEntry = (InputColumnTableEntry) tableEntry;
        IDbOperatorManager operatorsManager = mapperManager.getCurrentLanguage().getOperatorsManager();
        IDbOperator dbOperator = operatorsManager.getOperatorFromValue(inputEntry.getOperator());
        boolean operatorIsSet = dbOperator != null;
        boolean expressionIsSet = expression != null && expression.trim().length() > 0;
        Problem problem = null;
        String errorMessage = null;
        String key = null;
        if (!operatorIsSet && expressionIsSet) {
            errorMessage = //$NON-NLS-1$
            Messages.getString(//$NON-NLS-1$
            "ProblemsManager.operatorNotSet", new Object[] { inputEntry.getName() });
            key = KEY_OPERATOR_EMPTY;
            problem = new Problem(null, errorMessage, ProblemStatus.ERROR);
            problem.setKey(key);
            problems.add(problem);
        }
        if (operatorIsSet && !expressionIsSet && !dbOperator.isMonoOperand()) {
            errorMessage = //$NON-NLS-1$
            Messages.getString(//$NON-NLS-1$
            "ProblemsManager.inputExpressionEmpty", new Object[] { inputEntry.getParentName(), inputEntry.getName() });
            key = KEY_INPUT_EXPRESSION_EMPTY;
            problem = new Problem(null, errorMessage, ProblemStatus.ERROR);
            problem.setKey(key);
            problems.add(problem);
        }
        Problem warningProblem = null;
        if (inputEntry.isUnmatchingEntry()) {
            InputTable inputTable = (InputTable) inputEntry.getParent();
            String message = //$NON-NLS-1$
            Messages.getString(//$NON-NLS-1$
            "ProblemsManager.entryDoesntMatch", new Object[] { inputEntry.getParentName(), inputEntry.getName(), inputTable.getTableName() });
            warningProblem = new Problem(null, message, ProblemStatus.WARNING);
            warningProblem.setKey(KEY_NO_MATCHING);
            problems.add(warningProblem);
        }
    } else if (tableEntry instanceof OutputColumnTableEntry) {
        String errorMessage = null;
        Problem problem = null;
        if (expression == null || EMPTY_STRING.equals(expression.trim())) {
            errorMessage = //$NON-NLS-1$
            Messages.getString(//$NON-NLS-1$
            "ProblemsManager.outputExpressionEmpty", new Object[] { tableEntry.getParentName(), tableEntry.getName() });
        }
        if (errorMessage != null) {
            problem = new Problem(null, errorMessage, ProblemStatus.ERROR);
            problem.setKey(KEY_OUTPUT_EXPRESSION_EMPTY);
            problems.add(problem);
        }
    }
    tableEntry.setProblems(problems.size() > 0 ? problems : null);
}
Also used : InputTable(org.talend.designer.dbmap.model.table.InputTable) ArrayList(java.util.ArrayList) Problem(org.talend.core.model.process.Problem) OutputColumnTableEntry(org.talend.designer.dbmap.model.tableentry.OutputColumnTableEntry) IDbOperator(org.talend.designer.dbmap.language.operator.IDbOperator) InputColumnTableEntry(org.talend.designer.dbmap.model.tableentry.InputColumnTableEntry) IDbOperatorManager(org.talend.designer.dbmap.language.operator.IDbOperatorManager)

Example 15 with Problem

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

Problem (org.talend.core.model.process.Problem)34 TalendProblem (org.talend.core.model.process.TalendProblem)15 ArrayList (java.util.ArrayList)10 IProblem (org.eclipse.jdt.core.compiler.IProblem)9 PersistenceException (org.talend.commons.exception.PersistenceException)4 IProcess (org.talend.core.model.process.IProcess)4 IFile (org.eclipse.core.resources.IFile)3 CoreException (org.eclipse.core.runtime.CoreException)3 SystemException (org.talend.commons.exception.SystemException)3 Item (org.talend.core.model.properties.Item)3 ITalendSynchronizer (org.talend.designer.codegen.ITalendSynchronizer)3 HashSet (java.util.HashSet)2 List (java.util.List)2 IMarker (org.eclipse.core.resources.IMarker)2 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)2 ProblemStatus (org.talend.core.model.process.Problem.ProblemStatus)2 Property (org.talend.core.model.properties.Property)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)2