Search in sources :

Example 1 with BeforeMapping

use of org.mapstruct.BeforeMapping in project pnc by project-ncl.

the class BuildBCRevisionFetcher method mapFromAuditedBuildConfig.

@BeforeMapping
public void mapFromAuditedBuildConfig(BuildRecord build, @MappingTarget Build.Builder dtoBuilder) {
    Integer id = build.getBuildConfigurationId();
    Integer revision = build.getBuildConfigurationRev();
    // If somebody before us already set the BCA we don't need to query it from DB again
    BuildConfigurationAudited bca = build.getBuildConfigurationAudited();
    if (bca == null) {
        bca = bcAuditedRepository.queryById(new IdRev(id, revision));
    }
    BuildConfigurationRevisionRef bcRevision = bcRevisionMapper.toRef(bca);
    ProjectRef project = projectMapper.toRef(bca.getProject());
    Environment environment = environmentMapper.toRef(bca.getBuildEnvironment());
    SCMRepository scmRepository = scmRepositoryMapper.toRef(bca.getRepositoryConfiguration());
    dtoBuilder.buildConfigRevision(bcRevision);
    dtoBuilder.project(project);
    dtoBuilder.environment(environment);
    dtoBuilder.scmRepository(scmRepository);
}
Also used : BuildConfigurationAudited(org.jboss.pnc.model.BuildConfigurationAudited) BuildConfigurationRevisionRef(org.jboss.pnc.dto.BuildConfigurationRevisionRef) Environment(org.jboss.pnc.dto.Environment) IdRev(org.jboss.pnc.model.IdRev) ProjectRef(org.jboss.pnc.dto.ProjectRef) SCMRepository(org.jboss.pnc.dto.SCMRepository) BeforeMapping(org.mapstruct.BeforeMapping)

Example 2 with BeforeMapping

use of org.mapstruct.BeforeMapping in project octopus by MetaHut.

the class FlowDefinitionFromDTOConverter method createSchedule.

@BeforeMapping
public void createSchedule(MonitorFlowDefinitionCreateOrUpdateRequestDTO source) {
    if (StringUtils.isBlank(source.getSchedulerCode())) {
        // TODO name parameter need to be optimized
        MetaDatasetResponseDTO dataset = metaService.queryDatasetByCode(source.getDatasetCode());
        StringJoiner taskName = new StringJoiner(NAME_SPLICE_SYMBOL).add(dataset.getDatasource().getCode()).add(source.getDatasetCode()).add(String.valueOf(source.getCode()));
        String schedulerCode = schedulerService.createMetricsProductionTaskAndAddSchedule(taskName.toString(), source.getCode(), source.getCrontab());
        source.setSchedulerCode(schedulerCode);
    }
}
Also used : MetaDatasetResponseDTO(org.metahut.octopus.api.dto.MetaDatasetResponseDTO) StringJoiner(java.util.StringJoiner) BeforeMapping(org.mapstruct.BeforeMapping)

Example 3 with BeforeMapping

use of org.mapstruct.BeforeMapping in project springfox by springfox.

the class ServiceModelToSwagger2Mapper method beforeMappingOperations.

@BeforeMapping
@SuppressWarnings("deprecation")
void beforeMappingOperations(@MappingTarget Operation target, springfox.documentation.service.Operation source, @Context ModelNamesRegistry modelNamesRegistry) {
    List<io.swagger.models.parameters.Parameter> parameters = new ArrayList<>();
    if (useModelV3) {
        for (RequestParameter each : source.getRequestParameters()) {
            parameters.addAll(Mappers.getMapper(RequestParameterMapper.class).mapParameter(each, modelNamesRegistry));
        }
        target.setResponses(mapResponses(source.getResponses(), modelNamesRegistry));
    } else {
        for (springfox.documentation.service.Parameter each : source.getParameters()) {
            parameters.add(Mappers.getMapper(ParameterMapper.class).mapParameter(each));
        }
        target.setResponses(mapResponseMessages(source.getResponseMessages()));
    }
    target.setParameters(parameters);
}
Also used : RequestParameter(springfox.documentation.service.RequestParameter) ArrayList(java.util.ArrayList) RequestParameter(springfox.documentation.service.RequestParameter) BeforeMapping(org.mapstruct.BeforeMapping)

Aggregations

BeforeMapping (org.mapstruct.BeforeMapping)3 ArrayList (java.util.ArrayList)1 StringJoiner (java.util.StringJoiner)1 BuildConfigurationRevisionRef (org.jboss.pnc.dto.BuildConfigurationRevisionRef)1 Environment (org.jboss.pnc.dto.Environment)1 ProjectRef (org.jboss.pnc.dto.ProjectRef)1 SCMRepository (org.jboss.pnc.dto.SCMRepository)1 BuildConfigurationAudited (org.jboss.pnc.model.BuildConfigurationAudited)1 IdRev (org.jboss.pnc.model.IdRev)1 MetaDatasetResponseDTO (org.metahut.octopus.api.dto.MetaDatasetResponseDTO)1 RequestParameter (springfox.documentation.service.RequestParameter)1