use of org.talend.core.service.IMRProcessService in project tdi-studio-se by Talend.
the class JavaProcessorUtilities method hasBatchOrStreamingSubProcess.
public static boolean hasBatchOrStreamingSubProcess(Item item, Set<String> testedItems) throws PersistenceException {
if (testedItems.contains(item.getProperty().getId())) {
return false;
}
testedItems.add(item.getProperty().getId());
if (GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class)) {
IMRProcessService batchService = (IMRProcessService) GlobalServiceRegister.getDefault().getService(IMRProcessService.class);
if (batchService.isMapReduceItem(item)) {
return true;
}
}
if (GlobalServiceRegister.getDefault().isServiceRegistered(IStormProcessService.class)) {
IStormProcessService streamingService = (IStormProcessService) GlobalServiceRegister.getDefault().getService(IStormProcessService.class);
if (streamingService.isStormItem(item)) {
return true;
}
}
if (GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class) || GlobalServiceRegister.getDefault().isServiceRegistered(IStormProcessService.class)) {
if (item != null && item.eClass() == PropertiesPackage.Literals.PROCESS_ITEM) {
ProcessType processType = ((ProcessItem) item).getProcess();
EList<NodeType> nodes = processType.getNode();
for (NodeType node : nodes) {
if ("tRunJob".equals(node.getComponentName())) {
//$NON-NLS-1$
EList<ElementParameterType> elementParameters = node.getElementParameter();
for (ElementParameterType param : elementParameters) {
if (param.getName() != null && "PROCESS:PROCESS_TYPE_PROCESS".equals(param.getName())) {
//$NON-NLS-1$
Object value = param.getValue();
if (value != null && !"".equals(value)) {
//$NON-NLS-1$
IRepositoryViewObject lastVersion = RunProcessPlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().getLastVersion(value.toString());
if (lastVersion != null) {
boolean hasBatchOrStreaming = hasBatchOrStreamingSubProcess(lastVersion.getProperty().getItem(), testedItems);
if (hasBatchOrStreaming) {
// only stop the loop once we checked every child
return hasBatchOrStreaming;
}
}
}
}
}
}
}
}
}
return false;
}
use of org.talend.core.service.IMRProcessService in project tdi-studio-se by Talend.
the class AbstractTalendEditor method doSave.
@Override
public void doSave(IProgressMonitor monitor) {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
//$NON-NLS-1$
monitor.beginTask("begin save job...", 100);
monitor.worked(10);
savePreviewPictures();
// generate the MR infor parameter.
try {
boolean isStormServiceRegistered = GlobalServiceRegister.getDefault().isServiceRegistered(IStormProcessService.class);
boolean isMRServiceRegistered = GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class);
if (isStormServiceRegistered || isMRServiceRegistered) {
IProcess2 process = getProcess();
if (process != null) {
IRepositoryViewObject repoObjectView = DesignerPlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().getLastVersion(process.getId());
if (repoObjectView != null && repoObjectView.getProperty() != null) {
Item currentItem = repoObjectView.getProperty().getItem();
if (isMRServiceRegistered) {
IMRProcessService mrService = (IMRProcessService) GlobalServiceRegister.getDefault().getService(IMRProcessService.class);
if (mrService.isMapReduceItem(currentItem)) {
// We make sure that the current item is a Batch item before generating the M/R
// information parameters.
mrService.generateMRInfosParameter(process);
}
}
if (isStormServiceRegistered) {
IStormProcessService stormService = (IStormProcessService) GlobalServiceRegister.getDefault().getService(IStormProcessService.class);
if (stormService.isStormItem(currentItem)) {
// We make sure that the current item is a Streaming item before generating the Spark
// Streaming information parameters.
stormService.generateSparkStreamingInfosParameter(process);
}
}
}
}
}
} catch (PersistenceException e) {
e.printStackTrace();
}
try {
if (getEditorInput() instanceof JobEditorInput) {
boolean saved = ((JobEditorInput) getEditorInput()).saveProcess(new SubProgressMonitor(monitor, 80), null);
if (!saved) {
monitor.setCanceled(true);
throw new InterruptedException();
}
}
getCommandStack().markSaveLocation();
setDirty(false);
boolean isneedReload = false;
for (int i = 0; i < getProcess().getGraphicalNodes().size(); i++) {
Node node = (Node) getProcess().getGraphicalNodes().get(i);
if (node.isNeedloadLib()) {
isneedReload = true;
node.setNeedLoadLib(false);
}
}
if (isneedReload) {
// / See bug 4821
((ILibrariesService) GlobalServiceRegister.getDefault().getService(ILibrariesService.class)).updateModulesNeededForCurrentJob(getProcess());
}
monitor.worked(10);
} catch (Exception e) {
// e.printStackTrace();
ExceptionHandler.process(e);
monitor.setCanceled(true);
} finally {
monitor.done();
}
}
use of org.talend.core.service.IMRProcessService in project tdi-studio-se by Talend.
the class UpdateCheckResult method updateJobInfor.
@Override
protected void updateJobInfor() {
if (getJob() != null) {
String jobInfor = null;
if (getJob() instanceof IProcess2) {
Property property = ((IProcess2) getJob()).getProperty();
jobInfor = RepositoryUpdateManager.getUpdateJobInfor(property);
org.talend.core.model.properties.Item item = property.getItem();
if (item instanceof JobletProcessItem) {
handleJoblet(item);
} else if (GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class)) {
IMRProcessService mrProcessService = (IMRProcessService) GlobalServiceRegister.getDefault().getService(IMRProcessService.class);
isMR = mrProcessService.isMapReduceItem(item);
}
if (GlobalServiceRegister.getDefault().isServiceRegistered(IStormProcessService.class)) {
IStormProcessService streamingService = (IStormProcessService) GlobalServiceRegister.getDefault().getService(IStormProcessService.class);
isStreaming = streamingService.isStormItem(item);
}
}
if (getJob() instanceof org.talend.core.model.properties.Item) {
jobInfor = RepositoryUpdateManager.getUpdateJobInfor(((org.talend.core.model.properties.Item) getJob()).getProperty());
if (getJob() instanceof JobletProcessItem) {
handleJoblet((JobletProcessItem) getJob());
} else if (GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class)) {
IMRProcessService mrProcessService = (IMRProcessService) GlobalServiceRegister.getDefault().getService(IMRProcessService.class);
isMR = mrProcessService.isMapReduceItem((org.talend.core.model.properties.Item) getJob());
}
if (GlobalServiceRegister.getDefault().isServiceRegistered(IStormProcessService.class)) {
IStormProcessService streamingService = (IStormProcessService) GlobalServiceRegister.getDefault().getService(IStormProcessService.class);
isStreaming = streamingService.isStormItem((org.talend.core.model.properties.Item) getJob());
}
}
String others = null;
if (isFromItem()) {
// update item
others = UpdatesConstants.START;
}
if (jobInfor != null) {
this.jobInfor = jobInfor + UpdatesConstants.SPACE + UpdateManagerUtils.addBrackets(others);
return;
}
}
}
Aggregations