예제 #1
0
 /**
  * 
  */
 public function import($data, Event $event)
 {
     $csv = Reader::createFromString(trim($data));
     $csv->setDelimiter(';');
     // get startgroups at first
     $groups = new Map();
     foreach ($csv->fetchColumn(0) as $name) {
         if (!$groups->has($name)) {
             $startgroup = $this->getStartgroup($name);
             $startgroup->setEvent($event);
             $groups->set($name, $startgroup);
         }
     }
     $id = 0;
     foreach ($csv as $row) {
         $id++;
         $routine = $this->getRoutine($id);
         $group = $groups->get($row[0]);
         $judges = (count($row) - 1) / 3;
         for ($j = 1; $j <= $judges; $j++) {
             $score = new PerformanceScore();
             $score->setRoutine($routine);
             $score->setJudge($group->getPerformanceJudge($j));
             $score->setExecution($row[($j - 1) * 3 + 1]);
             $score->setChoreography($row[($j - 1) * 3 + 2]);
             $score->setMusicAndTiming($row[($j - 1) * 3 + 3]);
             $score->setTotal($row[($j - 1) * 3 + 1] + $row[($j - 1) * 3 + 2] + $row[($j - 1) * 3 + 3]);
             $routine->addPerformanceScore($score);
         }
         $group->addRoutine($routine);
         $group->save();
     }
     $event->save();
 }
 /**
  * @param Request $request
  * @param Created $payload
  */
 public function created(Request $request, Created $payload)
 {
     $serializer = PerformanceScore::getSerializer();
     $resource = new Resource($payload->getModel(), $serializer);
     $document = new Document($resource);
     return new JsonResponse($document->toArray(), 201, ['Location' => $resource->getLinks()['self']]);
 }
예제 #3
0
 /**
  * @param Request $request
  * @param Updated $payload
  */
 public function updated(Request $request, Updated $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);
 }
 /**
  * @param Request $request
  * @param Updated $payload
  */
 public function updated(Request $request, Updated $payload)
 {
     $params = new Parameters($request->query->all());
     $serializer = PerformanceScore::getSerializer();
     $resource = new Resource($payload->getModel(), $serializer);
     $resource = $resource->with($params->getInclude(['routine', 'judge']));
     $resource = $resource->fields($params->getFields(['performance-score' => PerformanceScore::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 mixed $model
  * @return Relationship
  */
 public function performanceScore($model)
 {
     $serializer = PerformanceScore::getSerializer();
     $id = $serializer->getId($model->getPerformanceScore());
     if ($id !== null) {
         $relationship = new Relationship(new Resource($model->getPerformanceScore(), $serializer));
         $relationship->setLinks(['related' => '%apiurl%' . $serializer->getType(null) . '/' . $id]);
         return $this->addRelationshipSelfLink($relationship, $model, 'performance-score');
     }
     return null;
 }
예제 #7
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());
 }
예제 #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 = Routine::getSerializer();
     $resource = new Collection($data, $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);
     // 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
파일: JudgeQuery.php 프로젝트: iuf/junia
 /**
  * Filter the query by a related \iuf\junia\model\PerformanceScore object
  *
  * @param \iuf\junia\model\PerformanceScore|ObjectCollection $performanceScore the related object to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildJudgeQuery The current query, for fluid interface
  */
 public function filterByPerformanceScore($performanceScore, $comparison = null)
 {
     if ($performanceScore instanceof \iuf\junia\model\PerformanceScore) {
         return $this->addUsingAlias(JudgeTableMap::COL_ID, $performanceScore->getJudgeId(), $comparison);
     } elseif ($performanceScore instanceof ObjectCollection) {
         return $this->usePerformanceScoreQuery()->filterByPrimaryKeys($performanceScore->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByPerformanceScore() only accepts arguments of type \\iuf\\junia\\model\\PerformanceScore or Collection');
     }
 }
예제 #10
0
파일: Routine.php 프로젝트: iuf/junia
 /**
  * @param ChildPerformanceScore $performanceScore The ChildPerformanceScore object to add.
  */
 protected function doAddPerformanceScore(ChildPerformanceScore $performanceScore)
 {
     $this->collPerformanceScores[] = $performanceScore;
     $performanceScore->setRoutine($this);
 }
예제 #11
0
 /**
  * Exclude object from result
  *
  * @param   ChildPerformanceScore $performanceScore Object to remove from the list of results
  *
  * @return $this|ChildPerformanceScoreQuery The current query, for fluid interface
  */
 public function prune($performanceScore = null)
 {
     if ($performanceScore) {
         $this->addUsingAlias(PerformanceScoreTableMap::COL_ID, $performanceScore->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
예제 #12
0
 /**
  * @param mixed $model
  * @return Relationship
  */
 public function performanceScores($model)
 {
     $relationship = new Relationship(new Collection($model->getPerformanceScores(), PerformanceScore::getSerializer()));
     return $this->addRelationshipSelfLink($relationship, $model, 'performance-score');
 }
예제 #13
0
 /**
  * Updates a PerformanceScore 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' => 'PerformanceScore not found.']);
     }
     // hydrate
     $serializer = PerformanceScore::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 PerformanceScoreEvent($model);
     $dispatcher = $this->getServiceContainer()->getDispatcher();
     $dispatcher->dispatch(PerformanceScoreEvent::PRE_UPDATE, $event);
     $dispatcher->dispatch(PerformanceScoreEvent::PRE_SAVE, $event);
     $rows = $model->save();
     $dispatcher->dispatch(PerformanceScoreEvent::POST_UPDATE, $event);
     $dispatcher->dispatch(PerformanceScoreEvent::POST_SAVE, $event);
     $payload = ['model' => $model];
     if ($rows === 0) {
         return new NotUpdated($payload);
     }
     return new Updated($payload);
 }
 /**
  * @param Request $request
  * @param Found $payload
  */
 public function read(Request $request, Found $payload)
 {
     $serializer = PerformanceScore::getSerializer();
     $relationship = $serializer->judge($payload->getModel());
     return new JsonResponse($relationship->toArray());
 }
예제 #15
0
파일: Score.php 프로젝트: iuf/junia
 /**
  * Sets a single ChildPerformanceScore object as related to this object by a one-to-one relationship.
  *
  * @param  ChildPerformanceScore $v ChildPerformanceScore
  * @return $this|\iuf\junia\model\Score The current object (for fluent API support)
  * @throws PropelException
  */
 public function setPerformanceScore(ChildPerformanceScore $v = null)
 {
     $this->singlePerformanceScore = $v;
     // Make sure that that the passed-in ChildPerformanceScore isn't already associated with this object
     if ($v !== null && $v->getScore(null, false) === null) {
         $v->setScore($this);
     }
     return $this;
 }