Commit ce394f53 authored by Matija Obreza's avatar Matija Obreza
Browse files

Annotated entities for ES indexing

parent 7dad4f8d
......@@ -379,5 +379,17 @@
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
<version>2.1.12.RELEASE</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
......@@ -47,6 +47,9 @@ import org.genesys.catalog.service.PublishValidationInterface;
import org.genesys.common.model.Partner;
import org.genesys.common.model.SelfCleaning;
import org.genesys.filerepository.model.RepositoryFile;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonView;
......@@ -62,6 +65,7 @@ import com.fasterxml.jackson.annotation.JsonView;
@Entity
@Cacheable
@Audited
@Document(indexName = "catalog")
public class Dataset extends UuidModel implements Publishable, SelfCleaning, PublishValidationInterface, AclAwareModel {
/** The Constant serialVersionUID. */
......@@ -86,6 +90,7 @@ public class Dataset extends UuidModel implements Publishable, SelfCleaning, Pub
@CollectionTable(name = "datasetAccessions", joinColumns = @JoinColumn(name = "datasetId"),
// index
indexes = { @Index(columnList = "datasetId, instCode, acceNumb"), @Index(columnList = "datasetId, genus") })
@Field(type=FieldType.Object)
@JsonView({ JsonViews.Public.class })
private Set<AccessionIdentifier> accessionIdentifiers;
......@@ -101,18 +106,21 @@ public class Dataset extends UuidModel implements Publishable, SelfCleaning, Pub
@OneToMany(fetch = FetchType.LAZY, cascade = {})
@JoinTable(name = "datasetRepositoryfile", joinColumns = @JoinColumn(name = "datasetId", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "repositoryfileId", referencedColumnName = "id"))
@OrderColumn(name = "position")
@Field(type=FieldType.Object)
@JsonView({ JsonViews.Public.class })
private List<RepositoryFile> repositoryFiles;
/** The creators. */
@PublishValidation(innerCheck = true)
@OneToMany(cascade = { CascadeType.ALL }, mappedBy = "dataset", orphanRemoval = true, fetch = FetchType.LAZY)
@Field(type=FieldType.Object)
@JsonView({ JsonViews.Public.class })
private List<DatasetCreator> creators;
/** The locations. */
@PublishValidation(innerCheck = true)
@OneToMany(cascade = { CascadeType.ALL }, mappedBy = "dataset", orphanRemoval = true, fetch = FetchType.LAZY)
@Field(type=FieldType.Object)
@JsonView({ JsonViews.Public.class })
private List<DatasetLocation> locations;
......
......@@ -49,6 +49,9 @@ import org.genesys.catalog.model.vocab.VocabularyTerm;
import org.genesys.common.model.Partner;
import org.genesys.common.model.SelfCleaning;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
......@@ -67,6 +70,7 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
@Table(name = "descriptor")
@Audited
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "uuid")
@Document(indexName = "catalog")
public class Descriptor extends UuidModel implements SelfCleaning, Publishable, Copyable<Descriptor>, AclAwareModel {
/** The Constant serialVersionUID. */
......@@ -181,6 +185,7 @@ public class Descriptor extends UuidModel implements SelfCleaning, Publishable,
@JsonIdentityReference(alwaysAsId = false)
@JsonIgnoreProperties(value = { "terms" })
@JsonView({ JsonViews.Public.class })
@Field(type = FieldType.Nested)
private ControlledVocabulary vocabulary;
/**
......@@ -194,6 +199,7 @@ public class Descriptor extends UuidModel implements SelfCleaning, Publishable,
uniqueConstraints = { @UniqueConstraint(columnNames = { "descriptorId", "termId" }) })
@OrderColumn(name = "idx")
@JsonView({ JsonViews.Public.class })
@Field(type = FieldType.Nested)
private List<VocabularyTerm> terms;
/** The owner. */
......
......@@ -43,6 +43,9 @@ import org.genesys.blocks.model.UuidModel;
import org.genesys.blocks.security.model.AclAwareModel;
import org.genesys.common.model.Partner;
import org.genesys.common.model.SelfCleaning;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
......@@ -58,6 +61,7 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
@Audited
@Cacheable
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "uuid")
@Document(indexName = "catalog")
public class DescriptorList extends UuidModel implements Publishable, SelfCleaning, AclAwareModel {
/** The Constant serialVersionUID. */
......@@ -105,12 +109,14 @@ public class DescriptorList extends UuidModel implements Publishable, SelfCleani
@OrderColumn(name = "position")
@JsonView({ JsonViews.Public.class })
@JsonIgnoreProperties(value = { "descriptorLists", "datasets", "owner", "vocabulary", "terms" })
@Field(type = FieldType.Nested)
List<Descriptor> descriptors;
/** The owner. */
@ManyToOne(cascade = {}, optional = false)
@JoinColumn(name = "partnerId", updatable = false)
@JsonView({ JsonViews.Public.class })
@Field(type = FieldType.Nested)
private Partner owner;
/** The publisher. */
......
......@@ -38,6 +38,9 @@ import org.genesys.blocks.security.model.AclAwareModel;
import org.genesys.common.model.Partner;
import org.genesys.common.model.SelfCleaning;
import org.hibernate.annotations.ColumnDefault;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
......@@ -56,6 +59,7 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
*/
@Entity
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "uuid")
@Document(indexName = "catalog")
public class ControlledVocabulary extends UuidModel implements Publishable, SelfCleaning, AclAwareModel {
/** The Constant serialVersionUID. */
......@@ -104,6 +108,7 @@ public class ControlledVocabulary extends UuidModel implements Publishable, Self
@OrderColumn(name = "idx")
@JsonIgnoreProperties({ "vocabulary", "descriptor" })
@JsonView({ JsonViews.Minimal.class })
@Field(type = FieldType.Nested)
private List<VocabularyTerm> terms;
/** Number of terms in the vocabulary */
......
......@@ -33,6 +33,9 @@ import org.genesys.blocks.model.BasicModel;
import org.genesys.blocks.model.JsonViews;
import org.genesys.catalog.model.traits.Descriptor;
import org.genesys.common.model.SelfCleaning;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
......@@ -53,6 +56,7 @@ import com.fasterxml.jackson.annotation.JsonView;
*/
@Entity
@Table(name = "Term")
@Document(indexName = "catalog")
public class VocabularyTerm extends BasicModel implements SelfCleaning {
/** The Constant serialVersionUID. */
......@@ -78,6 +82,7 @@ public class VocabularyTerm extends BasicModel implements SelfCleaning {
@JsonView({ JsonViews.Indexed.class, JsonViews.Minimal.class })
@JsonIgnoreProperties(value = { "terms", "owner" })
@JsonIdentityReference(alwaysAsId = false)
@Field(type = FieldType.Nested)
private Descriptor descriptor;
/**
......@@ -90,6 +95,7 @@ public class VocabularyTerm extends BasicModel implements SelfCleaning {
@JsonView({ JsonViews.Indexed.class, JsonViews.Minimal.class })
@JsonIgnoreProperties(value = { "terms", "owner" })
@JsonIdentityReference(alwaysAsId = false)
@Field(type = FieldType.Nested)
private ControlledVocabulary vocabulary;
/**
......
......@@ -25,6 +25,7 @@ import javax.persistence.Table;
import org.genesys.blocks.auditlog.annotations.Audited;
import org.genesys.blocks.model.UuidModel;
import org.genesys.blocks.security.model.AclAwareModel;
import org.springframework.data.elasticsearch.annotations.Document;
/**
* @author Maxym Borodenko
......@@ -33,6 +34,7 @@ import org.genesys.blocks.security.model.AclAwareModel;
@Cacheable
@Table(name = "crop")
@Audited
@Document(indexName = "catalog")
public class Crop extends UuidModel implements SelfCleaning, AclAwareModel {
/** The Constant serialVersionUID. */
......
......@@ -40,6 +40,7 @@ import org.genesys.blocks.security.model.AclAwareModel;
import org.genesys.catalog.model.traits.Descriptor;
import org.genesys.catalog.model.traits.DescriptorList;
import org.genesys.catalog.model.vocab.ControlledVocabulary;
import org.springframework.data.elasticsearch.annotations.Document;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnore;
......@@ -54,6 +55,7 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
@Cacheable
@Table(name = "partner")
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "uuid")
@Document(indexName = "catalog")
public class Partner extends UuidModel implements SelfCleaning, AclAwareModel {
/** The Constant serialVersionUID. */
......
......@@ -299,6 +299,10 @@
<artifactId>httpclient</artifactId>
<groupId>org.apache.httpcomponents</groupId>
</exclusion>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava-jdk5</artifactId>
</exclusion>
</exclusions>
</dependency>
......@@ -667,5 +671,10 @@
<artifactId>freemarker</artifactId>
<version>2.3.23</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
<version>2.1.12.RELEASE</version>
</dependency>
</dependencies>
</project>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment