using a proper displayLabel for the parent SepaMandate->Customer (HOWTO)
Unfortunately without a test for the HTML template changes of the Angular components because these seem to come only with Protractor, which we had not configured in JHipster.
This commit is contained in:
@ -11,6 +11,7 @@ import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
@ -22,11 +23,14 @@ public class SepaMandateService implements IdToDtoResolver<SepaMandateDTO> {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(SepaMandateService.class);
|
||||
|
||||
private final EntityManager em;
|
||||
|
||||
private final SepaMandateRepository sepaMandateRepository;
|
||||
|
||||
private final SepaMandateMapper sepaMandateMapper;
|
||||
|
||||
public SepaMandateService(SepaMandateRepository sepaMandateRepository, SepaMandateMapper sepaMandateMapper) {
|
||||
public SepaMandateService(final EntityManager em, final SepaMandateRepository sepaMandateRepository, final SepaMandateMapper sepaMandateMapper) {
|
||||
this.em = em;
|
||||
this.sepaMandateRepository = sepaMandateRepository;
|
||||
this.sepaMandateMapper = sepaMandateMapper;
|
||||
}
|
||||
@ -41,6 +45,8 @@ public class SepaMandateService implements IdToDtoResolver<SepaMandateDTO> {
|
||||
log.debug("Request to save SepaMandate : {}", sepaMandateDTO);
|
||||
SepaMandate sepaMandate = sepaMandateMapper.toEntity(sepaMandateDTO);
|
||||
sepaMandate = sepaMandateRepository.save(sepaMandate);
|
||||
em.flush();
|
||||
em.refresh(sepaMandate);
|
||||
return sepaMandateMapper.toDto(sepaMandate);
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ public class SepaMandateDTO implements AccessMappings, FluentBuilder<SepaMandate
|
||||
private Long customerId;
|
||||
|
||||
@AccessFor(update = Role.IGNORED, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
||||
private String customerPrefix;
|
||||
private String customerDisplayLabel;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
@ -149,12 +149,12 @@ public class SepaMandateDTO implements AccessMappings, FluentBuilder<SepaMandate
|
||||
this.customerId = customerId;
|
||||
}
|
||||
|
||||
public String getCustomerPrefix() {
|
||||
return customerPrefix;
|
||||
public String getCustomerDisplayLabel() {
|
||||
return customerDisplayLabel;
|
||||
}
|
||||
|
||||
public void setCustomerPrefix(String customerPrefix) {
|
||||
this.customerPrefix = customerPrefix;
|
||||
public void setCustomerDisplayLabel(String customerDisplayLabel) {
|
||||
this.customerDisplayLabel = customerDisplayLabel;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -192,7 +192,7 @@ public class SepaMandateDTO implements AccessMappings, FluentBuilder<SepaMandate
|
||||
", lastUsedDate='" + getLastUsedDate() + "'" +
|
||||
", remark='" + getRemark() + "'" +
|
||||
", customer=" + getCustomerId() +
|
||||
", customerPrefix='" + getCustomerPrefix() + "'" +
|
||||
", customerDisplayLabel='" + getCustomerDisplayLabel() + "'" +
|
||||
"}";
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
package org.hostsharing.hsadminng.service.mapper;
|
||||
|
||||
import org.hostsharing.hsadminng.domain.*;
|
||||
import org.hostsharing.hsadminng.domain.SepaMandate;
|
||||
import org.hostsharing.hsadminng.service.dto.SepaMandateDTO;
|
||||
|
||||
import org.mapstruct.*;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
|
||||
/**
|
||||
* Mapper for the entity SepaMandate and its DTO SepaMandateDTO.
|
||||
@ -12,9 +14,14 @@ import org.mapstruct.*;
|
||||
public interface SepaMandateMapper extends EntityMapper<SepaMandateDTO, SepaMandate> {
|
||||
|
||||
@Mapping(source = "customer.id", target = "customerId")
|
||||
@Mapping(source = "customer.prefix", target = "customerPrefix")
|
||||
@Mapping(target = "customerDisplayLabel", ignore = true)
|
||||
SepaMandateDTO toDto(SepaMandate sepaMandate);
|
||||
|
||||
@AfterMapping
|
||||
default void setDisplayLabels(final @MappingTarget SepaMandateDTO dto, final SepaMandate entity) {
|
||||
dto.setCustomerDisplayLabel(CustomerMapper.displayLabel(entity.getCustomer()));
|
||||
}
|
||||
|
||||
@Mapping(source = "customerId", target = "customer")
|
||||
SepaMandate toEntity(SepaMandateDTO sepaMandateDTO);
|
||||
|
||||
|
Reference in New Issue
Block a user