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);
}
}
}
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;
}
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;
}
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;
}
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);
}
Aggregations