On Mon, May 17, 2010 at 11:10:43PM +0800, eric wrote:
> 
> i just want to create a todolist for a user.if workflow launch a process
> definition,engine will send workitem to participant.
> so if i map the participant to the user.the user will have a todo task about
> workitem.

Hello Eric,

why not simply think of the workitem as a task ?

It is much simpler.

> today,as your says,i implements the Ruote::StorageParticipant,after consume
> the participant,i will create a relationship bewteen
> the user and the participant,

What kind of relationship ?

> at the same time,i will create a todo task for
> a user.

As said, why not simply think of the "workitem" as a "task" ?

> and then in the rails application,user will get todo task.
> 
> ---8<---
> module TestWoo
>   class WooTestParticipant < Ruote::StorageParticipant
>     def consume( workitem )
>      super(workitem)
>      puts "1----------------------__>" +workitem.nil?.to_s
>      message = Rufus::Json.encode(workitem)
>      wfid = workitem.h.fei['wfid']
>      puts "2----------------------__>" + message.to_s
>      participant = workitem.participant_name
>      fields = workitem.to_h['fields']
>      puts "3----------------------__>" + fields.to_s
>      wfid_s = wfid.to_s
>      participant_s = participant.to_s
>      puts  "4===>wfid = " + wfid_s
>      puts  "5===>participant = " + participant_s
>      map_participant_user(wfid_s,participant_s)
>      puts "6----------------------__>"
>     end
>     #just want to map the participant to user.
>     #and the user will get from cloudsoft_security_roleuser.
>     def map_participant_user(wfid_s,participant_s)
>        ActiveRecord::Base.connection.insert("insert into
> wfwiparticipant(workitem_id,participant,participant2,workitem_state,extend1)"
> +
>                                             "select
> '#{wfid_s}','#{participant_s}',csru.user_id,1,'' from" +
>                                             " cloudsoft_security_role
> csr,cloudsoft_security_roleuser csru" +
>                                             " where csr.role_id =
> csru.role_id " +
>                                             " and csr.role_id =
> '#{participant_s}'");
>     end
>   end
> end
> --->8---
> 
> do you have any suggestion about this.

This code looks like PHP. It's not very readable.

Why are you using SQL statements directly ?

In Rails you have ActiveRecord, it's an ORM. ORM means "Object to Relational 
Mapper". You can do a lot of things in Ruby directly without writing SQL code.

Please teach yourself about ActiveRecord.

  
http://www.amazon.cn/mn/detailApp/ref=sr_1_1?_encoding=UTF8&s=books&qid=1274138540&asin=B0011C47ZA&sr=8-1


Kind regards,

-- 
John Mettraux - http://jmettraux.wordpress.com

-- 
you received this message because you are subscribed to the "ruote users" group.
to post : send email to [email protected]
to unsubscribe : send email to [email protected]
more options : http://groups.google.com/group/openwferu-users?hl=en

Reply via email to