|
|
|
@ -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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|