use of org.talend.designer.runprocess.IRunProcessService in project tdi-studio-se by Talend.
the class Log4jSettingPage method performOk.
@Override
public boolean performOk() {
boolean ok = super.performOk();
if (templateTxt != null && !templateTxt.isDisposed()) {
IRunProcessService service = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
service = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
}
if (reset) {
if (service != null) {
Log4jPrefsSettingManager.getInstance().saveLog4jNodeIntoPref(Log4jPrefsConstants.LOG4J_ENABLE_NODE, String.valueOf(false));
Log4jPrefsSettingManager.getInstance().saveLog4jNodeIntoPref(Log4jPrefsConstants.LOG4J_CONTENT_NODE, service.getLogTemplate(Log4jPrefsConstants.LOG4JFILEPATH));
}
} else {
if (log4jBtn != null && !log4jBtn.isDisposed()) {
Log4jPrefsSettingManager.getInstance().saveLog4jNodeIntoPref(Log4jPrefsConstants.LOG4J_ENABLE_NODE, String.valueOf(log4jBtn.getSelection()));
}
Log4jPrefsSettingManager.getInstance().saveLog4jNodeIntoPref(Log4jPrefsConstants.LOG4J_CONTENT_NODE, templateTxt.getText());
}
reset = false;
}
// updat the log4j file for code project
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreService.class)) {
ICoreService service = (ICoreService) GlobalServiceRegister.getDefault().getService(ICoreService.class);
if (service != null) {
service.syncLog4jSettings();
}
}
return ok;
}
use of org.talend.designer.runprocess.IRunProcessService in project tdi-studio-se by Talend.
the class RepositoryPreferenceInitializer method getTemplateTxt.
private String getTemplateTxt(String path) {
IRunProcessService service = null;
String templateString = "";
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
service = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
}
if (service != null) {
templateString = service.getLogTemplate(path);
}
return templateString;
}
use of org.talend.designer.runprocess.IRunProcessService in project tdi-studio-se by Talend.
the class WSDL2JAVAController method syncRoutine.
/**
* DOC xtan there will be refactor for this method with JavaRoutineSynchronizer.syncRoutine().
*
* @param routineItem
* @param copyToTemp
* @return
* @throws SystemException
*/
private IFile syncRoutine(RoutineItem routineItem, boolean copyToTemp, String name) throws SystemException {
FileOutputStream fos = null;
try {
IRunProcessService service = DesignerPlugin.getDefault().getRunProcessService();
ITalendProcessJavaProject talendProcessJavaProject = service.getTalendProcessJavaProject();
if (talendProcessJavaProject == null) {
return null;
}
IFolder srcFolder = talendProcessJavaProject.getSrcFolder();
IFile file = srcFolder.getFile(JavaUtils.JAVA_ROUTINES_DIRECTORY + '/' + routineItem.getProperty().getLabel() + JavaUtils.JAVA_EXTENSION);
if (copyToTemp) {
String routineContent = new String(routineItem.getContent().getInnerContent());
routineContent = chanageRoutinesPackage(routineContent, name);
String label = routineItem.getProperty().getLabel();
if (!label.equals(ITalendSynchronizer.TEMPLATE)) {
routineContent = routineContent.replaceAll(ITalendSynchronizer.TEMPLATE, label);
File f = file.getLocation().toFile();
fos = new FileOutputStream(f);
fos.write(routineContent.getBytes());
fos.close();
}
}
if (!file.exists()) {
file.refreshLocal(1, null);
}
return file;
} catch (CoreException e) {
throw new SystemException(e);
} catch (IOException e) {
throw new SystemException(e);
} finally {
try {
fos.close();
} catch (Exception e) {
// ignore me even if i'm null
ExceptionHandler.process(e);
}
}
}
use of org.talend.designer.runprocess.IRunProcessService in project tdi-studio-se by Talend.
the class TalendJavaSourceViewer method createViewerWithVariables.
public static ReconcilerViewer createViewerWithVariables(Composite composite, int styles, IExpressionDataBean dataBean) {
IDocument document = new Document();
StringBuffer buff = new StringBuffer();
//$NON-NLS-1$
buff.append("\npackage internal;\n\n");
buff.append(getImports());
//$NON-NLS-1$ //$NON-NLS-2$
buff.append("public class " + VIEWER_CLASS_NAME + currentId + " {\n");
IRunProcessService runProcessService = getRunProcessService();
if (runProcessService != null && runProcessService.getSelectedContext() != null) {
List<IContextParameter> params = runProcessService.getSelectedContext().getContextParameterList();
buff.append(TEXT_1);
for (IContextParameter ctxParam : params) {
buff.append(TEXT_2);
buff.append(ctxParam.getName());
buff.append(TEXT_3);
buff.append(ctxParam.getName());
buff.append(TEXT_4);
}
buff.append(TEXT_5);
for (IContextParameter ctxParam : params) {
if (//$NON-NLS-1$ //$NON-NLS-2$
ctxParam.getType().equals("id_List Of Value") || ctxParam.getType().equals("id_File") || ctxParam.getType().equals("id_Directory") || ctxParam.getType().equals("id_Character")) {
//$NON-NLS-1$ //$NON-NLS-2$
buff.append(TEXT_6);
buff.append(ctxParam.getName());
buff.append(TEXT_7);
} else {
buff.append(TEXT_8);
buff.append(JavaTypesManager.getTypeToGenerate(ctxParam.getType(), true));
buff.append(TEXT_9);
buff.append(ctxParam.getName());
buff.append(TEXT_10);
}
}
buff.append(TEXT_11);
//$NON-NLS-1$
buff.append("\tprivate static ContextProperties context = new ContextProperties();\n");
//$NON-NLS-1$
buff.append("\tprivate static final java.util.Map<String, Object> globalMap = new java.util.HashMap<String, Object>();\n");
if (dataBean != null) {
buff.append(parseVariables(dataBean.getVariables()));
//$NON-NLS-1$ //$NON-NLS-2$
buff.append("\tpublic " + dataBean.getExpressionType() + " myFunction(){\n");
}
//$NON-NLS-1$
buff.append("\t\treturn \n");
}
int length = buff.toString().length();
//$NON-NLS-1$
String defaultValue = "";
//$NON-NLS-1$
buff.append(defaultValue + "\n;\t\n}\n}");
document.set(buff.toString());
return initializeViewer(composite, styles, true, document, length);
}
use of org.talend.designer.runprocess.IRunProcessService in project tdi-studio-se by Talend.
the class BDJobReArchieveCreator method create.
public void create(File file, boolean isExport) {
if (file == null || !file.exists() || (isExport && !file.isFile()) || fatherProcessItem == null) {
return;
}
// check
if (!isMRWithHDInsight() && !isFatJar()) {
return;
}
Property property = processItem.getProperty();
Property fatherProperty = fatherProcessItem.getProperty();
String label = property.getLabel();
String fatherLabel = fatherProperty.getLabel();
String version = property.getVersion();
JavaJobExportReArchieveCreator creator = new JavaJobExportReArchieveCreator(file.getAbsolutePath(), label);
String jobJarName = JavaResourcesHelper.getJobJarName(property.getLabel(), property.getVersion()) + FileExtensions.JAR_FILE_SUFFIX;
try {
if (isExport) {
// If we are in an export context, we first unzip the archive, then we modify the jar.
// create temp folders.
// clean temp folder
creator.deleteTempFiles();
//$NON-NLS-1$ //$NON-NLS-2$
File zipTmpFolder = new File(creator.getTmpFolder(), "zip-" + label + "_" + version);
//$NON-NLS-1$ //$NON-NLS-2$
File jarTmpFolder = new File(creator.getTmpFolder(), "jar-" + label + "_" + version);
zipTmpFolder.mkdirs();
jarTmpFolder.mkdirs();
// unzip the files.
FilesUtils.unzip(file.getAbsolutePath(), zipTmpFolder.getAbsolutePath());
// same the the job pom assembly for package.
File originalJarFile = new File(zipTmpFolder, fatherLabel + '/' + jobJarName);
modifyJar(originalJarFile, jarTmpFolder, creator, jobJarName, zipTmpFolder, property);
ZipToFile.zipFile(zipTmpFolder.getAbsolutePath(), file.getAbsolutePath());
} else {
// If we are in a local context, we just have to modify the jar.
// clean temp folder
creator.deleteTempFiles();
//$NON-NLS-1$ //$NON-NLS-2$
File jarTmpFolder = new File(creator.getTmpFolder(), "jar-" + label + "_" + version);
jarTmpFolder.mkdirs();
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
IRunProcessService service = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
ITalendProcessJavaProject talendProcessJavaProject = service.getTalendProcessJavaProject();
File targetFolder = new File(talendProcessJavaProject.getTargetFolder().getLocationURI());
// In a local mode, the routines/beans/udfs jars are not in the lib folder. We then copy them.
// Copy routines and rename it to match the
// "JavaUtils.ROUTINE_JAR_NAME + FileExtensions.JAR_FILE_SUFFIX" name
Set<FilterInfo> codeJars = new HashSet<FilterInfo>(Arrays.asList(new FilterInfo(JavaUtils.ROUTINE_JAR_NAME, FileExtensions.JAR_FILE_SUFFIX)));
for (File f : FileUtils.getAllFilesFromFolder(targetFolder, codeJars)) {
FilesUtils.copyFile(f, new File(talendProcessJavaProject.getLibFolder().getLocation().toPortableString() + "/" + JavaUtils.ROUTINE_JAR_NAME + //$NON-NLS-1$
FileExtensions.JAR_FILE_SUFFIX));
}
// Copy beans and rename it to match the "JavaUtils.BEANS_JAR_NAME + FileExtensions.JAR_FILE_SUFFIX"
// name
codeJars = new HashSet<FilterInfo>(Arrays.asList(new FilterInfo(JavaUtils.BEANS_JAR_NAME, FileExtensions.JAR_FILE_SUFFIX)));
for (File f : FileUtils.getAllFilesFromFolder(targetFolder, codeJars)) {
FilesUtils.copyFile(f, new File(talendProcessJavaProject.getLibFolder().getLocation().toPortableString() + "/" + JavaUtils.BEANS_JAR_NAME + //$NON-NLS-1$
FileExtensions.JAR_FILE_SUFFIX));
}
// Copy udfs and rename it to match the
// "JavaUtils.PIGUDFS_JAR_NAME + FileExtensions.JAR_FILE_SUFFIX"
// name
codeJars = new HashSet<FilterInfo>(Arrays.asList(new FilterInfo(JavaUtils.PIGUDFS_JAR_NAME, FileExtensions.JAR_FILE_SUFFIX)));
for (File f : FileUtils.getAllFilesFromFolder(targetFolder, codeJars)) {
FilesUtils.copyFile(f, new File(talendProcessJavaProject.getLibFolder().getLocation().toPortableString() + "/" + JavaUtils.PIGUDFS_JAR_NAME + //$NON-NLS-1$
FileExtensions.JAR_FILE_SUFFIX));
}
modifyJar(new File(file, jobJarName), jarTmpFolder, creator, jobJarName, talendProcessJavaProject.getLibFolder().getParent().getLocation().toFile(), property);
} else {
//$NON-NLS-1$
CommonExceptionHandler.log("Unable to update the job jar because the RunProcessService is not registered.");
}
}
} catch (Exception e) {
ExceptionHandler.process(e);
} finally {
// when debug, keep the files first. because when build again. will do clean also.
if (!CommonsPlugin.isDebugMode()) {
creator.deleteTempFiles();
}
}
}
Aggregations