List of usage examples for java.lang Short toString
public String toString()
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccOracle.CFAccOracleAccountEntryTable.java
public CFAccCursor openAccountEntryCursorByDrCcyIdx(CFAccAuthorization Authorization, Short DebitCurrencyId) { String sql = getSqlSelectAccountEntryBuff() + "WHERE " + ((DebitCurrencyId == null) ? "acny.debit_ccyid is null " : "acny.debit_ccyid = " + DebitCurrencyId.toString() + " ") + "ORDER BY " + "acny.TenantId ASC" + ", " + "acny.AccountId ASC" + ", " + "acny.EntryId ASC"; CFAccCursor cursor = new CFAccOracleCursor(Authorization, schema, sql); return (cursor); }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccOracle.CFAccOracleAccountEntryTable.java
public CFAccCursor openAccountEntryCursorByCrCcyIdx(CFAccAuthorization Authorization, Short CreditCurrencyId) { String sql = getSqlSelectAccountEntryBuff() + "WHERE " + ((CreditCurrencyId == null) ? "acny.credit_ccyid is null " : "acny.credit_ccyid = " + CreditCurrencyId.toString() + " ") + "ORDER BY " + "acny.TenantId ASC" + ", " + "acny.AccountId ASC" + ", " + "acny.EntryId ASC"; CFAccCursor cursor = new CFAccOracleCursor(Authorization, schema, sql); return (cursor); }
From source file:com.jd.survey.web.survey.PrivateSurveyController.java
/** * Updates a survey page /* w w w . j av a2s. co m*/ * @param surveyPage * @param backAction * @param proceedAction * @param bindingResult * @param uiModel * @param principal * @param httpServletRequest * @return */ @Secured({ "ROLE_ADMIN", "ROLE_SURVEY_ADMIN", "ROLE_SURVEY_PARTICIPANT" }) @RequestMapping(method = RequestMethod.POST, produces = "text/html") public String updateSurveyPage(@Valid SurveyPage surveyPage, @RequestParam(value = "_back", required = false) String backAction, @RequestParam(value = "_proceed", required = false) String proceedAction, BindingResult bindingResult, Model uiModel, Principal principal, HttpServletRequest httpServletRequest) { try { String login = principal.getName(); Short order = surveyPage.getOrder(); if (proceedAction != null) { //next button Survey survey = surveyService.survey_findById(surveyPage.getSurvey().getId()); //Check if the user is authorized if (!survey.getLogin().equals(login)) { log.warn(UNAUTHORIZED_ATTEMPT_TO_ACCESS_SURVEY_WARNING_MESSAGE + survey.getId() + REQUEST_PATH_WARNING_MESSAGE + httpServletRequest.getPathInfo() + FROM_USER_LOGIN_WARNING_MESSAGE + principal.getName() + FROM_IP_WARNING_MESSAGE + httpServletRequest.getLocalAddr()); return "accessDenied"; } //Check that the survey was not submitted if (!(survey.getStatus().equals(SurveyStatus.I) || survey.getStatus().equals(SurveyStatus.R))) { log.warn(UNAUTHORIZED_ATTEMPT_TO_EDIT_SUBMITTED_SURVEY_WARNING_MESSAGE + survey.getId() + REQUEST_PATH_WARNING_MESSAGE + httpServletRequest.getPathInfo() + FROM_USER_LOGIN_WARNING_MESSAGE + principal.getName() + FROM_IP_WARNING_MESSAGE + httpServletRequest.getLocalAddr()); return "accessDenied"; } List<SurveyPage> surveyPages = surveyService.surveyPage_getAll(surveyPage.getSurvey().getId(), messageSource.getMessage(DATE_FORMAT, null, LocaleContextHolder.getLocale())); surveyPage.setSurvey(survey); surveyPage = surveyService.surveyPage_updateSettings(surveyPage); //populate the uploaded files MultipartHttpServletRequest multiPartRequest = (MultipartHttpServletRequest) httpServletRequest; Iterator<String> fileNames = multiPartRequest.getFileNames(); while (fileNames.hasNext()) { String fileName = fileNames.next(); Long questionId = Long.parseLong(fileName.toUpperCase().replace("FILE", "")); for (QuestionAnswer questionAnswer : surveyPage.getQuestionAnswers()) { if (questionAnswer.getQuestion().getId().equals(questionId) && multiPartRequest.getFile(fileName).getBytes().length > 0) { questionAnswer.setSurveyDocument(new SurveyDocument(survey.getId(), questionId, multiPartRequest.getFile(fileName).getName(), multiPartRequest.getFile(fileName).getContentType(), multiPartRequest.getFile(fileName).getBytes())); } } } Policy policy = Policy.getInstance(this.getClass().getResource(POLICY_FILE_LOCATION)); AntiSamy as = new AntiSamy(); for (QuestionAnswer questionAnswer : surveyPage.getQuestionAnswers()) { if (questionAnswer.getQuestion().getType().getIsTextInput()) { CleanResults cr = as.scan(questionAnswer.getStringAnswerValue(), policy); questionAnswer.setStringAnswerValue(cr.getCleanHTML()); } } GlobalSettings globalSettings = applicationSettingsService.getSettings(); SurveyPageValidator validator = new SurveyPageValidator( messageSource.getMessage(DATE_FORMAT, null, LocaleContextHolder.getLocale()), globalSettings.getValidContentTypes(), globalSettings.getValidImageTypes(), globalSettings.getMaximunFileSize(), globalSettings.getInvalidContentMessage(), globalSettings.getInvalidFileSizeMessage()); validator.validate(surveyPage, bindingResult); if (bindingResult.hasErrors()) { /* for (ObjectError err :bindingResult.getAllErrors()) { log.info("getObjectName:" + err.getObjectName() + " getCode:" + err.getCode() + " getDefaultMessage:" + err.getDefaultMessage()); log.info("toString:" + err.toString()); } */ uiModel.addAttribute("survey_base_path", "private"); uiModel.addAttribute("survey", survey); uiModel.addAttribute("surveyPage", surveyPage); uiModel.addAttribute("surveyDefinition", surveySettingsService.surveyDefinition_findById(surveyPage.getSurvey().getTypeId())); uiModel.addAttribute("surveyPages", surveyPages); return "surveys/page"; } surveyService.surveyPage_update(surveyPage, messageSource.getMessage(DATE_FORMAT, null, LocaleContextHolder.getLocale())); //get the survey pages from the database again, prvious call updates visibility when there is branching logic surveyPages = surveyService.surveyPage_getAll(surveyPage.getSurvey().getId(), messageSource.getMessage(DATE_FORMAT, null, LocaleContextHolder.getLocale())); order = getNextPageOrder(surveyPages, order); if (order.equals((short) 0)) { //Submit page uiModel.asMap().clear(); return "redirect:/private/submit/" + encodeUrlPathSegment(surveyPage.getSurvey().getId().toString(), httpServletRequest); } else { //go to the next page uiModel.asMap().clear(); return "redirect:/private/" + encodeUrlPathSegment(surveyPage.getSurvey().getId().toString(), httpServletRequest) + "/" + encodeUrlPathSegment(order.toString(), httpServletRequest); } } else {//back button Survey survey = surveyService.survey_findById(surveyPage.getSurvey().getId()); //Check if the user is authorized if (!survey.getLogin().equals(login)) { log.warn(UNAUTHORIZED_ATTEMPT_TO_ACCESS_SURVEY_WARNING_MESSAGE + survey.getId() + REQUEST_PATH_WARNING_MESSAGE + httpServletRequest.getPathInfo() + FROM_USER_LOGIN_WARNING_MESSAGE + principal.getName() + FROM_IP_WARNING_MESSAGE + httpServletRequest.getLocalAddr()); return "accessDenied"; } List<SurveyPage> surveyPages = surveyService.surveyPage_getAll(surveyPage.getSurvey().getId(), messageSource.getMessage(DATE_FORMAT, null, LocaleContextHolder.getLocale())); order = getPreviousPageOrder(surveyPages, order); if (order.equals((short) 0)) { //Go to the surveyEntries page uiModel.asMap().clear(); return "redirect:/private/" + encodeUrlPathSegment(survey.getTypeId().toString(), httpServletRequest) + "?list"; } else { //go to previous page uiModel.asMap().clear(); return "redirect:/private/" + encodeUrlPathSegment(survey.getId().toString(), httpServletRequest) + "/" + encodeUrlPathSegment(order.toString(), httpServletRequest); } } } catch (Exception e) { log.error(e.getMessage(), e); throw (new RuntimeException(e)); } }
From source file:com.jd.survey.web.survey.PublicSurveyController.java
/** * Updates a survey page//ww w. j a v a 2s. c om * @param surveyPage * @param backAction * @param proceedAction * @param bindingResult * @param uiModel * @param httpServletRequest * @return */ @RequestMapping(method = RequestMethod.POST, produces = "text/html") public String updateSurveyPage(@Valid SurveyPage surveyPage, @RequestParam(value = "_back", required = false) String backAction, @RequestParam(value = "_proceed", required = false) String proceedAction, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) { try { Short order = surveyPage.getOrder(); Survey survey = surveyService.survey_findById(surveyPage.getSurvey().getId()); SurveyDefinition surveyDefinition = surveySettingsService.surveyDefinition_findById(survey.getTypeId()); if (!surveyDefinition.getIsPublic()) {//survey definition not open to the public //attempt to access a private survey definition from a public open url log.warn(SURVEY_NOT_PUBLIC_WARNING_MESSAGE + httpServletRequest.getPathInfo() + FROM_IP_WARNING_MESSAGE + httpServletRequest.getLocalAddr()); return "accessDenied"; } //Attempt to access a survey from different IP Address if (!survey.getIpAddress().equalsIgnoreCase(httpServletRequest.getLocalAddr())) { log.warn(UNAUTHORIZED_ATTEMPT_TO_ACCESS_SURVEY_WARNING_MESSAGE + httpServletRequest.getPathInfo() + FROM_IP_WARNING_MESSAGE + httpServletRequest.getLocalAddr()); return "accessDenied"; } if (proceedAction != null) { //next button List<SurveyPage> surveyPages = surveyService.surveyPage_getAll(surveyPage.getSurvey().getId(), messageSource.getMessage(DATE_FORMAT, null, LocaleContextHolder.getLocale())); surveyPage.setOrder(surveyPages.get(surveyPage.getOrder() - 1).getOrder()); surveyPage.setTitle(surveyPages.get(surveyPage.getOrder() - 1).getTitle()); surveyPage.setInstructions(surveyPages.get(surveyPage.getOrder() - 1).getInstructions()); surveyPage.setSurvey(survey); surveyPage = surveyService.surveyPage_updateSettings(surveyPage); //populate the uploaded files MultipartHttpServletRequest multiPartRequest = (MultipartHttpServletRequest) httpServletRequest; Iterator<String> fileNames = multiPartRequest.getFileNames(); while (fileNames.hasNext()) { String fileName = fileNames.next(); Long questionId = Long.parseLong(fileName.toUpperCase().replace("FILE", "")); for (QuestionAnswer questionAnswer : surveyPage.getQuestionAnswers()) { if (questionAnswer.getQuestion().getId().equals(questionId) && multiPartRequest.getFile(fileName).getBytes().length > 0) { questionAnswer.setSurveyDocument(new SurveyDocument(survey.getId(), questionId, multiPartRequest.getFile(fileName).getName(), multiPartRequest.getFile(fileName).getContentType(), multiPartRequest.getFile(fileName).getBytes())); } } } Policy policy = Policy.getInstance(this.getClass().getResource(POLICY_FILE_LOCATION)); AntiSamy as = new AntiSamy(); for (QuestionAnswer questionAnswer : surveyPage.getQuestionAnswers()) { if (questionAnswer.getQuestion().getType().getIsTextInput()) { CleanResults cr = as.scan(questionAnswer.getStringAnswerValue(), policy); questionAnswer.setStringAnswerValue(cr.getCleanHTML()); } } GlobalSettings globalSettings = applicationSettingsService.getSettings(); SurveyPageValidator validator = new SurveyPageValidator( messageSource.getMessage(DATE_FORMAT, null, LocaleContextHolder.getLocale()), globalSettings.getValidContentTypes(), globalSettings.getValidImageTypes(), globalSettings.getMaximunFileSize(), globalSettings.getInvalidContentMessage(), globalSettings.getInvalidFileSizeMessage()); validator.validate(surveyPage, bindingResult); if (bindingResult.hasErrors()) { /* for (ObjectError err :bindingResult.getAllErrors()) { log.info("getObjectName:" + err.getObjectName() + " getCode:" + err.getCode() + " getDefaultMessage:" + err.getDefaultMessage()); log.info("toString:" + err.toString()); } */ uiModel.addAttribute("survey_base_path", "open"); uiModel.addAttribute("survey", survey); uiModel.addAttribute("surveyDefinition", surveySettingsService.surveyDefinition_findById(survey.getTypeId())); uiModel.addAttribute("surveyPage", surveyPage); uiModel.addAttribute("surveyPages", surveyPages); return "surveys/page"; } surveyService.surveyPage_update(surveyPage, messageSource.getMessage(DATE_FORMAT, null, LocaleContextHolder.getLocale())); //get the survey pages from the database again, prvious call updates visibility when there is branching logic surveyPages = surveyService.surveyPage_getAll(surveyPage.getSurvey().getId(), messageSource.getMessage(DATE_FORMAT, null, LocaleContextHolder.getLocale())); order = getNextPageOrder(surveyPages, order); if (order.equals((short) 0)) { //Submit page uiModel.asMap().clear(); return "redirect:/open/submit/" + encodeUrlPathSegment(surveyPage.getSurvey().getId().toString(), httpServletRequest); } else { //go to the next page uiModel.asMap().clear(); return "redirect:/open/" + encodeUrlPathSegment(surveyPage.getSurvey().getId().toString(), httpServletRequest) + "/" + encodeUrlPathSegment(order.toString(), httpServletRequest); } } else {//back button List<SurveyPage> surveyPages = surveyService.surveyPage_getAll(surveyPage.getSurvey().getId(), messageSource.getMessage(DATE_FORMAT, null, LocaleContextHolder.getLocale())); order = getPreviousPageOrder(surveyPages, order); if (order.equals((short) 0)) { //Go to the surveyEntries page uiModel.asMap().clear(); return "redirect:/open/" + encodeUrlPathSegment(survey.getTypeId().toString(), httpServletRequest) + "?list"; } else { //go to previous page uiModel.asMap().clear(); return "redirect:/open/" + encodeUrlPathSegment(survey.getId().toString(), httpServletRequest) + "/" + encodeUrlPathSegment(order.toString(), httpServletRequest); } } } catch (Exception e) { log.error(e.getMessage(), e); throw (new RuntimeException(e)); } }
From source file:com.znsx.cms.service.impl.DeviceManagerImpl.java
@Override public String createControlDevice(String name, String standardNumber, String dasId, String organId, Integer period, String stakeNumber, String longitude, String latitude, Short type, Short subType, String note, String navigation, Integer height, Integer width, Short sectionType, String reserve, String ip, Integer port) { ControlDevice cd = null;/*w w w . ja va 2s . c o m*/ if (type.intValue() == TypeDefinition.DEVICE_TYPE_CMS) { // ? Organ organ = organDAO.findById(organId); if (!organ.getType().equals(TypeDefinition.ORGAN_TYPE_TUNNEL) && !organ.getType().equals(TypeDefinition.ORGAN_TYPE_BRIDGE) && !organ.getType().equals(TypeDefinition.ORGAN_TYPE_ROAD) && !organ.getType().equals(TypeDefinition.ORGAN_TYPE_TOLLGATE)) { throw new BusinessException(ErrorCode.DETECTOR_MAPPING_ORGAN_ERROR, "detector mapping organ ," + type.toString() + ", is error"); } cd = new ControlDeviceCms(); } else if (type.intValue() == TypeDefinition.DEVICE_TYPE_FAN) { // ? Organ organ = organDAO.findById(organId); if (!organ.getType().equals(TypeDefinition.ORGAN_TYPE_TUNNEL)) { throw new BusinessException(ErrorCode.DETECTOR_MAPPING_ORGAN_ERROR, "detector mapping organ ," + type.toString() + ", is error"); } cd = new ControlDeviceFan(); } else if (type.intValue() == TypeDefinition.DEVICE_TYPE_LIGHT) { // ? Organ organ = organDAO.findById(organId); if (!organ.getType().equals(TypeDefinition.ORGAN_TYPE_TUNNEL)) { throw new BusinessException(ErrorCode.DETECTOR_MAPPING_ORGAN_ERROR, "detector mapping organ ," + type.toString() + ", is error"); } cd = new ControlDeviceLight(); } else if (type.intValue() == TypeDefinition.DEVICE_TYPE_RD) { // ? Organ organ = organDAO.findById(organId); if (!organ.getType().equals(TypeDefinition.ORGAN_TYPE_TUNNEL)) { throw new BusinessException(ErrorCode.DETECTOR_MAPPING_ORGAN_ERROR, "detector mapping organ ," + type.toString() + ", is error"); } cd = new ControlDeviceRd(); } else if (type.intValue() == TypeDefinition.DEVICE_TYPE_WP) { // ? Organ organ = organDAO.findById(organId); if (!organ.getType().equals(TypeDefinition.ORGAN_TYPE_TUNNEL)) { throw new BusinessException(ErrorCode.DETECTOR_MAPPING_ORGAN_ERROR, "detector mapping organ ," + type.toString() + ", is error"); } cd = new ControlDeviceWp(); } else if (type.intValue() == TypeDefinition.DEVICE_TYPE_RAIL) { // ? Organ organ = organDAO.findById(organId); if (!organ.getType().equals(TypeDefinition.ORGAN_TYPE_TUNNEL) && !organ.getType().equals(TypeDefinition.ORGAN_TYPE_TOLLGATE)) { throw new BusinessException(ErrorCode.DETECTOR_MAPPING_ORGAN_ERROR, "detector mapping organ ," + type.toString() + ", is error"); } cd = new ControlDeviceRail(); } else if (type.intValue() == TypeDefinition.DEVICE_TYPE_IS) { // ? Organ organ = organDAO.findById(organId); if (!organ.getType().equals(TypeDefinition.ORGAN_TYPE_TUNNEL) && !organ.getType().equals(TypeDefinition.ORGAN_TYPE_ROAD) && !organ.getType().equals(TypeDefinition.ORGAN_TYPE_BRIDGE)) { throw new BusinessException(ErrorCode.DETECTOR_MAPPING_ORGAN_ERROR, "detector mapping organ ," + type.toString() + ", is error"); } cd = new ControlDeviceIs(); } else if (type.intValue() == TypeDefinition.DEVICE_TYPE_TSL) { // ? Organ organ = organDAO.findById(organId); if (!organ.getType().equals(TypeDefinition.ORGAN_TYPE_TUNNEL) && !organ.getType().equals(TypeDefinition.ORGAN_TYPE_ROAD) && !organ.getType().equals(TypeDefinition.ORGAN_TYPE_BRIDGE)) { throw new BusinessException(ErrorCode.DETECTOR_MAPPING_ORGAN_ERROR, "detector mapping organ ," + type.toString() + ", is error"); } cd = new ControlDeviceTsl(); } else if (type.intValue() == TypeDefinition.DEVICE_TYPE_LIL) { // ? Organ organ = organDAO.findById(organId); if (!organ.getType().equals(TypeDefinition.ORGAN_TYPE_TUNNEL) && !organ.getType().equals(TypeDefinition.ORGAN_TYPE_TOLLGATE) && !organ.getType().equals(TypeDefinition.ORGAN_TYPE_ROAD) && !organ.getType().equals(TypeDefinition.ORGAN_TYPE_BRIDGE)) { throw new BusinessException(ErrorCode.DETECTOR_MAPPING_ORGAN_ERROR, "detector mapping organ ," + type.toString() + ", is error"); } cd = new ControlDeviceLil(); } else { throw new BusinessException(ErrorCode.PARAMETER_INVALID, "Parameter type[" + type + "] invalid !"); } // standardNumber?? LinkedHashMap<String, Object> params = new LinkedHashMap<String, Object>(); params.put("standardNumber", standardNumber); List<ControlDevice> list = controlDeviceDAO.findByPropertys(params); if (list.size() >= 1) { throw new BusinessException(ErrorCode.UNIQUE_PROPERTY_DUPLICATE, "standardNumber[" + standardNumber + "] is already exist !"); } // name?? // params.clear(); // params.put("name", name); // list = controlDeviceDAO.findByPropertys(params); // if (list.size() >= 1) { // throw new BusinessException(ErrorCode.NAME_EXIST, "name[" + name // + "] is already exist !"); // } cd.setCreateTime(System.currentTimeMillis()); cd.setDas(dasDAO.findById(dasId)); cd.setLatitude(latitude); cd.setLongitude(longitude); cd.setName(name); cd.setNote(note); cd.setOrgan(organDAO.findById(organId)); cd.setPeriod(period); cd.setStakeNumber(stakeNumber); cd.setStandardNumber(standardNumber); cd.setSubType(subType); cd.setNavigation(navigation); cd.setHeight(height); cd.setWidth(width); cd.setSectionType(sectionType); cd.setReserve(reserve); cd.setIp(ip); cd.setPort(port); controlDeviceDAO.save(cd); // ?SN syncSN(null, standardNumber, TypeDefinition.RESOURCE_TYPE_CD); return cd.getId(); }
From source file:ca.oson.json.Oson.java
private String short2JsonDefault(FieldData objectDTO) { Short valueToReturn = json2ShortDefault(objectDTO); if (valueToReturn == null) { return null; }//from w w w . j a v a 2s. c o m return valueToReturn.toString(); }