Java tutorial
/* * Copyright 2016 OPEN TONE Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jp.co.opentone.bsol.linkbinder.view; import jp.co.opentone.bsol.framework.core.ProcessContext; import jp.co.opentone.bsol.framework.core.config.SystemConfig; import jp.co.opentone.bsol.framework.core.exception.ReflectionRuntimeException; import jp.co.opentone.bsol.framework.core.message.Message; import jp.co.opentone.bsol.framework.core.message.Messages; import jp.co.opentone.bsol.framework.core.service.ServiceAbortException; import jp.co.opentone.bsol.framework.core.util.ArgumentValidator; import jp.co.opentone.bsol.framework.core.util.DateUtil; import jp.co.opentone.bsol.framework.web.extension.jsf.FacesHelper; import jp.co.opentone.bsol.framework.web.extension.jsf.annotation.Transfer; import jp.co.opentone.bsol.framework.web.view.action.ServiceActionHandler; import jp.co.opentone.bsol.framework.web.view.flash.Flash; import jp.co.opentone.bsol.framework.web.view.util.ViewHelper; import jp.co.opentone.bsol.linkbinder.Constants; import jp.co.opentone.bsol.linkbinder.action.AbstractAction; import jp.co.opentone.bsol.linkbinder.dto.Correspon; import jp.co.opentone.bsol.linkbinder.dto.LoginUserInfo; import jp.co.opentone.bsol.linkbinder.dto.Project; import jp.co.opentone.bsol.linkbinder.dto.ProjectCustomSetting; import jp.co.opentone.bsol.linkbinder.dto.ProjectUser; import jp.co.opentone.bsol.linkbinder.dto.User; import jp.co.opentone.bsol.linkbinder.dto.Workflow; import jp.co.opentone.bsol.linkbinder.dto.code.CorresponStatus; import jp.co.opentone.bsol.linkbinder.dto.code.ForLearning; import jp.co.opentone.bsol.linkbinder.dto.condition.AbstractCondition; import jp.co.opentone.bsol.linkbinder.dto.condition.SearchCorresponCondition; import jp.co.opentone.bsol.linkbinder.dto.condition.SearchFullTextSearchCorresponCondition; import jp.co.opentone.bsol.linkbinder.dto.condition.SearchUserCondition; import jp.co.opentone.bsol.linkbinder.event.EventBus; import jp.co.opentone.bsol.linkbinder.message.ApplicationMessageCode; import jp.co.opentone.bsol.linkbinder.service.UserPermissionHelper; import jp.co.opentone.bsol.linkbinder.service.UserRoleHelper; import jp.co.opentone.bsol.linkbinder.service.WorkflowHelper; import jp.co.opentone.bsol.linkbinder.service.admin.ProjectCustomSettingService; import jp.co.opentone.bsol.linkbinder.service.admin.UserService; import org.apache.commons.beanutils.PropertyUtils; import org.apache.commons.lang.StringUtils; import javax.annotation.PostConstruct; import javax.annotation.Resource; import javax.faces.context.FacesContext; import javax.servlet.http.HttpServletRequest; import java.io.Serializable; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.text.SimpleDateFormat; import java.util.HashMap; import java.util.List; import java.util.Map; /** * Page?. * @author opentone */ public abstract class AbstractPage implements LinkBinderPage, Serializable { /** * SerialVersionID. */ private static final long serialVersionUID = 8042658538697619215L; /** * ????. */ public static final String DEFAULT_ACTION_NAME = "Initialize"; /** * ????. */ public static final String PREVIOUS = "<<"; /** * ???. */ public static final String NEXT = ">>"; /** * ""?????. * @return "" */ public String getLearningContentsLabel() { return SystemConfig.getValue(Constants.KEY_LEARNING_CONTENTS_LABEL); } /** * ""?????. * @return "" */ public String getLearningCorresponLabel() { return SystemConfig.getValue(Constants.KEY_LEARNING_CORRESPON_LABEL); } /** * ???ManagedBean. */ @Resource private LoginUserInfoHolder loginUserInfoHolder; /** * ???ID. */ private String loginProjectId; /** * . */ @Resource private User currentUser; /** * ???. * <p> * Service???????????! * </p> */ @Resource //CHECKSTYLE:OFF protected ServiceActionHandler handler; //CHECKSTYLE:ON /** * view????. */ @Resource //CHECKSTYLE:OFF protected ViewHelper viewHelper; //CHECKSTYLE:ON /** * ???????. */ @Resource private UserPermissionHelper userPermissionHelper; /** * ??????. */ @Resource private UserRoleHelper userRoleHelper; /** * ?????. */ @Resource private WorkflowHelper workflowHelper; /** * ?. */ @Resource private UserService userService; /** * ?. */ @Resource private ProjectCustomSettingService projectCustomSettingService; @Resource protected EventBus eventBus; /** * ???????. */ private boolean transferNext; /** * SystemAdmin. */ private boolean systemAdmin; /** * ProjectAdmin. */ private boolean projectAdmin; /** * GroupAdmin. */ private boolean groupAdmin; /** * ???/?GroupAdmin. */ private boolean anyGroupAdmin; /** * ??. */ private List<Workflow> displayWorkflowList; /** * ID. */ private String projectId; /** * ???ID. */ private Long corresponGroupId; /** * ?????. */ private String actionName; /** * ???. */ public AbstractPage() { } /** * ???. */ @PostConstruct public final void afterInstanciated() { setUpLoginProjectId(); setHeaderInfoToFlash(); setActionName(DEFAULT_ACTION_NAME); // ?ActionHandler? handler.setUser(currentUser); // ??? Map<String, Object> values = new HashMap<String, Object>(); values.put(Constants.KEY_PROJECT, getCurrentProject()); // URL HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext() .getRequest(); if (request != null) { values.put(Constants.KEY_BASE_URL, viewHelper.getBasePath()); values.put(Constants.KEY_CONTEXT_URL, request.getContextPath()); } handler.setActionContextValues(values); } /** * ?????. */ @Override public final void setUp() { setHeaderInfoToFlash(); } public void setHeaderInfoToFlash() { LoginUserInfo info; if (StringUtils.isNotEmpty(loginProjectId)) { info = loginUserInfoHolder.getLoginProjectUserInfo(loginProjectId); } else { info = loginUserInfoHolder.getLoginUserInfo(); } setHeaderInfoToFlash(info); } public void setHeaderInfoToFlash(LoginUserInfo info) { if (info == null) { return; } javax.faces.context.Flash f = viewHelper.getExternalContext().getFlash(); if (info.getLoginProject() != null) { f.putNow("projectId", info.getLoginProject().getProjectId()); f.putNow("projectNameE", info.getLoginProject().getNameE()); f.putNow("projectClientNameE", info.getLoginProject().getClientNameE()); } else { f.putNow("projectId", null); f.putNow("projectNameE", null); f.putNow("projectClientNameE", null); } if (info.getLoginUser() != null) { f.putNow("userId", info.getLoginUser().getUserId()); f.putNow("userLabel", info.getLoginUser().getLabel()); } } private void setUpLoginProjectId() { FacesHelper h = new FacesHelper(FacesContext.getCurrentInstance()); if (h.isGetRequest()) { String id = (String) viewHelper.getExternalContext().getRequestParameterMap().get("projectId"); setLoginProjectId(id); } } /** * ???URL???. * * * @param path ??? * @return ?? */ public String toUrl(String path) { return toUrl(path, true); } /** * ???URL???. * ????ID?. * * @param path ?? * @param withProjectId URL?ID???true * @return ?? */ public String toUrl(String path, boolean withProjectId) { // path?null???????? if (path == null) { return path; } if (!withProjectId || containsProjectId(path)) { return path; } StringBuilder result = new StringBuilder(path); result.append(path.indexOf('?') != -1 ? '&' : '?'); String pjId = getCurrentProjectId(); if (StringUtils.isEmpty(pjId)) { pjId = loginProjectId; } result.append("projectId=").append(pjId); return result.toString(); } private boolean containsProjectId(String path) { return path.matches(".*projectId=.*"); } /** * ???actionName??????true?. * @param action * ??. submit?value * @return actionName??????true */ public boolean isActionInvoked(String action) { HttpServletRequest req = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext() .getRequest(); if (isPartialAjax()) { return StringUtils.equals(action, req.getParameter("javax.faces.source")); } else { return StringUtils.isNotEmpty(req.getParameter(action)); } } /** * ???JSF2?Ajax?Partial Request???true?. * @return Partial Request???true */ public boolean isPartialAjax() { String value = ((HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest()) .getParameter("javax.faces.partial.ajax"); return Boolean.parseBoolean(value); } public EventBus getEventBus() { return eventBus; } /** * ???bean???. * @return bean?? */ public String getBeanName() { String name = this.getClass().getSimpleName(); return name.substring(0, 1).toLowerCase() + name.substring(1); } /** * @return the viewHelper */ public ViewHelper getViewHelper() { return viewHelper; } /** * @param viewHelper * the viewHelper to set */ public void setViewHelper(ViewHelper viewHelper) { this.viewHelper = viewHelper; } public ServiceActionHandler getHandler() { return handler; } public void setHandler(ServiceActionHandler handler) { this.handler = handler; } /* * (non-Javadoc) * @see jp.co.opentone.bsol.framework.view.Page#isTransferNext() */ public boolean isTransferNext() { return transferNext; } /* * (non-Javadoc) * @see jp.co.opentone.bsol.framework.view.Page#setTransferNext(boolean) */ public void setTransferNext(boolean transferNext) { this.transferNext = transferNext; if (transferNext) { // ??????Flash?? Map<String, Object> values = collectTransferValues(); Flash flash = new Flash(); if (isTransferNext()) { flash.setValue(KEY_TRANSFER, values); } } } private Map<String, Object> collectTransferValues() { Map<String, Object> values = new HashMap<String, Object>(); for (Field field : getClass().getDeclaredFields()) { if (field.isAnnotationPresent(Transfer.class)) { field.setAccessible(true); try { Object value = field.get(this); if (value != null) { values.put(field.getName(), field.get(this)); } } catch (IllegalArgumentException e) { throw new ReflectionRuntimeException(e); } catch (IllegalAccessException e) { throw new ReflectionRuntimeException(e); } } } return values; } /** * ???ID?. * <p> * ????????<code>null</code>????. * </p> * @return ID */ public String getCurrentProjectId() { Project p = getCurrentProject(); if (p != null) { return p.getProjectId(); } return null; } /** * ????. * <p> * ????????<code>null</code>????. * </p> * @return */ public Project getCurrentProject() { String p = getLoginProjectId(); if (StringUtils.isEmpty(p)) { return null; } return loginUserInfoHolder.getLoginProjectInfo(p); } /** * ???Use Person in Charge??. * ???? * defualtValue??Use Person in Charge??. * @return Person in Charge??? */ public boolean isUsePersonInCharge() { if (getCurrentProject() != null) { if (getCurrentProject().getProjectCustomSetting() != null) { return getCurrentProject().getProjectCustomSetting().isUsePersonInCharge(); } } return ProjectCustomSetting.DEFAULT_USE_PERSON_IN_CHARGE; } /** * ???Default Status??. * ???? * defualtValue??Default Status??. * @return Person in Charge??? */ public CorresponStatus getDefaultStatus() { if (getCurrentProject() != null) { if (getCurrentProject().getProjectCustomSetting() != null) { return getCurrentProject().getProjectCustomSetting().getDefaultStatus(); } } return ProjectCustomSetting.DEFAULT_CORRESPON_STATUS; } public boolean isLearningProject() { Project project = getCurrentProject(); if (project != null) { if (ForLearning.LEARNING.equals(project.getForLearning())) { return true; } } return false; } /** * ??????true?. * @return ????true */ public boolean isUseLearning() { return getCurrentUser().isUseLearning(); } /** * ????????true?. * @return */ public boolean isProjectUseLearning() { Project p = getCurrentProject(); if (p != null && p.getProjectCustomSetting() != null) { return p.getProjectCustomSetting().isUseLearning(); } return false; } /** * ??????????. * <p> * ????????<code>null</code>????. * </p> * @return */ public ProjectUser getCurrentProjectUser() { return loginUserInfoHolder.getLoginUserInfo(getLoginProjectId()); } /** * @param currentUser * the currentUser to set */ public void setCurrentUser(User currentUser) { this.currentUser = currentUser; } /** * @return the currentUser */ public User getCurrentUser() { return currentUser; } /** * ?System Admin??????true. * @return System Admin??????true????false */ public boolean isSystemAdmin() { handler.handleAction(new SystemAdminAction(this)); return systemAdmin; } /** * ??????Project Admin??????true. * @param checkProjectId * ID * @return Project Admin??????true????false */ public boolean isProjectAdmin(String checkProjectId) { if (StringUtils.isEmpty(checkProjectId)) { return false; } projectId = checkProjectId; handler.handleAction(new ProjectAdminAction(this)); return projectAdmin; } /** * ????????Group Admin??????true. * @param groupId * ???ID * @return Group Admin??????true????false */ public boolean isGroupAdmin(Long groupId) { ArgumentValidator.validateNotNull(groupId); corresponGroupId = groupId; handler.handleAction(new GroupAdminAction(this)); return groupAdmin; } /** * ???/???Group Admin???? * ???????true?. * @param c * ? * @return ?Group Admin???????????true */ public boolean isAnyGroupAdmin(Correspon c) { ArgumentValidator.validateNotNull(c); handler.handleAction(new AnyGroupAdminAction(this, c)); return anyGroupAdmin; } /** * ???Group Admin???????????. * * @param checkProjectId ID * @return ?Group Admin???????????true */ public boolean isAnyGroupAdmin(String checkProjectId) { ArgumentValidator.validateNotNull(checkProjectId); return getUserPermissionHelper().isAnyGroupAdmin(checkProjectId); } /** * ??????????. * @return ??????true */ public boolean isProjectSelected() { return getCurrentProjectId() != null; } /** * ???????. * ??????????. * @throws ServiceAbortException ??????? */ public void checkProjectSelected() throws ServiceAbortException { if (!isProjectSelected()) { throw new ServiceAbortException( ApplicationMessageCode.CANNOT_PERFORM_BECAUSE_ACCESS_LEVEL_INSUFFICIENT); } } /** * ???. * @param messageKey ?KEY * @param object ? */ public void setNextPageMessage(String messageKey, Object... object) { Flash flash = new Flash(); Message message = Messages.getMessage(messageKey, object); flash.setValue(KEY_FLASH_MASSAGE, viewHelper.createFacesMessage(message)); } /** * ???. * @param messageKey ?KEY * @param object ? */ public void setPageMessage(String messageKey, Object... object) { ProcessContext pc = ProcessContext.getCurrentContext(); pc.clearMessages(); pc.addMessage(messageKey, object); } private LoginUserInfo getCurrentLoginUserInfo() { if (loginUserInfoHolder == null) { return null; } LoginUserInfo info; if (StringUtils.isNotEmpty(loginProjectId)) { info = loginUserInfoHolder.getLoginProjectUserInfo(loginProjectId); } else { info = loginUserInfoHolder.getLoginUserInfo(); } return info; } /** * ????. * @param condition ? */ public void setNextSearchCondition(AbstractCondition condition) { LoginUserInfo info = getCurrentLoginUserInfo(); if (info != null) { info.setValue(createSearchConditionKey(condition), condition); } } private String createSearchConditionKey(AbstractCondition condition) { return condition != null ? createSearchConditionKey(condition.getClass()) : KEY_SEARCH_CONDITION; } private String createSearchConditionKey(Class<? extends AbstractCondition> clazz) { return KEY_SEARCH_CONDITION + "_" + clazz.getSimpleName(); } /** * ????. * @param clazz ??? * @return ? */ public AbstractCondition getPreviousSearchCondition(Class<? extends AbstractCondition> clazz) { LoginUserInfo info = getCurrentLoginUserInfo(); if (info != null) { Object result = info.getValue(createSearchConditionKey(clazz)); if (result != null && result.getClass().isAssignableFrom(clazz)) { return (AbstractCondition) result; } } return null; } /** * ????????. * @return ?? */ public SearchCorresponCondition getCurrentSearchCorresponCondition() { if (StringUtils.isNotEmpty(loginProjectId)) { LoginUserInfo info = loginUserInfoHolder.getLoginProjectUserInfo(loginProjectId); if (info != null) { return (SearchCorresponCondition) info.getValue(Constants.KEY_SEARCH_CORRESPON_CONDITION); } } return null; } /** * ?????. * <p> * loginProjectId??????? * @param condition ?? */ public void setCurrentSearchCorresponCondition(SearchCorresponCondition condition) { setCurrentSearchCorresponCondition(condition, loginProjectId); } /** * ?????. * @param condition ?? * @param selectedProjectId ID */ public void setCurrentSearchCorresponCondition(SearchCorresponCondition condition, String selectedProjectId) { if (StringUtils.isNotEmpty(selectedProjectId)) { LoginUserInfo info = loginUserInfoHolder.getLoginProjectUserInfo(selectedProjectId); if (info != null) { info.setValue(Constants.KEY_SEARCH_CORRESPON_CONDITION, condition); } } } /** * ???????. * @return ?? */ public SearchFullTextSearchCorresponCondition getCurrentSearchFullTextSearchCorresponCondition() { if (StringUtils.isNotEmpty(loginProjectId)) { LoginUserInfo info = loginUserInfoHolder.getLoginProjectUserInfo(loginProjectId); if (info != null) { return (SearchFullTextSearchCorresponCondition) info .getValue(Constants.KEY_SEARCH_FULL_TEXT_SEARCH_CORRESPON_CONDTION); } } return null; } /** * ?????. * @param condition ?? */ public void setCurrentSearchFullTextSearchCorresponCondition(SearchFullTextSearchCorresponCondition condition) { if (StringUtils.isNotEmpty(loginProjectId)) { LoginUserInfo info = loginUserInfoHolder.getLoginProjectUserInfo(loginProjectId); if (info != null) { info.setValue(Constants.KEY_SEARCH_FULL_TEXT_SEARCH_CORRESPON_CONDTION, condition); } } } /** * CurrentProject?CurrentProjectUser???. * @param project */ public void setCurrentProjectInfo(Project project) { handler.handleAction(new SetCurrentProjectAction(this, project)); } /** * @param actionName * the actionName to set */ public void setActionName(String actionName) { this.actionName = actionName; } /** * @return the actionName */ public String getActionName() { return actionName; } /** * ?actionName???. * @return actionName */ public String getRequestedActionName() { HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext() .getRequest(); if (request == null) { return ""; } String result = request.getParameter("form:actionName"); if (result == null) { return ""; } return result; } /** * ?????. * @return ?? */ public String createFileName() { return new SimpleDateFormat("yyyyMMddHHmmss").format(DateUtil.getNow()); } /** * ??????. * @return ???? */ public String getPreviousLabel() { return PREVIOUS; } /** * ?????. * @return ??? */ public String getNextLabel() { return NEXT; } /** * ?????????????. * @param condition ? * @return ?? */ public AbstractCondition cloneToAllRowCondition(AbstractCondition condition) { AbstractCondition clone = null; try { clone = condition.getClass().getConstructor().newInstance(); PropertyUtils.copyProperties(clone, condition); //? clone.setPageNo(1); clone.setPageRowNum(Integer.MAX_VALUE); } catch (NoSuchMethodException e) { throw new ReflectionRuntimeException(e); } catch (IllegalArgumentException e) { throw new ReflectionRuntimeException(e); } catch (SecurityException e) { throw new ReflectionRuntimeException(e); } catch (InstantiationException e) { throw new ReflectionRuntimeException(e); } catch (IllegalAccessException e) { throw new ReflectionRuntimeException(e); } catch (InvocationTargetException e) { throw new ReflectionRuntimeException(e); } return clone; } /** * ???????. * ???????????. * @param object * @return ?? */ public Object cloneToObject(Object object) { Object clone = null; try { clone = object.getClass().getConstructor().newInstance(); PropertyUtils.copyProperties(clone, object); } catch (NoSuchMethodException e) { throw new ReflectionRuntimeException(e); } catch (IllegalArgumentException e) { throw new ReflectionRuntimeException(e); } catch (SecurityException e) { throw new ReflectionRuntimeException(e); } catch (InstantiationException e) { throw new ReflectionRuntimeException(e); } catch (IllegalAccessException e) { throw new ReflectionRuntimeException(e); } catch (InvocationTargetException e) { throw new ReflectionRuntimeException(e); } return clone; } /** * @return the userPermissionHelper */ public UserPermissionHelper getUserPermissionHelper() { return userPermissionHelper; } /** * @return the userRoleHelper */ public UserRoleHelper getUserRoleHelper() { return userRoleHelper; } public List<Workflow> createDisplayWorkflowList(Correspon correspon) { ArgumentValidator.validateNotNull(correspon); handler.handleAction(new CreateDisplayWorkflowListAction(this, correspon)); return displayWorkflowList; } public List<Workflow> createDisplayWorkflowList(User preparer, List<Workflow> workflows) { ArgumentValidator.validateNotNull(preparer); ArgumentValidator.validateNotNull(workflows); Correspon c = new Correspon(); c.setCreatedBy(preparer); c.setWorkflows(workflows); handler.handleAction(new CreateDisplayWorkflowListAction(this, c)); return displayWorkflowList; } /** * @param loginUserInfoHolder the loginUserInfoHolder to set */ public void setLoginUserInfoHolder(LoginUserInfoHolder loginUserInfoHolder) { this.loginUserInfoHolder = loginUserInfoHolder; } /** * @return the loginUserInfoHolder */ public LoginUserInfoHolder getLoginUserInfoHolder() { return loginUserInfoHolder; } /** * @param loginProjectId the loginProjectId to set */ public void setLoginProjectId(String loginProjectId) { this.loginProjectId = loginProjectId; } /** * @return the loginProjectId */ public String getLoginProjectId() { return loginProjectId; } /** * ???. * * @return ?:true */ public boolean isLoginProject() { if (StringUtils.isNotEmpty(loginProjectId)) { return true; } return false; } static class SystemAdminAction extends AbstractAction { /** * SerialVersionUID. */ private static final long serialVersionUID = -6342245885831727090L; /** ??. */ private AbstractPage page; public SystemAdminAction(AbstractPage page) { super(page); this.page = page; } /* * (non-Javadoc) * @see jp.co.opentone.bsol.framework.action.Action#execute() */ public void execute() throws ServiceAbortException { page.systemAdmin = page.getUserPermissionHelper().isSystemAdmin(page.currentUser); } } static class ProjectAdminAction extends AbstractAction { /** * SerialVersionUID. */ private static final long serialVersionUID = 1909154663217521352L; /** ??. */ private AbstractPage page; public ProjectAdminAction(AbstractPage page) { super(page); this.page = page; } /* * (non-Javadoc) * @see jp.co.opentone.bsol.framework.action.Action#execute() */ public void execute() throws ServiceAbortException { page.projectAdmin = page.getUserPermissionHelper().isProjectAdmin(page.currentUser, page.projectId); } } static class GroupAdminAction extends AbstractAction { /** * SerialVersionUID. */ private static final long serialVersionUID = -2416142075620249874L; /** ??. */ private AbstractPage page; public GroupAdminAction(AbstractPage page) { super(page); this.page = page; } /* * (non-Javadoc) * @see jp.co.opentone.bsol.framework.action.Action#execute() */ public void execute() throws ServiceAbortException { page.groupAdmin = page.getUserPermissionHelper().isGroupAdmin(page.currentUser, page.corresponGroupId); } } static class AnyGroupAdminAction extends AbstractAction { /** * SerialVersionUID. */ private static final long serialVersionUID = 3410090289269928398L; /** ??. */ private AbstractPage page; /** ?. */ private Correspon c; public AnyGroupAdminAction(AbstractPage page, Correspon c) { super(page); this.page = page; this.c = c; } /* * (non-Javadoc) * @see jp.co.opentone.bsol.framework.action.Action#execute() */ public void execute() throws ServiceAbortException { page.anyGroupAdmin = page.getUserPermissionHelper().isAnyGroupAdmin(c); } } /** * CurrentProject?CurrentProjectUser?. * @author opentone */ static class SetCurrentProjectAction extends AbstractAction { /** * SerialVersionUID. */ private static final long serialVersionUID = -7699429985264318982L; /** ??. */ private AbstractPage page; /** . */ private Project project; public SetCurrentProjectAction(AbstractPage page, Project project) { super(page); this.page = page; this.project = project; } /* * (non-Javadoc) * @see jp.co.opentone.bsol.framework.action.Action#execute() */ public void execute() throws ServiceAbortException { // ? project.setProjectCustomSetting(page.projectCustomSettingService.find(project.getProjectId(), false)); SearchUserCondition condition = new SearchUserCondition(); condition.setProjectId(project.getProjectId()); condition.setEmpNo(page.getCurrentUser().getEmpNo()); ProjectUser pu = null; List<ProjectUser> list = page.userService.search(condition); if (list.size() > 0) { pu = list.get(0); } try { addLoginProjectInfo(page.currentUser, project, pu); } catch (IllegalUserLoginException e) { throw new ServiceAbortException("Invalid user", e, ApplicationMessageCode.INVALID_USER); } } private void addLoginProjectInfo(User user, Project p, ProjectUser pu) throws IllegalUserLoginException { LoginUserInfo info = new LoginUserInfo(); info.setLoginUser(user); info.setLoginProject(p); info.setProjectUser(pu); page.loginUserInfoHolder.addLoginProject(info); } } /** * Project?. * @author opentone */ static class ClearCurrentProjectAction extends AbstractAction { /** * SerialVersionUID. */ private static final long serialVersionUID = -3225783751851640016L; /** ??. */ private AbstractPage page; public ClearCurrentProjectAction(AbstractPage page) { super(page); this.page = page; } /* * (non-Javadoc) * @see jp.co.opentone.bsol.framework.action.Action#execute() */ public void execute() throws ServiceAbortException { page.viewHelper.removeSessionValue(Constants.KEY_PROJECT); page.viewHelper.removeSessionValue(Constants.KEY_PROJECT_USER); page.viewHelper.removeSessionValue(Constants.KEY_SEARCH_CORRESPON_CONDITION); page.viewHelper.removeSessionValue(Constants.KEY_SEARCH_FULL_TEXT_SEARCH_CORRESPON_CONDTION); } } static class CreateDisplayWorkflowListAction extends AbstractAction { /** * SerialVersionUID. */ private static final long serialVersionUID = -624113434207894144L; /** ??. */ private AbstractPage page; /** ?. */ private Correspon c; public CreateDisplayWorkflowListAction(AbstractPage page, Correspon c) { super(page); this.page = page; this.c = c; } /* * (non-Javadoc) * @see jp.co.opentone.bsol.framework.action.Action#execute() */ public void execute() throws ServiceAbortException { page.displayWorkflowList = page.workflowHelper.createWorkflowListWithPreparer(c); } } }