Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
a5b8a96
make serverinfo calls path relative and increase read timeout
nickpalladino Mar 4, 2024
fa0c8db
Added pedigree controller placeholder
nickpalladino Mar 5, 2024
89120b1
Adding pedigree dao in progress
nickpalladino Mar 8, 2024
30309e2
Some more work on pedigree dao
nickpalladino Mar 11, 2024
3429f23
[BI-2065] - Experiment overwrite does not do all data validations on …
HMS17 Mar 19, 2024
95fda13
[BI-2065] - Missing bracket
HMS17 Mar 19, 2024
d7d8dc6
[BI-2065] - Clarify todo
HMS17 Mar 20, 2024
bd77c55
Timestamp Error Handling
HMS17 Apr 2, 2024
d1edd99
Temporary change to build
nickpalladino Apr 16, 2024
fe117b9
Merge branch 'develop' into helium-integration
nickpalladino Apr 16, 2024
ab4070f
Brapi pedigree endpoint now filtered by program
nickpalladino Apr 17, 2024
e932d9d
Filtering work
nickpalladino Apr 19, 2024
1fe76b4
Changed to using get call instead of search
nickpalladino Apr 19, 2024
5a78119
Added comment
nickpalladino Apr 19, 2024
4b41a96
Commented out unused search call for now, github actions build error
nickpalladino Apr 19, 2024
8d16b80
Added comment to utility function
nickpalladino Apr 19, 2024
b64e7c8
[BI-2101] added transactional email configuration
mlm483 Apr 22, 2024
fe7d0e1
[BI-2101] updated email subject and body
mlm483 Apr 23, 2024
c5c556e
[BI-2101] added default values for email configuration
mlm483 Apr 24, 2024
da45d4b
[BI-2101] updated .env.template
mlm483 Apr 30, 2024
fa81b8d
[BI-2101] used existing utility method
mlm483 Apr 30, 2024
20eda41
[BI-2104] protect against null pointer exception
davedrp May 1, 2024
5b26088
[BI-2065] - Code review timestamp fix
HMS17 May 2, 2024
9375820
Merge pull request #354 from Breeding-Insight/bug/BI-2104
davedrp May 2, 2024
fa114be
[autocommit] bumping build number
rob-ouser-bi May 2, 2024
7ca9b7e
Merge branch 'develop' into bug/BI-2065
HMS17 May 2, 2024
d283ded
Removed unused reference source
nickpalladino May 2, 2024
5b43b9f
Added details to method documentation justifying commented code
nickpalladino May 2, 2024
a113a49
Added documentation for stripProgramKeys
nickpalladino May 2, 2024
5f6796b
Merge branch 'develop' into helium-integration
nickpalladino May 3, 2024
4a5a4d1
Merge branch 'develop' into feature/BI-2101
mlm483 May 3, 2024
d36bcce
Merge pull request #351 from Breeding-Insight/feature/BI-2101
mlm483 May 3, 2024
22abf88
[autocommit] bumping build number
rob-ouser-bi May 3, 2024
a44d7b4
Merge branch 'develop' into helium-integration
nickpalladino May 3, 2024
2be3bf1
Merge pull request #337 from Breeding-Insight/helium-integration
nickpalladino May 3, 2024
480c3b7
[autocommit] bumping build number
rob-ouser-bi May 3, 2024
c18b75a
[autocommit] bumping build number
rob-ouser-bi May 6, 2024
e26da32
Update version.properties
nickpalladino May 6, 2024
8a95cda
[autocommit] bumping build number
rob-ouser-bi May 6, 2024
f83e467
Merge branch 'develop' into bug/BI-2065
HMS17 May 6, 2024
38f35d0
Merge pull request #340 from Breeding-Insight/bug/BI-2065
HMS17 May 6, 2024
6a0278c
[autocommit] bumping build number
rob-ouser-bi May 6, 2024
72bf86b
[BI-2101-fix] updated SMTP port in template
mlm483 May 7, 2024
2225009
[autocommit] bumping build number
rob-ouser-bi May 7, 2024
ed1fd02
Merge branch 'bug/BI-2065' into release/0.9.1
mlm483 May 8, 2024
86922f2
[autocommit] bumping build number
rob-ouser-bi May 8, 2024
e7e46b7
[BI-2127] return Lat, Long, Elevation, and RTK
davedrp May 13, 2024
1a909b6
[BI-2127] protect against nulls
davedrp May 13, 2024
5a2100c
[BI-2127] protect against a double beign NaN (not yet set) before con…
davedrp May 14, 2024
a52eebd
[BI-2128] implemented fix and integration tests
mlm483 May 15, 2024
c3af14f
[BI-2128] added test description
mlm483 May 15, 2024
fa8c7cb
[BI-2128] fixed typo
mlm483 May 15, 2024
626d737
Merge branch 'bug/BI-2128' into develop
mlm483 May 16, 2024
c67e67a
[autocommit] bumping build number
rob-ouser-bi May 16, 2024
4bcc841
Merge branch 'develop' into bug/BI-2127
davedrp May 17, 2024
2e41d4c
[BI-2127] made code more readable
davedrp May 17, 2024
6662651
Merge pull request #356 from Breeding-Insight/bug/BI-2127
davedrp May 22, 2024
453cf79
[autocommit] bumping build number
rob-ouser-bi May 22, 2024
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
8 changes: 5 additions & 3 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ BRAPI_REFERENCE_SOURCE=breedinginsight.org
WEB_BASE_URL=http://localhost:8080

# Email server
EMAIL_RELAY_HOST=mailhog
EMAIL_RELAY_PORT=1025
EMAIL_FROM=bidevteam@cornell.edu
EMAIL_RELAY_HOST=<mailhog for development, email-smtp.us-east-1.amazonaws.com for production>
EMAIL_RELAY_PORT=<1025 for development, 2587 for production>
EMAIL_FROM=noreply@breedinginsight.org
#EMAIL_RELAY_LOGIN=<blank for development>
#EMAIL_RELAY_PASSWORD=<blank for development>

GIGWA_HOST=<gigwa host (including port)>
GIGWA_USER=<username>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/*
* 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.
*/

package org.breedinginsight.brapi.v2;

import io.micronaut.http.HttpResponse;
import io.micronaut.http.HttpStatus;
import io.micronaut.http.annotation.*;
import io.micronaut.security.annotation.Secured;
import io.micronaut.security.rules.SecurityRule;
import lombok.extern.slf4j.Slf4j;
import org.brapi.client.v2.model.exceptions.ApiException;
import org.brapi.v2.model.BrAPIIndexPagination;
import org.brapi.v2.model.BrAPIMetadata;
import org.brapi.v2.model.germ.BrAPIPedigreeNode;
import org.brapi.v2.model.germ.response.BrAPIPedigreeListResponse;
import org.brapi.v2.model.germ.response.BrAPIPedigreeListResponseResult;
import org.breedinginsight.api.auth.ProgramSecured;
import org.breedinginsight.api.auth.ProgramSecuredRoleGroup;
import org.breedinginsight.brapi.v1.controller.BrapiVersion;
import org.breedinginsight.brapi.v2.dao.BrAPIPedigreeDAO;
import org.breedinginsight.model.Program;
import org.breedinginsight.services.ProgramService;
import org.breedinginsight.utilities.Utilities;

import javax.annotation.Nullable;
import javax.inject.Inject;
import java.util.*;

@Slf4j
@Controller("/${micronaut.bi.api.version}/programs/{programId}" + BrapiVersion.BRAPI_V2)
@Secured(SecurityRule.IS_AUTHENTICATED)
public class BrAPIPedigreeController {
private final BrAPIPedigreeDAO pedigreeDAO;

private final ProgramService programService;

@Inject
public BrAPIPedigreeController(BrAPIPedigreeDAO pedigreeDAO,
ProgramService programService) {
this.pedigreeDAO = pedigreeDAO;
this.programService = programService;
}

@Get("/pedigree")
@ProgramSecured(roleGroups = {ProgramSecuredRoleGroup.ALL})
public HttpResponse<BrAPIPedigreeListResponse> pedigreeGet(@PathVariable("programId") UUID programId,
@Nullable @QueryValue("accessionNumber") String accessionNumber,
@Nullable @QueryValue("collection") String collection,
@Nullable @QueryValue("familyCode") String familyCode,
@Nullable @QueryValue("binomialName") String binomialName,
@Nullable @QueryValue("genus") Boolean genus,
@Nullable @QueryValue("species") String species,
@Nullable @QueryValue("synonym") String synonym,
@Nullable @QueryValue("includeParents") Boolean includeParents,
@Nullable @QueryValue("includeSiblings") Boolean includeSiblings,
@Nullable @QueryValue("includeProgeny") Boolean includeProgeny,
@Nullable @QueryValue("includeFullTree") Boolean includeFullTree,
@Nullable @QueryValue("pedigreeDepth") Integer pedigreeDepth,
@Nullable @QueryValue("progenyDepth") Integer progenyDepth,
@Nullable @QueryValue("commonCropName") String commonCropName,
@Nullable @QueryValue("programDbId") String programDbId,
@Nullable @QueryValue("trialDbId") String trialDbId,
@Nullable @QueryValue("studyDbId") String studyDbId,
@Nullable @QueryValue("germplasmDbId") String germplasmDbId,
@Nullable @QueryValue("germplasmName") String germplasmName,
@Nullable @QueryValue("germplasmPUI") String germplasmPUI,
@Nullable @QueryValue("externalReferenceId") String externalReferenceId,
@Nullable @QueryValue("externalReferenceSource") String externalReferenceSource,
@Nullable @QueryValue("page") Integer page,
@Nullable @QueryValue("pageSize") Integer pageSize) {

log.debug("pedigreeGet: fetching pedigree by filters");

Optional<Program> program = programService.getById(programId);
if(program.isEmpty()) {
log.warn("Program id: " + programId + " not found");
return HttpResponse.notFound();
}

try {
List<BrAPIPedigreeNode> pedigree = pedigreeDAO.getPedigree(
program.get(),
Optional.ofNullable(includeParents),
Optional.ofNullable(includeSiblings),
Optional.ofNullable(includeProgeny),
Optional.ofNullable(includeFullTree),
Optional.ofNullable(pedigreeDepth),
Optional.ofNullable(progenyDepth),
Optional.ofNullable(germplasmName));

return HttpResponse.ok(
new BrAPIPedigreeListResponse()
.metadata(new BrAPIMetadata().pagination(new BrAPIIndexPagination().currentPage(0)
.totalPages(1)
.pageSize(pedigree.size())
.totalCount(pedigree.size())))
.result(new BrAPIPedigreeListResponseResult().data(pedigree))
);
} catch (ApiException e) {
log.error(Utilities.generateApiExceptionLogMessage(e), e);
return HttpResponse.status(HttpStatus.INTERNAL_SERVER_ERROR, "error fetching pedigree");
}
}

@Post("/pedigree")
@ProgramSecured(roleGroups = {ProgramSecuredRoleGroup.ALL})
public HttpResponse<?> pedigreePost(@PathVariable("programId") UUID programId, @Body List<BrAPIPedigreeNode> body) {
//DO NOT IMPLEMENT - Users are only able to create pedigree via the DeltaBreed UI
return HttpResponse.notFound();
}

@Put("/pedigree")
@ProgramSecured(roleGroups = {ProgramSecuredRoleGroup.ALL})
public HttpResponse<?> pedigreePut(@PathVariable("programId") UUID programId, @Body Map<String, BrAPIPedigreeNode> body) {
//DO NOT IMPLEMENT - Users aren't yet able to update observation units
return HttpResponse.notFound();
}

// TODO: search and retrieve endpoints
// already have some work done, search call in BrAPIPedigreeDAO

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import java.io.IOException;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

@Slf4j
Expand Down Expand Up @@ -147,7 +148,7 @@ public BrAPIServerInfoResponse programServerinfo(@PathVariable("programId") UUID
.build();

for(BrAPIService service : programServices) {
service.setService(programBrAPIBase + service.getService());
service.setService(service.getService());
}

BrAPIServerInfo programServerInfo = new BrAPIServerInfo();
Expand Down Expand Up @@ -230,7 +231,10 @@ private HttpResponse<String> executeRequest(String path, UUID programId, HttpReq
}

private HttpResponse<String> makeCall(Request brapiRequest) {
OkHttpClient client = new OkHttpClient();
// TODO: use config parameter for timeout
OkHttpClient client = new OkHttpClient.Builder()
.readTimeout(5, TimeUnit.MINUTES)
.build();
try (Response brapiResponse = client.newCall(brapiRequest).execute()) {
if(brapiResponse.isSuccessful()) {
try(ResponseBody body = brapiResponse.body()) {
Expand Down
Loading