/** * @Route("/test/{message}/{stepNumber}", name="datamap_test") */ public function testAction(Message $message, $stepNumber) { $steps = json_decode($message->getFlow(), true); if (!isset($steps[$stepNumber])) { throw new NotFoundHttpException(); } $step = $steps[$stepNumber]; $datamap = $this->getDoctrine()->getManager()->getRepository('VRAppBundle:Datamap')->findOneByName($step['Datamap']); if (!$datamap) { throw new NotFoundHttpException(); } $data = json_decode($message->getFlowMessage()); if ($message->getFlowName() == 'nne') { $data = $data[$stepNumber - 1]; } $map = new Map(json_decode($datamap->getMap(), true)); $dataMapper = new DataMapper(); $dataMapper->setMap($map); return $this->render('VRAppBundle:Datamap:test.html.twig', array('message' => json_encode($data, JSON_PRETTY_PRINT), 'datamap' => $datamap, 'output' => json_encode($dataMapper->map($data), JSON_PRETTY_PRINT))); }
public function generateWithJsonErrorInFlowMessage($manager) { $message = new Message(); $message->setFlowCreatedAt(new \DateTime()); $message->setFlow(json_encode([1 => ['Module' => 'Accounts', 'GUID' => uniqid(), 'Datamap' => 'ExampleDatamap', 'Status' => 'Done'], 2 => ['Module' => 'Contacts', 'GUID' => uniqid(), 'Datamap' => 'ExampleDatamap', 'Status' => 'Error'], 3 => ['Module' => 'Tasks', 'GUID' => uniqid(), 'Datamap' => 'ExampleDatamap', 'Status' => 'In progress'], 4 => ['Module' => 'Relation', 'GUID' => '', 'SourceModule' => 'Accounts', 'DestinationModule' => 'Contacts', 'SourceStep' => 1, 'DestinationStep' => 2, 'Status' => 'New']])); $message->setFlowStatus('New'); $message->setFlowMessage('some text'); $message->setFlowName('nne'); $manager->persist($message); }
/** * @Route("/set-step-guid/{id}/{stepNumber}", name="message_set_step_guid") * * @param Request $request * @param Message $message * @param integer $stepNumber * * @throws \Exception * * @return \Symfony\Component\HttpFoundation\RedirectResponse */ public function setStepGuidAction(Request $request, Message $message, $stepNumber) { $guid = $request->get('guid'); $newGuid = $request->get('new-guid-value'); if (!$guid) { $this->get('session')->getFlashBag()->add('error', 'Error setting GUID. Form is not valid.'); return $this->redirect($request->headers->get('referer')); } if ($guid == 'new-guid') { if ($newGuid) { $guid = $newGuid; } else { $this->get('session')->getFlashBag()->add('error', 'Please provide new GUID value.'); return $this->redirect($request->headers->get('referer')); } } $em = $this->getDoctrine()->getManager(); $message->changeStepParameter($stepNumber, 'GUID', $guid); $message->batchChangeStepStatuses(null, 'New'); $message->setFlowStatus('New'); $em->persist($message); $em->flush(); $this->get('session')->getFlashBag()->add('success', 'GUID set successfully in step number ' . $stepNumber); return $this->redirect($request->headers->get('referer')); }
public function testGetPayloadArray() { $message = new Message(); $this->assertNull($message->getPayloadArray()); $flowMessage = ['a' => array('some-key-1' => 'some-value-1'), 'b' => array('some-key-1' => 'some-value-2')]; $message->setFlowMessage(json_encode($flowMessage)); $this->assertCount(2, $message->getPayloadArray()); }