use of org.activiti.api.process.model.payloads.GetProcessInstancesPayload in project Activiti by Activiti.
the class ProcessRuntimeImpl method processInstances.
@Override
public Page<ProcessInstance> processInstances(Pageable pageable, GetProcessInstancesPayload getProcessInstancesPayload) {
if (getProcessInstancesPayload == null) {
throw new IllegalStateException("payload cannot be null");
}
GetProcessInstancesPayload securityKeysInPayload = securityPoliciesManager.restrictProcessInstQuery(SecurityPolicyAccess.READ);
org.activiti.engine.runtime.ProcessInstanceQuery internalQuery = runtimeService.createProcessInstanceQuery();
if (!securityKeysInPayload.getProcessDefinitionKeys().isEmpty()) {
getProcessInstancesPayload.setProcessDefinitionKeys(securityKeysInPayload.getProcessDefinitionKeys());
}
if (getProcessInstancesPayload.getProcessDefinitionKeys() != null && !getProcessInstancesPayload.getProcessDefinitionKeys().isEmpty()) {
internalQuery.processDefinitionKeys(getProcessInstancesPayload.getProcessDefinitionKeys());
}
if (getProcessInstancesPayload.getBusinessKey() != null && !getProcessInstancesPayload.getBusinessKey().isEmpty()) {
internalQuery.processInstanceBusinessKey(getProcessInstancesPayload.getBusinessKey());
}
if (getProcessInstancesPayload.isSuspendedOnly()) {
internalQuery.suspended();
}
if (getProcessInstancesPayload.isActiveOnly()) {
internalQuery.active();
}
if (getProcessInstancesPayload.getParentProcessInstanceId() != null) {
internalQuery.superProcessInstanceId(getProcessInstancesPayload.getParentProcessInstanceId());
}
return new PageImpl<>(processInstanceConverter.from(internalQuery.listPage(pageable.getStartIndex(), pageable.getMaxItems())), Math.toIntExact(internalQuery.count()));
}
use of org.activiti.api.process.model.payloads.GetProcessInstancesPayload in project Activiti by Activiti.
the class SecurityPoliciesProcessInstanceRestrictionApplierTest method restrictToKeysAddFilterOnGivenKeys.
@Test
public void restrictToKeysAddFilterOnGivenKeys() {
// given
Set<String> keys = singleton("procDef");
// when
GetProcessInstancesPayload filter = restrictionApplier.restrictToKeys(keys);
// then
assertThat(filter.getProcessDefinitionKeys()).isEqualTo(keys);
}
use of org.activiti.api.process.model.payloads.GetProcessInstancesPayload in project Activiti by Activiti.
the class SecurityPoliciesProcessInstanceRestrictionApplierTest method denyAllShouldAddUnmatchableFilter.
@Test
public void denyAllShouldAddUnmatchableFilter() {
// when
GetProcessInstancesPayload filter = restrictionApplier.denyAll();
// then
assertThat(filter.getProcessDefinitionKeys()).hasSize(1);
assertThat(filter.getProcessDefinitionKeys().iterator().next()).startsWith("missing-");
}
use of org.activiti.api.process.model.payloads.GetProcessInstancesPayload in project Activiti by Activiti.
the class GetProcessInstancesPayloadBuilder method build.
public GetProcessInstancesPayload build() {
GetProcessInstancesPayload getProcessInstancesPayload = new GetProcessInstancesPayload();
getProcessInstancesPayload.setBusinessKey(businessKey);
getProcessInstancesPayload.setProcessDefinitionKeys(processDefinitionKeys);
getProcessInstancesPayload.setActiveOnly(activeOnly);
getProcessInstancesPayload.setSuspendedOnly(suspendedOnly);
getProcessInstancesPayload.setParentProcessInstanceId(parentProcessInstanceId);
return getProcessInstancesPayload;
}
Aggregations