Subversion Repositories SmartDukaan

Rev

Rev 5519 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5519 amar.kumar 1
package in.shop2020.alert.util;
2
 
3
import java.util.Date;
4
 
5
import org.apache.thrift.transport.TFileTransport.tailPolicy;
6
 
7
import in.shop2020.alert.AlertMapper;
8
import in.shop2020.alert.AlertedEntity;
9
import in.shop2020.alert.EntityProcessedState;
10
import in.shop2020.alert.EntityType;
11
import in.shop2020.alert.MonitoredEntity;
12
import in.shop2020.alert.SearchFilter;
13
 
14
public class Converter {
15
 
16
	public static in.shop2020.alert.domain.SearchFilter toDomainSearchFilter(SearchFilter tSearchFilter) {
17
		if(tSearchFilter != null) {
18
			in.shop2020.alert.domain.SearchFilter searchFilter = new in.shop2020.alert.domain.SearchFilter();
19
			searchFilter.setEntityType(tSearchFilter.getEntityType());
20
			searchFilter.setEventType(tSearchFilter.getEventType());
21
			searchFilter.setEntityIdentifier(tSearchFilter.getEntityIdentifier());
22
			searchFilter.setWarnExpiryTime(tSearchFilter.getWarnExpiryTime());
23
			searchFilter.setCriticalExpiryTime(tSearchFilter.getCriticalExpiryTime());
24
			searchFilter.setEntityProcessedState(tSearchFilter.getEntityProcessedState());
25
			return searchFilter;
26
		}
27
		return null;
28
	}
29
 
30
	public static AlertedEntity toThriftAlertedEntity(
31
			in.shop2020.alert.domain.AlertedEntity alertedEntity) {
32
		if(alertedEntity != null) {
33
			AlertedEntity tAlertedEntity = new AlertedEntity();
34
			tAlertedEntity.setId(alertedEntity.getId());
35
			tAlertedEntity.setEntityType(alertedEntity.getEntityType());
36
			tAlertedEntity.setEventType(alertedEntity.getEventType());
37
			tAlertedEntity.setEntityIdentifier(alertedEntity.getEntityIdentifier());
38
			tAlertedEntity.setEntityProcessedState(alertedEntity.getEntityProcessedState());
39
			tAlertedEntity.setLastAlertedTime(alertedEntity.getLastAlertedTime().getTime());
40
			return tAlertedEntity;
41
		}
42
		return null;
43
	}
44
 
45
	public static MonitoredEntity toThriftMonitoredEntity(in.shop2020.alert.domain.MonitoredEntity entity) {
46
		if(entity != null) {
47
			MonitoredEntity tEntity = new MonitoredEntity();
48
			tEntity.setId(entity.getId());
49
			tEntity.setEntityType(entity.getEntityType());
50
			tEntity.setEventType(entity.getEventType());
51
			tEntity.setEntityIdentifier(entity.getEntityIdentifier());
52
			tEntity.setEntityProcessedState(entity.getEntityProcessedState());
5759 amar.kumar 53
			if(entity.getWarnExpiryTime()!=null){
54
				tEntity.setWarnExpiryTime(entity.getWarnExpiryTime().getTime());
55
			}
56
			if(entity.getCriticalExpiryTime()!=null){
57
				tEntity.setCriticalExpiryTime(entity.getCriticalExpiryTime().getTime());
58
			}
5519 amar.kumar 59
			tEntity.setDescription(entity.getEntityProperties());
60
			return tEntity;
61
		}
62
		return null;
63
	}
64
 
65
	public static in.shop2020.alert.domain.MonitoredEntity toDbEntity(
66
			MonitoredEntity tMonitoredEntity) {
67
		if(tMonitoredEntity != null) {
68
			in.shop2020.alert.domain.MonitoredEntity entity = new in.shop2020.alert.domain.MonitoredEntity();
69
			entity.setId(tMonitoredEntity.getId());
70
			entity.setEntityType(tMonitoredEntity.getEntityType());
71
			entity.setEventType(tMonitoredEntity.getEventType());
72
			entity.setEntityIdentifier(tMonitoredEntity.getEntityIdentifier());
73
			entity.setEntityProcessedState(tMonitoredEntity.getEntityProcessedState());
74
			entity.setWarnExpiryTime(new Date(tMonitoredEntity.getWarnExpiryTime()));
75
			entity.setCriticalExpiryTime(new Date(tMonitoredEntity.getCriticalExpiryTime()));
76
			entity.setEntityProperties(tMonitoredEntity.getDescription());
77
			return entity;
78
		}
79
		return null;
80
	}
81
 
82
	public static AlertMapper toThriftAlertMapper(in.shop2020.alert.domain.AlertMapper alertMap) {
83
		if(alertMap!=null) {
84
			AlertMapper tAlertMapper = new AlertMapper();
85
			tAlertMapper.setEntityType(alertMap.getEntityType());
86
			tAlertMapper.setEventType(alertMap.getEventType());
87
			tAlertMapper.setEventdesciption(alertMap.getEventDescription());
88
			tAlertMapper.setAlertType(alertMap.getAlertType());
89
			tAlertMapper.setUserIds(alertMap.getUserIds());
90
			return tAlertMapper;
91
		}
92
		return null;
93
	}
94
 
95
	public static in.shop2020.alert.domain.AlertMapper toDbAlertMap(AlertMapper tAlertMap) {
96
		if(tAlertMap!=null) {
97
			in.shop2020.alert.domain.AlertMapper alertMap = new in.shop2020.alert.domain.AlertMapper();
98
			alertMap.setEntityType(tAlertMap.getEntityType());
99
			alertMap.setEventType(tAlertMap.getEventType());
100
			alertMap.setEventDescription(tAlertMap.getEventdesciption());
101
			alertMap.setAlertType(tAlertMap.getAlertType());
102
			alertMap.setUserIds(tAlertMap.getUserIds());
103
			return alertMap;
104
		}
105
		return null;
106
	}
107
 
108
}