use of org.talend.designer.core.model.utils.emf.talendfile.ConnectionType in project tdi-studio-se by Talend.
the class RenameConnectionRunIfOkToOnComponentOkTask method renameConnections.
/**
* yzhang Comment method "renameConnections".
*
* @param item
* @param processType
* @throws PersistenceException
*/
private void renameConnections(Item item, ProcessType processType) throws PersistenceException {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
boolean modified = false;
for (Object o : processType.getConnection()) {
ConnectionType currentConnection = (ConnectionType) o;
if (currentConnection.getConnectorName().equals("RUN_OK")) {
//$NON-NLS-1$
currentConnection.setConnectorName(EConnectionType.ON_COMPONENT_OK.getName());
currentConnection.setLabel(EConnectionType.ON_COMPONENT_OK.getDefaultLinkName());
currentConnection.setLineStyle(EConnectionType.ON_COMPONENT_OK.getId());
modified = true;
}
}
if (modified) {
factory.save(item, true);
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.ConnectionType in project tesb-studio-se by Talend.
the class RouteJavaScriptOSGIForESBManager method collectRouteInfo.
private Map<String, Object> collectRouteInfo(ProcessItem processItem, IProcess process) {
Map<String, Object> routeInfo = new HashMap<String, Object>();
// route name and class name
//$NON-NLS-1$
routeInfo.put("name", processItem.getProperty().getLabel());
String className = getClassName(processItem);
String idName = className;
String suffix = getOsgiServiceIdSuffix();
if (suffix != null && suffix.length() > 0) {
idName += suffix;
}
//$NON-NLS-1$
routeInfo.put("className", className);
//$NON-NLS-2$
routeInfo.put("idName", idName);
boolean useSAM = false;
boolean hasCXFUsernameToken = false;
boolean hasCXFSamlConsumer = false;
boolean hasCXFSamlProvider = false;
boolean hasCXFRSSamlProviderAuthz = false;
Collection<NodeType> cSOAPs = EmfModelUtils.getComponentsByName(processItem, "cSOAP");
boolean hasCXFComponent = !cSOAPs.isEmpty();
cSOAPs.addAll(EmfModelUtils.getComponentsByName(processItem, "cREST"));
if (!cSOAPs.isEmpty()) {
Set<String> consumerNodes = new HashSet<String>();
@SuppressWarnings("unchecked") List<ConnectionType> connections = processItem.getProcess().getConnection();
for (ConnectionType conn : connections) {
consumerNodes.add(conn.getTarget());
}
boolean isEEVersion = isStudioEEVersion();
for (NodeType node : cSOAPs) {
boolean nodeUseSAM = false;
boolean nodeUseSaml = false;
boolean nodeUseAuthz = false;
boolean nodeUseRegistry = false;
// http://jira.talendforge.org/browse/TESB-3850
//$NON-NLS-1$
String format = EmfModelUtils.computeTextElementValue("DATAFORMAT", node);
if (!useSAM && !"RAW".equals(format)) {
//$NON-NLS-1$
nodeUseSAM = //$NON-NLS-1$
EmfModelUtils.computeCheckElementValue("ENABLE_SAM", node) || //$NON-NLS-1$
EmfModelUtils.computeCheckElementValue("SERVICE_ACTIVITY_MONITOR", node);
}
// security is disable in case CXF_MESSAGE or RAW dataFormat
if (!"CXF_MESSAGE".equals(format) && !"RAW".equals(format)) {
//$NON-NLS-1$ //$NON-NLS-2$
if (isEEVersion && EmfModelUtils.computeCheckElementValue("ENABLE_REGISTRY", node)) {
//$NON-NLS-1$
nodeUseRegistry = true;
// https://jira.talendforge.org/browse/TESB-10725
nodeUseSAM = false;
} else if (EmfModelUtils.computeCheckElementValue("ENABLE_SECURITY", node)) {
//$NON-NLS-1$
//$NON-NLS-1$
String securityType = EmfModelUtils.computeTextElementValue("SECURITY_TYPE", node);
if ("USER".equals(securityType)) {
//$NON-NLS-1$
hasCXFUsernameToken = true;
} else if ("SAML".equals(securityType)) {
//$NON-NLS-1$
nodeUseSaml = true;
nodeUseAuthz = isEEVersion && EmfModelUtils.computeCheckElementValue("USE_AUTHORIZATION", node);
}
}
}
useSAM |= nodeUseSAM;
if (consumerNodes.contains(ElementParameterParser.getUNIQUENAME(node))) {
hasCXFSamlConsumer |= nodeUseSaml | nodeUseRegistry;
} else {
hasCXFSamlProvider |= nodeUseSaml | nodeUseRegistry;
hasCXFRSSamlProviderAuthz |= nodeUseAuthz;
}
}
}
//$NON-NLS-1$
routeInfo.put("useSAM", useSAM);
//$NON-NLS-1$
routeInfo.put("hasCXFUsernameToken", hasCXFUsernameToken);
//$NON-NLS-1$
routeInfo.put("hasCXFSamlConsumer", hasCXFSamlConsumer);
//$NON-NLS-1$
routeInfo.put("hasCXFSamlProvider", hasCXFSamlProvider);
//$NON-NLS-1$
routeInfo.put("hasCXFRSSamlProviderAuthz", hasCXFRSSamlProviderAuthz && !hasCXFComponent);
//$NON-NLS-1$
routeInfo.put("hasCXFComponent", hasCXFComponent);
// route OSGi DataSources
//$NON-NLS-1$
routeInfo.put("dataSources", DataSourceConfig.getAliases(process));
//$NON-NLS-1$
routeInfo.put("routelets", routelets);
return routeInfo;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ConnectionType 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;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ConnectionType in project tdi-studio-se by Talend.
the class ReplaceRunBeforeAfterWithThenRunMigrationTask method isMultiJob.
/**
* To see whether the job with sub jobs.
*
* yzhang Comment method "isMulitiJob".
*
* @return
*/
private boolean isMultiJob(List<ConnectionType> connections) {
Map<String, Integer> map = new HashMap<String, Integer>();
for (ConnectionType conn : connections) {
if (conn.getLabel().equals(Messages.getString("ReplaceRunBeforeAfterWithThenRunMigrationTask.RunAfter")) || conn.getLabel().equals(Messages.getString("ReplaceRunBeforeAfterWithThenRunMigrationTask.RunBefore"))) {
//$NON-NLS-1$ //$NON-NLS-2$
if (map.containsKey(conn.getTarget())) {
int i = map.get(conn.getTarget());
map.put(conn.getTarget(), ++i);
} else {
map.put(conn.getTarget(), 1);
}
}
}
for (Integer flag : map.values()) {
if (flag > 1) {
return true;
}
}
return false;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ConnectionType in project tdi-studio-se by Talend.
the class ReplaceRunBeforeAfterWithThenRunMigrationTask method replaceConnections.
/**
* Replace run before and after connection with then run.
*
* yzhang Comment method "replaceConnections".
*
* @param processType
*
* @throws PersistenceException
*/
public void replaceConnections(Item item, ProcessType processType) throws PersistenceException {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
boolean modified = false;
Map<String, List> runAfterMap = new TreeMap<String, List>();
if (isMultiJob(processType.getConnection())) {
// TODO: if it's a job with muliti sub jobs an error mark need to be added in repository.
}
for (Object o : processType.getConnection()) {
ConnectionType currentConnection = (ConnectionType) o;
if (currentConnection.getLabel().equals(Messages.getString("ReplaceRunBeforeAfterWithThenRunMigrationTask.RunAfter"))) {
//$NON-NLS-1$
//$NON-NLS-1$
currentConnection.setLabel(Messages.getString("ReplaceRunBeforeAfterWithThenRunMigrationTask.ThenRun"));
currentConnection.setLineStyle(EConnectionType.ON_SUBJOB_OK.getId());
String sourceKey = currentConnection.getSource();
if (!runAfterMap.containsKey(sourceKey)) {
List<ConnectionType> connectionList = new ArrayList<ConnectionType>();
connectionList.add(currentConnection);
runAfterMap.put(sourceKey, connectionList);
} else {
runAfterMap.get(sourceKey).add(currentConnection);
}
modified = true;
} else if (currentConnection.getLabel().equals(Messages.getString("ReplaceRunBeforeAfterWithThenRunMigrationTask.RunBefore"))) {
//$NON-NLS-1$
//$NON-NLS-1$
currentConnection.setLabel(Messages.getString("ReplaceRunBeforeAfterWithThenRunMigrationTask.ThenRun"));
String target = currentConnection.getTarget();
currentConnection.setTarget(currentConnection.getSource());
currentConnection.setSource(target);
String sourceKey = currentConnection.getSource();
if (!runAfterMap.containsKey(sourceKey)) {
List<ConnectionType> connectionList = new ArrayList<ConnectionType>();
connectionList.add(currentConnection);
runAfterMap.put(sourceKey, connectionList);
} else {
runAfterMap.get(sourceKey).add(currentConnection);
}
modified = true;
}
}
if (modified) {
resetDirectionOfConnections(runAfterMap);
factory.save(item);
}
}
Aggregations