예제 #1
0
 /**
  * @param Request $request
  * @param Created $payload
  */
 public function created(Request $request, Created $payload)
 {
     $serializer = Startgroup::getSerializer();
     $resource = new Resource($payload->getModel(), $serializer);
     $document = new Document($resource);
     return new JsonResponse($document->toArray(), 201, ['Location' => $resource->getLinks()['self']]);
 }
 /**
  * @param Request $request
  * @param Updated $payload
  */
 public function updated(Request $request, Updated $payload)
 {
     $params = new Parameters($request->query->all());
     $serializer = PerformanceStatistic::getSerializer();
     $resource = new Resource($payload->getModel(), $serializer);
     $resource = $resource->with($params->getInclude(['events', 'startgroups', 'routine']));
     $resource = $resource->fields($params->getFields(['performance-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'event' => Event::getSerializer()->getFields(), 'startgroup' => Startgroup::getSerializer()->getFields(), 'routine' => Routine::getSerializer()->getFields()]));
     $document = new Document($resource);
     return new JsonResponse($document->toArray(), 200);
 }
예제 #3
0
 /**
  * @param Request $request
  * @param Found $payload
  */
 public function found(Request $request, Found $payload)
 {
     $params = new Parameters($request->query->all());
     $serializer = Competition::getSerializer();
     $resource = new Resource($payload->getModel(), $serializer);
     $resource = $resource->with($params->getInclude(['startgroups']));
     $resource = $resource->fields($params->getFields(['competition' => Competition::getSerializer()->getFields(), 'startgroup' => Startgroup::getSerializer()->getFields()]));
     $document = new Document($resource);
     return new JsonResponse($document->toArray(), 200);
 }
예제 #4
0
 /**
  * @param Request $request
  * @param Updated $payload
  */
 public function updated(Request $request, Updated $payload)
 {
     $params = new Parameters($request->query->all());
     $serializer = Startgroup::getSerializer();
     $resource = new Resource($payload->getModel(), $serializer);
     $resource = $resource->with($params->getInclude(['competition', 'event', 'performance-total-statistic', 'performance-execution-statistic', 'performance-choreography-statistic', 'performance-music-and-timing-statistic', 'routines', 'judges', 'routines.performance-total-statistic', 'routines.performance-execution-statistic', 'routines.performance-choreography-statistic', 'routines.performance-music-and-timing-statistic', 'routines.performance-scores', 'routines.performance-scores.judge']));
     $resource = $resource->fields($params->getFields(['startgroup' => Startgroup::getSerializer()->getFields(), 'competition' => Competition::getSerializer()->getFields(), 'event' => Event::getSerializer()->getFields(), 'performance-total-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'performance-execution-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'performance-choreography-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'performance-music-and-timing-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'routine' => Routine::getSerializer()->getFields(), 'judge' => Judge::getSerializer()->getFields()]));
     $document = new Document($resource);
     return new JsonResponse($document->toArray(), 200);
 }
예제 #5
0
 /**
  * @param Request $request
  * @param Found $payload
  */
 public function found(Request $request, Found $payload)
 {
     $params = new Parameters($request->query->all());
     $serializer = Judge::getSerializer();
     $resource = new Resource($payload->getModel(), $serializer);
     $resource = $resource->with($params->getInclude(['startgroup', 'user', 'performance-score']));
     $resource = $resource->fields($params->getFields(['judge' => Judge::getSerializer()->getFields(), 'startgroup' => Startgroup::getSerializer()->getFields(), 'user' => User::getSerializer()->getFields(), 'performance-score' => PerformanceScore::getSerializer()->getFields()]));
     $document = new Document($resource);
     return new JsonResponse($document->toArray(), 200);
 }
예제 #6
0
 /**
  * @param Request $request
  * @param Found $payload
  */
 public function found(Request $request, Found $payload)
 {
     $params = new Parameters($request->query->all());
     $serializer = Routine::getSerializer();
     $resource = new Resource($payload->getModel(), $serializer);
     $resource = $resource->with($params->getInclude(['startgroup', 'performance-total-statistic', 'performance-execution-statistic', 'performance-choreography-statistic', 'performance-music-and-timing-statistic', 'performance-scores']));
     $resource = $resource->fields($params->getFields(['routine' => Routine::getSerializer()->getFields(), 'startgroup' => Startgroup::getSerializer()->getFields(), 'performance-total-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'performance-execution-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'performance-choreography-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'performance-music-and-timing-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'performance-score' => PerformanceScore::getSerializer()->getFields()]));
     $document = new Document($resource);
     return new JsonResponse($document->toArray(), 200);
 }
예제 #7
0
 private function analyzeGroup(Startgroup $group)
 {
     $groups = new Map();
     $this->prepareMap($groups);
     foreach ($group->getRoutines() as $routine) {
         foreach ($this->targets as $key => $target) {
             $getter = sprintf('getPerformance%sStatistic', $target);
             $statistic = $routine->{$getter}();
             if ($statistic === null) {
                 $setter = sprintf('setPerformance%sStatistic', $target);
                 $statistic = new PerformanceStatistic();
                 $routine->{$setter}($statistic);
             }
             $statistic = $this->analyzeRoutine($routine, $statistic, $target);
             $this->all->get($key)->add($statistic);
             $groups->get($key)->add($statistic);
         }
         $routine->save();
     }
     $this->processSummary($group, $groups);
     $group->save();
 }
예제 #8
0
 /**
  * @param Request $request
  * @param Found $payload
  */
 public function found(Request $request, Found $payload)
 {
     $params = new Parameters($request->query->all());
     $data = $payload->getModel();
     $serializer = Startgroup::getSerializer();
     $resource = new Collection($data, $serializer);
     $resource = $resource->with($params->getInclude(['competition', 'event', 'performance-total-statistic', 'performance-execution-statistic', 'performance-choreography-statistic', 'performance-music-and-timing-statistic', 'routines', 'judges', 'routines.performance-total-statistic', 'routines.performance-execution-statistic', 'routines.performance-choreography-statistic', 'routines.performance-music-and-timing-statistic', 'routines.performance-scores', 'routines.performance-scores.judge']));
     $resource = $resource->fields($params->getFields(['startgroup' => Startgroup::getSerializer()->getFields(), 'competition' => Competition::getSerializer()->getFields(), 'event' => Event::getSerializer()->getFields(), 'performance-total-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'performance-execution-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'performance-choreography-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'performance-music-and-timing-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'routine' => Routine::getSerializer()->getFields(), 'judge' => Judge::getSerializer()->getFields()]));
     $document = new Document($resource);
     // meta
     $document->setMeta(['total' => $data->getNbResults(), 'first' => $data->getFirstPage(), 'next' => $data->getNextPage(), 'previous' => $data->getPreviousPage(), 'last' => $data->getLastPage()]);
     // return response
     return new JsonResponse($document->toArray());
 }
예제 #9
0
 /**
  * @param Request $request
  * @param Found $payload
  */
 public function found(Request $request, Found $payload)
 {
     $params = new Parameters($request->query->all());
     $data = $payload->getModel();
     $serializer = Judge::getSerializer();
     $resource = new Collection($data, $serializer);
     $resource = $resource->with($params->getInclude(['startgroup', 'user', 'performance-score']));
     $resource = $resource->fields($params->getFields(['judge' => Judge::getSerializer()->getFields(), 'startgroup' => Startgroup::getSerializer()->getFields(), 'user' => User::getSerializer()->getFields(), 'performance-score' => PerformanceScore::getSerializer()->getFields()]));
     $document = new Document($resource);
     // meta
     $document->setMeta(['total' => $data->getNbResults(), 'first' => $data->getFirstPage(), 'next' => $data->getNextPage(), 'previous' => $data->getPreviousPage(), 'last' => $data->getLastPage()]);
     // return response
     return new JsonResponse($document->toArray());
 }
예제 #10
0
파일: Routine.php 프로젝트: iuf/junia
 /**
  * Clears the current object, sets all attributes to their default values and removes
  * outgoing references as well as back-references (from other objects to this one. Results probably in a database
  * change of those foreign objects when you call `save` there).
  */
 public function clear()
 {
     if (null !== $this->aStartgroup) {
         $this->aStartgroup->removeRoutine($this);
     }
     if (null !== $this->aPerformanceTotalStatistic) {
         $this->aPerformanceTotalStatistic->removeRoutineRelatedByPerformanceTotalStatisticId($this);
     }
     if (null !== $this->aPerformanceExecutionStatistic) {
         $this->aPerformanceExecutionStatistic->removeRoutineRelatedByPerformanceExecutionStatisticId($this);
     }
     if (null !== $this->aPerformanceChoreographyStatistic) {
         $this->aPerformanceChoreographyStatistic->removeRoutineRelatedByPerformanceChoreographyStatisticId($this);
     }
     if (null !== $this->aPerformanceMusicAndTimingStatistic) {
         $this->aPerformanceMusicAndTimingStatistic->removeRoutineRelatedByPerformanceMusicAndTimingStatisticId($this);
     }
     $this->id = null;
     $this->name = null;
     $this->startgroup_id = null;
     $this->performance_total_statistic_id = null;
     $this->performance_execution_statistic_id = null;
     $this->performance_choreography_statistic_id = null;
     $this->performance_music_and_timing_statistic_id = null;
     $this->alreadyInSave = false;
     $this->clearAllReferences();
     $this->resetModified();
     $this->setNew(true);
     $this->setDeleted(false);
 }
예제 #11
0
 /**
  * Filter the query by a related \iuf\junia\model\Startgroup object
  *
  * @param \iuf\junia\model\Startgroup|ObjectCollection $startgroup the related object to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildPerformanceStatisticQuery The current query, for fluid interface
  */
 public function filterByStartgroupRelatedByPerformanceMusicAndTimingStatisticId($startgroup, $comparison = null)
 {
     if ($startgroup instanceof \iuf\junia\model\Startgroup) {
         return $this->addUsingAlias(PerformanceStatisticTableMap::COL_ID, $startgroup->getPerformanceMusicAndTimingStatisticId(), $comparison);
     } elseif ($startgroup instanceof ObjectCollection) {
         return $this->useStartgroupRelatedByPerformanceMusicAndTimingStatisticIdQuery()->filterByPrimaryKeys($startgroup->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByStartgroupRelatedByPerformanceMusicAndTimingStatisticId() only accepts arguments of type \\iuf\\junia\\model\\Startgroup or Collection');
     }
 }
 /**
  * @param Request $request
  * @param Found $payload
  */
 public function read(Request $request, Found $payload)
 {
     $serializer = Startgroup::getSerializer();
     $relationship = $serializer->performanceTotalStatistic($payload->getModel());
     return new JsonResponse($relationship->toArray());
 }
예제 #13
0
 /**
  * @param Request $request
  * @param Updated $payload
  */
 public function updated(Request $request, Updated $payload)
 {
     $serializer = Startgroup::getSerializer();
     $relationship = $serializer->routines($payload->getModel());
     return new JsonResponse($relationship->toArray());
 }
예제 #14
0
 /**
  * Exclude object from result
  *
  * @param   ChildStartgroup $startgroup Object to remove from the list of results
  *
  * @return $this|ChildStartgroupQuery The current query, for fluid interface
  */
 public function prune($startgroup = null)
 {
     if ($startgroup) {
         $this->addUsingAlias(StartgroupTableMap::COL_ID, $startgroup->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
예제 #15
0
 /**
  * @param mixed $model
  * @return Relationship
  */
 public function startgroup($model)
 {
     $serializer = Startgroup::getSerializer();
     $id = $serializer->getId($model->getStartgroup());
     if ($id !== null) {
         $relationship = new Relationship(new Resource($model->getStartgroup(), $serializer));
         $relationship->setLinks(['related' => '%apiurl%' . $serializer->getType(null) . '/' . $id]);
         return $this->addRelationshipSelfLink($relationship, $model, 'startgroup');
     }
     return null;
 }
 /**
  * @param mixed $model
  * @return Relationship
  */
 public function startgroups($model)
 {
     $relationship = new Relationship(new Collection($model->getStartgroups(), Startgroup::getSerializer()));
     return $this->addRelationshipSelfLink($relationship, $model, 'startgroup');
 }
예제 #17
0
파일: Judge.php 프로젝트: iuf/junia
 /**
  * Clears the current object, sets all attributes to their default values and removes
  * outgoing references as well as back-references (from other objects to this one. Results probably in a database
  * change of those foreign objects when you call `save` there).
  */
 public function clear()
 {
     if (null !== $this->aStartgroup) {
         $this->aStartgroup->removeJudge($this);
     }
     if (null !== $this->aUser) {
         $this->aUser->removeJudge($this);
     }
     $this->id = null;
     $this->position = null;
     $this->startgroup_id = null;
     $this->user_id = null;
     $this->alreadyInSave = false;
     $this->clearAllReferences();
     $this->resetModified();
     $this->setNew(true);
     $this->setDeleted(false);
 }
 /**
  * @param Request $request
  * @param Found $payload
  */
 public function read(Request $request, Found $payload)
 {
     $serializer = Startgroup::getSerializer();
     $relationship = $serializer->competition($payload->getModel());
     return new JsonResponse($relationship->toArray());
 }
예제 #19
0
 /**
  * @param string $name
  * @return Startgroup
  */
 private function getStartgroup($name)
 {
     $name = $this->translate($name);
     // some special cases
     $competition = null;
     if ($name == 'Junior Expert (male)' || $name == 'Expert (male)') {
         $competition = $this->competitions->get('Individual Freestyle (male)');
         $startgroupName = str_replace(' (male)', '', $name);
     } else {
         if ($name == 'Junior Expert (female)' || $name == 'Expert (female)') {
             $competition = $this->competitions->get('Individual Freestyle (female)');
             $startgroupName = str_replace(' (female)', '', $name);
         }
     }
     if ($competition === null) {
         $words = new Set();
         foreach (array_values($this->translations) as $names) {
             $words->addAll(Text::create($names)->split(' '));
         }
         $startgroupName = trim(str_replace($words->toArray(), '', $name));
         $words = Text::create($startgroupName)->split(' ');
         $competitionName = preg_replace('/\\s\\s+/', ' ', trim(str_replace($words->toArray(), '', $name)));
         if (!$this->competitions->has($competitionName)) {
             throw new \Exception('Cannot find competition for ' . $competitionName);
         }
         $competition = $this->competitions->get($competitionName);
     }
     $startgroup = new Startgroup();
     $startgroup->setName($startgroupName);
     $startgroup->setSlug(NameUtils::dasherize(strtolower($startgroupName)));
     $startgroup->setCompetition($competition);
     return $startgroup;
 }
예제 #20
0
 /**
  * @param ChildStartgroup $startgroupRelatedByPerformanceMusicAndTimingStatisticId The ChildStartgroup object to add.
  */
 protected function doAddStartgroupRelatedByPerformanceMusicAndTimingStatisticId(ChildStartgroup $startgroupRelatedByPerformanceMusicAndTimingStatisticId)
 {
     $this->collStartgroupsRelatedByPerformanceMusicAndTimingStatisticId[] = $startgroupRelatedByPerformanceMusicAndTimingStatisticId;
     $startgroupRelatedByPerformanceMusicAndTimingStatisticId->setPerformanceMusicAndTimingStatistic($this);
 }
예제 #21
0
파일: Competition.php 프로젝트: iuf/junia
 /**
  * @param ChildStartgroup $startgroup The ChildStartgroup object to add.
  */
 protected function doAddStartgroup(ChildStartgroup $startgroup)
 {
     $this->collStartgroups[] = $startgroup;
     $startgroup->setCompetition($this);
 }
예제 #22
0
파일: JudgeQuery.php 프로젝트: iuf/junia
 /**
  * Filter the query by a related \iuf\junia\model\Startgroup object
  *
  * @param \iuf\junia\model\Startgroup|ObjectCollection $startgroup The related object(s) to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @throws \Propel\Runtime\Exception\PropelException
  *
  * @return ChildJudgeQuery The current query, for fluid interface
  */
 public function filterByStartgroup($startgroup, $comparison = null)
 {
     if ($startgroup instanceof \iuf\junia\model\Startgroup) {
         return $this->addUsingAlias(JudgeTableMap::COL_STARTGROUP_ID, $startgroup->getId(), $comparison);
     } elseif ($startgroup instanceof ObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(JudgeTableMap::COL_STARTGROUP_ID, $startgroup->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByStartgroup() only accepts arguments of type \\iuf\\junia\\model\\Startgroup or Collection');
     }
 }
예제 #23
0
 /**
  * Updates a Startgroup with the given idand the provided data
  * 
  * @param mixed $id
  * @param mixed $data
  * @return PayloadInterface
  */
 public function update($id, $data)
 {
     // find
     $model = $this->get($id);
     if ($model === null) {
         return new NotFound(['message' => 'Startgroup not found.']);
     }
     // hydrate
     $serializer = Startgroup::getSerializer();
     $model = $serializer->hydrate($model, $data);
     // validate
     $validator = $this->getValidator();
     if ($validator !== null && !$validator->validate($model)) {
         return new NotValid(['errors' => $validator->getValidationFailures()]);
     }
     // dispatch
     $event = new StartgroupEvent($model);
     $dispatcher = $this->getServiceContainer()->getDispatcher();
     $dispatcher->dispatch(StartgroupEvent::PRE_UPDATE, $event);
     $dispatcher->dispatch(StartgroupEvent::PRE_SAVE, $event);
     $rows = $model->save();
     $dispatcher->dispatch(StartgroupEvent::POST_UPDATE, $event);
     $dispatcher->dispatch(StartgroupEvent::POST_SAVE, $event);
     $payload = ['model' => $model];
     if ($rows === 0) {
         return new NotUpdated($payload);
     }
     return new Updated($payload);
 }