配置Rational ClearQuest 悲观锁定

作者:高嫄

   ClearQuest在V7.1以前的版本中用户会发现当他在处理某条变更请求时,其他人也正在对其进行编辑或其它操作,从而产生冲突。ClearQuest V7.1中提供了一种新机制"悲观锁定",它使得在同一时刻对同一记录,只能有一个用户进行编辑处理,而其他用户会在编辑时,得到相应信息,从而解决冲突。

要启动该功能,需要使用ClearQuest Designe设置一下。新建一个类型为Base的行为Lock,对该行为新建一个初始化行为(Action_Initialization)脚本LockRecord,编写脚本:"$entity->LockRecord(0)",这里我们选用perl脚本作为编辑脚本。

 

 

 

      用户可以选择Basic或者Perl脚本进行编辑。对于Lock操作,也可以创建一个类型为RECORD_SCRIPT_ALIAS的操作,这样用户可以自行决定是在编辑记录的情况下默认锁定记录,还是用户选择"Lock"操作后锁定记录。

如果你是一普通用户,到此设置就结束了。但是如果你是一个管理员,还需要设置UnLockRecord。同样是在ClearQuest designer中,再建一个UnLockRecord行为,选择此行为的类型为RECORD_SCRIPT_ALIAS,新建记录脚本UnLockRecord,并与UnLockRecord行为关联。

 

   

      可能有的用户会问,如果管理员不在或因为其他原因不能解锁怎么办。此时,锁定用户可以通过"Revert"或者是"Apply"来解除锁定。此外,用户也可以在脚本中设置锁定时间,当锁定超时后,ClearQuest会自动任务锁定解除,"Revert"之前用户所做的操作。对此感兴趣的用户,可以参考findrecordlocks.pl,该脚本在clearquest安装目录下。

 

脚本LockRecord Sample:

sub Defect_LockRecord {

    my($result);

    my($param) = @_;

    # record type name is Defect

 

    if (ref ($param) eq "CQEventObject") {

        # add your CQEventObject parameter handling code here

    } elsif (ref (/$param) eq "SCALAR") {

        # add your scalar parameter handling code here

        # The Web clients support scalar paramter type only,

        # so the hook code added in the above section, needs to be duplicated here

    } else {

        # add your handling code for other type parameters here, for example:

        # die("Unknown parameter type");

}

$entity->LockRecord(0);

    return $result;

}

 

脚本UnLockRecord Sample:

sub Defect_UnlockRecord {

    my($result);

    my($param) = @_;

    # record type name is Defect  

    $result = "";

    my $locked_by = $entity->GetLockOwner();

    if ($locked_by ne "") {

        my $do_unlock = $session->IsUserSuperUser();

        if (! $do_unlock) {

            # If the current user holds the lock, let them unlock it.

            my $username = $session->GetUserLoginName();

            if ($username =~ /^$locked_by$/i) {

                $do_unlock = 1;

            }

        }

        if (! $do_unlock) {

            # Additional options to "authorize" unlocking:

            # 1) allow if user is a member of an "unlock" group

            #    get user's groups, check if member

            # 2) allow for privileged users, e.g. Security Administrator

            #    check session for the chosen privilege

            # 3) many other possibilities

            #

            # if ( user-should-be-allowed-to-unlock-the-record ) {

            #     $do_unlock = 1;

            # }

        }

        if ($do_unlock) {

            $entity->UnlockRecord();

        }

        else {

            $result = "You are not allowed to unlock this record.";

        }

    }

    return $result;

}

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值