use of org.talend.core.model.process.IProcess in project tdi-studio-se by Talend.
the class SpagicJavaDeployManager method getExportResources.
@Override
public List<ExportFileResource> getExportResources(ExportFileResource[] process, String... codeOptions) throws ProcessorException {
for (ExportFileResource proces : process) {
ProcessItem processItem = (ProcessItem) proces.getItem();
ProcessorUtilities.setExportConfig(proces.getDirectoryName(), true);
IProcess jobProcess = null;
if (!isOptionChoosed(ExportChoice.doNotCompileCode)) {
jobProcess = generateJobFiles(processItem, contextName, statisticPort != IProcessor.NO_STATISTICS, tracePort != IProcessor.NO_TRACES, isOptionChoosed(ExportChoice.applyToChildren));
}
List<URL> resources = new ArrayList<URL>();
resources.addAll(getLauncher(isOptionChoosed(ExportChoice.needLauncher), isOptionChoosed(ExportChoice.needParameterValues), isOptionChoosed(ExportChoice.needContext), jobProcess, processItem, escapeSpace(contextName), escapeSpace(launcher), statisticPort, tracePort, codeOptions));
addJobItem(process, processItem, isOptionChoosed(ExportChoice.needJobItem), proces);
resources.addAll(getJobScripts(processItem, isOptionChoosed(ExportChoice.needJobScript)));
// resources.addAll(getProperties(processItem, srcList));
resources.addAll(getProperties(processItem, contextName));
addContextScripts(proces, isOptionChoosed(ExportChoice.needContext));
// add children jobs
boolean needChildren = true;
List<URL> childrenList = addChildrenResources(process, processItem, needChildren, proces, exportChoice);
resources.addAll(childrenList);
proces.addResources(resources);
// Gets job designer resouce
// List<URL> srcList = getSource(processItem, exportChoice.get(ExportChoice.needSource));
// process[i].addResources(JOB_SOURCE_FOLDER_NAME, srcList);
}
// Exports the system libs
List<ExportFileResource> list = new ArrayList<ExportFileResource>(Arrays.asList(process));
// Add the java system libraries
ExportFileResource rootResource = new ExportFileResource(null, LIBRARY_FOLDER_NAME);
//$NON-NLS-1$
ExportFileResource spagicResource = new ExportFileResource(null, "");
list.add(rootResource);
list.add(spagicResource);
// Gets system routines
if (isOptionChoosed(ExportChoice.needSystemRoutine)) {
rootResource.addResources(getSystemRoutine(process));
}
// Gets user routines
if (isOptionChoosed(ExportChoice.needUserRoutine)) {
rootResource.addResources(getUserRoutine(process));
}
// Gets talend libraries
List<URL> talendLibraries = getExternalLibraries(isOptionChoosed(ExportChoice.needTalendLibraries), process);
rootResource.addResources(talendLibraries);
return list;
}
use of org.talend.core.model.process.IProcess in project tdi-studio-se by Talend.
the class SpagicJavaDeployManager method getProperties.
public List<URL> getProperties(ProcessItem processItem, String contextName) {
List<URL> list = new ArrayList<URL>();
Properties p = new Properties();
FileOutputStream out = null;
String projectName = getCorrespondingProjectName(processItem);
String jobName = processItem.getProperty().getLabel();
String jobFolderName = JavaResourcesHelper.getJobFolderName(escapeFileNameSpace(processItem), processItem.getProperty().getVersion());
try {
// List<SpagoBiServer> listServerSapgo = null;
// listServerSapgo = SpagicServerHelper.parse(new SpagicPreferencePage().getPreferenceStore().getString(
// SpagoBiServer.SPAGOBI_SERVER));
// if (listServerSapgo != null && !listServerSapgo.isEmpty()) {
// Iterator<SpagoBiServer> iterator = listServerSapgo.iterator();
// while (iterator.hasNext()) {
// SpagoBiServer spagoBiServer = iterator.next();
// }
// }
IPath path = getSrcRootLocation();
//$NON-NLS-1$
File file = new File(getTmpFolder() + PATH_SEPARATOR + "spagic.properties");
//$NON-NLS-1$
path = path.append(projectName).append(jobFolderName).append(jobName + ".java");
BufferedReader buff = new BufferedReader(new FileReader(path.toPortableString()));
int nbLine = 0;
while (buff.readLine() != null) {
nbLine++;
}
out = new FileOutputStream(file);
PrintStream ps = new PrintStream(out);
IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
IProcess process = service.getProcessFromProcessItem(processItem);
List<IContextParameter> ctxParams = process.getContextManager().getContext(contextName).getContextParameterList();
for (IContextParameter ctxParam : ctxParams) {
p.put(ctxParam.getName(), ctxParam.getValue());
}
p.put("JobClassName", //$NON-NLS-1$
getCorrespondingProjectName(null) + //$NON-NLS-1$
"." + JavaResourcesHelper.getJobFolderName(processItem.getProperty().getLabel(), processItem.getProperty().getVersion()) + "." + //$NON-NLS-1$
processItem.getProperty().getLabel());
//$NON-NLS-1$
p.put("talendJobClassDescription", HTMLDocUtils.checkString(processItem.getProperty().getDescription()));
//$NON-NLS-1$
p.put("rowNumber", Integer.toString(nbLine));
//$NON-NLS-1$ //$NON-NLS-2$
p.put("host", "localhost");
p.list(ps);
ps.flush();
list.add(file.toURI().toURL());
} catch (Exception e) {
ExceptionHandler.process(e);
} finally {
if (out != null) {
try {
out.close();
} catch (Exception e) {
}
}
}
return list;
}
use of org.talend.core.model.process.IProcess in project tdi-studio-se by Talend.
the class MapperUI method openNewOutputCreationDialog.
public String openNewOutputCreationDialog() {
final IProcess process = mapperManager.getMapperComponent().getProcess();
//$NON-NLS-1$
String outputName = process.generateUniqueConnectionName("out");
InputDialog id = new InputDialog(mapperShell, "Add a output", "New Output :", outputName, new IInputValidator() {
@Override
public String isValid(String newText) {
if (!process.checkValidConnectionName(newText)) {
return "Output is invalid.";
}
return null;
}
});
int response = id.open();
if (response == InputDialog.OK) {
return id.getValue();
}
return null;
}
use of org.talend.core.model.process.IProcess in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method getExternalLibraries.
/**
* Gets required java jars.
*
* @param process
*
* @param boolean1
* @return
*/
protected List<URL> getExternalLibraries(boolean needLibraries, ExportFileResource[] process, final Set<String> neededLibraries) {
List<URL> list = new ArrayList<URL>();
if (!needLibraries) {
return list;
}
IFolder libFolder = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
IRunProcessService processService = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
ITalendProcessJavaProject talendProcessJavaProject = processService.getTalendProcessJavaProject();
if (talendProcessJavaProject != null) {
libFolder = talendProcessJavaProject.getLibFolder();
}
}
if (libFolder == null) {
return list;
}
File file = libFolder.getLocation().toFile();
File[] files = file.listFiles(FilesUtils.getAcceptModuleFilesFilter());
// Lists all the needed jar files
Set<String> listModulesReallyNeeded = new HashSet<String>();
if (neededLibraries == null) {
// in case export as been done with option "not recompile", then libraires can't be retrieved when build.
IDesignerCoreService designerService = RepositoryPlugin.getDefault().getDesignerCoreService();
for (ExportFileResource resource : process) {
ProcessItem item = (ProcessItem) resource.getItem();
String version = item.getProperty().getVersion();
if (!isMultiNodes() && this.getSelectedJobVersion() != null) {
version = this.getSelectedJobVersion();
}
ProcessItem selectedProcessItem;
if (resource.getNode() != null) {
selectedProcessItem = ItemCacheManager.getProcessItem(resource.getNode().getRoot().getProject(), item.getProperty().getId(), version);
} else {
// if no node given, take in the current project only
selectedProcessItem = ItemCacheManager.getProcessItem(item.getProperty().getId(), version);
}
IProcess iProcess = designerService.getProcessFromProcessItem(selectedProcessItem);
Set<String> processNeededLibraries = iProcess.getNeededLibraries(true);
if (processNeededLibraries != null) {
listModulesReallyNeeded.addAll(processNeededLibraries);
}
}
} else {
listModulesReallyNeeded.addAll(neededLibraries);
}
// jar from routines
List<IRepositoryViewObject> collectRoutines = new ArrayList<IRepositoryViewObject>();
boolean useBeans = false;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
if (camelService.isInstanceofCamel(process[0].getItem())) {
useBeans = true;
}
}
String include = null;
if (useBeans) {
include = USER_BEANS_PATH;
} else {
include = USER_ROUTINES_PATH;
}
collectRoutines.addAll(collectRoutines(process, include));
collectRoutines.addAll(collectRoutines(process, USER_PIGUDF_PATH));
for (IRepositoryViewObject object : collectRoutines) {
Item item = object.getProperty().getItem();
if (item instanceof RoutineItem) {
RoutineItem routine = (RoutineItem) item;
EList imports = routine.getImports();
for (Object o : imports) {
IMPORTType type = (IMPORTType) o;
listModulesReallyNeeded.add(type.getMODULE());
}
}
}
if (Log4jPrefsSettingManager.getInstance().isLog4jEnable()) {
addLog4jToJarList(listModulesReallyNeeded);
}
for (File tempFile : files) {
try {
if (listModulesReallyNeeded.contains(tempFile.getName())) {
list.add(tempFile.toURL());
}
} catch (MalformedURLException e) {
ExceptionHandler.process(e);
}
}
return list;
// List<URL> libraries = new ArrayList<URL>();
// if (needLibraries) {
// try {
// ILibrariesService service = CorePlugin.getDefault().getLibrariesService();
// libraries = service.getTalendRoutines();
// } catch (Exception e) {
// ExceptionHandler.process(e);
// }
// }
// return libraries;
}
use of org.talend.core.model.process.IProcess in project tdi-studio-se by Talend.
the class JobScriptsManager method getCommandByTalendJob.
protected String getCommandByTalendJob(String targetPlatform, ProcessItem processItem, String context, boolean needContext, int statisticPort, int tracePort, String... codeOptions) {
String[] cmd = new String[] {};
try {
IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
IProcess currentProcess = service.getProcessFromProcessItem(processItem);
cmd = ProcessorUtilities.getCommandLine(true, targetPlatform, true, currentProcess, processItem.getProperty(), context, needContext, statisticPort, tracePort, codeOptions);
} catch (ProcessorException e) {
ExceptionHandler.process(e);
}
return ProcessorUtilities.generateCmdByTalendJob(cmd);
}
Aggregations