diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/DmpAssociatedUserBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/DmpAssociatedUserBuilder.java index 836ad27c7..0a52542eb 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/DmpAssociatedUserBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/DmpAssociatedUserBuilder.java @@ -87,7 +87,7 @@ public class DmpAssociatedUserBuilder extends BaseBuilder x.getUser().getId()); if (!fields.hasField(this.asIndexer(UserContactInfo._user, User._id))) { - itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getUser() != null).peek(x -> { + itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getUser() != null).forEach(x -> { x.getUser().setId(null); }); } diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/DmpDescriptionTemplateBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/DmpDescriptionTemplateBuilder.java index dcf9d1b86..2ab87c434 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/DmpDescriptionTemplateBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/DmpDescriptionTemplateBuilder.java @@ -113,7 +113,7 @@ public class DmpDescriptionTemplateBuilder extends BaseBuilder x.setId(null)).collect(Collectors.toList()); + itemMap.values().stream().filter(Objects::nonNull).forEach(x -> x.setId(null)); } return itemMap; @@ -130,7 +130,7 @@ public class DmpDescriptionTemplateBuilder extends BaseBuilder x != null && x.getGroupId() != null).peek(x -> { + itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getGroupId() != null).forEach(x -> { x.setGroupId(null); }); } @@ -159,7 +159,7 @@ public class DmpDescriptionTemplateBuilder extends BaseBuilder x.setGroupId(null)).collect(Collectors.toList()); + itemMap.values().stream().filter(Objects::nonNull).forEach(x -> x.setGroupId(null)); } return itemMap; diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/DmpUserBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/DmpUserBuilder.java index 382d12510..e42e631a2 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/DmpUserBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/DmpUserBuilder.java @@ -136,7 +136,7 @@ public class DmpUserBuilder extends BaseBuilder{ itemMap = this.builderFactory.builder(DmpBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Dmp::getId); } if (!fields.hasField(Dmp._id)) { - itemMap.values().stream().filter(Objects::nonNull).peek(x -> x.setId(null)).collect(Collectors.toList()); + itemMap.values().stream().filter(Objects::nonNull).forEach(x -> x.setId(null)); } return itemMap; diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpBuilder.java index 1190118c4..7ad8a3586 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpBuilder.java @@ -107,7 +107,7 @@ public class PublicDmpBuilder extends BaseBuilder { itemMap = this.builderFactory.builder(PublicDmpReferenceBuilder.class).authorize(this.authorize).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId()); if (!fields.hasField(this.asIndexer(PublicDmpReference._dmp, PublicDmp._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).forEach(x -> { x.getDmp().setId(null); }); } @@ -125,7 +125,7 @@ public class PublicDmpBuilder extends BaseBuilder { itemMap = this.builderFactory.builder(PublicDmpUserBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId()); if (!fields.hasField(this.asIndexer(PublicDmpUser._dmp, PublicDmp._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).forEach(x -> { x.getDmp().setId(null); }); } @@ -143,7 +143,7 @@ public class PublicDmpBuilder extends BaseBuilder { itemMap = this.builderFactory.builder(PublicDescriptionBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId()); if (!fields.hasField(this.asIndexer(PublicDescription._dmp, PublicDescription._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).forEach(x -> { x.getDmp().setId(null); }); } @@ -161,7 +161,7 @@ public class PublicDmpBuilder extends BaseBuilder { itemMap = this.builderFactory.builder(PublicEntityDoiBuilder.class).authorize(this.authorize).asMasterKey(query, clone, PublicEntityDoi::getEntityId); if (!fields.hasField(this.asIndexer(PublicEntityDoi._entityId))) { - itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getEntityId() != null).peek(x -> { + itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getEntityId() != null).forEach(x -> { x.setEntityId(null); }); } @@ -176,10 +176,10 @@ public class PublicDmpBuilder extends BaseBuilder { Map> itemMap; FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(PublicDmp._id); DmpQuery query = this.queryFactory.query(DmpQuery.class).disableTracking().authorize(this.authorize).groupIds(data.stream().map(DmpEntity::getGroupId).distinct().collect(Collectors.toList())).isActive(IsActive.Active); - itemMap = this.builderFactory.builder(PublicDmpBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getGroupId()); + itemMap = this.builderFactory.builder(PublicDmpBuilder.class).authorize(this.authorize).asMasterKey(query, clone, PublicDmp::getGroupId); if (!fields.hasField(this.asIndexer(PublicDmp._otherDmpVersions, PublicDmp._id))) { - itemMap.values().stream().flatMap(List::stream).filter(x -> x != null).peek(x -> { + itemMap.values().stream().flatMap(List::stream).filter(Objects::nonNull).forEach(x -> { x.setId(null); }); } diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpDescriptionTemplateBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpDescriptionTemplateBuilder.java index 234dab424..aa80d5907 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpDescriptionTemplateBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpDescriptionTemplateBuilder.java @@ -89,7 +89,7 @@ public class PublicDmpDescriptionTemplateBuilder extends BaseBuilder x.setId(null)).collect(Collectors.toList()); + itemMap.values().stream().filter(Objects::nonNull).forEach(x -> x.setId(null)); } return itemMap; diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpReferenceBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpReferenceBuilder.java index 3489b74bf..82069be30 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpReferenceBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpReferenceBuilder.java @@ -96,7 +96,7 @@ public class PublicDmpReferenceBuilder extends BaseBuilder x.setId(null)).collect(Collectors.toList()); + itemMap.values().stream().filter(Objects::nonNull).forEach(x -> x.setId(null)); } return itemMap; @@ -123,7 +123,7 @@ public class PublicDmpReferenceBuilder extends BaseBuilder x.setId(null)).collect(Collectors.toList()); + itemMap.values().stream().filter(Objects::nonNull).forEach(x -> x.setId(null)); } return itemMap; diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpUserBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpUserBuilder.java index 31d3f6591..336d4bc0f 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpUserBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/PublicDmpUserBuilder.java @@ -126,7 +126,7 @@ public class PublicDmpUserBuilder extends BaseBuilder x.setId(null)).collect(Collectors.toList()); + itemMap.values().stream().filter(Objects::nonNull).forEach(x -> x.setId(null)); } return itemMap; diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/PublicReferenceBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/PublicReferenceBuilder.java index d4b7c9f51..9c40c0383 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/PublicReferenceBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/PublicReferenceBuilder.java @@ -92,7 +92,7 @@ public class PublicReferenceBuilder extends BaseBuilder x.setId(null)).collect(Collectors.toList()); + itemMap.values().stream().filter(Objects::nonNull).forEach(x -> x.setId(null)); } return itemMap; diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/RecentActivityItemBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/RecentActivityItemBuilder.java index f5ad7888f..b63f009f5 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/RecentActivityItemBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/RecentActivityItemBuilder.java @@ -98,7 +98,7 @@ public class RecentActivityItemBuilder extends BaseBuilder x.setId(null)).collect(Collectors.toList()); + itemMap.values().stream().filter(Objects::nonNull).forEach(x -> x.setId(null)); } return itemMap; @@ -125,7 +125,7 @@ public class RecentActivityItemBuilder extends BaseBuilder x.setId(null)).collect(Collectors.toList()); + itemMap.values().stream().filter(Objects::nonNull).forEach(x -> x.setId(null)); } return itemMap; diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/UserBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/UserBuilder.java index 739b5d858..1235da346 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/UserBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/UserBuilder.java @@ -14,7 +14,6 @@ import org.opencdmp.commons.JsonHandlingService; import org.opencdmp.commons.scope.tenant.TenantScope; import org.opencdmp.commons.types.user.AdditionalInfoEntity; import org.opencdmp.convention.ConventionService; -import org.opencdmp.data.TenantEntityManager; import org.opencdmp.data.UserEntity; import org.opencdmp.model.TenantUser; import org.opencdmp.model.UserContactInfo; @@ -29,7 +28,6 @@ import org.opencdmp.query.UserRoleQuery; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; -import org.springframework.context.MessageSource; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -46,25 +44,21 @@ public class UserBuilder extends BaseBuilder { private final BuilderFactory builderFactory; private final JsonHandlingService jsonHandlingService; private final AuthorizationProperties authorizationProperties; - private final TenantEntityManager tenantEntityManager; private final TenantScope tenantScope; - private final MessageSource messageSource; private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); @Autowired public UserBuilder(ConventionService conventionService, QueryFactory queryFactory, - BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, AuthorizationProperties authorizationProperties, TenantEntityManager tenantEntityManager, TenantScope tenantScope, MessageSource messageSource) { + BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, AuthorizationProperties authorizationProperties, TenantScope tenantScope) { super(conventionService, new LoggerService(LoggerFactory.getLogger(UserBuilder.class))); this.queryFactory = queryFactory; this.builderFactory = builderFactory; this.jsonHandlingService = jsonHandlingService; this.authorizationProperties = authorizationProperties; - this.tenantEntityManager = tenantEntityManager; this.tenantScope = tenantScope; - this.messageSource = messageSource; } public UserBuilder authorize(EnumSet values) { @@ -131,7 +125,7 @@ public class UserBuilder extends BaseBuilder { itemMap = this.builderFactory.builder(UserContactInfoBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getUser().getId()); if (!fields.hasField(this.asIndexer(UserContactInfo._user, User._id))) { - itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getUser() != null).peek(x -> { + itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getUser() != null).forEach(x -> { x.getUser().setId(null); }); } @@ -149,7 +143,7 @@ public class UserBuilder extends BaseBuilder { itemMap = this.builderFactory.builder(UserRoleBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getUser().getId()); if (!fields.hasField(this.asIndexer(UserRole._user, User._id))) { - itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getUser() != null).peek(x -> { + itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getUser() != null).forEach(x -> { x.getUser().setId(null); }); } @@ -178,7 +172,7 @@ public class UserBuilder extends BaseBuilder { itemMap = this.builderFactory.builder(UserRoleBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getUser().getId()); if (!fields.hasField(this.asIndexer(UserRole._user, User._id))) { - itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getUser() != null).peek(x -> { + itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getUser() != null).forEach(x -> { x.getUser().setId(null); }); } @@ -196,7 +190,7 @@ public class UserBuilder extends BaseBuilder { itemMap = this.builderFactory.builder(UserCredentialBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getUser().getId()); if (!fields.hasField(this.asIndexer(UserCredential._user, User._id))) { - itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getUser() != null).peek(x -> { + itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getUser() != null).forEach(x -> { x.getUser().setId(null); }); } @@ -214,10 +208,9 @@ public class UserBuilder extends BaseBuilder { itemMap = this.builderFactory.builder(TenantUserBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getUser().getId()); if (!fields.hasField(this.asIndexer(TenantUser._user, User._id))) { - itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getUser() != null).map(x -> { + itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getUser() != null).forEach(x -> { x.getUser().setId(null); - return x; - }).collect(Collectors.toList()); + }); } return itemMap; } diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/description/DescriptionBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/description/DescriptionBuilder.java index 49dde4db7..c2d964b4b 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/description/DescriptionBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/description/DescriptionBuilder.java @@ -288,7 +288,7 @@ public class DescriptionBuilder extends BaseBuilder x.getDescription().getId()); if (!fields.hasField(this.asIndexer(DescriptionReference._description, Description._id))) { - itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getDescription() != null).peek(x -> { + itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getDescription() != null).forEach(x -> { x.getDescription().setId(null); }); } @@ -306,7 +306,7 @@ public class DescriptionBuilder extends BaseBuilder x.getDescription().getId()); if (!fields.hasField(this.asIndexer(DescriptionTag._description, Description._id))) { - itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getDescription() != null).peek(x -> { + itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getDescription() != null).forEach(x -> { x.getDescription().setId(null); }); } diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/dmp/DmpBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/dmp/DmpBuilder.java index 0c594f941..621ee47c4 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/dmp/DmpBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/dmp/DmpBuilder.java @@ -160,7 +160,7 @@ public class DmpBuilder extends BaseBuilder { 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))) { - 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).forEach(x -> { x.getDmp().setId(null); }); } @@ -178,7 +178,7 @@ public class DmpBuilder extends BaseBuilder { itemMap = this.builderFactory.builder(EntityDoiBuilder.class).authorize(this.authorize).asMasterKey(query, clone, EntityDoi::getEntityId); if (!fields.hasField(this.asIndexer(EntityDoi._entityId))) { - itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getEntityId() != null).peek(x -> { + itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getEntityId() != null).forEach(x -> { x.setEntityId(null); }); } @@ -257,7 +257,7 @@ public class DmpBuilder extends BaseBuilder { 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 -> { + itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getDmp() != null).forEach(x -> { x.getDmp().setId(null); }); } @@ -275,7 +275,7 @@ public class DmpBuilder extends BaseBuilder { itemMap = this.builderFactory.builder(DescriptionBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId()); if (!fields.hasField(this.asIndexer(Description._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).forEach(x -> { x.getDmp().setId(null); }); } @@ -293,7 +293,7 @@ public class DmpBuilder extends BaseBuilder { itemMap = this.builderFactory.builder(DmpDescriptionTemplateBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId()); if (!fields.hasField(this.asIndexer(DmpDescriptionTemplate._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).forEach(x -> { x.getDmp().setId(null); }); } @@ -308,10 +308,10 @@ public class DmpBuilder extends BaseBuilder { Map> itemMap; FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Dmp._id); DmpQuery query = this.queryFactory.query(DmpQuery.class).disableTracking().authorize(this.authorize).groupIds(data.stream().map(DmpEntity::getGroupId).distinct().collect(Collectors.toList())); - itemMap = this.builderFactory.builder(DmpBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getGroupId()); + itemMap = this.builderFactory.builder(DmpBuilder.class).authorize(this.authorize).asMasterKey(query, clone, Dmp::getGroupId); if (!fields.hasField(this.asIndexer(Dmp._otherDmpVersions, Dmp._id))) { - itemMap.values().stream().flatMap(List::stream).filter(x -> x != null).peek(x -> { + itemMap.values().stream().flatMap(List::stream).filter(Objects::nonNull).forEach(x -> { x.setId(null); }); } diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/dmpreference/DmpReferenceBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/dmpreference/DmpReferenceBuilder.java index f44571662..50694a364 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/dmpreference/DmpReferenceBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/dmpreference/DmpReferenceBuilder.java @@ -114,7 +114,7 @@ public class DmpReferenceBuilder extends BaseBuilder x.setId(null)).collect(Collectors.toList()); + itemMap.values().stream().filter(Objects::nonNull).forEach(x -> x.setId(null)); } return itemMap; @@ -141,7 +141,7 @@ public class DmpReferenceBuilder extends BaseBuilder x.setId(null)).collect(Collectors.toList()); + itemMap.values().stream().filter(Objects::nonNull).forEach(x -> x.setId(null)); } return itemMap;