Commit 90624bd5 authored by Matija Obreza's avatar Matija Obreza
Browse files

Include accession list UUIDs in ES

parent dfb75f4d
......@@ -40,15 +40,23 @@ public class ElasticQueryBuilder implements Visitor<Void, Void> {
}
private String customizedPath(String path) {
String root = null;
// Just remove the entity name from the path -- hopefully that's fine
if (path.contains(".")) {
int lastDot = path.indexOf('.');
// String base = path.substring(0, lastDot);
path = path.substring(lastDot + 1);
int firstDot = path.indexOf('.');
root = path.substring(0, firstDot);
path = path.substring(firstDot + 1);
}
if (path.contains("accessionId.")) {
return path.replace("accessionId.", "");
// FIXME We should try to build this from annotations on startup. This is very hacky.
if ("accession".equals(root)) {
if (path.equals("accessionId.lists.uuid")) {
// Example of @JsonIdentityReference(alwaysAsId = true)
return "lists";
} else if (path.startsWith("accessionId.")) {
// Example of @JsonUnwrapped
return path.replace("accessionId.", "");
}
}
return path;
}
......
......@@ -46,11 +46,15 @@ import org.genesys.blocks.model.JsonViews;
import org.genesys.custom.elasticsearch.IgnoreField;
import org.hibernate.annotations.Type;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldIndex;
import org.springframework.data.elasticsearch.annotations.FieldType;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonView;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
/**
* Entity holds the assigned accession identifiers regardless of active or
......@@ -77,7 +81,10 @@ public class AccessionId extends AuditedVersionedModel implements IdUUID {
@ManyToMany(cascade = {}, fetch = FetchType.LAZY)
@JoinTable(name = "accession_listitem", joinColumns = @JoinColumn(name = "acceid"), inverseJoinColumns = @JoinColumn(name = "listid"))
@JsonIgnore
@JsonView({ JsonViews.Indexed.class })
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "uuid")
@JsonIdentityReference(alwaysAsId = true)
@Field(index = FieldIndex.not_analyzed, type = FieldType.String)
private Set<AccessionList> lists;
@OneToOne(fetch = FetchType.LAZY, cascade = { CascadeType.ALL }, optional = true, orphanRemoval = true)
......@@ -113,12 +120,12 @@ public class AccessionId extends AuditedVersionedModel implements IdUUID {
@OneToMany(mappedBy = "accession", cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, orphanRemoval = true)
@JsonIgnoreProperties({ "accession" })
@Field(type=FieldType.Nested)
@Field(type = FieldType.Nested)
private List<AccessionAlias> aliases;
@OneToMany(mappedBy = "accession", cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, orphanRemoval = true)
@JsonIgnoreProperties({ "accession" })
@Field(type=FieldType.Nested)
@Field(type = FieldType.Nested)
private List<AccessionRemark> remarks;
@Column(name = "breederCode", nullable = false, length = 9)
......
Markdown is supported
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