/** * Searches for all awards with the same award id and grabs all sequence numbers for that award * returning the sequence number as both the key and the value for the pair. * * @return the list of <key, value> pairs of the current award sequence numbers * @see org.kuali.rice.krad.keyvalues.KeyValuesFinder#getKeyValues() */ @Override public List<KeyValue> getKeyValues() { AwardDocument doc = (AwardDocument) getDocument(); String awardNumber = doc.getAward().getAwardNumber(); KeyValuesService keyValuesService = (KeyValuesService) KcServiceLocator.getService("keyValuesService"); Map<String, Object> idMatch = new HashMap<String, Object>(); idMatch.put("awardNumber", awardNumber); Collection<Award> awards = keyValuesService.findMatching(Award.class, idMatch); List<Integer> sortedList = new ArrayList<Integer>(); for (Award award : awards) { sortedList.add(award.getSequenceNumber()); } Collections.sort(sortedList, Collections.reverseOrder()); List<KeyValue> keyValues = new ArrayList<KeyValue>(); for (Integer num : sortedList) { keyValues.add(new ConcreteKeyValue(num.toString(), num.toString())); } return keyValues; }
@Override public List<KeyValue> getKeyValues() { if (subModuleCodes == null) { List<KeyValue> labels = new ArrayList<KeyValue>(); labels.add(new ConcreteKeyValue("0", "select")); if (StringUtils.isNotBlank(moduleCode)) { KeyValuesService boService = KNSServiceLocator.getKeyValuesService(); Map<String, Object> fieldValues = new HashMap<String, Object>(); fieldValues.put("moduleCode", moduleCode); Collection<CoeusSubModule> codes = (Collection<CoeusSubModule>) boService.findMatching(CoeusSubModule.class, fieldValues); for (CoeusSubModule coeusSubModule : codes) { labels.add( new ConcreteKeyValue( coeusSubModule.getSubModuleCode(), coeusSubModule.getDescription())); } } subModuleCodes = labels; } return subModuleCodes; }