Search in sources :

Example 1 with MetaDataDO

use of org.apache.shenyu.admin.model.entity.MetaDataDO in project incubator-shenyu by apache.

the class MetaDataServiceImpl method delete.

@Override
@Transactional(rollbackFor = Exception.class)
public int delete(final List<String> ids) {
    int count = 0;
    Set<String> idSet = Optional.ofNullable(ids).orElseGet(ArrayList::new).stream().filter(StringUtils::isNotEmpty).collect(Collectors.toSet());
    if (CollectionUtils.isNotEmpty(idSet)) {
        List<MetaDataDO> metaDataDoList = metaDataMapper.selectByIdSet(idSet);
        List<MetaData> metaDataList = Optional.ofNullable(metaDataDoList).orElseGet(ArrayList::new).stream().map(MetaDataTransfer.INSTANCE::mapToData).collect(Collectors.toList());
        count = metaDataMapper.deleteByIdSet(idSet);
        eventPublisher.publishEvent(new DataChangedEvent(ConfigGroupEnum.META_DATA, DataEventTypeEnum.DELETE, metaDataList));
    }
    return count;
}
Also used : DataChangedEvent(org.apache.shenyu.admin.listener.DataChangedEvent) MetaData(org.apache.shenyu.common.dto.MetaData) MetaDataDO(org.apache.shenyu.admin.model.entity.MetaDataDO) MetaDataTransfer(org.apache.shenyu.admin.transfer.MetaDataTransfer) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with MetaDataDO

use of org.apache.shenyu.admin.model.entity.MetaDataDO in project incubator-shenyu by apache.

the class MetaDataServiceImpl method saveOrUpdateMetaData.

@Override
public void saveOrUpdateMetaData(final MetaDataDO exist, final MetaDataRegisterDTO metaDataDTO) {
    DataEventTypeEnum eventType;
    MetaDataDO metaDataDO = MetaDataTransfer.INSTANCE.mapRegisterDTOToEntity(metaDataDTO);
    if (Objects.isNull(exist)) {
        Timestamp currentTime = new Timestamp(System.currentTimeMillis());
        metaDataDO.setId(UUIDUtils.getInstance().generateShortUuid());
        metaDataDO.setDateCreated(currentTime);
        metaDataDO.setDateUpdated(currentTime);
        metaDataMapper.insert(metaDataDO);
        eventType = DataEventTypeEnum.CREATE;
    } else {
        metaDataDO.setId(exist.getId());
        metaDataMapper.update(metaDataDO);
        eventType = DataEventTypeEnum.UPDATE;
    }
    // publish MetaData's event
    eventPublisher.publishEvent(new DataChangedEvent(ConfigGroupEnum.META_DATA, eventType, Collections.singletonList(MetaDataTransfer.INSTANCE.mapToData(metaDataDO))));
}
Also used : DataEventTypeEnum(org.apache.shenyu.common.enums.DataEventTypeEnum) DataChangedEvent(org.apache.shenyu.admin.listener.DataChangedEvent) MetaDataDO(org.apache.shenyu.admin.model.entity.MetaDataDO) Timestamp(java.sql.Timestamp)

Example 3 with MetaDataDO

use of org.apache.shenyu.admin.model.entity.MetaDataDO in project incubator-shenyu by apache.

the class ShenyuClientRegisterSofaServiceImpl method registerMetadata.

@Override
protected void registerMetadata(final MetaDataRegisterDTO metaDataDTO) {
    MetaDataService metaDataService = getMetaDataService();
    MetaDataDO exist = metaDataService.findByServiceNameAndMethodName(metaDataDTO.getServiceName(), metaDataDTO.getMethodName());
    metaDataService.saveOrUpdateMetaData(exist, metaDataDTO);
}
Also used : MetaDataService(org.apache.shenyu.admin.service.MetaDataService) MetaDataDO(org.apache.shenyu.admin.model.entity.MetaDataDO)

Example 4 with MetaDataDO

use of org.apache.shenyu.admin.model.entity.MetaDataDO in project incubator-shenyu by apache.

the class ShenyuClientRegisterSpringCloudServiceImpl method registerMetadata.

@Override
protected void registerMetadata(final MetaDataRegisterDTO metaDataDTO) {
    MetaDataService metaDataService = getMetaDataService();
    metaDataDTO.setPath(PathUtils.decoratorPath(metaDataDTO.getContextPath()));
    MetaDataDO metaDataDO = metaDataService.findByPath(metaDataDTO.getPath());
    metaDataService.saveOrUpdateMetaData(metaDataDO, metaDataDTO);
}
Also used : MetaDataService(org.apache.shenyu.admin.service.MetaDataService) MetaDataDO(org.apache.shenyu.admin.model.entity.MetaDataDO)

Example 5 with MetaDataDO

use of org.apache.shenyu.admin.model.entity.MetaDataDO in project incubator-shenyu by apache.

the class ShenyuClientRegisterTarsServiceImpl method registerMetadata.

@Override
protected void registerMetadata(final MetaDataRegisterDTO metaDataDTO) {
    MetaDataService metaDataService = getMetaDataService();
    MetaDataDO exist = metaDataService.findByServiceNameAndMethodName(metaDataDTO.getServiceName(), metaDataDTO.getMethodName());
    metaDataService.saveOrUpdateMetaData(exist, metaDataDTO);
}
Also used : MetaDataService(org.apache.shenyu.admin.service.MetaDataService) MetaDataDO(org.apache.shenyu.admin.model.entity.MetaDataDO)

Aggregations

MetaDataDO (org.apache.shenyu.admin.model.entity.MetaDataDO)36 Test (org.junit.jupiter.api.Test)23 AbstractSpringIntegrationTest (org.apache.shenyu.admin.AbstractSpringIntegrationTest)14 MetaDataService (org.apache.shenyu.admin.service.MetaDataService)7 MetaDataRegisterDTO (org.apache.shenyu.register.common.dto.MetaDataRegisterDTO)7 DataChangedEvent (org.apache.shenyu.admin.listener.DataChangedEvent)4 PageParameter (org.apache.shenyu.admin.model.page.PageParameter)3 Timestamp (java.sql.Timestamp)2 MetaDataQuery (org.apache.shenyu.admin.model.query.MetaDataQuery)2 MetaDataVO (org.apache.shenyu.admin.model.vo.MetaDataVO)2 MetaDataTransfer (org.apache.shenyu.admin.transfer.MetaDataTransfer)2 MetaData (org.apache.shenyu.common.dto.MetaData)2 DataEventTypeEnum (org.apache.shenyu.common.enums.DataEventTypeEnum)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 ArrayList (java.util.ArrayList)1 Transactional (org.springframework.transaction.annotation.Transactional)1