diff --git a/pom.xml b/pom.xml
index c6f103b..7beee74 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
eu.dnetlib.dhp
dhp-schemas
jar
- 2.3.7-SNAPSHOT
+ 2.3.6-SNAPSHOT
diff --git a/src/main/java/eu/dnetlib/dhp/schema/mdstore/MDStore.java b/src/main/java/eu/dnetlib/dhp/schema/mdstore/MDStore.java
index 99e9cea..7cafcc2 100644
--- a/src/main/java/eu/dnetlib/dhp/schema/mdstore/MDStore.java
+++ b/src/main/java/eu/dnetlib/dhp/schema/mdstore/MDStore.java
@@ -2,12 +2,11 @@
package eu.dnetlib.dhp.schema.mdstore;
import java.io.Serializable;
+import java.util.Date;
+import java.util.Objects;
import java.util.UUID;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
+import javax.persistence.*;
@Entity
@Table(name = "mdstores")
@@ -38,6 +37,13 @@ public class MDStore implements Serializable {
@Column(name = "api_id")
private String apiId;
+ @Column(name = "hdfs_path")
+ private String hdfsPath;
+
+ @Column(name = "creation_date")
+ @Temporal(TemporalType.TIMESTAMP)
+ private Date creationDate;
+
public String getId() {
return id;
}
@@ -94,9 +100,28 @@ public class MDStore implements Serializable {
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(
- final String format, final String layout, final String interpretation) {
- return newInstance(format, layout, interpretation, null, null, null);
+ final String format,
+ final String layout,
+ final String interpretation,
+ final String hdfsBasePath) {
+ return newInstance(format, layout, interpretation, null, null, null, hdfsBasePath);
}
public static MDStore newInstance(
@@ -105,15 +130,48 @@ public class MDStore implements Serializable {
final String interpretation,
final String dsName,
final String dsId,
- final String apiId) {
+ final String apiId,
+ final String hdfsBasePath) {
+
+ final String mdId = "md-" + UUID.randomUUID();
+
final MDStore md = new MDStore();
- md.setId("md-" + UUID.randomUUID());
+ md.setId(mdId);
md.setFormat(format);
md.setLayout(layout);
md.setInterpretation(interpretation);
+ md.setCreationDate(new Date());
md.setDatasourceName(dsName);
md.setDatasourceId(dsId);
md.setApiId(apiId);
+ md.setHdfsPath(String.format("%s/%s", hdfsBasePath, mdId));
+
return md;
}
+
+ @Override
+ public String toString() {
+ return String
+ .format(
+ "MDStore [id=%s, format=%s, layout=%s, interpretation=%s, datasourceName=%s, datasourceId=%s, apiId=%s, hdfsPath=%s, creationDate=%s]",
+ id, format, layout, interpretation, datasourceName, datasourceId, apiId, hdfsPath, creationDate);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id);
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof MDStore)) {
+ return false;
+ }
+ final MDStore other = (MDStore) obj;
+ return Objects.equals(id, other.id);
+ }
+
}
diff --git a/src/main/java/eu/dnetlib/dhp/schema/mdstore/MDStoreCurrentVersion.java b/src/main/java/eu/dnetlib/dhp/schema/mdstore/MDStoreCurrentVersion.java
index e741c43..56163ff 100644
--- a/src/main/java/eu/dnetlib/dhp/schema/mdstore/MDStoreCurrentVersion.java
+++ b/src/main/java/eu/dnetlib/dhp/schema/mdstore/MDStoreCurrentVersion.java
@@ -2,6 +2,7 @@
package eu.dnetlib.dhp.schema.mdstore;
import java.io.Serializable;
+import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -48,4 +49,26 @@ public class MDStoreCurrentVersion implements Serializable {
public static MDStoreCurrentVersion newInstance(final MDStoreVersion v) {
return newInstance(v.getMdstore(), v.getId());
}
+
+ @Override
+ public String toString() {
+ return String.format("MDStoreCurrentVersion [mdstore=%s, currentVersion=%s]", mdstore, currentVersion);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(currentVersion, mdstore);
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof MDStoreCurrentVersion)) {
+ return false;
+ }
+ final MDStoreCurrentVersion other = (MDStoreCurrentVersion) obj;
+ return Objects.equals(currentVersion, other.currentVersion) && Objects.equals(mdstore, other.mdstore);
+ }
}
diff --git a/src/main/java/eu/dnetlib/dhp/schema/mdstore/MDStoreVersion.java b/src/main/java/eu/dnetlib/dhp/schema/mdstore/MDStoreVersion.java
index d6f62ce..e09e755 100644
--- a/src/main/java/eu/dnetlib/dhp/schema/mdstore/MDStoreVersion.java
+++ b/src/main/java/eu/dnetlib/dhp/schema/mdstore/MDStoreVersion.java
@@ -3,13 +3,9 @@ package eu.dnetlib.dhp.schema.mdstore;
import java.io.Serializable;
import java.util.Date;
+import java.util.Objects;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
+import javax.persistence.*;
@Entity
@Table(name = "mdstore_versions")
@@ -38,15 +34,22 @@ public class MDStoreVersion implements Serializable {
@Column(name = "size")
private long size = 0;
- public static MDStoreVersion newInstance(final String mdId, final boolean writing) {
- final MDStoreVersion t = new MDStoreVersion();
- t.setId(mdId + "-" + new Date().getTime());
- t.setMdstore(mdId);
- t.setLastUpdate(null);
- t.setWriting(writing);
- t.setReadCount(0);
- t.setSize(0);
- return t;
+ @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;
}
public String getId() {
@@ -96,4 +99,37 @@ public class MDStoreVersion implements Serializable {
public void setSize(final long size) {
this.size = size;
}
+
+ public String getHdfsPath() {
+ return hdfsPath;
+ }
+
+ public void setHdfsPath(final String hdfsPath) {
+ this.hdfsPath = hdfsPath;
+ }
+
+ @Override
+ public String toString() {
+ return String
+ .format(
+ "MDStoreVersion [id=%s, mdstore=%s, writing=%s, readCount=%s, lastUpdate=%s, size=%s, hdfsPath=%s]", id,
+ mdstore, writing, readCount, lastUpdate, size, hdfsPath);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id);
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof MDStoreVersion)) {
+ return false;
+ }
+ final MDStoreVersion other = (MDStoreVersion) obj;
+ return Objects.equals(id, other.id);
+ }
}
diff --git a/src/main/java/eu/dnetlib/dhp/schema/mdstore/MDStoreWithInfo.java b/src/main/java/eu/dnetlib/dhp/schema/mdstore/MDStoreWithInfo.java
index 7367890..5bc60d3 100644
--- a/src/main/java/eu/dnetlib/dhp/schema/mdstore/MDStoreWithInfo.java
+++ b/src/main/java/eu/dnetlib/dhp/schema/mdstore/MDStoreWithInfo.java
@@ -3,13 +3,9 @@ package eu.dnetlib.dhp.schema.mdstore;
import java.io.Serializable;
import java.util.Date;
+import java.util.Objects;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
+import javax.persistence.*;
@Entity
@Table(name = "mdstores_with_info")
@@ -43,6 +39,10 @@ public class MDStoreWithInfo implements Serializable {
@Column(name = "current_version")
private String currentVersion;
+ @Column(name = "creation_date")
+ @Temporal(TemporalType.TIMESTAMP)
+ private Date creationDate;
+
@Column(name = "lastupdate")
@Temporal(TemporalType.TIMESTAMP)
private Date lastUpdate;
@@ -53,6 +53,9 @@ public class MDStoreWithInfo implements Serializable {
@Column(name = "n_versions")
private long numberOfVersions = 0;
+ @Column(name = "hdfs_path")
+ private String hdfsPath;
+
public String getId() {
return id;
}
@@ -117,6 +120,14 @@ public class MDStoreWithInfo implements Serializable {
this.currentVersion = currentVersion;
}
+ public Date getCreationDate() {
+ return creationDate;
+ }
+
+ public void setCreationDate(final Date creationDate) {
+ this.creationDate = creationDate;
+ }
+
public Date getLastUpdate() {
return lastUpdate;
}
@@ -140,4 +151,39 @@ public class MDStoreWithInfo implements Serializable {
public void setNumberOfVersions(final long numberOfVersions) {
this.numberOfVersions = numberOfVersions;
}
+
+ public String getHdfsPath() {
+ return hdfsPath;
+ }
+
+ public void setHdfsPath(final String hdfsPath) {
+ this.hdfsPath = hdfsPath;
+ }
+
+ @Override
+ public String toString() {
+ return String
+ .format(
+ "MDStoreWithInfo [id=%s, format=%s, layout=%s, interpretation=%s, datasourceName=%s, datasourceId=%s, apiId=%s, currentVersion=%s, creationDate=%s, lastUpdate=%s, size=%s, numberOfVersions=%s, hdfsPath=%s]",
+ id, format, layout, interpretation, datasourceName, datasourceId, apiId, currentVersion, creationDate,
+ lastUpdate, size, numberOfVersions, hdfsPath);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id);
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof MDStoreWithInfo)) {
+ return false;
+ }
+ final MDStoreWithInfo other = (MDStoreWithInfo) obj;
+ return Objects.equals(id, other.id);
+ }
+
}