FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
UploadSummary.php
Go to the documentation of this file.
1 <?php
2 /***************************************************************
3 Copyright (C) 2020 Siemens AG
4 
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 version 2 as published by the Free Software Foundation.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  ***************************************************************/
22 namespace Fossology\UI\Api\Models;
23 
25 
31 {
32 
37  private $mainLicense;
42  private $uniqueLicenses;
47  private $uploadId;
52  private $totalLicenses;
57  private $uploadName;
77  private $filesCleared;
82  private $clearingStatus;
87  private $copyrightCount;
88 
89  public function __construct()
90  {
91  $this->mainLicense = null;
92  $this->uniqueLicenses = 0;
93  $this->uploadId = null;
94  $this->totalLicenses = 0;
95  $this->uploadName = null;
96  $this->uniqueConcludedLicenses = 0;
97  $this->totalConcludedLicenses = 0;
98  $this->filesToBeCleared = 0;
99  $this->filesCleared = 0;
100  $this->clearingStatus = UploadStatus::OPEN;
101  $this->copyrightCount = 0;
102  }
103 
108  public function getJSON()
109  {
110  return json_encode($this->getArray());
111  }
112 
117  public function getArray()
118  {
119  return [
120  "id" => $this->uploadId,
121  "uploadName" => $this->uploadName,
122  "mainLicense" => $this->mainLicense,
123  "uniqueLicenses" => $this->uniqueLicenses,
124  "totalLicenses" => $this->totalLicenses,
125  "uniqueConcludedLicenses" => $this->uniqueConcludedLicenses,
126  "totalConcludedLicenses" => $this->totalConcludedLicenses,
127  "filesToBeCleared" => $this->filesToBeCleared,
128  "filesCleared" => $this->filesCleared,
129  "clearingStatus" => self::statusToString($this->clearingStatus),
130  "copyrightCount" => $this->copyrightCount
131  ];
132  }
133 
137  public function setMainLicense($mainLicense)
138  {
139  $this->mainLicense = $mainLicense;
140  }
141 
146  {
147  $this->uniqueLicenses = intval($uniqueLicenses);
148  }
149 
153  public function setUploadId($uploadId)
154  {
155  $this->uploadId = intval($uploadId);
156  }
157 
162  {
163  $this->totalLicenses = intval($totalLicenses);
164  }
165 
169  public function setUploadName($uploadName)
170  {
171  $this->uploadName = $uploadName;
172  }
173 
178  {
179  $this->uniqueConcludedLicenses = intval($uniqueConcludedLicenses);
180  }
181 
186  {
187  $this->totalConcludedLicenses = intval($totalConcludedLicenses);
188  }
189 
194  {
195  $this->filesToBeCleared = intval($filesToBeCleared);
196  }
197 
202  {
203  $this->filesCleared = intval($filesCleared);
204  }
205 
210  {
211  $this->clearingStatus = $clearingStatus;
212  }
213 
218  {
219  $this->copyrightCount = intval($copyrightCount);
220  }
221 
227  public static function statusToString($status)
228  {
229  $string = null;
230  switch ($status) {
231  case UploadStatus::OPEN:
232  $string = "Open";
233  break;
234  case UploadStatus::IN_PROGRESS:
235  $string = "InProgress";
236  break;
237  case UploadStatus::CLOSED:
238  $string = "Closed";
239  break;
240  case UploadStatus::REJECTED:
241  $string = "Rejected";
242  break;
243  default:
244  $string = "NA";
245  }
246  return $string;
247  }
248 }
setTotalConcludedLicenses($totalConcludedLicenses)
Model class to hold Upload info.
setUniqueConcludedLicenses($uniqueConcludedLicenses)