SPEL group_leader

Document created by Gutis Champion on Jan 12, 2016
Version 1Show Document
  • View in full screen mode

Instead of a more common read/write lock approach, the BOP environment utilizes a check-in / check-out

 

metaphor with notification of changes as it’s way of handling revisions and update conflict. The user requests a

 

special object from the TOP object named the Group Leader. When the user wants to modify the attributes of a

 

dob, he sends a ‘checkout’ message to the group leader. If the group leader can check out the object he does

 

so and tells the user that the checkout succeeded. If some other group leader has the object checked out the

 

checkout fails and the user is notified of this. Once the object is checked out, the user can make changes. The

 

user can checkout additional objects on the group leader. When the user has completed his changes, he

 

checks in the group leader which commits all of the changes. Any other consumers of the Bop(s) which are

 

changed can register for changes in the attributes of the Bop. They would be notified of the change in attribute

 

value after the checkinn is complete.

 

Provided by vanma13

 

 

Examples:

 

Basic usage:

 

object crobj, group_leader;
send_wait(0, top_object(), "call_attr", "cr", "dob_by_persid", 0, "cr:400001");  
crobj = msg[0];  
send_wait(0, top_object(), "get_co_group");  
group_leader = msg[0];  
send_wait(0, group_leader, "checkout", crobj);
send_wait(0, crobj, "call_attr", "summary", "set_val", "hello"); 
send_wait(0, crobj, "call_attr", "description", "set_val", "world");
send_wait(0,group_leader, "checkin");  
if (msg_error()) {  
  send_wait(0, group_leader, "uncheck");  
}  

 

Advanced usage:

By:cdtj

 

send_wait(0, top_object(), "call_attr", "iss", "dob_by_persid", 0, "iss:123456");  
issobj = msg[0];  
send_wait(0, top_object(), "get_co_group");  
gl = msg[0];  
send_wait(0,top_object(), "call_attr", "cnt", "current_user_id");  
who = msg[0];  
send_wait(0, issobj, "change_status", gl, // group_leader  
  who,                                    // analyst  
  description,                            // description  
  "ASGN",                                 // new status code  
  NULL);                                  // unknown  
send_wait(0, issobj, "call_attr", "summary", "set_val", "hello"); // setting new summary here  
send_wait(0, issobj, "call_attr", "description", "set_val", "world"); // setting new description here  
send_wait(0, gl, "checkin");  
if (msg_error()) {  
  send_wait(0, gl, "uncheck");  
}  

note: attrs defenition and debuging were omitted;
note2: i didnt call checkout because it's a part of "change_status" method, if I found it correct;

 

Check if objects are locked e.g. opened in edit mode.

 

int c_count,i;
  c_count = 0;
  object c_list, c_dob;
  send_wait(0, top_object(), "call_attr", "cr", "sync_fetch", "RLIST_STATIC", "active = 1", -1, 0);
  c_count = msg[1];
  c_list = msg[0];

  if (c_count > 0) {
  for (i=0;i<c_count;i++){
    send_wait(0, c_list, "dob_by_index", "DEFAULT", i, i);
    c_dob = msg[0];
    printf("%s ",c_dob.ref_num);
    object group_leader;  
   //get group_leader
    send_wait(0, top_object(), "get_co_group");
    group_leader = msg[0];
    //Try to checkout object
    send_wait(0, group_leader, "checkout", c_dob); 
    if (msg_error()) { 
    printf("Locked \n");
    } else
    {
    printf("Not Locked \n");
    send_wait(0, group_leader, "uncheck");
    }
  }
}

 

Get group_leader for context object

By: cdtj

 

object group_leader; 
send_wait(0, this, "get_gl");  
group_leader = msg[0]; 

 

For some reason this method can not be used to check if ticket is in edit mode in this case it will return msg_error that there is no group_leader.

 

Will update this when more examples or group_leader related methods comes in.

 

Document is based on group_leader in spell scripts discussion

2 people found this helpful

Attachments

    Outcomes