Rev 5519 | Blame | Compare with Previous | Last modification | View Log | RSS feed
package in.shop2020.alert.util;import java.util.Date;import org.apache.thrift.transport.TFileTransport.tailPolicy;import in.shop2020.alert.AlertMapper;import in.shop2020.alert.AlertedEntity;import in.shop2020.alert.EntityProcessedState;import in.shop2020.alert.EntityType;import in.shop2020.alert.MonitoredEntity;import in.shop2020.alert.SearchFilter;public class Converter {public static in.shop2020.alert.domain.SearchFilter toDomainSearchFilter(SearchFilter tSearchFilter) {if(tSearchFilter != null) {in.shop2020.alert.domain.SearchFilter searchFilter = new in.shop2020.alert.domain.SearchFilter();searchFilter.setEntityType(tSearchFilter.getEntityType());searchFilter.setEventType(tSearchFilter.getEventType());searchFilter.setEntityIdentifier(tSearchFilter.getEntityIdentifier());searchFilter.setWarnExpiryTime(tSearchFilter.getWarnExpiryTime());searchFilter.setCriticalExpiryTime(tSearchFilter.getCriticalExpiryTime());searchFilter.setEntityProcessedState(tSearchFilter.getEntityProcessedState());return searchFilter;}return null;}public static AlertedEntity toThriftAlertedEntity(in.shop2020.alert.domain.AlertedEntity alertedEntity) {if(alertedEntity != null) {AlertedEntity tAlertedEntity = new AlertedEntity();tAlertedEntity.setId(alertedEntity.getId());tAlertedEntity.setEntityType(alertedEntity.getEntityType());tAlertedEntity.setEventType(alertedEntity.getEventType());tAlertedEntity.setEntityIdentifier(alertedEntity.getEntityIdentifier());tAlertedEntity.setEntityProcessedState(alertedEntity.getEntityProcessedState());tAlertedEntity.setLastAlertedTime(alertedEntity.getLastAlertedTime().getTime());return tAlertedEntity;}return null;}public static MonitoredEntity toThriftMonitoredEntity(in.shop2020.alert.domain.MonitoredEntity entity) {if(entity != null) {MonitoredEntity tEntity = new MonitoredEntity();tEntity.setId(entity.getId());tEntity.setEntityType(entity.getEntityType());tEntity.setEventType(entity.getEventType());tEntity.setEntityIdentifier(entity.getEntityIdentifier());tEntity.setEntityProcessedState(entity.getEntityProcessedState());if(entity.getWarnExpiryTime()!=null){tEntity.setWarnExpiryTime(entity.getWarnExpiryTime().getTime());}if(entity.getCriticalExpiryTime()!=null){tEntity.setCriticalExpiryTime(entity.getCriticalExpiryTime().getTime());}tEntity.setDescription(entity.getEntityProperties());return tEntity;}return null;}public static in.shop2020.alert.domain.MonitoredEntity toDbEntity(MonitoredEntity tMonitoredEntity) {if(tMonitoredEntity != null) {in.shop2020.alert.domain.MonitoredEntity entity = new in.shop2020.alert.domain.MonitoredEntity();entity.setId(tMonitoredEntity.getId());entity.setEntityType(tMonitoredEntity.getEntityType());entity.setEventType(tMonitoredEntity.getEventType());entity.setEntityIdentifier(tMonitoredEntity.getEntityIdentifier());entity.setEntityProcessedState(tMonitoredEntity.getEntityProcessedState());entity.setWarnExpiryTime(new Date(tMonitoredEntity.getWarnExpiryTime()));entity.setCriticalExpiryTime(new Date(tMonitoredEntity.getCriticalExpiryTime()));entity.setEntityProperties(tMonitoredEntity.getDescription());return entity;}return null;}public static AlertMapper toThriftAlertMapper(in.shop2020.alert.domain.AlertMapper alertMap) {if(alertMap!=null) {AlertMapper tAlertMapper = new AlertMapper();tAlertMapper.setEntityType(alertMap.getEntityType());tAlertMapper.setEventType(alertMap.getEventType());tAlertMapper.setEventdesciption(alertMap.getEventDescription());tAlertMapper.setAlertType(alertMap.getAlertType());tAlertMapper.setUserIds(alertMap.getUserIds());return tAlertMapper;}return null;}public static in.shop2020.alert.domain.AlertMapper toDbAlertMap(AlertMapper tAlertMap) {if(tAlertMap!=null) {in.shop2020.alert.domain.AlertMapper alertMap = new in.shop2020.alert.domain.AlertMapper();alertMap.setEntityType(tAlertMap.getEntityType());alertMap.setEventType(tAlertMap.getEventType());alertMap.setEventDescription(tAlertMap.getEventdesciption());alertMap.setAlertType(tAlertMap.getAlertType());alertMap.setUserIds(tAlertMap.getUserIds());return alertMap;}return null;}}