/**
   * @see RadiologyObsFormController#saveObs(HttpServletRequest, HttpServletResponse, String,
   *     RadiologyOrder, Obs Obs, BindingResult)
   */
  @Test
  @Verifies(
      value = "should populate model and view with obs occuring thrown APIException",
      method =
          "saveObs(HttpServletRequest, HttpServletResponse, String, RadiologyOrder, Obs Obs, BindingResult)")
  public void saveObs_ShouldPopulateModelAndViewWithObsOccuringThrownAPIException()
      throws Exception {

    MockHttpSession mockSession = new MockHttpSession();
    MockMultipartHttpServletRequest mockRequest = new MockMultipartHttpServletRequest();
    mockRequest.addParameter("editReason", "Test Edit Reason");
    mockRequest.setSession(mockSession);

    when(obsErrors.hasErrors()).thenReturn(false);
    mockObs.setConcept(new Concept());
    final String fileName = "test.txt";
    final byte[] content = "Hello World".getBytes();
    MockMultipartFile mockMultipartFile =
        new MockMultipartFile("complexDataFile", fileName, "text/plain", content);

    mockRequest.addFile(mockMultipartFile);
    APIException apiException = new APIException("Test Exception Handling");
    when(obsService.saveObs(mockObs, "Test Edit Reason")).thenThrow(apiException);
    ModelAndView modelAndView =
        radiologyObsFormController.saveObs(
            mockRequest, null, "Test Edit Reason", mockRadiologyOrder, mockObs, obsErrors);
    assertThat(modelAndView.getViewName(), is("module/radiology/radiologyObsForm"));
    assertNotNull(modelAndView);

    assertThat(modelAndView.getModelMap(), hasKey("obs"));
    Obs obs = (Obs) modelAndView.getModelMap().get("obs");
    assertThat(obs, is(mockObs));
  }
  @RequestMapping("/update")
  public ModelAndView updatePaytype(
      String id, HttpServletResponse response, HttpServletRequest request) throws Exception {
    ModelAndView view = new ModelAndView();
    Report report = reportLogService.findById(id);
    User user = SessionUtils.getUser(request);
    if (user != null && user.getCompany() != null) {
      List<PayGroup> payGroups = tmsService.findAllPageGroups(user.getCompany().getId());
      view.getModelMap().put("payGroupList", payGroups);
    }
    view.getModelMap().put("reportTypeList", ReportType.values());
    List<String> pagings = new ArrayList<String>();
    pagings.add("Postion");
    pagings.add("Employee");
    view.getModelMap().put("pagingList", pagings);

    List<String> sorts = new ArrayList<String>();
    sorts.add("surname");
    sorts.add("Firstname");
    sorts.add("Employee No");
    view.getModelMap().put("sortList", sorts);
    view.getModel().put("report", new ReportVo(report));
    view.setViewName("admin/report/savereport");
    return view;
  }
  @RequestMapping(value = "/reason/{feeling}")
  public ModelAndView reason(@PathVariable("feeling") String feeling) {

    ModelAndView model = new ModelAndView("index2");

    model.getModelMap().put("reason", service.getReasonForMood(feeling));

    model.getModelMap().put("success", 0);

    return model;
  }
  /**
   * Tests that a blank form can be retrieved.
   *
   * @throws Exception
   */
  @Test
  public void testAddRecord() throws Exception {
    login("admin", "password", new String[] {Role.ADMIN});

    request.setMethod("GET");
    request.setRequestURI("/bdrs/user/singleSiteMultiTaxa.htm");
    request.setParameter("surveyId", survey.getId().toString());

    ModelAndView mv = handle(request, response);
    ModelAndViewAssert.assertViewName(mv, "singleSiteMultiTaxa");
    ModelAndViewAssert.assertModelAttributeAvailable(mv, "record");
    ModelAndViewAssert.assertModelAttributeAvailable(mv, "survey");
    ModelAndViewAssert.assertModelAttributeAvailable(mv, "preview");
    ModelAndViewAssert.assertModelAttributeAvailable(mv, "formFieldList");
    ModelAndViewAssert.assertModelAttributeAvailable(mv, "sightingRowFormFieldList");

    for (FormField formField : ((List<FormField>) mv.getModelMap().get("formFieldList"))) {
      if (formField.isAttributeFormField()) {
        Assert.assertEquals(
            AttributeScope.SURVEY,
            ((RecordAttributeFormField) formField).getAttribute().getScope());
      } else if (formField.isPropertyFormField()) {
        String propertyName = ((RecordPropertyFormField) formField).getPropertyName();
        // It should not be either the species or the number
        Assert.assertFalse(Record.RECORD_PROPERTY_SPECIES.equals(propertyName));
        Assert.assertFalse(Record.RECORD_PROPERTY_NUMBER.equals(propertyName));
      } else {
        Assert.assertTrue(false);
      }
    }

    for (FormField formField :
        ((List<FormField>) mv.getModelMap().get("sightingRowFormFieldList"))) {
      if (formField.isAttributeFormField()) {
        Assert.assertFalse(
            AttributeScope.SURVEY.equals(
                ((RecordAttributeFormField) formField).getAttribute().getScope()));
      } else if (formField.isPropertyFormField()) {
        String propertyName = ((RecordPropertyFormField) formField).getPropertyName();
        // It should not be either the species or the number
        Assert.assertTrue(
            Record.RECORD_PROPERTY_SPECIES.equals(propertyName)
                || Record.RECORD_PROPERTY_NUMBER.equals(propertyName));
      } else {
        Assert.assertTrue(false);
      }
    }
  }
  @Override
  public void freePlanList(ModelAndView mav) {
    Map<String, Object> map = mav.getModelMap();
    HttpServletRequest request = (HttpServletRequest) map.get("request");

    String member_number = request.getParameter("member_number");
    //		HomeAspect.logger.info(HomeAspect.logMsg+member_number);

    List<String> countryList = null;
    int check = 0;
    // 로그인을 했을 경우 회원의 자유일정이 이전에 등록했었는지 확인한다.
    if (!member_number.equals("")) {
      // schedule 테이블에 자유여행 일정이 이미 등록되어있다면 자유여행 일정을 생성하지 못 한다. 삭제 후 일정 생성 가능.
      check = freePlanDao.freePlanGetSchedule(Integer.parseInt(member_number));
      //			HomeAspect.logger.info(HomeAspect.logMsg+check);

      if (check == 0) {
        // 국가명 list를 받아오기 전에 개수를 확인한다.
        int count = freePlanDao.freePlanCtrNum();
        //				HomeAspect.logger.info(HomeAspect.logMsg+count);

        if (count > 0) {
          countryList = freePlanDao.freePlanCtrList();
          //					HomeAspect.logger.info(HomeAspect.logMsg+countryList.size());
        }
      }
    }

    mav.addObject("check", check);
    mav.addObject("countryList", countryList);
    mav.setViewName("freeplan/freePlanList");
  }
  @Override
  public void freePlanSchedule(ModelAndView mav) {
    Map<String, Object> map = mav.getModelMap();
    HttpServletRequest request = (HttpServletRequest) map.get("request");

    // 클릭된 도시명과 국가명을 전달 받는다.
    String cityName = request.getParameter("cityName");
    String ctrName = request.getParameter("ctrName");
    //		HomeAspect.logger.info(HomeAspect.logMsg+cityName+","+ctrName);

    int count = freePlanDao.freePlanSelectCityNum(cityName);
    //		HomeAspect.logger.info(HomeAspect.logMsg+count);

    List<FreePlanDto> freePlanList = null;
    List<String> freePlanCityNameList = null;
    if (count > 0) {
      // cityName(도시)에 속한 모든 장소 정보를 받는다.
      freePlanList = freePlanDao.freePlanSelectCityList(cityName);
      // ctrName(국가)에 cityName를 제외한 도시명을 받는다.
      freePlanCityNameList = freePlanDao.freePlanCityNameList(ctrName, cityName);
      //
      //	HomeAspect.logger.info(HomeAspect.logMsg+freePlanList.size()+","+freePlanCityNameList.size());
    }

    mav.addObject("ctrName", ctrName);
    mav.addObject("freePlanCityNameList", freePlanCityNameList);
    mav.addObject("freePlanList", freePlanList);
    mav.setViewName("freeplan/freePlanSchedule");
  }
Example #7
0
 /**
  * 获取AAA列表
  *
  * @param acId acId
  * @return ModelAndView
  */
 @RequestMapping("/weblist")
 public ModelAndView webList(final String acId) {
   ModelAndView t_view = BaseDispatcherServlet.getModeAndView();
   t_view.getModelMap().put(S_AC_ID, acId);
   t_view.setViewName("wirelessconfig/acother/web_list");
   return t_view;
 }
  /** @see RadiologyObsFormController#getObs(Order, Obs) */
  @Test
  @Verifies(
      value = "should populate model and view with obs for given obs and given valid order",
      method = "getObs(Order, Obs)")
  public void getObs_shouldPopulateModelAndViewWithObsForGivenObsAndGivenValidOrder()
      throws Exception {

    ModelAndView modelAndView = radiologyObsFormController.getObs(mockRadiologyOrder, mockObs);

    assertNotNull(modelAndView);
    assertThat(modelAndView.getViewName(), is("module/radiology/radiologyObsForm"));

    assertThat(modelAndView.getModelMap(), hasKey("obs"));
    Obs obs = (Obs) modelAndView.getModelMap().get("obs");
    assertThat(obs, is(mockObs));
  }
  /**
   * @see RadiologyDashboardController#getRadiologyOrdersForPatient(Patient)
   * @verifies return model and view populated with an empty list of radiology orders if given
   *     patient is unknown
   */
  @Test
  public void
      getRadiologyOrdersForPatient_shouldReturnModelAndViewPopulatedWithAnEmptyListOfRadiologyOrdersIfGivenPatientIsUnknown()
          throws Exception {

    ModelAndView modelAndView =
        radiologyDashboardController.getRadiologyOrdersForPatient(invalidPatient);

    assertNotNull(modelAndView);
    assertTrue(
        modelAndView.getViewName().equals("/module/radiology/portlets/radiologyDashboardTab"));

    assertThat(modelAndView.getModelMap(), hasKey("radiologyOrders"));
    ArrayList<RadiologyOrder> radiologyOrders =
        (ArrayList<RadiologyOrder>) modelAndView.getModelMap().get("radiologyOrders");
    assertThat(radiologyOrders, is(empty()));
  }
Example #10
0
 @RequestMapping(value = "/admin/addUser.html", method = RequestMethod.GET)
 public ModelAndView addUser() {
   ModelAndView modelAndView = new ModelAndView();
   ModelMap modelMap = modelAndView.getModelMap();
   modelMap.put(ROLE, UserRole.values());
   modelAndView.setViewName(createUser);
   return modelAndView;
 }
 @Test
 public void souldReturnCorrectPartialValueInModel() {
   setUpPlayerProfile();
   boolean expectedPartialValue = true;
   final ModelAndView mainProfilePage =
       underTest.getMainProfilePage(modelMap, request, response, expectedPartialValue);
   assertModelMapContainsPartialValue(expectedPartialValue, mainProfilePage.getModelMap());
 }
Example #12
0
  /**
   * 获取AAA列表
   *
   * @param acId acId
   * @return ModelAndView
   * @throws ContainerException ContainerException
   * @throws ServiceException ServiceException
   */
  @RequestMapping("/userauthlist")
  public ModelAndView userAuthList(final String acId) throws ServiceException, ContainerException {
    ModelAndView t_view = BaseDispatcherServlet.getModeAndView();
    t_view.getModelMap().put(S_AC_ID, acId);
    List<AAAWebWlanOptions> t_wlanOptions = new ArrayList<AAAWebWlanOptions>();
    List<RadiusServerPojo> t_radiusList = new ArrayList<RadiusServerPojo>();
    try {
      t_radiusList = getIAAAService(acId).getRadiusServers();
      t_view.getModelMap().put("radiusList", toJson(t_radiusList));
      t_wlanOptions = getIAAAWebService(acId).getWlanOptions();
    } catch (NoConnMsgException t_e) {
      S_LOGGER.error("NoConnMsgException when userAuthList", t_e);
    }

    t_view.getModelMap().put("wlanOptions", toJson(t_wlanOptions));
    t_view.setViewName("wirelessconfig/acother/user_auth_list");
    return t_view;
  }
 @RequestMapping("/processUserRegister")
 public ModelAndView registerUser(@ModelAttribute("newUser") Account newUser) {
   // System.out.println(newUser);
   // logger.info("HEY LOOK");
   ModelAndView mav = new ModelAndView();
   // INSERT CODE TO VALIDATE SERVERSIDE
   // INSERT CODE TO SAVE TO DATABASE
   // LOG IN
   // EMAIL CONFIRMATION
   // SHOWINFORMATION
   mav.getModelMap().addAttribute("username", newUser.getUsername());
   mav.getModelMap().addAttribute("nickname", newUser.getNickname());
   mav.getModelMap().addAttribute("email", newUser.getEmail());
   mav.getModelMap().addAttribute("website", newUser.getWebsite());
   mav.setViewName("pages/testpages/output");
   // mav.setViewName("pages/register");
   return mav;
 }
  /** @see RadiologyObsFormController#getNewObs(Order) */
  @Test
  @Verifies(
      value = "should populate model and view with new obs given a valid order",
      method = "getNewObs(Order)")
  public void getNewObs_shouldPopulateModelAndViewWithNewObsGivenAValidOrder() throws Exception {

    ModelAndView modelAndView = radiologyObsFormController.getNewObs(mockRadiologyOrder);

    assertNotNull(modelAndView);
    assertThat(modelAndView.getViewName(), is("module/radiology/radiologyObsForm"));

    assertThat(modelAndView.getModelMap(), hasKey("obs"));
    Obs obs = (Obs) modelAndView.getModelMap().get("obs");

    assertNotNull(obs.getOrder());
    assertThat((RadiologyOrder) obs.getOrder(), is(mockRadiologyOrder));
    assertThat(obs.getPerson(), is((Person) mockRadiologyOrder.getPatient()));
  }
 @RequestMapping("/regIncomingUser")
 public ModelAndView register() {
   System.out.println("LOOK-----------------------------------");
   ModelAndView mav = new ModelAndView();
   mav.getModelMap().addAttribute("newUser", new Account());
   mav.setViewName("pages/testpages/output");
   // mav.setViewName("pages/register");
   return mav;
 }
  @RequestMapping("/condition")
  public ModelAndView condition(
      ReportType type, HttpServletResponse response, HttpServletRequest request) throws Exception {
    ModelAndView view = new ModelAndView();

    User user = SessionUtils.getUser(request);
    if (user != null && user.getCompany() != null) {
      List<PayGroup> payGroups = tmsService.findAllPageGroups(user.getCompany().getId());
      view.getModelMap().put("payGroupList", payGroups);
    }

    if (ReportType.TimeCardReport.getName().equals(type.getName())) {
      view.setViewName("admin/report/timecard");
    }

    if (ReportType.TimeCardDetailsReport.getName().equals(type.getName())) {
      view.setViewName("admin/report/timecarddetails");
    }
    if (ReportType.EmployeesListReport.getName().equals(type.getName())) {
      view.setViewName("admin/report/employeelist");
    }
    if (ReportType.ExceptionsReport.getName().equals(type.getName())) {
      view.getModelMap().put("types", ExcetpitonTypes.values());
      view.setViewName("admin/report/exceptions");
    }
    if (ReportType.OnsiteReport.getName().equals(type.getName())) {
      view.setViewName("admin/report/onsite");
    }
    if (ReportType.LeaveReport.getName().equals(type.getName())) {
      view.setViewName("admin/report/leave");
    }
    if (ReportType.JobHoursSummaryReport.getName().equals(type.getName())) {
      view.setViewName("admin/report/jobhourssummary");
    }
    if (ReportType.JobHoursDetailsReport.getName().equals(type.getName())) {
      view.setViewName("admin/report/jobhoursdetails");
    }
    if (ReportType.AuditingReport.getName().equals(type.getName())) {
      view.setViewName("admin/report/auditing");
    }

    return view;
  }
Example #17
0
  @RequestMapping(value = "/admin/updateUser.html", method = RequestMethod.GET)
  public ModelAndView ajaxUpdateUser(String guid) {
    User currentUser = userService.findUserByGuid(guid);
    ModelAndView modelAndView = new ModelAndView(userInfo);
    ModelMap modelMap = modelAndView.getModelMap();
    modelMap.put(USER, currentUser);
    modelMap.put(ROLE, UserRole.values());

    return modelAndView;
  }
Example #18
0
 @RequestMapping(
     value = "/programme.pdf",
     method = RequestMethod.GET,
     produces = "application/pdf")
 protected ModelAndView programme(@RequestParam(defaultValue = "false") boolean a3)
     throws Exception {
   ModelAndView model = new ModelAndView("pdfViewResolver", "data", service.getData());
   model.getModelMap().put("modeA3", a3);
   return model;
 }
  @Test
  public void shouldReturnPersonListView() {
    ModelAndView mav = personController.listPeople();
    assertEquals("list", mav.getViewName());

    @SuppressWarnings("unchecked")
    List<Person> people = (List<Person>) mav.getModelMap().get("people");
    assertNotNull(people);
    assertEquals(DataInitializer.PERSON_COUNT, people.size());
  }
  @Test
  public void resolveExceptionShouldSetCountries() {
    long maxUploadSize = 1000;
    setUpPlayerProfile();

    final ModelAndView modelAndViewUnderTest =
        underTest.resolveException(
            request, response, null, new MaxUploadSizeExceededException(maxUploadSize));
    assertSame(
        countryRepository.getCountries(), modelAndViewUnderTest.getModelMap().get("countries"));
  }
  @Test
  public void resolveExceptionShouldSetGender() {
    long maxUploadSize = 1000;
    setUpPlayerProfile();

    final ModelAndView modelAndViewUnderTest =
        underTest.resolveException(
            request, response, null, new MaxUploadSizeExceededException(maxUploadSize));
    assertThat(
        genderRepository.getGenders(),
        is(equalTo(modelAndViewUnderTest.getModelMap().get("genders"))));
  }
Example #22
0
  @Override
  public void postHandle(
      HttpServletRequest request,
      HttpServletResponse response,
      Object handler,
      ModelAndView modelAndView)
      throws Exception {
    try {
      if (modelAndView != null) {
        Context context = (Context) request.getAttribute("context");

        if (!modelAndView.getModelMap().containsAttribute("context")) {
          modelAndView.getModelMap().addAttribute("context", context);
        }
        if (!modelAndView.getModelMap().containsAttribute("user")) {
          modelAndView.getModelMap().addAttribute("user", context.getUser());
        }
      }
    } catch (Exception e) {
    }
  }
Example #23
0
 /**
  * 获取AAA列表数据,用于刷新页面
  *
  * @param acId acId
  * @return ModelAndView
  * @throws ContainerException ContainerException
  * @throws ServiceException ServiceException
  */
 @RequestMapping("/getaaalist")
 public ModelAndView getAAAList(final String acId) throws ServiceException, ContainerException {
   ModelAndView t_view = BaseDispatcherServlet.getModeAndView();
   List<RadiusServerPojo> t_Radius = null;
   try {
     t_Radius = getIAAAService(acId).getRadiusServers();
   } catch (NoConnMsgException t_e) {
     S_LOGGER.error("NoConnMsgException when getAAAList", t_e);
   }
   t_view.getModelMap().put("aaaList", t_Radius);
   return t_view;
 }
  /**
   * @see RadiologyObsFormController#saveObs(HttpServletRequest, HttpServletResponse, String,
   *     RadiologyOrder, Obs Obs, BindingResult)
   */
  @Test
  @Verifies(
      value = "should return populated model and view if edit reason is null and obs id not null",
      method =
          "saveObs(HttpServletRequest, HttpServletResponse, String, RadiologyOrder, Obs Obs, BindingResult)")
  public void saveObs_shouldReturnPopulatedModelAndViewIfEditReasonIsNullAndObsIdNotNull() {

    MockHttpSession mockSession = new MockHttpSession();
    mockRequest.addParameter("saveObs", "saveObs");
    mockRequest.setSession(mockSession);

    when(obsErrors.hasErrors()).thenReturn(false);

    ModelAndView modelAndView =
        radiologyObsFormController.saveObs(
            mockRequest, null, null, mockRadiologyOrder, mockObs, obsErrors);

    assertThat(modelAndView.getViewName(), is("module/radiology/radiologyObsForm"));
    assertThat(modelAndView.getModelMap(), hasKey("obs"));
    Obs obs = (Obs) modelAndView.getModelMap().get("obs");
    assertThat(obs, is(mockObs));
  }
Example #25
0
 /**
  * 获取AAA列表
  *
  * @param acId acId
  * @return ModelAndView
  * @throws ContainerException ContainerException
  * @throws ServiceException ServiceException
  */
 @RequestMapping("/aaalist")
 public ModelAndView aAAList(final String acId) throws ServiceException, ContainerException {
   ModelAndView t_view = BaseDispatcherServlet.getModeAndView();
   List<RadiusServerPojo> t_Radius = null;
   try {
     t_Radius = getIAAAService(acId).getRadiusServers();
   } catch (NoConnMsgException t_e) {
     S_LOGGER.error("NoConnMsgException when aAAList", t_e);
   }
   t_view.getModelMap().put("aaaList", t_Radius);
   t_view.getModelMap().put(S_AC_ID, acId);
   t_view.setViewName("wirelessconfig/acother/aaa_list");
   return t_view;
 }
Example #26
0
  @RequestMapping(value = "/admin/index.html", method = RequestMethod.GET)
  public ModelAndView index() {

    ModelAndView modelAndView = new ModelAndView(index);
    ModelMap modelMap = modelAndView.getModelMap();

    List<User> users = userService.findAllUsers();
    Account account = accountService.findLatestRecord();
    int totalIncome = incomeService.getTotal();

    List<Food> dishes = foodService.findAllFoods();

    Payment todayPayment = paymentService.getPaymentOfToday();

    List<FoodType> catagorys = foodTypeService.findAllFoodTypes();
    Map<String, List<Food>> map = new HashMap<String, List<Food>>();

    for (FoodType type : catagorys) {
      List<Food> foods = foodService.findFoodByType(type.getGuid());
      if (foods.size() > 0) {
        map.put(type.getName(), foods);
      }
    }

    modelMap.put(USERS, users);

    if (account != null) {
      modelMap.put(REMAINDER, account.getRemainder());
    }

    modelMap.put(INCOMETOTAL, totalIncome);

    modelMap.put(DISHES, dishes);
    modelMap.put(CATAGORYS, map);

    if (todayPayment != null) {
      modelMap.put(TODAYCONSUME, todayPayment.getAmount());
    }

    List<String> contentPages = new ArrayList<String>();
    contentPages.add(dashboard + JSPSUFFIX);
    contentPages.add(userManage + JSPSUFFIX);
    contentPages.add(dishManage + JSPSUFFIX);
    modelMap.put(CONTENTPAGE, contentPages);

    List<StepBean> emptyStepBean = Collections.emptyList();
    modelMap.put(STEPS, emptyStepBean);

    return modelAndView;
  }
  /**
   * Tests that additional rows can be retrieved. This is normally done via ajax.
   *
   * @throws Exception
   */
  @Test
  public void testAjaxAddSightingRow() throws Exception {
    login("admin", "password", new String[] {Role.ADMIN});

    request.setMethod("GET");
    request.setRequestURI("/bdrs/user/singleSiteMultiTaxa/sightingRow.htm");

    Map<String, String> param = new HashMap<String, String>();
    param.put("surveyId", survey.getId().toString());
    // Try 3 requests
    for (int i = 0; i < 3; i++) {
      param.put("sightingIndex", new Integer(i).toString());

      request.setParameters(param);

      ModelAndView mv = handle(request, response);
      ModelAndViewAssert.assertViewName(mv, "singleSiteMultiTaxaRow");

      String expectedPrefix = String.format(SingleSiteMultiTaxaController.PREFIX_TEMPLATE, i);
      ModelAndViewAssert.assertModelAttributeAvailable(mv, "formFieldList");
      for (FormField formField : ((List<FormField>) mv.getModelMap().get("formFieldList"))) {
        if (formField.isAttributeFormField()) {

          RecordAttributeFormField attributeField = (RecordAttributeFormField) formField;
          Assert.assertEquals(expectedPrefix, attributeField.getPrefix());
          Assert.assertNull(attributeField.getRecord().getId());
          Assert.assertEquals(survey, attributeField.getSurvey());

          Assert.assertFalse(
              AttributeScope.SURVEY.equals(attributeField.getAttribute().getScope()));

        } else if (formField.isPropertyFormField()) {

          RecordPropertyFormField propertyField = (RecordPropertyFormField) formField;
          Assert.assertEquals(expectedPrefix, propertyField.getPrefix());
          Assert.assertNull(propertyField.getRecord().getId());
          Assert.assertEquals(survey, propertyField.getSurvey());

          Assert.assertTrue(
              Record.RECORD_PROPERTY_SPECIES.equals(propertyField.getPropertyName())
                  || Record.RECORD_PROPERTY_NUMBER.equals(propertyField.getPropertyName()));

        } else {

          Assert.assertTrue(false);
        }
      }
    }
  }
  @RequestMapping(value = "AddComputer", method = RequestMethod.POST)
  public ModelAndView postAddComputer(
      @ModelAttribute("dto") @Valid ComputerDTO computerDTO,
      BindingResult result,
      @RequestParam("company") String companyIdString)
      throws ServletException, IOException {

    setCompanyToDto(companyIdString, computerDTO);

    ModelAndView mav = new ModelAndView();

    long companyId = UsefulFunctions.stringToLong(companyIdString, 0);

    Company company = null;
    if (companyId != 0) {
      company = companyServices.getCompany(companyId);
    }

    /* Validation case */
    if (!result.hasErrors()) {
      Computer neoComputer = computerMapper.dtoToObject(computerDTO, company);
      long id = computerServices.insert(neoComputer);
      if (id >= 0) {
        mav.getModelMap().addAttribute("message", "add");
        mav.getModelMap().addAttribute("computerIdMessage", id);
        mav.setViewName("redirect:DashBoard");
      }
      /* Error case */
    } else {
      allCompany = companyServices.getAllCompanies();
      mav.getModelMap().addAttribute("allCompany", allCompany);
      mav.getModelMap().addAttribute("error", result.hasErrors());
      mav.setViewName("addComputer");
    }
    return mav;
  }
Example #29
0
  @RequestMapping(value = "/admin/login.html", method = RequestMethod.POST)
  public ModelAndView loginIn(HttpSession session, String username, String password) {

    ModelAndView target = new ModelAndView();

    if (isValidUser(username, password)) {
      session.setAttribute(USERNAME, username);
      target = index();
    } else {
      ModelMap modelMap = target.getModelMap();
      modelMap.put(ERRORMSG, "用户名或密码错误");
      target.setViewName(login);
    }
    return target;
  }
  /**
   * Delete a client
   *
   * @param id
   * @param modelAndView
   * @return
   */
  @PreAuthorize("hasRole('ROLE_ADMIN')")
  @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
  public String apiDeleteClient(@PathVariable("id") Long id, ModelAndView modelAndView) {

    ClientDetailsEntity client = clientService.getClientById(id);

    if (client == null) {
      logger.error("apiDeleteClient failed; client with id " + id + " could not be found.");
      modelAndView.getModelMap().put("code", HttpStatus.NOT_FOUND);
      modelAndView
          .getModelMap()
          .put(
              "errorMessage",
              "Could not delete client. The requested client with id "
                  + id
                  + "could not be found.");
      return "jsonErrorView";
    } else {
      modelAndView.getModelMap().put("code", HttpStatus.OK);
      clientService.deleteClient(client);
    }

    return "httpCodeView";
  }