use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class QueryGuessCommand method generateNewQueryFromDQRuler.
private String generateNewQueryFromDQRuler(IElementParameter dqRulerParam) {
ITDQRuleService rulerService = null;
try {
rulerService = (ITDQRuleService) GlobalServiceRegister.getDefault().getService(ITDQRuleService.class);
} catch (RuntimeException e) {
// nothing to do
}
if (rulerService != null) {
//$NON-NLS-1$
IElementParameter existConnection = node.getElementParameter("USE_EXISTING_CONNECTION");
boolean useExistConnection = (existConnection == null ? false : (Boolean) existConnection.getValue());
INode connectionNode = null;
if (node != null && node instanceof INode) {
process = ((INode) node).getProcess();
}
if (useExistConnection && process != null) {
IElementParameter connector = node.getElementParameter("CONNECTION");
if (connector != null) {
String connectorValue = connector.getValue().toString();
List<? extends INode> graphicalNodes = process.getGeneratingNodes();
for (INode node : graphicalNodes) {
if (node.getUniqueName().equals(connectorValue)) {
connectionNode = node;
break;
}
}
}
}
//$NON-NLS-1$
IElementParameter typeParam = node.getElementParameter("TYPE");
IElementParameter dbParam = node.getElementParameter(EParameterName.DBNAME.getName());
IContext lastRunContext = ((IProcess2) process).getLastRunContext();
String dbName = JavaProcessUtil.getRealParamValue(process, dbParam.getValue().toString(), lastRunContext);
IElementParameter schemaParam = node.getElementParameter(EParameterName.SCHEMA_DB.getName());
String schemaName = JavaProcessUtil.getRealParamValue(process, schemaParam == null ? org.apache.commons.lang.StringUtils.EMPTY : schemaParam.getValue().toString(), lastRunContext);
IElementParameter tableParam = node.getElementParameterFromField(EParameterFieldType.DBTABLE);
String tableName = JavaProcessUtil.getRealParamValue(process, tableParam.getValue().toString(), lastRunContext);
//$NON-NLS-1$
IElementParameter whereClause = node.getElementParameter("WHERE_CLAUSE");
String whereStr = org.apache.commons.lang.StringUtils.EMPTY;
if (whereClause.getValue() != null) {
whereStr = JavaProcessUtil.getRealParamValue(process, whereClause.getValue().toString(), lastRunContext);
}
if (connectionNode != null) {
//$NON-NLS-1$
typeParam = connectionNode.getElementParameter("TYPE");
dbParam = connectionNode.getElementParameter(EParameterName.DBNAME.getName());
dbName = JavaProcessUtil.getRealParamValue(process, dbParam.getValue().toString(), lastRunContext);
schemaParam = connectionNode.getElementParameter(EParameterName.SCHEMA_DB.getName());
schemaName = JavaProcessUtil.getRealParamValue(process, schemaParam == null ? org.apache.commons.lang.StringUtils.EMPTY : schemaParam.getValue().toString(), lastRunContext);
}
List<IMetadataTable> metadataList = null;
IMetadataTable metadataTable = null;
if (node instanceof Node) {
metadataList = ((Node) node).getMetadataList();
if (metadataList != null && !metadataList.isEmpty()) {
metadataTable = metadataList.get(0);
}
}
return rulerService.getQueryByRule(dqRulerParam, typeParam, dbName, schemaName, tableName, metadataTable, node.getElementName().contains("Invalid"), //$NON-NLS-1$
whereStr);
}
return org.apache.commons.lang.StringUtils.EMPTY;
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class TalendEditorComponentCreationUtil method addComponentCreationAssist.
public static void addComponentCreationAssist(AbstractTalendEditor talendEditor) {
final GraphicalViewer graphicalViewer = (GraphicalViewer) talendEditor.getAdapter(GraphicalViewer.class);
final CommandStack commandStack = (CommandStack) talendEditor.getAdapter(CommandStack.class);
final String categoryName = talendEditor.getComponenentsHandler().extractComponentsCategory().getName();
final IProcess2 process = talendEditor.getProcess();
KeyListener listener = new KeyListener() {
@Override
public void keyReleased(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
if (Character.isISOControl(e.character) || Character.isSpaceChar(e.character)) {
return;
}
TalendEditorComponentCreationAssist assist = new TalendEditorComponentCreationAssist(categoryName, graphicalViewer, commandStack, process);
assist.showComponentCreationAssist(e.character);
}
};
graphicalViewer.getControl().addKeyListener(listener);
graphicalViewer.getControl().setData(COMPONENT_CREATION_ASSIST_LISTENER, listener);
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class JobLaunchConfigurationDelegate method findProcessFromRepository.
/**
* DOC bqian Comment method "findProcessFromRepository".
*
* @param jobName
* @return
*/
private IProcess2 findProcessFromRepository(String jobId, String version) {
try {
ItemCacheManager.clearCache();
ProcessItem processItem = ItemCacheManager.getProcessItem(jobId, version);
if (processItem != null) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreService.class)) {
IDesignerCoreService service = (IDesignerCoreService) GlobalServiceRegister.getDefault().getService(IDesignerCoreService.class);
IProcess process = service.getProcessFromItem(processItem);
if (process instanceof IProcess2) {
return (IProcess2) process;
}
}
// keep old code for now, but it should never be called.
ProcessEditorInput fileEditorInput = new ProcessEditorInput(processItem, true, true, true);
IProcess2 process = fileEditorInput.getLoadedProcess();
return process;
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
return null;
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class MissingSettingsMultiThreadDynamicComposite method afterChangingLibraries.
@Override
public void afterChangingLibraries() {
final Element ele = this.getElement();
if (ele instanceof Node) {
final Node node = (Node) ele;
// after install, need update the error marks for node
IProcess process = node.getProcess();
if (process instanceof IProcess2) {
// check whole process to make sure other related nodes can be updated also.
((IProcess2) process).checkProcess();
}
}
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class AbstractMultiPageTalendEditor method doSave.
/**
* Saves the multi-page editor's document.
*/
@Override
public void doSave(final IProgressMonitor monitor) {
Item curItem = getProcess().getProperty().getItem();
IRepositoryService service = CorePlugin.getDefault().getRepositoryService();
IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
try {
// For TDI-23825, if not lock by user try to lock again.
if (!getProcess().isReadOnly()) {
repFactory.lock(curItem);
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
if (getProcess().isReadOnly() || repFactory.isUserReadOnlyOnCurrentProject()) {
MessageDialog.openWarning(getEditor(0).getEditorSite().getShell(), Messages.getString("AbstractMultiPageTalendEditor.readonly"), Messages.getString("AbstractMultiPageTalendEditor.readonlyMessage"));
return;
}
ERepositoryStatus status = repFactory.getStatus(curItem);
if (!status.equals(ERepositoryStatus.LOCK_BY_USER) && !repFactory.getRepositoryContext().isEditableAsReadOnly()) {
MessageDialog.openWarning(getEditor(0).getEditorSite().getShell(), Messages.getString("AbstractMultiPageTalendEditor.canNotSaveTitle"), Messages.getString("AbstractMultiPageTalendEditor.canNotSaveMessage"));
return;
}
if (!isDirty()) {
return;
}
Map<String, Boolean> jobletMap = new HashMap<String, Boolean>();
changeCollapsedState(true, jobletMap);
updateRunJobContext();
designerEditor.getProcess().getProperty().eAdapters().remove(dirtyListener);
repFactory.addRepositoryWorkUnitListener(repositoryWorkListener);
if (jobletEditor == getActiveEditor()) {
boolean isDirty = jobletEditor.isDirty();
refreshPropertyDirtyStatus();
jobletEditor.doSave(monitor);
try {
IProcess2 oldProcess = getProcess();
ICreateXtextProcessService n = CorePlugin.getDefault().getCreateXtextProcessService();
ProcessType processType = n.convertDesignerEditorInput(((IFile) jobletEditor.getEditorInput().getAdapter(IResource.class)).getLocation().toOSString(), oldProcess.getProperty());
IProcess2 newProcess = null;
Item item = getProcess().getProperty().getItem();
if (item instanceof ProcessItem) {
((Process) designerEditor.getProcess()).updateProcess(processType);
if (isDirty) {
getProcess().setProcessModified(true);
getProcess().setNeedRegenerateCode(true);
}
} else if (item instanceof JobletProcessItem) {
AbstractProcessProvider processProvider = AbstractProcessProvider.findProcessProviderFromPID(IComponent.JOBLET_PID);
if (processProvider != null) {
newProcess = processProvider.buildNewGraphicProcess(item);
}
designerEditor.setProcess(newProcess);
Boolean lastVersion = null;
if (oldProcess instanceof ILastVersionChecker) {
lastVersion = ((ILastVersionChecker) oldProcess).isLastVersion(item);
}
if (designerEditor.getEditorInput() instanceof JobEditorInput) {
((JobEditorInput) designerEditor.getEditorInput()).checkInit(lastVersion, null, true);
}
}
getEditor(0).doSave(monitor);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
} else {
refreshPropertyDirtyStatus();
getEditor(0).doSave(monitor);
}
/*
* refresh should be executed before add the listener,or it will has eProxy on the property,it will cause a
* editor dirty problem. hywang commet bug 17357
*/
if (processEditorInput != null) {
propertyInformation = new ArrayList(processEditorInput.getItem().getProperty().getInformations());
propertyIsDirty = false;
}
if (designerEditor != null && dirtyListener != null) {
designerEditor.getProcess().getProperty().eAdapters().add(dirtyListener);
}
refreshJobSettingsView();
changeCollapsedState(false, jobletMap);
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
ITestContainerProviderService testContainerService = (ITestContainerProviderService) GlobalServiceRegister.getDefault().getService(ITestContainerProviderService.class);
if (testContainerService != null) {
testContainerService.updateDetect(getProcess(), false);
}
}
if (isCheckout) {
CommandStack stack = (CommandStack) getAdapter(CommandStack.class);
stack.flush();
isCheckout = false;
}
}
Aggregations