Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to create Bookmark in skeleton JET
How to create Bookmark in skeleton JET [message #900486] Tue, 07 August 2012 09:33 Go to next message
ALeksander Sadecki is currently offline ALeksander Sadecki
Messages: 4
Registered: August 2012
Junior Member
Hi Experts,

I have created skeleton where I have a lot of fields. Let's assume I have field

String CLASSNAME = "my_name";


I would like to change the name of this variable in my .jettxt file. How can I do it?

It should be like:
???? CLASSNAME="NEWCLASSNAME" ?????


Thank you in advance

[Updated on: Tue, 07 August 2012 09:47]

Report message to a moderator

Re: How to create Bookmark in skeleton [message #900510 is a reply to message #900486] Tue, 07 August 2012 10:40 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26141
Registered: July 2009
Senior Member
Aleksander,

I'm not sure what you're asking. It's it about JET syntax for
substitutions? E.g., <%=some-Java expression-that-yields-the-substitution%>


On 07/08/2012 11:33 AM, ALeksander Sadecki wrote:
> Hi Experts,
>
> I have created skeleton where I have a lot of fields. Let's assume I
> have field
>
> String CLASSNAME = "my_name";
>
> I would like to change the name of this variable in my .jettxt file.
> How can I do it?
>
> It should be like: ???? CLASSNAME="NEWCLASSNAME" ?????
>
> Thank you in advance
Re: How to create Bookmark in skeleton [message #900513 is a reply to message #900510] Tue, 07 August 2012 10:49 Go to previous messageGo to next message
ALeksander Sadecki is currently offline ALeksander Sadecki
Messages: 4
Registered: August 2012
Junior Member
Hi,

Thank you for your response. I think that the easiest way to explain it will be copy code here.

My skeleton:

@Path("/ProposalREST")
public class CLASS {
  
  	String MyText = "text"; 
  	
  	
	@POST
	@Path("/POST")
	@Consumes(MediaType.APPLICATION_JSON)
	public Response postProposal(Proposal x) {
		return Response.status(201).entity("").build();
	}

	@GET
	@Path("/GET")
	@Produces(MediaType.APPLICATION_JSON)
	public Proposal getProposal(Proposal x) {
		return null;
	}

	@DELETE
	@Path("/DELETE") 
	@Consumes(MediaType.APPLICATION_JSON)
	public Response deleteProposal(Proposal x) {
		return Response.status(201).entity("").build();
	}

	@PUT
	@Path("/PUT")
	@Consumes(MediaType.APPLICATION_JSON)
	public Response putProposal(Proposal x) {
		return Response.status(201).entity("").build();
	}

	public String dummy() {
	}
	
}


And my jettxt file:

 <%@
 
 jet package="REST"
 
 imports="import javax.ws.rs.Path javax.ws.rs.GET javax.ws.rs.Produces javax.ws.rs.core.MediaType
 javax.ws.rs.POST javax.ws.rs.core.Response javax.ws.rs.DELETE javax.ws.rs.PUT javax.ws.rs.Consumes"
 
 class="Proposal"
 
 skeleton="rest.skeleton"
 
 %>


In skeleton I have got MyText variable. I want to substitute name of this variable in jettxt file.

Do you know what I mean?

[Updated on: Tue, 07 August 2012 10:49]

Report message to a moderator

Re: How to create Bookmark in skeleton [message #900517 is a reply to message #900513] Tue, 07 August 2012 11:15 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26141
Registered: July 2009
Senior Member
Aleksander,

If I understand correctly, there's no way to change the skeleton from
the template.

On 07/08/2012 12:49 PM, ALeksander Sadecki wrote:
> Hi,
>
> Thank you for your response. I think that the easiest way to explain
> it will be copy code here.
>
> My skeleton:
>
> @Path("/ProposalREST")
> public class CLASS {
>
> String MyText = "text";
>
> @POST
> @Path("/POST")
> @Consumes(MediaType.APPLICATION_JSON)
> public Response postProposal(Proposal x) {
> return Response.status(201).entity("").build();
> }
>
> @GET
> @Path("/GET")
> @Produces(MediaType.APPLICATION_JSON)
> public Proposal getProposal(Proposal x) {
> return null;
> }
>
> @DELETE
> @Path("/DELETE") @Consumes(MediaType.APPLICATION_JSON)
> public Response deleteProposal(Proposal x) {
> return Response.status(201).entity("").build();
> }
>
> @PUT
> @Path("/PUT")
> @Consumes(MediaType.APPLICATION_JSON)
> public Response putProposal(Proposal x) {
> return Response.status(201).entity("").build();
> }
>
> public String dummy() {
> }
>
> }
>
> And my jettxt file:
>
> <%@
>
> jet package="REST"
>
> imports="import javax.ws.rs.Path javax.ws.rs.GET javax.ws.rs.Produces
> javax.ws.rs.core.MediaType
> javax.ws.rs.POST javax.ws.rs.core.Response javax.ws.rs.DELETE
> javax.ws.rs.PUT javax.ws.rs.Consumes"
>
> class="Proposal"
>
> skeleton="rest.skeleton"
>
> %>
>
> In skeleton I have got MyText variable. I want to substitute name of
> this variable in jettxt file.
>
> Do you know what I mean?
> Quote:
>> Options:
>> Post Notification
>> Notify me when someone replies to this message.
>
Re: How to create Bookmark in skeleton [message #900526 is a reply to message #900517] Tue, 07 August 2012 11:49 Go to previous messageGo to next message
ALeksander Sadecki is currently offline ALeksander Sadecki
Messages: 4
Registered: August 2012
Junior Member
But for example I have CLASS in skeleton and in my jettxt file I have
class="Proposal"
and after build it is changed. So probably it is possible...

Maybe from another side, I would like to create JET project which generate for me code like this:

import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

@Path("/YourClassRest")
	public class YourClassRest {

	@POST
	@Path("/POST")
	@Consumes(MediaType.APPLICATION_JSON)
	public Response postYourClass(YourClass x) {
		return Response.status(201).entity("").build();
	};

	@GET
	@Path("/GET")
	@Produces(MediaType.APPLICATION_JSON)
	public YourClass getYourClass(YourClass x) {
		return null;
	};

	@PUT
	@Path("/PUT")
	@Consumes(MediaType.APPLICATION_JSON)
	public Response putYourClass(YourClass x) {
		return Response.status(201).entity("").build();
	}

	@DELETE
	@Path("/DELETE") 
	public void deleteYourClass(YourClass x) {
	};
}


And I can give the name of YourClass. How can I do it?
Re: How to create Bookmark in skeleton [message #900531 is a reply to message #900526] Tue, 07 August 2012 12:12 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26141
Registered: July 2009
Senior Member
Aleksander,

Comments below.

On 07/08/2012 1:49 PM, ALeksander Sadecki wrote:
> But for example I have CLASS in skeleton and in my jettxt file I have
> class="Proposal" and after build it is changed. So probably it is
> possible...
If you modify the framework in some way then in theory pretty much
anything is possible.
>
> Maybe from another side, I would like to create JET project which
> generate for me code like this:
>
>
> import javax.ws.rs.Consumes;
> import javax.ws.rs.DELETE;
> import javax.ws.rs.GET;
> import javax.ws.rs.POST;
> import javax.ws.rs.PUT;
> import javax.ws.rs.Path;
> import javax.ws.rs.Produces;
> import javax.ws.rs.core.MediaType;
> import javax.ws.rs.core.Response;
>
> @Path("/YourClassRest")
> public class YourClassRest {
>
> @POST
> @Path("/POST")
> @Consumes(MediaType.APPLICATION_JSON)
> public Response postYourClass(YourClass x) {
> return Response.status(201).entity("").build();
> };
>
> @GET
> @Path("/GET")
> @Produces(MediaType.APPLICATION_JSON)
> public YourClass getYourClass(YourClass x) {
> return null;
> };
>
> @PUT
> @Path("/PUT")
> @Consumes(MediaType.APPLICATION_JSON)
> public Response putYourClass(YourClass x) {
> return Response.status(201).entity("").build();
> }
>
> @DELETE
> @Path("/DELETE") public void deleteYourClass(YourClass x) {
> };
> }
>
> And I can give the name of YourClass. How can I do it?
Maybe you should have a look at the templates in
org.eclipse.emf.codegen.ecore/templates. Of course within a template
you can do any kinds of substitutions.
Re: How to create Bookmark in skeleton [message #900532 is a reply to message #900531] Tue, 07 August 2012 12:21 Go to previous messageGo to next message
ALeksander Sadecki is currently offline ALeksander Sadecki
Messages: 4
Registered: August 2012
Junior Member
Ok, thanks. So, I do not have to use template. I can do it in another way but I have no idea how. Is it possible to generate a method for Java Class without skeletons?
Re: How to create Bookmark in skeleton [message #900664 is a reply to message #900532] Wed, 08 August 2012 06:08 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26141
Registered: July 2009
Senior Member
Aleksander,

You need templates. Did you have a look at EMF templates? Did you read
the tutorial?

On 07/08/2012 2:21 PM, ALeksander Sadecki wrote:
> Ok, thanks. So, I do not have to use template. I can do it in another
> way but I have no idea how. Is it possible to generate a method for
> Java Class without skeletons?
Previous Topic:[CDO/Hibernate] NPE: at org.hibernate.hql.internal.ast.HqlSqlWalker.createFromJoinElement(HqlSqlWalk
Next Topic:Slim Model Instance Backup
Goto Forum:
  


Current Time: Sat Oct 25 23:49:15 GMT 2014

Powered by FUDForum. Page generated in 0.06525 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software