use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.
the class AbstractPreferenceComposite method addButtonListeners.
private void addButtonListeners() {
reloadBtn.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
onReloadButtonClick();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
saveBtn.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
onSaveButtonClick();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
if (hasRunJobNode(false) && needApplyToChildren()) {
applyToChildrenJob.addSelectionListener(new SelectionListener() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
// zli for bug 12335
final ProgressDialog progress = new ProgressDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()) {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorReference[] editorReferences = activePage.getEditorReferences();
CorePlugin defaultPlugin = CorePlugin.getDefault();
IDesignerCoreService designerCoreService = defaultPlugin.getDesignerCoreService();
List<IProcess2> openedProcessList = designerCoreService.getOpenedProcess(RepositoryUpdateManager.getEditors());
List<String> activeProcessId = new ArrayList<String>();
for (IProcess process : openedProcessList) {
activeProcessId.add(process.getId());
}
final int rate = 1 / openedProcessList.size() - activeProcessId.size();
for (INode runjobNode : tRunJobNodes) {
String id = (String) runjobNode.getElementParameter(EParameterName.PROCESS_TYPE_PROCESS.getName()).getValue();
String version = (String) runjobNode.getElementParameter(EParameterName.PROCESS_TYPE_VERSION.getName()).getValue();
if ("".equals(id) || id == null) {
//$NON-NLS-1$
MessageDialog.openWarning(getShell(), //$NON-NLS-1$
Messages.getString("AbstractPreferenceComposite.warning", runjobNode.getUniqueName()), Messages.getString("AbstractPreferenceComposite.jobAssigned", //$NON-NLS-1$
runjobNode.getUniqueName()));
return;
}
if (activeProcessId.contains(id)) {
IEditorPart activeEditorPart = activePage.getActiveEditor();
for (IEditorReference editorReference : editorReferences) {
IEditorPart editorPart = editorReference.getEditor(false);
if ((editorPart != activeEditorPart) && (editorPart instanceof MultiPageTalendEditor)) {
IElement element = ((MultiPageTalendEditor) editorPart).getProcess();
StatsAndLogsViewHelper.applySettings(elem, element, AbstractPreferenceComposite.this);
}
}
} else {
try {
SubProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1 * UpdatesConstants.SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
subMonitor.beginTask(UpdatesConstants.EMPTY, 1 * rate);
IRepositoryViewObject lastVersion = DesignerPlugin.getDefault().getProxyRepositoryFactory().getLastVersion(id);
if (lastVersion != null) {
Item item = lastVersion.getProperty().getItem();
IProcess processFromItem = designerCoreService.getProcessFromItem(item);
if (processFromItem instanceof Process) {
Process process = (Process) processFromItem;
StatsAndLogsViewHelper.applySettings(elem, process, AbstractPreferenceComposite.this);
IProxyRepositoryFactory factory = defaultPlugin.getProxyRepositoryFactory();
Property property = factory.getUptodateProperty(process.getProperty());
process.setProperty(property);
subMonitor.subTask(RepositoryUpdateManager.getUpdateJobInfor(process.getProperty()));
ProcessType processType = process.saveXmlFile();
Item item2 = process.getProperty().getItem();
if (item2 instanceof JobletProcessItem) {
((JobletProcessItem) item2).setJobletProcess((JobletProcess) processType);
} else {
((ProcessItem) item2).setProcess(processType);
}
factory.save(item2);
subMonitor.done();
}
}
} catch (PersistenceException e1) {
e1.printStackTrace();
} catch (IOException e2) {
e2.printStackTrace();
}
}
applySettingsToSubJob(id, version);
}
}
};
try {
progress.executeProcess();
} catch (InvocationTargetException e1) {
e1.printStackTrace();
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
/**
* yzhang Comment method "applySettingsToSubJob".
*
* @param id
* @param version
*/
private void applySettingsToSubJob(String id, String version) {
final ProcessItem processItem = ItemCacheManager.getProcessItem(id, version);
if (processItem == null) {
return;
}
ProcessType processType = processItem.getProcess();
EList<ElementParameterType> parameters = processType.getParameters().getElementParameter();
StatsAndLogsViewHelper.applySettings(parameters, elem);
List<NodeType> nodes = findRunJobNode(processType.getNode());
for (NodeType nodeType : nodes) {
EList<ElementParameterType> list = nodeType.getElementParameter();
ElementParameterType idParam = getElementParameterType(list, //$NON-NLS-1$
PROCESS + ":" + EParameterName.PROCESS_TYPE_PROCESS.getName());
ElementParameterType versionParam = getElementParameterType(list, //$NON-NLS-1$
PROCESS + ":" + EParameterName.PROCESS_TYPE_VERSION.getName());
String subId = idParam.getValue();
String subVersion = versionParam.getValue();
applySettingsToSubJob(subId, subVersion);
}
}
});
}
}
use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.
the class AbstractSchemaController method copySchemaFromChildJob.
public void copySchemaFromChildJob(Node runJobNode, final Item item) {
// 0004322: tRunJob can import the tBufferOutput schema from the son job
if (runJobNode != null && item instanceof ProcessItem) {
IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
IProcess process = service.getProcessFromProcessItem((ProcessItem) item);
List<? extends INode> graphicalNodes = process.getGraphicalNodes();
for (INode node : graphicalNodes) {
if ((node != null) && node.getComponent().getName().equals("tBufferOutput")) {
//$NON-NLS-1$
List<IMetadataTable> list = node.getMetadataList();
if (list.size() > 0) {
List<IMetadataTable> metadata = runJobNode.getMetadataList();
if (metadata.size() == 0) {
metadata.add(list.get(0).clone());
} else {
IMetadataTable table = metadata.get(0);
// clear schema of tRunJob, so we will replace with schema of tBufferOutput
table.getListColumns().clear();
List<IMetadataColumn> columns = list.get(0).getListColumns();
for (IMetadataColumn col : columns) {
table.getListColumns().add(col.clone());
}
}
// skip other tBufferOutput component
break;
}
}
}
}
}
use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.
the class GenerateDocAsHTMLWizardPage method getDefaultFileName.
/**
* yzhang Comment method "getDefaultFileName".
*/
protected String getDefaultFileName() {
if (nodes.length >= 1) {
String label = null;
String version = null;
RepositoryNode node = nodes[0];
if (node.getType() == ENodeType.SYSTEM_FOLDER || node.getType() == ENodeType.SIMPLE_FOLDER) {
label = node.getProperties(EProperties.LABEL).toString();
} else if (node.getType() == ENodeType.REPOSITORY_ELEMENT) {
IRepositoryViewObject repositoryObject = node.getObject();
if (repositoryObject.getProperty().getItem() instanceof ProcessItem) {
ProcessItem processItem = (ProcessItem) repositoryObject.getProperty().getItem();
label = processItem.getProperty().getLabel();
version = processItem.getProperty().getVersion();
}
}
if (version != null) {
//$NON-NLS-1$
return label + "_" + version;
} else {
return label;
}
}
//$NON-NLS-1$
return "";
}
use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.
the class PropertyChangeCommand method undo.
@Override
public void undo() {
IElementParameter currentParam = elem.getElementParameter(propName);
if (repositoryValueWasUsed) {
if (currentParam.getFieldType() == EParameterFieldType.MEMO_SQL) {
elem.setPropertyValue(EParameterName.QUERYSTORE_TYPE.getName(), EmfComponent.REPOSITORY);
} else {
elem.setPropertyValue(propertyTypeName, EmfComponent.REPOSITORY);
}
for (IElementParameter param : elem.getElementParameters()) {
String repositoryValue = param.getRepositoryValue();
if (param.isShow(elem.getElementParameters()) && (repositoryValue != null) && param.getCategory().equals(currentParam.getCategory())) {
param.setRepositoryValueUsed(true);
}
}
}
elem.setPropertyValue(propName, oldValue);
if (propName.contains(EParameterName.PROCESS_TYPE_PROCESS.getName())) {
// oldValue is the id of the job
ProcessItem processItem = ItemCacheManager.getProcessItem((String) oldValue);
if (processItem != null) {
currentParam.getParentParameter().setValue(processItem.getProperty().getLabel());
}
}
for (IElementParameter param : oldElementValues.keySet()) {
param.setValue(oldElementValues.get(param));
}
if (toUpdate) {
elem.setPropertyValue(updataComponentParamName, Boolean.TRUE);
}
if (changeMetadataCommands != null) {
int size = changeMetadataCommands.size();
for (int i = size - 1; 0 <= i; i--) {
ChangeMetadataCommand changeMetadataCommand = changeMetadataCommands.get(i);
changeMetadataCommand.undo();
}
}
if (updateELTMapComponentCommand != null) {
updateELTMapComponentCommand.undo();
}
CodeView.refreshCodeView(elem);
ComponentSettings.switchToCurComponentSettingsView();
JobSettings.switchToCurJobSettingsView();
refreshTraceConnections();
refreshResumingConnections();
if (elem instanceof Node) {
((Node) elem).checkAndRefreshNode();
}
refreshMR(propName);
}
use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.
the class PropertyChangeCommand method redo.
@Override
public void redo() {
IElementParameter currentParam = elem.getElementParameter(propName);
if (repositoryValueWasUsed) {
if (currentParam.getFieldType() == EParameterFieldType.MEMO_SQL) {
elem.setPropertyValue(EParameterName.QUERYSTORE_TYPE.getName(), EmfComponent.BUILTIN);
} else {
elem.setPropertyValue(propertyTypeName, EmfComponent.BUILTIN);
}
for (IElementParameter param : elem.getElementParameters()) {
boolean paramFlag = JobSettingsConstants.isExtraParameter(param.getName());
boolean extraFlag = JobSettingsConstants.isExtraParameter(propertyTypeName);
if (paramFlag == extraFlag) {
// for job settings extra.(feature 2710)
param.setRepositoryValueUsed(false);
}
}
}
elem.setPropertyValue(propName, newValue);
if (propName.contains(EParameterName.PROCESS_TYPE_PROCESS.getName())) {
// newValue is the id of the job
ProcessItem processItem = ItemCacheManager.getProcessItem((String) newValue);
if (processItem != null) {
currentParam.getParentParameter().setValue(processItem.getProperty().getLabel());
}
}
if (currentParam.getFieldType().equals(EParameterFieldType.CLOSED_LIST)) {
for (int i = 0; i < elem.getElementParameters().size(); i++) {
IElementParameter param = elem.getElementParameters().get(i);
if (param.getDefaultValues().size() > 0) {
param.setValueToDefault(elem.getElementParameters());
}
}
}
if (toUpdate) {
elem.setPropertyValue(updataComponentParamName, new Boolean(true));
}
if (changeMetadataCommands != null) {
for (ChangeMetadataCommand changeMetadataCommand : changeMetadataCommands) {
changeMetadataCommand.redo();
}
}
if (updateELTMapComponentCommand != null) {
updateELTMapComponentCommand.redo();
}
CodeView.refreshCodeView(elem);
ComponentSettings.switchToCurComponentSettingsView();
JobSettings.switchToCurJobSettingsView();
refreshTraceConnections();
refreshResumingConnections();
if (elem instanceof Node) {
((Node) elem).checkAndRefreshNode();
}
refreshMR(propName);
}
Aggregations