private int getAttrKeyNdx(List<SearchResultRowInfo> results, String keyAttrKey) { if (results != null && !results.isEmpty()){ for (int i=0; i < results.get(0).getCells().size(); i++){ if (results.get(0).getCells().get(i).getKey().equals(keyAttrKey)) { return i; } } } return 0; }
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; }
@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; }
public List<KeyValue> getKeyValues() { List<KeyValue> departments = new ArrayList<KeyValue>(); SearchRequestInfo searchRequest = new SearchRequestInfo(); searchRequest.setSearchKey("org.search.generic"); try { for (SearchResultRowInfo result : getOrganizationService().search(searchRequest, ContextUtils.getContextInfo()).getRows()) { String orgId = ""; String orgShortName = ""; String orgOptionalLongName = ""; String orgType = ""; for (SearchResultCellInfo resultCell : result.getCells()) { if ("org.resultColumn.orgId".equals(resultCell.getKey())) { orgId = resultCell.getValue(); } else if ("org.resultColumn.orgShortName".equals(resultCell.getKey())) { orgShortName = resultCell.getValue(); } else if ("org.resultColumn.orgOptionalLongName".equals(resultCell.getKey())) { orgOptionalLongName = resultCell.getValue(); } else if ("org.resultColumn.orgType".equals(resultCell.getKey())) { orgType = resultCell.getValue(); } } departments.add(buildKeyLabelPair(orgId, orgShortName, orgOptionalLongName, orgType)); } return departments; } catch (Exception e) { LOG.error("Error building KeyValues List", e); throw new RuntimeException(e); } }
@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> 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; }
curSearchResultCellKEY= curSearchResultCell.getKey(); if(curSearchResultCellKEY.equals("lo.resultColumn.categoryId")){ curCatID= curSearchResultCell.getValue();
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 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); }
if (srCells != null && srCells.size() > 0) { for (SearchResultCellInfo srcell : srCells) { if (srcell.getKey().equals("lu.resultColumn.luOptionalLongName")) { result.add(srcell.getValue());
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; }
if(cell.getKey().equals(GRADE_TYPE_ID_CELL_KEY)) { selectedGradeTypeId = cell.getValue();
if(srCells != null && srCells.size() > 0){ for(SearchResultCellInfo srcell : srCells){ if (srcell.getKey().equals("lu.resultColumn.cluId")) { coreProgramId = srcell.getValue(); break;