use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.
the class RenametParseXMLRowTotExtractXMLFieldMigrationTask method execute.
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() == ECodeLanguage.JAVA && processType != null) {
try {
//$NON-NLS-1$
IComponentFilter filter1 = new NameComponentFilter("tParseXMLRow");
IComponentConversion changeNodeNameConversion = new IComponentConversion() {
public void transform(NodeType node) {
ProcessType item = (ProcessType) node.eContainer();
for (Object o : item.getNode()) {
NodeType nt = (NodeType) o;
for (Object o1 : nt.getElementParameter()) {
ElementParameterType t = (ElementParameterType) o1;
String value = t.getValue();
if (value != null) {
if (value.contains("tParseXMLRow")) {
//$NON-NLS-1$
//$NON-NLS-1$ //$NON-NLS-2$
String replaceAll = value.replaceAll("tParseXMLRow", "tExtractXMLField");
t.setValue(replaceAll);
}
}
}
}
}
};
// bug 22125
ModifyComponentsAction.searchAndModify(item, processType, filter1, Arrays.<IComponentConversion>asList(new RenameComponentConversion("tExtractXMLField")));
return ExecutionResult.SUCCESS_WITH_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
} else {
return ExecutionResult.NOTHING_TO_DO;
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.NodeType 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 useSL = 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;
useSL |= // $NON-NLS-1$
EmfModelUtils.computeCheckElementValue("ENABLE_SL", node) || EmfModelUtils.computeCheckElementValue("SERVICE_LOCATOR", node);
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("useSL", useSL);
// $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.NodeType in project tesb-studio-se by Talend.
the class JavaCamelJobScriptsExportWSAction method exportAllReferenceRoutelets.
@SuppressWarnings("unchecked")
protected final void exportAllReferenceRoutelets(String routeName, ProcessItem routeProcess, Set<String> routelets) throws InvocationTargetException, InterruptedException {
for (NodeType node : (Collection<NodeType>) routeProcess.getProcess().getNode()) {
if (!EmfModelUtils.isComponentActive(node)) {
continue;
}
final ElementParameterType routeletId = EmfModelUtils.findElementParameterByName(EParameterName.PROCESS_TYPE.getName() + ':' + EParameterName.PROCESS_TYPE_PROCESS.getName(), node);
if (null != routeletId) {
final IRepositoryViewObject referencedRouteletNode;
try {
referencedRouteletNode = getJobRepositoryNode(routeletId.getValue(), CamelRepositoryNodeType.repositoryRouteletType);
// getRouteletRepositoryNode(routeletId);
} catch (PersistenceException e) {
throw new InvocationTargetException(e);
}
final ProcessItem routeletProcess = (ProcessItem) referencedRouteletNode.getProperty().getItem();
final String className = RouteJavaScriptOSGIForESBManager.getClassName(routeletProcess);
String idSuffix = "-" + routeName;
if (!routelets.add(className + idSuffix)) {
continue;
}
String routeletVersion = EmfModelUtils.findElementParameterByName(EParameterName.PROCESS_TYPE.getName() + ':' + EParameterName.PROCESS_TYPE_VERSION.getName(), node).getValue();
if (RelationshipItemBuilder.LATEST_VERSION.equals(routeletVersion)) {
routeletVersion = referencedRouteletNode.getVersion();
}
final File routeletFile;
try {
routeletFile = // $NON-NLS-1$
File.createTempFile("routelet", FileConstants.JAR_FILE_SUFFIX, new File(getTempDir()));
addBuildArtifact(referencedRouteletNode, "jar", routeletFile);
} catch (IOException e) {
throw new InvocationTargetException(e);
}
String routeletName = referencedRouteletNode.getLabel();
String routeletBundleName = routeName + "_" + routeletName;
String routeletBundleSymbolicName = routeletBundleName;
Project project = ProjectManager.getInstance().getCurrentProject();
if (project != null) {
String projectName = project.getLabel();
if (projectName != null && projectName.length() > 0) {
routeletBundleSymbolicName = projectName.toLowerCase() + '.' + routeletBundleSymbolicName;
}
}
String routeletModelVersion = PomIdsHelper.getJobVersion(referencedRouteletNode.getProperty());
String routeletModelGroupId = PomIdsHelper.getJobGroupId(referencedRouteletNode.getProperty());
List<ProjectReference> projectReferenceList = project.getProjectReferenceList();
// TESB-27979, if routelet is in the same project with route
boolean inMainProject = ProjectManager.getInstance().isInMainProject(project, routeletProcess);
// Use same Version and GroupId for routelet from route(TESB-27437, TESB-26578, TESB-22521)
if (projectReferenceList.size() == 0 || CommonUIPlugin.isFullyHeadless() || inMainProject) {
routeletModelVersion = getArtifactVersion();
routeletModelGroupId = getGroupId();
} else {
if (StringUtils.endsWith(PomIdsHelper.getJobVersion(routeProcess.getProperty()), MavenUrlHelper.VERSION_SNAPSHOT)) {
routeletModelVersion = StringUtils.endsWith(routeletModelVersion, MavenUrlHelper.VERSION_SNAPSHOT) ? routeletModelVersion : routeletModelVersion + "-" + MavenUrlHelper.VERSION_SNAPSHOT;
ILibraryManagerService localLibraryManager = (ILibraryManagerService) GlobalServiceRegister.getDefault().getService(ILibraryManagerService.class);
Dependency d = new Dependency();
d.setArtifactId(routeletBundleName);
d.setGroupId(routeletModelGroupId);
d.setVersion(routeletModelVersion);
localLibraryManager.deploy(routeletFile.toURI(), PomUtil.generateMvnUrl(d), new NullProgressMonitor());
}
}
BundleModel routeletModel = new BundleModel(routeletModelGroupId, routeletBundleName, routeletModelVersion, routeletFile);
if (featuresModel.addBundle(routeletModel)) {
String routeletBundleVersion = getArtifactVersion();
routeletBundleVersion = routeletBundleVersion.replace("-", ".");
exportRouteBundle(referencedRouteletNode, routeletFile, routeletVersion, routeletBundleName, routeletBundleSymbolicName, routeletBundleVersion, idSuffix, null, EmfModelUtils.findElementParameterByName(EParameterName.PROCESS_TYPE.getName() + ':' + EParameterName.PROCESS_TYPE_CONTEXT.getName(), node).getValue());
CamelFeatureUtil.addFeatureAndBundles(routeletProcess, featuresModel);
exportAllReferenceJobs(routeName, routeletProcess);
exportAllReferenceRoutelets(routeName, routeletProcess, routelets);
}
}
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tesb-studio-se by Talend.
the class CamelDesignerUtil method checkRouteInputExistInJob.
public static boolean checkRouteInputExistInJob(ProcessItem pi) {
if (pi == null || pi.getProcess() == null) {
return false;
}
EList<?> nodes = pi.getProcess().getNode();
Iterator<?> iterator = nodes.iterator();
while (iterator.hasNext()) {
Object next = iterator.next();
if (!(next instanceof NodeType)) {
continue;
}
NodeType nt = (NodeType) next;
if (!EmfModelUtils.isComponentActive(nt) && !EmfModelUtils.computeCheckElementValue("ACTIVATE", nt)) {
continue;
}
String componentName = nt.getComponentName();
if ("tRouteInput".equals(componentName)) {
return true;
} else if (service != null) {
ProcessType jobletProcess = service.getJobletProcess(nt);
if (jobletProcess == null) {
continue;
}
if (checkRouteInputExistInJoblet(jobletProcess)) {
return true;
}
}
}
return false;
}
use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tesb-studio-se by Talend.
the class ConsumerFaultResponseMigrationTask method addMoreFaultResponseMessage.
private void addMoreFaultResponseMessage(Item item) throws PersistenceException {
if (item instanceof ProcessItem) {
ProcessType processType = ((ProcessItem) item).getProcess();
for (Object o : processType.getNode()) {
if (o instanceof NodeType) {
NodeType currentNode = (NodeType) o;
if ("tESBConsumer".equals(currentNode.getComponentName())) {
Iterator<?> iterator = currentNode.getMetadata().iterator();
while (iterator.hasNext()) {
MetadataType metadataType = (MetadataType) iterator.next();
if ("FAULT".equals(metadataType.getConnector())) {
EList<?> column = metadataType.getColumn();
addColumn(column, faultActor);
addColumn(column, faultCode);
addColumn(column, faultNode);
addColumn(column, faultRole);
}
}
}
}
}
FACTORY.save(item, true);
}
}
Aggregations