001package org.gbif.api.model.collections; 002 003import io.swagger.v3.oas.annotations.media.Schema; 004 005import org.gbif.api.model.registry.PostPersist; 006import org.gbif.api.model.registry.PrePersist; 007import org.gbif.api.vocabulary.collections.Source; 008 009import java.io.Serializable; 010import java.util.Date; 011import java.util.Objects; 012import java.util.StringJoiner; 013 014import javax.validation.constraints.NotNull; 015import javax.validation.constraints.Null; 016 017/** Metadata to sync GRSciColl entities with their master sources. */ 018public class MasterSourceMetadata implements Serializable { 019 020 @Schema( 021 description = "Identifier for the master source metadata.", 022 accessMode = Schema.AccessMode.READ_ONLY 023 ) 024 @Null(groups = {PrePersist.class}) 025 @NotNull(groups = {PostPersist.class}) 026 private Integer key; 027 028 // TODO 029 //@Schema( 030 // description = "" 031 //) 032 @NotNull private Source source; 033 034 // TODO 035 //@Schema( 036 // description = "" 037 //) 038 @NotNull private String sourceId; 039 040 @Schema( 041 description = "The GBIF username of the creator of the master source metadata.", 042 accessMode = Schema.AccessMode.READ_ONLY 043 ) 044 private String createdBy; 045 046 @Schema( 047 description = "Timestamp of when the master source metadata was created.", 048 accessMode = Schema.AccessMode.READ_ONLY 049 ) 050 private Date created; 051 052 public MasterSourceMetadata() {} 053 054 public MasterSourceMetadata(Source source, String sourceId) { 055 this.source = source; 056 this.sourceId = sourceId; 057 } 058 059 public Integer getKey() { 060 return key; 061 } 062 063 public void setKey(Integer key) { 064 this.key = key; 065 } 066 067 public Source getSource() { 068 return source; 069 } 070 071 public void setSource(Source source) { 072 this.source = source; 073 } 074 075 public String getSourceId() { 076 return sourceId; 077 } 078 079 public void setSourceId(String sourceId) { 080 this.sourceId = sourceId; 081 } 082 083 public String getCreatedBy() { 084 return createdBy; 085 } 086 087 public void setCreatedBy(String createdBy) { 088 this.createdBy = createdBy; 089 } 090 091 public Date getCreated() { 092 return created; 093 } 094 095 public void setCreated(Date created) { 096 this.created = created; 097 } 098 099 @Override 100 public boolean equals(Object o) { 101 if (this == o) { 102 return true; 103 } 104 if (o == null || getClass() != o.getClass()) { 105 return false; 106 } 107 MasterSourceMetadata metadata = (MasterSourceMetadata) o; 108 return Objects.equals(key, metadata.key) 109 && source == metadata.source 110 && Objects.equals(sourceId, metadata.sourceId) 111 && Objects.equals(createdBy, metadata.createdBy) 112 && Objects.equals(created, metadata.created); 113 } 114 115 @Override 116 public int hashCode() { 117 return Objects.hash(key, source, sourceId, createdBy, created); 118 } 119 120 @Override 121 public String toString() { 122 return new StringJoiner(", ", MasterSourceMetadata.class.getSimpleName() + "[", "]") 123 .add("key=" + key) 124 .add("source=" + source) 125 .add("sourceId='" + sourceId + "'") 126 .add("createdBy='" + createdBy + "'") 127 .add("created=" + created) 128 .toString(); 129 } 130}