本文整理汇总了Java中org.activiti.engine.delegate.Expression类的典型用法代码示例。如果您正苦于以下问题:Java Expression类的具体用法?Java Expression怎么用?Java Expression使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Expression类属于org.activiti.engine.delegate包,在下文中一共展示了Expression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNextClaim
import org.activiti.engine.delegate.Expression; //导入依赖的package包/类
@Override
public Map<String, List<String>> getNextClaim(String procDefId, String activityId) {
List<TaskDefinition> taskDefinitions = getNextActivities(procDefId, activityId);
Map<String, List<String>> map = new HashMap<>();
for (TaskDefinition taskDefinition : taskDefinitions) {
List<String> list = new ArrayList<>();
if (taskDefinition.getAssigneeExpression() != null) {
list.add(taskDefinition.getAssigneeExpression().getExpressionText());
} else if (taskDefinition.getCandidateUserIdExpressions() != null) {
for (Expression expression : taskDefinition.getCandidateUserIdExpressions()) {
list.add(expression.getExpressionText());
}
}
if (taskDefinition.getNameExpression() != null) {
map.put(taskDefinition.getNameExpression().getExpressionText(), list);
} else {
map.put(taskDefinition.getKey(), list);
}
}
return map;
}
示例2: packageSingleActivitiInfo
import org.activiti.engine.delegate.Expression; //导入依赖的package包/类
/**
* 封装输出信息,包括:当前节点的X、Y坐标、变量信息、任务类型、任务描述
* @param activity
* @param processInstance
* @param currentActiviti
* @return
*/
private Map<String, Object> packageSingleActivitiInfo(ActivityImpl activity, ProcessInstance processInstance,
boolean currentActiviti) throws Exception {
Map<String, Object> vars = new HashMap<String, Object>();
Map<String, Object> activityInfo = new HashMap<String, Object>();
activityInfo.put("currentActiviti", currentActiviti);
setPosition(activity, activityInfo);
setWidthAndHeight(activity, activityInfo);
Map<String, Object> properties = activity.getProperties();
vars.put("节点名称", properties.get("name"));
vars.put("任务类型", ActUtils.parseToZhType(properties.get("type").toString()));
ActivityBehavior activityBehavior = activity.getActivityBehavior();
logger.debug("activityBehavior={}", activityBehavior);
if (activityBehavior instanceof UserTaskActivityBehavior) {
Task currentTask = null;
// 当前节点的task
if (currentActiviti) {
currentTask = getCurrentTaskInfo(processInstance);
}
// 当前任务的分配角色
UserTaskActivityBehavior userTaskActivityBehavior = (UserTaskActivityBehavior) activityBehavior;
TaskDefinition taskDefinition = userTaskActivityBehavior.getTaskDefinition();
Set<Expression> candidateGroupIdExpressions = taskDefinition.getCandidateGroupIdExpressions();
if (!candidateGroupIdExpressions.isEmpty()) {
// 任务的处理角色
setTaskGroup(vars, candidateGroupIdExpressions);
// 当前处理人
if (currentTask != null) {
setCurrentTaskAssignee(vars, currentTask);
}
}
}
vars.put("节点说明", properties.get("documentation"));
String description = activity.getProcessDefinition().getDescription();
vars.put("描述", description);
logger.debug("trace variables: {}", vars);
activityInfo.put("vars", vars);
return activityInfo;
}
示例3: getExpressionVariableAsInteger
import org.activiti.engine.delegate.Expression; //导入依赖的package包/类
/**
* Gets an expression variable from the execution as Integer. This method will throw IllegalArgumentException if it is not a valid integer value and is a
* required variable.
*
* @param expression the expression variable to get.
* @param execution the execution that contains the variable value.
* @param variableName the variable name
* @param isRequired whether this variable is required
*
* @return the integer variable value.
* @throws IllegalArgumentException if not a valid integer value.
*/
public Integer getExpressionVariableAsInteger(Expression expression, DelegateExecution execution, String variableName, boolean isRequired)
throws IllegalArgumentException
{
Integer variableInteger = null;
String variableString = getExpressionVariableAsString(expression, execution);
if (isRequired && StringUtils.isBlank(variableString))
{
throw new IllegalArgumentException("\"" + variableName + "\" must be specified.");
}
if (isRequired || StringUtils.isNotBlank(variableString))
{
try
{
variableInteger = Integer.parseInt(getExpressionVariableAsString(expression, execution));
}
catch (Exception ex)
{
throw new IllegalArgumentException("\"" + variableName + "\" must be a valid integer value.", ex);
}
}
return variableInteger;
}
示例4: testGetExpressionVariableAsBooleanInvalidValue
import org.activiti.engine.delegate.Expression; //导入依赖的package包/类
@Test
public void testGetExpressionVariableAsBooleanInvalidValue()
{
// Mock dependencies.
Expression expression = mock(Expression.class);
DelegateExecution execution = mock(DelegateExecution.class);
when(expression.getValue(execution)).thenReturn(INVALID_VALUE);
// Try to call the method under test.
try
{
activitiHelper.getExpressionVariableAsBoolean(expression, execution, VARIABLE_NAME, NO_VARIABLE_REQUIRED, NO_BOOLEAN_DEFAULT_VALUE);
fail();
}
catch (IllegalArgumentException e)
{
assertEquals(String.format("\"%s\" must be a valid boolean value of \"true\" or \"false\".", VARIABLE_NAME), e.getMessage());
}
}
示例5: testGetExpressionVariableAsBooleanRequiredBlankValue
import org.activiti.engine.delegate.Expression; //导入依赖的package包/类
@Test
public void testGetExpressionVariableAsBooleanRequiredBlankValue()
{
// Mock dependencies.
Expression expression = mock(Expression.class);
DelegateExecution execution = mock(DelegateExecution.class);
when(expression.getValue(execution)).thenReturn(BLANK_TEXT);
// Try to call the method under test.
try
{
activitiHelper.getExpressionVariableAsBoolean(expression, execution, VARIABLE_NAME, VARIABLE_REQUIRED, NO_BOOLEAN_DEFAULT_VALUE);
fail();
}
catch (IllegalArgumentException e)
{
assertEquals(String.format("\"%s\" must be specified.", VARIABLE_NAME), e.getMessage());
}
}
示例6: testGetExpressionVariableAsIntegerInvalidValue
import org.activiti.engine.delegate.Expression; //导入依赖的package包/类
@Test
public void testGetExpressionVariableAsIntegerInvalidValue()
{
// Mock dependencies.
Expression expression = mock(Expression.class);
DelegateExecution execution = mock(DelegateExecution.class);
when(expression.getValue(execution)).thenReturn(INVALID_VALUE);
// Try to call the method under test.
try
{
activitiHelper.getExpressionVariableAsInteger(expression, execution, VARIABLE_NAME, VARIABLE_REQUIRED);
fail();
}
catch (IllegalArgumentException e)
{
assertEquals(String.format("\"%s\" must be a valid integer value.", VARIABLE_NAME), e.getMessage());
}
}
示例7: testGetExpressionVariableAsIntegerRequiredBlankValue
import org.activiti.engine.delegate.Expression; //导入依赖的package包/类
@Test
public void testGetExpressionVariableAsIntegerRequiredBlankValue()
{
// Mock dependencies.
Expression expression = mock(Expression.class);
DelegateExecution execution = mock(DelegateExecution.class);
when(expression.getValue(execution)).thenReturn(BLANK_TEXT);
// Try to call the method under test.
try
{
activitiHelper.getExpressionVariableAsInteger(expression, execution, VARIABLE_NAME, VARIABLE_REQUIRED);
fail();
}
catch (IllegalArgumentException e)
{
assertEquals(String.format("\"%s\" must be specified.", VARIABLE_NAME), e.getMessage());
}
}
示例8: testGetRequiredExpressionVariableAsStringBlankValue
import org.activiti.engine.delegate.Expression; //导入依赖的package包/类
@Test
public void testGetRequiredExpressionVariableAsStringBlankValue()
{
// Mock dependencies.
Expression expression = mock(Expression.class);
DelegateExecution execution = mock(DelegateExecution.class);
when(expression.getValue(execution)).thenReturn(BLANK_TEXT);
// Try to call the method under test.
try
{
activitiHelper.getRequiredExpressionVariableAsString(expression, execution, VARIABLE_NAME);
fail();
}
catch (IllegalArgumentException e)
{
assertEquals(String.format("\"%s\" must be specified.", VARIABLE_NAME), e.getMessage());
}
}
示例9: parseDataInputAssociation
import org.activiti.engine.delegate.Expression; //导入依赖的package包/类
protected AbstractDataAssociation parseDataInputAssociation(Element dataAssociationElement) {
String sourceRef = dataAssociationElement.element("sourceRef").getText();
String targetRef = dataAssociationElement.element("targetRef").getText();
List<Element> assignments = dataAssociationElement.elements("assignment");
if (assignments.isEmpty()) {
return new MessageImplicitDataInputAssociation(sourceRef, targetRef);
} else {
SimpleDataInputAssociation dataAssociation = new SimpleDataInputAssociation(sourceRef, targetRef);
for (Element assigmentElement : dataAssociationElement.elements("assignment")) {
Expression from = this.expressionManager.createExpression(assigmentElement.element("from").getText());
Expression to = this.expressionManager.createExpression(assigmentElement.element("to").getText());
Assignment assignment = new Assignment(from, to);
dataAssociation.addAssignment(assignment);
}
return dataAssociation;
}
}
示例10: parseTimer
import org.activiti.engine.delegate.Expression; //导入依赖的package包/类
private TimerDeclarationImpl parseTimer(Element timerEventDefinition, ScopeImpl timerActivity, String jobHandlerType) {
// TimeDate
TimerDeclarationType type = TimerDeclarationType.DATE;
Expression expression = parseExpression(timerEventDefinition, "timeDate");
// TimeCycle
if (expression == null) {
type = TimerDeclarationType.CYCLE;
expression = parseExpression(timerEventDefinition, "timeCycle");
}
// TimeDuration
if (expression == null) {
type = TimerDeclarationType.DURATION;
expression = parseExpression(timerEventDefinition, "timeDuration");
}
// Parse the timer declaration
// TODO move the timer declaration into the bpmn activity or next to the
// TimerSession
TimerDeclarationImpl timerDeclaration = new TimerDeclarationImpl(expression, type, jobHandlerType);
timerDeclaration.setJobHandlerConfiguration(timerActivity.getId());
return timerDeclaration;
}
示例11: parseDataInputAssociation
import org.activiti.engine.delegate.Expression; //导入依赖的package包/类
protected AbstractDataAssociation parseDataInputAssociation(Element dataAssociationElement) {
String sourceRef = dataAssociationElement.element("sourceRef").getText();
String targetRef = dataAssociationElement.element("targetRef").getText();
List<Element> assignments = dataAssociationElement.elements("assignment");
if (assignments.isEmpty()) {
MessageImplicitDataInputAssociation messageImplicitDataInputAssociation = new MessageImplicitDataInputAssociation(sourceRef, targetRef);
addDataAssociationToList(dataAssociationElement, messageImplicitDataInputAssociation);
return messageImplicitDataInputAssociation;
} else {
SimpleDataInputAssociation dataAssociation = new SimpleDataInputAssociation(sourceRef, targetRef);
for (Element assigmentElement : dataAssociationElement.elements("assignment")) {
Expression from = this.expressionManager.createExpression(assigmentElement.element("from").getText());
Expression to = this.expressionManager.createExpression(assigmentElement.element("to").getText());
Assignment assignment = new Assignment(from, to);
dataAssociation.addAssignment(assignment);
}
addDataAssociationToList(dataAssociationElement, dataAssociation);
return dataAssociation;
}
}
示例12: createDataInputAssociation
import org.activiti.engine.delegate.Expression; //导入依赖的package包/类
public AbstractDataAssociation createDataInputAssociation(BpmnParse bpmnParse, DataAssociation dataAssociationElement) {
if (StringUtils.isEmpty(dataAssociationElement.getTargetRef())) {
bpmnParse.getBpmnModel().addProblem("targetRef is required", dataAssociationElement);
}
if (dataAssociationElement.getAssignments().isEmpty()) {
return new MessageImplicitDataInputAssociation(dataAssociationElement.getSourceRef(), dataAssociationElement.getTargetRef());
} else {
SimpleDataInputAssociation dataAssociation = new SimpleDataInputAssociation(
dataAssociationElement.getSourceRef(), dataAssociationElement.getTargetRef());
for (org.activiti.bpmn.model.Assignment assigmentElement : dataAssociationElement.getAssignments()) {
if (StringUtils.isNotEmpty(assigmentElement.getFrom()) && StringUtils.isNotEmpty(assigmentElement.getTo())) {
Expression from = bpmnParse.getExpressionManager().createExpression(assigmentElement.getFrom());
Expression to = bpmnParse.getExpressionManager().createExpression(assigmentElement.getTo());
Assignment assignment = new Assignment(from, to);
dataAssociation.addAssignment(assignment);
}
}
return dataAssociation;
}
}
示例13: addAuthorizationsFromIterator
import org.activiti.engine.delegate.Expression; //导入依赖的package包/类
private void addAuthorizationsFromIterator(Set<Expression> exprSet, ProcessDefinitionEntity processDefinition, ExprType exprType) {
if (exprSet != null) {
Iterator<Expression> iterator = exprSet.iterator();
while (iterator.hasNext()) {
Expression expr = (Expression) iterator.next();
IdentityLinkEntity identityLink = new IdentityLinkEntity();
identityLink.setProcessDef(processDefinition);
if (exprType.equals(ExprType.USER)) {
identityLink.setUserId(expr.toString());
} else if (exprType.equals(ExprType.GROUP)) {
identityLink.setGroupId(expr.toString());
}
identityLink.setType(IdentityLinkType.CANDIDATE);
identityLink.insert();
}
}
}
示例14: getExpressionString
import org.activiti.engine.delegate.Expression; //导入依赖的package包/类
protected String getExpressionString(Expression expression, VariableScope variableScope)
{
if (expression != null)
{
return (String) expression.getValue(variableScope);
}
return null;
}
示例15: doSkip
import org.activiti.engine.delegate.Expression; //导入依赖的package包/类
public void doSkip(DelegateTask delegateTask) {
delegateTask.getExecution().setVariableLocal(
"_ACTIVITI_SKIP_EXPRESSION_ENABLED", true);
TaskDefinition taskDefinition = ((TaskEntity) delegateTask)
.getTaskDefinition();
ExpressionManager expressionManager = Context
.getProcessEngineConfiguration().getExpressionManager();
Expression expression = expressionManager
.createExpression("${_ACTIVITI_SKIP_EXPRESSION_ENABLED}");
taskDefinition.setSkipExpression(expression);
}