/** * Display specified contract * * @return Response */ public function show($id) { $contract = $this->contract->findWithAnnotations($id); if (!$contract) { abort('404'); } $translatedFrom = []; if (isset($contract->metadata->translated_from) && !empty($contract->metadata->translated_from)) { $translatedFrom = $this->contract->getcontracts($contract->metadata->translated_from); } $supportingDocument = $this->contract->getSupportingDocuments($contract->id); $status = $this->contract->getStatus($id); $annotationStatus = $this->annotation->getStatus($id); $annotations = $contract->annotations; $contract->metadata_comment = $this->comment->getLatest($contract->id, Comment::TYPE_METADATA); $contract->text_comment = $this->comment->getLatest($contract->id, Comment::TYPE_TEXT); $contract->annotation_comment = $this->comment->getLatest($contract->id, Comment::TYPE_ANNOTATION); return view('contract.show', compact('contract', 'status', 'annotations', 'annotationStatus', 'translatedFrom', 'supportingDocument')); }
/** * Post contract annotations * * @param $id */ public function postAnnotation($id) { $contract = $this->contract->findWithAnnotations($id); $annotationData = []; $data = []; $annotations = $contract->annotations; foreach ($annotations as $annotation) { $json = $annotation->annotation; $json->id = $annotation->id; $json->contact_id = $contract->id; $json->metadata = $this->getMetadataForES($contract->metadata, true); $annotationData[] = $json; } $data['annotations'] = json_encode($annotationData); try { $request = $this->http->post($this->apiURL('contract/annotations'), null, $data); $response = $request->send(); $this->logger->info('Annotation successfully submitted to Elastic Search.', $response->json()); } catch (Exception $e) { $this->logger->error($e->getMessage()); } }