Event

public class Event extends FeedItem implements Serializable, Putable, Postable

Describes an event like those shared in Networks

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

public String addressLine1

First line of the address where the event is to take place. Some addresses may not have this value, in which case its value will be Event.NOWHERE_INTERNAL.

addressLine2

public String addressLine2

Second line of the address where the event is to take place. Some addresses may not have this value, in which case its value will be Event.NOWHERE_INTERNAL.

authorId

public long authorId

Unique identifier of the User who created the event

city

public String city

City portion of the address where the event is to take place. Some addresses may not have this value, in which case its value will be Event.NOWHERE_INTERNAL.

country

public String country

Country portion of the address where the event is to take place. Some addresses may not have this value, in which case its value will be Event.NOWHERE_INTERNAL.

description

public String description

User-generated description of the event. May contain formatting from org.codethechange.culturemesh.FormatManager.

See also: org.codethechange.culturemesh.CreateEventActivity

id

public long id

A unique identifier for the event. This should be generated server-side.

networkId

public long networkId

Unique identifier corresponding to the Network the Event is shared within

region

public String region

Region portion of the address where the event is to take place. Some addresses may not have this value, in which case its value will be Event.NOWHERE_INTERNAL.

timeOfEvent

public String timeOfEvent

Date and time of the event which must strictly conform to yyyy-MM-ddTHH:mm:ss.SSSZ. For example, 2015-01-01T15:00:00.000Z is an acceptable value.

title

public String title

User-generated title for the event. Generally short (one line).

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 the Event
  • 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 be null.

Parameters:
  • json – JSON representation of the Event to be created
Throws:
  • JSONException – May be thrown if an improperly formatted JSON is provided

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), the Event.NOWHERE constant is returned.

getAuthor

public long getAuthor()

Get the unique identifier of the User who created the event

Returns:Unique identifier of event author

getDescription

public String getDescription()

Get the author-generated description of the Event

Returns:Text the User wrote to describe the event

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

getTimeOfEvent

public String getTimeOfEvent()

Get the date and time of the event

Returns:Timestamp for the event, which will be formatted as yyyy-MM-ddTHH:mm:ss.SSSZ

getTitle

public String getTitle()

Get the author-generated title for the Event

Returns:Title the User chose to describe the event

setAuthor

public void setAuthor(User author)

Set the ID of the event’s author. WARNING: The same ID must be used for a given User across CultureMesh.

Parameters:
  • author – Unique identifier of the User who created the event.

setDescription

public void setDescription(String description)

Set the author-generated description of the Event

Parameters:
  • description – Text the User wrote to describe the event

setTimeOfEvent

public void setTimeOfEvent(String timeOfEvent)

Set the date and time of the event

Parameters:
  • timeOfEvent – Timestamp for when the event will occur. Must strictly conform to yyyy-MM-ddTHH:mm:ss.SSSZ.

setTitle

public void setTitle(String title)

Set the author-generated title for the Event

Parameters:
  • title – Title the User chose to describe the event