Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/git issue 4049 process instance api enhancement #4222

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Changes in OpenAPI look good.

Expand Up @@ -12,6 +12,14 @@
type = "string"
desc = "The id of the process definition that this process instance belongs to." />

<#--
GIT Issue : https://github.com/camunda/camunda-bpm-platform/issues/4049
-->
<@lib.property
name = "definitionKey"
type = "string"
desc = "The key of the process definition that this process instance belongs to." />

<@lib.property
name = "businessKey"
type = "string"
Expand Down Expand Up @@ -40,4 +48,4 @@
desc = "The tenant id of the process instance." />

</@lib.dto>
</#macro>
</#macro>
Expand Up @@ -34,6 +34,7 @@
"links": [],
"id": "anId",
"definitionId": "aProcDefId",
"definitionKey": "aProcDefKey",
"businessKey": "aKey",
"caseInstanceId": "aCaseInstanceId",
"ended": false,
Expand All @@ -53,4 +54,4 @@
}
}

</#macro>
</#macro>
Expand Up @@ -60,6 +60,7 @@
"links": [],
"id": "anId",
"definitionId": "aProcessDefinitionId",
"definitionKey": "aProcessDefinitionKey",
"businessKey": "aKey",
"caseInstanceId": "aCaseInstanceId",
"ended": false,
Expand All @@ -80,4 +81,4 @@
}
}

</#macro>
</#macro>
Expand Up @@ -28,6 +28,7 @@
"value": {
"id":"aProcessInstanceId",
"definitionId":"aProcDefId",
"definitionKey":"aProcDefKey",
"businessKey":"aKey",
"caseInstanceId":"aCaseInstanceId",
"ended":false,
Expand All @@ -45,4 +46,4 @@

}
}
</#macro>
</#macro>
Expand Up @@ -28,13 +28,18 @@ public class ProcessInstanceDto extends LinkableDto {
private boolean ended;
private boolean suspended;
private String tenantId;
/**
* GIT Issue : https://github.com/camunda/camunda-bpm-platform/issues/4049
*/
private String definitionKey;

public ProcessInstanceDto() {
}

public ProcessInstanceDto(ProcessInstance instance) {
this.id = instance.getId();
this.definitionId = instance.getProcessDefinitionId();
this.definitionKey = instance.getProcessDefinitionKey();
this.businessKey = instance.getBusinessKey();
this.caseInstanceId = instance.getCaseInstanceId();
this.ended = instance.isEnded();
Expand All @@ -49,6 +54,14 @@ public String getId() {
public String getDefinitionId() {
return definitionId;
}

/**
* @return the definitionKey
* GIT Issue : https://github.com/camunda/camunda-bpm-platform/issues/4049
*/
public String getDefinitionKey() {
return definitionKey;
Comment on lines +62 to +63
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Formatting:

Suggested change
public String getDefinitionKey() {
return definitionKey;
public String getDefinitionKey() {
return definitionKey;

}

public String getBusinessKey() {
return businessKey;
Expand Down
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Failing test (the mocks are not updated): ProcessInstanceRestServiceInteractionTest.testGetSingleInstance with

java.lang.AssertionError: 
1 expectation failed.
JSON path definitionKey doesn't match.
Expected: aKey
  Actual: null
	at org.camunda.bpm.engine.rest.ProcessInstanceRestServiceInteractionTest.testGetSingleInstance(ProcessInstanceRestServiceInteractionTest.java:1090)

How to run the REST API tests (after the engine and sql-script modules are built)?:
mvn clean install -Pjersey2 -f engine-rest/engine-rest/pom.xml

Expand Up @@ -1083,6 +1083,7 @@ public void testGetSingleInstance() {
.body("id", Matchers.equalTo(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID))
.body("ended", Matchers.equalTo(MockProvider.EXAMPLE_PROCESS_INSTANCE_IS_ENDED))
.body("definitionId", Matchers.equalTo(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID))
.body("definitionKey", Matchers.equalTo(MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY))
.body("businessKey", Matchers.equalTo(MockProvider.EXAMPLE_PROCESS_INSTANCE_BUSINESS_KEY))
.body("suspended", Matchers.equalTo(MockProvider.EXAMPLE_PROCESS_INSTANCE_IS_SUSPENDED))
.body("tenantId", Matchers.equalTo(MockProvider.EXAMPLE_TENANT_ID))
Expand Down
Expand Up @@ -1935,4 +1935,25 @@ public ProcessEngine getProcessEngine() {
public String getProcessDefinitionTenantId() {
return getProcessDefinition().getTenantId();
}

/**
* reference to a process definition entity within Execution Entity
*
* GIT Issue : https://github.com/camunda/camunda-bpm-platform/issues/4049
*/

protected transient ProcessDefinitionEntity processDefinitionKey;

/**
* persisted reference to the process definition.
*
* @see #getProcessDefinitionKey()
*
* GIT Issue : https://github.com/camunda/camunda-bpm-platform/issues/4049
*/

@Override
public String getProcessDefinitionKey() {
return getProcessDefinition().getKey();
}
}
Expand Up @@ -86,4 +86,14 @@ public String getProcessInstanceId() {
public String getTenantId() {
return executionEntity.getTenantId();
}
/**
* The Key of the process definition of the process instance.
*
* GIT Issue : https://github.com/camunda/camunda-bpm-platform/issues/4049
*/

@Override
public String getProcessDefinitionKey() {
return executionEntity.getProcessDefinitionKey();
}
}
Expand Up @@ -32,6 +32,13 @@ public interface ProcessInstance extends Execution {
*/
String getProcessDefinitionId();

/**
* The Key of the process definition of the process instance.
*
* GIT Issue : https://github.com/camunda/camunda-bpm-platform/issues/4049
*/
String getProcessDefinitionKey();

/**
* The business key of this process instance.
*/
Expand Down
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Instead of using association extend the table with PROC_DEF_KEY_ column. You will need to add the change to the create and update sql scripts.

Expand Up @@ -155,8 +155,22 @@
<result property="cachedEntityState" column="CACHED_ENT_STATE_" jdbcType="INTEGER"/>
<result property="sequenceCounter" column="SEQUENCE_COUNTER_" jdbcType="BIGINT"/>
<result property="tenantId" column="TENANT_ID_" jdbcType="VARCHAR"/>
<result property="tenantId" column="TENANT_ID_" jdbcType="VARCHAR"/>

<!-- Added the association relationship between Process Instance and Process Definition
GIT Issue : https://github.com/camunda/camunda-bpm-platform/issues/4049 -->
<association property="processDefinitionKey" resultMap="definitionResult"/>
</resultMap>

<!-- Added the resultMap id="definitionResult" to accomodate returning Process definition Key for Process Instance GET and POST API Calls
as per GIT Issue : https://github.com/camunda/camunda-bpm-platform/issues/4049
Averted updates to selectExecutionsByQueryCriteriaSql, as this select query is also being used by other API's-->

<resultMap id="definitionResult" type="org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity">
<id property="id" column="ID_" jdbcType="VARCHAR" />
<result property="key" column="KEY_"/>
</resultMap>

<resultMap type="org.camunda.bpm.engine.impl.util.ImmutablePair" id="deploymentIdMapping">
<id property="left" column="DEPLOYMENT_ID_" jdbcType="VARCHAR" />
<id property="right" column="ID_" jdbcType="VARCHAR" />
Expand Down