Search in sources :

Example 6 with AfterMapping

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);
}
Also used : BigDecimal(java.math.BigDecimal) AfterMapping(org.mapstruct.AfterMapping)

Example 7 with AfterMapping

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());
}
Also used : EdisonHalAppender(sonia.scm.web.EdisonHalAppender) Links(de.otto.edison.hal.Links) AfterMapping(org.mapstruct.AfterMapping)

Example 8 with AfterMapping

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);
}
Also used : FacilityAddressDTO(gov.ca.cwds.cals.service.dto.FacilityAddressDTO) AddressDTO(gov.ca.cwds.cals.service.dto.AddressDTO) AfterMapping(org.mapstruct.AfterMapping)

Example 9 with AfterMapping

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);
}
Also used : Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) AfterMapping(org.mapstruct.AfterMapping)

Example 10 with AfterMapping

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);
}
Also used : BigDecimal(java.math.BigDecimal) AfterMapping(org.mapstruct.AfterMapping)

Aggregations

AfterMapping (org.mapstruct.AfterMapping)12 Links (de.otto.edison.hal.Links)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 BigDecimal (java.math.BigDecimal)2 EdisonHalAppender (sonia.scm.web.EdisonHalAppender)2 S3bucketDataStorage (com.epam.pipeline.entity.datastorage.aws.S3bucketDataStorage)1 NamePrefixType (gov.ca.cwds.cals.persistence.model.calsns.dictionaries.NamePrefixType)1 NameSuffixType (gov.ca.cwds.cals.persistence.model.calsns.dictionaries.NameSuffixType)1 AddressDTO (gov.ca.cwds.cals.service.dto.AddressDTO)1 FacilityAddressDTO (gov.ca.cwds.cals.service.dto.FacilityAddressDTO)1 BaseOutOfHomePlacement (gov.ca.cwds.data.legacy.cms.entity.BaseOutOfHomePlacement)1 BasePlacementEpisode (gov.ca.cwds.data.legacy.cms.entity.BasePlacementEpisode)1 County (gov.ca.cwds.data.legacy.cms.entity.syscodes.County)1 Field (java.lang.reflect.Field)1 Method (java.lang.reflect.Method)1 Timestamp (java.sql.Timestamp)1 LocalDate (java.time.LocalDate)1 Period (java.time.Period)1