Skip to content
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
2 changes: 2 additions & 0 deletions src/main/java/org/breedinginsight/model/Trait.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public Trait(TraitEntity traitEntity) {
this.setUpdatedAt(traitEntity.getUpdatedAt());
this.setUpdatedBy(traitEntity.getUpdatedBy());
this.setActive(traitEntity.getActive());
this.setTermType(traitEntity.getTermType());
}

public static Trait parseSqlRecord(Record record) {
Expand All @@ -106,6 +107,7 @@ public static Trait parseSqlRecord(Record record) {
.updatedAt(record.getValue(TRAIT.UPDATED_AT))
.updatedBy(record.getValue(TRAIT.UPDATED_BY))
.active(record.getValue(TRAIT.ACTIVE))
.termType(record.getValue(TRAIT.TERM_TYPE))
.build();
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/breedinginsight/services/TraitService.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ public List<Trait> createTraits(UUID programId, List<Trait> traits, Authenticate
.createdBy(actingUser.getId())
.updatedBy(actingUser.getId())
.active(true)
.termType(trait.getTermType())
.build();
traitDAO.insert(jooqTrait);
trait.setId(jooqTrait.getId());
Expand Down Expand Up @@ -416,6 +417,7 @@ public List<Trait> updateTraits(UUID programId, List<Trait> traits, Authenticate
existingTraitEntity.setObservationVariableName(updatedTrait.getObservationVariableName());
existingTraitEntity.setProgramObservationLevelId(updatedTrait.getProgramObservationLevel().getId());
existingTraitEntity.setUpdatedBy(user.getId());
existingTraitEntity.setTermType(updatedTrait.getTermType());
traitDAO.update(existingTraitEntity);

// Update in brapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public TraitQueryMapper() {
Map.entry("updatedByUserId",
trait -> trait.getUpdatedByUser() != null ? trait.getUpdatedByUser().getId() : null),
Map.entry("updatedByUserName",
trait -> trait.getUpdatedByUser() != null ? trait.getUpdatedByUser().getName() : null)
trait -> trait.getUpdatedByUser() != null ? trait.getUpdatedByUser().getName() : null),
Map.entry("termType", Trait::getTermType)
);
}

Expand Down
25 changes: 25 additions & 0 deletions src/main/resources/db/migration/V1.0.10__add_onto_term_type.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

CREATE TYPE "term_type" AS ENUM (
'PHENOTYPE',
'GERM_ATTRIBUTE',
'GERM_PASSPORT'
);

ALTER TABLE trait ADD COLUMN term_type term_type NOT NULL DEFAULT 'PHENOTYPE';
UPDATE trait SET term_type='PHENOTYPE';