Skip to content

Commit

Permalink
Merge branch '35276_add_metagenomic_workflow_resource' of github.com:…
Browse files Browse the repository at this point in the history
…AAFC-BICoE/seqdb-api into 35276_add_metagenomic_workflow_resource
  • Loading branch information
cgendreau committed Dec 3, 2024
2 parents b43c16a + 745c62b commit eb2ac0a
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import io.crnk.core.resource.annotations.JsonApiResource;
import java.time.OffsetDateTime;
import java.util.UUID;

import org.javers.core.metamodel.annotation.ShallowReference;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand Down Expand Up @@ -37,6 +40,10 @@ public class MetagenomicsBatchItemDto {
@JsonApiRelation
private PcrBatchItemDto pcrBatchItem;

@ShallowReference
@JsonApiRelation
private MolecularAnalysisRunItemDto molecularAnalysisRunItem;

@JsonApiRelation
private NgsIndexDto indexI5;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ public class MetagenomicsBatchItem implements DinaEntity {
@JoinColumn(name = "pcr_batch_item_id")
private PcrBatchItem pcrBatchItem;

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

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "indexi5_id")
private NgsIndex indexI5;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?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">
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="54-Add_metagenomics_tables" context="schema-change" author="cgendreau">
<createTable tableName="metagenomics_batch">
Expand All @@ -14,19 +14,20 @@
<constraints nullable="false" unique="true" />
</column>
<column name="created_by" type="VARCHAR(250)">
<constraints nullable="false"/>
<constraints nullable="false" />
</column>
<column name="_group" type="VARCHAR(50)">
<constraints nullable="false"/>
<constraints nullable="false" />
</column>
<column name="created_on" type="timestamptz" defaultValueComputed="current_timestamp"/>
<column name="created_on" type="timestamptz" defaultValueComputed="current_timestamp" />
<column name="name" type="VARCHAR(100)">
<constraints nullable="false"/>
<constraints nullable="false" />
</column>
<column name="protocol" type="uuid"/>
<column name="protocol" type="uuid" />

<column name="index_set_id" type="integer">
<constraints foreignKeyName="fk_metagenomics_index_set_id_to_indexset" references="indexsets(id)"/>
<constraints foreignKeyName="fk_metagenomics_index_set_id_to_indexset"
references="indexsets(id)" />
</column>

</createTable>
Expand All @@ -39,24 +40,31 @@
<constraints nullable="false" unique="true" />
</column>
<column name="created_by" type="VARCHAR(250)">
<constraints nullable="false"/>
<constraints nullable="false" />
</column>
<column name="created_on" type="timestamptz" defaultValueComputed="current_timestamp"/>
<column name="created_on" type="timestamptz" defaultValueComputed="current_timestamp" />

<column name="metagenomics_batch_id" type="integer">
<constraints foreignKeyName="fk_metagenomics_batch_item_to_batch_id" references="metagenomics_batch(id)"/>
<constraints foreignKeyName="fk_metagenomics_batch_item_to_batch_id"
references="metagenomics_batch(id)" />
</column>

<column name="pcr_batch_item_id" type="integer">
<constraints foreignKeyName="fk_metagenomics_batch_item_to_pcr_batch_item" references="pcr_batch_item(id)"/>
<constraints foreignKeyName="fk_metagenomics_batch_item_to_pcr_batch_item"
references="pcr_batch_item(id)" />
</column>
<column name="molecular_analysis_run_item_id" type="integer">
<constraints foreignKeyName="fk_metagenomics_batch_item_to_molecular_analysis_run_item_id"
references="molecular_analysis_run_item(id)" />
</column>

<column name="indexi5_id" type="integer">
<constraints foreignKeyName="fk_metagenomics_batch_item_indexi5_to_ngsindex" references="ngsindexes(id)"/>
<constraints foreignKeyName="fk_metagenomics_batch_item_indexi5_to_ngsindex"
references="ngsindexes(id)" />
</column>
<column name="indexi7_id" type="integer">
<constraints foreignKeyName="fk_metagenomics_batch_item_indexi7_to_ngsindex" references="ngsindexes(id)"/>
<constraints foreignKeyName="fk_metagenomics_batch_item_indexi7_to_ngsindex"
references="ngsindexes(id)" />
</column>
</createTable>
</changeSet>
</databaseChangeLog>
</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@

import ca.gc.aafc.seqdb.api.dto.MetagenomicsBatchDto;
import ca.gc.aafc.seqdb.api.dto.MetagenomicsBatchItemDto;
import ca.gc.aafc.seqdb.api.dto.MolecularAnalysisResultDto;
import ca.gc.aafc.seqdb.api.dto.MolecularAnalysisRunDto;
import ca.gc.aafc.seqdb.api.dto.MolecularAnalysisRunItemDto;
import ca.gc.aafc.seqdb.api.dto.pcr.PcrBatchDto;
import ca.gc.aafc.seqdb.api.dto.pcr.PcrBatchItemDto;
import ca.gc.aafc.seqdb.api.testsupport.fixtures.MetagenomicsBatchItemTestFixture;
import ca.gc.aafc.seqdb.api.testsupport.fixtures.MetagenomicsBatchTestFixture;
import ca.gc.aafc.seqdb.api.testsupport.fixtures.MolecularAnalysisResultFixture;
import ca.gc.aafc.seqdb.api.testsupport.fixtures.MolecularAnalysisRunItemTestFixture;
import ca.gc.aafc.seqdb.api.testsupport.fixtures.MolecularAnalysisRunTestFixture;
import ca.gc.aafc.seqdb.api.testsupport.fixtures.PcrBatchItemTestFixture;
import ca.gc.aafc.seqdb.api.testsupport.fixtures.PcrBatchTestFixture;

Expand All @@ -27,20 +33,43 @@ public class MetagenomicsBatchIT extends BaseRepositoryTestV2 {
@Inject
private PcrBatchItemRepository pcrBatchItemRepository;

@Inject
private MolecularAnalysisRunRepository molecularAnalysisRunRepository;

@Inject
private MolecularAnalysisRunItemRepository molecularAnalysisRunItemRepository;

@Inject
private MolecularAnalysisResultRepository molecularAnalysisResultRepository;

@Test
public void onValidDto_dtoSavedWithoutExceptions() {

MetagenomicsBatchDto metagenomicsBatchDto = metagenomicsBatchRepository
.create(MetagenomicsBatchTestFixture.newMetagenomicsBatch());
.create(MetagenomicsBatchTestFixture.newMetagenomicsBatch());

PcrBatchDto pcrBatchDto = PcrBatchTestFixture.newPcrBatch();
pcrBatchDto = pcrBatchRepository.create(pcrBatchDto);

PcrBatchItemDto pcrBatchItemDto = PcrBatchItemTestFixture.newPcrBatchItem(pcrBatchDto);
pcrBatchItemDto = pcrBatchItemRepository.create(pcrBatchItemDto);

MolecularAnalysisRunDto runDto = molecularAnalysisRunRepository
.create(MolecularAnalysisRunTestFixture.newMolecularAnalysisRun());

MolecularAnalysisResultDto resultDto = molecularAnalysisResultRepository
.create(MolecularAnalysisResultFixture.newMolecularAnalysisResult());

MolecularAnalysisRunItemDto runItemDto = MolecularAnalysisRunItemTestFixture
.newMolecularAnalysisRunItem();
runItemDto.setRun(runDto);
runItemDto.setResult(resultDto);

runItemDto = molecularAnalysisRunItemRepository.create(runItemDto);

MetagenomicsBatchItemDto itemDto = MetagenomicsBatchItemTestFixture.newMetagenomicsBatchItem(metagenomicsBatchDto);
itemDto.setPcrBatchItem(pcrBatchItemDto);
itemDto.setMolecularAnalysisRunItem(runItemDto);

metagenomicsBatchItemRepository.create(itemDto);
}
Expand Down

0 comments on commit eb2ac0a

Please sign in to comment.