Event¶
-
public class
Event
extends FeedItem implements Serializable, Putable, Postable¶ Describes an event like those shared in
Network
s
Fields¶
NOWHERE¶
-
public static final String
NOWHERE
¶ Value other classes should pass to this class and should expect to receive from this class to represent the portions of addresses that are not a part of the address. Note that
Event.getAddress()
uses this constant only when the entire address is missing.
addressLine1¶
addressLine2¶
city¶
country¶
description¶
-
public String
description
¶ User-generated description of the event. May contain formatting from
org.codethechange.culturemesh.FormatManager
.
networkId¶
region¶
timeOfEvent¶
Constructors¶
Event¶
-
public
Event
(long id, long networkId, String title, String description, String timeOfEvent, long author, String addressLine1, String addressLine2, String city, String region, String country)¶ Construct an Event object from the provided parameters.
Parameters: - id – Unique identifier for the event
- networkId – Unique identifier for the
Network
the event is a part of - title – User-generated title for the event
- description – User-generated description of the event
- timeOfEvent – Date and time of the event. Must strictly conform to the format
yyyy-MM-ddTHH:mm:ss.SSSZ
. - author – Unique identifier for the
User
creating theEvent
- addressLine1 – Optional first line of the address.
Event.NOWHERE
if absent. - addressLine2 – Optional second line of the address.
Event.NOWHERE
if absent. - city – Optional city portion of the address.
Event.NOWHERE
if absent. - region – Optional region portion of the address.
Event.NOWHERE
if absent. - country – Optional country portion of the address.
Event.NOWHERE
if absent.
Event¶
-
public
Event
()¶ Empty constructor that does nothing to initialize any instance fields. For database use only.
Event¶
-
public
Event
(JSONObject json)¶ Create a new Event object from a JSON representation that conforms to the following format:
{ "id": 0, "id_network": 0, "id_host": 0, "date_created": "string", "event_date": "2018-06-23T04:39:42.600Z", "title": "string", "address_1": "string", "address_2": "string", "country": "string", "city": "string", "region": "string", "description": "string" }
Note that
date_created
is not used and may be omitted. Empty address fields should benull
.Parameters: - json – JSON representation of the
Event
to be created
Throws: - JSONException – May be thrown if an improperly formatted JSON is provided
- json – JSON representation of the
Methods¶
getAddress¶
-
public String
getAddress
()¶ Generate a formatted form of the address for the event that is suitable for display to user.
Returns: UI-suitable form of the address where the event will take place. Address portions (line1, line2, city, region, and country) are separated by commas, and missing portions are excluded. Example: 123 Any Street, New York, New York
. The address portions are user-generated, so this String may not describe a valid address. If no address is specified (i.e. if all address portions are missing), theEvent.NOWHERE
constant is returned.
getAuthor¶
getDescription¶
getPostJson¶
-
public JSONObject
getPostJson
()¶ Create a JSON representation of the object that conforms to the following format:
{ "id_network": 0, "id_host": 0, "event_date": "2018-07-21T15:10:30.838Z", "title": "string", "address_1": "string", "address_2": "string", "country": "string", "city": "string", "region": "string", "description": "string" }
This is intended to be the format used by the
/event/new
POST endpoint.Throws: - JSONException – Unclear when this would be thrown
Returns: JSON representation of the object
getPutJson¶
-
public JSONObject
getPutJson
()¶ Create a JSON representation of the object that conforms to the following format:
{ "id": 0, "id_network": 0, "id_host": 0, "event_date": "2018-07-21T15:10:30.838Z", "title": "string", "address_1": "string", "address_2": "string", "country": "string", "city": "string", "region": "string", "description": "string" }
This is intended to be the format used by the
/event/new
PUT endpoint.Throws: - JSONException – Unclear when this would be thrown
Returns: JSON representation of the object