Skip to content

Commit

Permalink
feat(engine): save user who evaluated a decision using the decision s…
Browse files Browse the repository at this point in the history
…ervice

related to #CAM-5238
  • Loading branch information
ingorichtsmeier authored and menski committed Jan 26, 2016
1 parent 8b76b54 commit 6d01761
Show file tree
Hide file tree
Showing 19 changed files with 172 additions and 53 deletions.
15 changes: 10 additions & 5 deletions distro/sql-script/upgrade/db2_engine_7.4_to_7.5.sql
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
-- tenant id --

ALTER TABLE ACT_RE_DEPLOYMENT
ALTER TABLE ACT_RE_DEPLOYMENT
ADD TENANT_ID_ varchar(255);

create index ACT_IDX_DEPLOYMENT_TENANT_ID on ACT_RE_DEPLOYMENT(TENANT_ID_);

ALTER TABLE ACT_RE_PROCDEF
ALTER TABLE ACT_RE_PROCDEF
ADD TENANT_ID_ varchar(255);

ALTER TABLE ACT_RE_PROCDEF
DROP UNIQUE ACT_UNIQ_PROCDEF;

create index ACT_IDX_PROCDEF_TENANT_ID ON ACT_RE_PROCDEF(TENANT_ID_);

ALTER TABLE ACT_RU_EXECUTION
ALTER TABLE ACT_RU_EXECUTION
ADD TENANT_ID_ varchar(255);

create index ACT_IDX_EXEC_TENANT_ID on ACT_RU_EXECUTION(TENANT_ID_);



-- user on historic decision instance --

ALTER TABLE ACT_HI_DECINST
ADD USER_ID_ varchar(255);
16 changes: 11 additions & 5 deletions distro/sql-script/upgrade/h2_engine_7.4_to_7.5.sql
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
-- tenant id --

ALTER TABLE ACT_RE_DEPLOYMENT
ALTER TABLE ACT_RE_DEPLOYMENT
ADD TENANT_ID_ varchar(255);

create index ACT_IDX_DEPLOYMENT_TENANT_ID on ACT_RE_DEPLOYMENT(TENANT_ID_);

ALTER TABLE ACT_RE_PROCDEF
ALTER TABLE ACT_RE_PROCDEF
ADD TENANT_ID_ varchar(255);

ALTER TABLE ACT_RE_PROCDEF
DROP CONSTRAINT ACT_UNIQ_PROCDEF;

create index ACT_IDX_PROCDEF_TENANT_ID ON ACT_RE_PROCDEF(TENANT_ID_);

ALTER TABLE ACT_RU_EXECUTION
ALTER TABLE ACT_RU_EXECUTION
ADD TENANT_ID_ varchar(255);

create index ACT_IDX_EXEC_TENANT_ID on ACT_RU_EXECUTION(TENANT_ID_);


-- user on historic decision instance --

ALTER TABLE ACT_HI_DECINST
ADD USER_ID_ varchar(255);
50 changes: 28 additions & 22 deletions distro/sql-script/upgrade/mariadb_engine_7.4_to_7.5.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,52 @@ ALTER TABLE ACT_HI_CASEINST
MODIFY COLUMN CREATE_TIME_ datetime(3) not null;

ALTER TABLE ACT_HI_CASEINST
MODIFY COLUMN CLOSE_TIME_ datetime(3);
MODIFY COLUMN CLOSE_TIME_ datetime(3);

ALTER TABLE ACT_HI_CASEACTINST
MODIFY COLUMN CREATE_TIME_ datetime(3) not null;
MODIFY COLUMN CREATE_TIME_ datetime(3) not null;

ALTER TABLE ACT_HI_CASEACTINST
MODIFY COLUMN END_TIME_ datetime(3);
MODIFY COLUMN END_TIME_ datetime(3);

ALTER TABLE ACT_HI_DECINST
MODIFY COLUMN EVAL_TIME_ datetime(3) not null;
MODIFY COLUMN EVAL_TIME_ datetime(3) not null;

ALTER TABLE ACT_RU_TASK
MODIFY COLUMN DUE_DATE_ datetime(3);
MODIFY COLUMN DUE_DATE_ datetime(3);

ALTER TABLE ACT_RU_TASK
MODIFY COLUMN FOLLOW_UP_DATE_ datetime(3);
MODIFY COLUMN FOLLOW_UP_DATE_ datetime(3);

ALTER TABLE ACT_HI_PROCINST
MODIFY COLUMN START_TIME_ datetime(3) not null;
MODIFY COLUMN START_TIME_ datetime(3) not null;

ALTER TABLE ACT_HI_PROCINST
MODIFY COLUMN END_TIME_ datetime(3);
MODIFY COLUMN END_TIME_ datetime(3);

ALTER TABLE ACT_HI_ACTINST
MODIFY COLUMN START_TIME_ datetime(3) not null;
MODIFY COLUMN START_TIME_ datetime(3) not null;

ALTER TABLE ACT_HI_ACTINST
MODIFY COLUMN END_TIME_ datetime(3);
MODIFY COLUMN END_TIME_ datetime(3);

ALTER TABLE ACT_HI_TASKINST
MODIFY COLUMN START_TIME_ datetime(3) not null;
MODIFY COLUMN START_TIME_ datetime(3) not null;

ALTER TABLE ACT_HI_TASKINST
MODIFY COLUMN END_TIME_ datetime(3);
MODIFY COLUMN END_TIME_ datetime(3);

ALTER TABLE ACT_HI_TASKINST
MODIFY COLUMN DUE_DATE_ datetime(3);
MODIFY COLUMN DUE_DATE_ datetime(3);

ALTER TABLE ACT_HI_TASKINST
MODIFY COLUMN FOLLOW_UP_DATE_ datetime(3);
MODIFY COLUMN FOLLOW_UP_DATE_ datetime(3);

ALTER TABLE ACT_HI_DETAIL
MODIFY COLUMN TIME_ datetime(3) not null;
MODIFY COLUMN TIME_ datetime(3) not null;

ALTER TABLE ACT_HI_COMMENT
MODIFY COLUMN TIME_ datetime(3) not null;
MODIFY COLUMN TIME_ datetime(3) not null;

-- set timestamp precision --

Expand Down Expand Up @@ -91,23 +91,29 @@ ALTER TABLE ACT_HI_JOB_LOG

ALTER TABLE ACT_HI_JOB_LOG
MODIFY COLUMN JOB_DUEDATE_ timestamp(3) NULL;

-- tenant id --

ALTER TABLE ACT_RE_DEPLOYMENT
ALTER TABLE ACT_RE_DEPLOYMENT
ADD TENANT_ID_ varchar(255);

create index ACT_IDX_DEPLOYMENT_TENANT_ID on ACT_RE_DEPLOYMENT(TENANT_ID_);

ALTER TABLE ACT_RE_PROCDEF
ALTER TABLE ACT_RE_PROCDEF
ADD TENANT_ID_ varchar(255);

ALTER TABLE ACT_RE_PROCDEF
DROP INDEX ACT_UNIQ_PROCDEF;

create index ACT_IDX_PROCDEF_TENANT_ID ON ACT_RE_PROCDEF(TENANT_ID_);

ALTER TABLE ACT_RU_EXECUTION
ALTER TABLE ACT_RU_EXECUTION
ADD TENANT_ID_ varchar(255);

create index ACT_IDX_EXEC_TENANT_ID on ACT_RU_EXECUTION(TENANT_ID_);


-- user on historic decision instance --

ALTER TABLE ACT_HI_DECINST
ADD USER_ID_ varchar(255);
18 changes: 12 additions & 6 deletions distro/sql-script/upgrade/mssql_engine_7.4_to_7.5.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,29 @@ alter table ACT_RU_EXECUTION
add constraint ACT_FK_EXE_PROCINST
foreign key (PROC_INST_ID_)
references ACT_RU_EXECUTION (ID_);

-- tenant id --

ALTER TABLE ACT_RE_DEPLOYMENT
ALTER TABLE ACT_RE_DEPLOYMENT
ADD TENANT_ID_ nvarchar(255);

create index ACT_IDX_DEPLOYMENT_TENANT_ID on ACT_RE_DEPLOYMENT(TENANT_ID_);

ALTER TABLE ACT_RE_PROCDEF
ALTER TABLE ACT_RE_PROCDEF
ADD TENANT_ID_ nvarchar(255);

ALTER TABLE ACT_RE_PROCDEF
DROP CONSTRAINT ACT_UNIQ_PROCDEF;

create index ACT_IDX_PROCDEF_TENANT_ID ON ACT_RE_PROCDEF(TENANT_ID_);

ALTER TABLE ACT_RU_EXECUTION
ALTER TABLE ACT_RU_EXECUTION
ADD TENANT_ID_ nvarchar(255);

create index ACT_IDX_EXEC_TENANT_ID on ACT_RU_EXECUTION(TENANT_ID_);


-- user on historic decision instance --

ALTER TABLE ACT_HI_DECINST
ADD USER_ID_ nvarchar(255);
14 changes: 10 additions & 4 deletions distro/sql-script/upgrade/mysql_engine_7.4_to_7.5.sql
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
-- tenant id --

ALTER TABLE ACT_RE_DEPLOYMENT
ALTER TABLE ACT_RE_DEPLOYMENT
ADD TENANT_ID_ varchar(255);

create index ACT_IDX_DEPLOYMENT_TENANT_ID on ACT_RE_DEPLOYMENT(TENANT_ID_);

ALTER TABLE ACT_RE_PROCDEF
ALTER TABLE ACT_RE_PROCDEF
ADD TENANT_ID_ varchar(255);

ALTER TABLE ACT_RE_PROCDEF
DROP INDEX ACT_UNIQ_PROCDEF;

create index ACT_IDX_PROCDEF_TENANT_ID ON ACT_RE_PROCDEF(TENANT_ID_);

ALTER TABLE ACT_RU_EXECUTION
ALTER TABLE ACT_RU_EXECUTION
ADD TENANT_ID_ varchar(255);

create index ACT_IDX_EXEC_TENANT_ID on ACT_RU_EXECUTION(TENANT_ID_);


-- user on historic decision instance --

ALTER TABLE ACT_HI_DECINST
ADD USER_ID_ varchar(255);
16 changes: 11 additions & 5 deletions distro/sql-script/upgrade/oracle_engine_7.4_to_7.5.sql
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
-- tenant id --

ALTER TABLE ACT_RE_DEPLOYMENT
ALTER TABLE ACT_RE_DEPLOYMENT
ADD TENANT_ID_ NVARCHAR2(255);

create index ACT_IDX_DEPLOYMENT_TENANT_ID on ACT_RE_DEPLOYMENT(TENANT_ID_);

ALTER TABLE ACT_RE_PROCDEF
ALTER TABLE ACT_RE_PROCDEF
ADD TENANT_ID_ NVARCHAR2(255);

ALTER TABLE ACT_RE_PROCDEF
DROP CONSTRAINT ACT_UNIQ_PROCDEF;

create index ACT_IDX_PROCDEF_TENANT_ID ON ACT_RE_PROCDEF(TENANT_ID_);

ALTER TABLE ACT_RU_EXECUTION
ALTER TABLE ACT_RU_EXECUTION
ADD TENANT_ID_ NVARCHAR2(255);

create index ACT_IDX_EXEC_TENANT_ID on ACT_RU_EXECUTION(TENANT_ID_);


-- user on historic decision instance --

ALTER TABLE ACT_HI_DECINST
ADD USER_ID_ NVARCHAR2(255);
14 changes: 10 additions & 4 deletions distro/sql-script/upgrade/postgres_engine_7.4_to_7.5.sql
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
-- tenant id --

ALTER TABLE ACT_RE_DEPLOYMENT
ALTER TABLE ACT_RE_DEPLOYMENT
ADD TENANT_ID_ varchar(255);

create index ACT_IDX_DEPLOYMENT_TENANT_ID on ACT_RE_DEPLOYMENT(TENANT_ID_);

ALTER TABLE ACT_RE_PROCDEF
ALTER TABLE ACT_RE_PROCDEF
ADD TENANT_ID_ varchar(255);

ALTER TABLE ACT_RE_PROCDEF
DROP CONSTRAINT ACT_UNIQ_PROCDEF;

create index ACT_IDX_PROCDEF_TENANT_ID ON ACT_RE_PROCDEF(TENANT_ID_);

ALTER TABLE ACT_RU_EXECUTION
ALTER TABLE ACT_RU_EXECUTION
ADD TENANT_ID_ varchar(255);

create index ACT_IDX_EXEC_TENANT_ID on ACT_RU_EXECUTION(TENANT_ID_);


-- user on historic decision instance --

ALTER TABLE ACT_HI_DECINST
ADD USER_ID_ varchar(255);
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* Represents one evaluation of a decision.
*
* @author Philipp Ossler
* @author Ingo Richtsmeier
*
*/
public interface HistoricDecisionInstance {
Expand Down Expand Up @@ -65,6 +66,12 @@ public interface HistoricDecisionInstance {
/** The corresponding activity instance in case the decision was evaluated inside a process or a case. */
String getActivityInstanceId();

/**
* The user ID in case the decision was evaluated by an authenticated user using the decision service
* outside of an execution context.
*/
String getUserId();

/**
* The input values of the evaluated decision. The fetching of the input values must be enabled on the query.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* History entry for an evaluated decision.
*
* @author Philipp Ossler
* @author Ingo Richtsmeier
*
*/
public class HistoricDecisionInstanceEntity extends HistoryEvent implements HistoricDecisionInstance {
Expand All @@ -47,6 +48,8 @@ public class HistoricDecisionInstanceEntity extends HistoryEvent implements Hist

protected Double collectResultValue;

protected String userId;

protected List<HistoricDecisionInputInstance> inputs;
protected List<HistoricDecisionOutputInstance> outputs;

Expand Down Expand Up @@ -98,6 +101,14 @@ public void setEvaluationTime(Date evaluationTime) {
this.evaluationTime = evaluationTime;
}

public String getUserId() {
return userId;
}

public void setUserId(String userId) {
this.userId = userId;
}

@Override
public List<HistoricDecisionInputInstance> getInputs() {
if(inputs != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.camunda.bpm.engine.impl.ProcessEngineLogger;
import org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity;
import org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity;
import org.camunda.bpm.engine.impl.context.Context;
import org.camunda.bpm.engine.impl.db.EnginePersistenceLogger;
import org.camunda.bpm.engine.impl.history.event.HistoricDecisionInputInstanceEntity;
import org.camunda.bpm.engine.impl.history.event.HistoricDecisionInstanceEntity;
Expand All @@ -46,6 +47,7 @@

/**
* @author Philipp Ossler
* @author Ingo Richtsmeier
*/
public class DefaultDmnHistoryEventProducer implements DmnHistoryEventProducer {

Expand Down Expand Up @@ -88,6 +90,8 @@ public HistoryEvent createDecisionEvaluatedEvt(DmnDecisionTableEvaluationEvent e
initDecisionInstanceEvent(event, evaluationEvent, HistoryEventTypes.DMN_DECISION_EVALUATE);
// set current time as evaluation time
event.setEvaluationTime(ClockUtil.getCurrentTime());
// set the user id if there is an authenticated user and no process instance
setUserId(event);

return event;
}
Expand Down Expand Up @@ -228,5 +232,9 @@ protected String getCaseDefinitionKey(CaseExecutionEntity execution) {
}
}

protected void setUserId(HistoricDecisionInstanceEntity event) {
event.setUserId(Context.getCommandContext().getAuthenticatedUserId());
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ create table ACT_HI_DECINST (
ACT_ID_ varchar(255),
EVAL_TIME_ timestamp not null,
COLLECT_VALUE_ double precision,
USER_ID_ varchar(255),
primary key (ID_)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ create table ACT_HI_DECINST (
ACT_ID_ varchar(255),
EVAL_TIME_ timestamp not null,
COLLECT_VALUE_ double,
USER_ID_ varchar(255),
primary key (ID_)
);

Expand Down
Loading

0 comments on commit 6d01761

Please sign in to comment.