@Override
	protected void postFromJSON(JSONObject from, Subscription to) throws JSONException {

		try {
			
			if(from.has("user") && !from.isNull("user")) {
				JSONObject user = from.getJSONObject("user");
				if(user != null) {
					to.setUser(userFactory.fromJSON(user));
				}
			}
			
			if(from.has("entity") && !from.isNull("entity")) {
				JSONObject entity = from.getJSONObject("entity");
				if(entity != null) {
					to.setEntity(entityFactory.fromJSON(entity));
				}
			}
			
			if(from.has("subscribed") && !from.isNull("subscribed")) {
				to.setSubscribed(from.getBoolean("subscribed"));
			}			
			
			if(from.has("date") && !from.isNull("date")) {
				try {
					to.setDate(DATE_FORMAT.parse(from.getString("date")).getTime());
				}
				catch (ParseException e) {
					if(logger != null && logger.isWarnEnabled()) {
						logger.warn("Could not parse date [" +
								from.getString("date") +
								"] using format [" +
								DATE_FORMAT_STRING +
								"]");
					}
				}
			}
			
			if(from.has("type") && !from.isNull("type")) {
				try {
					to.setNotificationType(NotificationType.valueOf(from.getString("type").toUpperCase()));
				}
				catch (Exception e) {
					if(logger != null && logger.isWarnEnabled()) {
						logger.warn("Could not parse type [" +
								from.getString("type") +
								"] into " + NotificationType.class.getName());
					}
				}
			}			
		}
		catch (Throwable e) {
			throw new JSONException(e.getMessage());
		}		
	}
@Override
	protected void postFromJSON(JSONObject from, Subscription to) throws JSONException {

		try {
			
			if(from.has("user") && !from.isNull("user")) {
				JSONObject user = from.getJSONObject("user");
				if(user != null) {
					to.setUser(userFactory.fromJSON(user));
				}
			}
			
			if(from.has("entity") && !from.isNull("entity")) {
				JSONObject entity = from.getJSONObject("entity");
				if(entity != null) {
					to.setEntity(entityFactory.fromJSON(entity));
				}
			}
			
			if(from.has("subscribed") && !from.isNull("subscribed")) {
				to.setSubscribed(from.getBoolean("subscribed"));
			}			
			
			if(from.has("date") && !from.isNull("date")) {
				try {
					to.setDate(DATE_FORMAT.parse(from.getString("date")).getTime());
				}
				catch (ParseException e) {
					if(logger != null && logger.isWarnEnabled()) {
						logger.warn("Could not parse date [" +
								from.getString("date") +
								"] using format [" +
								DATE_FORMAT_STRING +
								"]");
					}
				}
			}
			
			if(from.has("type") && !from.isNull("type")) {
				try {
					to.setNotificationType(NotificationType.valueOf(from.getString("type").toUpperCase()));
				}
				catch (Exception e) {
					if(logger != null && logger.isWarnEnabled()) {
						logger.warn("Could not parse type [" +
								from.getString("type") +
								"] into " + NotificationType.class.getName());
					}
				}
			}			
		}
		catch (Throwable e) {
			throw new JSONException(e.getMessage());
		}		
	}
@ Override protected void postFromJSON ( JSONObject from , Subscription to ) throws JSONException { try { if ( from . has ( "user" ) && ! from . isNull ( "user" ) ) { JSONObject user = from . getJSONObject ( "user" ) ; if ( user != null ) { to . setUser ( userFactory . fromJSON ( user ) ) ; } } if ( from . has ( "entity" ) && ! from . isNull ( "entity" ) ) { JSONObject entity = from . getJSONObject ( "entity" ) ; if ( entity != null ) { to . setEntity ( entityFactory . fromJSON ( entity ) ) ; } } if ( from . has ( "subscribed" ) && ! from . isNull ( "subscribed" ) ) { to . setSubscribed ( from . getBoolean ( "subscribed" ) ) ; } if ( from . has ( "date" ) && ! from . isNull ( "date" ) ) { try { to . setDate ( DATE_FORMAT . parse ( from . getString ( "date" ) ) . getTime ( ) ) ; } catch ( ParseException e ) { if ( logger != null && logger . isWarnEnabled ( ) ) { logger . warn ( "Could not parse date [" + from . getString ( "date" ) + "] using format [" + DATE_FORMAT_STRING + "]" ) ; } } } if ( from . has ( "type" ) && ! from . isNull ( "type" ) ) { try { to . setNotificationType ( NotificationType . valueOf ( from . getString ( "type" ) . toUpperCase ( ) ) ) ; } catch ( Exception e ) { if ( logger != null && logger . isWarnEnabled ( ) ) { logger . warn ( "Could not parse type [" + from . getString ( "type" ) + "] into " + NotificationType . class . getName ( ) ) ; } } } } catch ( Throwable e ) { throw new JSONException ( e . getMessage ( ) ) ; } }
/* (non-Javadoc)
@see com.socialize.entity.SocializeObjectFactory#postFromJSON(org.json.JSONObject, com.socialize.entity.SocializeObject)
/ * ( non - Javadoc )