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; }
if("lo.resultColumn.categoryName".equals(cell.getKey())){ categoryCell = cell; break; }else if("lo.resultColumn.loId".equals(cell.getKey())){ loId = cell.getValue(); SearchResultCellInfo cell = idToCellMap.get(loId); if(cell == null){ cell = new SearchResultCellInfo("lo.resultColumn.categoryName",""); idToCellMap.put(loId, cell); if(cell.getValue()==null||cell.getValue().isEmpty()){ cell.setValue(categoryCell.getValue()); }else if(categoryCell.getValue()!=null && !categoryCell.getValue().isEmpty()){ cell.setValue(cell.getValue()+", "+categoryCell.getValue());
for (ResultColumnInfo resultColumn : searchTypeInfo.getSearchResultTypeInfo().getResultColumns()) { SearchResultCellInfo resultCell = new SearchResultCellInfo(); resultCell.setKey(resultColumn.getKey()); resultCell.setValue(queryResultCell.toString());
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); } } } } }
if(cell.getValue()!=null && ("lu.resultColumn.luOptionalExpFirstAtpDisplay".equals(cell.getKey()) || "lu.resultColumn.luOptionalLastAtpDisplay".equals(cell.getKey()))) { List<SearchResultCellInfo> cells = atpIdToCellMapping.get(cell.getValue()); if(cells==null){ cells = new ArrayList<SearchResultCellInfo>(); atpIdToCellMapping.put(cell.getValue(), cells); String atpName = null; for(SearchResultCellInfo cell:row.getCells()){ if("atp.resultColumn.atpId".equals(cell.getKey())){ atpId = cell.getValue(); }else if("atp.resultColumn.atpShortName".equals(cell.getKey())){ atpName = cell.getValue(); cell.setValue(atpName);
/** * @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 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; }
String variationLongName = null; for (SearchResultCellInfo cell : row.getCells()) { if ("lu.resultColumn.cluId".equals(cell.getKey())) { programId = cell.getValue(); } else if ("lu.resultColumn.luOptionalLongName".equals(cell.getKey())) { variationLongName = cell.getValue(); String resultComponentTypeName = null; for (SearchResultCellInfo cell : row.getCells()) { if ("lrc.resultColumn.resultComponent.id".equals(cell.getKey())) { resultComponentTypeId = cell.getValue(); } else if ("lrc.resultColumn.resultComponent.name".equals(cell.getKey())) { resultComponentTypeName = cell.getValue(); if ("lu.resultColumn.cluId".equals(cell.getKey())) { programId = cell.getValue(); } else if ("lu.resultColumn.luOptionalAdminOrg".equals(cell.getKey())) { orgId = cell.getValue(); orgCell = cell; } else if ("lu.resultColumn.resultComponentId".equals(cell.getKey())) { resultComponentName = resultComponentMapping.get(cell.getValue()); resultComponentCell = cell; } else if ("lu.resultColumn.variationId".equals(cell.getKey())) { variationCell = cell; } else if ("lu.resultColumn.luOptionalCampusLocation".equals(cell.getKey())) { campusLocationCell = cell; campusCode = cell.getValue(); variationCell.setValue("");
private SearchResultRowInfo getListItem(String id) { for (SearchResultRowInfo s : resultDataMap) { if (s.getCells().get(keyAttrNdx).getValue().equals(id)) { return s; } } return null; }
@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; }
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; } /**
@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; }
resultRow.setCells(new ArrayList<SearchResultCellInfo>()); SearchResultCellInfo cell = new SearchResultCellInfo(); cell.setKey(ENTITY_ID_RESULT); cell.setValue(person.getEntityId()); resultRow.getCells().add(cell); cell = new SearchResultCellInfo(); cell.setKey(PERSON_ID_RESULT); cell.setValue(person.getPrincipalId()); resultRow.getCells().add(cell); cell = new SearchResultCellInfo(); cell.setKey(PRINCIPAL_NAME_RESULT); cell.setValue(person.getPrincipalName()); resultRow.getCells().add(cell); cell = new SearchResultCellInfo(); cell.setKey(GIVEN_NAME_RESULT); cell.setValue(person.getName()); resultRow.getCells().add(cell); cell = new SearchResultCellInfo(); cell.setKey(DISPLAY_NAME_RESULT); cell.setValue(person.getName() + " (" + person.getPrincipalName() + ")"); resultRow.getCells().add(cell);
@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); } });
String code = null; for(SearchResultCellInfo cell:row.getCells()){ if("lu.resultColumn.cluId".equals(cell.getKey())){ cluId = cell.getValue(); }else if("lu.resultColumn.luOptionalCode".equals(cell.getKey())){ code = cell.getValue(); if("proposal.resultColumn.proposalOptionalName".equals(cell.getKey())){ proposalNameCell = cell; cell.setKey("lu.resultColumn.proposalOptionalName"); }else if("proposal.resultColumn.proposalOptionalReferenceId".equals(cell.getKey())){ cluId = cell.getValue(); cell.setKey("lu.resultColumn.proposalOptionalReferenceId"); }else if("proposal.resultColumn.proposalId".equals(cell.getKey())){ cell.setKey("lu.resultColumn.proposalId"); proposalNameCell.setValue(cluIdToCodeMap.get(cluId)+" ("+proposalNameCell.getValue()+")");
/** * @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 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(); } });
/** * 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; }
@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); } }
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); } }