Revert "MembershipDTO JSonSerializerWithAccessFilter proper membershipDisplayReference"

This reverts commit da5b667607.
This commit is contained in:
Michael Hoennig 2019-04-27 06:37:30 +02:00
parent 638a35ea5a
commit 51ff0c4990
4 changed files with 9 additions and 55 deletions

View File

@ -2,9 +2,10 @@ package org.hostsharing.hsadminng.service.dto;
import org.hostsharing.hsadminng.service.CustomerService;
import org.hostsharing.hsadminng.service.MembershipService;
import org.hostsharing.hsadminng.service.accessfilter.*;
import org.springframework.boot.jackson.JsonComponent;
import org.springframework.context.ApplicationContext;
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 javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
@ -15,7 +16,7 @@ import java.util.Objects;
/**
* A DTO for the Membership entity.
*/
public class MembershipDTO extends FluentBuilder<MembershipDTO> implements Serializable, AccessMappings {
public class MembershipDTO extends FluentBuilder<MembershipDTO> implements Serializable {
@SelfId(resolver = MembershipService.class)
@AccessFor(read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
@ -46,9 +47,6 @@ public class MembershipDTO extends FluentBuilder<MembershipDTO> 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;
}
@ -113,14 +111,6 @@ public class MembershipDTO extends FluentBuilder<MembershipDTO> 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) {
@ -155,20 +145,4 @@ public class MembershipDTO extends FluentBuilder<MembershipDTO> implements Seria
", customer='" + getCustomerPrefix() + "'" +
"}";
}
@JsonComponent
public static class MembershipJsonSerializer extends JsonSerializerWithAccessFilter<MembershipDTO> {
public MembershipJsonSerializer(final ApplicationContext ctx) {
super(ctx);
}
}
@JsonComponent
public static class MembershipJsonDeserializer extends JsonDeserializerWithAccessFilter<MembershipDTO> {
public MembershipJsonDeserializer(final ApplicationContext ctx) {
super(ctx);
}
}
}

View File

@ -1,14 +1,9 @@
package org.hostsharing.hsadminng.service.mapper;
import org.hostsharing.hsadminng.domain.Customer;
import org.hostsharing.hsadminng.domain.Membership;
import org.hostsharing.hsadminng.domain.*;
import org.hostsharing.hsadminng.service.dto.MembershipDTO;
import org.mapstruct.AfterMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import java.util.Objects;
import org.mapstruct.*;
/**
* Mapper for the entity Membership and its DTO MembershipDTO.
@ -18,21 +13,8 @@ public interface MembershipMapper extends EntityMapper<MembershipDTO, Membership
@Mapping(source = "customer.id", target = "customerId")
@Mapping(source = "customer.prefix", target = "customerPrefix")
@Mapping(target = "membershipDisplayReference", ignore = true)
MembershipDTO toDto(Membership membership);
// TODO BLOG HOWTO: multi-field display reference for selection lists
// also change the filed in the option list in *-update.html
@AfterMapping
default void setMembershipDisplayReference(final @MappingTarget MembershipDTO dto, final Membership entity) {
final Customer customer = entity.getCustomer();
dto.setMembershipDisplayReference(customer.getReference()
+ ":" + customer.getPrefix()
+ " [" + customer.getName() + "] "
+ entity.getAdmissionDocumentDate().toString() + " - "
+ Objects.toString(entity.getCancellationDocumentDate(), ""));
}
@Mapping(target = "shares", ignore = true)
@Mapping(target = "assets", ignore = true)
@Mapping(source = "customerId", target = "customer")

View File

@ -89,7 +89,7 @@
<label class="form-control-label" jhiTranslate="hsadminNgApp.asset.membership" for="field_membership">Membership</label>
<select class="form-control" id="field_membership" name="membership" [(ngModel)]="asset.membershipId" required>
<option *ngIf="!editForm.value.membership" [ngValue]="null" selected></option>
<option [ngValue]="membershipOption.id" *ngFor="let membershipOption of memberships; trackBy: trackMembershipById">{{membershipOption.membershipDisplayReference}}</option>
<option [ngValue]="membershipOption.id" *ngFor="let membershipOption of memberships; trackBy: trackMembershipById">{{membershipOption.admissionDocumentDate}}</option>
</select>
</div>
<div [hidden]="!(editForm.controls.membership?.dirty && editForm.controls.membership?.invalid)">

View File

@ -13,7 +13,6 @@ export interface IMembership {
assets?: IAsset[];
customerPrefix?: string;
customerId?: number;
membershipDisplayReference?: string;
}
export class Membership implements IMembership {
@ -27,7 +26,6 @@ export class Membership implements IMembership {
public shares?: IShare[],
public assets?: IAsset[],
public customerPrefix?: string,
public customerId?: number,
public membershipDisplayReference?: string
public customerId?: number
) {}
}