use of org.talend.core.model.update.UpdateResult in project tdi-studio-se by Talend.
the class UpdateManagerUtils method refreshRelatedViewers.
/**
*
* ggu Comment method "refreshViewers".
*/
@SuppressWarnings("unchecked")
private static void refreshRelatedViewers(List results) {
boolean context = false;
boolean jobSetting = false;
boolean componentSettings = false;
boolean palette = false;
for (UpdateResult result : (List<UpdateResult>) results) {
// if (!result.isChecked()) {
// continue;
// }
IUpdateItemType updateType = result.getUpdateType();
if (updateType != null) {
if (EUpdateItemType.CONTEXT.equals(updateType)) {
if (result.isJoblet() && !result.isChecked()) {
continue;
}
context = true;
} else if (EUpdateItemType.JOB_PROPERTY_EXTRA.equals(updateType) || EUpdateItemType.JOB_PROPERTY_STATS_LOGS.equals(updateType) || EUpdateItemType.JOB_PROPERTY_HEADERFOOTER.equals(updateType)) {
jobSetting = true;
} else if (EUpdateItemType.NODE_PROPERTY.equals(updateType) || EUpdateItemType.NODE_QUERY.equals(updateType) || EUpdateItemType.NODE_SCHEMA.equals(updateType)) {
componentSettings = true;
} else if (EUpdateItemType.RELOAD.equals(updateType) || EUpdateItemType.JOBLET_RENAMED.equals(updateType) || EUpdateItemType.JOBLET_SCHEMA.equals(updateType)) {
if (result.isJoblet() && !result.isChecked()) {
continue;
}
palette = true;
}
}
}
// recheck from the providers
Set<String> viewIds = UpdateManagerProviderDetector.INSTANCE.needRefreshRelatedViews(results);
// context
if (!context) {
context = viewIds.contains(AbstractContextView.CTX_ID_DESIGNER);
}
if (context) {
Contexts.switchToCurContextsView();
}
// jobsetting
if (!jobSetting) {
jobSetting = viewIds.contains(JobSettingsView.ID);
}
if (jobSetting) {
JobSettings.switchToCurJobSettingsView();
}
// component setting
if (!componentSettings) {
componentSettings = viewIds.contains(ComponentSettingsView.ID);
}
if (componentSettings) {
ComponentSettings.switchToCurComponentSettingsView();
}
// }
if (palette) {
ComponentPaletteUtilities.updatePalette();
}
}
use of org.talend.core.model.update.UpdateResult in project tdi-studio-se by Talend.
the class UpdateViewerHelper method checkUpdateStatus.
public void checkUpdateStatus() {
List<UpdateResult> inputElements = updateDialog.getInputElements();
if (inputElements != null) {
for (UpdateResult result : inputElements) {
if (result.isReadOnlyProcess()) {
updateDialog.updateReadOnlyJobWarnMessage();
return;
}
if (!result.isChecked() && (result.getResultType() == EUpdateResult.UPDATE || result.getResultType() == EUpdateResult.DELETE)) {
updateDialog.updateWarnMessage();
return;
}
}
}
updateDialog.updateNomarlMessage();
}
use of org.talend.core.model.update.UpdateResult in project tdi-studio-se by Talend.
the class UpdateViewerHelper method refreshSelectButton.
/**
*
* ggu Comment method "refreshSelectButton".
*
* refresh the label of select button.
*/
@SuppressWarnings("restriction")
public void refreshSelectButton() {
List<UpdateResult> inputElements = updateDialog.getInputElements();
if (inputElements == null) {
return;
}
int num = 0;
for (UpdateResult result : inputElements) {
if (result.isChecked()) {
num++;
}
}
if (num == inputElements.size()) {
// updateDialog.setSelectButtonLabel(WorkbenchMessages.SelectionDialog_deselectLabel);
//$NON-NLS-1$
updateDialog.setSelectButtonLabel(Messages.getString("WorkbenchMessages.SelectionDialog_deselectLabel"));
} else {
// updateDialog.setSelectButtonLabel(WorkbenchMessages.SelectionDialog_selectLabel);
//$NON-NLS-1$
updateDialog.setSelectButtonLabel(Messages.getString("WorkbenchMessages.SelectionDialog_selectLabel"));
}
}
use of org.talend.core.model.update.UpdateResult 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.model.update.UpdateResult in project tdi-studio-se by Talend.
the class RepositoryUpdateTest method launchRepositoryUpdateOnNode.
/**
* DOC nrousseau Comment method "updateNode".
* @param id
* @param process
* @param node
* @throws PersistenceException
*/
private void launchRepositoryUpdateOnNode(String id, Process process, Node node) throws PersistenceException {
GenericConnectionItem connectionItem;
IRepositoryViewObject object;
object = ProxyRepositoryFactory.getInstance().getLastVersion(id);
connectionItem = (GenericConnectionItem) object.getProperty().getItem();
Assert.assertEquals(1, SchemaUtils.getMetadataTables(connectionItem.getConnection(), SubContainer.class).size());
UpdateResult ur = createUpdateResult(node);
ur.setResult(EUpdateItemType.NODE_PROPERTY, EUpdateResult.UPDATE, connectionItem);
ur.setJob(process);
UpdateNodeParameterCommand cmd = new UpdateNodeParameterCommand(ur);
cmd.execute();
}
Aggregations