use of org.talend.designer.codegen.ITalendSynchronizer in project tdi-studio-se by Talend.
the class ProblemsView method restoreProblem.
/**
*
* ggu Comment method "restoreProblem".
*
* when restore the item, check the problem.
*/
private void restoreProblem(RoutineItem item) {
ICodeGeneratorService service = (ICodeGeneratorService) GlobalServiceRegister.getDefault().getService(ICodeGeneratorService.class);
ITalendSynchronizer routineSynchronizer = null;
switch(LanguageManager.getCurrentLanguage()) {
case JAVA:
routineSynchronizer = service.createJavaRoutineSynchronizer();
break;
case PERL:
routineSynchronizer = service.createPerlRoutineSynchronizer();
break;
default:
}
if (routineSynchronizer != null) {
try {
routineSynchronizer.syncRoutine(item, true);
IFile file = routineSynchronizer.getFile(item);
if (file == null) {
return;
}
file.refreshLocal(IResource.DEPTH_ONE, null);
Problems.addRoutineFile(file, item.getProperty());
} catch (SystemException e) {
ExceptionHandler.process(e);
} catch (CoreException e) {
ExceptionHandler.process(e);
}
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
Problems.refreshProblemTreeView();
}
});
}
}
use of org.talend.designer.codegen.ITalendSynchronizer in project tdi-studio-se by Talend.
the class JavaCompilationParticipant method updateProblems.
/**
* yzhang Comment method "updateProblems".
*/
private void updateProblems(List<IRepositoryViewObject> routineObjectList, String filePath) {
IRunProcessService runProcessService = CorePlugin.getDefault().getRunProcessService();
try {
ITalendProcessJavaProject talendProcessJavaProject = runProcessService.getTalendProcessJavaProject();
if (talendProcessJavaProject == null) {
return;
}
final ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
IProject javaProject = talendProcessJavaProject.getProject();
IFile file = javaProject.getFile(filePath);
String fileName = file.getName();
for (IRepositoryViewObject repositoryObject : routineObjectList) {
Property property = repositoryObject.getProperty();
Item item = property.getItem();
IFile currentFile = synchronizer.getFile(item);
if (currentFile != null && fileName.equals(currentFile.getName()) && currentFile.exists()) {
Problems.addRoutineFile(currentFile, property);
break;
}
}
} catch (SystemException e) {
ExceptionHandler.process(e);
}
}
use of org.talend.designer.codegen.ITalendSynchronizer in project tdi-studio-se by Talend.
the class JobErrorsChecker method checkLastGenerationHasCompilationError.
public static void checkLastGenerationHasCompilationError(boolean updateProblemsView) throws ProcessorException {
if (updateProblemsView && CommonsPlugin.isHeadless()) {
updateProblemsView = false;
}
boolean hasError = false;
boolean isJob = true;
Item item = null;
final IProxyRepositoryFactory proxyRepositoryFactory = CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
final ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
Integer line = null;
String errorMessage = null;
try {
for (JobInfo jobInfo : LastGenerationInfo.getInstance().getLastGeneratedjobs()) {
if (jobInfo.isTestContainer()) {
continue;
}
item = null;
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;
}
IFile file = synchronizer.getFile(item);
if (file == null) {
return;
}
// check other java files related to the job . example : spark job will generate several java file for
// one job
final IResource[] members = file.getParent().members();
for (IResource member : members) {
if (member instanceof IFile && "java".equals(member.getFileExtension())) {
IMarker[] markers = ((IFile) member).findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ONE);
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) {
switch(severity) {
case IMarker.SEVERITY_ERROR:
hasError = true;
line = lineNr;
errorMessage = message;
break;
default:
break;
}
}
}
}
}
if (updateProblemsView) {
Problems.addRoutineFile(file, ProblemType.JOB, item.getProperty().getLabel(), item.getProperty().getVersion(), true);
}
if (hasError) {
break;
}
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
if (hasError && item != null) {
if (isJob) {
throw new ProcessorException(//$NON-NLS-1$
Messages.getString("JobErrorsChecker_compile_errors") + " " + '\n' + Messages.getString("JobErrorsChecker_compile_error_message", item.getProperty().getLabel()) + //$NON-NLS-1$
'\n' + Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + //$NON-NLS-1$
'\n' + Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + errorMessage + //$NON-NLS-1$
'\n' + //$NON-NLS-1$
Messages.getString("JobErrorsChecker_compile_error_jvmmessage"));
} else {
throw new ProcessorException(//$NON-NLS-1$
Messages.getString("CamelJobErrorsChecker_compile_errors") + " " + '\n' + Messages.getString("JobErrorsChecker_compile_error_message", item.getProperty().getLabel()) + //$NON-NLS-1$
'\n' + Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + //$NON-NLS-1$
'\n' + Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + errorMessage + //$NON-NLS-1$
'\n' + //$NON-NLS-1$
Messages.getString("JobErrorsChecker_compile_error_jvmmessage"));
}
}
// if no error for job, check codes.
checkRoutinesCompilationError();
}
Aggregations