-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApplicationDomainConversionFactory.java
82 lines (73 loc) · 3.6 KB
/
ApplicationDomainConversionFactory.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package com.sit.sso.web.application.domain;
import java.util.ArrayList;
import java.util.List;
import com.sit.sso.common.application.domain.Application;
/**
* Conversion factory for converting Application to ApplicationExternal and vice versa.
*
*/
public class ApplicationDomainConversionFactory {
public static Application fromApplicationExternalToApplication (ApplicationExternal appExternal) {
Application app = new Application();
app.setAppId(appExternal.getAppId());
app.setName(appExternal.getName());
app.setDescription(appExternal.getDescription());
app.setPlannedDeploymentDate(appExternal.getPlannedDeploymentDate());
app.setNumberUsers(appExternal.getNumberUsers());
app.setMaxLoginsPerHour(appExternal.getMaxLoginsPerHour());
app.setHomePage(appExternal.getHomePage());
app.setTechnicalOwner(appExternal.getTechnicalOwner());
app.setBusinessOwner(appExternal.getBusinessOwner());
app.setSupportContact(appExternal.getSupportContact());
app.setOtherContact(appExternal.getOtherContact());
app.setRegisteredBy(appExternal.getRegisteredBy());
return app;
}
public static Application updateInternalInstanceWithExternalData (Application appInternal, ApplicationExternal appExternal) {
appInternal.setName(appExternal.getName());
appInternal.setDescription(appExternal.getDescription());
appInternal.setPlannedDeploymentDate(appExternal.getPlannedDeploymentDate());
appInternal.setNumberUsers(appExternal.getNumberUsers());
appInternal.setMaxLoginsPerHour(appExternal.getMaxLoginsPerHour());
appInternal.setHomePage(appExternal.getHomePage());
appInternal.setTechnicalOwner(appExternal.getTechnicalOwner());
appInternal.setBusinessOwner(appExternal.getBusinessOwner());
appInternal.setSupportContact(appExternal.getSupportContact());
appInternal.setOtherContact(appExternal.getOtherContact());
return appInternal;
}
public static List<Application> fromApplicationExternalListToApplicationList(List<ApplicationExternal> appExternalList) {
List<Application> appList = new ArrayList<Application>();
for (int i=0; i<appExternalList.size(); i++) {
ApplicationExternal currentExternalApp = appExternalList.get(i);
Application currentApp = fromApplicationExternalToApplication(currentExternalApp);
appList.add(currentApp);
}
return appList;
}
public static ApplicationExternal fromApplicationToApplicationExternal (Application app) {
ApplicationExternal appExternal = new ApplicationExternal();
appExternal.setAppId(app.getAppId());
appExternal.setName(app.getName());
appExternal.setDescription(app.getDescription());
appExternal.setPlannedDeploymentDate(app.getPlannedDeploymentDate());
appExternal.setNumberUsers(app.getNumberUsers());
appExternal.setMaxLoginsPerHour(app.getMaxLoginsPerHour());
appExternal.setHomePage(app.getHomePage());
appExternal.setTechnicalOwner(app.getTechnicalOwner());
appExternal.setBusinessOwner(app.getBusinessOwner());
appExternal.setSupportContact(app.getSupportContact());
appExternal.setOtherContact(app.getOtherContact());
appExternal.setRegisteredBy(app.getRegisteredBy());
return appExternal;
}
public static List<ApplicationExternal> fromApplicationListToApplicationExternalList(List<Application> appList) {
List<ApplicationExternal> appExternalList = new ArrayList<ApplicationExternal>();
for (int i=0; i<appList.size(); i++) {
Application currentApp = appList.get(i);
ApplicationExternal currentExternalApp = fromApplicationToApplicationExternal(currentApp);
appExternalList.add(currentExternalApp);
}
return appExternalList;
}
}