public static synchronized void copyProperties( LoginToken token, Locale locale, TimeZone tz, Schedule src, ScheduleForm dest) throws Exception { if (src != null && dest != null) { copyScheduleDetails(token, locale, tz, src, dest); DracService[] serviceIdList = src.getServiceIdList(); if (serviceIdList != null) { ServiceForm[] services = new ServiceForm[serviceIdList.length]; ServiceHelper.copyProperties(locale, tz, serviceIdList, services); dest.setServices(services); for (ServiceForm service : services) { if (service.isActivateable()) { dest.setActivateableService(true); break; } } for (ServiceForm service : services) { if (service.isCancellable()) { dest.setCancellableService(true); break; } } } } }
public static void setServiceList( Locale locale, TimeZone tz, List<StatusType> services, ScheduleForm form) { if (services != null && form != null) { ServiceForm serviceForm = null; ArrayList<ServiceForm> list = new ArrayList<ServiceForm>(); SimpleDateFormat dateFormatter = new SimpleDateFormat(DracConstants.WEB_GUI_TIME, locale); dateFormatter.setTimeZone(tz); int cnt = 0; for (StatusType status : services) { serviceForm = new ServiceForm(); String startTime = status.getProperties(StatusType.START_TIME); String endTime = status.getProperties(StatusType.END_TIME); if (startTime == null || startTime.equals("") || endTime == null || endTime.equals("")) { continue; } Date startDate = new Date(Long.parseLong(startTime)); serviceForm.setStartdate(dateFormatter.format(startDate)); Date endDate = new Date(Long.parseLong(endTime)); serviceForm.setEnddate(dateFormatter.format(endDate)); serviceForm.setStatus(status.getType().toString()); serviceForm.setMessage(status.getProperties(StatusType.MESSAGE)); serviceForm.setResultNum(++cnt); list.add(serviceForm); } ServiceForm[] serviceForms = list.toArray(new ServiceForm[list.size()]); form.setServices(serviceForms); } }