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:
parent
2980103764
commit
087e6617d3
@ -11,6 +11,7 @@ import org.springframework.data.domain.Pageable;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -22,11 +23,14 @@ public class SepaMandateService implements IdToDtoResolver<SepaMandateDTO> {
|
|||||||
|
|
||||||
private final Logger log = LoggerFactory.getLogger(SepaMandateService.class);
|
private final Logger log = LoggerFactory.getLogger(SepaMandateService.class);
|
||||||
|
|
||||||
|
private final EntityManager em;
|
||||||
|
|
||||||
private final SepaMandateRepository sepaMandateRepository;
|
private final SepaMandateRepository sepaMandateRepository;
|
||||||
|
|
||||||
private final SepaMandateMapper sepaMandateMapper;
|
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.sepaMandateRepository = sepaMandateRepository;
|
||||||
this.sepaMandateMapper = sepaMandateMapper;
|
this.sepaMandateMapper = sepaMandateMapper;
|
||||||
}
|
}
|
||||||
@ -41,6 +45,8 @@ public class SepaMandateService implements IdToDtoResolver<SepaMandateDTO> {
|
|||||||
log.debug("Request to save SepaMandate : {}", sepaMandateDTO);
|
log.debug("Request to save SepaMandate : {}", sepaMandateDTO);
|
||||||
SepaMandate sepaMandate = sepaMandateMapper.toEntity(sepaMandateDTO);
|
SepaMandate sepaMandate = sepaMandateMapper.toEntity(sepaMandateDTO);
|
||||||
sepaMandate = sepaMandateRepository.save(sepaMandate);
|
sepaMandate = sepaMandateRepository.save(sepaMandate);
|
||||||
|
em.flush();
|
||||||
|
em.refresh(sepaMandate);
|
||||||
return sepaMandateMapper.toDto(sepaMandate);
|
return sepaMandateMapper.toDto(sepaMandate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ public class SepaMandateDTO implements AccessMappings, FluentBuilder<SepaMandate
|
|||||||
private Long customerId;
|
private Long customerId;
|
||||||
|
|
||||||
@AccessFor(update = Role.IGNORED, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(update = Role.IGNORED, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
||||||
private String customerPrefix;
|
private String customerDisplayLabel;
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
@ -149,12 +149,12 @@ public class SepaMandateDTO implements AccessMappings, FluentBuilder<SepaMandate
|
|||||||
this.customerId = customerId;
|
this.customerId = customerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCustomerPrefix() {
|
public String getCustomerDisplayLabel() {
|
||||||
return customerPrefix;
|
return customerDisplayLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCustomerPrefix(String customerPrefix) {
|
public void setCustomerDisplayLabel(String customerDisplayLabel) {
|
||||||
this.customerPrefix = customerPrefix;
|
this.customerDisplayLabel = customerDisplayLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -192,7 +192,7 @@ public class SepaMandateDTO implements AccessMappings, FluentBuilder<SepaMandate
|
|||||||
", lastUsedDate='" + getLastUsedDate() + "'" +
|
", lastUsedDate='" + getLastUsedDate() + "'" +
|
||||||
", remark='" + getRemark() + "'" +
|
", remark='" + getRemark() + "'" +
|
||||||
", customer=" + getCustomerId() +
|
", customer=" + getCustomerId() +
|
||||||
", customerPrefix='" + getCustomerPrefix() + "'" +
|
", customerDisplayLabel='" + getCustomerDisplayLabel() + "'" +
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package org.hostsharing.hsadminng.service.mapper;
|
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.hostsharing.hsadminng.service.dto.SepaMandateDTO;
|
||||||
|
import org.mapstruct.AfterMapping;
|
||||||
import org.mapstruct.*;
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.Mapping;
|
||||||
|
import org.mapstruct.MappingTarget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mapper for the entity SepaMandate and its DTO SepaMandateDTO.
|
* Mapper for the entity SepaMandate and its DTO SepaMandateDTO.
|
||||||
@ -12,9 +14,14 @@ import org.mapstruct.*;
|
|||||||
public interface SepaMandateMapper extends EntityMapper<SepaMandateDTO, SepaMandate> {
|
public interface SepaMandateMapper extends EntityMapper<SepaMandateDTO, SepaMandate> {
|
||||||
|
|
||||||
@Mapping(source = "customer.id", target = "customerId")
|
@Mapping(source = "customer.id", target = "customerId")
|
||||||
@Mapping(source = "customer.prefix", target = "customerPrefix")
|
@Mapping(target = "customerDisplayLabel", ignore = true)
|
||||||
SepaMandateDTO toDto(SepaMandate sepaMandate);
|
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")
|
@Mapping(source = "customerId", target = "customer")
|
||||||
SepaMandate toEntity(SepaMandateDTO sepaMandateDTO);
|
SepaMandate toEntity(SepaMandateDTO sepaMandateDTO);
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
<dd>
|
<dd>
|
||||||
<span>{{sepaMandate.lastUsedDate}}</span>
|
<span>{{sepaMandate.lastUsedDate}}</span>
|
||||||
</dd>
|
</dd>
|
||||||
|
</dd>
|
||||||
<dt><span jhiTranslate="hsadminNgApp.sepaMandate.remark">Remark</span></dt>
|
<dt><span jhiTranslate="hsadminNgApp.sepaMandate.remark">Remark</span></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<span>{{sepaMandate.remark}}</span>
|
<span>{{sepaMandate.remark}}</span>
|
||||||
@ -44,7 +45,7 @@
|
|||||||
<dt><span jhiTranslate="hsadminNgApp.sepaMandate.customer">Customer</span></dt>
|
<dt><span jhiTranslate="hsadminNgApp.sepaMandate.customer">Customer</span></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<div *ngIf="sepaMandate.customerId">
|
<div *ngIf="sepaMandate.customerId">
|
||||||
<a [routerLink]="['/customer', sepaMandate.customerId, 'view']">{{sepaMandate.customerPrefix}}</a>
|
<a [routerLink]="['/customer', sepaMandate.customerId, 'view']">{{sepaMandate.customerDisplayLabel}}</a>
|
||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
@ -124,7 +124,7 @@
|
|||||||
<label class="form-control-label" jhiTranslate="hsadminNgApp.sepaMandate.customer" for="field_customer">Customer</label>
|
<label class="form-control-label" jhiTranslate="hsadminNgApp.sepaMandate.customer" for="field_customer">Customer</label>
|
||||||
<select class="form-control" id="field_customer" name="customer" [(ngModel)]="sepaMandate.customerId" required>
|
<select class="form-control" id="field_customer" name="customer" [(ngModel)]="sepaMandate.customerId" required>
|
||||||
<option *ngIf="!editForm.value.customer" [ngValue]="null" selected></option>
|
<option *ngIf="!editForm.value.customer" [ngValue]="null" selected></option>
|
||||||
<option [ngValue]="customerOption.id" *ngFor="let customerOption of customers; trackBy: trackCustomerById">{{customerOption.prefix}}</option>
|
<option [ngValue]="customerOption.id" *ngFor="let customerOption of customers; trackBy: trackCustomerById">{{customerOption.displayLabel}}</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div [hidden]="!(editForm.controls.customer?.dirty && editForm.controls.customer?.invalid)">
|
<div [hidden]="!(editForm.controls.customer?.dirty && editForm.controls.customer?.invalid)">
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
<th jhiSortBy="validUntilDate"><span jhiTranslate="hsadminNgApp.sepaMandate.validUntilDate">Valid Until Date</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
<th jhiSortBy="validUntilDate"><span jhiTranslate="hsadminNgApp.sepaMandate.validUntilDate">Valid Until Date</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||||
<th jhiSortBy="lastUsedDate"><span jhiTranslate="hsadminNgApp.sepaMandate.lastUsedDate">Last Used Date</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
<th jhiSortBy="lastUsedDate"><span jhiTranslate="hsadminNgApp.sepaMandate.lastUsedDate">Last Used Date</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||||
<th jhiSortBy="remark"><span jhiTranslate="hsadminNgApp.sepaMandate.remark">Remark</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
<th jhiSortBy="remark"><span jhiTranslate="hsadminNgApp.sepaMandate.remark">Remark</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||||
<th jhiSortBy="customerPrefix"><span jhiTranslate="hsadminNgApp.sepaMandate.customer">Customer</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
<th jhiSortBy="customerDisplayLabel"><span jhiTranslate="hsadminNgApp.sepaMandate.customer">Customer</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -42,7 +42,7 @@
|
|||||||
<td>{{sepaMandate.remark}}</td>
|
<td>{{sepaMandate.remark}}</td>
|
||||||
<td>
|
<td>
|
||||||
<div *ngIf="sepaMandate.customerId">
|
<div *ngIf="sepaMandate.customerId">
|
||||||
<a [routerLink]="['../customer', sepaMandate.customerId , 'view' ]" >{{sepaMandate.customerPrefix}}</a>
|
<a [routerLink]="['../customer', sepaMandate.customerId , 'view' ]" >{{sepaMandate.customerDisplayLabel}}</a>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
|
@ -11,7 +11,7 @@ export interface ISepaMandate {
|
|||||||
validUntilDate?: Moment;
|
validUntilDate?: Moment;
|
||||||
lastUsedDate?: Moment;
|
lastUsedDate?: Moment;
|
||||||
remark?: string;
|
remark?: string;
|
||||||
customerPrefix?: string;
|
customerDisplayLabel?: string;
|
||||||
customerId?: number;
|
customerId?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ export class SepaMandate implements ISepaMandate {
|
|||||||
public validUntilDate?: Moment,
|
public validUntilDate?: Moment,
|
||||||
public lastUsedDate?: Moment,
|
public lastUsedDate?: Moment,
|
||||||
public remark?: string,
|
public remark?: string,
|
||||||
public customerPrefix?: string,
|
public customerDisplayLabel?: string,
|
||||||
public customerId?: number
|
public customerId?: number
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,7 @@ public class SepaMandateDTOIntTest {
|
|||||||
private static final Integer SOME_CUSTOMER_REFERENCE = 10001;
|
private static final Integer SOME_CUSTOMER_REFERENCE = 10001;
|
||||||
private static final String SOME_CUSTOMER_PREFIX = "abc";
|
private static final String SOME_CUSTOMER_PREFIX = "abc";
|
||||||
private static final String SOME_CUSTOMER_NAME = "Some Customer Name";
|
private static final String SOME_CUSTOMER_NAME = "Some Customer Name";
|
||||||
|
private static final String SOME_CUSTOMER_DISPLAY_LABEL = "Some Customer Name [10001:abc]";
|
||||||
private static final Customer SOME_CUSTOMER = new Customer().id(SOME_CUSTOMER_ID)
|
private static final Customer SOME_CUSTOMER = new Customer().id(SOME_CUSTOMER_ID)
|
||||||
.reference(SOME_CUSTOMER_REFERENCE).prefix(SOME_CUSTOMER_PREFIX).name(SOME_CUSTOMER_NAME);
|
.reference(SOME_CUSTOMER_REFERENCE).prefix(SOME_CUSTOMER_PREFIX).name(SOME_CUSTOMER_NAME);
|
||||||
|
|
||||||
@ -164,7 +165,7 @@ public class SepaMandateDTOIntTest {
|
|||||||
expected.setId(SOME_SEPA_MANDATE_ID);
|
expected.setId(SOME_SEPA_MANDATE_ID);
|
||||||
expected.setCustomerId(SOME_CUSTOMER_ID);
|
expected.setCustomerId(SOME_CUSTOMER_ID);
|
||||||
expected.setRemark("Updated Remark");
|
expected.setRemark("Updated Remark");
|
||||||
expected.setCustomerPrefix(SOME_CUSTOMER_PREFIX);
|
expected.setCustomerDisplayLabel(SOME_CUSTOMER_DISPLAY_LABEL);
|
||||||
assertThat(actual).isEqualToIgnoringGivenFields(expected, "displayLabel");
|
assertThat(actual).isEqualToIgnoringGivenFields(expected, "displayLabel");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,7 +184,7 @@ public class SepaMandateDTOIntTest {
|
|||||||
.withFieldValueIfPresent("lastUsedDate", Objects.toString(dto.getLastUsedDate()))
|
.withFieldValueIfPresent("lastUsedDate", Objects.toString(dto.getLastUsedDate()))
|
||||||
.withFieldValueIfPresent("remark", dto.getRemark())
|
.withFieldValueIfPresent("remark", dto.getRemark())
|
||||||
.withFieldValueIfPresent("customerId", dto.getCustomerId())
|
.withFieldValueIfPresent("customerId", dto.getCustomerId())
|
||||||
.withFieldValue("customerPrefix", dto.getCustomerPrefix())
|
.withFieldValue("customerDisplayLabel", dto.getCustomerDisplayLabel())
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ public class SepaMandateDTOUnitTest extends AccessMappingsUnitTestBase<SepaManda
|
|||||||
"validUntilDate", "revokationDocumentDate");
|
"validUntilDate", "revokationDocumentDate");
|
||||||
readAccessFor(SepaMandateDTO.class, Role.CONTRACTUAL_CONTACT).shouldBeExactlyFor(
|
readAccessFor(SepaMandateDTO.class, Role.CONTRACTUAL_CONTACT).shouldBeExactlyFor(
|
||||||
"grantingDocumentDate", "bic", "id", "validUntilDate", "customerId", "validFromDate", "iban",
|
"grantingDocumentDate", "bic", "id", "validUntilDate", "customerId", "validFromDate", "iban",
|
||||||
"revokationDocumentDate", "customerPrefix", "lastUsedDate", "reference");
|
"revokationDocumentDate", "customerDisplayLabel", "lastUsedDate", "reference");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -72,7 +72,7 @@ public class SepaMandateDTOUnitTest extends AccessMappingsUnitTestBase<SepaManda
|
|||||||
dto.setBic("BIC1234");
|
dto.setBic("BIC1234");
|
||||||
dto.setRemark("Some Remark");
|
dto.setRemark("Some Remark");
|
||||||
dto.setCustomerId(parentId);
|
dto.setCustomerId(parentId);
|
||||||
dto.setCustomerPrefix("abc");
|
dto.setCustomerDisplayLabel("abc");
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ public class SepaMandateDTOUnitTest extends AccessMappingsUnitTestBase<SepaManda
|
|||||||
dto.setBic(RandomStringUtils.randomAlphanumeric(10).toUpperCase());
|
dto.setBic(RandomStringUtils.randomAlphanumeric(10).toUpperCase());
|
||||||
dto.setRemark(RandomStringUtils.randomAlphanumeric(20).toUpperCase());
|
dto.setRemark(RandomStringUtils.randomAlphanumeric(20).toUpperCase());
|
||||||
dto.setCustomerId(parentId);
|
dto.setCustomerId(parentId);
|
||||||
dto.setCustomerPrefix(RandomStringUtils.randomAlphabetic(3).toLowerCase());
|
dto.setCustomerDisplayLabel(RandomStringUtils.randomAlphabetic(3).toLowerCase());
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ public class SepaMandateResourceIntTest {
|
|||||||
|
|
||||||
// Create the SepaMandate
|
// Create the SepaMandate
|
||||||
SepaMandateDTO sepaMandateDTO = sepaMandateMapper.toDto(sepaMandate);
|
SepaMandateDTO sepaMandateDTO = sepaMandateMapper.toDto(sepaMandate);
|
||||||
sepaMandateDTO.setCustomerPrefix(null);
|
sepaMandateDTO.setCustomerDisplayLabel(null);
|
||||||
sepaMandateDTO.setRemark(null);
|
sepaMandateDTO.setRemark(null);
|
||||||
sepaMandateDTO.setRevokationDocumentDate(null);
|
sepaMandateDTO.setRevokationDocumentDate(null);
|
||||||
sepaMandateDTO.setLastUsedDate(null);
|
sepaMandateDTO.setLastUsedDate(null);
|
||||||
|
Loading…
Reference in New Issue
Block a user