13 namespace Fossology\UI\Api\Controllers;
21 use Psr\Http\Message\ServerRequestInterface;
29 const FILE_INPUT_NAME =
'fileInput';
32 private $highlightProcessor;
40 $this->highlightProcessor = $this->container->get(
'view.highlight_processor');
41 $this->licenseDao = $this->container->get(
'dao.license');
55 $symReq = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
56 $uploadedFile = $symReq->files->get($this::FILE_INPUT_NAME,
null);
57 if (is_null($uploadedFile)) {
60 if ($uploadedFile->getError() !== UPLOAD_ERR_OK) {
63 list($licenses, $highlightInfoKeywords, $highlightInfoLicenses) = $this->restHelper->getPlugin(
'agent_nomos_once')->
64 AnalyzeFile($uploadedFile->getPathname(),
true);
66 $highlights = array();
68 for ($index = 0; $index < count($highlightInfoKeywords[
'position']); $index ++) {
69 $position = $highlightInfoKeywords[
'position'][$index];
70 $length = $highlightInfoKeywords[
'length'][$index];
72 $highlights[] =
new Highlight($position, $position + $length,
75 for ($index = 0; $index < count($highlightInfoLicenses[
'position']); $index ++) {
76 $position = $highlightInfoLicenses[
'position'][$index];
77 $length = $highlightInfoLicenses[
'length'][$index];
78 $name = $highlightInfoLicenses[
'name'][$index];
80 $highlights[] =
new Highlight($position, $position + $length,
81 Highlight::SIGNATURE, $name);
83 $this->highlightProcessor->sortHighlights($highlights);
84 $returnVal =
new OneShot($licenses, $highlights);
85 return $response->withJson($returnVal->getArray(), 200);
99 $symReq = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
100 $uploadedFile = $symReq->files->get($this::FILE_INPUT_NAME,
null);
101 if (is_null($uploadedFile)) {
104 if ($uploadedFile->getError() !== UPLOAD_ERR_OK) {
108 list($licenseIds, $highlights) = $this->restHelper->getPlugin(
'oneshot-monk')->
109 scanMonk($uploadedFile->getPathname());
110 $this->highlightProcessor->addReferenceTexts($highlights);
111 $licenseArray = array_map(
function($licenseIds) {
112 return ($this->licenseDao->getLicenseById($licenseIds))
115 $returnVal =
new OneShot($licenseArray, $highlights);
116 return $response->withJson($returnVal->getArray(), 200);
130 $symReq = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
131 $uploadedFile = $symReq->files->get($this::FILE_INPUT_NAME,
null);
132 if (is_null($uploadedFile)) {
135 if ($uploadedFile->getError() !== UPLOAD_ERR_OK) {
138 list($copyrights, $highlights) = $this->restHelper->getPlugin(
'agent_copyright_once')->
139 AnalyzeOne(
true, $uploadedFile->getPathname());
140 $this->highlightProcessor->sortHighlights($highlights);
141 $returnVal =
new OneShot($copyrights, $highlights);
142 return $response->withJson($returnVal->getArray(
'copyrights'), 200);
Controller for OneShot Analysis.
runOneShotNomos($request, $response, $args)
runOneShotCEU($request, $response, $args)
runOneShotMonk($request, $response, $args)
Base controller for REST calls.
Override Slim response for withJson function.