use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType 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.designer.core.model.utils.emf.talendfile.ElementParameterType in project tdi-studio-se by Talend.
the class HandleOracleSchemaMigrationTask method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() == ECodeLanguage.JAVA && processType != null) {
NodeType tOracleConnection = null;
for (Object nodeType : processType.getNode()) {
NodeType tmpNodeType = (NodeType) nodeType;
if (tmpNodeType.getComponentName().equals("tOracleConnection")) {
//$NON-NLS-1$
tOracleConnection = tmpNodeType;
break;
}
}
if (tOracleConnection != null) {
if (ComponentUtilities.getNodeProperty(tOracleConnection, "SCHEMA_DB") == null) {
//$NON-NLS-1$
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.addNodeProperty(tOracleConnection, "SCHEMA_DB", "TEXT");
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.setNodeValue(tOracleConnection, "SCHEMA_DB", "\"\"");
} else {
//$NON-NLS-1$
ElementParameterType elementParameter = ComponentUtilities.getNodeProperty(tOracleConnection, "SCHEMA_DB");
if (elementParameter.getValue().equals("ROOT")) {
//$NON-NLS-1$
//$NON-NLS-1$
elementParameter.setValue("\"\"");
}
}
}
return ExecutionResult.SUCCESS_WITH_ALERT;
} else {
return ExecutionResult.NOTHING_TO_DO;
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType in project tdi-studio-se by Talend.
the class CorrectBatchSizeForDBComponents method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
List<String> filterList = Arrays.asList("tAmazonOracleOutput", "tInformixOutput");
IComponentConversion correctBatchModeForDBComponents = new IComponentConversion() {
public void transform(NodeType node) {
ElementParameterType useExistingConnPara = ComponentUtilities.getNodeProperty(node, "USE_EXISTING_CONNECTION");
if (useExistingConnPara == null) {
ComponentUtilities.addNodeProperty(node, "USE_EXISTING_CONNECTION", "CHECK");
ComponentUtilities.getNodeProperty(node, "USE_EXISTING_CONNECTION").setValue("false");
}
ElementParameterType useBatchAndUseConnPara = ComponentUtilities.getNodeProperty(node, "USE_BATCH_AND_USE_CONN");
if (useBatchAndUseConnPara == null) {
ComponentUtilities.addNodeProperty(node, "USE_BATCH_AND_USE_CONN", "CHECK");
ComponentUtilities.getNodeProperty(node, "USE_BATCH_AND_USE_CONN").setValue("false");
}
boolean useExistConn = ComponentUtilities.getNodeProperty(node, "USE_EXISTING_CONNECTION").getValue().equalsIgnoreCase("true");
ElementParameterType elementParaType = ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE");
if (elementParaType == null) {
ComponentUtilities.addNodeProperty(node, "USE_BATCH_SIZE", "CHECK");
ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE").setValue("false");
}
if (!useExistConn) {
if (elementParaType != null && elementParaType.getValue().equalsIgnoreCase("true")) {
String batchSizeInStr = ComponentUtilities.getNodeProperty(node, "BATCH_SIZE").getValue();
if (batchSizeInStr != null && !"".equals(batchSizeInStr)) {
int batchSize = Integer.valueOf(batchSizeInStr);
if (batchSize <= 0) {
ComponentUtilities.getNodeProperty(node, "BATCH_SIZE").setValue("1");
}
}
}
}
}
};
for (String componentName : filterList) {
IComponentFilter filter = new NameComponentFilter(componentName);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(correctBatchModeForDBComponents));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType in project tdi-studio-se by Talend.
the class CorrectBatchSizeForDBComponentsMore method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
List<String> filterList = Arrays.asList("tAS400Output", "tNetezzaOutput", "tVerticaOutput", "tDB2Output", "tMSSqlOutput", "tPostgresqlOutput", "tSybaseOutput", "tVectorWiseOutput", "tAmazonMysqlOutput");
IComponentConversion correctBatchModeForDBComponents = new IComponentConversion() {
public void transform(NodeType node) {
ElementParameterType useExistingConnPara = ComponentUtilities.getNodeProperty(node, "USE_EXISTING_CONNECTION");
if (useExistingConnPara == null) {
ComponentUtilities.addNodeProperty(node, "USE_EXISTING_CONNECTION", "CHECK");
ComponentUtilities.getNodeProperty(node, "USE_EXISTING_CONNECTION").setValue("false");
}
ElementParameterType elementParaType = ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE");
if (elementParaType == null) {
ComponentUtilities.addNodeProperty(node, "USE_BATCH_SIZE", "CHECK");
ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE").setValue("false");
}
if (elementParaType != null && elementParaType.getValue().equalsIgnoreCase("true")) {
String batchSizeInStr = ComponentUtilities.getNodeProperty(node, "BATCH_SIZE").getValue();
if (batchSizeInStr != null && !"".equals(batchSizeInStr)) {
if (batchSizeInStr.matches("\\d+")) {
//$NON-NLS-1$
int batchSize = Integer.valueOf(batchSizeInStr);
if (batchSize <= 0) {
ComponentUtilities.getNodeProperty(node, "BATCH_SIZE").setValue("1");
}
}
}
}
}
};
for (String componentName : filterList) {
IComponentFilter filter = new NameComponentFilter(componentName);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(correctBatchModeForDBComponents));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType in project tdi-studio-se by Talend.
the class DisableUseBatchWhenRejectLineExists method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
List<String> filterList = Arrays.asList("tFirebirdOutput", "tGreenplumOutput", "tIngresOutput", "tInterbaseOutput", "tParAccelOutput", "tPostgresPlusOutput", "tSQLiteOutput", "tRedshiftOutput");
List<String> filterListMore = Arrays.asList("tTeradataOutput", "tOracleOutput");
IComponentConversion disableUseBatchWhenRejectLineExists = new IComponentConversion() {
public void transform(NodeType node) {
ElementParameterType useBatch = ComponentUtilities.getNodeProperty(node, "USE_BATCH");
List<ConnectionType> list = ComponentUtilities.getNodeOutputConnections(node);
for (ConnectionType connType : list) {
EConnectionType eConnType = EConnectionType.getTypeFromId(connType.getLineStyle());
if (eConnType == EConnectionType.FLOW_MAIN && connType.getConnectorName().equals("REJECT")) {
if (useBatch == null) {
ComponentUtilities.addNodeProperty(node, "USE_BATCH", "CHECK");
}
ComponentUtilities.getNodeProperty(node, "USE_BATCH").setValue("false");
break;
}
}
}
};
IComponentConversion disableUseBatchWhenRejectLineExistsMore = new IComponentConversion() {
public void transform(NodeType node) {
ElementParameterType useBatch = ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE");
ElementParameterType useBatchAndUseExistingConn = ComponentUtilities.getNodeProperty(node, "USE_BATCH_AND_USE_CONN");
List<ConnectionType> list = ComponentUtilities.getNodeOutputConnections(node);
for (ConnectionType connType : list) {
EConnectionType eConnType = EConnectionType.getTypeFromId(connType.getLineStyle());
if (eConnType == EConnectionType.FLOW_MAIN && connType.getConnectorName().equals("REJECT")) {
if (useBatch == null) {
ComponentUtilities.addNodeProperty(node, "USE_BATCH_SIZE", "CHECK");
}
if (useBatchAndUseExistingConn == null) {
ComponentUtilities.addNodeProperty(node, "USE_BATCH_AND_USE_CONN", "CHECK");
}
ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE").setValue("false");
ComponentUtilities.getNodeProperty(node, "USE_BATCH_AND_USE_CONN").setValue("false");
break;
}
}
}
};
for (String componentName : filterList) {
IComponentFilter filter = new NameComponentFilter(componentName);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(disableUseBatchWhenRejectLineExists));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
for (String componentName : filterListMore) {
IComponentFilter filter = new NameComponentFilter(componentName);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(disableUseBatchWhenRejectLineExistsMore));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
Aggregations