2020-04-27 14:52:31 +02:00
|
|
|
|
2019-04-03 10:53:54 +02:00
|
|
|
package eu.dnetlib.data.mdstore.manager.common.model;
|
2019-03-18 15:30:07 +01:00
|
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
import java.util.Date;
|
2020-04-28 11:23:29 +02:00
|
|
|
|
2019-03-18 15:30:07 +01:00
|
|
|
import javax.persistence.Column;
|
|
|
|
import javax.persistence.Entity;
|
|
|
|
import javax.persistence.Id;
|
|
|
|
import javax.persistence.Table;
|
|
|
|
import javax.persistence.Temporal;
|
|
|
|
import javax.persistence.TemporalType;
|
|
|
|
|
|
|
|
@Entity
|
2019-03-20 15:36:23 +01:00
|
|
|
@Table(name = "mdstore_versions")
|
|
|
|
public class MDStoreVersion implements Serializable {
|
|
|
|
|
2020-04-27 14:52:31 +02:00
|
|
|
/** */
|
|
|
|
private static final long serialVersionUID = -4763494442274298339L;
|
2020-04-27 14:45:40 +02:00
|
|
|
|
2020-04-27 14:52:31 +02:00
|
|
|
@Id
|
|
|
|
@Column(name = "id")
|
|
|
|
private String id;
|
2020-04-27 14:45:40 +02:00
|
|
|
|
2020-04-27 14:52:31 +02:00
|
|
|
@Column(name = "mdstore")
|
|
|
|
private String mdstore;
|
2020-04-27 14:45:40 +02:00
|
|
|
|
2020-04-27 14:52:31 +02:00
|
|
|
@Column(name = "writing")
|
|
|
|
private boolean writing;
|
2020-04-27 14:45:40 +02:00
|
|
|
|
2020-04-27 14:52:31 +02:00
|
|
|
@Column(name = "readcount")
|
|
|
|
private int readCount = 0;
|
2020-04-27 14:45:40 +02:00
|
|
|
|
2020-04-27 14:52:31 +02:00
|
|
|
@Column(name = "lastupdate")
|
|
|
|
@Temporal(TemporalType.TIMESTAMP)
|
|
|
|
private Date lastUpdate;
|
2020-04-27 14:45:40 +02:00
|
|
|
|
2020-04-27 14:52:31 +02:00
|
|
|
@Column(name = "size")
|
|
|
|
private long size = 0;
|
2020-04-27 14:45:40 +02:00
|
|
|
|
2021-01-28 08:24:45 +01:00
|
|
|
@Column(name = "hdfs_path")
|
|
|
|
private String hdfsPath;
|
|
|
|
|
|
|
|
public static MDStoreVersion newInstance(final String mdId, final boolean writing, final String hdfsBasePath) {
|
|
|
|
final MDStoreVersion v = new MDStoreVersion();
|
|
|
|
|
|
|
|
final String versionId = mdId + "-" + new Date().getTime();
|
|
|
|
v.setId(versionId);
|
|
|
|
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;
|
2020-04-27 14:52:31 +02:00
|
|
|
}
|
2020-04-27 14:45:40 +02:00
|
|
|
|
2020-04-27 14:52:31 +02:00
|
|
|
public String getId() {
|
|
|
|
return id;
|
|
|
|
}
|
2020-04-27 14:45:40 +02:00
|
|
|
|
2020-04-27 14:52:31 +02:00
|
|
|
public void setId(final String id) {
|
|
|
|
this.id = id;
|
|
|
|
}
|
2020-04-27 14:45:40 +02:00
|
|
|
|
2020-04-27 14:52:31 +02:00
|
|
|
public String getMdstore() {
|
|
|
|
return mdstore;
|
|
|
|
}
|
2020-04-27 14:45:40 +02:00
|
|
|
|
2020-04-27 14:52:31 +02:00
|
|
|
public void setMdstore(final String mdstore) {
|
|
|
|
this.mdstore = mdstore;
|
|
|
|
}
|
2020-04-27 14:45:40 +02:00
|
|
|
|
2020-04-27 14:52:31 +02:00
|
|
|
public boolean isWriting() {
|
|
|
|
return writing;
|
|
|
|
}
|
2020-04-27 14:45:40 +02:00
|
|
|
|
2020-04-27 14:52:31 +02:00
|
|
|
public void setWriting(final boolean writing) {
|
|
|
|
this.writing = writing;
|
|
|
|
}
|
2020-04-27 14:45:40 +02:00
|
|
|
|
2020-04-27 14:52:31 +02:00
|
|
|
public int getReadCount() {
|
|
|
|
return readCount;
|
|
|
|
}
|
2020-04-27 14:45:40 +02:00
|
|
|
|
2020-04-27 14:52:31 +02:00
|
|
|
public void setReadCount(final int readCount) {
|
|
|
|
this.readCount = readCount;
|
|
|
|
}
|
2020-04-27 14:45:40 +02:00
|
|
|
|
2020-04-27 14:52:31 +02:00
|
|
|
public Date getLastUpdate() {
|
|
|
|
return lastUpdate;
|
|
|
|
}
|
2020-04-27 14:45:40 +02:00
|
|
|
|
2020-04-27 14:52:31 +02:00
|
|
|
public void setLastUpdate(final Date lastUpdate) {
|
|
|
|
this.lastUpdate = lastUpdate;
|
|
|
|
}
|
2020-04-27 14:45:40 +02:00
|
|
|
|
2020-04-27 14:52:31 +02:00
|
|
|
public long getSize() {
|
|
|
|
return size;
|
|
|
|
}
|
2020-04-27 14:45:40 +02:00
|
|
|
|
2020-04-27 14:52:31 +02:00
|
|
|
public void setSize(final long size) {
|
|
|
|
this.size = size;
|
|
|
|
}
|
2021-01-28 08:24:45 +01:00
|
|
|
|
|
|
|
public String getHdfsPath() {
|
|
|
|
return hdfsPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setHdfsPath(final String hdfsPath) {
|
|
|
|
this.hdfsPath = hdfsPath;
|
|
|
|
}
|
2019-03-18 15:30:07 +01:00
|
|
|
}
|