/** * update the ctods study based on coppa study. * @param studyProtocol coppa study protocol * @throws Exception on error */ public void update(StudyProtocol studyProtocol) throws Exception { if (studyProtocol == null) { return; } StudySearchDto ssDto = new StudySearchDto(); ssDto.setNciIdentifier(studyProtocol.getAssignedIdentifier().getExtension()); List<StudySearchDto> ssDtos = search(ssDto); Session session = getSession(); Transaction tran = session.beginTransaction(); for (StudySearchDto searchDto : ssDtos) { logger.debug(" Updating Coppa Studies for NCI Id = " + ssDto.getNciIdentifier() + " ctods id = " + searchDto.getId()); Protocol protocol = (Protocol) session.load(Protocol.class, searchDto.getId()); protocol.setLongTitleText(StringUtils.substring(studyProtocol.getOfficialTitle().getValue(), 0 , LVConstants.NUM_500)); if (studyProtocol.getPublicTitle() != null) { protocol.setShortTitleText(StringUtils.substring(studyProtocol.getPublicTitle().getValue() , 0 , LVConstants.NUM_200)); } session.update(protocol); } tran.commit(); }
private Map<Long, LoadLabStatus> getLoadLabStatus(List<Long> ids) { Map<Long, LoadLabStatus> map = new HashMap<Long, LoadLabStatus>(); String data = LVUtils.convertListToNumberConcat(ids, ","); System.out.println(" data ..." + data); if (StringUtils.isEmpty(data)) { return map; } StringBuffer hql = new StringBuffer( " Select lls from LoadLabStatus lls where clinicalResultId in ( " + data + " )"); List<LoadLabStatus> loadLabs = (List<LoadLabStatus>) getSession().createQuery(hql.toString()).list(); for (LoadLabStatus loadLab : loadLabs) { map.put(loadLab.getClinicalResultId(), loadLab); } return map; }
public final String getXPathWithNilsAllowed( String operand, String xpath ) { if (StringUtils.isNotBlank(xpath)) { StringBuilder s = new StringBuilder(100); s.append("normalize-space("); s.append(operand); s.append(")='' or ("); s.append(xpath); s.append(")"); return s.toString(); } else { return xpath; } }
@Override public String execute() throws Exception { // System.out.println("### About to generate Word doc..."); // System.out.println("XML is: \n" + this.xml + "\n"); //###LEO request.setAttribute("res", "@@@ " + new Date()); request.getSession().setAttribute("xml", xml); //'UTF-8', 'ISO-8859-1' or nothing? up to you... if (!StringUtils.isEmpty(xml)) { response.setContentType("application/msword; charset=UTF-8"); response.setHeader("Content-disposition", "inline;filename=wordDoc.doc"); PrintWriter writer = response.getWriter(); writer.println(xml); writer.flush(); // System.out.println("### Doc generated..."); return null; }else{ System.out.println("Error: Empty XML field porra!!!" ); } return SUCCESS; }
/** * * @return Success * @throws Exception on error */ public String list() throws Exception { if (StringUtils.isEmpty(ssDto.getNciIdentifier()) && StringUtils.isEmpty(ssDto.getShortTitle())) { setAttribute(LVConstants.FAILURE_MESSAGE, "Minimum one criteria is requured to do the search"); return ERROR; } setAttribute("results", new StudySearchDAO().search(ssDto)); if (getStudyProtocolIdFromSession() != getStudyProtocolIdentifier()) { // user has changed the study, set null for participant setSession(LVConstants.STUDY_PART_SEARCH_DTO, null); } return SUCCESS; }
/** * converts a string array to string concat with a , to be used in a sql. * @param ids ids * @param delimiter delimiter * @return String */ public static String convertListToStringConcat(List<String> ids , String delimiter) { StringBuffer data = new StringBuffer(); for (String id : ids) { data.append("'" + id + "'" + delimiter); } return StringUtils.removeEnd(data.toString(), delimiter); }
/** * converts a string array to string concat with a , to be used in a sql. * @param ids ids * @param delimiter delimiter * @return String */ public static String convertListToNumberConcat(List<Long> ids , String delimiter) { StringBuffer data = new StringBuffer(); for (Long id : ids) { data.append(id + delimiter); } return StringUtils.removeEnd(data.toString(), delimiter); }
/** * converts a ids seperated by a comma to a set. * @param ids ids * @param delimiter delimiter * @return Set */ public static Set<Long> convertStringToSet(String ids , String delimiter) { Set<Long> labs = new HashSet<Long>(); if (StringUtils.isEmpty(ids)) { return labs; } StringTokenizer st = new StringTokenizer(ids, delimiter); while (st.hasMoreTokens()) { labs.add(new Long(st.nextElement().toString())); } return labs; }
/** * converts a ids seperated by a comma to a set. * @param ids ids * @param delimiter delimiter * @return Set */ public static List<Long> convertStringToList(String ids , String delimiter) { List<Long> labs = new ArrayList<Long>(); if (StringUtils.isEmpty(ids)) { return labs; } StringTokenizer st = new StringTokenizer(ids, delimiter); while (st.hasMoreTokens()) { labs.add(new Long(st.nextElement().toString())); } return labs; }
/** * Displays the user profile and contacts for the given provider. * * @return String where the action should flow * @throws Exception * if an error occurs */ @Action(value = "/socialAuthSuccessAction") public String execute() throws Exception { SASFHelper helper = SASFStaticHelper.getHelper(request); try { Profile profile = helper.getProfile(); List<Contact> contactsList = helper.getContactList(); if (contactsList != null && contactsList.size() > 0) { for (Contact p : contactsList) { if (StringUtils.isEmpty(p.getFirstName()) && StringUtils.isEmpty(p.getLastName())) { p.setFirstName(p.getDisplayName()); } } } request.setAttribute("profile", profile); request.setAttribute("contacts", contactsList); return "success"; } catch (Exception ex) { ex.printStackTrace(); } return "failure"; }
private String buildDropdownControl(final Answer answer, final String idSuffix, final String value) { List<AnswerValue> answerValues = answer.getAnswerValues(); String controlId = "select." + idSuffix; StringBuilder input = new StringBuilder(); input.append(" <select ") // .append(" multiple=").append(QUOTE).append("false").append(QUOTE) .append(" id=").append(QUOTE).append(controlId).append(QUOTE) .append(" name=").append(QUOTE).append(controlId).append(QUOTE) .append(getClassAndStyle()); input.append(" >"); if(answer.getQuestion().getParent().getForm().getModule().isShowPleaseSelectOptionInDropDown()) { input.append("<option value=\"\">" + PLEASE_SELECT_OPTION_TEXT + "</option>"); } for (AnswerValue av: answerValues) { String pdesc = htmlEscape ? HtmlUtils.htmlEscape(av.getDescription().length() > MAX_LETTERS_IN_OPTION_TEXT ? av.getDescription().substring(0, MAX_LETTERS_IN_OPTION_TEXT) + "..." : av.getDescription()) : av.getDescription(); String ptitle = av.getDescription().length() > MAX_LETTERS_IN_OPTION_TEXT ? (htmlEscape ? HtmlUtils.htmlEscape(av.getDescription()) : av.getDescription()) : null; input.append("<option ") // .append(" label=").append(QUOTE).append(av.getName()).append(QUOTE) .append(" value=").append(QUOTE).append(av.getValue()).append(QUOTE); if(org.apache.commons.lang.StringUtils.isNotBlank(ptitle)) { input.append(" title=").append(QUOTE).append(ptitle).append(QUOTE); } if(value != null && value.equals(av.getValue())) { input.append(" selected=").append(QUOTE).append("selected").append(QUOTE); } input.append(">") .append(pdesc) .append("</option>"); } input.append("</select>"); return input.toString(); }
/** * Populates the list of forms. * @return */ @ModelAttribute(value="formList") public List<BaseForm> populateFormList( @RequestParam(value="moduleId",required=false) String moduleId ) { if ( StringUtils.isBlank( moduleId ) ) return new ArrayList<BaseForm>(); return formManager.getModuleForms(new Long(moduleId)); }
@Inject(value = "struts.convention.action.groovyPackages", required = false) public void setGrrovyActionPackages(String actionPackages) { if (StringUtils.isNotBlank(actionPackages)) { this.groovyActionPackages = actionPackages.split("\\s*[,]\\s*"); } }
/** * SearchObjects retrieves the user entered search criteria and returns the study search results. * * @param spsDto study participant search dto * @return searchResult * @throws Exception on error */ public List<StudyParticipantSearchDto> search(StudyParticipantSearchDto spsDto) throws Exception { List<StudyParticipantSearchDto> spsDtos = new ArrayList<StudyParticipantSearchDto>(); LabViewerAuthorizationHelper labAuth = new LabViewerAuthorizationHelper(); boolean allSiteAccess = true; // in 2.4, implement admin and cge. for now comment this functionality due to user info not set, while coming // from psc or caAERS // if (spsDto.getUserName() != null) { // allSiteAccess = labAuth.isAllSites(spsDto.getUserName()); // } String ids = null; StringBuffer hql = new StringBuffer(" Select i , part , hc from Identifier as i "); hql.append(" left outer join i.studyParticipantAssignment as spa "); hql.append(" join spa.studySite as ss "); hql.append(" join ss.healthcareSite as hc "); hql.append(" join spa.participant as part "); hql.append(" join ss.protocol as p where p.id = " + spsDto.getStudyProtocolId()); hql.append(" and i.studyParticipantAssignment is not null"); if (StringUtils.isNotEmpty(spsDto.getFirstName())) { hql.append(" and upper(part.firstName) like '%" + spsDto.getFirstName().toUpperCase() + "%'"); } if (StringUtils.isNotEmpty(spsDto.getLastName())) { hql.append(" and upper(part.lastName) like '%" + spsDto.getLastName().toUpperCase() + "%'"); } if (StringUtils.isNotEmpty(spsDto.getIdentifier())) { hql.append(" and upper(i.extension) like '%" + spsDto.getIdentifier().toUpperCase() + "%'"); } if (spsDto.getId() != null) { hql.append(" and part.id = " + spsDto.getId()); } if (!allSiteAccess) { ids = LVUtils.convertListToStringConcat(labAuth.getAuthSites(spsDto.getUserName()), ","); if (StringUtils.isNotEmpty(ids)) { hql.append(" and hc.nciInstituteCode in (" + ids + ")"); } } List<Object> obs = getSession().createQuery(hql.toString()).list(); Object[] data = null; for (Object d : obs) { data = (Object[]) d; Identifier identifier = (Identifier) data[0]; Participant participant = (Participant) data[1]; HealthcareSite healtcareSite = (HealthcareSite) data[2]; spsDtos.add(new StudyParticipantSearchDto(identifier, participant, healtcareSite)); } return spsDtos; }