Author: objectiser
Date: 2008-08-01 11:14:49 -0400 (Fri, 01 Aug 2008)
New Revision: 213
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/util/ConversationUtil.java
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/META-INF/MANIFEST.MF
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/GenerateDialog.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationInteractionModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/IfModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/util/InteractionUtil.java
Log:
Generation dialog now creates the Java project, stores the jboss-esb.xml and creates the
business object type class.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/META-INF/MANIFEST.MF
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/META-INF/MANIFEST.MF 2008-08-01
11:06:31 UTC (rev 212)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/META-INF/MANIFEST.MF 2008-08-01
15:14:49 UTC (rev 213)
@@ -13,7 +13,8 @@
org.scribble.osgi,
org.scribble.conversation.model,
org.scribble.lang.model,
- org.scribble.core
+ org.scribble.core,
+ org.eclipse.jface.text
Scribble-Extensions: org.jboss.tools.overlord.jbossesb.parser.JBossESBParser,
org.jboss.tools.overlord.jbossesb.parser.JBossESBNotation,
org.jboss.tools.overlord.jbossesb.validation.ESBLanguageModelValidationRule,
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/GenerateDialog.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/GenerateDialog.java 2008-08-01
11:06:31 UTC (rev 212)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/GenerateDialog.java 2008-08-01
15:14:49 UTC (rev 213)
@@ -20,6 +20,11 @@
import java.util.logging.Level;
import java.util.logging.Logger;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.dialogs.IDialogConstants;
@@ -29,15 +34,17 @@
import org.eclipse.swt.widgets.*;
import org.jboss.tools.overlord.jbossesb.model.DefaultESBLanguageModel;
import org.jboss.tools.overlord.jbossesb.model.ESBLanguageModel;
+import org.jboss.tools.overlord.jbossesb.model.util.ConversationUtil;
+import org.jboss.tools.overlord.jbossesb.model.util.InteractionUtil;
import org.scribble.conversation.model.ConversationModel;
import org.scribble.extensions.RegistryFactory;
-import org.scribble.model.DefaultModelListener;
-import org.scribble.model.Model;
-import org.scribble.model.ModelReference;
-import org.scribble.model.ModelRepository;
-import org.scribble.model.Role;
+import org.scribble.model.*;
import org.scribble.model.change.ModelGenerator;
+import org.scribble.conversation.model.*;
+import org.w3c.dom.Node;
import org.eclipse.jdt.core.*;
+import org.eclipse.jdt.core.dom.*;
+import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
@@ -47,11 +54,11 @@
*/
public class GenerateDialog extends org.eclipse.jface.dialogs.Dialog {
+ private static final String ESB_CONFIG_PATH = "src/conf/jboss-esb.xml";
private static final String JAVA_SOURCE_LOCATION = "src/java";
-
private static final String CLASSPATH_FILENAME = ".classpath";
-
private static final String OUTPUT_LOCATION = "classes";
+
/**
* This is the constructor for the generate dialog.
*
@@ -370,6 +377,180 @@
org.w3c.dom.Element esbConfig, ConversationModel localcm)
throws Exception {
+ IJavaProject jproj=createJavaProject(projectName);
+
+ if (jproj != null && esbConfig != null) {
+ // Store ESB configuration
+ IPath esbConfigPath=jproj.getPath().append(new Path(ESB_CONFIG_PATH));
+
+ IFile
esbConfigFile=jproj.getProject().getWorkspace().getRoot().getFile(esbConfigPath);
+ createParentFolder(esbConfigFile);
+ esbConfigFile.create(null, true,
+ new org.eclipse.core.runtime.NullProgressMonitor());
+
+ String config=getText(esbConfig);
+
+ if (config != null) {
+ esbConfigFile.setContents(new java.io.ByteArrayInputStream(
+ config.getBytes()), true, false,
+ new org.eclipse.core.runtime.NullProgressMonitor());
+ }
+
+ // Generate business object types for
+ // local conversation model
+ generateBusinessObjectType(jproj, localcm.getConversation());
+ }
+ }
+
+ protected void generateBusinessObjectType(IJavaProject jproj,
+ Conversation conversation) throws Exception {
+
+ IPath sourceLocation=jproj.getPath().append(new Path(JAVA_SOURCE_LOCATION));
+
+ String javaClass=ConversationUtil.getBusinessObjectType(conversation);
+
+ String javaPath=javaClass.replace('.', '/')+".java";
+
+ IPath javaFile=sourceLocation.append(new Path(javaPath));
+
+ IFile file=jproj.getProject().getWorkspace().getRoot().getFile(javaFile);
+ createParentFolder(file);
+ file.create(null, true, new org.eclipse.core.runtime.NullProgressMonitor());
+
+ String text="package "+
+ ConversationUtil.getBusinessObjectTypePackageName(conversation)+";\r\n"+
+ "public class "+
+ ConversationUtil.getBusinessObjectTypeClassName(conversation)+"
{\r\n}\r\n";
+
+ ASTParser parser = ASTParser.newParser(AST.JLS3);
+ parser.setResolveBindings(true);
+ parser.setSource(new char[0]);
+
+ CompilationUnit root=(CompilationUnit)parser.createAST(null);
+
+ AST ast=root.getAST();
+
+ org.eclipse.jface.text.IDocument doc=
+ new org.eclipse.jface.text.Document();
+
+ root.recordModifications();
+
+ PackageDeclaration pd=ast.newPackageDeclaration();
+ pd.setName(ast.newName(ConversationUtil.getBusinessObjectTypePackageName(conversation)));
+ root.setPackage(pd);
+
+ TypeDeclaration type=ast.newTypeDeclaration();
+
+ type.setName(ast.newSimpleName(ConversationUtil.getBusinessObjectTypeClassName(conversation)));
+
+ Modifier pubmod=ast.newModifier(ModifierKeyword.PUBLIC_KEYWORD);
+ type.modifiers().add(pubmod);
+
+ root.types().add(type);
+
+ // Process conversation to obtain necessary methods and
+ // properties
+ generateBusinessObjectTypeMethods(type, conversation);
+
+ org.eclipse.text.edits.TextEdit edits=root.rewrite(doc, null);
+
+ try {
+ edits.apply(doc);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+
+ java.io.ByteArrayInputStream is=
+ new java.io.ByteArrayInputStream(doc.get().getBytes());
+
+ file.setContents(is, false, true, null);
+
+ is.close();
+ }
+
+ protected void generateBusinessObjectTypeMethods(TypeDeclaration type,
+ final Conversation conversation) throws Exception {
+ final java.util.List<Role> roles=new java.util.Vector<Role>();
+
+ conversation.visit(new Visitor() {
+ public boolean visit(ModelObject obj) {
+ boolean ret=true;
+
+ if (obj instanceof Conversation &&
+ obj != conversation) {
+ ret = false;
+ } else if (obj instanceof Interaction) {
+ Interaction interaction=(Interaction)obj;
+
+ // If send and a response, then create
+ // 'to' role service category/name
+ // methods
+ if (InteractionUtil.isSend(interaction) &&
+ interaction.getReplyToLabel() == null &&
+ interaction.getToRole() != null &&
+ roles.contains(interaction.getToRole()) == false) {
+ roles.add(interaction.getToRole());
+ }
+ }
+
+ return(ret);
+ }
+ });
+
+ for (int i=0; i < roles.size(); i++) {
+ AST ast=type.getAST();
+
+ String methodName=
+ InteractionUtil.getRoleServiceCategoryAccessorMethod(roles.get(i).getName());
+
+ MethodDeclaration method=ast.newMethodDeclaration();
+ method.setName(ast.newSimpleName(methodName));
+ method.setReturnType2(ast.newSimpleType(
+ ast.newName("String")));
+
+ method.modifiers().add(ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD));
+
+ org.eclipse.jdt.core.dom.Block block=ast.newBlock();
+
+ LineComment comment=ast.newLineComment();
+
+ ReturnStatement retStatement=ast.newReturnStatement();
+
+ retStatement.setExpression(ast.newNullLiteral());
+
+ block.statements().add(retStatement);
+
+ method.setBody(block);
+
+ type.bodyDeclarations().add(method);
+
+ methodName=
+ InteractionUtil.getRoleServiceNameAccessorMethod(roles.get(i).getName());
+
+ method=ast.newMethodDeclaration();
+ method.setName(ast.newSimpleName(methodName));
+ method.setReturnType2(ast.newSimpleType(
+ ast.newName("String")));
+
+ method.modifiers().add(ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD));
+
+ block=ast.newBlock();
+
+ retStatement=ast.newReturnStatement();
+
+ retStatement.setExpression(ast.newNullLiteral());
+
+ block.statements().add(retStatement);
+
+ method.setBody(block);
+
+ type.bodyDeclarations().add(method);
+ }
+ }
+
+ protected IJavaProject createJavaProject(String projectName)
+ throws Exception {
+
// Create project
IProject project=m_file.getWorkspace().getRoot().getProject(projectName);
project.create(new org.eclipse.core.runtime.NullProgressMonitor());
@@ -379,12 +560,22 @@
project.open(new org.eclipse.core.runtime.NullProgressMonitor());
IProjectDescription description = jproj.getProject().getDescription();
+
+ // Update the project natures to include Java Nature
String[] prevNatures= description.getNatureIds();
String[] newNatures= new String[prevNatures.length + 1];
System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
newNatures[prevNatures.length]= JavaCore.NATURE_ID;
description.setNatureIds(newNatures);
+ // Setup project reference to CDM project
+ IProject[] prevProjects=description.getReferencedProjects();
+ IProject[] newProjects=new IProject[prevProjects.length+1];
+ System.arraycopy(prevProjects, 0, newProjects, 0, prevProjects.length);
+ newProjects[prevProjects.length] = m_file.getProject();
+ description.setReferencedProjects(newProjects);
+
+ // Set the description
jproj.getProject().setDescription(description,
new org.eclipse.core.runtime.NullProgressMonitor());
@@ -421,6 +612,8 @@
jproj.setRawClasspath(classpaths, outputLocation,
new org.eclipse.core.runtime.NullProgressMonitor());
+
+ return(jproj);
}
/**
@@ -448,6 +641,140 @@
}
/**
+ * This class converts a DOM representation node to
+ * text.
+ *
+ * @param node The DOM node
+ * @return The text
+ * @throws Exception Failed to convert
+ */
+ protected String getText(Node node) throws Exception {
+ String ret=null;
+
+ try {
+ // Transform the DOM represent to text
+ java.io.ByteArrayOutputStream xmlstr=
+ new java.io.ByteArrayOutputStream();
+
+ DOMSource source=new DOMSource();
+ source.setNode(node);
+
+ StreamResult result=new StreamResult(xmlstr);
+
+ Transformer trans=
+ TransformerFactory.newInstance().newTransformer();
+ trans.transform(source, result);
+
+ xmlstr.close();
+
+ ret = new String(xmlstr.toByteArray());
+
+ if ((node instanceof org.w3c.dom.Document) == false) {
+
+ // Strip off any <?xml> header
+ int index=ret.indexOf("<?xml");
+ if (index != -1) {
+ index = ret.indexOf("<", 1);
+
+ if (index != -1) {
+ ret = ret.substring(index);
+ } else {
+ index = ret.indexOf("?>");
+
+ if (index != -1) {
+ index += 2;
+
+ // Remove any trailing whitespaces
+ // after XML header
+ while (index < ret.length() &&
+ Character.isWhitespace(ret.charAt(index))) {
+ index++;
+ }
+
+ ret = ret.substring(index);
+ }
+ }
+ }
+ }
+
+ } catch(Exception e) {
+ throw new Exception("Failed to transform " +
+ "DOM representation into text", e);
+ }
+
+ int pos=0;
+ int prevpos=0;
+ StringBuffer buf=new StringBuffer();
+ int level=0;
+
+ while ((pos=ret.indexOf('<', prevpos)) != -1) {
+
+ if (prevpos < pos &&
+ ret.substring(prevpos, pos).trim().length() > 0 &&
+ ret.charAt(prevpos-1) != '?') {
+
+ if (ret.charAt(prevpos) == '\r' &&
+ ret.charAt(prevpos+1) == '\n') {
+ prevpos += 2;
+ }
+ for (int i=0; i < level; i++) {
+ buf.append(" ");
+ }
+
+ buf.append(ret.substring(prevpos, pos).trim());
+ buf.append("\r\n");
+ }
+
+ int endpos=ret.indexOf('>', pos);
+
+ if (endpos > 0) {
+ boolean noreturn=false;
+
+ if (pos > 0 && ret.charAt(pos+1) == '/') {
+ level--;
+ }
+
+ for (int i=0; i < level; i++) {
+ buf.append(" ");
+ }
+ buf.append(ret.substring(pos, endpos+1));
+
+ if (ret.charAt(endpos-1)== '?') {
+ //noreturn = true;
+
+ } else if (ret.charAt(endpos-1) == '/') {
+ // Ignore
+ } else if (pos > 0 && ret.charAt(pos+1) == '/') {
+ // Ignore
+
+ } else if (pos > 0 && ret.charAt(pos+1) == '!') {
+ // Ignore
+
+ } else {
+ level++;
+ }
+
+ if (noreturn == false) {
+ buf.append("\r\n");
+ }
+
+ pos = endpos+1;
+ }
+
+ prevpos = pos;
+ }
+
+ if (prevpos != -1 &&
+ ret.substring(prevpos).trim().length() > 0) {
+ buf.append(ret.substring(prevpos));
+ }
+
+ ret = buf.toString();
+
+ return(ret);
+ }
+
+ /**
* This method is used to report an error.
*
* @param mesg The error message
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationInteractionModelChangeRule.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationInteractionModelChangeRule.java 2008-08-01
11:06:31 UTC (rev 212)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationInteractionModelChangeRule.java 2008-08-01
15:14:49 UTC (rev 213)
@@ -19,6 +19,7 @@
import org.jboss.tools.overlord.jbossesb.model.*;
import org.jboss.tools.overlord.jbossesb.model.actions.*;
+import org.jboss.tools.overlord.jbossesb.model.util.ConversationUtil;
import org.jboss.tools.overlord.jbossesb.model.util.IdentityUtil;
import org.jboss.tools.overlord.jbossesb.model.util.InteractionUtil;
import org.scribble.model.*;
@@ -32,9 +33,6 @@
@RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
public class ConversationInteractionModelChangeRule extends AbstractModelChangeRule {
- private static final String SERVICE_NAME_ACCESSOR_SUFFIX = "ServiceName";
- private static final String SERVICE_CATEGORY_ACCESSOR_SUFFIX =
"ServiceCategory";
-
/**
* This method determines whether the rule is appropriate
* for the supplied type of model, parent (in the context) and
@@ -167,8 +165,9 @@
interaction.getToRole().getName().charAt(0))+
interaction.getToRole().getName().substring(1);
- action.setDestinationExpression(roleName+SERVICE_CATEGORY_ACCESSOR_SUFFIX,
- roleName+SERVICE_NAME_ACCESSOR_SUFFIX);
+ action.setDestinationExpression(
+ InteractionUtil.getRoleServiceCategoryProperty(roleName),
+ InteractionUtil.getRoleServiceNameProperty(roleName));
}
if (interaction.getEnclosingDefinition() instanceof Conversation &&
@@ -250,6 +249,12 @@
((ESBService)context.getParent()).addAction(action, -1);
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == action
&&
+ interaction.getEnclosingDefinition() instanceof Conversation) {
+ action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)interaction.getEnclosingDefinition())));
+ }
+
// If not a response, then add to the gateway
if (interaction.getReplyToLabel() == null) {
ESBService gwService=esbModel.getGatewayService();
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationModelChangeRule.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationModelChangeRule.java 2008-08-01
11:06:31 UTC (rev 212)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationModelChangeRule.java 2008-08-01
15:14:49 UTC (rev 213)
@@ -19,6 +19,7 @@
import org.jboss.tools.overlord.jbossesb.model.*;
import org.jboss.tools.overlord.jbossesb.model.actions.*;
+import org.jboss.tools.overlord.jbossesb.model.util.ConversationUtil;
import org.scribble.model.*;
import org.scribble.model.change.*;
import org.scribble.conversation.model.*;
@@ -146,6 +147,7 @@
}
csa.setServiceDescriptionName(sdname);
+ csa.setBusinessObjectType(ConversationUtil.getBusinessObjectType(conv));
service.addAction(csa, -1);
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/IfModelChangeRule.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/IfModelChangeRule.java 2008-08-01
11:06:31 UTC (rev 212)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/IfModelChangeRule.java 2008-08-01
15:14:49 UTC (rev 213)
@@ -21,6 +21,7 @@
import org.jboss.tools.overlord.jbossesb.model.*;
import org.jboss.tools.overlord.jbossesb.model.actions.*;
+import org.jboss.tools.overlord.jbossesb.model.util.ConversationUtil;
import org.jboss.tools.overlord.jbossesb.model.util.InteractionUtil;
import org.scribble.model.*;
import org.scribble.model.change.*;
@@ -257,6 +258,12 @@
}
}
}
+
+ if (service.getFirstSessionBasedAction() == switchAction &&
+ ifElem.getEnclosingDefinition() instanceof Conversation) {
+ switchAction.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)ifElem.getEnclosingDefinition())));
+ }
}
return(true);
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/util/ConversationUtil.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/util/ConversationUtil.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/util/ConversationUtil.java 2008-08-01
15:14:49 UTC (rev 213)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.model.util;
+
+import org.scribble.conversation.model.*;
+
+/**
+ * This class contains utility functions related to the
+ * Conversation.
+ */
+public class ConversationUtil {
+
+ /**
+ * This method returns the full class name associated with the
+ * business object type for the supplied conversation.
+ *
+ * @param conversation The conversation
+ * @return The business object type full class name
+ */
+ public static String getBusinessObjectType(Conversation conversation) {
+ String ret=getBusinessObjectTypePackageName(conversation);
+
+ ret += "."+getBusinessObjectTypeClassName(conversation);
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the package name associated with the
+ * business object type for the supplied conversation.
+ *
+ * @param conversation The conversation
+ * @return The business object type package name
+ */
+ public static String getBusinessObjectTypePackageName(Conversation conversation) {
+ String ret=null;
+
+ if (conversation.getModel() != null &&
+ conversation.getModel().getNamespace() != null) {
+ ret = conversation.getModel().getNamespace().getName()+".";
+ } else {
+ ret = "";
+ }
+
+ if (conversation.getModelName().getLocatedRole() != null) {
+ ret += conversation.getModelName().getLocatedRole();
+ }
+
+ ret = ret.toLowerCase();
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the class name associated with the
+ * business object type for the supplied conversation.
+ *
+ * @param conversation The conversation
+ * @return The business object type class name
+ */
+ public static String getBusinessObjectTypeClassName(Conversation conversation) {
+ String ret=conversation.getModelName().getName();
+
+ return(ret);
+ }
+}
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/util/InteractionUtil.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/util/InteractionUtil.java 2008-08-01
11:06:31 UTC (rev 212)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/util/InteractionUtil.java 2008-08-01
15:14:49 UTC (rev 213)
@@ -24,6 +24,9 @@
*/
public class InteractionUtil {
+ private static final String SERVICE_NAME_ACCESSOR_SUFFIX = "ServiceName";
+ private static final String SERVICE_CATEGORY_ACCESSOR_SUFFIX =
"ServiceCategory";
+
/**
* This method returns the text representation of the
* supplied type reference.
@@ -70,4 +73,64 @@
return(ret);
}
+
+ /**
+ * This method returns the business object type property
+ * for the role's service category.
+ *
+ * @param roleName The role
+ * @return The service category property
+ */
+ public static String getRoleServiceCategoryProperty(String roleName) {
+ String ret=roleName+SERVICE_CATEGORY_ACCESSOR_SUFFIX;
+
+ ret = Character.toLowerCase(ret.charAt(0))+ret.substring(1);
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the business object type property
+ * for the role's service name.
+ *
+ * @param roleName The role
+ * @return The service name property
+ */
+ public static String getRoleServiceNameProperty(String roleName) {
+ String ret=roleName+SERVICE_NAME_ACCESSOR_SUFFIX;
+
+ ret = Character.toLowerCase(ret.charAt(0))+ret.substring(1);
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the business object type accessor method
+ * for the role's service category.
+ *
+ * @param roleName The role
+ * @return The service category property
+ */
+ public static String getRoleServiceCategoryAccessorMethod(String roleName) {
+ String ret=roleName+SERVICE_CATEGORY_ACCESSOR_SUFFIX;
+
+ ret = "get"+Character.toUpperCase(ret.charAt(0))+ret.substring(1);
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the business object type accessor method
+ * for the role's service name.
+ *
+ * @param roleName The role
+ * @return The service name property
+ */
+ public static String getRoleServiceNameAccessorMethod(String roleName) {
+ String ret=roleName+SERVICE_NAME_ACCESSOR_SUFFIX;
+
+ ret = "get"+Character.toUpperCase(ret.charAt(0))+ret.substring(1);
+
+ return(ret);
+ }
}