From da5b6676073b6ee418efbc00655da1dc15e540ec Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Fri, 26 Apr 2019 17:42:30 +0200 Subject: [PATCH] MembershipDTO JSonSerializerWithAccessFilter proper membershipDisplayReference --- .../hsadminng/service/dto/MembershipDTO.java | 36 ++++++++++++++++--- .../service/mapper/MembershipMapper.java | 22 ++++++++++-- .../asset/asset-update.component.html | 2 +- .../app/shared/model/membership.model.ts | 4 ++- 4 files changed, 55 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipDTO.java b/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipDTO.java index 2286a064..a705ba7c 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipDTO.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipDTO.java @@ -2,10 +2,9 @@ package org.hostsharing.hsadminng.service.dto; import org.hostsharing.hsadminng.service.CustomerService; import org.hostsharing.hsadminng.service.MembershipService; -import org.hostsharing.hsadminng.service.accessfilter.AccessFor; -import org.hostsharing.hsadminng.service.accessfilter.ParentId; -import org.hostsharing.hsadminng.service.accessfilter.Role; -import org.hostsharing.hsadminng.service.accessfilter.SelfId; +import org.hostsharing.hsadminng.service.accessfilter.*; +import org.springframework.boot.jackson.JsonComponent; +import org.springframework.context.ApplicationContext; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; @@ -16,7 +15,7 @@ import java.util.Objects; /** * A DTO for the Membership entity. */ -public class MembershipDTO extends FluentBuilder implements Serializable { +public class MembershipDTO extends FluentBuilder implements Serializable, AccessMappings { @SelfId(resolver = MembershipService.class) @AccessFor(read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}) @@ -47,6 +46,9 @@ public class MembershipDTO extends FluentBuilder implements Seria @AccessFor(init = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}) private String customerPrefix; + @AccessFor(read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}) + private String membershipDisplayReference; + public Long getId() { return id; } @@ -111,6 +113,14 @@ public class MembershipDTO extends FluentBuilder implements Seria this.customerPrefix = customerPrefix; } + private String getMembershipDisplayReference() { + return membershipDisplayReference; + } + + public void setMembershipDisplayReference(final String membershipDisplayReference) { + this.membershipDisplayReference = membershipDisplayReference; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -145,4 +155,20 @@ public class MembershipDTO extends FluentBuilder implements Seria ", customer='" + getCustomerPrefix() + "'" + "}"; } + + @JsonComponent + public static class MembershipJsonSerializer extends JsonSerializerWithAccessFilter { + + public MembershipJsonSerializer(final ApplicationContext ctx) { + super(ctx); + } + } + + @JsonComponent + public static class MembershipJsonDeserializer extends JsonDeserializerWithAccessFilter { + + public MembershipJsonDeserializer(final ApplicationContext ctx) { + super(ctx); + } + } } diff --git a/src/main/java/org/hostsharing/hsadminng/service/mapper/MembershipMapper.java b/src/main/java/org/hostsharing/hsadminng/service/mapper/MembershipMapper.java index 02a45ace..ed779cbe 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/mapper/MembershipMapper.java +++ b/src/main/java/org/hostsharing/hsadminng/service/mapper/MembershipMapper.java @@ -1,9 +1,14 @@ package org.hostsharing.hsadminng.service.mapper; -import org.hostsharing.hsadminng.domain.*; +import org.hostsharing.hsadminng.domain.Customer; +import org.hostsharing.hsadminng.domain.Membership; import org.hostsharing.hsadminng.service.dto.MembershipDTO; +import org.mapstruct.AfterMapping; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.MappingTarget; -import org.mapstruct.*; +import java.util.Objects; /** * Mapper for the entity Membership and its DTO MembershipDTO. @@ -13,8 +18,21 @@ public interface MembershipMapper extends EntityMapperMembership
diff --git a/src/main/webapp/app/shared/model/membership.model.ts b/src/main/webapp/app/shared/model/membership.model.ts index 27bc7e7a..ffdca230 100644 --- a/src/main/webapp/app/shared/model/membership.model.ts +++ b/src/main/webapp/app/shared/model/membership.model.ts @@ -13,6 +13,7 @@ export interface IMembership { assets?: IAsset[]; customerPrefix?: string; customerId?: number; + membershipDisplayReference?: string; } export class Membership implements IMembership { @@ -26,6 +27,7 @@ export class Membership implements IMembership { public shares?: IShare[], public assets?: IAsset[], public customerPrefix?: string, - public customerId?: number + public customerId?: number, + public membershipDisplayReference?: string ) {} }