use of org.talend.core.service.IMRProcessService in project tdi-studio-se by Talend.
the class ChangeActivateStatusElementCommand method refreshMRStatus.
private void refreshMRStatus() {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class)) {
IMRProcessService mrService = (IMRProcessService) GlobalServiceRegister.getDefault().getService(IMRProcessService.class);
if (mrService != null) {
List<INode> mrNodeList = new ArrayList<INode>();
for (Node node : nodeList) {
if (node.isMapReduceStart() && !mrNodeList.contains(node)) {
mrNodeList.add(node);
}
}
mrService.refreshMRStatus(mrNodeList);
}
}
}
use of org.talend.core.service.IMRProcessService in project tdi-studio-se by Talend.
the class UpdateCheckResult method getCategory.
@Override
@SuppressWarnings("unchecked")
public String getCategory() {
String category = null;
if (getUpdateType() instanceof EUpdateItemType) {
switch((EUpdateItemType) getUpdateType()) {
case NODE_PROPERTY:
case NODE_SCHEMA:
case NODE_QUERY:
case NODE_VALIDATION_RULE:
case JOBLET_SCHEMA:
if (getUpdateObject() != null) {
if (getUpdateObject() instanceof Node) {
Node node = (Node) getUpdateObject();
if (node.getUniqueName().equals(node.getLabel())) {
category = node.getUniqueName();
} else {
category = node.getLabel() + UpdateManagerUtils.addBrackets(node.getUniqueName());
}
}
if (getUpdateObject() instanceof NodeType) {
NodeType node = (NodeType) getUpdateObject();
String uniqueName = null;
for (ElementParameterType param : (List<ElementParameterType>) node.getElementParameter()) {
if (EParameterName.UNIQUE_NAME.getName().equals(param.getName())) {
uniqueName = param.getValue();
break;
}
}
if (uniqueName != null) {
category = uniqueName;
}
}
}
break;
case JOB_PROPERTY_EXTRA:
case JOB_PROPERTY_STATS_LOGS:
case JOB_PROPERTY_HEADERFOOTER:
case JOB_PROPERTY_MAPREDUCE:
boolean isJoblet = false;
boolean isMR = false;
if (getUpdateObject() != null) {
if (getUpdateObject() instanceof org.talend.designer.core.ui.editor.process.Process) {
if (AbstractProcessProvider.isExtensionProcessForJoblet((IProcess) getUpdateObject())) {
isJoblet = true;
} else if (GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class)) {
IMRProcessService mrProcessService = (IMRProcessService) GlobalServiceRegister.getDefault().getService(IMRProcessService.class);
org.talend.core.model.properties.Item item = ((org.talend.designer.core.ui.editor.process.Process) getUpdateObject()).getProperty().getItem();
isMR = mrProcessService.isMapReduceItem(item);
}
}
}
if (isMR) {
//
category = JobSettingsView.VIEW_NAME_BATCH;
} else if (isJoblet) {
// joblet
category = JobSettingsView.VIEW_NAME_JOBLET;
} else {
category = JobSettingsView.getViewNameLable();
}
break;
case JOB_PROPERTY_STORM:
boolean isStreaming = false;
if (getUpdateObject() != null && getUpdateObject() instanceof org.talend.designer.core.ui.editor.process.Process) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IStormProcessService.class)) {
IStormProcessService streamingService = (IStormProcessService) GlobalServiceRegister.getDefault().getService(IStormProcessService.class);
org.talend.core.model.properties.Item item = ((org.talend.designer.core.ui.editor.process.Process) getUpdateObject()).getProperty().getItem();
isStreaming = streamingService.isStormItem(item);
}
}
if (isStreaming) {
//
category = JobSettingsView.VIEW_NAME_STREAMING;
} else {
category = JobSettingsView.getViewNameLable();
}
break;
case CONTEXT:
// case JOBLET_CONTEXT:
category = UpdatesConstants.CONTEXT;
break;
case CONTEXT_GROUP:
category = UpdatesConstants.CONTEXT_GROUP;
break;
case JOBLET_RENAMED:
case RELOAD:
case JUNIT_RELOAD:
if (getUpdateObject() != null && getUpdateObject() instanceof List) {
String display = UpdateManagerHelper.getCollectionsDisplay(getUpdateObject(), true);
if (display != null) {
category = display;
}
} else if (getParameter() != null && getParameter() instanceof PropertyChangeEvent) {
PropertyChangeEvent event = (PropertyChangeEvent) getParameter();
// reload all compoennts.
if (event.getSource() != null && !(event.getSource() instanceof IProcess)) {
category = UpdatesConstants.COMPONENT;
break;
}
} else {
category = UpdatesConstants.JOBLET;
}
break;
default:
}
} else {
category = UpdateManagerProviderDetector.INSTANCE.getDisplayCategory(this);
}
return category == null ? UpdatesConstants.EMPTY : category;
}
use of org.talend.core.service.IMRProcessService in project tdi-studio-se by Talend.
the class UpdateContentProvider method getElements.
@Override
@SuppressWarnings("unchecked")
public Object[] getElements(Object inputElement) {
List<Job> jobs = new ArrayList<Job>();
if (inputElement instanceof Collection) {
for (UpdateResult result : (List<UpdateResult>) inputElement) {
String jobName = result.getJobInfor();
if (jobName == null) {
jobName = UpdatesConstants.EMPTY;
}
Job job = getJob(jobs, jobName);
if (job == null) {
job = new Job(jobName);
Object job2 = result.getJob();
if (job2 != null) {
if (job2 instanceof IProcess2) {
// ?? joblet
job.setJoblet(((IProcess2) job2).disableRunJobView());
job.setReadOnlyProcess(result.isReadOnlyProcess());
IProcess2 process = (IProcess2) job2;
org.talend.core.model.properties.Item processItem = process.getProperty().getItem();
job.setModelItem(processItem);
boolean isMRProcess = false;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class)) {
IMRProcessService mrProcessService = (IMRProcessService) GlobalServiceRegister.getDefault().getService(IMRProcessService.class);
isMRProcess = mrProcessService.isMapReduceItem(processItem);
}
boolean isStreamingProcess = false;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IStormProcessService.class)) {
IStormProcessService streamingService = (IStormProcessService) GlobalServiceRegister.getDefault().getService(IStormProcessService.class);
isStreamingProcess = streamingService.isStormItem(processItem);
}
if (isMRProcess) {
job.setMR(isMRProcess);
} else if (isStreamingProcess) {
job.setStreaming(isStreamingProcess);
} else if (processItem instanceof ProcessItem) {
job.setJoblet(false);
job.setMR(false);
job.setStreaming(false);
job.setSparkJoblet(false);
job.setSparkStreamingJoblet(false);
} else if (processItem instanceof JobletProcessItem) {
boolean isSpark = false;
boolean isSparkStreaming = false;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ISparkJobletProviderService.class)) {
ISparkJobletProviderService sparkJobletService = (ISparkJobletProviderService) GlobalServiceRegister.getDefault().getService(ISparkJobletProviderService.class);
if (sparkJobletService != null && sparkJobletService.isSparkJobletItem(processItem)) {
isSpark = true;
}
}
if (GlobalServiceRegister.getDefault().isServiceRegistered(ISparkStreamingJobletProviderService.class)) {
ISparkStreamingJobletProviderService sparkStreamingJobletService = (ISparkStreamingJobletProviderService) GlobalServiceRegister.getDefault().getService(ISparkStreamingJobletProviderService.class);
if (sparkStreamingJobletService != null && sparkStreamingJobletService.isSparkStreamingJobletItem(processItem)) {
isSparkStreaming = true;
}
}
if (isSpark) {
job.setSparkJoblet(true);
job.setJoblet(false);
} else if (isSparkStreaming) {
job.setSparkStreamingJoblet(true);
job.setJoblet(false);
} else {
job.setJoblet(true);
}
}
}
} else {
String itemId = result.getObjectId();
if (itemId != null) {
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
try {
IRepositoryViewObject repoViewObject = factory.getLastVersion(itemId);
if (repoViewObject != null) {
Property property = repoViewObject.getProperty();
if (property != null) {
job.setModelItem(property.getItem());
}
}
} catch (PersistenceException e) {
CommonExceptionHandler.process(e, Priority.WARN);
}
}
job.setJoblet(result.isJoblet());
job.setMR(result.isMR());
job.setStreaming(result.isStreaming());
job.setSparkJoblet(result.isSparkJoblet());
job.setSparkStreamingJoblet(result.isSparkStreamingJoblet());
}
jobs.add(job);
}
Category category = job.getCategory(result.getCategory());
if (category == null) {
category = new Category(job, result.getCategory());
// for icon
category.setType(result.getUpdateType());
if (result.getUpdateObject() instanceof Node) {
// for node icon
category.setNode(result.getUpdateObject());
}
if (result.getUpdateObject() instanceof NodeType) {
// for node icon
category.setNode(result.getUpdateObject());
}
if (result.getUpdateObject() instanceof List) {
// for node icon
List list = (List) result.getUpdateObject();
if (list.size() > 0) {
Object object = list.get(0);
if (object instanceof Node) {
category.setNode(object);
}
}
}
job.addCategory(category);
}
Item item = new Item(category, result);
category.addItem(item);
}
}
return jobs.toArray();
}
use of org.talend.core.service.IMRProcessService in project tdi-studio-se by Talend.
the class HTMLDocGenerator method handleXMLFile.
/**
* Generates the xml file base on an instance of <code>ExportFileResource</code> and the temporary folder path.
*
* @param resource
* @param tempFolderPath
* @param version
*/
private void handleXMLFile(ExportFileResource resource, String tempFolderPath, String... version) throws Exception {
Item item = resource.getItem();
// Check if generate Job Extra / Stats&Logs Setting Info
if (item instanceof ProcessItem) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class)) {
IMRProcessService mrProcessService = (IMRProcessService) GlobalServiceRegister.getDefault().getService(IMRProcessService.class);
generateExtraSetting = !mrProcessService.isMapReduceItem(item);
generateStatsLogsSetting = generateExtraSetting;
} else if (isRouteProcess(item)) {
generateStatsLogsSetting = generateExtraSetting = !isRouteProcess(item);
}
} else if (item instanceof JobletProcessItem) {
generateStatsLogsSetting = false;
}
targetConnectionMap = new HashMap<String, List>();
sourceConnectionMap = new HashMap<String, List>();
getSourceAndTargetConnection(item);
Document document = DocumentHelper.createDocument();
Element projectElement = generateProjectInfo(document);
Element jobElement = generateJobInfo(item, projectElement, version);
// This two element see feature 4162
generateContextInfo(item, jobElement);
generateJobSettingInfo(item, jobElement);
List<List> allList = seperateNodes(item);
if (allList == null || allList.size() != 3) {
return;
}
List<INode> allComponentsList = allList.get(0);
List<INode> internalNodeComponentsList = allList.get(1);
List<INode> externalNodeComponentsList = allList.get(2);
if (allComponentsList.size() > 0) {
// Generates information for 'Component List' part in exported HTML file.
generateAllComponentsSummaryInfo(item, jobElement, allComponentsList);
}
//$NON-NLS-1$
Element internalNodeElement = jobElement.addElement("internalNodeComponents");
//$NON-NLS-1$
Element externalNodeElement = jobElement.addElement("externalNodeComponents");
if (internalNodeComponentsList.size() > 0) {
InternalNodeComponentHandler internalNodeComponentHandler = new InternalNodeComponentHandler(this.picFilePathMap, internalNodeElement, internalNodeComponentsList, this.sourceConnectionMap, this.targetConnectionMap, this.designerCoreService, this.repositoryConnectionItemMap, this.repositoryDBIdAndNameMap, externalNodeHTMLMap);
// Generates internal node components information.
internalNodeComponentHandler.generateComponentInfo();
}
if (externalNodeComponentsList.size() > 0) {
ExternalNodeComponentHandler externalNodeComponentHandler = new ExternalNodeComponentHandler(this.picFilePathMap, externalNodeElement, externalNodeComponentsList, this.sourceConnectionMap, this.targetConnectionMap, this.designerCoreService, this.repositoryConnectionItemMap, this.repositoryDBIdAndNameMap, externalNodeHTMLMap);
// Generates external node components(tMap etc.) information.
externalNodeComponentHandler.generateComponentInfo();
}
// Generates all connection information(include internal node and external node).
EList connectionList = null;
if (item instanceof ProcessItem) {
connectionList = ((ProcessItem) item).getProcess().getConnection();
} else if (item instanceof JobletProcessItem) {
connectionList = (((JobletProcessItem) item).getJobletProcess().getConnection());
}
if (connectionList != null && connectionList.size() != 0) {
generateConnectionsInfo(jobElement, connectionList);
}
//$NON-NLS-1$
String versionPath = "_";
if (version != null && version.length == 1) {
versionPath = versionPath + version[0];
} else {
versionPath = versionPath + item.getProperty().getVersion();
}
String filePath = tempFolderPath + File.separatorChar + item.getProperty().getLabel() + versionPath + IHTMLDocConstants.XML_FILE_SUFFIX;
// This element see feature 4382
if (item instanceof ProcessItem) {
generateSourceCodeInfo((ProcessItem) item, jobElement);
}
XMLHandler.generateXMLFile(tempFolderPath, filePath, document);
}
use of org.talend.core.service.IMRProcessService in project tdi-studio-se by Talend.
the class ChangeActivateStatusSubjobCommand method refreshMRStatus.
private void refreshMRStatus() {
Process process = (Process) node.getProcess();
if (GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class)) {
IMRProcessService mrService = (IMRProcessService) GlobalServiceRegister.getDefault().getService(IMRProcessService.class);
if (mrService != null) {
List<INode> mrNodeList = new ArrayList<INode>();
for (INode node : process.getGraphicalNodes()) {
if ((((Node) node).isMapReduceStart()) && !mrNodeList.contains(node)) {
mrNodeList.add(node);
}
}
mrService.refreshMRStatus(mrNodeList);
}
}
}
Aggregations