Polarion工作流插件(自定义)

  1. 创建插件
  2. 命名插件

  3. 配置插件



  4. Condition&Function
    package com.polarion.capital.example.conditions;
    
    import com.polarion.alm.tracker.model.IWorkItem;
    import com.polarion.alm.tracker.workflow.IArguments;
    import com.polarion.alm.tracker.workflow.ICallContext;
    import com.polarion.alm.tracker.workflow.ICondition;
    
    /**
     * Each implementation of workflow condition has to implement ICondition class.
     * This condition will simply count number of comments. The workflow condition
     * will be successful if the method 'passesCondition' will return true.
     * 
     * @return true if WI has at least 1 comment, or false otherwise
     * 
     * @author Michal Antolik
     */
    public class ConditionExample implements ICondition {
    
    	public boolean passesCondition(ICallContext context, IArguments arguments) {
    		IWorkItem wi = context.getWorkItem();
    		return !wi.getApprovals().isEmpty();
    	}
    
    }
    public class FunctionExample implements IFunction {
    
    	static final private long day = 24 * 3600 * 1000L;
    	static final private long hour = 3600 * 1000L;
    
    	/*
    	 * (non-Javadoc)
    	 * 
    	 * @see com.polarion.alm.tracker.workflow.IFunction#execute(com.polarion.alm.tracker.workflow.ICallContext,
    	 *      com.polarion.alm.tracker.workflow.IArguments)
    	 */
    	public void execute(ICallContext context, IArguments arguments) {
    
    		String field = arguments.getAsString("field");
    
    		IWorkItem wi = context.getWorkItem();
    		ICustomField cf = wi.getCustomFieldPrototype(field);
    
    		if (cf == null) {
    			throw new UserFriendlyRuntimeException(
    					"Invalid action parameter: Specified field doesn't exist.");
    		}
    
    		IType type = cf.getType();
    		if (!(type instanceof IPrimitiveType)
    				|| !(((IPrimitiveType) type).getTypeName()
    						.equals("java.lang.String"))) {
    			throw new UserFriendlyRuntimeException(
    					"Invalid action parameter: Incorrect field type - expected 'string'");
    		}
    
    		long creationDate = wi.getCreated().getTime();
    		long now = Calendar.getInstance().getTimeInMillis();
    		long diff = now - creationDate;
    
    		long days = diff / day;
    		long hours = (diff - days * day) / hour;
    
    		StringBuffer time = new StringBuffer();
    		if (days > 0) {
    			time.append(days).append(" days ");
    		}
    
    		if (hours > 0) {
    			time.append(hours).append(" hours");
    		}
    
    		if (time.length() == 0) {
    			time.append("less than 1 hour");
    		}
    
    		wi.setCustomField(field, time.toString());
    	}
    
    }

    特别注意:<module id="com.polarion.capital.example" version="1.0.0">
    id设置为项目名称,此处如果不设置会导致插件无法正常使用。

  5. 部署插件

    部署地址目录结构参考:E:\programs\Polarion_2304\polarion\extensions\README.txt


  6. 插件使用

    插件部署后,重启Polarion服务才可以使用。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

童心同萌

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值