Skip to content
Snippets Groups Projects
Commit cf0a8129 authored by Lene Wasskog's avatar Lene Wasskog
Browse files

feat: Add observer information to excel file

parent 5545f85f
No related branches found
No related tags found
1 merge request!191Add map module and Open-Meteo support
...@@ -691,6 +691,8 @@ public class Observation implements Serializable, no.nibio.vips.observation.Obse ...@@ -691,6 +691,8 @@ public class Observation implements Serializable, no.nibio.vips.observation.Obse
} }
return new ObservationListItem( return new ObservationListItem(
this.getObservationId(), this.getObservationId(),
this.userId,
this.user != null ? this.user.getFullName() : null,
this.getObservationTimeSeriesId(), this.getObservationTimeSeriesId(),
this.getTimeOfObservation(), this.getTimeOfObservation(),
this.getOrganismId(), this.getOrganismId(),
......
...@@ -143,6 +143,12 @@ public class VipsLogicUser implements Serializable, Comparable{ ...@@ -143,6 +143,12 @@ public class VipsLogicUser implements Serializable, Comparable{
this.lastName = lastName; this.lastName = lastName;
} }
@JsonIgnore
@Transient
public String getFullName() {
return firstName + " " + lastName;
}
@OneToMany(cascade = CascadeType.ALL, mappedBy = "vipsLogicUser", fetch=FetchType.EAGER) @OneToMany(cascade = CascadeType.ALL, mappedBy = "vipsLogicUser", fetch=FetchType.EAGER)
@XmlTransient @XmlTransient
@JsonIgnore @JsonIgnore
......
...@@ -28,6 +28,8 @@ import no.nibio.vips.observationdata.ObservationDataSchema; ...@@ -28,6 +28,8 @@ import no.nibio.vips.observationdata.ObservationDataSchema;
*/ */
public class ObservationListItem implements Comparable{ public class ObservationListItem implements Comparable{
private Integer observationId, observationTimeSeriesId, organismId, cropOrganismId; private Integer observationId, observationTimeSeriesId, organismId, cropOrganismId;
private Integer observerId;
private String observerName;
private Date timeOfObservation; private Date timeOfObservation;
private String organismName, cropOrganismName; private String organismName, cropOrganismName;
private String observationTimeSeriesLabel; private String observationTimeSeriesLabel;
...@@ -42,6 +44,8 @@ public class ObservationListItem implements Comparable{ ...@@ -42,6 +44,8 @@ public class ObservationListItem implements Comparable{
public ObservationListItem( public ObservationListItem(
Integer observationId, Integer observationId,
Integer observerId,
String observerName,
Integer observationTimeSeriesId, Integer observationTimeSeriesId,
Date timeOfObservation, Date timeOfObservation,
Integer organismId, Integer organismId,
...@@ -59,6 +63,8 @@ public class ObservationListItem implements Comparable{ ...@@ -59,6 +63,8 @@ public class ObservationListItem implements Comparable{
ObservationDataSchema observationDataSchema ObservationDataSchema observationDataSchema
){ ){
this.observationId = observationId; this.observationId = observationId;
this.observerId = observerId;
this.observerName = observerName;
this.observationTimeSeriesId = observationTimeSeriesId; this.observationTimeSeriesId = observationTimeSeriesId;
this.timeOfObservation = timeOfObservation; this.timeOfObservation = timeOfObservation;
this.organismId = organismId; this.organismId = organismId;
...@@ -101,6 +107,34 @@ public class ObservationListItem implements Comparable{ ...@@ -101,6 +107,34 @@ public class ObservationListItem implements Comparable{
this.observationId = observationId; this.observationId = observationId;
} }
/**
* @return The ID of the observer
*/
public Integer getObserverId() {
return observerId;
}
/**
* @param observerId The ID to set
*/
public void setObserverId(Integer observerId) {
this.observerId = observerId;
}
/**
* @return The full name of the observer
*/
public String getObserverName() {
return observerName;
}
/**
* @param observerName The observer name to set
*/
public void setObserverName(String observerName) {
this.observerName = observerName;
}
/** /**
* @return the observationTimeSeriesId * @return the observationTimeSeriesId
*/ */
......
...@@ -24,11 +24,13 @@ public final class ExcelFileGenerator { ...@@ -24,11 +24,13 @@ public final class ExcelFileGenerator {
private static final int COL_INDEX_DATE = 0; private static final int COL_INDEX_DATE = 0;
private static final int COL_INDEX_LOCATION = 1; private static final int COL_INDEX_LOCATION = 1;
private static final int COL_INDEX_ORGANISM = 2; private static final int COL_INDEX_OBSERVER_ID = 2;
private static final int COL_INDEX_CROP_ORGANISM = 3; private static final int COL_INDEX_OBSERVER_NAME = 3;
private static final int COL_INDEX_HEADING = 4; private static final int COL_INDEX_ORGANISM = 4;
private static final int COL_INDEX_DESCRIPTION = 5; private static final int COL_INDEX_CROP_ORGANISM = 5;
private static final int COL_START_INDEX_DATA = 6; private static final int COL_INDEX_HEADING = 6;
private static final int COL_INDEX_DESCRIPTION = 7;
private static final int COL_START_INDEX_DATA = 8;
public static byte[] generateExcel(VipsLogicUser user, ULocale locale, List<ObservationListItem> observations) throws IOException { public static byte[] generateExcel(VipsLogicUser user, ULocale locale, List<ObservationListItem> observations) throws IOException {
ResourceBundle rb = ResourceBundle.getBundle("no.nibio.vips.logic.i18n.vipslogictexts", locale.toLocale()); ResourceBundle rb = ResourceBundle.getBundle("no.nibio.vips.logic.i18n.vipslogictexts", locale.toLocale());
...@@ -174,6 +176,8 @@ public final class ExcelFileGenerator { ...@@ -174,6 +176,8 @@ public final class ExcelFileGenerator {
Row headerRow = sheet.createRow(0); Row headerRow = sheet.createRow(0);
headerRow.createCell(COL_INDEX_DATE).setCellValue(rb.getString("timeOfObservation")); headerRow.createCell(COL_INDEX_DATE).setCellValue(rb.getString("timeOfObservation"));
headerRow.createCell(COL_INDEX_LOCATION).setCellValue(rb.getString("location")); headerRow.createCell(COL_INDEX_LOCATION).setCellValue(rb.getString("location"));
headerRow.createCell(COL_INDEX_OBSERVER_ID).setCellValue(rb.getString("observerId"));
headerRow.createCell(COL_INDEX_OBSERVER_NAME).setCellValue(rb.getString("observer"));
headerRow.createCell(COL_INDEX_ORGANISM).setCellValue(rb.getString("organism")); headerRow.createCell(COL_INDEX_ORGANISM).setCellValue(rb.getString("organism"));
headerRow.createCell(COL_INDEX_CROP_ORGANISM).setCellValue(rb.getString("cropOrganismId")); headerRow.createCell(COL_INDEX_CROP_ORGANISM).setCellValue(rb.getString("cropOrganismId"));
headerRow.createCell(COL_INDEX_HEADING).setCellValue(rb.getString("observationHeading")); headerRow.createCell(COL_INDEX_HEADING).setCellValue(rb.getString("observationHeading"));
...@@ -196,6 +200,8 @@ public final class ExcelFileGenerator { ...@@ -196,6 +200,8 @@ public final class ExcelFileGenerator {
Row row = sheet.createRow(rowIndex); Row row = sheet.createRow(rowIndex);
row.createCell(COL_INDEX_DATE).setCellValue(localDateOfObservation.format(DATE_FORMATTER)); row.createCell(COL_INDEX_DATE).setCellValue(localDateOfObservation.format(DATE_FORMATTER));
row.createCell(COL_INDEX_LOCATION).setCellValue(pointOfInterestName); row.createCell(COL_INDEX_LOCATION).setCellValue(pointOfInterestName);
row.createCell(COL_INDEX_OBSERVER_ID).setCellValue(item.getObserverId());
row.createCell(COL_INDEX_OBSERVER_NAME).setCellValue(item.getObserverName());
row.createCell(COL_INDEX_ORGANISM).setCellValue(item.getOrganismName()); row.createCell(COL_INDEX_ORGANISM).setCellValue(item.getOrganismName());
row.createCell(COL_INDEX_CROP_ORGANISM).setCellValue(item.getCropOrganismName()); row.createCell(COL_INDEX_CROP_ORGANISM).setCellValue(item.getCropOrganismName());
row.createCell(COL_INDEX_HEADING).setCellValue(item.getObservationHeading()); row.createCell(COL_INDEX_HEADING).setCellValue(item.getObservationHeading());
......
...@@ -602,6 +602,8 @@ observedDateOfFirstCatch = Observed date of first catch ...@@ -602,6 +602,8 @@ observedDateOfFirstCatch = Observed date of first catch
observedValue = Observed value observedValue = Observed value
observerId = Observer ID
observer = Observer observer = Observer
older = Older older = Older
......
...@@ -602,6 +602,8 @@ observedDateOfFirstCatch = Observert dato for f\u00f8rste fellefangst ...@@ -602,6 +602,8 @@ observedDateOfFirstCatch = Observert dato for f\u00f8rste fellefangst
observedValue = Observert verdi observedValue = Observert verdi
observerId = Observat\u00f8r-Id
observer = Observat\u00f8r observer = Observat\u00f8r
older = Eldre older = Eldre
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment