@Test public final void testPreProcessNextTab() { HttpServletRequest aReq = new MockHttpServletRequest(); TargetManager targetManager = new MockTargetManager(testFile); testInstance.setTargetManager(targetManager); testInstance.setAuthorityManager(new AuthorityManagerImpl()); testInstance.setPatternFactory(new SpringSchedulePatternFactory()); Target target = targetManager.load(4000L); AbstractTargetEditorContext targetEditorContext = new AbstractTargetEditorContext(target,true); aReq.getSession().setAttribute(TabbedTargetController.EDITOR_CONTEXT, targetEditorContext); HttpServletResponse aResp = new MockHttpServletResponse(); TargetSchedulesCommand aCmd = new TargetSchedulesCommand(); TabbedController tc = new TabbedTargetController(); TabConfig tabConfig = new TabConfig(); tabConfig.setViewName("target"); List<Tab> tabs = getTabList(targetManager); tabConfig.setTabs(tabs); tc.setTabConfig(tabConfig); tc.setDefaultCommandClass(org.webcurator.ui.target.command.TargetDefaultCommand.class); Tab currentTab = tabs.get(1); aCmd.setHarvestNow(true); BindException aErrors = new BindException(aCmd, "TargetSchedulesCommand"); testInstance.setContextSessionKey(TabbedTargetController.EDITOR_CONTEXT); ModelAndView mav = testInstance.preProcessNextTab(tc, currentTab, aReq, aResp, aCmd, aErrors); assertTrue(mav != null); }
public TabbedModelAndView preProcessNextTab(TabbedController tc, Tab nextTabID, HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) { AbstractTargetEditorContext editorContext = getEditorContext(req); AbstractTarget abstractTarget = editorContext.getAbstractTarget(); if (!abstractTarget.isAnnotationsSet()) { abstractTarget.setAnnotations(targetManager.getAnnotations(abstractTarget)); } String alertText = ""; int count=0; for (Annotation ann: abstractTarget.getAnnotations()) { if (ann.isAlertable()) { count++; alertText+=(count+": "+ann.getNote()+"\n"); } } TabbedModelAndView tmav = tc.new TabbedModelAndView(); tmav.addObject("schedules", editorContext.getSortedSchedules()); tmav.addObject("patternMap", patternFactory.getPatternMap()); tmav.addObject("privilegeString", privilegeString); tmav.addObject("editMode", editorContext.isEditMode()); tmav.addObject("abstractTarget", abstractTarget); tmav.addObject("editControllerUrl", editControllerUrl); tmav.addObject("alertText", alertText); if(abstractTarget.getObjectType() == AbstractTarget.TYPE_TARGET) { if(abstractTarget.getOid()!=null) { Target target = targetManager.load(abstractTarget.getOid()); tmav.addObject("allowOptimize", target.isAllowOptimize()); } } return tmav; }
TargetSchedulesHandler extends TabHandler { public TabbedModelAndView preProcessNextTab(TabbedController tc, Tab nextTabID, HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) { AbstractTargetEditorContext editorContext = getEditorContext(req); AbstractTarget abstractTarget = editorContext.getAbstractTarget(); if (!abstractTarget.isAnnotationsSet()) { abstractTarget.setAnnotations(targetManager.getAnnotations(abstractTarget)); } String alertText = ""; int count=0; for (Annotation ann: abstractTarget.getAnnotations()) { if (ann.isAlertable()) { count++; alertText+=(count+": "+ann.getNote()+"\n"); } } TabbedModelAndView tmav = tc.new TabbedModelAndView(); tmav.addObject("schedules", editorContext.getSortedSchedules()); tmav.addObject("patternMap", patternFactory.getPatternMap()); tmav.addObject("privilegeString", privilegeString); tmav.addObject("editMode", editorContext.isEditMode()); tmav.addObject("abstractTarget", abstractTarget); tmav.addObject("editControllerUrl", editControllerUrl); tmav.addObject("alertText", alertText); if(abstractTarget.getObjectType() == AbstractTarget.TYPE_TARGET) { if(abstractTarget.getOid()!=null) { Target target = targetManager.load(abstractTarget.getOid()); tmav.addObject("allowOptimize", target.isAllowOptimize()); } } return tmav; } }
TargetSchedulesHandler extends TabHandler { public TabbedModelAndView preProcessNextTab(TabbedController tc, Tab nextTabID, HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) { AbstractTargetEditorContext editorContext = getEditorContext(req); AbstractTarget abstractTarget = editorContext.getAbstractTarget(); if (!abstractTarget.isAnnotationsSet()) { abstractTarget.setAnnotations(targetManager.getAnnotations(abstractTarget)); } String alertText = ""; int count=0; for (Annotation ann: abstractTarget.getAnnotations()) { if (ann.isAlertable()) { count++; alertText+=(count+": "+ann.getNote()+"\n"); } } TabbedModelAndView tmav = tc.new TabbedModelAndView(); tmav.addObject("schedules", editorContext.getSortedSchedules()); tmav.addObject("patternMap", patternFactory.getPatternMap()); tmav.addObject("privilegeString", privilegeString); tmav.addObject("editMode", editorContext.isEditMode()); tmav.addObject("abstractTarget", abstractTarget); tmav.addObject("editControllerUrl", editControllerUrl); tmav.addObject("alertText", alertText); if(abstractTarget.getObjectType() == AbstractTarget.TYPE_TARGET) { if(abstractTarget.getOid()!=null) { Target target = targetManager.load(abstractTarget.getOid()); tmav.addObject("allowOptimize", target.isAllowOptimize()); } } return tmav; }  }
TargetSchedulesHandler extends TabHandler { public TabbedModelAndView preProcessNextTab(TabbedController tc, Tab nextTabID, HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) { AbstractTargetEditorContext editorContext = getEditorContext(req); AbstractTarget abstractTarget = editorContext.getAbstractTarget(); if (!abstractTarget.isAnnotationsSet()) { abstractTarget.setAnnotations(targetManager.getAnnotations(abstractTarget)); } String alertText = ""; int count=0; for (Annotation ann: abstractTarget.getAnnotations()) { if (ann.isAlertable()) { count++; alertText+=(count+": "+ann.getNote()+"\n"); } } TabbedModelAndView tmav = tc.new TabbedModelAndView(); tmav.addObject("schedules", editorContext.getSortedSchedules()); tmav.addObject("patternMap", patternFactory.getPatternMap()); tmav.addObject("privilegeString", privilegeString); tmav.addObject("editMode", editorContext.isEditMode()); tmav.addObject("abstractTarget", abstractTarget); tmav.addObject("editControllerUrl", editControllerUrl); tmav.addObject("alertText", alertText); if(abstractTarget.getObjectType() == AbstractTarget.TYPE_TARGET) { if(abstractTarget.getOid()!=null) { Target target = targetManager.load(abstractTarget.getOid()); tmav.addObject("allowOptimize", target.isAllowOptimize()); } } return tmav; }  AbstractTargetEditorContext getEditorContext(HttpServletRequest req); void setPatternFactory(SchedulePatternFactory patternFactory); @Override void initBinder(HttpServletRequest request, ServletRequestDataBinder binder); void processTab(TabbedController tc, Tab currentTab,
			HttpServletRequest req, HttpServletResponse res, Object comm,
			BindException errors); TabbedModelAndView preProcessNextTab(TabbedController tc,
			Tab nextTabID, HttpServletRequest req, HttpServletResponse res,
			Object comm, BindException errors); ModelAndView processOther(TabbedController tc, Tab currentTab,
			HttpServletRequest req, HttpServletResponse res, Object comm,
			BindException errors); void setBusinessObjectFactory(BusinessObjectFactory businessObjectFactory); void setAuthorityManager(AuthorityManager authorityManager); void setTargetManager(TargetManager targetManager); String getContextSessionKey(); void setContextSessionKey(String contextSessionKey); String getPrivilegeString(); void setPrivilegeString(String privilegeString); void setEditControllerUrl(String editControllerUrl); }
TargetSchedulesHandler extends TabHandler { public TabbedModelAndView preProcessNextTab(TabbedController tc, Tab nextTabID, HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) { AbstractTargetEditorContext editorContext = getEditorContext(req); AbstractTarget abstractTarget = editorContext.getAbstractTarget(); if (!abstractTarget.isAnnotationsSet()) { abstractTarget.setAnnotations(targetManager.getAnnotations(abstractTarget)); } String alertText = ""; int count=0; for (Annotation ann: abstractTarget.getAnnotations()) { if (ann.isAlertable()) { count++; alertText+=(count+": "+ann.getNote()+"\n"); } } TabbedModelAndView tmav = tc.new TabbedModelAndView(); tmav.addObject("schedules", editorContext.getSortedSchedules()); tmav.addObject("patternMap", patternFactory.getPatternMap()); tmav.addObject("privilegeString", privilegeString); tmav.addObject("editMode", editorContext.isEditMode()); tmav.addObject("abstractTarget", abstractTarget); tmav.addObject("editControllerUrl", editControllerUrl); tmav.addObject("alertText", alertText); if(abstractTarget.getObjectType() == AbstractTarget.TYPE_TARGET) { if(abstractTarget.getOid()!=null) { Target target = targetManager.load(abstractTarget.getOid()); tmav.addObject("allowOptimize", target.isAllowOptimize()); } } return tmav; }  AbstractTargetEditorContext getEditorContext(HttpServletRequest req); void setPatternFactory(SchedulePatternFactory patternFactory); @Override void initBinder(HttpServletRequest request, ServletRequestDataBinder binder); void processTab(TabbedController tc, Tab currentTab,
			HttpServletRequest req, HttpServletResponse res, Object comm,
			BindException errors); TabbedModelAndView preProcessNextTab(TabbedController tc,
			Tab nextTabID, HttpServletRequest req, HttpServletResponse res,
			Object comm, BindException errors); ModelAndView processOther(TabbedController tc, Tab currentTab,
			HttpServletRequest req, HttpServletResponse res, Object comm,
			BindException errors); void setBusinessObjectFactory(BusinessObjectFactory businessObjectFactory); void setAuthorityManager(AuthorityManager authorityManager); void setTargetManager(TargetManager targetManager); String getContextSessionKey(); void setContextSessionKey(String contextSessionKey); String getPrivilegeString(); void setPrivilegeString(String privilegeString); void setEditControllerUrl(String editControllerUrl);  }