1 | package edu.iu.uis.sit.portal.portlet.admin.services; |
2 | |
3 | import java.util.Iterator; |
4 | import java.util.List; |
5 | |
6 | import edu.iu.uis.sit.portal.portlet.admin.dao.AdminDAO; |
7 | import edu.iu.uis.sit.portal.portlet.admin.domain.ApplicationConstant; |
8 | import edu.iu.uis.sit.portal.portlet.admin.domain.PortalConfig; |
9 | import edu.iu.uis.sit.portal.portlet.admin.domain.PortalSupport; |
10 | import edu.iu.uis.sit.portal.portlet.admin.domain.PortletApplication; |
11 | import edu.iu.uis.sit.portal.portlet.admin.domain.PortletConfig; |
12 | import edu.iu.uis.sit.portal.portlet.admin.domain.PortletMapping; |
13 | |
14 | public class AdminServiceImpl implements AdminService { |
15 | private AdminDAO adminDAO; |
16 | |
17 | public void savePortletConfig(PortletApplication portletApplication, PortletConfig portletConfig) { |
18 | portletConfig.setPortletApplication(portletApplication); |
19 | adminDAO.savePortletConfig(portletConfig); |
20 | } |
21 | |
22 | public void deletePortletConfig(PortletConfig portletConfig) { |
23 | adminDAO.deletePortletConfig(portletConfig); |
24 | } |
25 | |
26 | public PortletConfig findPortletConfigById(Long portletConfigId) { |
27 | return adminDAO.findPortletConfigById(portletConfigId); |
28 | } |
29 | |
30 | public void deletePortalSupport(PortalSupport portalSupport) { |
31 | adminDAO.deletePortalSupport(portalSupport); |
32 | } |
33 | |
34 | public PortalSupport findPortalSupportById(Long portalSupportId) { |
35 | return adminDAO.findPortalSupportById(portalSupportId); |
36 | } |
37 | |
38 | public void savePortletApplication(PortalConfig portalConfig, PortletApplication portletApplication) { |
39 | if (portletApplication.getPortletApplicationId() != null) { |
40 | for (Iterator iter = portalConfig.getPortletApplications().iterator(); iter.hasNext();) { |
41 | PortletApplication application = (PortletApplication) iter.next(); |
42 | if (application.getPortletApplicationId().longValue() == portletApplication.getPortletApplicationId().longValue()) { |
43 | application.setContextPath(portletApplication.getContextPath()); |
44 | } |
45 | } |
46 | } else { |
47 | portalConfig.getPortalSupports().add(portletApplication); |
48 | } |
49 | adminDAO.savePortalConfig(portalConfig); |
50 | } |
51 | |
52 | public void deletePortletApplication(PortletApplication portletApplication) { |
53 | adminDAO.deletePortletApplication(portletApplication); |
54 | } |
55 | |
56 | public PortletApplication findPortletApplicationById(Long portletApplicationId) { |
57 | return adminDAO.findPortletApplicationById(portletApplicationId); |
58 | } |
59 | |
60 | public void savePortalSupport(PortalConfig portalConfig, PortalSupport portalSupport) { |
61 | if (portalSupport.getPortalSupportId() != null) { |
62 | for (Iterator iter = portalConfig.getPortalSupports().iterator(); iter.hasNext();) { |
63 | PortalSupport support = (PortalSupport) iter.next(); |
64 | if (support.getPortalSupportId().longValue() == portalSupport.getPortalSupportId().longValue()) { |
65 | support.setSupportName(portalSupport.getSupportName()); |
66 | } |
67 | } |
68 | } else { |
69 | portalConfig.getPortalSupports().add(portalSupport); |
70 | } |
71 | adminDAO.savePortalConfig(portalConfig); |
72 | } |
73 | |
74 | public void saveApplicationConstant(ApplicationConstant applicationConstant) { |
75 | adminDAO.saveApplicationConstant(applicationConstant); |
76 | } |
77 | |
78 | public void deleteApplicationConstant(ApplicationConstant applicationConstant) { |
79 | adminDAO.deleteApplicationConstant(applicationConstant); |
80 | } |
81 | |
82 | public List findAllApplicationConstants() { |
83 | return adminDAO.findAllApplicationConstants(); |
84 | } |
85 | |
86 | public ApplicationConstant findApplicationConstantByName(String constantName) { |
87 | return adminDAO.findApplicationConstantByName(constantName); |
88 | } |
89 | |
90 | public ApplicationConstant findApplicationConstantById(Long constantId) { |
91 | return adminDAO.findApplicationConstantById(constantId); |
92 | } |
93 | |
94 | public void savePortletMapping(PortletMapping portletMapping) { |
95 | adminDAO.savePortletMapping(portletMapping); |
96 | } |
97 | |
98 | public void deletePortletMapping(PortletMapping portletMapping) { |
99 | adminDAO.deletePortletMapping(portletMapping); |
100 | } |
101 | |
102 | public List findAllPortletMappings() { |
103 | return adminDAO.findAllPortletMappings(); |
104 | } |
105 | |
106 | public PortletMapping findPortletMappingById(Long mappingId) { |
107 | return adminDAO.findPortletMappingById(mappingId); |
108 | } |
109 | |
110 | public void savePortalConfig(PortalConfig portalConfig) { |
111 | adminDAO.savePortalConfig(portalConfig); |
112 | } |
113 | |
114 | public PortalConfig getPortalConfig() { |
115 | List portalConfig = adminDAO.getPortalConfigs(); |
116 | |
117 | if (portalConfig != null && !portalConfig.isEmpty()) { |
118 | return (PortalConfig) portalConfig.get(0); |
119 | } |
120 | return new PortalConfig(); |
121 | } |
122 | |
123 | public AdminDAO getAdminDAO() { |
124 | return adminDAO; |
125 | } |
126 | |
127 | public void setAdminDAO(AdminDAO adminDAO) { |
128 | this.adminDAO = adminDAO; |
129 | } |
130 | |
131 | } |