new fields in mdstore beans

This commit is contained in:
Michele Artini 2021-01-28 08:24:45 +01:00
parent 150a617bd1
commit 38f2508c87
3 changed files with 88 additions and 13 deletions

View File

@ -2,12 +2,15 @@
package eu.dnetlib.data.mdstore.manager.common.model; package eu.dnetlib.data.mdstore.manager.common.model;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
import java.util.UUID; import java.util.UUID;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity @Entity
@Table(name = "mdstores") @Table(name = "mdstores")
@ -38,6 +41,13 @@ public class MDStore implements Serializable {
@Column(name = "api_id") @Column(name = "api_id")
private String apiId; private String apiId;
@Column(name = "hdfs_path")
private String hdfsPath;
@Column(name = "creation_date")
@Temporal(TemporalType.TIMESTAMP)
private Date creationDate;
public String getId() { public String getId() {
return id; return id;
} }
@ -94,9 +104,28 @@ public class MDStore implements Serializable {
this.apiId = apiId; this.apiId = apiId;
} }
public String getHdfsPath() {
return hdfsPath;
}
public void setHdfsPath(final String hdfsPath) {
this.hdfsPath = hdfsPath;
}
public Date getCreationDate() {
return creationDate;
}
public void setCreationDate(final Date creationDate) {
this.creationDate = creationDate;
}
public static MDStore newInstance( public static MDStore newInstance(
final String format, final String layout, final String interpretation) { final String format,
return newInstance(format, layout, interpretation, null, null, null); final String layout,
final String interpretation,
final String hdfsBasePath) {
return newInstance(format, layout, interpretation, null, null, null, hdfsBasePath);
} }
public static MDStore newInstance( public static MDStore newInstance(
@ -105,15 +134,23 @@ public class MDStore implements Serializable {
final String interpretation, final String interpretation,
final String dsName, final String dsName,
final String dsId, final String dsId,
final String apiId) { final String apiId,
final String hdfsBasePath) {
final String mdId = "md-" + UUID.randomUUID();
final MDStore md = new MDStore(); final MDStore md = new MDStore();
md.setId("md-" + UUID.randomUUID()); md.setId(mdId);
md.setFormat(format); md.setFormat(format);
md.setLayout(layout); md.setLayout(layout);
md.setInterpretation(interpretation); md.setInterpretation(interpretation);
md.setCreationDate(new Date());
md.setDatasourceName(dsName); md.setDatasourceName(dsName);
md.setDatasourceId(dsId); md.setDatasourceId(dsId);
md.setApiId(apiId); md.setApiId(apiId);
md.setHdfsPath(String.format("%s/%s", hdfsBasePath, mdId));
return md; return md;
} }
} }

View File

@ -38,15 +38,22 @@ public class MDStoreVersion implements Serializable {
@Column(name = "size") @Column(name = "size")
private long size = 0; private long size = 0;
public static MDStoreVersion newInstance(final String mdId, final boolean writing) { @Column(name = "hdfs_path")
final MDStoreVersion t = new MDStoreVersion(); private String hdfsPath;
t.setId(mdId + "-" + new Date().getTime());
t.setMdstore(mdId); public static MDStoreVersion newInstance(final String mdId, final boolean writing, final String hdfsBasePath) {
t.setLastUpdate(null); final MDStoreVersion v = new MDStoreVersion();
t.setWriting(writing);
t.setReadCount(0); final String versionId = mdId + "-" + new Date().getTime();
t.setSize(0); v.setId(versionId);
return t; v.setMdstore(mdId);
v.setLastUpdate(null);
v.setWriting(writing);
v.setReadCount(0);
v.setSize(0);
v.setHdfsPath(String.format("%s/%s/%s", hdfsBasePath, mdId, versionId));
return v;
} }
public String getId() { public String getId() {
@ -96,4 +103,12 @@ public class MDStoreVersion implements Serializable {
public void setSize(final long size) { public void setSize(final long size) {
this.size = size; this.size = size;
} }
public String getHdfsPath() {
return hdfsPath;
}
public void setHdfsPath(final String hdfsPath) {
this.hdfsPath = hdfsPath;
}
} }

View File

@ -43,6 +43,10 @@ public class MDStoreWithInfo implements Serializable {
@Column(name = "current_version") @Column(name = "current_version")
private String currentVersion; private String currentVersion;
@Column(name = "creation_date")
@Temporal(TemporalType.TIMESTAMP)
private Date creationDate;
@Column(name = "lastupdate") @Column(name = "lastupdate")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Date lastUpdate; private Date lastUpdate;
@ -53,6 +57,9 @@ public class MDStoreWithInfo implements Serializable {
@Column(name = "n_versions") @Column(name = "n_versions")
private long numberOfVersions = 0; private long numberOfVersions = 0;
@Column(name = "hdfs_path")
private String hdfsPath;
public String getId() { public String getId() {
return id; return id;
} }
@ -117,6 +124,14 @@ public class MDStoreWithInfo implements Serializable {
this.currentVersion = currentVersion; this.currentVersion = currentVersion;
} }
public Date getCreationDate() {
return creationDate;
}
public void setCreationDate(final Date creationDate) {
this.creationDate = creationDate;
}
public Date getLastUpdate() { public Date getLastUpdate() {
return lastUpdate; return lastUpdate;
} }
@ -140,4 +155,12 @@ public class MDStoreWithInfo implements Serializable {
public void setNumberOfVersions(final long numberOfVersions) { public void setNumberOfVersions(final long numberOfVersions) {
this.numberOfVersions = numberOfVersions; this.numberOfVersions = numberOfVersions;
} }
public String getHdfsPath() {
return hdfsPath;
}
public void setHdfsPath(final String hdfsPath) {
this.hdfsPath = hdfsPath;
}
} }