add created, updated in DmpReference

This commit is contained in:
amentis 2023-10-27 11:41:44 +03:00
parent e4203a3bb4
commit 7508cf8698
4 changed files with 54 additions and 4 deletions

View File

@ -5,6 +5,7 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import java.time.Instant;
import java.util.UUID;
@Entity
@ -26,6 +27,15 @@ public class DmpReferenceEntity {
@Column(name = "data")
private String data;
@Column(name = "created_at", nullable = false)
private Instant createdAt;
public static final String _createdAt = "createdAt";
@Column(name = "updated_at", nullable = false)
private Instant updatedAt;
public static final String _updatedAt = "updatedAt";
public static final String _data = "data";
public UUID getId() {
@ -59,4 +69,20 @@ public class DmpReferenceEntity {
public void setData(String data) {
this.data = data;
}
public Instant getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Instant createdAt) {
this.createdAt = createdAt;
}
public Instant getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(Instant updatedAt) {
this.updatedAt = updatedAt;
}
}

View File

@ -1,5 +1,6 @@
package eu.eudat.model;
import java.time.Instant;
import java.util.UUID;
public class DmpReference {
@ -16,6 +17,13 @@ public class DmpReference {
private String data;
public static final String _data = "data";
private Instant createdAt;
public static final String _createdAt = "createdAt";
private Instant updatedAt;
public static final String _updatedAt = "updatedAt";
public UUID getId() {
return id;
}
@ -47,4 +55,12 @@ public class DmpReference {
public void setData(String data) {
this.data = data;
}
public Instant getCreatedAt() { return createdAt;}
public void setCreatedAt(Instant createdAt) {this.createdAt = createdAt;}
public Instant getUpdatedAt() {return updatedAt;}
public void setUpdatedAt(Instant updatedAt) {this.updatedAt = updatedAt;}
}

View File

@ -63,6 +63,8 @@ public class DmpReferenceBuilder extends BaseBuilder<DmpReference, DmpReferenceE
DmpReference m = new DmpReference();
if (fields.hasField(this.asIndexer(DmpReference._id))) m.setId(d.getId());
if (fields.hasField(this.asIndexer(DmpReference._data))) m.setData(d.getData());
if (fields.hasField(this.asIndexer(DmpReference._createdAt))) m.setCreatedAt(d.getCreatedAt());
if (fields.hasField(this.asIndexer(DmpReference._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
if(!referenceFields.isEmpty() && referenceItemsMap != null && referenceItemsMap.containsKey(d.getReferenceId())){
m.setReference(referenceItemsMap.get(d.getReferenceId()));
}

View File

@ -3,6 +3,7 @@ package eu.eudat.query;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.DmpReferenceEntity;
import eu.eudat.model.DmpReference;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.data.query.QueryBase;
@ -14,6 +15,7 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.time.Instant;
import java.util.*;
@Component
@ -137,15 +139,19 @@ public class DmpReferenceQuery extends QueryBase<DmpReferenceEntity> {
item.setReferenceId(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._dmpId, UUID.class));
item.setReferenceId(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._referenceId, UUID.class));
item.setData(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._data, String.class));
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._createdAt, Instant.class));
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._updatedAt, Instant.class));
return item;
}
@Override
protected String fieldNameOf(FieldResolver item) {
if (item.match(DmpReferenceEntity._id)) return DmpReferenceEntity._id;
else if (item.prefix(DmpReferenceEntity._dmpId)) return DmpReferenceEntity._dmpId;
else if (item.prefix(DmpReferenceEntity._referenceId)) return DmpReferenceEntity._referenceId;
else if (item.match(DmpReferenceEntity._data)) return DmpReferenceEntity._data;
if (item.match(DmpReference._id)) return DmpReferenceEntity._id;
else if (item.prefix(DmpReference._dmp)) return DmpReferenceEntity._dmpId;
else if (item.prefix(DmpReference._reference)) return DmpReferenceEntity._referenceId;
else if (item.match(DmpReference._data)) return DmpReferenceEntity._data;
else if (item.match(DmpReference._createdAt)) return DmpReferenceEntity._createdAt;
else if (item.match(DmpReference._updatedAt)) return DmpReferenceEntity._updatedAt;
else return null;
}