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-07-31 16:57:34 +02:00
|
|
|
import eu.eudat.query.GrantQuery;
|
2019-05-23 17:03:44 +02:00
|
|
|
import java.util.*;
|
2019-05-21 17:17:41 +02:00
|
|
|
|
2019-07-31 16:57:34 +02:00
|
|
|
public class GrantCriteria {
|
2019-05-21 17:17:41 +02:00
|
|
|
private Criteria<UUID> id;
|
|
|
|
private List<UUID> ids;
|
|
|
|
private Criteria<String> label;
|
|
|
|
private List<Integer> statuses;
|
|
|
|
private DateCriteria created;
|
|
|
|
private DateCriteria modified;
|
|
|
|
private UserCriteria creator;
|
|
|
|
|
|
|
|
public Criteria<UUID> getId() {
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2019-05-28 09:16:34 +02:00
|
|
|
public void setId(Criteria<UUID> id) {
|
|
|
|
this.id = id;
|
2019-05-21 17:17:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public List<UUID> getIds() {
|
|
|
|
return ids;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setIds(List<UUID> ids) {
|
|
|
|
this.ids = ids;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Criteria<String> getLabel() {
|
|
|
|
return label;
|
|
|
|
}
|
|
|
|
|
2019-05-28 09:16:34 +02:00
|
|
|
public void setLabel(Criteria<String> label) {
|
|
|
|
this.label = label;
|
2019-05-21 17:17:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setLabel(String label) {
|
|
|
|
Criteria<String> criteria = new Criteria<>();
|
|
|
|
criteria.setAs(label);
|
|
|
|
this.label = criteria;
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<Integer> getStatuses() {
|
|
|
|
return statuses;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setStatuses(List<Integer> statuses) {
|
|
|
|
this.statuses = statuses;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
public UserCriteria getCreator() {
|
|
|
|
return creator;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCreator(UserCriteria creator) {
|
|
|
|
this.creator = creator;
|
|
|
|
}
|
|
|
|
|
2019-05-23 17:03:44 +02:00
|
|
|
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());
|
|
|
|
if (this.label != null) fields.add(path + this.label.getAs());
|
|
|
|
if (!fields.contains(path + "id")) fields.add(path + "id");
|
2019-05-28 09:16:34 +02:00
|
|
|
if (this.creator != null) fields.addAll(this.creator.buildFields(path + "creationUser"));
|
2019-05-23 17:03:44 +02:00
|
|
|
return new LinkedList<>(fields);
|
|
|
|
}
|
|
|
|
|
2019-07-31 16:57:34 +02:00
|
|
|
public GrantQuery buildQuery(DatabaseRepository dao) {
|
2019-05-23 17:03:44 +02:00
|
|
|
List<String> fields = this.buildFields("");
|
2019-07-31 16:57:34 +02:00
|
|
|
GrantQuery query = new GrantQuery(dao.getGrantDao(), fields);
|
2019-05-21 17:17:41 +02:00
|
|
|
query.setId(this.id.getValue());
|
2019-05-23 17:03:44 +02:00
|
|
|
if (this.creator != null) query.setUserQuery(this.creator.buildQuery(dao));
|
2019-05-21 17:17:41 +02:00
|
|
|
return query;
|
|
|
|
}
|
|
|
|
}
|