Search in sources :

Example 1 with MetaDatasetResponseDTO

use of org.metahut.octopus.api.dto.MetaDatasetResponseDTO in project octopus by MetaHut.

the class MonitorLogToDTOConverter method queryMeta.

@Named("querySchemaMeta")
public MetaSchemaResponseDTO queryMeta(MonitorLog source) {
    MetaDatasetResponseDTO dataset = metaService.queryDatasetByCode(source.getDatasetCode());
    MetaSchemaResponseDTO metaSchemaResponseDTO = new MetaSchemaResponseDTO();
    metaSchemaResponseDTO.setDatasource(dataset.getDatasource());
    metaSchemaResponseDTO.setDatabase(dataset.getDatabase());
    metaSchemaResponseDTO.setDataset(new MetaDatasetSingleResponseDTO(dataset.getCode(), dataset.getName()));
    if (SubjectCategoryEnum.TABLE.name().equals(source.getSubjectCategory())) {
        return metaSchemaResponseDTO;
    }
    Optional<MetaSchemaSingleResponseDTO> first = dataset.getSchemas().stream().filter(schema -> source.getSubjectCode().equals(schema.getCode())).findFirst();
    if (!first.isPresent()) {
        metaSchemaResponseDTO.setCode("undefined");
        metaSchemaResponseDTO.setName("undefined");
        return metaSchemaResponseDTO;
    }
    MetaSchemaSingleResponseDTO metaSchemaSingleResponseDTO = first.get();
    metaSchemaResponseDTO.setCode(metaSchemaSingleResponseDTO.getCode());
    metaSchemaResponseDTO.setName(metaSchemaSingleResponseDTO.getName());
    return metaSchemaResponseDTO;
}
Also used : Converter(org.springframework.core.convert.converter.Converter) Mapping(org.mapstruct.Mapping) MetaSchemaSingleResponseDTO(org.metahut.octopus.api.dto.MetaSchemaSingleResponseDTO) Named(org.mapstruct.Named) Autowired(org.springframework.beans.factory.annotation.Autowired) MetaSchemaResponseDTO(org.metahut.octopus.api.dto.MetaSchemaResponseDTO) List(java.util.List) Mapper(org.mapstruct.Mapper) MetaService(org.metahut.octopus.server.service.MetaService) MetaDatasetResponseDTO(org.metahut.octopus.api.dto.MetaDatasetResponseDTO) MetaDatasetSingleResponseDTO(org.metahut.octopus.api.dto.MetaDatasetSingleResponseDTO) MonitorLogResponseDTO(org.metahut.octopus.api.dto.MonitorLogResponseDTO) Optional(java.util.Optional) SubjectCategoryEnum(org.metahut.octopus.common.enums.SubjectCategoryEnum) MonitorLog(org.metahut.octopus.monitordb.api.MonitorLog) MetaDatasetResponseDTO(org.metahut.octopus.api.dto.MetaDatasetResponseDTO) MetaSchemaSingleResponseDTO(org.metahut.octopus.api.dto.MetaSchemaSingleResponseDTO) MetaDatasetSingleResponseDTO(org.metahut.octopus.api.dto.MetaDatasetSingleResponseDTO) MetaSchemaResponseDTO(org.metahut.octopus.api.dto.MetaSchemaResponseDTO) Named(org.mapstruct.Named)

Example 2 with MetaDatasetResponseDTO

use of org.metahut.octopus.api.dto.MetaDatasetResponseDTO 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)

Aggregations

MetaDatasetResponseDTO (org.metahut.octopus.api.dto.MetaDatasetResponseDTO)2 List (java.util.List)1 Optional (java.util.Optional)1 StringJoiner (java.util.StringJoiner)1 BeforeMapping (org.mapstruct.BeforeMapping)1 Mapper (org.mapstruct.Mapper)1 Mapping (org.mapstruct.Mapping)1 Named (org.mapstruct.Named)1 MetaDatasetSingleResponseDTO (org.metahut.octopus.api.dto.MetaDatasetSingleResponseDTO)1 MetaSchemaResponseDTO (org.metahut.octopus.api.dto.MetaSchemaResponseDTO)1 MetaSchemaSingleResponseDTO (org.metahut.octopus.api.dto.MetaSchemaSingleResponseDTO)1 MonitorLogResponseDTO (org.metahut.octopus.api.dto.MonitorLogResponseDTO)1 SubjectCategoryEnum (org.metahut.octopus.common.enums.SubjectCategoryEnum)1 MonitorLog (org.metahut.octopus.monitordb.api.MonitorLog)1 MetaService (org.metahut.octopus.server.service.MetaService)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Converter (org.springframework.core.convert.converter.Converter)1