use of org.talend.core.model.properties.JobletProcessItem in project tdi-studio-se by Talend.
the class ValidationRulesUtil method getComponentsFromItemId.
/**
* DOC ycbai Comment method "getComponentsFromItemId". modify from method getAppropriateComponent() of
* TalendEditorDropTargetListener.
*
* @param itemId
* @param type
* @param quickCreateInput
* @param quickCreateOutput
* @return
*/
public static IComponent getComponentsFromItemId(String itemId, ERepositoryObjectType type, boolean quickCreateInput, boolean quickCreateOutput) {
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
IRepositoryViewObject obj = null;
try {
obj = factory.getLastVersion(itemId);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (obj == null) {
return null;
}
Item item = obj.getProperty().getItem();
if (item == null) {
return null;
}
EDatabaseComponentName name = EDatabaseComponentName.getCorrespondingComponentName(item, type);
String componentName = null;
if (item instanceof JobletProcessItem) {
// joblet
componentName = item.getProperty().getLabel();
} else if (name == null) {
return null;
} else {
// tRunjob
componentName = name.getDefaultComponentName();
}
// tRunJob is special from our rules
if (name == EDatabaseComponentName.RunJob || item instanceof JobletProcessItem) {
return ComponentsFactoryProvider.getInstance().get(componentName, ComponentCategory.CATEGORY_4_DI.getName());
} else {
// for database, file, webservices, saleforce ...
List<IComponent> neededComponents = filterNeededComponents(item, type);
IComponent component = chooseOneComponent(neededComponents, name, quickCreateInput, quickCreateOutput);
return component;
}
}
use of org.talend.core.model.properties.JobletProcessItem in project tdi-studio-se by Talend.
the class UpgradeParameterHelper method upgradeItem.
/**
*
* ggu Comment method "upgradeItem".
*
* upgrade the item parameters.
*/
//$NON-NLS-1$
@SuppressWarnings("unchecked")
public static boolean upgradeItem(Item item) {
if (item == null) {
return false;
}
boolean changed = false;
if (item instanceof ProcessItem) {
// job
ProcessType process = ((ProcessItem) item).getProcess();
if (process != null) {
ParametersType parameters = process.getParameters();
if (parameters != null) {
changed = upgradeMainParameters(parameters.getElementParameter());
}
changed = changed | upgradeNodes(process.getNode());
}
} else if (item instanceof JobletProcessItem) {
// Joblet
JobletProcess jobletProcess = ((JobletProcessItem) item).getJobletProcess();
if (jobletProcess != null) {
ParametersType parameters = jobletProcess.getParameters();
if (parameters != null) {
changed = upgradeMainParameters(parameters.getElementParameter());
}
changed = changed | upgradeNodes(jobletProcess.getNode());
}
}
return changed;
}
use of org.talend.core.model.properties.JobletProcessItem in project tdi-studio-se by Talend.
the class AddScreenshotFileMigrationTask method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
byte[] screenshotStream = null;
EList nodeList = null;
try {
if (item instanceof ProcessItem) {
ProcessItem process = (ProcessItem) item;
screenshotStream = process.getProcess().getScreenshot();
process.getProcess().getScreenshots().put("process", screenshotStream);
nodeList = process.getProcess().getNode();
for (int i = 0; i < nodeList.size(); i++) {
String nodeName;
NodeType node = (NodeType) nodeList.get(i);
if (node.getScreenshot() != null && node.getScreenshot().length > 0) {
EList params = node.getElementParameter();
for (int j = 0; j < params.size(); j++) {
ElementParameterType type = (ElementParameterType) params.get(j);
if ("UNIQUE_NAME".equals(type.getName())) {
nodeName = type.getValue();
process.getProcess().getScreenshots().put(nodeName, node.getScreenshot());
break;
}
}
node.setScreenshot(null);
}
}
process.getProcess().setScreenshot(null);
} else if (item instanceof JobletProcessItem) {
JobletProcessItem joblet = (JobletProcessItem) item;
screenshotStream = ((JobletProcessItem) item).getJobletProcess().getScreenshot();
joblet.getJobletProcess().getScreenshots().put("process", screenshotStream);
nodeList = joblet.getJobletProcess().getNode();
for (int i = 0; i < nodeList.size(); i++) {
String nodeName;
NodeType node = (NodeType) nodeList.get(i);
if (node.getScreenshot() != null && node.getScreenshot().length > 0) {
EList params = node.getElementParameter();
for (int j = 0; j < params.size(); j++) {
ElementParameterType type = (ElementParameterType) params.get(j);
if ("UNIQUE_NAME".equals(type.getName())) {
nodeName = type.getValue();
joblet.getJobletProcess().getScreenshots().put(nodeName, node.getScreenshot());
break;
}
}
node.setScreenshot(null);
}
}
joblet.getJobletProcess().setScreenshot(null);
}
ProxyRepositoryFactory.getInstance().save(item, true);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
use of org.talend.core.model.properties.JobletProcessItem in project tdi-studio-se by Talend.
the class ReplaceRunJobLabelVariableMigrationTask method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
@SuppressWarnings("unchecked")
@Override
public ExecutionResult execute(Item item) {
try {
List<NodeType> nodes = null;
if (item instanceof ProcessItem) {
nodes = ((ProcessItem) item).getProcess().getNode();
} else if (item instanceof JobletProcessItem) {
nodes = ((JobletProcessItem) item).getJobletProcess().getNode();
}
if (nodes != null) {
boolean modified = false;
for (NodeType node : nodes) {
if (ModifyComponentsAction.searchAndModify(node, filter, Arrays.<IComponentConversion>asList(replaceConversion))) {
modified = true;
}
}
if (modified) {
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
factory.save(item, true);
}
}
return ExecutionResult.SUCCESS_WITH_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
use of org.talend.core.model.properties.JobletProcessItem in project tdi-studio-se by Talend.
the class NodePart method performRequest.
@Override
public void performRequest(Request req) {
Node node = (Node) getModel();
IExternalData oldExternalData = node.getExternalData();
if (req.getType().equals(RequestConstants.REQ_OPEN)) {
IExternalNode externalNode = null;
if (node.isExternalNode()) {
IElementParameter externalParam = node.getElementParameterFromField(EParameterFieldType.EXTERNAL);
if (externalParam != null && externalParam.isShow(node.getElementParameters())) {
externalNode = ExternalUtilities.getExternalNodeReadyToOpen(node);
}
}
IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (externalNode != null && (part instanceof AbstractMultiPageTalendEditor)) {
boolean isOriginalNode = false;
ITestContainerProviderService testContainerService = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
testContainerService = (ITestContainerProviderService) GlobalServiceRegister.getDefault().getService(ITestContainerProviderService.class);
if (testContainerService != null) {
isOriginalNode = testContainerService.isOriginalNode(node);
if (isOriginalNode) {
testContainerService.renameConnection(node, true);
}
}
}
int returnValue = externalNode.open(getViewer().getControl().getShell());
if (!node.isReadOnly()) {
if (returnValue == SWT.OK) {
Command cmd = new ExternalNodeChangeCommand(node, externalNode, oldExternalData);
CommandStack cmdStack = (CommandStack) part.getAdapter(CommandStack.class);
cmdStack.execute(cmd);
} else {
externalNode.setExternalData(oldExternalData);
}
}
if (isOriginalNode && (testContainerService != null)) {
testContainerService.renameConnection(node, false);
}
} else {
// add for feature 13361
boolean isJoblet = false;
if (PluginChecker.isJobLetPluginLoaded()) {
AbstractProcessProvider jobletProcessProvider = AbstractProcessProvider.findProcessProviderFromPID(IComponent.JOBLET_PID);
final IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
boolean isAvoidShowJobletAfterDoubleClick = false;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IComponentsLocalProviderService.class)) {
IComponentsLocalProviderService componentService = (IComponentsLocalProviderService) GlobalServiceRegister.getDefault().getService(IComponentsLocalProviderService.class);
if (componentService != null) {
isAvoidShowJobletAfterDoubleClick = componentService.isAvoidToShowJobletAfterDoubleClick();
}
}
if (service != null && service.isJobletComponent(node) && !isAvoidShowJobletAfterDoubleClick) {
isJoblet = true;
String version = (String) node.getPropertyValue(EParameterName.PROCESS_TYPE_VERSION.getName());
final Item jobletItem = jobletProcessProvider.getJobletItem(node, version);
RepositoryWorkUnit<Object> repositoryWorkUnit = new RepositoryWorkUnit<Object>("", this) {
@Override
protected void run() throws LoginException, PersistenceException {
if (jobletItem != null) {
service.openJobletItem((JobletProcessItem) jobletItem);
}
}
};
repositoryWorkUnit.setAvoidUnloadResources(true);
CoreRuntimePlugin.getInstance().getProxyRepositoryFactory().executeRepositoryWorkUnit(repositoryWorkUnit);
}
}
if (!isJoblet) {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
String processName = (String) node.getPropertyValue(EParameterName.PROCESS_TYPE_PROCESS.getName());
String version = (String) node.getPropertyValue(EParameterName.PROCESS_TYPE_VERSION.getName());
boolean isAvoidShowJobAfterDoubleClick = false;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IComponentsLocalProviderService.class)) {
IComponentsLocalProviderService service = (IComponentsLocalProviderService) GlobalServiceRegister.getDefault().getService(IComponentsLocalProviderService.class);
if (service != null) {
isAvoidShowJobAfterDoubleClick = service.isAvoidToShowJobAfterDoubleClick();
}
}
// bug 20796
boolean isSelectUseDynamic = false;
Object useDynamicJobValue = node.getPropertyValue(EParameterName.USE_DYNAMIC_JOB.getName());
if (useDynamicJobValue != null && useDynamicJobValue instanceof Boolean) {
isSelectUseDynamic = (Boolean) useDynamicJobValue;
}
if (processName != null && !"".equals(processName) && !isAvoidShowJobAfterDoubleClick && !isSelectUseDynamic) {
//$NON-NLS-1$
ItemCacheManager.clearCache();
ProcessItem processItem = ItemCacheManager.getProcessItem(processName, version);
if (processItem == null) {
return;
}
Property updatedProperty = null;
try {
updatedProperty = ProxyRepositoryFactory.getInstance().getLastVersion(new Project(ProjectManager.getInstance().getProject(processItem)), processName).getProperty();
} catch (PersistenceException e) {
CommonExceptionHandler.process(e);
}
// update the property of the node repository object
// node.getObject().setProperty(updatedProperty);
processItem = (ProcessItem) updatedProperty.getItem();
final ProcessItem item = processItem;
RepositoryWorkUnit<Object> repositoryWorkUnit = new RepositoryWorkUnit<Object>("", this) {
@Override
protected void run() throws LoginException, PersistenceException {
try {
if (item != null) {
ERepositoryObjectType repObjType = ERepositoryObjectType.getItemType(item);
IJobEditorHandler editorInputFactory = JobEditorHandlerManager.getInstance().extractEditorInputFactory(repObjType.getType());
editorInputFactory.openJobEditor(editorInputFactory.createJobEditorInput(item, true));
}
} catch (PartInitException e) {
MessageBoxExceptionHandler.process(e);
}
}
};
repositoryWorkUnit.setAvoidUnloadResources(true);
CoreRuntimePlugin.getInstance().getProxyRepositoryFactory().executeRepositoryWorkUnit(repositoryWorkUnit);
} else {
try {
// modified for feature 2454.
page.showView(ComponentSettingsView.ID);
} catch (PartInitException e) {
CommonExceptionHandler.process(e);
}
}
}
}
}
super.performRequest(req);
}
Aggregations