/** * Standard constructor for WOComponent subclasses. * * @param context context of a transaction * @see WOComponent#pageWithName(String) * @see WOApplication#pageWithName(String, WOContext) */ public ERPublishCalendarPage(WOContext context) { super(context); events = new NSMutableArray(); calendarTimeZone = new NSTimestampFormatter ("%Z").format (new NSTimestamp()); dateTimeFormatter = new NSTimestampFormatter ("%Y%m%dT%H%M%S"); dateTimeFormatter.setDefaultFormatTimeZone (NSTimeZone.localTimeZone()); dateFormatter = new NSTimestampFormatter ("%Y%m%d"); dateFormatter.setDefaultFormatTimeZone (NSTimeZone.localTimeZone()); utcDateTimeFormatter = new NSTimestampFormatter ("%Y%m%dT%H%M%SZ"); utcDateTimeFormatter.setDefaultFormatTimeZone (NSTimeZone.timeZoneWithName ("UTC", false)); timeZoneFormatter = new NSTimestampFormatter ("%Z"); timeZoneFormatter.setDefaultFormatTimeZone (NSTimeZone.localTimeZone()); }
public Object marshall(SerializerState state, Object p, Object o) throws MarshallException { try { long time; String tz; if (o instanceof NSTimestamp) { time = ((NSTimestamp) o).getTime(); tz = ((NSTimestamp) o).timeZone().getID(); } else { throw new MarshallException("cannot marshall date using class " + o.getClass()); } JSONObject obj = new JSONObject(); if (ser.getMarshallClassHints()) { obj.put("javaClass", o.getClass().getName()); } obj.put("time", time); obj.put("tz", tz); return obj; } catch (JSONException e) { throw new MarshallException("Failed to marshall NSTimestamp.", e); } }
public Object unmarshall(SerializerState state, Class clazz, Object o) throws UnmarshallException { try { JSONObject jso = (JSONObject) o; long time = jso.getLong("time"); String tz = jso.getString("tz"); if (jso.has("javaClass")) { try { clazz = Class.forName(jso.getString("javaClass")); } catch (ClassNotFoundException cnfe) { throw new UnmarshallException(cnfe.getMessage()); } } if (NSTimestamp.class.equals(clazz)) { NSTimestamp timestamp = new NSTimestamp(time, NSTimeZone.getTimeZone(tz)); state.setSerialized(o, timestamp); return timestamp; } throw new UnmarshallException("invalid class " + clazz); } catch (JSONException e) { throw new UnmarshallException("Failed to unmarshall NSTimestamp.", e); } }
public MInstance(NSDictionary aDict, MSiteConfig aConfig) { shutdownFormatter.setDefaultFormatTimeZone(NSTimeZone.timeZoneWithName("UTC", true)); values = new NSMutableDictionary(aDict); _host = aConfig.hostWithName(hostName()); _application = aConfig.applicationWithName(applicationName()); _siteConfig = aConfig; calculateNextScheduledShutdown(); }
/** ******** Constructors ********* */ // This constructor is for adding new instances through the UI public MInstance(MHost aHost, MApplication anApplication, Integer anID, MSiteConfig aConfig) { shutdownFormatter.setDefaultFormatTimeZone(NSTimeZone.timeZoneWithName("UTC", true)); values = new NSMutableDictionary(); _host = aHost; _application = anApplication; _siteConfig = aConfig; setApplicationName(_application.name()); setHostName(_host.name()); setId(anID); takeValuesFromApplication(); setSchedulingEnabled(Boolean.FALSE); setSchedulingType("DAILY"); setSchedulingHourlyStartTime(Integer.valueOf(3)); setSchedulingDailyStartTime(Integer.valueOf(3)); setSchedulingWeeklyStartTime(Integer.valueOf(3)); setSchedulingStartDay(Integer.valueOf(1)); // Sunday setSchedulingInterval(Integer.valueOf(12)); setGracefulScheduling(Boolean.TRUE); }