2019-05-21 17:17:41 +02:00
|
|
|
package eu.eudat.criteria;
|
|
|
|
|
|
|
|
import eu.eudat.criteria.entities.Criteria;
|
|
|
|
import eu.eudat.criteria.entities.DateCriteria;
|
2019-05-23 17:03:44 +02:00
|
|
|
import eu.eudat.logic.services.operations.DatabaseRepository;
|
2019-05-21 17:17:41 +02:00
|
|
|
import eu.eudat.query.DMPQuery;
|
|
|
|
|
2019-05-23 17:03:44 +02:00
|
|
|
import java.util.*;
|
2019-05-21 17:17:41 +02:00
|
|
|
|
|
|
|
public class DMPCriteria {
|
|
|
|
private Criteria<UUID> id;
|
|
|
|
private Criteria<UUID> groupId;
|
|
|
|
private Criteria<String> label;
|
|
|
|
private Criteria<Integer> version;
|
|
|
|
private ProjectCriteria project;
|
|
|
|
private DateCriteria created;
|
|
|
|
private DateCriteria modified;
|
2019-05-23 17:03:44 +02:00
|
|
|
private UserCriteria creator;
|
|
|
|
private DatasetCriteria dataset;
|
2019-05-21 17:17:41 +02:00
|
|
|
|
|
|
|
public Criteria<UUID> getId() {
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setId(Criteria<UUID> id) {
|
|
|
|
this.id = id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setId(String id) {
|
|
|
|
Criteria<UUID> criteria = new Criteria<>();
|
|
|
|
criteria.setAs(id);
|
|
|
|
this.id = criteria;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Criteria<UUID> getGroupId() {
|
|
|
|
return groupId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setGroupId(Criteria<UUID> groupId) {
|
|
|
|
this.groupId = groupId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setGroupId(String groupId) {
|
|
|
|
Criteria<UUID> criteria = new Criteria<>();
|
|
|
|
criteria.setAs(groupId);
|
|
|
|
this.groupId = criteria;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Criteria<String> getLabel() {
|
|
|
|
return label;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLabel(Criteria<String> label) {
|
|
|
|
this.label = label;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLabel(String label) {
|
|
|
|
Criteria<String> criteria = new Criteria<>();
|
|
|
|
criteria.setAs(label);
|
|
|
|
this.label = criteria;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Criteria<Integer> getVersion() {
|
|
|
|
return version;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setVersion(Criteria<Integer> version) {
|
|
|
|
this.version = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setVersion(String version) {
|
|
|
|
Criteria<Integer> criteria = new Criteria<>();
|
|
|
|
criteria.setAs(version);
|
|
|
|
this.version = criteria;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ProjectCriteria getProject() {
|
|
|
|
return project;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setProject(ProjectCriteria project) {
|
|
|
|
this.project = project;
|
|
|
|
}
|
|
|
|
|
|
|
|
public DateCriteria getCreated() {
|
|
|
|
return created;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCreated(DateCriteria created) {
|
|
|
|
this.created = created;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCreated(String created) {
|
|
|
|
DateCriteria criteria = new DateCriteria();
|
|
|
|
criteria.setAs(created);
|
|
|
|
this.created = criteria;
|
|
|
|
}
|
|
|
|
|
|
|
|
public DateCriteria getModified() {
|
|
|
|
return modified;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setModified(DateCriteria modified) {
|
|
|
|
this.modified = modified;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setModified(String modified) {
|
|
|
|
DateCriteria criteria = new DateCriteria();
|
|
|
|
criteria.setAs(modified);
|
|
|
|
this.modified = criteria;
|
|
|
|
}
|
|
|
|
|
2019-05-23 17:03:44 +02:00
|
|
|
public UserCriteria getCreator() {
|
|
|
|
return creator;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCreator(UserCriteria creator) {
|
|
|
|
this.creator = creator;
|
|
|
|
}
|
|
|
|
|
|
|
|
public DatasetCriteria getDataset() {
|
|
|
|
return dataset;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setDataset(DatasetCriteria dataset) {
|
|
|
|
this.dataset = dataset;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected List<String> buildFields(String path) {
|
2019-05-28 09:16:34 +02:00
|
|
|
Set<String> fields = new LinkedHashSet<>();
|
2019-05-23 17:03:44 +02:00
|
|
|
path = path != null && !path.isEmpty() ? path + "." : "";
|
|
|
|
if (this.id != null) fields.add(path + this.id.getAs());
|
2019-05-28 09:16:34 +02:00
|
|
|
if (this.label != null) fields.add(path + this.label.getAs());
|
2019-05-23 17:03:44 +02:00
|
|
|
if (this.project != null) fields.addAll(this.project.buildFields(path + "project"));
|
|
|
|
if (this.creator != null) fields.addAll(this.creator.buildFields(path + "creator"));
|
|
|
|
if (this.dataset != null) fields.addAll(this.dataset.buildFields(path + "dataset"));
|
|
|
|
if (!fields.contains(path + "id")) fields.add(path + "id");
|
|
|
|
return new LinkedList<>(fields);
|
|
|
|
}
|
|
|
|
|
|
|
|
public DMPQuery buildQuery(DatabaseRepository dao) {
|
|
|
|
List<String> fields = this.buildFields("");
|
|
|
|
DMPQuery dmpQuery = new DMPQuery(dao.getDmpDao(), fields);
|
|
|
|
if (this.id != null) dmpQuery.setId(this.id.getValue());
|
|
|
|
if (this.project != null) dmpQuery.setProjectQuery(this.project.buildQuery(dao));
|
|
|
|
if (this.creator != null) dmpQuery.setUserQuery(this.creator.buildQuery(dao));
|
|
|
|
if (this.dataset != null) dmpQuery.setDatasetQuery(this.dataset.buildQuery(dao));
|
2019-05-21 17:17:41 +02:00
|
|
|
return dmpQuery;
|
|
|
|
}
|
|
|
|
}
|