public static function show(Inputter $inputter, JSONOutputter $outputter)
    {
        //	Show
        //
        $id = $inputter->additional_uri_arguments[0];
        $error = null;
        UniversallyUniqueIdentifier::propertyIsValid('rawIdentifier', $id, $error);
        if (isset($error)) {
            $outputter->print_error($error);
        }
        //	User ID
        //
        $client = new Everyman\Neo4j\Client('events.sb04.stations.graphenedb.com', 24789);
        $client->getTransport()->setAuth('Events', '3TP9LHROhv8LIcGmbYzq');
        $query_string = 'MATCH (object:Album)
						 WHERE object.' . UNIVERSALLY_UNIQUE_OBJECT_KEY_IDENTIFICATION . ' = \'' . $id . '\'
						 RETURN object';
        $query = new Everyman\Neo4j\Cypher\Query($client, $query_string);
        $result = $query->getResultSet();
        if (count($result) > 0) {
            //	Compare sent data is equal to data retrieved
            //
            $object = $result[0]['object'];
            //	Print data
            //
            $outputter->print_data(array(Album::printer_dictionary($object)));
        } else {
            // Throw error, user doesn't exists
            //
            $error = Error::withDomain(PRIVATE_EVENTS_REST_CONTROLLER_ERROR_DOMAIN, PRIVATE_EVENTS_REST_CONTROLLER_ERROR_CODE_ENTITY_DOES_NOT_EXIST, 'Album with ID does not exist.');
            $outputter->print_error($error);
        }
    }
 public static function isValid(&$properties_dictionary, $limit_to_keys, &$error)
 {
     //	Check each property is valid
     //
     if (isset($properties_dictionary[UNIVERSALLY_UNIQUE_OBJECT_KEY_IDENTIFICATION])) {
         $properties = array('rawIdentifier' => $properties_dictionary[UNIVERSALLY_UNIQUE_OBJECT_KEY_IDENTIFICATION]);
         if (ValidationC::should_test_property(UNIVERSALLY_UNIQUE_OBJECT_KEY_IDENTIFICATION, $properties_dictionary, true, $limit_to_keys) && !UniversallyUniqueIdentifier::isValid($properties, true, $error)) {
             //	Identifier was not valid
             //
             return false;
         }
     }
     if (ValidationC::should_test_property(UNIVERSALLY_UNIQUE_OBJECT_KEY_DATE_CREATED, $properties_dictionary, true, $limit_to_keys) && !UniversallyUniqueObject::propertyIsValid(UNIVERSALLY_UNIQUE_OBJECT_KEY_DATE_CREATED, $properties_dictionary[UNIVERSALLY_UNIQUE_OBJECT_KEY_DATE_CREATED], $error)) {
         //	Date created was not valid
         //
         return false;
     }
     if (ValidationC::should_test_property(UNIVERSALLY_UNIQUE_OBJECT_KEY_DATE_UPDATED, $properties_dictionary, true, $limit_to_keys) && !UniversallyUniqueObject::propertyIsValid(UNIVERSALLY_UNIQUE_OBJECT_KEY_DATE_UPDATED, $properties_dictionary[UNIVERSALLY_UNIQUE_OBJECT_KEY_DATE_UPDATED], $error)) {
         //	Date updated was not valid
         //
         return false;
     }
     if (ValidationC::should_test_property(UNIVERSALLY_UNIQUE_OBJECT_KEY_DATE_CREATED, $properties_dictionary, true, $limit_to_keys) && ValidationC::should_test_property(UNIVERSALLY_UNIQUE_OBJECT_KEY_DATE_UPDATED, $properties_dictionary, true, $limit_to_keys)) {
         //	Date updated cannot be before date created
         //
         if ($properties_dictionary[UNIVERSALLY_UNIQUE_OBJECT_KEY_DATE_CREATED] > $properties_dictionary[UNIVERSALLY_UNIQUE_OBJECT_KEY_DATE_UPDATED]) {
             //	Updated was before created
             //
             $error = Error::withDomain(VALIDATION_ERROR_DOMAIN, VALIDATION_ERROR_CODE_INVALID_PROPERTY, UNIVERSALLY_UNIQUE_OBJECT_KEY_DATE_CREATED . ' was before ' . UNIVERSALLY_UNIQUE_OBJECT_KEY_DATE_UPDATED);
             return false;
         }
     }
     return true;
 }
 public static function isValid(&$properties_dictionary, $limit_to_keys, &$error)
 {
     //	Check each property is valid
     //
     if (ValidationC::should_test_property('rawIdentifier', $properties_dictionary, true, $limit_to_keys) && !UniversallyUniqueIdentifier::propertyIsValid('rawIdentifier', $properties_dictionary['rawIdentifier'], $error)) {
         //	Identification was not valid
         //
         return false;
     }
     return true;
 }
 public static function list_event(Inputter $inputter, JSONOutputter $outputter)
 {
     //	List for event
     //
     //      Verify input
     //
     $required_dictionary = array('event_identification' => '');
     $inputter->validate_input($required_dictionary, null);
     //      Validate
     //
     $event_id = $inputter->variables_array['event_identification'];
     $event_error = null;
     UniversallyUniqueIdentifier::propertyIsValid('rawIdentifier', $event_id, $event_error);
     if (isset($event_error)) {
         $outputter->print_error($event_error);
     }
     //	Event ID
     //
     $client = new Everyman\Neo4j\Client('events.sb04.stations.graphenedb.com', 24789);
     $client->getTransport()->setAuth('Events', '3TP9LHROhv8LIcGmbYzq');
     $query_string = 'MATCH (occurrence:EventSpaceTimeOccurrence)-[:event]-(event:Event), (occurrence)-[:location]-(location:Location), (occurrence)-[:confined_date]-(confinedDate:ConfinedDate), (occurrence)-[:attendees_range]-(attendeesRange:Range) ' . 'WHERE event.' . UNIVERSALLY_UNIQUE_OBJECT_KEY_IDENTIFICATION . " = '" . $event_id . "' " . 'RETURN occurrence, location, confinedDate, attendeesRange';
     $query = new Everyman\Neo4j\Cypher\Query($client, $query_string);
     $result = $query->getResultSet();
     if (count($result) > 0) {
         $event_occurrence_prints = array();
         foreach ($result as $row) {
             $event_occurrence_print = EventSpaceTimeOccurrence::printer_dictionary($row['occurrence']);
             $event_occurrence_print[SPACE_TIME_OCCURRENCE_RELATIONSHIP_NAME_LOCATION] = Location::printer_dictionary($row['location']);
             $event_occurrence_print[SPACE_TIME_OCCURRENCE_RELATIONSHIP_NAME_CONFINED_DATE] = ConfinedDate::printer_dictionary($row['confinedDate']);
             $event_occurrence_print[EVENT_SPACE_TIME_OCCURRENCE_RELATIONSHIP_NAME_RANGE] = Range::printer_dictionary($row['attendeesRange']);
             array_push($event_occurrence_prints, $event_occurrence_print);
         }
         //	Print data
         //
         $outputter->print_data($event_occurrence_prints);
     } else {
         // Throw error, user doesn't exists
         //
         $error = Error::withDomain(PRIVATE_EVENTS_REST_CONTROLLER_ERROR_DOMAIN, PRIVATE_EVENTS_REST_CONTROLLER_ERROR_CODE_ENTITY_DOES_NOT_EXIST, 'No Event Occurrences for Event with identification ' . $event_id . ' does not exist.');
         $outputter->print_error($error);
     }
 }
 public static function destroy(Inputter $inputter, JSONOutputter $outputter)
 {
     //	User ID
     //
     //	1) Test all data is available and valid
     //
     //		identification
     //
     $identification_error = null;
     if (!UniversallyUniqueIdentifier::isValid($propertiesDictionary['identification'], true, $identification_error)) {
         $outputter->print_error($identification_error);
     }
     $validPropertiesDictionary['identification'] = $propertiesDictionary['identification'];
     //	2) Check user to update exists
     //
     //		User might exist (check against identification)
     //
     //			Create query
     //
     $client = new Everyman\Neo4j\Client('events.sb04.stations.graphenedb.com', 24789);
     $client->getTransport()->setAuth('Events', '3TP9LHROhv8LIcGmbYzq');
     $query_string_check_user = '******' . 'WHERE user.' . UNIVERSALLY_UNIQUE_IDENTIFIER_KEY_IDENTIFICATION . ' = \'' . $validPropertiesDictionary['identification'] . '\' ' . 'RETURN user';
     $query_check_user = new Everyman\Neo4j\Cypher\Query($client, $query_string_check_user);
     //			Run query
     //
     $result_check_user = $query_check_user->getResultSet();
     //			Do something based on the results
     //
     if ($result_check_user->count() < 1) {
         //	No users exist
         //
         $error = Error::withDomain(PRIVATE_EVENTS_REST_CONTROLLER_ERROR_DOMAIN, PRIVATE_EVENTS_REST_CONTROLLER_ERROR_CODE_ENTITY_DOES_NOT_EXIST, 'A user with the identification ' . $validPropertiesDictionary['identification'] . ' doesn\'t exist.');
         $outputter->print_error($error);
     }
     //	3) We've got the go ahead to process the request as it's intended - delete the user from the data store
     //
     //		Create query string
     //
     $query_string_delete_account = 'MATCH (user:User) ' . 'WHERE user.' . UNIVERSALLY_UNIQUE_IDENTIFIER_KEY_IDENTIFICATION . ' = \'' . $validPropertiesDictionary['identification'] . '\' ' . 'DELETE user ';
     //		Query
     //
     $query_delete_account = new Everyman\Neo4j\Cypher\Query($client, $query_string_delete_account);
     //		Run query
     //
     $result_delete_account = $query_delete_account->getResultSet();
     //	4) Output our final response
     //
     if ($result_delete_account != null) {
         $outputter->print_data();
     } else {
         // Throw error, no result
         //
         $error = Error(PRIVATE_EVENTS_REST_CONTROLLER_ERROR_DOMAIN, HTTP_INTERNAL_SERVER_ERROR);
         $outputter->print_error($error);
     }
 }
 public static function list_invited(Inputter $inputter, JSONOutputter $outputter)
 {
     //	List Invited
     //
     //  Constants
     //
     $invited_user_identification = 'invited_user_identification';
     //  Verify input
     //
     $required_keys = array($invited_user_identification => '');
     $inputter->validate_input($required_keys, null);
     //  Validate input
     //
     $validate_error = null;
     UniversallyUniqueIdentifier::propertyIsValid('rawIdentifier', $inputter->variables_array[$invited_user_identification], $validate_error);
     if (isset($validate_error)) {
         $outputter->print_error($validate_error);
     }
     //	Events
     //
     $client = new Everyman\Neo4j\Client('events.sb04.stations.graphenedb.com', 24789);
     $client->getTransport()->setAuth('Events', '3TP9LHROhv8LIcGmbYzq');
     $query_string = 'MATCH (invitedUser:AttendingUser)-[:softInvitation]-(event:Event)-[:type]-(eventType:EventType) ' . 'WHERE invitedUser.' . UNIVERSALLY_UNIQUE_OBJECT_KEY_IDENTIFICATION . " = '" . $inputter->variables_array[$invited_user_identification] . "' " . 'RETURN invitedUser, event, eventType';
     $query = new Everyman\Neo4j\Cypher\Query($client, $query_string);
     $result = $query->getResultSet();
     $creator = $result[0]['invitedUser'];
     if (count($creator) > 0) {
         //	Compare sent data is equal to data retrieved
         //
         $events_printer_dictionaries = array();
         foreach ($result as $value) {
             $event_print = Event::printer_dictionary($value['event']);
             $event_print[EVENT_RELATIONSHIP_NAME_TYPE] = EventType::printer_dictionary($value['eventType']);
             $event_print[EVENT_RELATIONSHIP_NAME_CREATOR] = AttendingUser::printer_dictionary($value['invitedUser']);
             array_push($events_printer_dictionaries, $event_print);
         }
         //	Print data
         //
         $outputter->print_data($events_printer_dictionaries);
     } else {
         // Throw error, user doesn't exists
         //
         $error = Error::withDomain(PRIVATE_EVENTS_REST_CONTROLLER_ERROR_DOMAIN, PRIVATE_EVENTS_REST_CONTROLLER_ERROR_CODE_ENTITY_DOES_NOT_EXIST, 'No such user with identification ' . $invited_user_identification . '.');
         $outputter->print_error($error);
     }
 }