use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.
the class JobLaunchShortcut method launch.
/**
* Locates a launchable entity in the given selection and launches an application in the specified mode.
*
* @see org.eclipse.debug.ui.ILaunchShortcut#launch(org.eclipse.jface.viewers.ISelection, java.lang.String)
*
* @param selection workbench selection
* @param mode one of the launch modes defined by the launch manager
* @see org.eclipse.debug.core.ILaunchManager
*/
@Override
public void launch(ISelection selection, String mode) {
if (selection instanceof IStructuredSelection) {
Object object = ((IStructuredSelection) selection).getFirstElement();
if (object instanceof RepositoryNode) {
RepositoryNode node = (RepositoryNode) object;
launch(node.getObject().getProperty().getItem(), mode);
}
}
}
use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.
the class SetupProcessDependenciesRoutinesAction method init.
@Override
public void init(TreeViewer viewer, IStructuredSelection selection) {
boolean canWork = !selection.isEmpty() && selection.size() == 1;
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
if (factory.isUserReadOnlyOnCurrentProject()) {
canWork = false;
}
if (canWork) {
Object o = selection.getFirstElement();
RepositoryNode node = (RepositoryNode) o;
switch(node.getType()) {
case REPOSITORY_ELEMENT:
if (ERepositoryObjectType.PROCESS_STORM != null && node.getObjectType().equals(ERepositoryObjectType.PROCESS_STORM)) {
canWork = true;
} else if (ERepositoryObjectType.PROCESS_MR != null && node.getObjectType().equals(ERepositoryObjectType.PROCESS_MR)) {
canWork = true;
} else if (ERepositoryObjectType.SPARK_JOBLET != null && node.getObjectType().equals(ERepositoryObjectType.SPARK_JOBLET)) {
canWork = true;
} else if (ERepositoryObjectType.SPARK_STREAMING_JOBLET != null && node.getObjectType().equals(ERepositoryObjectType.SPARK_STREAMING_JOBLET)) {
canWork = true;
} else if (node.getObjectType() != ERepositoryObjectType.PROCESS && node.getObjectType() != ERepositoryObjectType.JOBLET) {
canWork = false;
}
break;
default:
canWork = false;
}
if (canWork && node.getObject() != null && ProxyRepositoryFactory.getInstance().getStatus(node.getObject()) == ERepositoryStatus.DELETED) {
canWork = false;
}
if (canWork && !ProjectManager.getInstance().isInCurrentMainProject(node)) {
canWork = false;
}
// If the editProcess action canwork is true, then detect that the job version is the latest verison or not.
if (canWork) {
canWork = isLastVersion(node);
}
}
setEnabled(canWork);
}
use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.
the class SetupProcessDependenciesRoutinesAction method doRun.
@Override
protected void doRun() {
ISelection selection = getSelection();
Object obj = ((IStructuredSelection) selection).getFirstElement();
if (obj == null) {
return;
}
RepositoryNode node = (RepositoryNode) obj;
boolean readonly = false;
IRepositoryService service = DesignerPlugin.getDefault().getRepositoryService();
IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
ERepositoryStatus status = repFactory.getStatus(node.getObject());
if (!repFactory.isPotentiallyEditable(node.getObject()) || status == ERepositoryStatus.LOCK_BY_OTHER || status == ERepositoryStatus.LOCK_BY_USER) {
readonly = true;
}
Item item = node.getObject().getProperty().getItem();
if (item instanceof ProcessItem) {
ProcessItem processItem = (ProcessItem) item;
ProcessType process = processItem.getProcess();
SetupProcessDependenciesRoutinesDialog dialog = new SetupProcessDependenciesRoutinesDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), process, readonly);
if (dialog.open() == Window.OK && !readonly) {
process.getParameters().getRoutinesParameter().clear();
createRoutinesDependencies(process, dialog.getSystemRoutines());
createRoutinesDependencies(process, dialog.getUserRoutines());
try {
CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().save(processItem);
RelationshipItemBuilder.getInstance().addOrUpdateItem(processItem);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
} else if (item instanceof JobletProcessItem) {
JobletProcessItem jobProcessItem = (JobletProcessItem) item;
ProcessType process = jobProcessItem.getJobletProcess();
SetupProcessDependenciesRoutinesDialog dialog = new SetupProcessDependenciesRoutinesDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), process, readonly);
if (dialog.open() == Window.OK && !readonly) {
process.getParameters().getRoutinesParameter().clear();
createRoutinesDependencies(process, dialog.getSystemRoutines());
createRoutinesDependencies(process, dialog.getUserRoutines());
try {
CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().save(jobProcessItem);
IJobletProviderService jobletService = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
if (jobletService != null) {
jobletService.loadComponentsFromProviders();
}
RelationshipItemBuilder.getInstance().addOrUpdateItem(jobProcessItem);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
}
use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.
the class OpenRepositoryJobHierarchyAction method doRun.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
protected void doRun() {
ISelection selection = getSelection();
Object obj = ((IStructuredSelection) selection).getFirstElement();
RepositoryNode node = (RepositoryNode) obj;
Property property = (Property) node.getObject().getProperty();
Property updatedProperty = null;
try {
updatedProperty = ProxyRepositoryFactory.getInstance().getLastVersion(new Project(ProjectManager.getInstance().getProject(property.getItem())), property.getId()).getProperty();
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
// update the property of the node repository object
if (node.getObject() instanceof IRepositoryObject) {
IRepositoryObject iobject = (IRepositoryObject) node.getObject();
iobject.setProperty(updatedProperty);
}
Assert.isTrue(property.getItem() instanceof ProcessItem);
// TODO should use a fake Process here to replace the real Process.
// Process loadedProcess = new Process(property);
// loadedProcess.loadXmlFile();
IDesignerCoreService designerCoreService = CorePlugin.getDefault().getDesignerCoreService();
Process loadedProcess = (Process) designerCoreService.getProcessFromProcessItem((ProcessItem) updatedProperty.getItem());
OpenJobHierarchyAction openAction = new OpenJobHierarchyAction(this.getViewPart());
openAction.run(loadedProcess);
}
use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.
the class OpenRepositoryJobHierarchyAction method init.
/*
* (non-Javadoc)
*
* @see org.talend.repository.ui.actions.ITreeContextualAction#init(org.eclipse.jface.viewers.TreeViewer,
* org.eclipse.jface.viewers.IStructuredSelection)
*/
public void init(TreeViewer viewer, IStructuredSelection selection) {
boolean canWork = selection.size() == 1;
if (canWork) {
Object o = selection.getFirstElement();
RepositoryNode node = (RepositoryNode) o;
switch(node.getType()) {
case REPOSITORY_ELEMENT:
if (node.getObjectType() != ERepositoryObjectType.PROCESS) {
canWork = false;
}
break;
default:
canWork = false;
}
if (canWork && node.getObject() != null && ProxyRepositoryFactory.getInstance().getStatus(node.getObject()) == ERepositoryStatus.DELETED) {
canWork = false;
}
}
setEnabled(canWork);
}
Aggregations