Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
50.00% covered (danger)
50.00%
49 / 98
31.25% covered (danger)
31.25%
10 / 32
CRAP
0.00% covered (danger)
0.00%
0 / 1
OutcomeFilesystemRepository
50.00% covered (danger)
50.00%
49 / 98
31.25% covered (danger)
31.25%
10 / 32
336.00
0.00% covered (danger)
0.00%
0 / 1
 getFilePathFactory
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 getDbStorage
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 getFileSystem
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
 getVariableProperty
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
30
 deleteResult
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
12
 getDeliveryVariables
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getVariables
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
3
 restoreFile
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
1
 getVariable
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
2
 getTestTaker
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getDelivery
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getAllCallIds
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getAllTestTakerIds
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getAllDeliveryIds
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 spawnResult
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 storeRelatedTestTaker
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 storeRelatedDelivery
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 handleFiles
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
2
 storeItemVariables
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
2
 storeTestVariable
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
2
 storeItemVariable
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
1
 getValueAndReplaceWithPath
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 storeTestVariables
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 configure
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 deleteDeliveryExecutionData
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getResultByDelivery
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getRelatedItemCallIds
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getRelatedTestCallIds
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 countResultByDelivery
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 isFileReference
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 canFileBeRestored
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
 canFileBeExtracted
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3/**
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; under version 2
7 * of the License (non-upgradable).
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
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 *
18 * Copyright (c) 2019 (original work) Open Assessment Technologies SA;
19 *
20 */
21
22namespace oat\taoResultServer\models\classes\OutcomeFileSystemStorage;
23
24use common_exception_Error;
25use common_exception_NotFound;
26use Exception;
27use oat\oatbox\filesystem\FileSystem;
28use oat\oatbox\filesystem\FileSystemService;
29use oat\oatbox\service\ConfigurableService;
30use oat\oatbox\service\exception\InvalidServiceManagerException;
31use oat\taoDelivery\model\execution\Delete\DeliveryExecutionDeleteRequest;
32use oat\taoResultServer\models\classes\ResultStorageInterface;
33use taoResultServer_models_classes_ResponseVariable;
34use taoResultServer_models_classes_Variable;
35
36class OutcomeFilesystemRepository extends ConfigurableService implements ResultStorageInterface
37{
38    public const SERVICE_ID = 'taoResultServer/fileSystemRepository';
39
40    public const OPTION_STORAGE = 'storage';
41    public const OPTION_FILESYSTEM = 'filesystem';
42
43    public const BASE_TYPE_FILE_REFERENCE = 'fileReference';
44
45    /**
46     * @var ResultStorageInterface
47     */
48    private $storage;
49    /**
50     * @var FileSystem
51     */
52    private $filesystem;
53    /**
54     * @var FilePathFactory
55     */
56    private $filePathFactory;
57
58    protected function getFilePathFactory()
59    {
60        if (null === $this->filePathFactory) {
61            $this->filePathFactory = new FilePathFactory();
62        }
63
64        return $this->filePathFactory;
65    }
66
67    /**
68     * @return ResultStorageInterface
69     */
70    protected function getDbStorage()
71    {
72        if (null === $this->storage) {
73            $this->storage = $this->getServiceLocator()->get($this->getOption(self::OPTION_STORAGE));
74        }
75
76        return $this->storage;
77    }
78
79    /**
80     * @return FileSystem
81     *
82     * @throws common_exception_Error
83     * @throws common_exception_NotFound
84     * @throws InvalidServiceManagerException
85     */
86    protected function getFileSystem()
87    {
88        if (null === $this->filesystem) {
89            /** @var FileSystemService $fileSystemService */
90            $fileSystemService = $this->getServiceManager()->get(FileSystemService::SERVICE_ID);
91            $this->filesystem = $fileSystemService->getFileSystem($this->getOption(self::OPTION_FILESYSTEM));
92        }
93
94        return $this->filesystem;
95    }
96
97    /**
98     * Get only one property from a variable
99     *
100     * @param string $variableId   on which we want the property
101     * @param string $propertyName to retrieve
102     *
103     * @return int|string the property retrieved
104     *
105     * @throws InvalidServiceManagerException
106     * @throws common_exception_Error
107     * @throws common_exception_NotFound
108     */
109    public function getVariableProperty($variableId, $propertyName)
110    {
111        $propertyValue = $this->getDbStorage()->getVariableProperty($variableId, $propertyName);
112
113        if ($propertyName === 'baseType' && $propertyValue === self::BASE_TYPE_FILE_REFERENCE) {
114            return 'file';
115        }
116
117        if ($propertyName === 'candidateResponse') {
118            $baseType = $this->getDbStorage()->getVariableProperty($variableId, 'baseType');
119
120            if ($baseType === self::BASE_TYPE_FILE_REFERENCE) {
121                return $this->getFileSystem()->read($propertyValue);
122            }
123        }
124
125        return $propertyValue;
126    }
127
128    /**
129     * Remove the result and all the related variables
130     *
131     * @param string $deliveryResultIdentifier The identifier of the delivery execution
132     *
133     * @return boolean if the deletion was successful or not
134     *
135     * @throws InvalidServiceManagerException
136     * @throws common_exception_Error
137     * @throws common_exception_NotFound
138     */
139    public function deleteResult($deliveryResultIdentifier)
140    {
141        $dbStorage = $this->getDbStorage();
142
143        $rawVariables = $dbStorage->getDeliveryVariables($deliveryResultIdentifier);
144
145        foreach ($rawVariables as $rawVariable) {
146            /** @var taoResultServer_models_classes_Variable $variable */
147            $variable = $rawVariable[0]->variable;
148            if ($this->isFileReference($variable)) {
149                $this->getFileSystem()->deleteDir(
150                    $this->getFilePathFactory()->getDirPath($deliveryResultIdentifier)
151                );
152            }
153        }
154
155        return $dbStorage->deleteResult($deliveryResultIdentifier);
156    }
157
158    /**
159     * Get the complete variables list stored for delivery execution
160     *
161     * @param array|string $deliveryResultIdentifier
162     *
163     * @return mixed
164     */
165    public function getDeliveryVariables($deliveryResultIdentifier)
166    {
167        return $this->getDbStorage()->getDeliveryVariables($deliveryResultIdentifier);
168    }
169
170    /**
171     * get the complete variables list stored for a call id (item or test)
172     *
173     * @param string|array $callId an execution identifier
174     *
175     * @return array that contains the variables related to the call id
176     * Array
177     *(
178     *   [uri] => Array
179     *   (
180     *       [0] => stdClass Object
181     *       (
182     *           [uri] => uri
183     *           [class] => taoResultServer_models_classes_ResponseVariable
184     *           [deliveryResultIdentifier] => http://tao.localdomain:8888/tao.rdf#i14176019092304877
185     *           [callIdItem] => http://tao.localdomain:8888/tao.rdf#i14176019092304877.item-1.0
186     *           [callIdTest] =>
187     *           [test] => http://tao.localdomain:8888/tao.rdf#i14175986702737865-
188     *           [item] => http://tao.localdomain:8888/tao.rdf#i141631732273405
189     *           [variable] => taoResultServer_models_classes_ResponseVariable Object
190     *           (
191     *               [correctResponse] =>
192     *               [candidateResponse] => MQ==
193     *               [identifier] => numAttempts
194     *               [cardinality] => single
195     *               [baseType] => integer
196     *               [epoch] => 0.28031200 1417601924
197     *           )
198     *
199     *       )
200     *
201     *   )
202     *
203     *   [uri2] => Array
204     *   (
205     *       [0] => stdClass Object
206     *       (
207     *           [uri] => uri2
208     *           [class] => taoResultServer_models_classes_OutcomeVariable
209     *           [deliveryResultIdentifier] => http://tao.localdomain:8888/tao.rdf#i14176019092304877
210     *           [callIdItem] => http://tao.localdomain:8888/tao.rdf#i14176019092304877.item-1.0
211     *           [callIdTest] =>
212     *           [test] => http://tao.localdomain:8888/tao.rdf#i14175986702737865-
213     *           [item] => http://tao.localdomain:8888/tao.rdf#i141631732273405
214     *           [variable] => taoResultServer_models_classes_OutcomeVariable Object
215     *           (
216     *               [normalMaximum] =>
217     *               [normalMinimum] =>
218     *               [value] => Y29tcGxldGVk
219     *               [identifier] => completionStatus
220     *               [cardinality] => single
221     *               [baseType] => identifier
222     *               [epoch] => 0.28939600 1417601924
223     *           )
224     *
225     *       )
226     *
227     *   )
228     *
229     *)
230     * @throws InvalidServiceManagerException
231     * @throws common_exception_Error
232     * @throws common_exception_NotFound
233     */
234    public function getVariables($callId)
235    {
236        $rawVariables = $this->getDbStorage()->getVariables($callId);
237
238        /** @var  $rawVariable */
239        foreach ($rawVariables as &$rawVariable) {
240            if ($this->canFileBeRestored($rawVariable[0]->variable)) {
241                $rawVariable[0]->variable = $this->restoreFile($rawVariable[0]->variable);
242            }
243        }
244
245        return $rawVariables;
246    }
247
248    /**
249     * @param taoResultServer_models_classes_ResponseVariable $rawVariable
250     *
251     * @return taoResultServer_models_classes_ResponseVariable
252     *
253     * @throws InvalidServiceManagerException
254     * @throws common_exception_Error
255     * @throws common_exception_NotFound
256     */
257    private function restoreFile(taoResultServer_models_classes_ResponseVariable $rawVariable)
258    {
259        $variable = clone $rawVariable;
260
261        $path = $variable->getCandidateResponse();
262        $fileContent = $this->getFileSystem()->read($path);
263
264        $variable->setCandidateResponse($fileContent);
265        $variable->setBaseType('file');
266
267        return $variable;
268    }
269
270    /**
271     * Get The variable that match params
272     *
273     * @param string $callId             an execution identifier
274     * @param string $variableIdentifier the identifier of the variable
275     *
276     * @return array variable that match call id and variable identifier
277     * Array
278     *(
279     *   [uri] => Array
280     *   (
281     *       [0] => stdClass Object
282     *       (
283     *           [uri] => uri
284     *           [class] => taoResultServer_models_classes_OutcomeVariable
285     *           [deliveryResultIdentifier] => MyDeliveryResultIdentifier#1
286     *           [callIdItem] => MyCallId#2
287     *           [callIdTest] =>
288     *           [test] => MyGreatTest#2
289     *           [item] => MyGreatItem#2
290     *           [variable] => taoResultServer_models_classes_OutcomeVariable Object
291     *           (
292     *               [normalMaximum] =>
293     *               [normalMinimum] =>
294     *               [value] => TXlWYWx1ZQ==
295     *               [identifier] => Identifier
296     *               [cardinality] => multiple
297     *               [baseType] => float
298     *               [epoch] => 0.58277800 1417621663
299     *           )
300     *
301     *       )
302     *
303     *   )
304     *
305     *)
306     * @throws InvalidServiceManagerException
307     * @throws common_exception_Error
308     * @throws common_exception_NotFound
309     */
310    public function getVariable($callId, $variableIdentifier)
311    {
312        $rawVariable = $this->getDbStorage()->getVariable($callId, $variableIdentifier);
313
314        if ($this->canFileBeRestored($rawVariable[0]->variable)) {
315            $rawVariable[0]->variable = $this->restoreFile($rawVariable[0]->variable);
316        }
317
318        return $rawVariable;
319    }
320
321    /**
322     * Get the test taker id related to one specific delivery execution
323     *
324     * @param string $deliveryResultIdentifier the identifier of the delivery execution
325     *
326     * @return string the uri of the test taker related to the delivery execution
327     */
328    public function getTestTaker($deliveryResultIdentifier)
329    {
330        return $this->getDbStorage()->getTestTaker($deliveryResultIdentifier);
331    }
332
333    /**
334     * Get the delivery id related to one specific delivery execution
335     *
336     * @param string $deliveryResultIdentifier the identifier of the delivery execution
337     *
338     * @return string the uri of the delivery related to the delivery execution
339     */
340    public function getDelivery($deliveryResultIdentifier)
341    {
342        return $this->getDbStorage()->getDelivery($deliveryResultIdentifier);
343    }
344
345    /**
346     * Get the entire list of call ids that are stored (item or test)
347     * @return array the list of executions ids (across all results)
348     */
349    public function getAllCallIds()
350    {
351        return $this->getDbStorage()->getAllCallIds();
352    }
353
354    /**
355     * get all the ids of test taker that have attempt a test
356     * @return array of all test taker ids array(array('deliveryResultIdentifier' => 123, 'testTakerIdentifier' => 456))
357     */
358    public function getAllTestTakerIds()
359    {
360        return $this->getDbStorage()->getAllTestTakerIds();
361    }
362
363    /**
364     * Get all the ids of delivery that are stored.
365     *
366     * @return array of all delivery ids array(array('deliveryResultIdentifier' => 123, 'deliveryIdentifier' => 456))
367     */
368    public function getAllDeliveryIds()
369    {
370        return $this->getDbStorage()->getAllDeliveryIds();
371    }
372
373    /**
374     * Spawn Result
375     *
376     * Initialize a new raw Delivery Result.
377     *
378     * After initialization, the Delivery Result will be empty, and will not be linked
379     * to a Test Taker or a Delivery.
380     *
381     * Please note that it is the responisibility of the implementer to generate Delivery
382     * Result identifiers that are as unique as possible.
383     *
384     * @return string The unique identifier of the initialized Delivery Result.
385     */
386    public function spawnResult()
387    {
388        return $this->getDbStorage()->spawnResult();
389    }
390
391    /**
392     * Store Related Test Taker
393     *
394     * Attach a given Test Taker to a Delivery Result.
395     *
396     * A Delivery Result is always attached to a single Test Taker. This method enables
397     * the client code to register a given Test Taker, using its $testTakerIdentifier, to a
398     * given Delivery Result, using its $deliveryResultIdentifier.
399     *
400     * @param string $deliveryResultIdentifier The identifier of the Delivery Result (usually a Delivery Execution URI).
401     * @param string $testTakerIdentifier      The identifier of the Test Taker (usually a URI).
402     *
403     */
404    public function storeRelatedTestTaker($deliveryResultIdentifier, $testTakerIdentifier)
405    {
406        return $this->getDbStorage()->storeRelatedTestTaker($deliveryResultIdentifier, $testTakerIdentifier);
407    }
408
409    /**
410     * Store Related Delivery
411     *
412     * Store a delivery related to a specific delivery execution
413     *
414     * @param string $deliveryResultIdentifier (mostly delivery execution uri)
415     * @param string $deliveryIdentifier       (uri recommended)
416     */
417    public function storeRelatedDelivery($deliveryResultIdentifier, $deliveryIdentifier)
418    {
419        return $this->getDbStorage()->storeRelatedDelivery($deliveryResultIdentifier, $deliveryIdentifier);
420    }
421
422    /**
423     * @param string                                  $deliveryResultIdentifier
424     * @param taoResultServer_models_classes_Variable $itemVariable
425     *
426     * @return taoResultServer_models_classes_Variable
427     * @throws InvalidServiceManagerException
428     * @throws common_exception_Error
429     * @throws common_exception_NotFound
430     */
431    private function handleFiles($deliveryResultIdentifier, taoResultServer_models_classes_Variable $itemVariable)
432    {
433        if ($this->canFileBeExtracted($itemVariable)) {
434            $variable = clone $itemVariable;
435
436            $path = $this->getFilePathFactory()->getFilePath($deliveryResultIdentifier);
437
438            $fileContent = $this->getValueAndReplaceWithPath($variable, $path);
439
440            $this->getFileSystem()->write($path, $fileContent);
441
442            $variable->setBaseType(self::BASE_TYPE_FILE_REFERENCE);
443
444            return $variable;
445        }
446
447        return $itemVariable;
448    }
449
450    /**
451     * @param string $deliveryResultIdentifier
452     * @param        $test
453     * @param        $item
454     * @param array  $itemVariables
455     * @param        $callIdItem
456     *
457     * @throws InvalidServiceManagerException
458     * @throws common_exception_Error
459     * @throws common_exception_NotFound
460     */
461    public function storeItemVariables($deliveryResultIdentifier, $test, $item, array $itemVariables, $callIdItem)
462    {
463        $variables = [];
464
465        foreach ($itemVariables as $itemVariable) {
466            $variables[] = $this->handleFiles($deliveryResultIdentifier, $itemVariable);
467        }
468
469        $this->getDbStorage()->storeItemVariables(
470            $deliveryResultIdentifier,
471            $test,
472            $item,
473            $variables,
474            $callIdItem
475        );
476    }
477
478    /**
479     * Store Test Variable
480     *
481     * Submit a specific test Variable and store it
482     *
483     * @param string                                  $deliveryResultIdentifier
484     * @param string                                  $test
485     * @param taoResultServer_models_classes_Variable $testVariable
486     * @param                                         $callIdTest
487     */
488    public function storeTestVariable(
489        $deliveryResultIdentifier,
490        $test,
491        taoResultServer_models_classes_Variable $testVariable,
492        $callIdTest
493    ) {
494        $this->getDbStorage()->storeTestVariable(
495            $deliveryResultIdentifier,
496            $test,
497            $testVariable,
498            $callIdTest
499        );
500    }
501
502    /**
503     * Store Item Variable
504     *
505     * Submit a specific Item Variable, (ResponseVariable and OutcomeVariable shall be used respectively for collected
506     * data and score/interpretation computation) and store it with all the dependencies
507     *
508     * @param string                                  $deliveryResultIdentifier
509     * @param string                                  $test         (uri recommended)
510     * @param string                                  $item         (uri recommended)
511     * @param taoResultServer_models_classes_Variable $itemVariable the variable to store
512     * @param string                                  $callIdItem   contextual call id for the variable, ex. :  to
513     *                                                              distinguish the same variable output by the same
514     *                                                              item and that is presented several times in the
515     *                                                              same test
516     *
517     * @throws InvalidServiceManagerException
518     * @throws common_exception_Error
519     * @throws common_exception_NotFound
520     */
521    public function storeItemVariable(
522        $deliveryResultIdentifier,
523        $test,
524        $item,
525        taoResultServer_models_classes_Variable $itemVariable,
526        $callIdItem
527    ) {
528        $variable = $this->handleFiles($deliveryResultIdentifier, $itemVariable);
529
530        $this->getDbStorage()->storeItemVariable(
531            $deliveryResultIdentifier,
532            $test,
533            $item,
534            $variable,
535            $callIdItem
536        );
537    }
538
539    private function getValueAndReplaceWithPath(taoResultServer_models_classes_ResponseVariable $variable, $path)
540    {
541        $variableValue = $variable->getCandidateResponse();
542        $variable->setCandidateResponse($path);
543
544        return $variableValue;
545    }
546
547    public function storeTestVariables($deliveryResultIdentifier, $test, array $testVariables, $callIdTest)
548    {
549        return $this->getDbStorage()->storeTestVariables($deliveryResultIdentifier, $test, $testVariables, $callIdTest);
550    }
551
552    /**
553     * The storage may configure itself based on the resultServer definition
554     *
555     * @param array $callOptions
556     */
557    public function configure($callOptions = [])
558    {
559        return $this->getDbStorage()->configure($callOptions);
560    }
561
562    /**
563     * @param DeliveryExecutionDeleteRequest $request
564     *
565     * @throws Exception
566     * @return bool
567     */
568    public function deleteDeliveryExecutionData(DeliveryExecutionDeleteRequest $request)
569    {
570        return $this->getDbStorage()->deleteDeliveryExecutionData($request);
571    }
572
573
574    /**
575     * Get the result information (test taker, delivery, delivery execution) from filters
576     *
577     * @param array $delivery list of delivery to search : array('test','myValue')
578     * @param array $options  params to restrict results array(
579     *                        "order"=> "deliveryResultIdentifier" || "testTakerIdentifier" || "deliveryIdentifier",
580     *                        "orderdir"=>"ASC" || "DESC",
581     *                        "offset"=> an int,
582     *                        "limit"=> an int
583     *                        )
584     *
585     * @return array of results that match the filter : array(array('deliveryResultIdentifier' => '123',
586     *               'testTakerIdentifier' => '456', 'deliveryIdentifier' => '789'))
587     */
588    public function getResultByDelivery($delivery, $options = [])
589    {
590        return $this->getDbStorage()->getResultByDelivery($delivery, $options);
591    }
592
593    /**
594     * Get all the ids of the callItem for a specific delivery execution
595     *
596     * @param string $deliveryResultIdentifier The identifier of the delivery execution
597     *
598     * @return array the list of call item ids (across all results)
599     */
600    public function getRelatedItemCallIds($deliveryResultIdentifier)
601    {
602        return $this->getDbStorage()->getRelatedItemCallIds($deliveryResultIdentifier);
603    }
604
605    /**
606     * Get all the ids of the callTest for a specific delivery execution
607     *
608     * @param string $deliveryResultIdentifier The identifier of the delivery execution
609     *
610     * @return array the list of call test ids (across all results)
611     */
612    public function getRelatedTestCallIds($deliveryResultIdentifier)
613    {
614        return $this->getDbStorage()->getRelatedTestCallIds($deliveryResultIdentifier);
615    }
616
617    /**
618     * Count the number of result that match the filter
619     *
620     * @param array $delivery list of delivery to search : array('test','myValue')
621     *
622     * @return int the number of results that match filter
623     */
624    public function countResultByDelivery($delivery)
625    {
626        return $this->getDbStorage()->countResultByDelivery($delivery);
627    }
628
629    private function isFileReference(taoResultServer_models_classes_Variable $variable)
630    {
631        return $variable->getBaseType() === self::BASE_TYPE_FILE_REFERENCE;
632    }
633
634    private function canFileBeRestored(taoResultServer_models_classes_Variable $variable)
635    {
636        return $variable instanceof taoResultServer_models_classes_ResponseVariable
637            && $this->isFileReference($variable);
638    }
639
640    private function canFileBeExtracted(taoResultServer_models_classes_Variable $variable)
641    {
642        return $variable->getBaseType() === 'file'
643            && $variable instanceof taoResultServer_models_classes_ResponseVariable;
644    }
645}