if (year != null && year.getRunDate() != null) { IWTimestamp runDate = new IWTimestamp(year.getRunDate());
if (year != null && year.getLastRegistrationDate() != null) { IWTimestamp runDate = new IWTimestamp(year.getLastRegistrationDate());
	private RemoteScriptingResults handleDistanceUpdate(IWContext iwc, String sourceName, String runIdString) {		IWResourceBundle iwrb = getResourceBundle(iwc);		if (runIdString != null) {			Integer runId = Integer.valueOf(runIdString);		    RunBusiness runBiz = getRunBiz(iwc);				IWTimestamp ts = IWTimestamp.RightNow();		    Integer y = new Integer(ts.getYear());		    String yearString = y.toString();		    IWTimestamp stamp = new IWTimestamp();		    stamp.addYears(1);		    String nextYearString = String.valueOf(stamp.getYear());		 				try {					Group run = (Group) runBiz.getRunGroupByGroupId(runId);					String runnerYearString = yearString;					boolean finished = false;					Map yearMap = runBiz.getYearsMap(run);					Year year = (Year) yearMap.get(yearString);					if (year != null && year.getRunDate() != null) {						IWTimestamp runDate = new IWTimestamp(year.getRunDate());						if (ts.isLaterThanOrEquals(stamp)) {							finished = true;						}					}					Year nextYear = (Year) yearMap.get(nextYearString);					if (finished && nextYear != null) {						runnerYearString = nextYearString;					}					Collection distances = runBiz.getDistancesMap(run, runnerYearString);					    Vector ids = new Vector();			    Vector names = new Vector();			    			    if (distances != null) {				    Iterator disIter = distances.iterator();				    if (disIter.hasNext()) {					    	ids.add("");					    	names.add(iwrb.getLocalizedString("run_year_ddd.select_distance","Select distance..."));				    }				    while (disIter.hasNext()) {				    		Group distance = (Group) disIter.next();				    		String s = iwrb.getLocalizedString(distance.getName(),distance.getName());				    		ids.add(distance.getPrimaryKey().toString());				    		names.add(s);				    }				    if (distances.isEmpty()) {				    		ids.add("");				    		names.add("Unavailable");				    } 			    }			    else {			    		ids.add("");			    		names.add("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;	}