/** * @see org.kuali.student.common.ui.client.widgets.list.ListItems#getItemIds() */ @Override public List<String> getItemIds() { List<String> ids = new ArrayList<String>(); for (SearchResultRowInfo s:resultDataMap){ ids.add(s.getCells().get(keyAttrNdx).getValue()); } return ids; }
private SearchResultRowInfo getListItem(String id) { for (SearchResultRowInfo s : resultDataMap) { if (s.getCells().get(keyAttrNdx).getValue().equals(id)) { return s; } } return null; }
@Override public String getItemAttribute(String id, String attrKey) { SearchResultRowInfo r = getListItem(id); int attrIndex = attrKeys.indexOf(attrKey); if (attrIndex >= 0 && r != null){ return r.getCells().get(attrIndex + attrOffset).getValue(); } return null; }
protected List<Map<String,String>> attributeSetFromSearchResult(List<SearchResultRowInfo> results, String orgIdKey) { List<Map<String,String>> returnAttrSetList = new ArrayList<Map<String,String>>(); if (results != null) { for (SearchResultRowInfo result : results) { Map<String,String> attributeSet = new LinkedHashMap<String,String>(); String resolvedOrgId = ""; String resolvedOrgShortName = ""; for (SearchResultCellInfo resultCell : result.getCells()) { if ("org.resultColumn.orgId".equals(resultCell.getKey())) { resolvedOrgId = resultCell.getValue(); } else if ("org.resultColumn.orgShortName".equals(resultCell.getKey())) { resolvedOrgShortName = resultCell.getValue(); } } if (orgIdKey != null) { attributeSet.put(orgIdKey, resolvedOrgId); } attributeSet.put(KualiStudentKimAttributes.QUALIFICATION_ORG_ID, resolvedOrgId); returnAttrSetList.add(attributeSet); } } return returnAttrSetList; }
/** * @see org.kuali.student.common.ui.client.widgets.list.ListItems#getItemText(java.lang.String) */ @Override public String getItemText(String id) { if(getListItem(id)!=null){ return getListItem(id).getCells().get(itemTextAttrNdx).getValue(); } return ""; }
@Override public int compare(SearchResultRowInfo o1, SearchResultRowInfo o2) { String o1SortValue = null; String o2SortValue = null; for (SearchResultCellInfo cell : o1.getCells()) { if (sortColumn.equals(cell.getKey())) { o1SortValue = cell.getValue(); break; } } for (SearchResultCellInfo cell : o2.getCells()) { if (sortColumn.equals(cell.getKey())) { o2SortValue = cell.getValue(); break; } } if (o1SortValue != null) { if (o2SortValue == null) { return 1; } return o1SortValue.compareTo(o2SortValue); } if (o2SortValue == null) { return 0; } return -1; }
@Override public Boolean isLatestVersion(String versionIndId, Long versionSequenceNumber) throws Exception { try { //Perform a search to see if there are any new versions of the course that are approved, draft, etc. //We don't want to version if there are SearchRequestInfo request = new SearchRequestInfo("lu.search.isVersionable"); request.addParam("lu.queryParam.versionIndId", versionIndId); request.addParam("lu.queryParam.sequenceNumber", versionSequenceNumber.toString()); List<String> states = new ArrayList<String>(); states.add("Approved"); states.add("Active"); states.add("Draft"); states.add("Superseded"); request.addParam("lu.queryParam.luOptionalState", states); SearchResultInfo result = cluService.search(request, ContextUtils.getContextInfo()); String resultString = result.getRows().get(0).getCells().get(0).getValue(); return "0".equals(resultString); } catch (Exception ex) { // Log exception ex.printStackTrace(); throw new RuntimeException(ex); } }
@Override public Boolean isLatestVersion(String versionIndId, Long versionSequenceNumber) throws Exception { //Perform a search to see if there are any new versions of the course that are approved, draft, etc. //We don't want to version if there are try { SearchRequestInfo request = new SearchRequestInfo("lu.search.isVersionable"); request.addParam("lu.queryParam.versionIndId", versionIndId); request.addParam("lu.queryParam.sequenceNumber", versionSequenceNumber.toString()); List<String> states = new ArrayList<String>(); states.add("Approved"); states.add("Active"); states.add("Draft"); states.add("Superseded"); request.addParam("lu.queryParam.luOptionalState", states); SearchResultInfo result = cluService.search(request, ContextUtils.getContextInfo()); String resultString = result.getRows().get(0).getCells().get(0).getValue(); return "0".equals(resultString); } catch (Exception e) { LOG.error("IS LATEST VERSION ERROR"); return false; } }
@Override public void onSuccess(SearchResultInfo results) { resultRows.clear(); if(results != null){ for (SearchResultRowInfo r: results.getRows()){ ResultRow theRow = new ResultRow(); for(SearchResultCellInfo c: r.getCells()){ if(c.getKey().equals(resultIdColumnKey)){ theRow.setId(c.getValue()); } theRow.setValue(c.getKey(), c.getValue()); } resultRows.add(theRow); } } redraw(); } });
@Override public void onSuccess(SearchResultInfo results) { IdableSuggestion theSuggestion = null; if(results != null && !results.getRows().isEmpty()){ SearchResultRowInfo r = results.getRows().get(0); theSuggestion = new IdableSuggestion(); for(SearchResultCellInfo c: r.getCells()){ if(c.getKey().equals(resultDisplayKey)){ String itemText = c.getValue(); theSuggestion.addAttr(c.getKey(), c.getValue()); theSuggestion.setDisplayString(itemText); theSuggestion.setReplacementString(itemText); } else if(c.getKey().equals(resultIdKey)){ theSuggestion.setId(c.getValue()); theSuggestion.addAttr(c.getKey(), c.getValue()); } else { theSuggestion.addAttr(c.getKey(), c.getValue()); } } } callback.exec(theSuggestion); } });
private List<String> getMembershipQuerySearchResult(MembershipQueryInfo query, ContextInfo contextInfo) throws MissingParameterException, OperationFailedException, PermissionDeniedException, InvalidParameterException { if (query == null) { return null; } SearchRequestInfo request = new SearchRequestInfo(); request.setSearchKey(query.getSearchTypeKey()); request.setParams(query.getQueryParamValues()); SearchResultInfo result = search(request, contextInfo); Set<String> cluIds = new HashSet<String>(); List<SearchResultRowInfo> rows = result.getRows(); for (SearchResultRowInfo row : rows) { List<SearchResultCellInfo> cells = row.getCells(); for (SearchResultCellInfo cell : cells) { if (cell.getKey().equals("lu.resultColumn.luOptionalVersionIndId") && cell.getValue() != null) { cluIds.add(cell.getValue()); } } } return new ArrayList<String>(cluIds); }
private void doIdTranslation(SearchResultInfo searchResult) { for (SearchResultRowInfo searchResultRow : searchResult.getRows()) { for (SearchResultCellInfo searchResultCell : searchResultRow.getCells()) { String value = searchResultCell.getValue(); if (value != null && value.startsWith("kuali.atp")) { String newValue = idTranslatorFilter.getTranslationForAtp(value, ContextUtils.getContextInfo()); if (newValue != null) { searchResultCell.setValue(newValue); } } } } }
private List<String> getDepartments(List<String> departmentIds, ContextInfo contextInfo) throws MissingParameterException, PermissionDeniedException, OperationFailedException, InvalidParameterException { List<String> departments = new ArrayList<String>(); SearchRequestInfo searchRequest = new SearchRequestInfo("org.search.generic"); List<String> orgTypes = new ArrayList<String>(); orgTypes.add("kuali.org.Department"); searchRequest.addParam("org.queryParam.orgOptionalType", orgTypes); searchRequest.addParam("org.queryParam.orgOptionalIds", departmentIds); SearchResultInfo searchResult = getSearchDispatcher().search(searchRequest, contextInfo); if (null != searchResult) { for (SearchResultRowInfo result : searchResult.getRows()) { for (SearchResultCellInfo resultCell : result.getCells()) { if ("org.resultColumn.orgOptionalLongName".equals(resultCell.getKey())) { departments.add(resultCell.getValue()); } } } } return departments; } }
private List<String> getDepartmentRelatedColleges(List<String> departmentIds, ContextInfo contextInfo) throws MissingParameterException, PermissionDeniedException, OperationFailedException, InvalidParameterException { List<String> departmentRelatedCollegeIds = new ArrayList<String>(); SearchRequestInfo searchRequest = new SearchRequestInfo("org.search.orgQuickViewByRelationTypeOrgTypeRelatedOrgIds"); List<String> orgTypes = new ArrayList<String>(); orgTypes.add("kuali.org.College"); searchRequest.addParam("org.queryParam.optionalOrgTypeList", orgTypes); searchRequest.addParam("org.queryParam.optionalRelationType", "kuali.org.Contain"); searchRequest.addParam("org.queryParam.relatedOrgIds", departmentIds); SearchResultInfo searchResult = getSearchDispatcher().search(searchRequest, contextInfo); if (null != searchResult) { for (SearchResultRowInfo row : searchResult.getRows()) { for (SearchResultCellInfo cell : row.getCells()) { if ("org.resultColumn.orgId".equals(cell.getKey())) { departmentRelatedCollegeIds.add(cell.getValue()); } } } } return departmentRelatedCollegeIds; }
private String getCollegeName(String collegeId, ContextInfo contextInfo) throws MissingParameterException, PermissionDeniedException, OperationFailedException, InvalidParameterException { String collegeName = ""; SearchRequestInfo searchRequest = new SearchRequestInfo("org.search.generic"); List<String> orgTypes = new ArrayList<String>(); orgTypes.add("kuali.org.College"); searchRequest.addParam("org.queryParam.orgOptionalType", orgTypes); searchRequest.addParam("org.queryParam.orgOptionalId", collegeId); SearchResultInfo searchResult = getSearchDispatcher().search(searchRequest, contextInfo); if (null != searchResult) { for (SearchResultRowInfo result : searchResult.getRows()) { for (SearchResultCellInfo resultCell : result.getCells()) { if ("org.resultColumn.orgOptionalLongName".equals(resultCell.getKey())) { collegeName = resultCell.getValue(); } } } } return collegeName; }
public IdTranslation getTranslation(LookupMetadata lookupMetadata, String id) throws AssemblyException { SearchRequestInfo searchRequest = buildSearchRequestById(lookupMetadata, id); SearchResultInfo searchResults = null; try { searchResults = searchDispatcher.search(searchRequest, ContextUtils.getContextInfo()); } catch (Exception e) { throw new RuntimeException(e); } IdTranslation result = null; if(searchResults != null && searchResults.getRows().size() > 0){ result = new IdTranslation(); result.setId(id); SearchResultRowInfo r = searchResults.getRows().get(0); for(SearchResultCellInfo c: r.getCells()){ if(c.getKey().equals(lookupMetadata.getResultDisplayKey())){ result.addAttribute(c.getKey(), c.getValue()); result.setDisplay(c.getValue()); } else { result.addAttribute(c.getKey(), c.getValue()); } } } return result; }
public String getTranslationForAtp(String value, ContextInfo contextInfo) { SearchRequestInfo searchRequest = new SearchRequestInfo(); searchRequest.setSearchKey("atp.search.advancedAtpSearch"); ArrayList<SearchParamInfo> searchParams = new ArrayList<SearchParamInfo>(); SearchParamInfo searchParam = new SearchParamInfo(); searchParam.setKey("atp.advancedAtpSearchParam.atpId"); searchParam.getValues().add(value); searchParams.add(searchParam); searchRequest.setParams(searchParams); SearchResultInfo searchResult = null; try { searchResult = searchDispatcher.search(searchRequest, contextInfo); } catch (Exception e) { throw new RuntimeException(e); } if(searchResult!= null){ for (SearchResultRowInfo resultRow : searchResult.getRows()) { for (SearchResultCellInfo searchResultCell : resultRow.getCells()) { if(searchResultCell.getKey().equals("atp.resultColumn.atpDescrPlain")){ return searchResultCell.getValue(); } } } } return null; } }
private SearchResultRowInfo mapResultRow( String subSearchKey, SearchResultRowInfo row, CrossSearchTypeInfo crossSearchType) { SearchResultRowInfo resultRow = new SearchResultRowInfo(); for(JoinResultMappingInfo resultMapping: crossSearchType.getJoinResultMappings()){ if(subSearchKey.equals(resultMapping.getSubSearchKey())){ for(SearchResultCellInfo cell: row.getCells()){ if(resultMapping.getSubSearchResultParam().equals(cell.getKey())){ SearchResultCellInfo mappedCell = new SearchResultCellInfo(); mappedCell.setKey(resultMapping.getResultParam()); mappedCell.setValue(cell.getValue()); resultRow.getCells().add(mappedCell); break;//FIXME breaks are bad... but there is no map in the cells } } } } return resultRow; } /**
/** * Maps results from multiple searches into a single result row * * @param permutation * @param crossSearchType * @return a mapped SearchResultRowInfo */ private SearchResultRowInfo mapResultRow( Map<String, SearchResultRowInfo> permutation, CrossSearchTypeInfo crossSearchType) { //FIXME this is pretty inefficient to loop through everything... a map structure for the cells might be better SearchResultRowInfo resultRow = new SearchResultRowInfo(); for(JoinResultMappingInfo resultMapping: crossSearchType.getJoinResultMappings()){ for(SearchResultCellInfo cell: permutation.get(resultMapping.getSubSearchKey()).getCells()){ if(resultMapping.getSubSearchResultParam().equals(cell.getKey())){ SearchResultCellInfo mappedCell = new SearchResultCellInfo(); mappedCell.setKey(resultMapping.getResultParam()); mappedCell.setValue(cell.getValue()); resultRow.getCells().add(mappedCell); break;//FIXME breaks are bad... but there is no map in the cells } } } return resultRow; }