|
| 1 | +package org.openherbarium.webapp.model; |
| 2 | + |
| 3 | +import java.time.LocalDate; |
| 4 | +import java.util.ArrayList; |
| 5 | +import java.util.Collections; |
| 6 | +import java.util.List; |
| 7 | +import java.util.Set; |
| 8 | + |
| 9 | +public class Metadata { |
| 10 | + |
| 11 | + public static final String TAXON_NAME = "Taxon"; |
| 12 | + public static final String RECORDER = "Finder"; |
| 13 | + public static final String DETERMINER = "Bestimmer"; |
| 14 | + public static final String DATE = "Datum"; |
| 15 | + public static final String SCANS = "Scans"; |
| 16 | + |
| 17 | + private long id; |
| 18 | + private String externalId; |
| 19 | + private String taxonName; |
| 20 | + private Person recorder; |
| 21 | + private Person determiner; |
| 22 | + private LocalDate date; |
| 23 | + private Set<Scan> scans; |
| 24 | + |
| 25 | + public Metadata() { |
| 26 | + super(); |
| 27 | + } |
| 28 | + |
| 29 | + public Metadata(long id, String externalId, String taxonName, Person recorder, Person determiner, |
| 30 | + LocalDate date, Set<Scan> scans) { |
| 31 | + super(); |
| 32 | + this.id = id; |
| 33 | + this.externalId = externalId; |
| 34 | + this.taxonName = taxonName; |
| 35 | + this.recorder = recorder; |
| 36 | + this.determiner = determiner; |
| 37 | + this.date = date; |
| 38 | + this.scans = scans; |
| 39 | + } |
| 40 | + |
| 41 | + public long getId() { |
| 42 | + return id; |
| 43 | + } |
| 44 | + |
| 45 | + public void setId(long id) { |
| 46 | + this.id = id; |
| 47 | + } |
| 48 | + |
| 49 | + public String getExternalId() { |
| 50 | + return externalId; |
| 51 | + } |
| 52 | + |
| 53 | + public void setExternalId(String externalId) { |
| 54 | + this.externalId = externalId; |
| 55 | + } |
| 56 | + |
| 57 | + public String getTaxonName() { |
| 58 | + return taxonName; |
| 59 | + } |
| 60 | + |
| 61 | + public void setTaxonName(String taxonName) { |
| 62 | + this.taxonName = taxonName; |
| 63 | + } |
| 64 | + |
| 65 | + public Person getRecorder() { |
| 66 | + return recorder; |
| 67 | + } |
| 68 | + |
| 69 | + public void setRecorder(Person recorder) { |
| 70 | + this.recorder = recorder; |
| 71 | + } |
| 72 | + |
| 73 | + public Person getDeterminer() { |
| 74 | + return determiner; |
| 75 | + } |
| 76 | + |
| 77 | + public void setDeterminer(Person determiner) { |
| 78 | + this.determiner = determiner; |
| 79 | + } |
| 80 | + |
| 81 | + public Set<Scan> getScans() { |
| 82 | + return scans; |
| 83 | + } |
| 84 | + |
| 85 | + public void setScans(Set<Scan> scans) { |
| 86 | + this.scans = scans; |
| 87 | + } |
| 88 | + |
| 89 | + public LocalDate getDate() { |
| 90 | + return date; |
| 91 | + } |
| 92 | + |
| 93 | + public void setDate(LocalDate date) { |
| 94 | + this.date = date; |
| 95 | + } |
| 96 | + |
| 97 | + public Scan fetchDefaultScan() { |
| 98 | + return fetchScansAsSortedList().get(0); |
| 99 | + } |
| 100 | + |
| 101 | + public List<Scan> fetchScansAsSortedList() { |
| 102 | + final Set<Scan> scans = getScans(); |
| 103 | + if (scans != null && !scans.isEmpty()) { |
| 104 | + final List<Scan> scansList = new ArrayList<>(scans); |
| 105 | + Collections.sort(scansList); |
| 106 | + return scansList; |
| 107 | + } |
| 108 | + return new ArrayList<>(); |
| 109 | + } |
| 110 | +} |
0 commit comments