コード例 #1
0
    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 (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);
     }
 }
コード例 #4
0
 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);
     }
 }