Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | 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());
53
			tEntity.setWarnExpiryTime(entity.getWarnExpiryTime().getTime());
54
			tEntity.setCriticalExpiryTime(entity.getCriticalExpiryTime().getTime());
55
			tEntity.setDescription(entity.getEntityProperties());
56
			return tEntity;
57
		}
58
		return null;
59
	}
60
 
61
	public static in.shop2020.alert.domain.MonitoredEntity toDbEntity(
62
			MonitoredEntity tMonitoredEntity) {
63
		if(tMonitoredEntity != null) {
64
			in.shop2020.alert.domain.MonitoredEntity entity = new in.shop2020.alert.domain.MonitoredEntity();
65
			entity.setId(tMonitoredEntity.getId());
66
			entity.setEntityType(tMonitoredEntity.getEntityType());
67
			entity.setEventType(tMonitoredEntity.getEventType());
68
			entity.setEntityIdentifier(tMonitoredEntity.getEntityIdentifier());
69
			entity.setEntityProcessedState(tMonitoredEntity.getEntityProcessedState());
70
			entity.setWarnExpiryTime(new Date(tMonitoredEntity.getWarnExpiryTime()));
71
			entity.setCriticalExpiryTime(new Date(tMonitoredEntity.getCriticalExpiryTime()));
72
			entity.setEntityProperties(tMonitoredEntity.getDescription());
73
			return entity;
74
		}
75
		return null;
76
	}
77
 
78
	public static AlertMapper toThriftAlertMapper(in.shop2020.alert.domain.AlertMapper alertMap) {
79
		if(alertMap!=null) {
80
			AlertMapper tAlertMapper = new AlertMapper();
81
			tAlertMapper.setEntityType(alertMap.getEntityType());
82
			tAlertMapper.setEventType(alertMap.getEventType());
83
			tAlertMapper.setEventdesciption(alertMap.getEventDescription());
84
			tAlertMapper.setAlertType(alertMap.getAlertType());
85
			tAlertMapper.setUserIds(alertMap.getUserIds());
86
			return tAlertMapper;
87
		}
88
		return null;
89
	}
90
 
91
	public static in.shop2020.alert.domain.AlertMapper toDbAlertMap(AlertMapper tAlertMap) {
92
		if(tAlertMap!=null) {
93
			in.shop2020.alert.domain.AlertMapper alertMap = new in.shop2020.alert.domain.AlertMapper();
94
			alertMap.setEntityType(tAlertMap.getEntityType());
95
			alertMap.setEventType(tAlertMap.getEventType());
96
			alertMap.setEventDescription(tAlertMap.getEventdesciption());
97
			alertMap.setAlertType(tAlertMap.getAlertType());
98
			alertMap.setUserIds(tAlertMap.getUserIds());
99
			return alertMap;
100
		}
101
		return null;
102
	}
103
 
104
}