Search in sources :

Example 1 with Information

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

the class Problems method computePropertyMaxInformationLevel.

/**
     * See also AbstractEMFRepositoryFactory.computePropertyMaxInformationLevel
     * 
     * @param property
     */
public static void computePropertyMaxInformationLevel(Property property, boolean allowUpdateProperty) {
    EList<Information> informations = property.getInformations();
    InformationLevel maxLevel = null;
    for (int i = 0; i < informations.size(); i++) {
        Information information = informations.get(i);
        if (i == 0) {
            maxLevel = information.getLevel();
            continue;
        }
        int value = information.getLevel().getValue();
        if (maxLevel == null || value > maxLevel.getValue()) {
            maxLevel = information.getLevel();
        }
    }
    // TDI-22098
    // after run the job , if the modified the property ,should be save .
    InformationLevel propertyMaxLevel = property.getMaxInformationLevel();
    boolean isModified = false;
    if (maxLevel != null) {
        if (!maxLevel.equals(propertyMaxLevel)) {
            property.setMaxInformationLevel(maxLevel);
            isModified = true;
        }
    } else if (!InformationLevel.DEBUG_LITERAL.equals(propertyMaxLevel)) {
        property.setMaxInformationLevel(InformationLevel.DEBUG_LITERAL);
        isModified = true;
    }
    // save the property
    if (isModified && allowUpdateProperty) {
        IRepositoryService service = CorePlugin.getDefault().getRepositoryService();
        IProxyRepositoryFactory factory = service.getProxyRepositoryFactory();
        Item item = property.getItem();
        try {
            factory.save(item, false);
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
        }
    }
}
Also used : Item(org.talend.core.model.properties.Item) RoutineItem(org.talend.core.model.properties.RoutineItem) ProcessItem(org.talend.core.model.properties.ProcessItem) PersistenceException(org.talend.commons.exception.PersistenceException) InformationLevel(org.talend.core.model.properties.InformationLevel) Information(org.talend.core.model.properties.Information) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) IRepositoryService(org.talend.repository.model.IRepositoryService)

Example 2 with Information

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

the class Problems method addRoutineFile.

/**
     * 
     * ggu Comment method "addRoutineFile".
     * 
     * 
     */
public static List<Information> addRoutineFile(IFile file, ProblemType type, String label, String version, boolean... fromJob) {
    if (file == null || !file.exists()) {
        return Collections.emptyList();
    }
    String uniName = null;
    List<Information> informations = new ArrayList<Information>();
    try {
        IMarker[] markers = file.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ONE);
        Problems.clearAllComliationError(label);
        for (IMarker marker : markers) {
            Integer lineNr = (Integer) marker.getAttribute(IMarker.LINE_NUMBER);
            String message = (String) marker.getAttribute(IMarker.MESSAGE);
            Integer severity = (Integer) marker.getAttribute(IMarker.SEVERITY);
            Integer start = (Integer) marker.getAttribute(IMarker.CHAR_START);
            Integer end = (Integer) marker.getAttribute(IMarker.CHAR_END);
            if (lineNr != null && message != null && severity != null && start != null && end != null) {
                Information information = PropertiesFactory.eINSTANCE.createInformation();
                information.setText(message);
                informations.add(information);
                ProblemStatus status = null;
                switch(severity) {
                    case IMarker.SEVERITY_ERROR:
                        status = ProblemStatus.ERROR;
                        information.setLevel(InformationLevel.ERROR_LITERAL);
                        IPath location = file.getLocation();
                        if (location != null) {
                            String path = location.toString();
                            uniName = setErrorMark(path, lineNr);
                        }
                        break;
                    case IMarker.SEVERITY_WARNING:
                        status = ProblemStatus.WARNING;
                        information.setLevel(InformationLevel.WARN_LITERAL);
                        break;
                    case IMarker.SEVERITY_INFO:
                        status = ProblemStatus.INFO;
                        information.setLevel(InformationLevel.INFO_LITERAL);
                        break;
                    default:
                        break;
                }
                if (status != null) {
                    if (status != ProblemStatus.ERROR) {
                        continue;
                    }
                    if ("".equals(uniName) || uniName == null) {
                        //$NON-NLS-1$
                        //$NON-NLS-1$
                        uniName = "uniName";
                    }
                    add(status, marker, label, message, lineNr, uniName, start, end, type, version);
                }
            }
        }
        if (fromJob.length > 0 && fromJob[0]) {
            addErrorMark();
        }
    } catch (org.eclipse.core.runtime.CoreException e) {
        ExceptionHandler.process(e);
    }
    return informations;
}
Also used : ProblemStatus(org.talend.core.model.process.Problem.ProblemStatus) IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) CoreException(org.eclipse.core.runtime.CoreException) IMarker(org.eclipse.core.resources.IMarker) Information(org.talend.core.model.properties.Information)

Example 3 with Information

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

the class Problems method addJobRoutineFile.

public static List<Information> addJobRoutineFile(IFile file, ProblemType type, Item item, boolean... fromJob) {
    if (file == null || !file.exists()) {
        return Collections.emptyList();
    }
    String uniName = null;
    List<Information> informations = new ArrayList<Information>();
    try {
        Set<IMarker> fullMarker = new HashSet<IMarker>();
        IMarker[] markers = file.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ONE);
        if (markers != null) {
            fullMarker.addAll(Arrays.asList(markers));
        }
        // remove old
        Problems.clearAllComliationError(item.getProperty().getLabel());
        for (IMarker marker : fullMarker) {
            Integer lineNr = (Integer) marker.getAttribute(IMarker.LINE_NUMBER);
            String message = (String) marker.getAttribute(IMarker.MESSAGE);
            Integer severity = (Integer) marker.getAttribute(IMarker.SEVERITY);
            Integer start = (Integer) marker.getAttribute(IMarker.CHAR_START);
            Integer end = (Integer) marker.getAttribute(IMarker.CHAR_END);
            if (lineNr != null && message != null && severity != null && start != null && end != null) {
                Information information = PropertiesFactory.eINSTANCE.createInformation();
                information.setText(message);
                informations.add(information);
                ProblemStatus status = null;
                switch(severity) {
                    case IMarker.SEVERITY_ERROR:
                        status = ProblemStatus.ERROR;
                        information.setLevel(InformationLevel.ERROR_LITERAL);
                        IPath location = file.getLocation();
                        if (location != null) {
                            String path = location.toString();
                            uniName = setErrorMark(path, lineNr);
                        }
                        break;
                    case IMarker.SEVERITY_WARNING:
                        status = ProblemStatus.WARNING;
                        information.setLevel(InformationLevel.WARN_LITERAL);
                        break;
                    case IMarker.SEVERITY_INFO:
                        status = ProblemStatus.INFO;
                        information.setLevel(InformationLevel.INFO_LITERAL);
                        break;
                    default:
                        break;
                }
                if (status != null) {
                    if (status != ProblemStatus.ERROR) {
                        continue;
                    }
                    if ("".equals(uniName) || uniName == null) {
                        //$NON-NLS-1$
                        //$NON-NLS-1$
                        uniName = "uniName";
                    }
                    add(status, marker, item, message, lineNr, uniName, start, end, type);
                }
            }
        }
        // TalendProcessJavaProject.buildModules for buildWholeCodeProject (about line 324)
        if (!buildWholeProject) {
            addAll(computeCompilationUnit(file, type, item));
        }
        if (fromJob.length > 0 && fromJob[0]) {
            addErrorMark();
        }
    } catch (org.eclipse.core.runtime.CoreException e) {
        ExceptionHandler.process(e);
    }
    return informations;
}
Also used : IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) CoreException(org.eclipse.core.runtime.CoreException) Information(org.talend.core.model.properties.Information) ProblemStatus(org.talend.core.model.process.Problem.ProblemStatus) IMarker(org.eclipse.core.resources.IMarker) HashSet(java.util.HashSet)

Example 4 with Information

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

the class Problems method addRoutineFile.

public static List<Information> addRoutineFile(IFile file, final Property property, boolean... fromJob) {
    if (file == null) {
        return Collections.emptyList();
    }
    String routineFileName = null;
    String version = null;
    if (property == null) {
        routineFileName = getFileName(file);
    } else {
        routineFileName = property.getLabel();
        version = property.getVersion();
    }
    ProblemType type = ProblemType.NONE;
    if (property.getItem() instanceof RoutineItem) {
        type = ProblemType.ROUTINE;
    } else if (property.getItem() instanceof ProcessItem) {
        type = ProblemType.JOB;
    }
    List<Information> listInfos = addRoutineFile(file, type, routineFileName, version, fromJob);
    if (property == null || listInfos == null) {
        return Collections.emptyList();
    }
    return listInfos;
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) ProblemType(org.talend.core.model.process.Problem.ProblemType) RoutineItem(org.talend.core.model.properties.RoutineItem) Information(org.talend.core.model.properties.Information)

Example 5 with Information

use of org.talend.core.model.properties.Information in project tesb-studio-se by Talend.

the class ESBRepositoryContentHandler method computePropertyMaxInformationLevel.

private void computePropertyMaxInformationLevel(Property property) {
    EList<Information> informations = property.getInformations();
    InformationLevel maxLevel = null;
    for (Information information : informations) {
        int value = information.getLevel().getValue();
        if (maxLevel == null || value > maxLevel.getValue()) {
            maxLevel = information.getLevel();
        }
    }
    property.setMaxInformationLevel(maxLevel);
}
Also used : InformationLevel(org.talend.core.model.properties.InformationLevel) Information(org.talend.core.model.properties.Information)

Aggregations

Information (org.talend.core.model.properties.Information)6 ArrayList (java.util.ArrayList)2 IMarker (org.eclipse.core.resources.IMarker)2 CoreException (org.eclipse.core.runtime.CoreException)2 IPath (org.eclipse.core.runtime.IPath)2 ProblemStatus (org.talend.core.model.process.Problem.ProblemStatus)2 InformationLevel (org.talend.core.model.properties.InformationLevel)2 ProcessItem (org.talend.core.model.properties.ProcessItem)2 RoutineItem (org.talend.core.model.properties.RoutineItem)2 HashSet (java.util.HashSet)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 ProblemType (org.talend.core.model.process.Problem.ProblemType)1 Item (org.talend.core.model.properties.Item)1 Property (org.talend.core.model.properties.Property)1 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)1 IRepositoryService (org.talend.repository.model.IRepositoryService)1