Merge branch 'dmp-refactoring' of code-repo.d4science.org:MaDgiK-CITE/argos into dmp-refactoring
# Conflicts: # dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpBuilder.java
This commit is contained in:
commit
e81e6dd89a
|
@ -82,14 +82,14 @@ public class Dmp {
|
||||||
|
|
||||||
public static final String _hash = "hash";
|
public static final String _hash = "hash";
|
||||||
|
|
||||||
private List<Description> dmpDescriptions;
|
|
||||||
|
|
||||||
public static final String _dmpDescriptions = "dmpDescriptions";
|
|
||||||
|
|
||||||
private List<DmpReference> dmpReferences;
|
private List<DmpReference> dmpReferences;
|
||||||
|
|
||||||
public static final String _dmpReferences = "dmpReferences";
|
public static final String _dmpReferences = "dmpReferences";
|
||||||
|
|
||||||
|
private List<DmpUser> dmpUsers;
|
||||||
|
|
||||||
|
public static final String _dmpUsers = "dmoUsers";
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -234,14 +234,6 @@ public class Dmp {
|
||||||
this.hash = hash;
|
this.hash = hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Description> getDmpDescriptions() {
|
|
||||||
return dmpDescriptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDmpDescriptions(List<Description> dmpDescriptions) {
|
|
||||||
this.dmpDescriptions = dmpDescriptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<DmpReference> getDmpReferences() {
|
public List<DmpReference> getDmpReferences() {
|
||||||
return dmpReferences;
|
return dmpReferences;
|
||||||
}
|
}
|
||||||
|
@ -249,4 +241,13 @@ public class Dmp {
|
||||||
public void setDmpReferences(List<DmpReference> dmpReferences) {
|
public void setDmpReferences(List<DmpReference> dmpReferences) {
|
||||||
this.dmpReferences = dmpReferences;
|
this.dmpReferences = dmpReferences;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<DmpUser> getDmpUsers() {
|
||||||
|
return dmpUsers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDmpUsers(List<DmpUser> dmpUsers) {
|
||||||
|
this.dmpUsers = dmpUsers;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.model.*;
|
import eu.eudat.model.*;
|
||||||
import eu.eudat.query.DescriptionQuery;
|
import eu.eudat.query.DescriptionQuery;
|
||||||
import eu.eudat.query.DmpReferenceQuery;
|
import eu.eudat.query.DmpReferenceQuery;
|
||||||
|
import eu.eudat.query.DmpUserQuery;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
import gr.cite.tools.data.query.QueryFactory;
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
@ -56,7 +57,10 @@ public class DmpBuilder extends BaseBuilder<Dmp, DmpEntity> {
|
||||||
List<Dmp> models = new ArrayList<>();
|
List<Dmp> models = new ArrayList<>();
|
||||||
|
|
||||||
FieldSet dmpReferencesFields = fields.extractPrefixed(this.asPrefix(Dmp._dmpReferences));
|
FieldSet dmpReferencesFields = fields.extractPrefixed(this.asPrefix(Dmp._dmpReferences));
|
||||||
Map<UUID, List<DmpReference>> dmpReferenceMap = this.collectDmpReferences(dmpReferencesFields, data);
|
Map<UUID, List<DmpReference>> dmpReferencesMap = this.collectDmpReferences(dmpReferencesFields, data);
|
||||||
|
|
||||||
|
FieldSet dmpUsersFields = fields.extractPrefixed(this.asPrefix(Dmp._dmpUsers));
|
||||||
|
Map<UUID, List<DmpUser>> dmpUsersMap = this.collectDmpUsers(dmpUsersFields, data);
|
||||||
|
|
||||||
for (DmpEntity d : data) {
|
for (DmpEntity d : data) {
|
||||||
Dmp m = new Dmp();
|
Dmp m = new Dmp();
|
||||||
|
@ -93,8 +97,11 @@ public class DmpBuilder extends BaseBuilder<Dmp, DmpEntity> {
|
||||||
if (fields.hasField(this.asIndexer(Dmp._hash)))
|
if (fields.hasField(this.asIndexer(Dmp._hash)))
|
||||||
m.setHash(this.hashValue(d.getUpdatedAt()));
|
m.setHash(this.hashValue(d.getUpdatedAt()));
|
||||||
|
|
||||||
if (dmpReferenceMap != null && !dmpReferenceMap.isEmpty() && dmpReferenceMap.containsKey(d.getId()))
|
if (dmpReferencesMap != null && !dmpReferencesMap.isEmpty() && dmpReferencesMap.containsKey(d.getId()))
|
||||||
m.setDmpReferences(dmpReferenceMap.get(d.getId()));
|
m.setDmpReferences(dmpReferencesMap.get(d.getId()));
|
||||||
|
|
||||||
|
if (dmpUsersMap != null && !dmpUsersMap.isEmpty() && dmpUsersMap.containsKey(d.getId()))
|
||||||
|
m.setDmpUsers(dmpUsersMap.get(d.getId()));
|
||||||
|
|
||||||
models.add(m);
|
models.add(m);
|
||||||
}
|
}
|
||||||
|
@ -103,14 +110,14 @@ public class DmpBuilder extends BaseBuilder<Dmp, DmpEntity> {
|
||||||
return models;
|
return models;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<UUID, List<DmpReference>> collectDmpReferences(FieldSet fields, List<DmpEntity> datas) throws MyApplicationException {
|
private Map<UUID, List<DmpReference>> collectDmpReferences(FieldSet fields, List<DmpEntity> data) throws MyApplicationException {
|
||||||
if (fields.isEmpty() || datas.isEmpty()) return null;
|
if (fields.isEmpty() || data.isEmpty()) return null;
|
||||||
this.logger.debug("checking related - {}", DmpReference.class.getSimpleName());
|
this.logger.debug("checking related - {}", DmpReference.class.getSimpleName());
|
||||||
|
|
||||||
Map<UUID, List<DmpReference>> itemMap = null;
|
Map<UUID, List<DmpReference>> itemMap;
|
||||||
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(DmpReference._dmp, Dmp._id));
|
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(DmpReference._dmp, Dmp._id));
|
||||||
DmpReferenceQuery query = this.queryFactory.query(DmpReferenceQuery.class).authorize(this.authorize).dmpIds(datas.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList()));
|
DmpReferenceQuery query = this.queryFactory.query(DmpReferenceQuery.class).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList()));
|
||||||
itemMap = this.builderFactory.builder(DmpReferenceBuilder.class).authorize(this.authorize).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId());
|
itemMap = this.builderFactory.builder(DmpReferenceBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId());
|
||||||
|
|
||||||
if (!fields.hasField(this.asIndexer(DmpReference._dmp, Dmp._id))) {
|
if (!fields.hasField(this.asIndexer(DmpReference._dmp, Dmp._id))) {
|
||||||
itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getDmp() != null).peek(x -> {
|
itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getDmp() != null).peek(x -> {
|
||||||
|
@ -121,4 +128,23 @@ public class DmpBuilder extends BaseBuilder<Dmp, DmpEntity> {
|
||||||
return itemMap;
|
return itemMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<UUID, List<DmpUser>> collectDmpUsers(FieldSet fields, List<DmpEntity> data) throws MyApplicationException {
|
||||||
|
if (fields.isEmpty() || data.isEmpty())
|
||||||
|
return null;
|
||||||
|
this.logger.debug("checking related - {}", DmpUser.class.getSimpleName());
|
||||||
|
|
||||||
|
Map<UUID, List<DmpUser>> itemMap;
|
||||||
|
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(DmpUser._dmp, Dmp._id));
|
||||||
|
DmpUserQuery query = this.queryFactory.query(DmpUserQuery.class).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList()));
|
||||||
|
itemMap = this.builderFactory.builder(DmpUserBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId());
|
||||||
|
|
||||||
|
if (!fields.hasField(this.asIndexer(DmpUser._dmp, Dmp._id))) {
|
||||||
|
itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getDmp() != null).peek(x -> {
|
||||||
|
x.getDmp().setId(null);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return itemMap;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,6 @@ public class DmpCensor extends BaseCensor {
|
||||||
|
|
||||||
this.authService.authorizeForce(Permission.BrowseDmp);
|
this.authService.authorizeForce(Permission.BrowseDmp);
|
||||||
|
|
||||||
FieldSet dmpDescriptionsFields = fields.extractPrefixed(this.asIndexerPrefix(Dmp._dmpDescriptions));
|
|
||||||
this.censorFactory.censor(DescriptionCensor.class).censor(dmpDescriptionsFields, userId);
|
|
||||||
FieldSet dmpReferencesFields = fields.extractPrefixed(this.asIndexerPrefix(Dmp._dmpReferences));
|
FieldSet dmpReferencesFields = fields.extractPrefixed(this.asIndexerPrefix(Dmp._dmpReferences));
|
||||||
this.censorFactory.censor(DmpReferenceCensor.class).censor(dmpReferencesFields, userId);
|
this.censorFactory.censor(DmpReferenceCensor.class).censor(dmpReferencesFields, userId);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue