Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
211 commits
Select commit Hold shift + click to select a range
cdd3d68
Initial work on refactor modeling skeleton
nickpalladino Apr 26, 2024
d8ca032
Added trials pending data to get existing step
nickpalladino Apr 29, 2024
77e4a7e
Addeed studies pending data to get existing step
nickpalladino Apr 29, 2024
65cf44d
Added locations pending data to get existing step
nickpalladino Apr 29, 2024
8633a3e
Added dataset pending data to get existing step
nickpalladino Apr 30, 2024
ab03644
Added germplasm pending data to get existing step
nickpalladino Apr 30, 2024
9d2e108
create Middleware class
dmeidlin May 1, 2024
d97f27c
add comensation methods to Middleware class
dmeidlin May 2, 2024
3a0481f
add compensate method to middleware
dmeidlin May 2, 2024
2741485
Work on breaking out common workflow code
nickpalladino May 2, 2024
5fb31a0
Merge branch 'experiment-processor-refactor' of https://github.com/Br…
nickpalladino May 2, 2024
8f761ae
create ExpUnitContextService
dmeidlin May 2, 2024
8fe5fe2
add mapPendingOUsByName service method
dmeidlin May 2, 2024
6be417a
add common methods
dmeidlin May 2, 2024
82d02e6
add service methods for getting existing brapi data
dmeidlin May 3, 2024
1ca976d
add overloaded trial methods for fetching trial pio
dmeidlin May 3, 2024
b4906a5
add pending data context to signature
dmeidlin May 3, 2024
8f15d08
add ValidateService
dmeidlin May 3, 2024
63091c3
add ValidateService#validateFields
dmeidlin May 3, 2024
8a89c53
add observation and statistics service
dmeidlin May 3, 2024
42b1482
update Middleware#link to handle nested middleware
dmeidlin May 6, 2024
7ca5817
add method to create new brapi trials for import
dmeidlin May 6, 2024
afc5e91
add method to update pending trials
dmeidlin May 6, 2024
c926da4
add methods for creating and updating pending datasets
dmeidlin May 6, 2024
6ae624e
add method to update brapi study dependencies
dmeidlin May 6, 2024
314d0b1
Added db migration to create workflows
nickpalladino May 6, 2024
17ec461
add methods for committing studies
dmeidlin May 6, 2024
968e9ba
add methods for committing obs units
dmeidlin May 6, 2024
70d268c
add methods for committing pending observations
dmeidlin May 6, 2024
8fc2f31
Added bean mapping for factory producing appropriate workflow
nickpalladino May 7, 2024
4b61708
Added endpoint for retrieving workflows for given mapping id
nickpalladino May 7, 2024
585947e
fix up middleware for refID validation
dmeidlin May 7, 2024
6d56b6e
add error handler middleware
dmeidlin May 7, 2024
c1fe8fa
Simplify record mapping
nickpalladino May 7, 2024
6953727
add ExistingObsUnit middleware
dmeidlin May 8, 2024
255eb25
refactor unit service methods and document
dmeidlin May 8, 2024
251d0ae
get trials for required exp units
dmeidlin May 8, 2024
4b8960b
make required studies middleware
dmeidlin May 8, 2024
71c145e
create required locations middleware
dmeidlin May 8, 2024
5635dcf
add required dataset middleware
dmeidlin May 9, 2024
b0198f0
create required germplasm middleware
dmeidlin May 9, 2024
61c1229
batch location request
dmeidlin May 9, 2024
c697622
batch requests for studies and trials
dmeidlin May 10, 2024
3ca1a30
Pass workflow id through to import services
nickpalladino May 10, 2024
7108089
make link method static
dmeidlin May 10, 2024
c8e0bfe
Add workflow factory to create workflows from ids
nickpalladino May 13, 2024
4391479
Add missing file header
nickpalladino May 13, 2024
87ffdb5
Add bean to import mapping workflow model
nickpalladino May 13, 2024
19e3f17
validate dynamic columns
dmeidlin May 13, 2024
964c2f3
hash observations and add map to context
dmeidlin May 14, 2024
186ee1d
add logging statement
dmeidlin May 14, 2024
dc2ea96
fix for loop
dmeidlin May 14, 2024
1c1df39
Added position column to workflows for explicit ordering
nickpalladino May 14, 2024
36944a5
Added additional workflow skeletons
nickpalladino May 14, 2024
7a9af10
Clean up factory code
nickpalladino May 14, 2024
09b9133
Merge branch 'develop' into feature/BI-2122
nickpalladino May 15, 2024
027855f
construct pending observations
dmeidlin May 15, 2024
579e76d
Merge branch 'feature/BI-2122' into experiment-processor-refactor
nickpalladino May 15, 2024
d6ed109
cosntruct mapped pending import rows
dmeidlin May 17, 2024
7cb1f58
validate and record changelog
dmeidlin May 17, 2024
0585568
Moved create workflow work to own branch and rearranged things a little
nickpalladino May 20, 2024
777b7e2
Added file headers and dynamic column parser
nickpalladino May 20, 2024
9ec7de2
create classes for processed data
dmeidlin May 21, 2024
92af469
create validator classes
dmeidlin May 21, 2024
99b17e2
use field validator
dmeidlin May 21, 2024
9141e9b
create preview statistics class
dmeidlin May 22, 2024
df63e6d
update
dmeidlin May 22, 2024
2328d13
cleanup
dmeidlin May 22, 2024
5564ca1
create micronaut composite pattern classes for experiment import work…
dmeidlin May 22, 2024
f726611
create FileImportService method for GET workflows
dmeidlin May 22, 2024
f6952dd
delete unused classes
dmeidlin May 22, 2024
5e31aa6
clean up and renaming
dmeidlin May 23, 2024
708793d
add overrides to import services
dmeidlin May 23, 2024
68bdacb
create ExperimentWorkflow interface that extends Workflow interface
dmeidlin May 23, 2024
0e022f1
create interfaces for germplasm and sample workflows
dmeidlin May 23, 2024
f2a1034
create interfaces
dmeidlin May 23, 2024
0459dcd
create and update trial middleware
dmeidlin May 24, 2024
3b8c4ca
update observation middleware
dmeidlin May 24, 2024
e237fe9
create dataset middleware
dmeidlin May 24, 2024
8f483ff
create location creation middleware
dmeidlin May 24, 2024
322a69d
create brapi command interface
dmeidlin May 28, 2024
a4fdc48
create PendingTrial class
dmeidlin May 28, 2024
2345cff
add compensate method to brapi trial middleware
dmeidlin May 28, 2024
ef417bb
create BrAPIReadWorkflowInitialization class
dmeidlin May 29, 2024
15fd790
create PendiningLocation experimentImportEntity
dmeidlin May 29, 2024
402eb5d
create DomainImportService abstract class
dmeidlin May 31, 2024
69b813f
create pending observation entity
dmeidlin Jun 1, 2024
c5dd139
Shared services work in progress
nickpalladino Jun 3, 2024
c87a355
update workflow pending trial
dmeidlin Jun 4, 2024
bfc3273
create pending location and location creation
dmeidlin Jun 4, 2024
b31e60e
create pending study
dmeidlin Jun 4, 2024
4fac6ea
create study commit middleware
dmeidlin Jun 4, 2024
92c4386
create pending dataset
dmeidlin Jun 4, 2024
48b05e7
create pending observation unit
dmeidlin Jun 5, 2024
c7ccbb3
create pending observation
dmeidlin Jun 5, 2024
ba866cf
create pending germplasm
dmeidlin Jun 5, 2024
4742f18
create workflow initialization middleware
dmeidlin Jun 5, 2024
323f2cd
Merge branch 'feature/BI-2122-A' into feature/BI-2134
dmeidlin Jun 5, 2024
04e6160
connect workflow selector
dmeidlin Jun 6, 2024
36f02b3
change signature of Middleware to return context
dmeidlin Jun 6, 2024
cdf5517
compose import preview response
dmeidlin Jun 6, 2024
0a26bcf
connect up middleware
dmeidlin Jun 6, 2024
2ff1cb6
catch api error in initialization
dmeidlin Jun 7, 2024
394451a
add middlewareError to expUnitContext
dmeidlin Jun 7, 2024
cee306b
fix dependency injection circular reference
dmeidlin Jun 8, 2024
8825462
Renamed common services
nickpalladino Jun 10, 2024
2b0256d
Simplified workflow step calling
nickpalladino Jun 10, 2024
be58336
fix instantiation of gson
dmeidlin Jun 10, 2024
bce2c7f
change Workflow field names
dmeidlin Jun 10, 2024
6060fcc
use processorManager until Workflow business logic in place
dmeidlin Jun 10, 2024
90f478b
fix workflow navigator injection
dmeidlin Jun 10, 2024
62cf9ac
set the order field for workflows
dmeidlin Jun 10, 2024
57f5cfb
fix npe
dmeidlin Jun 10, 2024
dcbb769
merge in fixes
dmeidlin Jun 10, 2024
6041deb
add workflow test util methods
dmeidlin Jun 11, 2024
73da0a8
initialize expUnitContext
dmeidlin Jun 11, 2024
01faa6b
fix dependency injection for pending obs unit
dmeidlin Jun 11, 2024
5dab53d
fix injection for pending OU creation
dmeidlin Jun 11, 2024
5dda5a5
fix injection pending trial entity
dmeidlin Jun 11, 2024
49e89bb
fix injection pending study
dmeidlin Jun 11, 2024
535b001
fix injection pending location
dmeidlin Jun 11, 2024
d91c266
fix injection pendign observation
dmeidlin Jun 11, 2024
06ba038
fix injection pending germplasm
dmeidlin Jun 11, 2024
b106b2d
fix injection pending dataset
dmeidlin Jun 11, 2024
45d72d0
fix workflwo test util and pending trial NPE
dmeidlin Jun 12, 2024
a44896b
fix workflow test util
dmeidlin Jun 12, 2024
644ca0c
Added commit step
nickpalladino Jun 12, 2024
9087429
create entity factory and read factory
dmeidlin Jun 13, 2024
669751e
add obs unit to read factory
dmeidlin Jun 14, 2024
5bc9e1a
add obs unit to entity factory
dmeidlin Jun 14, 2024
c8d1cb6
Building
nickpalladino Jun 14, 2024
d57e4ac
Renamed to have github actions run
nickpalladino Jun 14, 2024
787f919
add remaining entitties to entity factory
dmeidlin Jun 14, 2024
e466598
fill out read factory
dmeidlin Jun 14, 2024
afeb1c1
create brapi creation factory
dmeidlin Jun 14, 2024
37d6ff3
inject creation factory into commit middleware
dmeidlin Jun 14, 2024
7daee23
create update factory
dmeidlin Jun 15, 2024
0c7659a
initialize pending study by ou id map
dmeidlin Jun 17, 2024
5a14c31
initialize pending trial by ou id
dmeidlin Jun 17, 2024
c5c0a29
initialize pending location by ou id
dmeidlin Jun 17, 2024
b69939d
initialize pending dataset by ou id
dmeidlin Jun 17, 2024
d340095
initialize pending germplasm by ou id
dmeidlin Jun 17, 2024
9b44987
create processed data factory
dmeidlin Jun 18, 2024
5cfa4cf
fix numeric trait validator
dmeidlin Jun 18, 2024
9727a18
fix initial observation creation to use existing brapi data
dmeidlin Jun 18, 2024
83ee522
fix how brapi-reference-url is injected
dmeidlin Jun 18, 2024
7288435
add log info statements for commit brapi data
dmeidlin Jun 19, 2024
ba6285c
inject status service into append workflow
dmeidlin Jun 19, 2024
6e78eac
update append-dataset integration tests to call workflow
dmeidlin Jun 20, 2024
7246ab6
add dataset update to commit middleware
dmeidlin Jun 20, 2024
1e63696
Updated create only tests to use new create workflow
nickpalladino Jun 20, 2024
3873195
use lists instead of sets when collecting dynamic columns
dmeidlin Jun 21, 2024
80b8e5c
prevent blank values from overwriting observation data
dmeidlin Jun 21, 2024
ef880c2
delete vestigial classes
dmeidlin Jun 21, 2024
d17a0a5
repackage observation validator
dmeidlin Jun 21, 2024
2319cbf
repackage factories
dmeidlin Jun 21, 2024
3e72234
delete unused prcessor
dmeidlin Jun 21, 2024
b235495
delete unused pipeline package
dmeidlin Jun 21, 2024
352061f
delete unused expunitcontext service
dmeidlin Jun 21, 2024
72be0bd
move data factory
dmeidlin Jun 22, 2024
5567db6
move expunitmiddleware context to model package
dmeidlin Jun 22, 2024
98d4b7d
clean up context models
dmeidlin Jun 22, 2024
2cc3f09
rename context models
dmeidlin Jun 23, 2024
a08a82d
delete unnecessary transaction and BrAPIReadRequiredData middleware
dmeidlin Jun 23, 2024
b7ece34
move throwing exceptions to experiment import service layer
dmeidlin Jun 24, 2024
7733d1b
add license statements
dmeidlin Jun 24, 2024
98cf134
optimize imports
dmeidlin Jun 24, 2024
3a76d1f
fix numerical validator to check for non-numeric values
dmeidlin Jun 24, 2024
b247b5d
parse OffssetDateTime for yyyy-MM-dd format
dmeidlin Jun 24, 2024
cfcdd9e
fix value match check for overwritten data
dmeidlin Jun 24, 2024
311c148
include appended timestamps in initial data
dmeidlin Jun 25, 2024
53269ee
clear statistics before processing import table
dmeidlin Jun 25, 2024
c57df5a
use exisiting processor workaround in empty data bean
dmeidlin Jun 25, 2024
b3885e7
add gid to preview statistics
dmeidlin Jun 25, 2024
7c72b91
fix canOverwrite boolean flag and observation update exception handling
dmeidlin Jun 26, 2024
d52b54d
remove vestigial reddison config setting
dmeidlin Jun 28, 2024
7fdd49e
delete unused create-new-environment workflow
dmeidlin Jun 28, 2024
fff2a95
delete unused append-workflow from enum
dmeidlin Jun 28, 2024
4c838a4
fetch workflow ids for experiment integration tests
dmeidlin Jun 28, 2024
82a0e5d
fix new-exp test and remove processor from import service layer
dmeidlin Jun 29, 2024
d61d58f
add documentation comments
dmeidlin Jul 1, 2024
68afa68
configure maven build github action to be manually triggerable
dmeidlin Jul 2, 2024
9fa39f6
add debug statements to experiment file import tests
dmeidlin Jul 2, 2024
cad35dc
add debug statements to ProgramCache#populate
dmeidlin Jul 2, 2024
4051b44
add debug statements to sample submission file import test
dmeidlin Jul 2, 2024
16871fc
[BI-2134] - added debug logging
mlm483 Jul 3, 2024
b4aedc3
add create-new-experiment workflow id to SampleSubmissionFileImportTe…
dmeidlin Jul 3, 2024
2d3eaa5
remove manual trigger from maven build github action
dmeidlin Jul 4, 2024
50a5398
add documentation string
dmeidlin Jul 4, 2024
5846513
changes type key to supported types key in github action
dmeidlin Jul 4, 2024
09640e8
add documentation string
dmeidlin Jul 4, 2024
2384cf7
parameterize use of raw types
dmeidlin Jul 8, 2024
c37f91c
make WorkflowUpdate creation private to factory
dmeidlin Jul 9, 2024
2f93738
delete unused WorkflowUpdate class
dmeidlin Jul 9, 2024
ab632bc
replace types keyword with old type syntax in maven build action
dmeidlin Jul 9, 2024
f17c1ce
revert keyword with synchronize type
dmeidlin Jul 9, 2024
e74d653
trigger build
dmeidlin Jul 9, 2024
40446a9
specify branch
dmeidlin Jul 9, 2024
f7585ee
revert
dmeidlin Jul 9, 2024
606224a
revert
dmeidlin Jul 9, 2024
766563b
Merge branch 'feature/BI-2132' into feature/BI-2134
dmeidlin Jul 9, 2024
e066710
Merge branch 'develop' into feature/BI-2134
dmeidlin Jul 10, 2024
a0b644f
fix test
dmeidlin Jul 10, 2024
f2c55c6
disable tests that need cache mocking fixed
dmeidlin Jul 10, 2024
6fe9775
update controller tests to use new exp workflow
dmeidlin Jul 10, 2024
e97baac
update more controller tests
dmeidlin Jul 10, 2024
1a71e28
Merge branch 'develop' into feature/BI-2134
dmeidlin Jul 10, 2024
3d21555
clean up code
dmeidlin Jul 10, 2024
58d3a7f
[BI-2134] - removed uses of deprecated constant
mlm483 Jul 11, 2024
578d127
delete unused interface
dmeidlin Jul 11, 2024
5ecc421
delete unused class
dmeidlin Jul 11, 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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ jobs:
JWT_SECRET: ${{ secrets.JWT_SECRET }}
OAUTH_CLIENT_ID: 123abc
OAUTH_CLIENT_SECRET: asdfljkhalkbaldsfjasdfi238497098asdf
BRAPI_REFERENCE_SOURCE: breedinginsight.org
BRAPI_REFERENCE_SOURCE: breedinginsight.org
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

package org.breedinginsight.api.model.v1.response;

import lombok.*;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,27 @@ public List<BrAPIObservation> getObservationsByStudyName(List<String> studyNames
);
}

/**
* Retrieves a list of observations based on their database IDs and a specific program.
*
* @param dbIds A list of database IDs representing the observations to retrieve.
* @param program The Program object for which the observations belong.
* @return A List of BrAPIObservation objects filtered by the provided database IDs.
* @throws ApiException if an error occurs during the retrieval process.
*/
public List<BrAPIObservation> getObservationsByDbIds(List<String> dbIds, Program program) throws ApiException {
// Check if the dbIds list is empty and return an empty list if so
if(dbIds.isEmpty()) {
return Collections.emptyList();
}

// Filter the observations based on the provided program ID and the provided list of dbIds
// Collect the filtered observations into a List and return the result
return getProgramObservations(program.getId()).values().stream()
.filter(o -> dbIds.contains(o.getObservationDbId()))
.collect(Collectors.toList());
}

public List<BrAPIObservation> getObservationsByTrialDbId(List<String> trialDbIds, Program program) throws ApiException {
if(trialDbIds.isEmpty()) {
return Collections.emptyList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,8 @@ private void addObsVarDataToRow(
Trait var,
Program program) {
String varName = Utilities.removeProgramKey(obs.getObservationVariableName(), program.getKey());
if (!(obs.getValue().equalsIgnoreCase("NA")) && (var.getScale().getDataType().equals(DataType.NUMERICAL) ||
var.getScale().getDataType().equals(DataType.DURATION))) {
if (!("NA".equalsIgnoreCase(obs.getValue())) && (DataType.NUMERICAL.equals(var.getScale().getDataType()) ||
DataType.DURATION.equals(var.getScale().getDataType()))) {
row.put(varName, Double.parseDouble(obs.getValue()));
} else {
row.put(varName, obs.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.breedinginsight.api.model.v1.response.metadata.StatusCode;
import org.breedinginsight.api.v1.controller.metadata.AddMetadata;
import org.breedinginsight.brapps.importer.model.mapping.ImportMapping;
import org.breedinginsight.brapps.importer.model.workflow.ImportWorkflow;
import org.breedinginsight.brapps.importer.services.ImportConfigManager;
import org.breedinginsight.brapps.importer.model.config.ImportConfigResponse;
import org.breedinginsight.brapps.importer.services.FileImportService;
Expand Down Expand Up @@ -76,7 +77,7 @@ public HttpResponse<Response<DataResponse<ImportConfigResponse>>> getImportTypes
Pagination pagination = new Pagination(configs.size(), 1, 1, 0);
Metadata metadata = new Metadata(pagination, metadataStatus);

Response<DataResponse<ImportConfigResponse>> response = new Response(metadata, new DataResponse<>(configs));
Response<DataResponse<ImportConfigResponse>> response = new Response<>(metadata, new DataResponse<>(configs));
return HttpResponse.ok(response);
}

Expand All @@ -95,7 +96,7 @@ public HttpResponse<Response<DataResponse<ImportMapping>>> getMappings(@PathVari
Pagination pagination = new Pagination(result.size(), 1, 1, 0);
Metadata metadata = new Metadata(pagination, metadataStatus);

Response<DataResponse<ImportMapping>> response = new Response(metadata, new DataResponse<>(result));
Response<DataResponse<ImportMapping>> response = new Response<>(metadata, new DataResponse<>(result));
return HttpResponse.ok(response);
} catch (DoesNotExistException e) {
log.info(e.getMessage());
Expand All @@ -116,7 +117,7 @@ public HttpResponse<Response<ImportMapping>> createMapping(@PathVariable UUID pr
try {
AuthenticatedUser actingUser = securityService.getUser();
ImportMapping result = fileImportService.createMapping(programId, actingUser, file);
Response<ImportMapping> response = new Response(result);
Response<ImportMapping> response = new Response<>(result);
return HttpResponse.ok(response);
} catch (DoesNotExistException e) {
log.info(e.getMessage());
Expand All @@ -140,7 +141,7 @@ public HttpResponse<Response<ImportMapping>> editMappingFile(@PathVariable UUID
try {
AuthenticatedUser actingUser = securityService.getUser();
ImportMapping result = fileImportService.updateMappingFile(programId, mappingId, actingUser, file);
Response<ImportMapping> response = new Response(result);
Response<ImportMapping> response = new Response<>(result);
return HttpResponse.ok(response);
} catch (DoesNotExistException e) {
log.info(e.getMessage());
Expand All @@ -165,7 +166,7 @@ public HttpResponse<Response<ImportMapping>> editMapping(@PathVariable UUID prog
try {
AuthenticatedUser actingUser = securityService.getUser();
ImportMapping result = fileImportService.updateMapping(programId, actingUser, mappingId, mapping, validate);
Response<ImportMapping> response = new Response(result);
Response<ImportMapping> response = new Response<>(result);
return HttpResponse.ok(response);
} catch (DoesNotExistException e) {
log.error(e.getMessage(), e);
Expand Down Expand Up @@ -205,7 +206,30 @@ public HttpResponse<Response<DataResponse<ImportMapping>>> getSystemMappings(@Nu
Pagination pagination = new Pagination(result.size(), result.size(), 1, 0);
Metadata metadata = new Metadata(pagination, metadataStatus);

Response<DataResponse<ImportMapping>> response = new Response(metadata, new DataResponse<>(result));
Response<DataResponse<ImportMapping>> response = new Response<>(metadata, new DataResponse<>(result));
return HttpResponse.ok(response);
}

@Get("/import/mappings/{mappingId}/workflows")
@Produces(MediaType.APPLICATION_JSON)
@AddMetadata
@Secured(SecurityRule.IS_ANONYMOUS)
public HttpResponse<Response<DataResponse<ImportWorkflow>>> getWorkflowsForSystemMapping(@PathVariable UUID mappingId) {

List<ImportWorkflow> workflows = null;
try {
workflows = fileImportService.getWorkflowsForSystemMapping(mappingId);
} catch (DoesNotExistException e) {
log.error(e.getMessage(), e);
return HttpResponse.status(HttpStatus.UNPROCESSABLE_ENTITY, e.getMessage());
}

List<Status> metadataStatus = new ArrayList<>();
metadataStatus.add(new Status(StatusCode.INFO, "Successful Query"));
Pagination pagination = new Pagination(workflows.size(), workflows.size(), 1, 0);
Metadata metadata = new Metadata(pagination, metadataStatus);

Response<DataResponse<ImportWorkflow>> response = new Response<>(metadata, new DataResponse<>(workflows));
return HttpResponse.ok(response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public HttpResponse<Response<ImportResponse>> uploadData(@PathVariable UUID prog
try {
AuthenticatedUser actingUser = securityService.getUser();
ImportResponse result = fileImportService.uploadData(programId, mappingId, actingUser, file);
Response<ImportResponse> response = new Response(result);
Response<ImportResponse> response = new Response<>(result);
return HttpResponse.ok(response);
} catch (DoesNotExistException e) {
log.error(e.getMessage(), e);
Expand Down Expand Up @@ -94,7 +94,7 @@ public HttpResponse<Response<ImportResponse>> getUploadData(@PathVariable UUID p
try {
AuthenticatedUser actingUser = securityService.getUser();
Pair<HttpStatus, ImportResponse> result = fileImportService.getDataUpload(uploadId, mapping);
Response<ImportResponse> response = new Response(result.getRight());
Response<ImportResponse> response = new Response<>(result.getRight());
if (result.getLeft().equals(HttpStatus.ACCEPTED)) {
return HttpResponse.ok(response).status(result.getLeft());
} else {
Expand All @@ -114,7 +114,7 @@ public HttpResponse<Response<ImportResponse>> commitData(@PathVariable UUID prog
@PathVariable UUID uploadId, @Body @Nullable Map<String, Object> userInput) {
try {
AuthenticatedUser actingUser = securityService.getUser();
ImportResponse result = fileImportService.updateUpload(programId, uploadId, actingUser, userInput, true);
ImportResponse result = fileImportService.updateUpload(programId, uploadId, null, actingUser, userInput, true);
Response<ImportResponse> response = new Response(result);
return HttpResponse.ok(response).status(HttpStatus.ACCEPTED);
} catch (DoesNotExistException e) {
Expand All @@ -140,8 +140,61 @@ public HttpResponse<Response<ImportResponse>> previewData(@PathVariable UUID pro
@PathVariable UUID uploadId) {
try {
AuthenticatedUser actingUser = securityService.getUser();
ImportResponse result = fileImportService.updateUpload(programId, uploadId, actingUser, null, false);
Response<ImportResponse> response = new Response(result);
ImportResponse result = fileImportService.updateUpload(programId, uploadId, null, actingUser, null, false);
Response<ImportResponse> response = new Response<>(result);
return HttpResponse.ok(response).status(HttpStatus.ACCEPTED);
} catch (DoesNotExistException e) {
log.error(e.getMessage(), e);
return HttpResponse.notFound();
} catch (AuthorizationException e) {
log.error(e.getMessage(), e);
return HttpResponse.status(HttpStatus.FORBIDDEN, e.getMessage());
} catch (UnprocessableEntityException e) {
log.error(e.getMessage(), e);
return HttpResponse.status(HttpStatus.UNPROCESSABLE_ENTITY, e.getMessage());
} catch (HttpStatusException e) {
log.error(e.getMessage(), e);
return HttpResponse.status(e.getStatus(), e.getMessage());
}
}

@Put("programs/{programId}/import/mappings/{mappingId}/workflows/{workflow}/data/{uploadId}/preview")
@Produces(MediaType.APPLICATION_JSON)
@AddMetadata
@ProgramSecured(roles = {ProgramSecuredRole.BREEDER, ProgramSecuredRole.SYSTEM_ADMIN})
public HttpResponse<Response<ImportResponse>> previewData(@PathVariable UUID programId, @PathVariable UUID mappingId,
@PathVariable String workflow, @PathVariable UUID uploadId) {
try {
AuthenticatedUser actingUser = securityService.getUser();
ImportResponse result = fileImportService.updateUpload(programId, uploadId, workflow, actingUser, null, false);
Response<ImportResponse> response = new Response<>(result);
return HttpResponse.ok(response).status(HttpStatus.ACCEPTED);
} catch (DoesNotExistException e) {
log.error(e.getMessage(), e);
return HttpResponse.notFound();
} catch (AuthorizationException e) {
log.error(e.getMessage(), e);
return HttpResponse.status(HttpStatus.FORBIDDEN, e.getMessage());
} catch (UnprocessableEntityException e) {
log.error(e.getMessage(), e);
return HttpResponse.status(HttpStatus.UNPROCESSABLE_ENTITY, e.getMessage());
} catch (HttpStatusException e) {
log.error(e.getMessage(), e);
return HttpResponse.status(e.getStatus(), e.getMessage());
}
}

@Put("programs/{programId}/import/mappings/{mappingId}/workflows/{workflow}/data/{uploadId}/commit")
@Produces(MediaType.APPLICATION_JSON)
@AddMetadata
@ProgramSecured(roles = {ProgramSecuredRole.BREEDER, ProgramSecuredRole.SYSTEM_ADMIN})
public HttpResponse<Response<ImportResponse>> commitData(@PathVariable UUID programId, @PathVariable UUID mappingId,
@PathVariable String workflow, @PathVariable UUID uploadId,
@Body @Nullable Map<String, Object> userInput) {
try {
AuthenticatedUser actingUser = securityService.getUser();
ImportResponse result = fileImportService.updateUpload(programId, uploadId, workflow, actingUser, userInput, true);
Response<ImportResponse> response = new Response<>(result);
return HttpResponse.ok(response).status(HttpStatus.ACCEPTED);
} catch (DoesNotExistException e) {
log.error(e.getMessage(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,15 @@

package org.breedinginsight.brapps.importer.model.imports;

import org.brapi.client.v2.model.exceptions.ApiException;
import org.breedinginsight.brapps.importer.model.ImportUpload;
import org.breedinginsight.brapps.importer.model.response.ImportPreviewResponse;
import org.breedinginsight.model.Program;
import org.breedinginsight.model.User;
import org.breedinginsight.services.exceptions.DoesNotExistException;
import org.breedinginsight.services.exceptions.MissingRequiredInfoException;
import org.breedinginsight.services.exceptions.UnprocessableEntityException;
import org.breedinginsight.services.exceptions.ValidatorException;
import tech.tablesaw.api.Table;
import org.breedinginsight.brapps.importer.model.workflow.ImportWorkflow;

import java.util.List;

public interface BrAPIImportService {
String getImportTypeId();
BrAPIImport getImportClass();
List<ImportWorkflow> getWorkflows();
default String getInvalidIntegerMsg(String columnName) {
return String.format("Column name \"%s\" must be integer type, but non-integer type provided.", columnName);
}
Expand All @@ -48,6 +41,6 @@ default String getMissingUserInputMsg(String fieldName) {
default String getWrongUserInputDataTypeMsg(String fieldName, String typeName) {
return String.format("User input, \"%s\" must be an %s", fieldName, typeName);
}
ImportPreviewResponse process(List<BrAPIImport> brAPIImports, Table data, Program program, ImportUpload upload, User user, Boolean commit)
ImportPreviewResponse process(ImportServiceContext context)
throws Exception;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* 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.brapps.importer.model.imports;

import lombok.extern.slf4j.Slf4j;
import org.breedinginsight.brapps.importer.model.response.ImportPreviewResponse;
import org.breedinginsight.brapps.importer.model.workflow.ImportWorkflow;
import org.breedinginsight.brapps.importer.model.workflow.ImportWorkflowResult;
import org.breedinginsight.brapps.importer.model.workflow.Workflow;

import javax.inject.Singleton;
import java.util.List;
import java.util.Optional;

@Singleton
@Slf4j
public abstract class DomainImportService implements BrAPIImportService {
private final Workflow workflowNavigator;


public DomainImportService(Workflow workflowNavigator)
{
this.workflowNavigator = workflowNavigator;
}

@Override
public String getMissingColumnMsg(String columnName) {
return "Column heading does not match template or ontology";
}
@Override
public List<ImportWorkflow> getWorkflows() {
return workflowNavigator.getWorkflows();
}

@Override
public ImportPreviewResponse process(ImportServiceContext context)
throws Exception {

Optional.ofNullable(context.getWorkflow())
.filter(workflow -> !workflow.isEmpty())
.ifPresent(workflow -> log.info("Workflow: " + workflow));


Optional<ImportWorkflowResult> result = workflowNavigator.process(context);

// Throw any exceptions caught during workflow processing
if (result.flatMap(ImportWorkflowResult::getCaughtException).isPresent()) {
throw result.flatMap(ImportWorkflowResult::getCaughtException).get();
}

return result.flatMap(ImportWorkflowResult::getImportPreviewResponse).orElse(null);
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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.brapps.importer.model.imports;

import lombok.*;
import org.breedinginsight.brapps.importer.model.ImportUpload;
import org.breedinginsight.model.Program;
import org.breedinginsight.model.User;
import tech.tablesaw.api.Table;

import java.util.List;

@Getter
@Setter
@Builder
@ToString
@AllArgsConstructor
@NoArgsConstructor
public class ImportServiceContext {
private String workflow;
private List<BrAPIImport> brAPIImports;
private Table data;
private Program program;
private ImportUpload upload;
private User user;
private boolean commit;
}
Loading