Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
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
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
aa138b6
[autocommit] bumping build number
rob-ouser-bi May 16, 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
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
1d63a71
[BI-2127] merged with BI-2127 into release/0.9.1
davedrp May 17, 2024
8a28a2d
[autocommit] bumping build number
rob-ouser-bi May 24, 2024
9104a3e
restore germplasmAccessionNumber to GermplasmTemplateMap
dmeidlin May 29, 2024
4e51c9f
Merge pull request #363 from Breeding-Insight/bug/BI-2155
dmeidlin May 30, 2024
f50cad4
[autocommit] bumping build number
rob-ouser-bi May 30, 2024
402eb5d
create DomainImportService abstract class
dmeidlin May 31, 2024
7fd32a0
Merging release/0.9.1 into develop
mlm483 Jun 5, 2024
f9a0783
[autocommit] bumping build number
rob-ouser-bi Jun 5, 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
d21a988
Merge pull request #360 from Breeding-Insight/feature/BI-2122-A
dmeidlin Jun 11, 2024
e406e38
Merge branch 'feature/BI-2122' into feature/BI-2132-A
nickpalladino Jun 18, 2024
79189ba
Messing with dependency issue
nickpalladino Jun 18, 2024
0ef8cd5
Removed ununsed fileImportService injection and resolved DI issue
nickpalladino Jun 21, 2024
1acd04b
Added in BI-2128 change
nickpalladino Jun 21, 2024
fc2a661
Merge branch 'develop' into feature/BI-2132-A
nickpalladino Jun 21, 2024
6a4043d
Updated create only tests to use create workflow
nickpalladino Jun 21, 2024
651cffc
Removed unused migration
nickpalladino Jun 21, 2024
39fb8cd
Removed append environment workflow
nickpalladino Jun 21, 2024
be8ea38
Fix error message
nickpalladino Jun 21, 2024
d11ef3c
Removed navigator stuff handled in domain import service
nickpalladino Jun 21, 2024
eebb493
Removed some development comments
nickpalladino Jun 21, 2024
1225ab4
Added db migration to change UNK breeding method class to Increase
nickpalladino Jun 26, 2024
d30d04f
Removed trailing whitespace on Unknown breeding method
nickpalladino Jun 26, 2024
b5dc3e8
Reference enum for new-experiment
nickpalladino Jul 1, 2024
2bbf7f3
Change variable name to reflect string type
nickpalladino Jul 1, 2024
ccc1414
Clarified comment
nickpalladino Jul 1, 2024
7a35165
Clarified comment
nickpalladino Jul 1, 2024
aa06c6e
Removed old comment
nickpalladino Jul 1, 2024
dd6f348
Updated doc comment
nickpalladino Jul 1, 2024
a6c3590
Cleaned up ProcessedData code
nickpalladino Jul 1, 2024
1a6de32
Changed from workflow to workflowId
nickpalladino Jul 2, 2024
4e9e1b8
Merge pull request #369 from Breeding-Insight/bug/BI-1975
nickpalladino Jul 2, 2024
281cc6c
[autocommit] bumping build number
rob-ouser-bi Jul 2, 2024
28a2272
Swapped lat and lon as they were reversed
nickpalladino Jun 26, 2024
a960d55
Merge pull request #368 from Breeding-Insight/bug/BI-2167
nickpalladino Jul 2, 2024
48a8817
[autocommit] bumping build number
rob-ouser-bi Jul 2, 2024
a488612
Change exception handling
nickpalladino Jul 2, 2024
9b04d44
Merge branch 'develop' into feature/BI-2132-A
nickpalladino Jul 2, 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
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.breedinginsight.brapi.v2.services;

import com.github.filosganga.geogson.model.Coordinates;
import com.github.filosganga.geogson.model.positions.SinglePosition;
import com.google.gson.JsonObject;
import io.micronaut.context.annotation.Property;
import io.micronaut.http.MediaType;
import io.micronaut.http.server.exceptions.InternalServerException;
Expand Down Expand Up @@ -465,6 +468,26 @@ private Map<String, Object> createExportRow(
row.put(ExperimentObservation.Columns.EXP_TYPE, experiment.getAdditionalInfo().getAsJsonObject().get(BrAPIAdditionalInfoFields.EXPERIMENT_TYPE).getAsString());
row.put(ExperimentObservation.Columns.ENV, Utilities.removeProgramKeyAndUnknownAdditionalData(study.getStudyName(), program.getKey()));
row.put(ExperimentObservation.Columns.ENV_LOCATION, Utilities.removeProgramKey(study.getLocationName(), program.getKey()));

// Lat, Long, Elevation
Coordinates coordinates = extractCoordinates(ou);
Optional.ofNullable(coordinates)
.map(c -> doubleToString(c.getLat()))
.ifPresent(lat -> row.put(ExperimentObservation.Columns.LAT, lat));
Optional.ofNullable(coordinates)
.map(c -> doubleToString(c.getLon()))
.ifPresent(lon -> row.put(ExperimentObservation.Columns.LONG, lon));
Optional.ofNullable(coordinates)
.map(c -> doubleToString(c.getAlt()))
.ifPresent(elevation -> row.put(ExperimentObservation.Columns.ELEVATION, elevation));

// RTK
JsonObject additionalInfo = ou.getAdditionalInfo();
String rtk = ( additionalInfo==null || additionalInfo.get(BrAPIAdditionalInfoFields.RTK) ==null )
? null
: additionalInfo.get(BrAPIAdditionalInfoFields.RTK).getAsString();
row.put(ExperimentObservation.Columns.RTK, rtk);

BrAPISeason season = seasonDAO.getSeasonById(study.getSeasons().get(0), program.getId());
row.put(ExperimentObservation.Columns.ENV_YEAR, season.getYear());
row.put(ExperimentObservation.Columns.EXP_UNIT_ID, Utilities.removeProgramKeyAndUnknownAdditionalData(ou.getObservationUnitName(), program.getKey()));
Expand All @@ -484,11 +507,13 @@ private Map<String, Object> createExportRow(
.findFirst();
blockLevel.ifPresent(brAPIObservationUnitLevelRelationship ->
row.put(ExperimentObservation.Columns.BLOCK_NUM, Integer.parseInt(brAPIObservationUnitLevelRelationship.getLevelCode())));
if (ou.getObservationUnitPosition() != null && ou.getObservationUnitPosition().getPositionCoordinateX() != null &&
ou.getObservationUnitPosition().getPositionCoordinateY() != null) {

//Row and Column
if ( ou.getObservationUnitPosition() != null ) {
row.put(ExperimentObservation.Columns.ROW, ou.getObservationUnitPosition().getPositionCoordinateX());
row.put(ExperimentObservation.Columns.COLUMN, ou.getObservationUnitPosition().getPositionCoordinateY());
}

if (ou.getTreatments() != null && !ou.getTreatments().isEmpty()) {
row.put(ExperimentObservation.Columns.TREATMENT_FACTORS, ou.getTreatments().get(0).getFactor());
} else {
Expand All @@ -499,7 +524,25 @@ private Map<String, Object> createExportRow(
return row;
}


private String doubleToString(double val){
return Double.isNaN(val) ? null : String.valueOf( val );
}
private Coordinates extractCoordinates(BrAPIObservationUnit ou){
Coordinates coordinates = null;
if ( ou.getObservationUnitPosition()!=null
&& ou.getObservationUnitPosition().getGeoCoordinates()!=null
&& ou.getObservationUnitPosition().getGeoCoordinates().getGeometry()!=null
&& ou.getObservationUnitPosition().getGeoCoordinates().getGeometry().positions()!=null
)
{
Object o = ou.getObservationUnitPosition().getGeoCoordinates().getGeometry().positions();
if (o instanceof SinglePosition){
SinglePosition sp = (SinglePosition)o;
coordinates= sp.coordinates();
}
}
return coordinates;
}

private void addObsVarColumns(
List<Column> columns,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +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.ImportMappingWorkflow;
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 @@ -214,16 +214,22 @@ public HttpResponse<Response<DataResponse<ImportMapping>>> getSystemMappings(@Nu
@Produces(MediaType.APPLICATION_JSON)
@AddMetadata
@Secured(SecurityRule.IS_ANONYMOUS)
public HttpResponse<Response<DataResponse<ImportMappingWorkflow>>> getWorkflowsForSystemMapping(@PathVariable UUID mappingId) {
public HttpResponse<Response<DataResponse<ImportWorkflow>>> getWorkflowsForSystemMapping(@PathVariable UUID mappingId) throws Exception {

List<ImportMappingWorkflow> workflows = fileImportService.getWorkflowsForSystemMapping(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<ImportMappingWorkflow>> response = new Response(metadata, new DataResponse<>(workflows));
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 @@ -163,7 +163,7 @@ public HttpResponse<Response<ImportResponse>> previewData(@PathVariable UUID pro
@AddMetadata
@ProgramSecured(roles = {ProgramSecuredRole.BREEDER, ProgramSecuredRole.SYSTEM_ADMIN})
public HttpResponse<Response<ImportResponse>> previewData(@PathVariable UUID programId, @PathVariable UUID mappingId,
@PathVariable UUID workflowId, @PathVariable UUID uploadId) {
@PathVariable String workflowId, @PathVariable UUID uploadId) {
try {
AuthenticatedUser actingUser = securityService.getUser();
ImportResponse result = fileImportService.updateUpload(programId, uploadId, workflowId, actingUser, null, false);
Expand All @@ -189,7 +189,7 @@ public HttpResponse<Response<ImportResponse>> previewData(@PathVariable UUID pro
@AddMetadata
@ProgramSecured(roles = {ProgramSecuredRole.BREEDER, ProgramSecuredRole.SYSTEM_ADMIN})
public HttpResponse<Response<ImportResponse>> commitData(@PathVariable UUID programId, @PathVariable UUID mappingId,
@PathVariable UUID workflowId, @PathVariable UUID uploadId,
@PathVariable String workflowId, @PathVariable UUID uploadId,
@Body @Nullable Map<String, Object> userInput) {
try {
AuthenticatedUser actingUser = securityService.getUser();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@
package org.breedinginsight.brapps.importer.model.imports;

import org.breedinginsight.brapps.importer.model.response.ImportPreviewResponse;
import org.breedinginsight.brapps.importer.model.workflow.ImportWorkflow;

import java.util.List;

public interface BrAPIImportService {
String getImportTypeId();
BrAPIImport getImportClass();
List<ImportWorkflow> getWorkflows() throws Exception;
default String getInvalidIntegerMsg(String columnName) {
return String.format("Column name \"%s\" must be integer type, but non-integer type provided.", columnName);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* 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.imports.experimentObservation.ExperimentObservation;
import org.breedinginsight.brapps.importer.model.response.ImportPreviewResponse;
import org.breedinginsight.brapps.importer.model.workflow.ExperimentWorkflow;
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 org.breedinginsight.brapps.importer.services.processors.ExperimentProcessor;
import org.breedinginsight.brapps.importer.services.processors.ProcessorManager;
import org.breedinginsight.brapps.importer.services.processors.experiment.ExperimentWorkflowNavigator;

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

@Singleton
@Slf4j
public abstract class DomainImportService implements BrAPIImportService {

// TODO: delete processor fields once WorkflowNavigator is used
private final Provider<ExperimentProcessor> experimentProcessorProvider;
private final Provider<ProcessorManager> processorManagerProvider;
private final Workflow workflowNavigator;


public DomainImportService(Provider<ExperimentProcessor> experimentProcessorProvider,
Provider<ProcessorManager> processorManagerProvider,
Workflow workflowNavigator)
{
this.experimentProcessorProvider = experimentProcessorProvider;
this.processorManagerProvider = processorManagerProvider;
this.workflowNavigator = workflowNavigator;
}

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

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

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

// TODO: return results from WorkflowNavigator once processing logic is in separate workflows
// return workflowNavigator.process(context).flatMap(ImportWorkflowResult::getImportPreviewResponse).orElse(null);
if (ExperimentWorkflowNavigator.Workflow.NEW_OBSERVATION.getId().equals(context.getWorkflowId())) {
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);

} else {
return processorManagerProvider.get().process(context.getBrAPIImports(),
List.of(experimentProcessorProvider.get()),
context.getData(),
context.getProgram(),
context.getUpload(),
context.getUser(),
context.isCommit());
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

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

import java.util.List;

@Getter
Expand All @@ -32,7 +32,7 @@
@AllArgsConstructor
@NoArgsConstructor
public class ImportServiceContext {
private Workflow workflow;
private String workflowId;
private List<BrAPIImport> brAPIImports;
private Table data;
private Program program;
Expand Down
Loading