private RemoteScriptingResults handleShirtSizeUpdate( IWContext iwc, String sourceName, String distanceIdString) { IWResourceBundle iwrb = getResourceBundle(iwc); if (distanceIdString != null) { Integer distanceID = Integer.valueOf(distanceIdString); RunBusiness runBiz = getRunBiz(iwc); try { Vector ids = new Vector(); Vector names = new Vector(); String shirtSizeMetadata = null; if (distanceID.intValue() != -1) { Group runDistance = runBiz.getRunGroupByGroupId(distanceID); shirtSizeMetadata = runDistance.getMetaData(PARAMETER_SHIRT_SIZES_PER_RUN); } List shirtSizes = null; if (shirtSizeMetadata != null) { shirtSizes = ListUtil.convertCommaSeparatedStringToList(shirtSizeMetadata); Iterator shirtIt = shirtSizes.iterator(); // ShirtSizeHome shirtSizeHome = (ShirtSizeHome) IDOLookup.getHome(ShirtSize.class); if (shirtIt.hasNext()) { ids.add("-1"); names.add( iwrb.getLocalizedString( "run_distance_dd.select_shirt_size", "Select shirt size...")); } while (shirtIt.hasNext()) { String shirtSizeKey = (String) shirtIt.next(); // ShirtSize shirtSize = shirtSizeHome.findByPrimaryKey(shirtSizeKey); // String s = iwrb.getLocalizedString(shirtSize.getName(),shirtSize.getName()); ids.add(shirtSizeKey); names.add(iwrb.getLocalizedString("shirt_size." + shirtSizeKey, shirtSizeKey)); } if (shirtSizes.isEmpty()) { ids.add("-1"); names.add(iwrb.getLocalizedString("unavailable", "Unavailable")); } } else { ids.add("-1"); names.add(iwrb.getLocalizedString("unavailable", "Unavailable")); } RemoteScriptingResults rsr = new RemoteScriptingResults(RemoteScriptHandler.getLayerName(sourceName, "id"), ids); rsr.addLayer(RemoteScriptHandler.getLayerName(sourceName, "name"), names); return rsr; } catch (Exception e) { e.printStackTrace(); } } return null; }
/* * (non-Javadoc) * * @see is.idega.idegaweb.member.presentation.UserEditor#getCommune(com.idega.user.data.User) */ protected Commune getCommune(IWContext iwc, User user) { try { if (user != null) { CommuneUserBusiness communeUserService = getCommuneUserService(iwc); Group communeGroup = communeUserService.getRootCitizenGroup(); Integer ID = communeGroup != null ? (Integer) communeGroup.getPrimaryKey() : new Integer(-1); if (user.getPrimaryGroupID() == ID.intValue() || user.hasRelationTo(communeGroup)) { if (super.showDefaultCommuneOption) { return getCommuneBusiness(iwc).getCommuneHome().findDefaultCommune(); } else { return null; } } } } catch (Exception e) { e.printStackTrace(System.err); } return null; }