127 lines
2.7 KiB
Java
127 lines
2.7 KiB
Java
package eu.dnetlib.data.mdstore.model;
|
|
|
|
import java.io.Serializable;
|
|
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
|
/**
|
|
* This class models a record in a Metadata store collection
|
|
*/
|
|
public class MetadataRecord implements Serializable {
|
|
|
|
private static final long serialVersionUID = -226995288313973437L;
|
|
|
|
/** The D-Net Identifier associated to the record */
|
|
private String id;
|
|
|
|
/** The original Identifier of the record */
|
|
private String originalId;
|
|
|
|
/** The encoding of the record, should be JSON or XML */
|
|
private String encoding;
|
|
|
|
/**
|
|
* The information about the provenance of the record see @{@link Provenance} for the model of this information
|
|
*/
|
|
private Provenance provenance;
|
|
|
|
/** The content of the metadata */
|
|
private String body;
|
|
|
|
/** the date when the record has been stored */
|
|
private Long dateOfCollection;
|
|
|
|
/** the date when the record has been stored */
|
|
private Long dateOfTransformation;
|
|
|
|
public MetadataRecord() {
|
|
|
|
}
|
|
|
|
public MetadataRecord(
|
|
final String originalId,
|
|
final String encoding,
|
|
final Provenance provenance,
|
|
final String body,
|
|
final Long dateOfCollection) {
|
|
|
|
this.originalId = originalId;
|
|
this.encoding = encoding;
|
|
this.provenance = provenance;
|
|
this.body = body;
|
|
this.dateOfCollection = dateOfCollection;
|
|
this.id = generateIdentifier(originalId, this.provenance.getNsPrefix());
|
|
}
|
|
|
|
public static String generateIdentifier(final String originalId, final String nsPrefix) {
|
|
return String.format("%s::%s", nsPrefix, DigestUtils.md5Hex(originalId));
|
|
}
|
|
|
|
public String getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(final String id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public String getOriginalId() {
|
|
return originalId;
|
|
}
|
|
|
|
public void setOriginalId(final String originalId) {
|
|
this.originalId = originalId;
|
|
}
|
|
|
|
public String getEncoding() {
|
|
return encoding;
|
|
}
|
|
|
|
public void setEncoding(final String encoding) {
|
|
this.encoding = encoding;
|
|
}
|
|
|
|
public Provenance getProvenance() {
|
|
return provenance;
|
|
}
|
|
|
|
public void setProvenance(final Provenance provenance) {
|
|
this.provenance = provenance;
|
|
}
|
|
|
|
public String getBody() {
|
|
return body;
|
|
}
|
|
|
|
public void setBody(final String body) {
|
|
this.body = body;
|
|
}
|
|
|
|
public Long getDateOfCollection() {
|
|
return dateOfCollection;
|
|
}
|
|
|
|
public void setDateOfCollection(final Long dateOfCollection) {
|
|
this.dateOfCollection = dateOfCollection;
|
|
}
|
|
|
|
public Long getDateOfTransformation() {
|
|
return dateOfTransformation;
|
|
}
|
|
|
|
public void setDateOfTransformation(final Long dateOfTransformation) {
|
|
this.dateOfTransformation = dateOfTransformation;
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(final Object o) {
|
|
if (!(o instanceof MetadataRecord)) { return false; }
|
|
return ((MetadataRecord) o).getId().equalsIgnoreCase(id);
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
return id.hashCode();
|
|
}
|
|
}
|