JPA annotation Fixes

This commit is contained in:
Fabio Sinibaldi 2020-10-05 18:14:20 +02:00
parent 2d1fc1cd62
commit eff6e68f92
8 changed files with 65 additions and 37 deletions

View File

@ -1,6 +1,6 @@
package org.gcube.application.geoportal.model;
import java.util.Date;
import java.time.Instant;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.Entity;
@ -42,9 +42,9 @@ public abstract class Record {
protected String folderId;
//Accounting
protected Date lastUpdateTime;
protected Instant lastUpdateTime;
protected String lastUpdateUser;
protected Date creationTime;
protected Instant creationTime;
protected String creationUser;

View File

@ -1,10 +1,14 @@
package org.gcube.application.geoportal.model.concessioni;
import java.util.Date;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import org.gcube.application.geoportal.model.Record;
import org.gcube.application.geoportal.model.RecordType;
@ -56,8 +60,8 @@ public class Concessione extends Record{
private List<String> risorseCorrelate;
private Date dataInizioScavo;
private Date dataFineScavo;
private Instant dataInizioScavo;
private Instant dataFineScavo;
private String titolareLicenza;
private String titolareCopyright;
@ -71,12 +75,20 @@ public class Concessione extends Record{
private Double centroidLong;
@OneToOne(cascade = CascadeType.ALL)
private RelazioneScavo relazioneScavo;
private List<UploadedImage> immaginiRappresentative;
@OneToMany(mappedBy = "record", cascade = CascadeType.ALL)
private List<UploadedImage> immaginiRappresentative=new ArrayList<UploadedImage>();
@OneToOne(cascade = CascadeType.ALL)
private LayerConcessione posizionamentoScavo;
private List<LayerConcessione> pianteFineScavo;
private List<OtherContent> genericContent;
@OneToMany(mappedBy = "record", cascade = CascadeType.ALL)
private List<LayerConcessione> pianteFineScavo=new ArrayList<>();
@OneToMany(mappedBy = "record", cascade = CascadeType.ALL)
private List<OtherContent> genericContent=new ArrayList<>();
public Concessione() {

View File

@ -1,8 +1,10 @@
package org.gcube.application.geoportal.model.content;
import java.util.Date;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@ -10,9 +12,12 @@ import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.gcube.application.geoportal.model.AccessPolicy;
import org.gcube.application.geoportal.model.Record;
import org.gcube.application.geoportal.utils.CollectionsUtils;
import lombok.Getter;
@ -35,11 +40,13 @@ public abstract class AssociatedContent {
private AccessPolicy policy;
private String licenseID;
private String titolo;
private Date creationTime;
private Instant creationTime;
@ManyToOne
private Record record;
private List<PersistedContent> actualContent;
@OneToMany(mappedBy = "associated", cascade = CascadeType.ALL)
private List<PersistedContent> actualContent=new ArrayList<>();

View File

@ -7,6 +7,7 @@ import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import lombok.EqualsAndHashCode;
@ -28,4 +29,6 @@ public abstract class PersistedContent {
@GeneratedValue(strategy=GenerationType.IDENTITY)
private long id;
@ManyToOne
private AssociatedContent associated;
}

View File

@ -1,32 +1,26 @@
package org.gcube.application.geoportal.model.gis;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.persistence.annotations.HashPartitioning;
import org.gcube.application.geoportal.model.fault.DataParsingException;
import java.io.Serializable;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
@RequiredArgsConstructor
@Getter
@ToString
@Slf4j
@NoArgsConstructor
@EqualsAndHashCode
public class BBOX{
public class BBOX implements Serializable{
/**
*
*/
private static final long serialVersionUID = -159414992596542946L;
public static BBOX WORLD_EXTENT=new BBOX(90d,180d,-90d,-180d);
@NonNull
private Double maxLat;
@NonNull
@ -35,4 +29,5 @@ public class BBOX{
private Double minLat;
@NonNull
private Double minLong;
}

View File

@ -1,7 +1,5 @@
package org.gcube.application.geoportal.model.gis;
import java.util.List;
import javax.persistence.Entity;
@Entity

View File

@ -9,12 +9,25 @@ public class CollectionsUtils {
public static boolean equalsCollections(Collection<?> a, Collection<?> b) {
if(a==null&&b!=null) return false;
if(a!=null&&b==null) return false;
if(a==null&&b!=null)
return false;
if(a!=null&&b==null)
return false;
if(a==null&&b==null) return true;
if(a==null&&b==null)
return true;
return CollectionUtils.isEqualCollection(a,b);
if(a.size()!=b.size())
return false;
Iterator<?> itA=a.iterator();
Iterator<?> itB=a.iterator();
while(itA.hasNext()) {
if(!itA.next().equals(itB.next()))
return false;
}
return true;
}
public static int hashCode(Collection<?> a) {

View File

@ -19,7 +19,7 @@ public class TestModel {
// Generic fields
concessione.setCreationTime(Date.from(Instant.now()));
concessione.setCreationTime(Instant.now());
concessione.setCreationUser("my author");
concessione.setLastUpdateTime(concessione.getCreationTime());
concessione.setVersion("1.0.0");
@ -46,8 +46,8 @@ public class TestModel {
concessione.setDataInizioScavo(Date.from(Instant.now()));
concessione.setDataFineScavo(Date.from(Instant.now()));
concessione.setDataInizioScavo(Instant.now());
concessione.setDataFineScavo(Instant.now());
concessione.setTitolareLicenza("Qualcun altro");
concessione.setTitolareCopyright("Chiedilo in giro");
@ -82,7 +82,7 @@ public class TestModel {
img.setDidascalia("You can see my image number "+i);
img.setFormat("TIFF");
img.setSoggetto(concessione.getSoggetto());
img.setCreationTime(Date.from(Instant.now()));
img.setCreationTime(Instant.now());
img.setResponsabili(concessione.getAuthors());
img.setLicenseID("CC-BY");
imgs.add(img);