Commit d35cd1e4 authored by Alexander Prendetskiy's avatar Alexander Prendetskiy Committed by Matija Obreza

Move tileIndex to AccessionData

Signed-off-by: Matija Obreza's avatarMatija Obreza <matija.obreza@croptrust.org>
parent eb199dd3
...@@ -42,7 +42,8 @@ import org.springframework.data.elasticsearch.annotations.Document; ...@@ -42,7 +42,8 @@ import org.springframework.data.elasticsearch.annotations.Document;
@Index(name = "IX_origcty_seqNo", columnList = "orgCtyId,seqNo"), @Index(name = "IX_origcty_seqNo", columnList = "orgCtyId,seqNo"),
@Index(name = "IX_taxa_seq", columnList = "taxonomyId2,seqNo"), @Index(name = "IX_taxa_seq", columnList = "taxonomyId2,seqNo"),
@Index(name = "IX_seqNo", columnList = "seqNo"), @Index(name = "IX_seqNo", columnList = "seqNo"),
@Index(name = "IX_accession_lastModifiedDate", columnList = "lastModifiedDate") }) @Index(name = "IX_accession_lastModifiedDate", columnList = "lastModifiedDate"),
@Index(unique = false, columnList = "tileIndex")})
@Audited @Audited
@Document(indexName = "genesys") @Document(indexName = "genesys")
public class Accession extends AccessionData { public class Accession extends AccessionData {
......
...@@ -38,6 +38,7 @@ import org.genesys.blocks.model.AuditedVersionedModel; ...@@ -38,6 +38,7 @@ import org.genesys.blocks.model.AuditedVersionedModel;
import org.genesys.blocks.model.IdUUID; import org.genesys.blocks.model.IdUUID;
import org.genesys.blocks.model.JsonViews; import org.genesys.blocks.model.JsonViews;
import org.genesys.blocks.model.SelfCleaning; import org.genesys.blocks.model.SelfCleaning;
import org.genesys.worldclim.WorldClimUtil;
import org.genesys2.server.model.impl.Country; import org.genesys2.server.model.impl.Country;
import org.genesys2.server.model.impl.Crop; import org.genesys2.server.model.impl.Crop;
import org.genesys2.server.model.impl.FaoInstitute; import org.genesys2.server.model.impl.FaoInstitute;
...@@ -178,6 +179,8 @@ public abstract class AccessionData extends AuditedVersionedModel implements IdU ...@@ -178,6 +179,8 @@ public abstract class AccessionData extends AuditedVersionedModel implements IdU
@Field(index = FieldIndex.not_analyzed) @Field(index = FieldIndex.not_analyzed)
@JsonInclude @JsonInclude
private boolean sgsv; private boolean sgsv;
private Long tileIndex;
/** /**
* Update MCPD {@link #storageStr} * Update MCPD {@link #storageStr}
...@@ -198,6 +201,12 @@ public abstract class AccessionData extends AuditedVersionedModel implements IdU ...@@ -198,6 +201,12 @@ public abstract class AccessionData extends AuditedVersionedModel implements IdU
this.instituteCode = getInstitute().getCode(); this.instituteCode = getInstitute().getCode();
this.storageStr = MCPDUtil.toMcpdArray(accessionId.getStorage()); this.storageStr = MCPDUtil.toMcpdArray(accessionId.getStorage());
this.duplSiteStr = MCPDUtil.toMcpdArray(accessionId.getDuplSite()); this.duplSiteStr = MCPDUtil.toMcpdArray(accessionId.getDuplSite());
AccessionGeo geo = this.accessionId.getGeo();
if (geo != null) {
tileIndex = WorldClimUtil.getTileIndex(5, geo.getLongitude(), geo.getLatitude());
}
} }
public FaoInstitute getInstitute() { public FaoInstitute getInstitute() {
...@@ -344,6 +353,14 @@ public abstract class AccessionData extends AuditedVersionedModel implements IdU ...@@ -344,6 +353,14 @@ public abstract class AccessionData extends AuditedVersionedModel implements IdU
this.accessionId = accessionId; this.accessionId = accessionId;
} }
public Long getTileIndex() {
return tileIndex;
}
public void setTileIndex(Long tileIndex) {
this.tileIndex = tileIndex;
}
@Override @Override
@Transient @Transient
public UUID getUuid() { public UUID getUuid() {
......
...@@ -3710,3 +3710,32 @@ databaseChangeLog: ...@@ -3710,3 +3710,32 @@ databaseChangeLog:
- dropColumn: - dropColumn:
tableName: dataset tableName: dataset
columnName: published columnName: published
- changeSet:
id: 1533210002102-1
author: aprendetskiy
changes:
- addColumn:
tableName: accession
columns:
- column:
name: tileIndex
type: BIGINT
- sql:
sql: >-
update accession a right join acce ac on ac.id = a.id right join accession_geo geo on geo.id = ac.geoId set a.tileIndex = geo.tileIndex;
- createIndex:
columns:
- column:
name: tileIndex
indexName: UK_21geycvlx21bswf9t89s2r99n
tableName: accession
- addColumn:
tableName: accession_historic
columns:
- column:
name: tileIndex
type: BIGINT
- sql:
sql: >-
update accession_historic ah right join acce ac on ac.id = ah.id right join accession_geo geo on geo.id = ac.geoId set ah.tileIndex = geo.tileIndex;
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