Skip to content

Commit

Permalink
fixes from code review by Mikko
Browse files Browse the repository at this point in the history
  • Loading branch information
Edvard Fonsell committed Dec 12, 2014
1 parent 4add93d commit 5d2264f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
Expand Down Expand Up @@ -62,7 +62,7 @@ public void storeWorkflowDefinition(WorkflowDefinition<? extends WorkflowState>
params.addValue("executor_group", executorInfo.getExecutorGroup());
String sql = "update nflow_workflow_definition "
+ "set definition = :definition, modified_by = :modified_by "
+ "where type = :type and executor_group = :executor_group";
+ "where type = :type and executor_group = :executor_group and definition <> :definition";
int updatedRows = namedJdbc.update(sql, params);
if (updatedRows == 0) {
sql = "insert into nflow_workflow_definition(type, definition, modified_by, executor_group) "
Expand All @@ -76,7 +76,7 @@ public void storeWorkflowDefinition(WorkflowDefinition<? extends WorkflowState>
}

public List<StoredWorkflowDefinition> queryStoredWorkflowDefinitions(Collection<String> types) {
String sql = "select * from nflow_workflow_definition where " + executorInfo.getExecutorGroupCondition();
String sql = "select definition from nflow_workflow_definition where " + executorInfo.getExecutorGroupCondition();
MapSqlParameterSource params = new MapSqlParameterSource();
if (!isEmpty(types)) {
sql += " and type in (:types)";
Expand All @@ -95,7 +95,7 @@ StoredWorkflowDefinition convert(WorkflowDefinition<? extends WorkflowState> def
resp.type = definition.getType();
resp.description = definition.getDescription();
resp.onError = definition.getErrorState().name();
Map<String, StoredWorkflowDefinition.State> states = new LinkedHashMap<>();
Map<String, StoredWorkflowDefinition.State> states = new HashMap<>();
for (WorkflowState state : definition.getStates()) {
states.put(state.name(), new StoredWorkflowDefinition.State(state.name(), state.getType().name(), state.getDescription()));
}
Expand Down
6 changes: 2 additions & 4 deletions nflow-engine/src/main/resources/scripts/db/h2.create.ddl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,11 @@ create table if not exists nflow_executor (
);

create table if not exists nflow_workflow_definition (
id int not null auto_increment primary key,
type varchar(64) not null,
definition text not null,
created timestamp not null default current_timestamp,
modified timestamp not null default current_timestamp,
modified_by int not null,
executor_group varchar(64) not null
executor_group varchar(64) not null,
primary key (type, executor_group)
);

create unique index if not exists nflow_workflow_definition_uniq on nflow_workflow_definition (type, executor_group);
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,11 @@ create table if not exists nflow_executor (
);

create table if not exists nflow_workflow_definition (
id int not null auto_increment primary key,
type varchar(64) not null,
definition text not null,
created timestamp(3) not null default current_timestamp(3),
modified timestamp(3) not null default current_timestamp(3) on update current_timestamp(3),
modified_by int not null,
executor_group varchar(64) not null,
constraint nflow_workflow_definition_uniq unique (type, executor_group)
primary key (type, executor_group)
);
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,13 @@ create table if not exists nflow_executor (
);

create table if not exists nflow_workflow_definition (
id int not null auto_increment primary key,
type varchar(64) not null,
definition text not null,
modified timestamp not null default current_timestamp on update current_timestamp,
modified_by int not null,
created timestamp not null,
executor_group varchar(64) not null,
constraint nflow_workflow_definition_uniq unique (type, executor_group)
primary key (type, executor_group)
);

drop trigger if exists nflow_workflow_definition_insert;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,13 @@ create table if not exists nflow_executor (
);

create table if not exists nflow_workflow_definition (
id serial primary key,
type varchar(64) not null,
definition text not null,
created timestamptz not null default current_timestamp,
modified timestamptz not null default current_timestamp,
modified_by int not null,
executor_group varchar(64) not null,
constraint nflow_workflow_definition_uniq unique (type, executor_group)
primary key (type, executor_group)
);

drop trigger if exists update_nflow_definition_modified on nflow_workflow_definition;
Expand Down

0 comments on commit 5d2264f

Please sign in to comment.