use of org.mapstruct.AfterMapping in project osms by malikov-yurii.
the class ProductMapper method afterToDto.
@AfterMapping
protected void afterToDto(Product source, @MappingTarget ProductAutocompleteDto target) {
final BigDecimal productPrice = ValueCalculator.calculateValue(source);
target.setLabel(source.getName() + " " + productPrice);
target.setProductPrice(productPrice);
}
use of org.mapstruct.AfterMapping in project scm-review-plugin by scm-manager.
the class CommentMapper method appendLinks.
@AfterMapping
void appendLinks(@MappingTarget CommentDto target, Comment source, @Context Repository repository, @Context String pullRequestId, @Context BranchRevisionResolver.RevisionResult revisions) {
String namespace = repository.getNamespace();
String name = repository.getName();
final Links.Builder linksBuilder = new Links.Builder();
linksBuilder.self(commentPathBuilder.createCommentSelfUri(namespace, name, pullRequestId, target.getId()));
if (!target.isSystemComment() && PermissionCheck.mayModifyComment(repository, source)) {
linksBuilder.single(link("update", commentPathBuilder.createUpdateCommentUri(namespace, name, pullRequestId, target.getId(), revisions)));
linksBuilder.single(link("possibleTransitions", commentPathBuilder.createPossibleTransitionUri(namespace, name, pullRequestId, target.getId())));
if (source.getReplies().isEmpty()) {
linksBuilder.single(link("delete", commentPathBuilder.createDeleteCommentUri(namespace, name, pullRequestId, target.getId(), revisions)));
}
}
applyEnrichers(new EdisonHalAppender(linksBuilder, new Embedded.Builder()), source, repository);
target.add(linksBuilder.build());
}
use of org.mapstruct.AfterMapping in project cals-api by ca-cwds.
the class FacilityAddressMapper method afterMapping.
@AfterMapping
default void afterMapping(@TargetType FacilityAddressDTO facilityAddressDTO, BasePlacementHome placementHome, CwsDictionaryEntriesHolder dictionaryEntriesHolder) {
AddressMapper addressMapper = Mappers.getMapper(AddressMapper.class);
AddressDTO addressDTO = null;
if (RESIDENTIAL.equals(facilityAddressDTO.getType())) {
addressDTO = addressMapper.toResidentialAddressDTO(placementHome, dictionaryEntriesHolder);
}
if (MAIL.equals(facilityAddressDTO.getType())) {
addressDTO = addressMapper.toMailAddressDTO(placementHome, dictionaryEntriesHolder);
}
facilityAddressDTO.setAddress(addressDTO);
}
use of org.mapstruct.AfterMapping in project api-core by ca-cwds.
the class CountyOwnershipMapper method afterMapping.
@AfterMapping
default void afterMapping(@MappingTarget CountyOwnership countyOwnership, String entityId, String discriminator) {
int yFlagsCount = 0;
for (Method method : countyOwnership.getClass().getMethods()) {
if (method.getName().startsWith("getCty")) {
String flag;
try {
flag = (String) method.invoke(countyOwnership);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException("Cannot calculate multi flag for county ownership {id: " + entityId + ", code: " + discriminator + "}", e);
}
if (Constants.Y.equals(flag)) {
yFlagsCount += 1;
}
}
}
String multiFlag = yFlagsCount > 1 ? Constants.Y : Constants.N;
countyOwnership.setMultiFlg(multiFlag);
}
use of org.mapstruct.AfterMapping in project osms by malikov-yurii.
the class ProductMapper method afterToDto.
@AfterMapping
protected void afterToDto(ProductVariation source, @MappingTarget ProductAutocompleteDto target) {
final BigDecimal productVariationPrice = ValueCalculator.calculateValue(source);
final String productVariationFullName = productVariationFullName(source);
target.setLabel(productVariationFullName + " " + productVariationPrice);
target.setProductName(productVariationFullName);
target.setProductPrice(productVariationPrice);
}
Aggregations