Skip to content

Commit

Permalink
Added new QualityControl entity
Browse files Browse the repository at this point in the history
  • Loading branch information
cgendreau committed Dec 3, 2024
1 parent b8fc9e3 commit 1c6286d
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 0 deletions.
69 changes: 69 additions & 0 deletions src/main/java/ca/gc/aafc/seqdb/api/entities/QualityControl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package ca.gc.aafc.seqdb.api.entities;

import java.time.OffsetDateTime;
import java.util.UUID;
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.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import org.hibernate.annotations.Generated;
import org.hibernate.annotations.GenerationTime;
import org.hibernate.annotations.NaturalId;

import ca.gc.aafc.dina.entity.DinaEntity;

@Getter
@Entity
@Builder
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "quality_control")
public class QualityControl implements DinaEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;

@NotNull
@NaturalId
private UUID uuid;

@NotBlank
@Column(name = "created_by", updatable = false)
private String createdBy;

@Column(name = "created_on", insertable = false, updatable = false)
@Generated(value = GenerationTime.INSERT)
private OffsetDateTime createdOn;

@Column(name = "_group")
private String group;

@NotBlank
@Size(max = 100)
private String name;

@NotBlank
@Size(max = 50)
private String qcType;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "molecular_analysis_run_item_id")
private MolecularAnalysisRunItem molecularAnalysisRunItem;

}
1 change: 1 addition & 0 deletions src/main/resources/db/changelog/db.changelog-master.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,5 @@
<!-- 54 already used-->
<include file="db/changelog/migrations/55-Add_managed_attribute.xml"/>
<include file="db/changelog/migrations/56-Add_managed_attribute_to_molecular_analysis.xml"/>
<include file="db/changelog/migrations/57-Add_quality_control_table.xml"/>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://local.xsd/dbchangelog-4.4.xsd"
objectQuotingStrategy="QUOTE_ONLY_RESERVED_WORDS">

<changeSet id="57-Add_quality_control_table" context="schema-change" author="cgendreau">
<createTable tableName="quality_control">
<column autoIncrement="true" name="id" type="SERIAL">
<constraints primaryKey="true" primaryKeyName="pk_quality_control_id" />
</column>
<column name="uuid" type="uuid">
<constraints nullable="false" unique="true" />
</column>
<column name="created_by" type="VARCHAR(250)">
<constraints nullable="false"/>
</column>
<column name="_group" type="VARCHAR(50)">
<constraints nullable="false"/>
</column>
<column name="created_on" type="timestamptz" defaultValueComputed="current_timestamp"/>

<column name="name" type="VARCHAR(100)">
<constraints nullable="false"/>
</column>

<column name="qc_type" type="VARCHAR(50)">
<constraints nullable="false"/>
</column>

<column name="molecular_analysis_run_item_id" type="integer">
<constraints foreignKeyName="fk_quality_control_to_molecular_analysis_run_item_id" references="molecular_analysis_run_item(id)"/>
</column>

</createTable>
</changeSet>
</databaseChangeLog>

0 comments on commit 1c6286d

Please sign in to comment.