@param core_kernel_classes_Resource $item
@param core_kernel_classes_Property $classProperty

@return HashEntry
@throws \oat\taoQtiItem\model\flyExporter\extractor\ExtractorException
@throws \Exception
188337
public static function run(core_kernel_classes_Resource $item, core_kernel_classes_Property $classProperty)
    {
        $itemProperty = $item->getProperty($classProperty->getUri());
        $labelItemProperty = $itemProperty->getLabel();

        $extractor = new OntologyExtractor();
        $extractor->addColumn($labelItemProperty, ['property' => $classProperty->getUri()]);
        $extractor->setItem($item);
        $extractor->run();
        $data = $extractor->getData();

        return new HashEntry($labelItemProperty, $data[$labelItemProperty]);
    }
1229988
public function isItemClass(core_kernel_classes_Class $clazz)
    {
        $returnValue = (bool)false;

        if ($this->itemClass->getUri() == $clazz->getUri()) {
            return true;
        }

        foreach ($clazz->getParentClasses(true) as $parent) {

            if ($parent->getUri() == $this->itemClass->getUri()) {
                $returnValue = true;
                break;
            }
        }

        return (bool)$returnValue;
    }
1285337
public function deleteResource(core_kernel_classes_Resource $resource)
    {
        if (LockManager::getImplementation()->isLocked($resource)) {
            $userId = common_session_SessionManager::getSession()->getUser()->getIdentifier();
            LockManager::getImplementation()->releaseLock($resource, $userId);
        }

        $result = $this->deleteItemContent($resource) && parent::deleteResource($resource);

        if ($result) {
            $this->getEventManager()->trigger(new ItemRemovedEvent($resource->getUri()));
        }

        return $result;
    }
911543
public function deleteItemContent(core_kernel_classes_Resource $item)
    {
        // Delete item directory from filesystem
        $definitonFileValues = $item->getPropertyValues($this->itemContentProperty);
        if (!empty($definitonFileValues)) {
            /** @var Directory $directory */
            $directory = $this->getFileReferenceSerializer()->unserializeDirectory(reset($definitonFileValues));
            if ($directory->exists()) {
                $directory->deleteSelf();
            }
        }

        //delete the folder for all languages!
        foreach ($item->getUsedLanguages($this->itemContentProperty) as $lang) {
            $files = $item->getPropertyValuesByLg($this->itemContentProperty, $lang);
            foreach ($files->getIterator() as $file) {
                if ($file instanceof core_kernel_classes_Resource) {
                    $this->getFileReferenceSerializer()->cleanUp($file->getUri());
                }
            }
        }

        return true;
    }
447920
public function index(){

        $test = new \core_kernel_classes_Resource($this->getRequestParameter('uri'));
        
        $model = $this->getServiceManager()->get(TestModel::SERVICE_ID);

        $itemSequence = array();
        $itemUris = array();
        $counter = 1;
        foreach($model->getItems($test) as $item){
            $itemUris[] = $item->getUri();
            $itemSequence[$counter] = array(
                'uri' 	=> tao_helpers_Uri::encode($item->getUri()),
                'label' => $item->getLabel()
            );
            $counter++;
        }
        
		// data for item sequence, terrible solution
		// @todo implement an ajax request for labels or pass from tree to sequence
		$allItems = array();
		foreach(\taoTests_models_classes_TestsService::singleton()->getAllItems() as $itemUri => $itemLabel){
			$allItems['item_'.tao_helpers_Uri::encode($itemUri)] = $itemLabel;
		}


        $config = $model->getConfig($test);
        $checked = (isset($config['previous']))? $config['previous'] : false;
        $testConfig['previous'] = array('label' => __('Allow test-taker to go back in test'), 'checked' => $checked);

		$this->setData('uri', $test->getUri());
    	$this->setData('allItems', json_encode($allItems));
		$this->setData('itemSequence', $itemSequence);
		$this->setData('testConfig', $testConfig);

		// data for generis tree form
		$this->setData('relatedItems', json_encode(tao_helpers_Uri::encodeArray($itemUris)));

		$openNodes = TreeHelper::getNodesToOpen($itemUris, new core_kernel_classes_Class(TaoOntology::ITEM_CLASS_URI));
		$this->setData('itemRootNode', TaoOntology::ITEM_CLASS_URI);
		$this->setData('itemOpenNodes', $openNodes);
		$this->setData('saveUrl', _url('saveItems', 'Authoring', 'taoTestLinear'));
        $this->setView('Authoring/index.tpl');
    }
1089663
protected function itemToArray($item)
    {
        if (is_array($item)) {
            return $item;
        } elseif (method_exists($item, 'toArray')) {
            return $item->toArray();
        } elseif (method_exists($item, 'getArrayCopy')) {
            return $item->getArrayCopy();
        }

        throw new Exception\RuntimeException(sprintf(
            'Items as part of this DataSource, with type "%s" cannot be cast to an array',
            is_object($item) ? get_class($item) : gettype($item)
        ));
    }
19332
public static function buildResourceNode(core_kernel_classes_Resource $resource, core_kernel_classes_Class $class, array $extraProperties = []) {
        $label = $resource->getLabel();
        $label = empty($label) ? __('no label') : $label;

		$extraValues = [];
        if (!empty($extraProperties))
		{
			foreach ($extraProperties as $key => $value)
			{
				$extraValues[$key] =  $resource->getOnePropertyValue($class->getProperty($value));
			}
		}

        $signatureGenerator = ServiceManager::getServiceManager()->get(SignatureGenerator::class);

        return [
            'data' 	=> _dh($label),
            'type'	=> 'instance',
            'attributes' => array_merge([
                'id' => tao_helpers_Uri::encode($resource->getUri()),
                'class' => 'node-instance',
                'data-uri' => $resource->getUri(),
                'data-classUri' => $class->getUri(),
                'data-signature' => $signatureGenerator->generate($resource->getUri()),
            ], $extraValues)
        ];
    }
1021036
public function get(CacheableInterface $item)
    {
        return isset($this->values[$item->getHashKey()]) ? $this->values[$item->getHashKey()] : false;
    }
216639
protected function getItemContentTokenizer(core_kernel_classes_Resource $resource)
    {
        $itemService= taoItems_models_classes_ItemsService::singleton();
        $model = $itemService->getItemModel($resource);
        if (! is_null($model)) {
            $impl = $itemService->getItemModelImplementation($model);
            if (! is_null($impl)) {
                if ($impl instanceof IndexableItemModel) {
                    return $impl->getItemContentTokenizer();
                }
            }
        }
        return null;
    }
186203
protected static function extract_item_record_from_record(stdClass $record) {
        $newrec = new stdClass();
        foreach ($record as $key => $value) {
            if (strpos($key, 'item') !== 0) {
                continue;
            }
            $key = substr($key, 4);
            $newrec->{$key} = $value;
        }
        return $newrec;
    }
938433
public function getItemDirectory(core_kernel_classes_Resource $item, $language = '')
    {
        // Get file by language
        if ($language === '') {
            $files = $item->getPropertyValues($this->itemContentProperty);
        } else {
            $files = $item->getPropertyValuesByLg($this->itemContentProperty, $language)->toArray();
        }

        // If multiple files then throw exception
        if (count($files) > 1) {
            common_Logger::i(print_r($files, true));
            throw new common_Exception(__METHOD__ . ': Item ' . $item->getUri() . ' has multiple.');
        }

        // If there is one file then return directory
        if (count($files) == 1) {
            $file = reset($files);
            $file = is_object($file) && $file instanceof core_kernel_classes_Resource ? $file->getUri() : (string)$file;
            return $this->getFileReferenceSerializer()->unserializeDirectory($file);
        }

        // Otherwise there is no file, create one and return directory
        $model = $this->getItemModel($item);
        if (is_null($model)) {
            throw new common_Exception('Call to ' . __FUNCTION__ . ' for item without model');
        }

        // File does not exist, let's create it
        $actualLang = empty($language) ? $this->getSessionLg() : $language;
        $filePath = tao_helpers_Uri::getUniqueId($item->getUri())
            . DIRECTORY_SEPARATOR . 'itemContent' . DIRECTORY_SEPARATOR . $actualLang;

        // Create item directory
        $itemDirectory = $this->getDefaultItemDirectory()->getDirectory($filePath);

        // Set uri file value as serial to item persistence
        $serial = $this->getFileReferenceSerializer()->serialize($itemDirectory);

        $item->setPropertyValueByLg($this->itemContentProperty, $serial, $actualLang);
        
        return $itemDirectory;
    }
520678
private function parseArrayToFieldEntity(array $item, $elementType)
    {
        $entity = new Field();
        $entity->set($item);
        $entity->element_type = $elementType;

        return $entity;
    }
244925
public function getInstances(core_kernel_classes_Class $resource, $recursive = false, $params = array())
    {
        $returnValue = array();
        
        $params = array_merge($params, array('like' => false, 'recursive' => $recursive));
        
        $query = $this->getFilteredQuery($resource, array(), $params);
        $result = $this->getPersistence()->query($query);
        
        while ($row = $result->fetch()) {
            $foundInstancesUri = $row['subject'];
            $returnValue[$foundInstancesUri] = new core_kernel_classes_Resource($foundInstancesUri);
        }
        
        return $returnValue;
    }
341685
@Override
    public ItemProcessor getProcessor(Item item) {
        for (Map.Entry<String, ItemProcessor> mapping : patternToProcessorMappings.entrySet()) {
            if (item.getUrl().matches(mapping.getKey())) {
                return mapping.getValue();
            }
        }

        return null;
    }
1135232
public function cache(CacheItemInterface $item)
    {
        $content = $this->execute();
        $item->set($content);

        return $item;
    }
346161
protected function getKeys($item)
    {
        if (is_array($item)) {
            return array_keys($item);
        } elseif ($this->header && is_object($item)) {
            return $this->header;
        }

        throw new InvalidArgumentException(sprintf(
            'Plum\PlumConsole\ConsoleTableWriter currently only supports array items or objects if headers '.
            'are set using the setHeader() method. You have passed an item of type "%s" to writeItem().',
            gettype($item)
        ));
    }
919183
public function run()
    {
        $this->data = [];

        if (empty($this->item) || !($this->item instanceof \core_kernel_classes_Resource)) {
            throw new ExtractorException('Export item not set.');
        }

        $properties = [];
        foreach ($this->columns as $config) {
            $properties[] = $config['property'];
        }
        $values = $this->item->getPropertiesValues($properties);

        foreach ($this->columns as $column => $config) {
            try {
                $data = [];
                foreach ($values[$config['property']->getUri()] as $itemValue) {
                    if (is_array($itemValue)) {
                        array_walk($itemValue, function (&$value) {
                            $resource = new \core_kernel_classes_Resource($value);
                            $value = $resource->getLabel();
                        });

                        if (isset($config['delimiter'])) {
                            $delimiter = $config['delimiter'];
                        } else {
                            $delimiter = self::DEFAULT_PROPERTY_DELIMITER;
                        }
                        $data[] = explode($delimiter, $itemValue);
                        continue;
                    }

                    $data[] = ($itemValue instanceof \core_kernel_classes_Resource)? $itemValue->getLabel() : (string)$itemValue;
                }
            } catch (\Exception $e) {
                \common_Logger::e('ERROR on column ' . $column . ' : ' . $e->getMessage());
                $data = ['N/A'];
            }

            $this->data[$column] = implode(self::DEFAULT_PROPERTY_DELIMITER, $data);
        }
        $this->columns = [];
        return $this;
    }