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

Entity sequence #329

Merged
merged 4 commits into from
Apr 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
Expand All @@ -30,7 +32,8 @@
public class ComparativeCohortAnalysis implements Serializable {

@Id
@GeneratedValue
@SequenceGenerator(name = "cca_seq", sequenceName = "cca_sequence", allocationSize = 1)
@GeneratedValue(generator = "cca_seq", strategy = GenerationType.SEQUENCE)
@Column(name = "cca_id")
private Integer analysisId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,26 @@
package org.ohdsi.webapi.cohortdefinition;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Set;
import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.CascadeType;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedAttributeNode;
import javax.persistence.NamedEntityGraph;
import javax.persistence.NamedSubgraph;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.OrderColumn;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
Expand All @@ -57,7 +53,8 @@ public class CohortDefinition implements Serializable{
private static final long serialVersionUID = 1L;

@Id
@GeneratedValue
@SequenceGenerator(name = "cohort_definition_seq",sequenceName = "cohort_definition_sequence", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "cohort_definition_seq")
@Access(AccessType.PROPERTY)
private Integer id;

Expand Down
9 changes: 4 additions & 5 deletions src/main/java/org/ohdsi/webapi/conceptset/ConceptSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@
package org.ohdsi.webapi.conceptset;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
Expand All @@ -35,7 +33,8 @@
public class ConceptSet implements Serializable {

@Id
@GeneratedValue
@SequenceGenerator(name = "concept_set_seq", sequenceName = "concept_set_sequence", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "concept_set_seq")
@Column(name="concept_set_id")
private int id;

Expand Down
8 changes: 5 additions & 3 deletions src/main/java/org/ohdsi/webapi/conceptset/ConceptSetItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
*/
package org.ohdsi.webapi.conceptset;

import com.fasterxml.jackson.annotation.JsonIgnore;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
Expand All @@ -33,8 +34,9 @@
public class ConceptSetItem implements Serializable{

@Id
@GeneratedValue
@Column(name="concept_set_item_id")
@SequenceGenerator(name = "concept_set_item_seq", sequenceName = "concept_set_item_sequence", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "concept_set_item_seq")
@Column(name="concept_set_item_id")
private int id;

@Column(name="concept_set_id")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
Expand All @@ -23,7 +25,8 @@
public class NegativeControlRecord implements Serializable {

@Id
@GeneratedValue
@SequenceGenerator(name = "concept_set_negative_controls_seq", sequenceName = "negative_controls_sequence", allocationSize = 1)
@GeneratedValue(generator = "concept_set_negative_controls_seq", strategy = GenerationType.SEQUENCE)
@Access(AccessType.PROPERTY)
@Column(name = "id")
private int id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedAttributeNode;
Expand All @@ -37,6 +38,7 @@
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.OrderColumn;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import org.ohdsi.webapi.cohortdefinition.CohortDefinition;

Expand Down Expand Up @@ -64,7 +66,8 @@
public class FeasibilityStudy {

@Id
@GeneratedValue
@SequenceGenerator(name = "feasibility_study_seq", sequenceName = "feasibility_study_sequence", allocationSize = 1)
@GeneratedValue(generator = "feasibility_study_seq", strategy = GenerationType.SEQUENCE)
@Column(name="id")
@Access(AccessType.PROPERTY)
private Integer id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
Expand All @@ -43,7 +45,8 @@ public class IncidenceRateAnalysis implements Serializable {
private static final long serialVersionUID = 1L;

@Id
@GeneratedValue
@SequenceGenerator(name = "ir_analysis_seq", sequenceName = "ir_analysis_sequence", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ir_analysis_seq")
@Column(name="id")
@Access(AccessType.PROPERTY)
private Integer id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import org.ohdsi.circe.vocabulary.ConceptSetExpression;

Expand All @@ -22,7 +24,8 @@
public class PatientLevelPredictionAnalysis {

@Id
@GeneratedValue
@SequenceGenerator(name = "plp_seq", sequenceName = "plp_sequence", allocationSize = 1)
@GeneratedValue(generator = "plp_seq", strategy = GenerationType.SEQUENCE)
@Column(name = "plp_id")
private Integer analysisId;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
-- cca
DECLARE
val INTEGER;
stmt VARCHAR2(255);
BEGIN
stmt := 'CREATE SEQUENCE ${ohdsiSchema}.cca_sequence START WITH ';
SELECT nvl2(max(cca_id), max(cca_id) + 1, 1) INTO val FROM ${ohdsiSchema}.cca;
EXECUTE IMMEDIATE stmt || val;
END;
/

-- cohort_definition
DECLARE
val INTEGER;
stmt VARCHAR2(255);
BEGIN
stmt := 'CREATE SEQUENCE ${ohdsiSchema}.cohort_definition_sequence START WITH ';
SELECT nvl2(max(id), max(id) + 1, 1) INTO val FROM ${ohdsiSchema}.cohort_definition;
EXECUTE IMMEDIATE stmt || val;
END;
/

DROP SEQUENCE ${ohdsiSchema}.CONCEPT_SET_SEQUENCE;

-- concept_set
DECLARE
val INTEGER;
stmt VARCHAR2(255);
BEGIN
stmt := 'CREATE SEQUENCE ${ohdsiSchema}.concept_set_sequence START WITH ';
SELECT nvl2(max(concept_set_id), max(concept_set_id) + 1, 1) INTO val FROM ${ohdsiSchema}.concept_set;
EXECUTE IMMEDIATE stmt || val;
END;
/

DROP SEQUENCE ${ohdsiSchema}.CONCEPT_SET_ITEM_SEQUENCE;

-- concept_set_item
DECLARE
val INTEGER;
stmt VARCHAR2(255);
BEGIN
stmt := 'CREATE SEQUENCE ${ohdsiSchema}.concept_set_item_sequence START WITH ';
SELECT nvl2(max(concept_set_item_id), max(concept_set_item_id) + 1, 1) INTO val FROM ${ohdsiSchema}.concept_set_item;
EXECUTE IMMEDIATE stmt || val;
END;
/

-- concept_set_negative_controls
DECLARE
val INTEGER;
stmt VARCHAR2(255);
BEGIN
stmt := 'CREATE SEQUENCE ${ohdsiSchema}.negative_controls_sequence START WITH ';
SELECT nvl2(max(id), max(id) + 1, 1) INTO val FROM ${ohdsiSchema}.concept_set_negative_controls;
EXECUTE IMMEDIATE stmt || val;
END;
/

-- feasibility_study
DECLARE
val INTEGER;
stmt VARCHAR2(255);
BEGIN
stmt := 'CREATE SEQUENCE ${ohdsiSchema}.feasibility_study_sequence START WITH ';
SELECT nvl2(max(id), max(id) + 1, 1) INTO val FROM ${ohdsiSchema}.feasibility_study;
EXECUTE IMMEDIATE stmt || val;
END;
/

-- ir_analysis
DECLARE
val INTEGER;
stmt VARCHAR2(255);
BEGIN
stmt := 'CREATE SEQUENCE ${ohdsiSchema}.ir_analysis_sequence START WITH ';
SELECT nvl2(max(id), max(id) + 1, 1) INTO val FROM ${ohdsiSchema}.ir_analysis;
EXECUTE IMMEDIATE stmt || val;
END;
/

-- plp
DECLARE
val INTEGER;
stmt VARCHAR2(255);
BEGIN
stmt := 'CREATE SEQUENCE ${ohdsiSchema}.plp_sequence START WITH ';
SELECT nvl2(max(plp_id), max(plp_id) + 1, 1) INTO val FROM ${ohdsiSchema}.plp;
EXECUTE IMMEDIATE stmt || val;
END;
/
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
CREATE SEQUENCE ${ohdsiSchema}.cca_sequence;
SELECT setval('${ohdsiSchema}.cca_sequence', coalesce(max(cca_id), 1)) FROM ${ohdsiSchema}.cca;

CREATE SEQUENCE ${ohdsiSchema}.cohort_definition_sequence;
SELECT setval('${ohdsiSchema}.cohort_definition_sequence', coalesce(max(id), 1)) FROM ${ohdsiSchema}.cohort_definition;

-- concept_set_sequence already exists - no need to create
SELECT setval('${ohdsiSchema}.concept_set_sequence', coalesce(max(concept_set_id), 1)) FROM ${ohdsiSchema}.concept_set;

-- concept_set_item_sequence already exists - no need to create
SELECT setval('${ohdsiSchema}.concept_set_item_sequence', coalesce(max(concept_set_item_id), 1)) FROM ${ohdsiSchema}.concept_set_item;

-- negative_controls_sequence already exists - no need to create
SELECT setval('${ohdsiSchema}.negative_controls_sequence', coalesce(max(id), 1)) FROM ${ohdsiSchema}.concept_set_negative_controls;

CREATE SEQUENCE ${ohdsiSchema}.feasibility_study_sequence;
SELECT setval('${ohdsiSchema}.feasibility_study_sequence', coalesce(max(id), 1)) FROM ${ohdsiSchema}.feasibility_study;

CREATE SEQUENCE ${ohdsiSchema}.ir_analysis_sequence;
SELECT setval('${ohdsiSchema}.ir_analysis_sequence', coalesce(max(id), 1)) FROM ${ohdsiSchema}.ir_analysis;

CREATE SEQUENCE ${ohdsiSchema}.plp_sequence;
SELECT setval('${ohdsiSchema}.plp_sequence', coalesce(max(plp_id), 1)) FROM ${ohdsiSchema}.plp;
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ALTER TABLE ${ohdsiSchema}.sec_user DROP COLUMN IF EXISTS password;
ALTER TABLE ${ohdsiSchema}.sec_user DROP COLUMN IF EXISTS salt;
ALTER TABLE ${ohdsiSchema}.sec_user DROP COLUMN password;
ALTER TABLE ${ohdsiSchema}.sec_user DROP COLUMN salt;
Loading