This repository has been archived on 2021-09-09. You can view files and clone it, but cannot push or open issues or pull requests.
geoportal-service/src/main/java/org/gcube/application/geoportal/service/model/legacy/concessioni/UploadedImage.java

113 lines
3.1 KiB
Java

package org.gcube.application.geoportal.service.model.legacy.concessioni;
import java.util.List;
import javax.persistence.DiscriminatorValue;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import org.gcube.application.geoportal.model.Record;
import org.gcube.application.geoportal.utils.CollectionsUtils;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@Entity
@DiscriminatorValue("IMAGE")
public class UploadedImage extends AssociatedContent {
private String didascalia;
private String format;
@ElementCollection(targetClass=String.class)
private List<String> responsabili;
@ElementCollection(targetClass=String.class)
private List<String> soggetto;
@ManyToOne
@JoinColumn(name="record_id", nullable=false)
private Record record;
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((didascalia == null) ? 0 : didascalia.hashCode());
result = prime * result + ((format == null) ? 0 : format.hashCode());
// result = prime * result + ((responsabili == null) ? 0 : responsabili.hashCode());
result = prime * result + CollectionsUtils.hashCode(responsabili);
// result = prime * result + ((soggetto == null) ? 0 : soggetto.hashCode());
result = prime * result + CollectionsUtils.hashCode(soggetto);
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
UploadedImage other = (UploadedImage) obj;
if (didascalia == null) {
if (other.didascalia != null)
return false;
} else if (!didascalia.equals(other.didascalia))
return false;
if (format == null) {
if (other.format != null)
return false;
} else if (!format.equals(other.format))
return false;
// if (responsabili == null) {
// if (other.responsabili != null)
// return false;
// } else if (!responsabili.equals(other.responsabili))
// return false;
if(!CollectionsUtils.equalsCollections(responsabili, other.responsabili)) return false;
// if (soggetto == null) {
// if (other.soggetto != null)
// return false;
// } else if (!soggetto.equals(other.soggetto))
// return false;
if(!CollectionsUtils.equalsCollections(soggetto, other.soggetto)) return false;
return true;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("UploadedImage [didascalia=");
builder.append(didascalia);
builder.append(", format=");
builder.append(format);
builder.append(", responsabili=");
builder.append(responsabili);
builder.append(", soggetto=");
builder.append(soggetto);
if(record!=null) {
builder.append(", owner-record-id=");
builder.append(record.getId());
}else {
builder.append(", record=");
builder.append(record);
}
builder.append(", toString()=");
builder.append(super.toString());
builder.append("]");
return builder.toString();
}
}