Search in sources :

Example 1 with GetProcessInstancesPayload

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()));
}
Also used : PageImpl(org.activiti.runtime.api.query.impl.PageImpl) GetProcessInstancesPayload(org.activiti.api.process.model.payloads.GetProcessInstancesPayload)

Example 2 with GetProcessInstancesPayload

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);
}
Also used : GetProcessInstancesPayload(org.activiti.api.process.model.payloads.GetProcessInstancesPayload) Test(org.junit.jupiter.api.Test)

Example 3 with GetProcessInstancesPayload

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-");
}
Also used : GetProcessInstancesPayload(org.activiti.api.process.model.payloads.GetProcessInstancesPayload) Test(org.junit.jupiter.api.Test)

Example 4 with GetProcessInstancesPayload

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;
}
Also used : GetProcessInstancesPayload(org.activiti.api.process.model.payloads.GetProcessInstancesPayload)

Aggregations

GetProcessInstancesPayload (org.activiti.api.process.model.payloads.GetProcessInstancesPayload)4 Test (org.junit.jupiter.api.Test)2 PageImpl (org.activiti.runtime.api.query.impl.PageImpl)1