| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
package org.kuali.rice.kew.help.web; |
| 18 |
|
|
| 19 |
|
import java.util.ArrayList; |
| 20 |
|
import java.util.List; |
| 21 |
|
|
| 22 |
|
import javax.servlet.http.HttpServletRequest; |
| 23 |
|
import javax.servlet.http.HttpServletResponse; |
| 24 |
|
|
| 25 |
|
import org.apache.commons.lang.StringUtils; |
| 26 |
|
import org.apache.struts.action.ActionForm; |
| 27 |
|
import org.apache.struts.action.ActionForward; |
| 28 |
|
import org.apache.struts.action.ActionMapping; |
| 29 |
|
import org.kuali.rice.core.api.impex.ExportDataSet; |
| 30 |
|
import org.kuali.rice.core.web.impex.ExportServlet; |
| 31 |
|
import org.kuali.rice.kew.export.KewExportDataSet; |
| 32 |
|
import org.kuali.rice.kew.help.HelpEntry; |
| 33 |
|
import org.kuali.rice.kew.help.service.HelpService; |
| 34 |
|
import org.kuali.rice.kew.service.KEWServiceLocator; |
| 35 |
|
import org.kuali.rice.kew.util.KEWConstants; |
| 36 |
|
import org.kuali.rice.kew.web.KewKualiAction; |
| 37 |
|
import org.kuali.rice.kns.util.GlobalVariables; |
| 38 |
|
import org.kuali.rice.kns.util.KNSConstants; |
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
@see |
| 45 |
|
@see |
| 46 |
|
|
| 47 |
|
@author |
| 48 |
|
|
|
|
|
| 0% |
Uncovered Elements: 86 (86) |
Complexity: 19 |
Complexity Density: 0.3 |
|
| 49 |
|
public class HelpAction extends KewKualiAction { |
| 50 |
|
private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(HelpAction.class); |
| 51 |
|
private static final String HELP_ID_KEY = "helpId"; |
| 52 |
|
private static final String ID_INVALID = "helpentry.id.invalid"; |
| 53 |
|
|
| 54 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 55 |
0
|
public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {... |
| 56 |
0
|
HelpForm helpForm = (HelpForm) form; |
| 57 |
0
|
HelpEntry helpEntry = helpForm.getHelpEntry(); |
| 58 |
0
|
getHelpService().save(helpEntry); |
| 59 |
0
|
GlobalVariables.getMessageMap().putInfo(KNSConstants.GLOBAL_MESSAGES, "helpentry.saved"); |
| 60 |
0
|
return mapping.findForward("summary"); |
| 61 |
|
} |
| 62 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
| 63 |
0
|
public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception{... |
| 64 |
0
|
HelpForm helpForm=(HelpForm)form; |
| 65 |
0
|
HelpEntry helpEntry=helpForm.getHelpEntry(); |
| 66 |
0
|
LOG.info(helpEntry.getHelpName()); |
| 67 |
0
|
getHelpService().delete(helpEntry); |
| 68 |
0
|
helpForm.setShowDelete("no"); |
| 69 |
0
|
GlobalVariables.getMessageMap().putInfo(KNSConstants.GLOBAL_MESSAGES, "helpentry.deleted"); |
| 70 |
0
|
return mapping.findForward("delete"); |
| 71 |
|
} |
| 72 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 73 |
0
|
public ActionForward getSearch (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {... |
| 74 |
0
|
LOG.debug("getSearch"); |
| 75 |
0
|
HelpForm helpForm = (HelpForm) form; |
| 76 |
|
|
| 77 |
0
|
helpForm.setIsAdmin(false); |
| 78 |
0
|
return mapping.findForward("getSearch"); |
| 79 |
|
} |
| 80 |
|
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 6 |
Complexity Density: 0.55 |
|
| 81 |
0
|
public ActionForward search (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {... |
| 82 |
0
|
HelpForm helpForm = (HelpForm) form; |
| 83 |
0
|
HelpEntry helpEntry = helpForm.getHelpEntry(); |
| 84 |
0
|
if(helpForm.getHelpId() != null && !StringUtils.isNumeric(helpForm.getHelpId())){ |
| 85 |
0
|
GlobalVariables.getMessageMap().putError(HELP_ID_KEY, ID_INVALID); |
| 86 |
|
} else { |
| 87 |
0
|
if (helpForm.getHelpId() != null) { |
| 88 |
0
|
helpEntry.setHelpId(new Long(helpForm.getHelpId())); |
| 89 |
|
} |
| 90 |
|
} |
| 91 |
|
|
| 92 |
0
|
List searchResults = getHelpService().search(helpEntry); |
| 93 |
|
|
| 94 |
0
|
if(searchResults != null && searchResults.size() > 0){ |
| 95 |
0
|
request.setAttribute("reqSearchResults", searchResults); |
| 96 |
|
} |
| 97 |
|
|
| 98 |
0
|
helpForm.setIsAdmin(false); |
| 99 |
|
|
| 100 |
0
|
return mapping.findForward("getSearch"); |
| 101 |
|
} |
| 102 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
| 103 |
0
|
public ActionForward clearSearch (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {... |
| 104 |
0
|
HelpForm helpForm = (HelpForm) form; |
| 105 |
0
|
helpForm.getHelpEntry().setHelpId(null); |
| 106 |
0
|
helpForm.getHelpEntry().setHelpName(null); |
| 107 |
0
|
helpForm.getHelpEntry().setHelpText(null); |
| 108 |
0
|
request.setAttribute("reqSearchResults", null); |
| 109 |
|
|
| 110 |
0
|
helpForm.setIsAdmin(false); |
| 111 |
0
|
return mapping.findForward("getSearch"); |
| 112 |
|
} |
| 113 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 114 |
0
|
public ActionForward report(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {... |
| 115 |
0
|
HelpForm helpForm = (HelpForm) form; |
| 116 |
0
|
helpForm.setHelpEntry(getHelpService().findById(new Long(request.getParameter("helpId")))); |
| 117 |
0
|
return mapping.findForward("report"); |
| 118 |
|
} |
| 119 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 120 |
0
|
public ActionForward showEdit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {... |
| 121 |
0
|
HelpForm helpForm = (HelpForm) form; |
| 122 |
0
|
if(helpForm.getHelpEntry().getHelpId() == null){ |
| 123 |
0
|
Long helpId = new Long(request.getParameter("helpId")); |
| 124 |
0
|
helpForm.setHelpEntry(getHelpService().findById(helpId)); |
| 125 |
|
} |
| 126 |
0
|
return mapping.findForward("basic"); |
| 127 |
|
} |
| 128 |
|
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 129 |
0
|
public ActionForward showDelete(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception{... |
| 130 |
0
|
HelpForm helpForm=(HelpForm)form; |
| 131 |
0
|
if(helpForm.getHelpEntry().getHelpId()==null){ |
| 132 |
0
|
Long helpId=new Long(request.getParameter("helpId")); |
| 133 |
0
|
helpForm.setHelpEntry(getHelpService().findById(helpId)); |
| 134 |
|
} |
| 135 |
|
|
| 136 |
0
|
helpForm.setIsAdmin(false); |
| 137 |
0
|
return mapping.findForward("delete"); |
| 138 |
|
} |
| 139 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 140 |
0
|
private HelpService getHelpService(){... |
| 141 |
0
|
return (HelpService) KEWServiceLocator.getService(KEWServiceLocator.HELP_SERVICE); |
| 142 |
|
} |
| 143 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 144 |
0
|
public ActionForward getHelpEntry(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {... |
| 145 |
0
|
HelpForm helpForm = (HelpForm) form; |
| 146 |
0
|
String helpKey = request.getParameter("helpKey"); |
| 147 |
0
|
helpForm.setHelpEntry(getHelpService().findByKey(helpKey)); |
| 148 |
0
|
helpForm.setShowEdit(KEWConstants.NO_LABEL); |
| 149 |
0
|
return mapping.findForward("popHelp"); |
| 150 |
|
} |
| 151 |
|
|
| 152 |
|
|
| 153 |
|
|
| 154 |
|
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 2 |
Complexity Density: 0.22 |
|
| 155 |
0
|
public ActionForward export(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {... |
| 156 |
0
|
HelpForm helpForm = (HelpForm) form; |
| 157 |
0
|
HelpEntry helpEntry = helpForm.getHelpEntry(); |
| 158 |
0
|
List searchResults = getHelpService().search(helpEntry); |
| 159 |
0
|
if(searchResults == null) { |
| 160 |
0
|
searchResults = new ArrayList(); |
| 161 |
|
} |
| 162 |
|
|
| 163 |
0
|
KewExportDataSet dataSet = new KewExportDataSet(); |
| 164 |
0
|
dataSet.getHelp().addAll(searchResults); |
| 165 |
0
|
request.getSession().setAttribute(ExportServlet.EXPORT_DATA_SET_KEY, dataSet); |
| 166 |
0
|
return new ActionForward(ExportServlet.generateExportPath(request, dataSet.createExportDataSet()), true); |
| 167 |
|
} |
| 168 |
|
|
| 169 |
|
} |