use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class MultiPageTalendEditor method setName.
/**
* DOC smallet Comment method "setName".
*
* @param label
*/
@Override
public void setName() {
if (getEditorInput() == null) {
return;
}
super.setName();
IProcess2 process2 = this.getProcess();
if (process2 == null) {
return;
}
Property property = process2.getProperty();
if (property == null) {
return;
}
String label = property.getDisplayName();
//$NON-NLS-1$
String jobVersion = "0.1";
if (process2 != null) {
jobVersion = process2.getVersion();
}
// if (getActivePage() == 1) {
ISVNProviderService service = null;
if (PluginChecker.isSVNProviderPluginLoaded()) {
service = (ISVNProviderService) GlobalServiceRegister.getDefault().getService(ISVNProviderService.class);
if (revisionChanged && service.isProjectInSvnMode()) {
revisionNumStr = service.getCurrentSVNRevision(process2);
revisionChanged = false;
if (revisionNumStr != null) {
//$NON-NLS-1$
revisionNumStr = ".r" + revisionNumStr;
}
}
}
//$NON-NLS-1$
String title = "MultiPageTalendEditor.Job";
if (process2 != null) {
Item item = process2.getProperty().getItem();
if (item instanceof JobletProcessItem) {
//$NON-NLS-1$
title = "MultiPageTalendEditor.Joblet";
}
}
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
boolean allowVerchange = brandingService.getBrandingConfiguration().isAllowChengeVersion();
if (allowVerchange) {
if (revisionNumStr != null) {
setPartName(Messages.getString(title, label, jobVersion) + revisionNumStr);
} else {
setPartName(Messages.getString(title, label, jobVersion));
}
} else {
if (revisionNumStr != null) {
//$NON-NLS-1$
setPartName(Messages.getString(title, label, "") + revisionNumStr);
} else {
//$NON-NLS-1$
setPartName(Messages.getString(title, label, ""));
}
}
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class AbstractMultiPageTalendEditor method refreshProcess.
/**
* Refresh the editor/process to the given refreshedItem version
*
* @param refreshedItem
* @param force
*/
private void refreshProcess(final Item refreshedItem, boolean force) {
Item currentItem = processEditorInput.getItem();
if (isStorageVersionChanged(refreshedItem, currentItem) || force) {
processEditorInput.setItem(refreshedItem);
final IProcess2 process = processEditorInput.getLoadedProcess();
getSite().getShell().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
process.setProperty(refreshedItem.getProperty());
process.updateProperties();
ProcessType processType = null;
if (refreshedItem instanceof ProcessItem) {
processType = ((ProcessItem) refreshedItem).getProcess();
} else if (refreshedItem instanceof JobletProcessItem) {
processType = ((JobletProcessItem) refreshedItem).getJobletProcess();
} else {
//$NON-NLS-1$
ExceptionHandler.process(new Exception("Mismatched case"));
}
if (processType != null) {
((Process) process).updateProcess(processType);
}
process.refreshProcess();
revisionChanged = true;
setName();
}
});
}
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class AbstractMultiPageTalendEditor method createPage1.
/**
* Creates page 1 of the multi-page editor, which allows you to change the font used in page 2.
*/
protected void createPage1() {
IProcess2 process = getProcess();
codeEditor = CodeEditorFactory.getInstance().getCodeEditor(getCurrentLang(), process);
processor = ProcessorUtilities.getProcessor(process, process.getProperty(), process.getContextManager().getDefaultContext());
if (processor instanceof IJavaBreakpointListener) {
JDIDebugModel.addJavaBreakpointListener((IJavaBreakpointListener) processor);
}
processor.setProcessorStates(IProcessor.STATES_EDIT);
if (codeEditor instanceof ISyntaxCheckableEditor) {
processor.setSyntaxCheckableEditor((ISyntaxCheckableEditor) codeEditor);
}
if (useCodeView) {
try {
IEditorInput editorInput = createFileEditorInput();
if (!(process.getProperty().getItem() instanceof ProcessItem)) {
// shouldn't work for joblet
editorInput = new JobletCodeEditInput();
}
int index = addPage(codeEditor, editorInput);
// init Syntax Validation.
//$NON-NLS-1$
setPageText(index, "Code");
} catch (PartInitException pie) {
// pie.printStackTrace();
ExceptionHandler.process(pie);
}
}
if (DesignerPlugin.getDefault().getPreferenceStore().getBoolean(TalendDesignerPrefConstants.GENERATE_CODE_WHEN_OPEN_JOB)) {
generateCode();
}
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class ElementParameter2ParameterType method loadProjectsettingsParameters.
/**
* DOC zli Comment method "loadProjectsettingsParameters".
*
* @param parameters
*/
public static void loadProjectsettingsParameters(ParametersType parameters) {
IEditorReference[] reference = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
IDesignerCoreService designerCoreService = CorePlugin.getDefault().getDesignerCoreService();
designerCoreService.switchToCurJobSettingsView();
List<IProcess2> openedProcess = designerCoreService.getOpenedProcess(reference);
for (IProcess2 process : openedProcess) {
if (process instanceof Element) {
Element processElem = (Element) process;
ElementParameter2ParameterType.loadElementParameters(processElem, parameters, null);
}
process.setNeedRegenerateCode(true);
}
IProxyRepositoryFactory repositoryFactory = CorePlugin.getDefault().getProxyRepositoryFactory();
IProcess process = null;
try {
List<IRepositoryViewObject> all = repositoryFactory.getAll(ERepositoryObjectType.PROCESS);
for (IRepositoryViewObject object : all) {
if (!openedProcess.contains(object)) {
Item item = object.getProperty().getItem();
if (item instanceof ProcessItem) {
process = designerCoreService.getProcessFromProcessItem((ProcessItem) item);
if (process != null && process instanceof IProcess2) {
IProcess2 process2 = (IProcess2) process;
if (process2 instanceof Element) {
Element processElem = (Element) process2;
ElementParameter2ParameterType.loadElementParameters(processElem, parameters, null);
ProcessType processType = process2.saveXmlFile();
if (processType != null) {
((ProcessItem) item).setProcess(processType);
}
repositoryFactory.save(item);
}
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class BigDataJavaProcessor method extractArgumentSegments.
@Override
public List<String> extractArgumentSegments() {
List<String> list = new ArrayList<>();
list.add(ProcessorConstants.CMD_KEY_WORD_LIBJAR);
StringBuffer libJars = new StringBuffer();
Set<String> libNames = null;
boolean isExport = isExportConfig() || isRunAsExport();
if (process instanceof IProcess2) {
if (isExport) {
// In an export mode, all the dependencies and the routines/beans/udfs are packaged in the lib folder.
libNames = JavaProcessorUtilities.extractLibNamesOnlyForMapperAndReducer((IProcess2) process);
} else {
// In the local mode, all the dependencies are packaged in the lib folder. The routines/beans/udfs are
// not.
// We will
// handle them separetely.
libNames = JavaProcessorUtilities.extractLibNamesOnlyForMapperAndReducerWithoutRoutines((IProcess2) process);
}
}
File libDir = JavaProcessorUtilities.getJavaProjectLibFolder();
File targetDir = new File(JavaProcessorUtilities.getTalendJavaProject().getTargetFolder().getLocationURI());
//$NON-NLS-1$
String libFolder = "";
if (libDir != null) {
libFolder = new Path(libDir.getAbsolutePath()).toPortableString();
}
// StringBuffer.
if (libNames != null && libNames.size() > 0) {
Iterator<String> itLibNames = libNames.iterator();
while (itLibNames.hasNext()) {
if (isExport) {
// In an export mode, the path is relative to the working directory.
libJars.append(getLibFolderInWorkingDir() + itLibNames.next()).append(',');
} else {
// In a local mode, the path is absolute.
//$NON-NLS-1$
libJars.append(libFolder + "/" + itLibNames.next()).append(',');
}
}
}
if (isExport) {
// In an export mode, we add the job jar which is located in the current working directory
//$NON-NLS-1$
libJars.append("./" + makeupJobJarName());
} else {
// In a local mode,we must append the routines/beans/udfs jars which are located in the target directory.
Set<FilterInfo> codeJars = new HashSet<>();
codeJars.add(new FilterInfo(JavaUtils.ROUTINE_JAR_NAME, FileExtensions.JAR_FILE_SUFFIX));
codeJars.add(new FilterInfo(JavaUtils.BEANS_JAR_NAME, FileExtensions.JAR_FILE_SUFFIX));
codeJars.add(new FilterInfo(JavaUtils.PIGUDFS_JAR_NAME, FileExtensions.JAR_FILE_SUFFIX));
List<File> files = FileUtils.getAllFilesFromFolder(targetDir, codeJars);
boolean routinesHaveBeenFound = false;
for (File f : files) {
if (!routinesHaveBeenFound && f.getName().startsWith(JavaUtils.ROUTINE_JAR_NAME)) {
routinesHaveBeenFound = true;
}
//$NON-NLS-1$
libJars.append(new Path(f.getAbsolutePath()).toPortableString() + ",");
}
// folder when the job is going to be running.
if (!routinesHaveBeenFound) {
File routinesJar = new File(//$NON-NLS-1$ //$NON-NLS-2$
targetDir + "/" + JavaUtils.ROUTINE_JAR_NAME + "-" + PomUtil.getDefaultMavenVersion() + FileExtensions.JAR_FILE_SUFFIX);
//$NON-NLS-1$
libJars.append(new Path(routinesJar.getAbsolutePath()).toPortableString() + ",");
}
// ... and add the jar of the job itself also located in the target directory/
if (targetDir != null) {
//$NON-NLS-1$
libJars.append(new Path(targetDir.getAbsolutePath()).toPortableString() + "/" + makeupJobJarName());
}
}
list.add(libJars.toString());
return list;
}
Aggregations