use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class AbstractJobSettingsPage method save.
protected void save() {
List<String> checkedObjects = new ArrayList<String>();
List<IRepositoryViewObject> allProcess = null;
try {
allProcess = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.PROCESS);
} catch (PersistenceException e1) {
ExceptionHandler.process(e1);
}
for (IRepositoryViewObject object : allProcess) {
if (isStatUseProjectSetting(object)) {
if (!checkedObjects.contains(object.getProperty().getId())) {
checkedObjects.add(object.getProperty().getId());
if (!checkedNodeObject.contains(object)) {
checkedNodeObject.add(object);
}
}
}
}
List<IProcess2> allOpenedProcessList = CorePlugin.getDefault().getDesignerCoreService().getOpenedProcess(getEditors());
if (allOpenedProcessList != null) {
for (int i = 0; i < allOpenedProcessList.size(); i++) {
if (checkedObjects.contains(allOpenedProcessList.get(i).getProperty().getId())) {
openedProcessList.add(allOpenedProcessList.get(i));
}
}
}
//
final IRunnableWithProgress runnable = new IRunnableWithProgress() {
@Override
public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask(getTaskMessages(), (checkedNodeObject.size()) * 100);
final Map<String, Set<String>> contextVars = DetectContextVarsUtils.detectByPropertyType(elem, true);
// must init this
addContextModel = false;
if (!contextVars.isEmpty()) {
// boolean showDialog = false;
Set<String> contextSet = new HashSet<String>();
for (String key : contextVars.keySet()) {
contextSet = contextVars.get(key);
break;
}
Connection connection = null;
IElementParameter ptParam = elem.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
if (ptParam != null) {
IElementParameter propertyElem = ptParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName());
Object proValue = propertyElem.getValue();
if (proValue instanceof String && ((String) proValue).equalsIgnoreCase(EmfComponent.REPOSITORY)) {
IElementParameter repositoryElem = ptParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
String value = (String) repositoryElem.getValue();
ConnectionItem connectionItem = UpdateRepositoryUtils.getConnectionItemByItemId(value);
connection = connectionItem.getConnection();
if (connection != null && connection.isContextMode()) {
addContextModel = true;
// ContextItem contextItem =
// ContextUtils.getContextItemById(connection.getContextId());
// for (IProcess process : openedProcessList) {
// Set<String> addedContext =
// ConnectionContextHelper.checkAndAddContextVariables(contextItem,
// contextSet, process.getContextManager(), false);
// if (addedContext != null && !addedContext.isEmpty()) {
// showDialog = true;
// break;
// }
// }
}
}
}
if (addContextModel) {
// if the context is not existed in job, will add or not.
Display disp = Display.getCurrent();
if (disp == null) {
disp = Display.getDefault();
}
if (disp != null) {
disp.syncExec(new Runnable() {
@Override
public void run() {
showContextAndCheck(contextVars);
}
});
} else {
showContextAndCheck(contextVars);
}
}
}
monitor.worked(10);
IWorkspaceRunnable workspaceRunnable = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
for (IRepositoryViewObject object : checkedNodeObject) {
saveProcess(object, addContextModel, contextVars, monitor);
}
}
};
IWorkspace workspace = ResourcesPlugin.getWorkspace();
try {
ISchedulingRule schedulingRule = workspace.getRoot();
workspace.run(workspaceRunnable, schedulingRule, IWorkspace.AVOID_UPDATE, monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
monitor.done();
}
};
final ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
try {
dialog.run(true, true, runnable);
} catch (InvocationTargetException e) {
ExceptionHandler.process(e);
} catch (InterruptedException e) {
ExceptionHandler.process(e);
}
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class ComponentSettingsView method getCategories.
/**
* yzhang Comment method "getCategories".
*
* @param elem
* @return
*/
private EComponentCategory[] getCategories(Element elem) {
if (elem instanceof Connection) {
EComponentCategory[] categories = EElementType.CONNECTION.getCategories();
if (PluginChecker.isTeamEdition()) {
Object propertyValue = elem.getPropertyValue(Connection.LINESTYLE_PROP);
if (propertyValue instanceof EConnectionType && ((EConnectionType) propertyValue).hasConnectionCategory(IConnectionCategory.FLOW)) {
// if (((Connection) elem).checkTraceShowEnable()) {
final List<EComponentCategory> list = new ArrayList<EComponentCategory>(Arrays.asList(categories));
boolean isMRProcess = false;
IProcess process = ((Connection) elem).getSource().getProcess();
if (process instanceof IProcess2) {
IProcess2 process2 = (IProcess2) process;
if (ComponentCategory.CATEGORY_4_MAPREDUCE.getName().equals(process2.getComponentsType())) {
isMRProcess = true;
}
}
boolean isStormProcess = false;
process = ((Connection) elem).getSource().getProcess();
if (process instanceof IProcess2) {
IProcess2 process2 = (IProcess2) process;
if (ComponentCategory.CATEGORY_4_STORM.getName().equals(process2.getComponentsType())) {
isStormProcess = true;
}
}
// mrjob and stormjob not add breakpoint
if (!isStormProcess && !isMRProcess) {
list.add(EComponentCategory.BREAKPOINT);
}
if (elem.getElementParameter(EParameterName.DEPARTITIONER.getName()) != null || elem.getElementParameter(EParameterName.PARTITIONER.getName()) != null || elem.getElementParameter(EParameterName.REPARTITIONER.getName()) != null) {
list.add(EComponentCategory.PARALLELIZATION);
}
// if it mr group line then add errorRecovery
if (isMRProcess && isMrGroupLine(elem)) {
list.add(EComponentCategory.RESUMING);
}
return list.toArray(new EComponentCategory[0]);
// }
} else if (propertyValue.equals(EConnectionType.ON_COMPONENT_OK) || propertyValue.equals(EConnectionType.ON_COMPONENT_ERROR) || propertyValue.equals(EConnectionType.RUN_IF) || propertyValue.equals(EConnectionType.ON_SUBJOB_OK) || propertyValue.equals(EConnectionType.ON_SUBJOB_ERROR) || propertyValue.equals(EConnectionType.ROUTE_WHEN) || propertyValue.equals(EConnectionType.ROUTE_CATCH) || propertyValue.equals(EConnectionType.STARTS)) {
boolean isMRProcess = false;
IProcess process = ((Connection) elem).getSource().getProcess();
if (process instanceof IProcess2) {
IProcess2 process2 = (IProcess2) process;
if (ComponentCategory.CATEGORY_4_MAPREDUCE.getName().equals(process2.getComponentsType())) {
isMRProcess = true;
}
}
boolean isStormProcess = false;
process = ((Connection) elem).getSource().getProcess();
if (process instanceof IProcess2) {
IProcess2 process2 = (IProcess2) process;
if (ComponentCategory.CATEGORY_4_STORM.getName().equals(process2.getComponentsType())) {
isStormProcess = true;
}
}
int length = categories.length;
EComponentCategory[] newCategories;
boolean isNormalJobNeedRecovery = (!isMRProcess && !isStormProcess && !isAvoidRecoveryByConditions(elem));
boolean isMrStormJobNeedRecovery = isMRProcess || isStormProcess;
if (isNeedRecoveryCategory(propertyValue, isNormalJobNeedRecovery, isMrStormJobNeedRecovery)) {
newCategories = new EComponentCategory[length + 1];
for (int i = 0; i < length; i++) {
newCategories[i] = categories[i];
}
EComponentCategory resuming = EComponentCategory.RESUMING;
newCategories[length] = resuming;
} else {
newCategories = new EComponentCategory[length];
for (int i = 0; i < length; i++) {
newCategories[i] = categories[i];
}
}
return newCategories;
}
}
return categories;
} else if (elem instanceof Node) {
// if (isAdvancedType(elem)) {
if (((Node) elem).isELTComponent()) {
if (//$NON-NLS-1$
!((Node) elem).getComponent().getName().endsWith("Output") && //$NON-NLS-1$
!((Node) elem).getComponent().getName().endsWith("Input") && //$NON-NLS-1$
!((Node) elem).getComponent().getName().endsWith("Map") && //$NON-NLS-1$
!((Node) elem).getComponent().getName().endsWith("TableList") && !((Node) elem).getComponent().getName().endsWith("ColumnList")) {
//$NON-NLS-1$
return EElementType.ELT_NODE.getCategories();
}
}
EComponentCategory[] categories = EElementType.ADVANCED_NODE.getCategories();
// add for bug TDI-8476
if (((Node) elem).getComponent() != null) {
String paletteType = ((Node) elem).getComponent().getPaletteType();
if (ComponentCategory.CATEGORY_4_CAMEL.getName().equals(paletteType)) {
categories = EElementType.NODE.getCategories();
}
}
if (PluginChecker.isValidationrulesPluginLoaded() && isSupportValidationRuleNode((Node) elem)) {
// show
EComponentCategory[] newCategories = new EComponentCategory[categories.length + 1];
System.arraycopy(categories, 0, newCategories, 0, categories.length);
newCategories[categories.length] = EComponentCategory.VALIDATION_RULES;
return newCategories;
}
return categories;
} else if (elem instanceof Note) {
return EElementType.NOTE.getCategories();
} else if (elem instanceof SubjobContainer) {
return EElementType.SUBJOB.getCategories();
} else if (elem instanceof ConnectionLabel) {
return getCategories(((ConnectionLabel) elem).getConnection());
}
return null;
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class DebugProcessTosComposite method setRunnable.
@Override
protected void setRunnable(boolean runnable) {
if (clearTracePerfBtn != null && !clearTracePerfBtn.isDisposed()) {
IProcess2 iProcess = null;
boolean enableClearBtn = true;
if (processContext != null && (iProcess = processContext.getProcess()) != null) {
if (iProcess.disableRunJobView()) {
enableClearBtn = false;
}
} else {
enableClearBtn = false;
}
clearTracePerfBtn.setEnabled(enableClearBtn);
}
// previousRow.setEnabled(runnable);
// nextRow.setEnabled(runnable);
// nextBreakPoint.setEnabled(runnable);
setExecBtn(runnable);
// }
if (enableLineLimitButton != null && !enableLineLimitButton.isDisposed()) {
enableLineLimitButton.setEnabled(runnable);
}
if (lineLimitText != null && !lineLimitText.isDisposed()) {
lineLimitText.setEnabled(runnable);
}
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class AbstractMultiPageTalendEditor method updateRunJobContext.
protected void updateRunJobContext() {
final JobContextManager manager = (JobContextManager) getProcess().getContextManager();
if (manager.isModified()) {
final Map<String, String> nameMap = manager.getNameMap();
// gcui:add a progressDialog.
Shell shell = null;
Display display = PlatformUI.getWorkbench().getDisplay();
if (display != null) {
shell = display.getActiveShell();
}
if (shell == null) {
display = Display.getCurrent();
if (display == null) {
display = Display.getDefault();
}
if (display != null) {
shell = display.getActiveShell();
}
}
ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(shell);
IRunnableWithProgress runnable = new IRunnableWithProgress() {
@Override
public void run(final IProgressMonitor monitor) {
//$NON-NLS-1$
monitor.beginTask(Messages.getString("AbstractMultiPageTalendEditor_pleaseWait"), IProgressMonitor.UNKNOWN);
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
IProxyRepositoryFactory factory = CorePlugin.getDefault().getProxyRepositoryFactory();
factory.executeRepositoryWorkUnit(new //$NON-NLS-1$
RepositoryWorkUnit<Object>(//$NON-NLS-1$
"..", //$NON-NLS-1$
this) {
@Override
protected void run() throws LoginException, PersistenceException {
try {
IProxyRepositoryFactory factory = CorePlugin.getDefault().getProxyRepositoryFactory();
Set<String> curContextVars = getCurrentContextVariables(manager);
IProcess2 process2 = getProcess();
String jobId = process2.getProperty().getId();
IEditorReference[] reference = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
List<IProcess2> processes = CorePlugin.getDefault().getDesignerCoreService().getOpenedProcess(reference);
// gcui:if nameMap is empty it do nothing.
if (!nameMap.isEmpty()) {
UpdateRunJobComponentContextHelper.updateItemRunJobComponentReference(factory, nameMap, jobId, curContextVars);
UpdateRunJobComponentContextHelper.updateOpenedJobRunJobComponentReference(processes, nameMap, jobId, curContextVars);
}
// add for bug 9564
List<IRepositoryViewObject> all = factory.getAll(ERepositoryObjectType.PROCESS, true);
List<ProcessItem> allProcess = new ArrayList<ProcessItem>();
for (IRepositoryViewObject repositoryObject : all) {
Item item = repositoryObject.getProperty().getItem();
if (item instanceof ProcessItem) {
ProcessItem processItem = (ProcessItem) item;
allProcess.add(processItem);
}
}
UpdateRunJobComponentContextHelper.updateRefJobRunJobComponentContext(factory, allProcess, process2);
} catch (PersistenceException e) {
// e.printStackTrace();
ExceptionHandler.process(e);
}
manager.setModified(false);
}
});
}
});
monitor.done();
if (monitor.isCanceled()) {
try {
//$NON-NLS-1$
throw new InterruptedException("Save Fail");
} catch (InterruptedException e) {
ExceptionHandler.process(e);
}
}
}
};
try {
progressDialog.run(true, true, runnable);
} catch (InvocationTargetException e1) {
ExceptionHandler.process(e1);
} catch (InterruptedException e1) {
ExceptionHandler.process(e1);
}
}
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class AbstractMultiPageTalendEditor method init.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.part.MultiPageEditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
*/
@Override
public void init(final IEditorSite site, IEditorInput editorInput) throws PartInitException {
setSite(site);
setInput(editorInput);
if (!(editorInput instanceof JobEditorInput)) {
return;
}
site.setSelectionProvider(new MultiPageTalendSelectionProvider(this));
getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(this);
// Lock the process :
IRepositoryService service = CorePlugin.getDefault().getRepositoryService();
final IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
processEditorInput = (JobEditorInput) editorInput;
final IProcess2 currentProcess = processEditorInput.getLoadedProcess();
if (!currentProcess.isReadOnly()) {
try {
Property property = processEditorInput.getItem().getProperty();
propertyInformation = new ArrayList(property.getInformations());
property.eAdapters().add(dirtyListener);
repFactory.lock(currentProcess);
boolean locked = repFactory.getStatus(currentProcess) == ERepositoryStatus.LOCK_BY_USER;
if (!locked) {
setReadOnly(true);
}
revisionChanged = true;
} catch (PersistenceException e) {
// e.printStackTrace();
ExceptionHandler.process(e);
} catch (BusinessException e) {
// Nothing to do
ExceptionHandler.process(e);
}
} else {
setReadOnly(true);
Bundle bundle = FrameworkUtil.getBundle(AbstractMultiPageTalendEditor.class);
final Display display = getSite().getShell().getDisplay();
this.lockService = bundle.getBundleContext().registerService(EventHandler.class.getName(), new EventHandler() {
@Override
public void handleEvent(Event event) {
String lockTopic = Constant.REPOSITORY_ITEM_EVENT_PREFIX + Constant.ITEM_LOCK_EVENT_SUFFIX;
if (lockTopic.equals(event.getTopic())) {
Object o = event.getProperty(Constant.ITEM_EVENT_PROPERTY_KEY);
if (o != null && o instanceof Item) {
Item item = (Item) o;
String itemId = item.getProperty().getId();
if (itemId.equals(currentProcess.getId())) {
if (currentProcess.isReadOnly()) {
boolean readOnly = currentProcess.checkReadOnly();
boolean orginalReadOnlyStatus = designerEditor.isReadOnly();
setReadOnly(readOnly);
if (!readOnly) {
display.asyncExec(new Runnable() {
@Override
public void run() {
setFocus();
}
});
if (orginalReadOnlyStatus == true) {
// refresh to the given item version, nomally it is the latest
// version,
// means the editor/process will be refreshed to the latest version
refreshProcess(item, false);
}
Property property = processEditorInput.getItem().getProperty();
propertyInformation = new ArrayList(property.getInformations());
property.eAdapters().add(dirtyListener);
}
}
}
}
}
}
}, new Hashtable<String, String>(Collections.singletonMap(EventConstants.EVENT_TOPIC, //$NON-NLS-1$
Constant.REPOSITORY_ITEM_EVENT_PREFIX + "*")));
revisionChanged = true;
}
// setTitleImage(ImageProvider.getImage(getEditorTitleImage()));
updateTitleImage(processEditorInput.getItem().getProperty());
getSite().getWorkbenchWindow().getPartService().addPartListener(partListener);
}
Aggregations