List of usage examples for org.apache.commons.lang BooleanUtils toStringTrueFalse
public static String toStringTrueFalse(boolean bool)
Converts a boolean to a String returning 'true'
or 'false'
.
BooleanUtils.toStringTrueFalse(true) = "true" BooleanUtils.toStringTrueFalse(false) = "false"
From source file:org.exem.flamingo.web.filesystem.s3.S3BrowserController.java
@RequestMapping(value = "listFolders", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK)/*from ww w . j ava 2 s . c o m*/ public Response listFolders(@RequestParam(required = false) String bucketName, @RequestParam(required = false) String prefix, @RequestParam(required = false) String continuationToken) { // Get bucket list if (StringUtils.isEmpty(bucketName)) { Response response = new Response(); response.getList().addAll(getBucketList()); response.setSuccess(true); return response; } // Get folder list ListObjectsV2Result result = s3BrowserService.listObjects(bucketName, prefix, continuationToken); List<S3ObjectInfo> list = new ArrayList<>(); List<String> commonPrefixes = result.getCommonPrefixes(); for (String key : commonPrefixes) { S3ObjectInfo object = new S3ObjectInfo(); object.setKey(key); object.setName(getName(key)); object.setBucketName(bucketName); object.setFolder(true); list.add(object); } Map<String, String> map = new HashMap<>(); map.put(S3Constansts.CONTINUATIONTOKEN, result.getNextContinuationToken()); map.put(S3Constansts.ISTRUNCATED, BooleanUtils.toStringTrueFalse(result.isTruncated())); Response response = new Response(); response.getList().addAll(list); response.getMap().putAll(map); response.setSuccess(true); return response; }
From source file:org.exem.flamingo.web.filesystem.s3.S3BrowserController.java
@RequestMapping(value = "listObjects", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK)/*from w w w. j av a 2 s .c o m*/ public Response listObjects(@RequestParam(required = false) String bucketName, @RequestParam(required = false) String prefix, @RequestParam(required = false) String continuationToken) { // Get bucket list if (StringUtils.isEmpty(bucketName)) { Response response = new Response(); response.getList().addAll(getBucketList()); response.setSuccess(true); return response; } // Get folder & bucket list ListObjectsV2Result result = s3BrowserService.listObjects(bucketName, prefix, continuationToken); List<S3ObjectInfo> list = new ArrayList<>(); List<String> commonPrefixes = result.getCommonPrefixes(); for (String key : commonPrefixes) { S3ObjectInfo object = new S3ObjectInfo(); object.setBucketName(bucketName); object.setKey(key); object.setName(getName(key)); object.setFolder(true); list.add(object); } List<S3ObjectSummary> objectSummaries = result.getObjectSummaries(); if (!StringUtils.endsWith(prefix, S3Constansts.DELIMITER)) { prefix = prefix + S3Constansts.DELIMITER; } for (S3ObjectSummary s3Object : objectSummaries) { String key = s3Object.getKey(); if (prefix.equals(key)) { continue; } S3ObjectInfo object = new S3ObjectInfo(); object.setBucketName(bucketName); object.setPrefix(prefix); object.setKey(key); object.setName(getName(key)); object.setObject(true); object.setSize(s3Object.getSize()); object.setLastModified(s3Object.getLastModified()); object.setStorageClass(s3Object.getStorageClass()); list.add(object); } Map<String, String> map = new HashMap<>(); map.put(S3Constansts.CONTINUATIONTOKEN, result.getNextContinuationToken()); map.put(S3Constansts.ISTRUNCATED, BooleanUtils.toStringTrueFalse(result.isTruncated())); Response response = new Response(); response.getList().addAll(list); response.getMap().putAll(map); response.setSuccess(true); return response; }
From source file:org.kuali.student.cm.course.service.impl.CourseMaintainableImpl.java
protected void populatePassFailOnDTO() { CourseInfoWrapper courseInfoWrapper = (CourseInfoWrapper) getDataObject(); AttributeInfo passFailAttr = null;//w ww .ja va2 s . co m for (AttributeInfo attr : courseInfoWrapper.getCourseInfo().getAttributes()) { if (StringUtils.equals(attr.getKey(), CurriculumManagementConstants.COURSE_RESULT_COMP_ATTR_PASSFAIL)) { passFailAttr = attr; break; } } if (passFailAttr == null) { passFailAttr = new AttributeInfo(); passFailAttr.setKey(CurriculumManagementConstants.COURSE_RESULT_COMP_ATTR_PASSFAIL); courseInfoWrapper.getCourseInfo().getAttributes().add(passFailAttr); } passFailAttr.setValue(BooleanUtils.toStringTrueFalse(courseInfoWrapper.isPassFail())); }
From source file:org.kuali.student.cm.course.service.impl.CourseMaintainableImpl.java
protected void populateAuditOnDTO() { CourseInfoWrapper courseInfoWrapper = (CourseInfoWrapper) getDataObject(); AttributeInfo auditAttr = null;/* www .ja v a 2 s . co m*/ for (AttributeInfo attr : courseInfoWrapper.getCourseInfo().getAttributes()) { if (StringUtils.equals(attr.getKey(), CurriculumManagementConstants.COURSE_RESULT_COMP_ATTR_AUDIT)) { auditAttr = attr; break; } } if (auditAttr == null) { auditAttr = new AttributeInfo(); auditAttr.setKey(CurriculumManagementConstants.COURSE_RESULT_COMP_ATTR_AUDIT); courseInfoWrapper.getCourseInfo().getAttributes().add(auditAttr); } auditAttr.setValue(BooleanUtils.toStringTrueFalse(courseInfoWrapper.isAudit())); }
From source file:org.kuali.student.cm.proposal.service.impl.ProposalLookupableImpl.java
protected void populateProposalAllowedActions(List<ProposalInfo> proposals) { if (proposals.isEmpty()) { return;//w ww . jav a2 s . com } List<String> workflowIds = new ArrayList<String>(); for (ProposalInfo proposal : proposals) { workflowIds.add(proposal.getWorkflowId()); } List<Document> documents = null; try { documents = KRADServiceLocatorWeb.getDocumentService() .getDocumentsByListOfDocumentHeaderIds(CMMaintenanceDocument.class, workflowIds); } catch (WorkflowException e) { throw new RuntimeException("Error loading maintenance document", e); } Map<String, Document> workflowId2Doc = new HashMap<String, Document>(); for (Document document : documents) { workflowId2Doc.put(document.getDocumentNumber(), document); } for (ProposalInfo proposal : proposals) { boolean canEdit; boolean canOpen; Document document = workflowId2Doc.get(proposal.getWorkflowId()); String docTypeName = document.getDocumentHeader().getWorkflowDocument().getDocumentTypeName(); canEdit = KRADServiceLocatorWeb.getDocumentDictionaryService().getDocumentAuthorizer(docTypeName) .canEdit(document, GlobalVariables.getUserSession().getPerson()); canOpen = KRADServiceLocatorWeb.getDocumentDictionaryService().getDocumentAuthorizer(docTypeName) .canOpen(document, GlobalVariables.getUserSession().getPerson()); AttributeInfo editAttribute = new AttributeInfo(CAN_EDIT_PROPOSAL_KEY, BooleanUtils.toStringTrueFalse(canEdit)); AttributeInfo openAttribute = new AttributeInfo(CAN_OPEN_PROPOSAL_KEY, BooleanUtils.toStringTrueFalse(canOpen)); proposal.getAttributes().add(editAttribute); proposal.getAttributes().add(openAttribute); } }
From source file:org.kuali.student.enrollment.class2.courseoffering.controller.CourseOfferingControllerPopulateUIForm.java
protected static void continueFromCreateCopyCourseOfferingInfo(CourseOfferingCreateWrapper coWrapper, CourseInfo course, TermInfo term) { ContextInfo contextInfo = ContextUtils.createDefaultContextInfo(); int firstValue = 0; try {//from ww w . j av a2s . c om List<CourseOfferingInfo> courseOfferingInfos = CourseOfferingManagementUtil.getCourseOfferingService() .getCourseOfferingsByCourseAndTerm(course.getId(), term.getId(), contextInfo); coWrapper.setCourse(course); coWrapper .setCreditCount( CourseOfferingViewHelperUtil .trimTrailing0(CourseOfferingManagementUtil.getLrcService() .getResultValue(course.getCreditOptions().get(firstValue) .getResultValueKeys().get(firstValue), contextInfo) .getValue())); coWrapper.setShowAllSections(true); coWrapper.setShowCopyCourseOffering(false); coWrapper.setShowTermOfferingLink(true); coWrapper.setContextBar(CourseOfferingContextBar.NEW_INSTANCE(coWrapper.getTerm(), coWrapper.getSocInfo(), CourseOfferingManagementUtil.getStateService(), CourseOfferingManagementUtil.getAcademicCalendarService(), contextInfo)); coWrapper.getExistingTermOfferings().clear(); coWrapper.getExistingOfferingsInCurrentTerm().clear(); for (CourseOfferingInfo courseOfferingInfo : courseOfferingInfos) { if (StringUtils.equals(courseOfferingInfo.getStateKey(), LuiServiceConstants.LUI_CO_STATE_OFFERED_KEY)) { CourseOfferingEditWrapper co = new CourseOfferingEditWrapper(courseOfferingInfo); co.setGradingOption( CourseOfferingManagementUtil.getGradingOption(courseOfferingInfo.getGradingOptionId())); coWrapper.getExistingOfferingsInCurrentTerm().add(co); } } //Get past 5 years CO Calendar termStart = Calendar.getInstance(); termStart.setTime(term.getStartDate()); String termYear = Integer.toString(termStart.get(Calendar.YEAR)); String termMonth = Integer.toString((termStart.get(Calendar.MONTH) + 1)); String termDayOfMonth = Integer.toString((termStart.getActualMaximum(Calendar.DAY_OF_MONTH))); org.kuali.student.r2.core.search.dto.SearchRequestInfo searchRequest = new org.kuali.student.r2.core.search.dto.SearchRequestInfo( CourseOfferingHistorySearchImpl.PAST_CO_SEARCH.getKey()); searchRequest.addParam(CourseOfferingHistorySearchImpl.COURSE_ID, coWrapper.getCourse().getId()); searchRequest.addParam(CourseOfferingHistorySearchImpl.TARGET_DAY_OF_MONTH_PARAM, termDayOfMonth); searchRequest.addParam(CourseOfferingHistorySearchImpl.TARGET_MONTH_PARAM, termMonth); searchRequest.addParam(CourseOfferingHistorySearchImpl.TARGET_YEAR_PARAM, termYear); searchRequest.addParam(CourseOfferingHistorySearchImpl.SearchParameters.CROSS_LIST_SEARCH_ENABLED, BooleanUtils.toStringTrueFalse(true)); org.kuali.student.r2.core.search.dto.SearchResultInfo searchResult = CourseOfferingManagementUtil .getSearchService().search(searchRequest, null); List<String> courseOfferingIds = new ArrayList<String>(searchResult.getTotalResults()); /* Checks whether the course is cross-listed and Set the codes that are cross listed to the cross-listed list */ for (org.kuali.student.r2.core.search.dto.SearchResultRowInfo row : searchResult.getRows()) { for (SearchResultCellInfo cellInfo : row.getCells()) { String value = StringUtils.EMPTY; if (cellInfo.getValue() != null) { value = cellInfo.getValue(); } if (CourseOfferingHistorySearchImpl.SearchResultColumns.CO_ID.equals(cellInfo.getKey())) { courseOfferingIds.add(value); } else if (CourseOfferingHistorySearchImpl.SearchResultColumns.IS_CROSS_LISTED .equals(cellInfo.getValue())) { coWrapper.setCrossListedCo(BooleanUtils.toBoolean(value)); } else if (CourseOfferingHistorySearchImpl.SearchResultColumns.CROSS_LISTED_COURSES .equals(cellInfo.getKey())) { coWrapper.setAlternateCOCodes(Arrays.asList(StringUtils.split(value, ","))); } } } /* * Avoid duplicates in case there is a cross Listed */ HashSet hs = new HashSet(); hs.addAll(courseOfferingIds); courseOfferingIds.clear(); courseOfferingIds.addAll(hs); courseOfferingInfos = CourseOfferingManagementUtil.getCourseOfferingService() .getCourseOfferingsByIds(courseOfferingIds, contextInfo); for (CourseOfferingInfo courseOfferingInfo : courseOfferingInfos) { CourseOfferingEditWrapper co = new CourseOfferingEditWrapper(courseOfferingInfo); TermInfo termInfo = CourseOfferingManagementUtil.getAcademicCalendarService() .getTerm(courseOfferingInfo.getTermId(), contextInfo); co.setTerm(termInfo); co.setGradingOption( CourseOfferingManagementUtil.getGradingOption(courseOfferingInfo.getGradingOptionId())); co.setAlternateCOCodes(coWrapper.getAlternateCOCodes()); coWrapper.getExistingTermOfferings().add(co); } } catch (Exception e) { throw new RuntimeException(e); } }
From source file:org.kuali.student.enrollment.class2.courseoffering.controller.CourseOfferingManagementController.java
@RequestMapping(params = "methodToCall=manageRegGroups") public ModelAndView manageRegGroups(@ModelAttribute("KualiForm") CourseOfferingManagementForm theForm) throws Exception { CourseOfferingInfo theCourseOfferingInfo = theForm.getCurrentCourseOfferingWrapper() .getCourseOfferingInfo();//from www .j a v a 2 s. c om Properties urlParameters = new Properties(); urlParameters.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.START_METHOD); urlParameters.put("coInfo.id", theCourseOfferingInfo.getId()); urlParameters.put(UifParameters.VIEW_ID, RegistrationGroupConstants.RG_VIEW); urlParameters.put(UifParameters.PAGE_ID, RegistrationGroupConstants.RG_PAGE); urlParameters.put("withinPortal", BooleanUtils.toStringTrueFalse(theForm.isWithinPortal())); String controllerPath = RegistrationGroupConstants.RG_CONTROLLER_PATH; //set the redirection param to carry over view information to RG view for customized breadcrumb generation return super.performRedirect(theForm, controllerPath, urlParameters); }
From source file:org.kuali.student.enrollment.class2.courseoffering.controller.CourseOfferingManagementController.java
@RequestMapping(params = "methodToCall=edit") public ModelAndView edit(@ModelAttribute("KualiForm") CourseOfferingManagementForm theForm) throws Exception { Object selectedObject = CourseOfferingManagementUtil.getSelectedObject(theForm, "edit"); if (selectedObject instanceof CourseOfferingListSectionWrapper) { Properties urlParameters = CourseOfferingHandler.edit(theForm, (CourseOfferingListSectionWrapper) selectedObject); if (((CourseOfferingListSectionWrapper) selectedObject).isCrossListed()) { urlParameters.put("editCrossListedCoAlias", BooleanUtils.toStringTrueFalse(true)); } else {//w ww .j a v a 2s. c om urlParameters.put("editCrossListedCoAlias", BooleanUtils.toStringTrueFalse(false)); } return super.performRedirect(theForm, CourseOfferingConstants.CONTROLLER_PATH_COURSEOFFERING_EDIT_MAINTENANCE, urlParameters); } else if (selectedObject instanceof ActivityOfferingWrapper) { Properties urlParameters = ActivityOfferingClusterHandler.editAO(theForm, ((ActivityOfferingWrapper) selectedObject).getAoInfo().getId()); return super.performRedirect(theForm, "activityOffering", urlParameters); } else if (selectedObject instanceof RegistrationGroupWrapper) { //Edit link from activity offering Properties urlParameters = ActivityOfferingClusterHandler.editAO(theForm, theForm.getActionParameters().get("aoId")); return super.performRedirect(theForm, "activityOffering", urlParameters); } else { throw new RuntimeException("Invalid type. Does not support for now"); } }
From source file:org.kuali.student.enrollment.class2.courseoffering.service.impl.ActivityOfferingWrapperLookupableImpl.java
@Override public List<?> performSearch(LookupForm lookupForm, Map<String, String> searchCriteria, boolean bounded) { boolean isValidCriteria = validateSearchParameters(lookupForm, searchCriteria); if (!isValidCriteria) { return new ArrayList<Object>(); }// w w w . ja v a 2 s . c o m List<ActivityOfferingWrapper> activityOfferingWrappers = new ArrayList<ActivityOfferingWrapper>(); String termId = searchCriteria.get("termId"); String courseOfferingCode = searchCriteria.get("courseOfferingCode"); /** * Edit AO maintenace document uses this AO search to allow user to add colocated AOs. */ if (StringUtils.isNotBlank(termId) && StringUtils.isNotBlank(courseOfferingCode)) { SearchRequestInfo searchRequest = new SearchRequestInfo( CourseOfferingManagementSearchImpl.CO_MANAGEMENT_SEARCH.getKey()); searchRequest.addParam(CourseOfferingManagementSearchImpl.SearchParameters.COURSE_CODE, StringUtils.upperCase(courseOfferingCode)); searchRequest.addParam(CourseOfferingManagementSearchImpl.SearchParameters.ATP_ID, termId); searchRequest.addParam( CourseOfferingManagementSearchImpl.SearchParameters.IS_EXACT_MATCH_CO_CODE_SEARCH, BooleanUtils.toStringTrueFalse(true)); try { String coId = ""; SearchResultInfo searchResult = CourseOfferingManagementUtil.getSearchService() .search(searchRequest, ContextUtils.createDefaultContextInfo()); if (searchResult.getRows().isEmpty()) { GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, RiceKeyConstants.ERROR_CUSTOM, "Invalid CourseOfferingCode " + courseOfferingCode); } else if (searchResult.getRows().size() > 1) { GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, RiceKeyConstants.ERROR_CUSTOM, "Multiple CourseOfferings entries found for " + courseOfferingCode); } else { for (SearchResultCellInfo cellInfo : searchResult.getRows().get(0).getCells()) { if (CourseOfferingManagementSearchImpl.SearchResultColumns.CO_ID .equals(cellInfo.getKey())) { coId = cellInfo.getValue(); break; } } } if (StringUtils.isNotBlank(coId)) { List<ActivityOfferingInfo> aos = CourseOfferingManagementUtil.getCourseOfferingService() .getActivityOfferingsByCourseOffering(coId, ContextUtils.createDefaultContextInfo()); for (ActivityOfferingInfo activityOffering : aos) { CO_AO_RG_ViewHelperServiceImpl helper = new CO_AO_RG_ViewHelperServiceImpl(); ActivityOfferingWrapper wrapper = helper.convertAOInfoToWrapper(activityOffering); wrapper.setCourseOfferingId(coId); activityOfferingWrappers.add(wrapper); } } } catch (Exception e) { throw new RuntimeException(e); } } return activityOfferingWrappers; }
From source file:org.kuali.student.enrollment.class2.courseoffering.service.impl.CourseOfferingManagementViewHelperServiceImpl.java
/** * This method loads all the course offerings for a term and course code. * * @param termInfo Term Info//w w w . java 2 s .com * @param courseCode Course Code * @param form Input Form * @throws Exception */ public void loadCourseOfferingsByTermAndCourseCode(TermInfo termInfo, String courseCode, CourseOfferingManagementForm form) throws Exception { SearchRequestInfo searchRequest = new SearchRequestInfo( CourseOfferingManagementSearchImpl.CO_MANAGEMENT_SEARCH.getKey()); searchRequest.addParam(CourseOfferingManagementSearchImpl.SearchParameters.COURSE_CODE, courseCode); searchRequest.addParam(CourseOfferingManagementSearchImpl.SearchParameters.ATP_ID, termInfo.getId()); searchRequest.addParam(CourseOfferingManagementSearchImpl.SearchParameters.CROSS_LIST_SEARCH_ENABLED, BooleanUtils.toStringTrueFalse(true)); // Check to see if the "exact co code match" param has been set. If so, add a query param. boolean isExactMatchSearch = BooleanUtils.toBoolean(form.getViewRequestParameters() .get(CourseOfferingManagementSearchImpl.SearchParameters.IS_EXACT_MATCH_CO_CODE_SEARCH)); if (isExactMatchSearch) { searchRequest.addParam( CourseOfferingManagementSearchImpl.SearchParameters.IS_EXACT_MATCH_CO_CODE_SEARCH, BooleanUtils.toStringTrueFalse(true)); } loadCourseOfferings(searchRequest, form); if (form.getCourseOfferingResultList().isEmpty()) { LOG.error("Error: Can't find any Course Offering for a course code: {} in term: {}", courseCode, termInfo.getName()); GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, CourseOfferingConstants.COURSEOFFERING_MSG_ERROR_NO_COURSE_OFFERING_IS_FOUND, "course code", courseCode, termInfo.getName()); } form.setContextBar(CourseOfferingContextBar.NEW_INSTANCE(form.getTermInfo(), form.getSocStateKey(), getStateService(), CourseOfferingManagementUtil.getAcademicCalendarService(), createContextInfo())); }