use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class ConnectionCreateCommandTest method executeSimpleInputToSimpleOutput3.
/**
* simple input to simple output with no metadata and without schema auto propagate.
*/
private ConnectionCreateCommand executeSimpleInputToSimpleOutput3() {
IProcess2 process = getFakeProcess();
Node simpleInputNode = NodeTestCreator.createSimpleInputNode(process);
// simple tests only since it's simply using the class ConnectionManager which already have JUnits.
List<Object> args = new ArrayList<Object>();
args.add(simpleInputNode.getUniqueName());
//$NON-NLS-1$
args.add("connectionName");
simpleInputNode.getMetadataList().clear();
IMetadataTable table = createSimpleMetadata1();
table.setTableName(simpleInputNode.getUniqueName());
table.setLabel(simpleInputNode.getUniqueName());
//$NON-NLS-1$
table.setAttachedConnector("FLOW");
simpleInputNode.getMetadataList().add(table);
// set null, the command should take the schema from the component directly
args.add(null);
//$NON-NLS-1$
ConnectionCreateCommand ccc = new ConnectionCreateCommand(simpleInputNode, "FLOW", args);
ConnectionCreateCommand.setCreatingConnection(true);
Node simpleOutputNode = NodeTestCreator.createSimpleOutputNodeNoPropagate(process);
ccc.setTarget(simpleOutputNode);
ccc.execute();
assertEquals(simpleInputNode.getOutgoingConnections().size(), 1);
assertEquals(simpleOutputNode.getIncomingConnections().size(), 1);
assertEquals(simpleOutputNode.getMetadataList().size(), 1);
IMetadataTable outputMetadata = simpleOutputNode.getMetadataList().get(0);
// no propagation
assertEquals(outputMetadata.getListColumns().size(), 0);
IConnection connection = simpleInputNode.getOutgoingConnections().get(0);
assertEquals(simpleOutputNode.getIncomingConnections().get(0), connection);
assertEquals(connection.getSource(), simpleInputNode);
assertEquals(connection.getTarget(), simpleOutputNode);
assertEquals(connection.getMetaName(), simpleInputNode.getUniqueName());
//$NON-NLS-1$
assertEquals(connection.getConnectorName(), "FLOW");
//$NON-NLS-1$
INodeConnector inputConnector = simpleInputNode.getConnectorFromName("FLOW");
//$NON-NLS-1$
INodeConnector outputConnector = simpleOutputNode.getConnectorFromName("FLOW");
assertEquals(inputConnector.getCurLinkNbOutput(), 1);
assertEquals(outputConnector.getCurLinkNbInput(), 1);
return ccc;
}
use of org.talend.core.model.process.IProcess2 in project tesb-studio-se by Talend.
the class ESBService method updateOperation.
@Override
public void updateOperation(INode node, String linkedRepository, RepositoryNode selectNode) {
String[] ids = linkedRepository.split(" - ");
if (ids.length == 3) {
try {
IRepositoryViewObject reViewObject = ProxyRepositoryFactory.getInstance().getLastVersion(ids[0]);
ServiceItem servicesItem = (ServiceItem) reViewObject.getProperty().getItem();
ServiceConnection serConn = (ServiceConnection) servicesItem.getConnection();
String portName = "";
EList<ServicePort> portList = serConn.getServicePort();
ServiceOperation operation = null;
for (ServicePort port : portList) {
if (port.getId().equals(ids[1])) {
portName = port.getName();
EList<ServiceOperation> opeList = port.getServiceOperation();
for (ServiceOperation ope : opeList) {
if (ope.getId().equals(ids[2])) {
operation = ope;
break;
}
}
break;
}
}
if (operation == null) {
return;
}
RepositoryNode topParent = getServicesTopNode(selectNode);
changeOldOperationLabel(topParent, node, operation);
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
IProcess2 process = (IProcess2) RepositoryPlugin.getDefault().getDesignerCoreService().getCurrentProcess();
Item jobItem = process.getProperty().getItem();
String jobID = jobItem.getProperty().getId();
String jobName = jobItem.getProperty().getLabel();
if (operation.getReferenceJobId() != null && !operation.getReferenceJobId().equals(jobID)) {
changeOtherJobSchemaValue(factory, operation, /* serConn, */
selectNode);
MessageDialog.openWarning(new Shell(), Messages.ESBService_DisconnectWarningTitle, Messages.ESBService_DisconnectWarningMsg);
}
operation.setReferenceJobId(jobID);
operation.setLabel(operation.getName() + '-' + jobName);
IFile wsdlPath = WSDLUtils.getWsdlFile(selectNode);
Map<String, String> serviceParameters = WSDLUtils.getServiceOperationParameters(wsdlPath, operation.getName(), portName);
CreateNewJobAction.setProviderRequestComponentConfiguration(node, serviceParameters);
factory.save(servicesItem);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
} catch (CoreException e) {
ExceptionHandler.process(e);
}
}
}
use of org.talend.core.model.process.IProcess2 in project tesb-studio-se by Talend.
the class AssignJobAction method assign.
public boolean assign(IRepositoryNode jobNode) {
if (jobNode == null) {
return false;
}
IRepositoryViewObject repositoryObject = jobNode.getObject();
final Item item = repositoryObject.getProperty().getItem();
// judge the job whether had T_ESB_PROVIDER_REQUEST
ProcessItem processItem = (ProcessItem) item;
NodeType providerNode = null;
for (Object obj : processItem.getProcess().getNode()) {
NodeType node = (NodeType) obj;
if (CreateNewJobAction.T_ESB_PROVIDER_REQUEST.equals(node.getComponentName())) {
providerNode = node;
break;
}
}
if (null == providerNode) {
MessageDialog.openWarning(Display.getCurrent().getActiveShell(), Messages.AssignJobAction_WarningTitle, Messages.AssignJobAction_WarningMessage);
return false;
}
try {
String jobID = item.getProperty().getId();
String jobName = item.getProperty().getLabel();
String operationName = repositoryNode.getObject().getLabel();
String portName = repositoryNode.getParent().getObject().getLabel();
ServiceItem serviceItem = (ServiceItem) repositoryNode.getParent().getParent().getObject().getProperty().getItem();
List<ServicePort> listPort = ((ServiceConnection) serviceItem.getConnection()).getServicePort();
for (ServicePort port : listPort) {
if (port.getName().equals(portName)) {
List<ServiceOperation> listOperation = port.getServiceOperation();
for (ServiceOperation operation : listOperation) {
if (operation.getLabel().equals(operationName)) {
// should not change the job name
// String jobNewName = port.getName() + "_" + operation.getName();
// if (resetJobname(item, jobNewName)) {
// jobName = jobNewName;
// }
operation.setReferenceJobId(jobID);
operation.setLabel(operation.getName() + "-" + jobName);
break;
}
}
break;
}
}
IFile wsdlPath = WSDLUtils.getWsdlFile(serviceItem);
Map<String, String> serviceParameters = WSDLUtils.getServiceOperationParameters(wsdlPath, ((OperationRepositoryObject) repositoryNode.getObject()).getName(), portName);
for (Object paramObj : providerNode.getElementParameter()) {
ElementParameterType param = (ElementParameterType) paramObj;
String name = param.getName();
if (serviceParameters.containsKey(name)) {
param.setValue(serviceParameters.get(name));
}
}
IProcess2 process = null;
IEditorReference[] reference = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
List<IProcess2> processes = RepositoryPlugin.getDefault().getDesignerCoreService().getOpenedProcess(reference);
for (IProcess2 processOpen : processes) {
if (processOpen.getProperty().getItem() == processItem) {
process = processOpen;
break;
}
}
if (process == null) {
IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
IProcess proc = service.getProcessFromProcessItem(processItem);
if (proc instanceof IProcess2) {
process = (IProcess2) proc;
}
}
if (process != null) {
List<? extends INode> nodelist = process.getGraphicalNodes();
for (INode node : nodelist) {
if (node.getComponent().getName().equals("tESBProviderRequest")) {
repositoryChange(repositoryNode, node);
}
}
processItem.setProcess(process.saveXmlFile());
}
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
factory.save(processItem);
factory.save(serviceItem);
return true;
} catch (Exception e) {
ExceptionHandler.process(e);
}
return false;
}
use of org.talend.core.model.process.IProcess2 in project tesb-studio-se by Talend.
the class ESBService method changeOtherJobSchemaValue.
// private void changenewOperationLabel(RepositoryNode newNode, INode node, ServiceConnection serConn) {
// String operationName = newNode.getObject().getLabel();
// String parentPortName = newNode.getParent().getObject().getLabel();
//
// String wsdlPath = serConn.getWSDLPath();
// try {
// Map<String, String> serviceParameters = WSDLUtils.getServiceParameters(wsdlPath);
// IRepositoryViewObject newObj = newNode.getObject();
// if (newObj instanceof OperationRepositoryObject) {
// ServiceOperation newOpe = (ServiceOperation) ((OperationRepositoryObject) newObj).getAbstractMetadataObject();
//
// IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
//
// if (newOpe.getReferenceJobId() != null) {
// changeOtherJobSchemaValue(factory, newOpe, serConn);
// MessageDialog.openWarning(new Shell(), "warning",
// "This other job which based on the Operation will be unset!");
// }
//
// IEditorPart activeEditor =
// PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
// IEditorInput input = activeEditor.getEditorInput();
// if (input instanceof ProcessEditorInput) {
// Item jobItem = ((ProcessEditorInput) input).getItem();
// String jobID = jobItem.getProperty().getId();
// String jobName = jobItem.getProperty().getLabel();
//
// newOpe.setReferenceJobId(jobID);
// newOpe.setLabel(newOpe.getName() + "-" + jobName);
//
// serviceParameters.put(WSDLUtils.PORT_NAME, parentPortName);
// serviceParameters.put(WSDLUtils.OPERATION_NAME, operationName);
//
// CreateNewJobAction.setProviderRequestComponentConfiguration(node, serviceParameters);
//
// try {
// factory.save(jobItem);
// } catch (PersistenceException e) {
// e.printStackTrace();
// }
// try {
// factory.save(newNode.getParent().getParent().getObject().getProperty().getItem());
// } catch (PersistenceException e) {
// e.printStackTrace();
// }
// RepositoryManager.refreshSavedNode(newNode);
// }
// }
//
// } catch (CoreException e1) {
// ExceptionHandler.process(e1);
// } catch (PersistenceException e) {
// ExceptionHandler.process(e);
// }
// }
private void changeOtherJobSchemaValue(IProxyRepositoryFactory factory, ServiceOperation newOpe, /*
* ServiceConnection
* serConn,
*/
RepositoryNode selectNode) throws PersistenceException, CoreException {
IRepositoryViewObject jobObj = factory.getLastVersion(newOpe.getReferenceJobId());
if (jobObj == null) {
return;
}
ProcessItem processItem = (ProcessItem) jobObj.getProperty().getItem();
IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
boolean foundInOpen = false;
IProcess2 process = null;
IEditorReference[] reference = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
List<IProcess2> processes = RepositoryPlugin.getDefault().getDesignerCoreService().getOpenedProcess(reference);
for (IProcess2 processOpen : processes) {
if (processOpen.getProperty().getItem() == processItem) {
foundInOpen = true;
process = processOpen;
break;
}
}
if (!foundInOpen) {
IProcess proc = service.getProcessFromProcessItem(processItem);
if (proc instanceof IProcess2) {
process = (IProcess2) proc;
}
}
newOpe.setReferenceJobId(null);
newOpe.setLabel(newOpe.getName());
if (process != null) {
List<? extends INode> nodelist = process.getGraphicalNodes();
for (INode node : nodelist) {
if (node.getComponent().getName().equals("tESBProviderRequest")) {
repositoryChange(selectNode, node, process);
break;
}
}
try {
if (!foundInOpen) {
processItem.setProcess(process.saveXmlFile());
factory.save(processItem);
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
} catch (IOException e) {
ExceptionHandler.process(e);
}
}
// ProcessType process = item.getProcess();
// EList<NodeType> nodeList = process.getNode();
//
// for (NodeType node : nodeList) {
// EList parameters = node.getElementParameter();
// for (Object paramObj : parameters) {
// ElementParameterType param = (ElementParameterType) paramObj;
// String name = param.getName();
// if (name.equals(WSDLUtils.OPERATION_NAME)) {
// if (!newOpe.getName().equals(param.getValue())) {
// break;
// }
// param.setValue(null);
// }
// if (name.equals("SCHEMA:SCHEMA_TYPE")) {
// param.setValue("BUILT_IN");
// break;
// }
//
// }
//
// }
// factory.save(item);
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class JobletConnectionReconnectCommand method execute.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.commands.Command#execute()
*/
@Override
public void execute() {
metadataChanges.clear();
if (newSource != null) {
INodeConnector connector = oldSource.getConnectorFromName(connectorName);
if (connector != null) {
connector.setCurLinkNbOutput(connector.getCurLinkNbOutput() - 1);
connector = newSource.getConnectorFromName(connectorName);
if (connector != null) {
connector.setCurLinkNbOutput(connector.getCurLinkNbOutput() + 1);
}
}
if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.FLOW)) {
newSourceSchemaType = (String) newSource.getPropertyValue(EParameterName.SCHEMA_TYPE.getName());
boolean builtInNewSource = newSource.getConnectorFromName(connectorName).isMultiSchema();
boolean builtInOldSource = oldSource.getConnectorFromName(connectorName).isMultiSchema();
if ((!builtInNewSource) && (!builtInOldSource)) {
setSchemaToNotBuiltInNode(oldSource, newSource, oldMetadataTable);
if (newSource.getJobletNode() != null) {
connection.setMetaName(newSource.getJobletNode().getUniqueName());
} else
connection.setMetaName(newSource.getUniqueName());
} else {
if (!builtInNewSource) {
int num = 0;
for (int i = 0; i < oldSource.getMetadataList().size(); i++) {
IMetadataTable meta = oldSource.getMetadataList().get(i);
if (meta.getTableName().equals(oldMetadataTable.getTableName())) {
num = i;
}
}
oldSource.getMetadataList().remove(num);
setSchemaToNotBuiltInNode(oldSource, newSource, oldMetadataTable);
if (newSource.getJobletNode() != null) {
connection.setMetaName(newSource.getJobletNode().getUniqueName());
} else
connection.setMetaName(newSource.getUniqueName());
}
if (!builtInOldSource) {
IMetadataTable meta = oldMetadataTable.clone();
meta.setTableName(connection.getUniqueName());
newSource.getMetadataList().add(meta);
connection.setMetaName(meta.getTableName());
}
if ((builtInOldSource) && (builtInNewSource)) {
int num = 0;
for (int i = 0; i < oldSource.getMetadataList().size(); i++) {
IMetadataTable meta = oldSource.getMetadataList().get(i);
if (meta.getTableName().equals(oldMetadataTable.getTableName())) {
num = i;
}
}
oldSource.getMetadataList().remove(num);
newSource.getMetadataList().add(oldMetadataTable);
}
}
if (newSourceSchemaType != null) {
newSource.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.BUILTIN);
}
if (oldSourceSchemaType != null) {
oldSource.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.BUILTIN);
}
} else {
if (newSource.getJobletNode() != null) {
connection.setMetaName(newSource.getJobletNode().getUniqueName());
} else
connection.setMetaName(newSource.getUniqueName());
}
connection.reconnect(newSource, oldTarget, newLineStyle);
connection.updateName();
if (newSourceSchemaType != null && connection.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA) && connector != null) {
IMetadataTable sourceMetadataTable = newSource.getMetadataFromConnector(connector.getName());
// IMetadataTable targetMetadataTable = oldTarget.getMetadataFromConnector(connector.getName());
if (oldMetadataTable != null && sourceMetadataTable != null) {
boolean sameFlag = oldMetadataTable.sameMetadataAs(sourceMetadataTable, IMetadataColumn.OPTIONS_NONE);
// For the auto propagate.
if (!sameFlag && oldTarget.getComponent().isSchemaAutoPropagated() && (oldMetadataTable.getListColumns().isEmpty() || getPropagateDialog())) {
ChangeMetadataCommand changeMetadataCmd = new ChangeMetadataCommand(oldTarget, null, null, sourceMetadataTable);
changeMetadataCmd.execute(true);
metadataChanges.add(changeMetadataCmd);
}
}
}
// ((Process) newSource.getProcess()).checkStartNodes();
// ((Process) newSource.getProcess()).checkProcess();
} else if (newTarget != null) {
newTargetSchemaType = (String) newTarget.getPropertyValue(EParameterName.SCHEMA_TYPE.getName());
INodeConnector connector = oldTarget.getConnectorFromType(oldLineStyle);
connector.setCurLinkNbInput(connector.getCurLinkNbInput() - 1);
connector = newTarget.getConnectorFromType(newLineStyle);
connector.setCurLinkNbInput(connector.getCurLinkNbInput() + 1);
connection.reconnect(oldSource, newTarget, newLineStyle);
connection.updateName();
if (newTargetSchemaType != null) {
if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA) && !connection.getLineStyle().equals(EConnectionType.FLOW_REF)) {
IMetadataTable targetOldMetadataTable = newTarget.getMetadataFromConnector(connector.getName());
if (oldMetadataTable != null && targetOldMetadataTable != null) {
boolean sameFlag = oldMetadataTable.sameMetadataAs(targetOldMetadataTable, IMetadataColumn.OPTIONS_NONE);
if (newTarget.getJobletNode() != null) {
IProcess2 jobletProcess = (IProcess2) newTarget.getJobletNode().getComponent().getProcess();
ERepositoryStatus status = ProxyRepositoryFactory.getInstance().getStatus(jobletProcess.getProperty().getItem());
if (!status.equals(ERepositoryStatus.READ_ONLY)) {
// For the auto propagate.
if (!sameFlag && newTarget.getComponent().isSchemaAutoPropagated() && (targetOldMetadataTable.getListColumns().isEmpty() || getPropagateDialog())) {
ChangeMetadataCommand changeMetadataCmd = new ChangeMetadataCommand(newTarget, null, null, oldMetadataTable);
changeMetadataCmd.execute(true);
metadataChanges.add(changeMetadataCmd);
}
}
}
}
}
newTarget.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.BUILTIN);
}
// ((Process) oldTarget.getProcess()).checkStartNodes();
// ((Process) oldTarget.getProcess()).checkProcess();
} else {
//$NON-NLS-1$
throw new IllegalStateException("Should not happen");
}
}
Aggregations