generis tree representation of a resource node

@param core_kernel_classes_Resource $resource
@param core_kernel_classes_Class $class
@param array $extraProperties
@return array
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)
        ];
    }
1124715
public function setType( core_kernel_classes_Resource $resource,  core_kernel_classes_Class $class)
    {
        $returnValue = $this->setPropertyValue($resource, $this->getModel()->getProperty(OntologyRdf::RDF_TYPE), $class);
        return (bool) $returnValue;
    }
777328
public function create(string $resourceClass, array $options = []): PropertyNameCollection
    {
        $propertyNames = [];
        $propertyNameCollection = null;

        if ($this->decorated) {
            try {
                $propertyNameCollection = $this->decorated->create($resourceClass, $options);
            } catch (ResourceClassNotFoundException $resourceClassNotFoundException) {
                // Ignore not found exceptions from parent
            }

            foreach ($propertyNameCollection as $propertyName) {
                $propertyNames[$propertyName] = $propertyName;
            }
        }

        if (!class_exists($resourceClass)) {
            if (null !== $propertyNameCollection) {
                return $propertyNameCollection;
            }

            throw new ResourceClassNotFoundException(sprintf('The resource class "%s" does not exist.', $resourceClass));
        }

        if ($properties = $this->extractor->getResources()[$resourceClass]['properties'] ?? false) {
            foreach ($properties as $propertyName => $property) {
                $propertyNames[$propertyName] = $propertyName;
            }
        }

        return new PropertyNameCollection(array_values($propertyNames));
    }
1168113
public function export($item, array $extraAttributes = []): array
    {
        /** @var Site $item */
        $attributeObj = [];
        $extraAttributes = array_merge($extraAttributes, $this->additionalAttributes(\get_class($item)));
        foreach($extraAttributes as $attribute) {
            if ($attribute === 'propagateEntries') {
                $attributeObj[$attribute] = (bool) $item->$attribute;
            } else {
                $attributeObj[$attribute] = $item->$attribute;
            }
        }

        $siteObj = array_merge([
            'groupId' => $item->getGroup()->id,
            'group' => $item->getGroup()->name,
            'name' => $item->name,
            'handle' => $item->handle,
            'language' => $item->language,
            'primary' => $item->primary,
            'hasUrls' => (bool) $item->hasUrls,
            'baseUrl' => $item->baseUrl,
        ], $attributeObj);

        return $this->stripNulls($siteObj);
    }
425064
public function getMethod($class, $method, $extraMappings = []) {
		if (isset($this->aliases[$class])) {
			$class = $this->aliases[$class];
		}

		return [
			$this->getSingleton($class),
			$this->resolveArgs($class, $method, " when resolving method $class::$method", $extraMappings)
		];
	}
1002294
public function setMultiple( core_kernel_classes_Resource $resource, $isMultiple)
    {
        
    	$multipleProperty = new core_kernel_classes_Property(GenerisRdf::PROPERTY_MULTIPLE);
        $value = ((bool)$isMultiple) ?  GenerisRdf::GENERIS_TRUE : GenerisRdf::GENERIS_FALSE ;
        $this->removePropertyValues($resource, $multipleProperty);
        $this->setPropertyValue($resource, $multipleProperty, $value);
        
    }
1224063
public function getProperties( core_kernel_classes_Class $resource, $recursive = false)
    {
        $returnValue = array();
        
        $sqlQuery = 'SELECT subject FROM statements WHERE predicate = ?  AND '. $this->getPersistence()->getPlatForm()->getObjectTypeCondition() .' = ?';
        $sqlResult = $this->getPersistence()->query($sqlQuery, array(
            OntologyRdfs::RDFS_DOMAIN,
            $resource->getUri()
        ));
        
        while ($row = $sqlResult->fetch()) {
            $property = new core_kernel_classes_Property($row['subject']);
            $returnValue[$property->getUri()] = $property;
        }
        
        if ($recursive == true) {
            $parentClasses = $this->getParentClasses($resource, true);
            foreach ($parentClasses as $parent) {
                if($parent->getUri() != OntologyRdfs::RDFS_CLASS) {
                	$returnValue = array_merge($returnValue, $parent->getProperties(false));
                }
            }
        }
        
        return $returnValue;
    }
432188
public static function fromResource(core_kernel_classes_Resource $resource) {
	    $values = $resource->getPropertiesValues(array(
			WfEngineOntology::PROPERTY_CALL_OF_SERVICES_SERVICE_DEFINITION,
			WfEngineOntology::PROPERTY_CALL_OF_SERVICES_ACTUAL_PARAMETER_IN,
			WfEngineOntology::PROPERTY_CALL_OF_SERVICES_ACTUAL_PARAMETER_OUT
	    ));
	    $serviceDefUri = current($values[WfEngineOntology::PROPERTY_CALL_OF_SERVICES_SERVICE_DEFINITION]);
	    $serviceCall = new self($serviceDefUri);
	    foreach ($values[WfEngineOntology::PROPERTY_CALL_OF_SERVICES_ACTUAL_PARAMETER_IN] as $inRes) {
	        $param = tao_models_classes_service_Parameter::fromResource($inRes);
	        $serviceCall->addInParameter($param);
	    }
	    if (!empty($values[WfEngineOntology::PROPERTY_CALL_OF_SERVICES_ACTUAL_PARAMETER_OUT])) {
	        $param = tao_models_classes_service_Parameter::fromResource(current($values[WfEngineOntology::PROPERTY_CALL_OF_SERVICES_ACTUAL_PARAMETER_OUT]));
	        $serviceCall->setOutParameter($param);
	    }
	    return $serviceCall;
	}
1136132
public function findByName($name, $extraDatas = array(), $executeQuery = true)
    {
        $name  = strtoupper($name);
        /** @var \Doctrine\ORM\QueryBuilder $queryBuilder */
        $queryBuilder = $this->createQueryBuilder('resourceNode');
        $queryBuilder->where($queryBuilder->expr()->like('UPPER(resourceNode.name)', ':name'));

        if (0 < count($extraDatas)) {
            foreach ($extraDatas as $key => $extraData) {
                $queryBuilder
                    ->andWhere(sprintf('resourceNode.%s = :%s', $key, $key))
                    ->setParameter(sprintf(':%s', $key), $extraData);
            }
        }

        $queryBuilder
            ->orderBy('resourceNode.name', 'ASC')
            ->setParameter(':name', "%{$name}%");

        return $executeQuery ? $queryBuilder->getQuery()->getResult(): $queryBuilder;
    }
449168
private function assignAndResolveIncludes(
        ResourceManager $resourceManager,
        string $resource,
        ElementInterface $resourceOrCollection,
        Parameters $parameters
    )
    {
        $relations = collect();

        $availableIncludes = $this->retrieveRelationsRecursive($resource, $relations, $resourceManager);

        $resourceOrCollection->with($parameters->getInclude($availableIncludes->all()));
    }
489715
public function getTree($path = '', $rootAlias = 't', $extraParams = array())
    {
        $results = $this->getFlatTree($path, $rootAlias, $extraParams);

        return $this->buildTree($results);
    }
739585
public function deleteInstances( core_kernel_classes_Class $resource, $resources, $deleteReference = false)
    {
        $returnValue = false;

        $class = new core_kernel_classes_Class($resource->getUri());
        $uris = array();
        
        foreach ($resources as $r) {
            $uri = (($r instanceof core_kernel_classes_Resource) ? $r->getUri() : $r);
            $uris[] = $this->getPersistence()->quote($uri);
        }
        
        if ($class->exists()) {
            $inValues = implode(',', $uris);
            $query = 'DELETE FROM statements WHERE subject IN (' . $inValues . ')';
        	
            if (true === $deleteReference) {
                $params[] = $resource->getUri();
                $query .= ' OR object IN (' . $inValues . ')';
            }
        	
            try {
        		// Even if now rows are affected, we consider the resources
        		// as deleted.
        		$this->getPersistence()->exec($query);	
        		$returnValue = true;
            } catch (PDOException $e) {
        	    throw new core_kernel_persistence_smoothsql_Exception("An error occured while deleting resources: " . $e->getMessage());
            }
        }

        return $returnValue;
    }
326863
public function getTemplateVars(array $extra = [])
    {
        $extraKeys = array_keys($extra);
        if (0 < count($extraKeys)) {
            foreach (array_keys($this->resources) as $key) {
                if (array_key_exists($key, $extraKeys)) {
                    throw new \RuntimeException(sprintf('Key "%s" used in extra template vars overrides a resource key.', $key));
                }
            }
            foreach (['identifiers', 'resource_name', 'resource_id', 'route_prefix'] as $key) {
                if (array_key_exists($key, $extraKeys)) {
                    throw new \RuntimeException(sprintf('Key "%s" is reserved and cannot be used in extra template vars.', $key));
                }
            }
        }

        return array_merge($this->resources, [
            'identifiers'   => $this->getIdentifiers(),
            'resource_name' => $this->config->getResourceName(),
            'resource_id'   => $this->config->getId(),
            'route_prefix'  => $this->config->getRoutePrefix(),
            'form_template' => $this->config->getTemplate('_form.html'),
        ], $extra);
    }
1213252
public function getInstancesPropertyValues( core_kernel_classes_Class $resource,  core_kernel_classes_Property $property, $propertyFilters = array(), $options = array())
    {
        $returnValue = array();
        
        $distinct = isset($options['distinct']) ? $options['distinct'] : false;
        
        if (count($propertyFilters) === 0) {
            $options = array_merge($options, array('like' => false));
        }
        
        $filteredQuery = $this->getFilteredQuery($resource, $propertyFilters, $options);
        
        // Get all the available property values in the subset of instances
        $query = 'SELECT';
        if ($distinct) {
            $query .= ' DISTINCT';
        }
        
        $query .= " object FROM (SELECT overq.subject, valuesq.object FROM (${filteredQuery}) as overq JOIN statements AS valuesq ON (overq.subject = valuesq.subject AND valuesq.predicate = ?)) AS overrootq";
        
        $sqlResult = $this->getPersistence()->query($query, array($property->getUri()));
        while ($row = $sqlResult->fetch()) {
            $returnValue[] = common_Utils::toResource($row['object']);
        }
        
        return (array) $returnValue;
    }
1000084
protected function getLink(\core_kernel_classes_Resource $resource)
    {
        $instance = $resource->getUniquePropertyValue($this->getProperty(self::PROPERTY_LINK));
        return $instance instanceof \core_kernel_classes_Resource ? $instance->getUri() : (string)$instance;
    }
474254
public function create(string $resourceClass, array $options = []): PropertyNameCollection
    {
        $properties = $this->propertyInfo->getProperties($resourceClass, $options);
        if (null === $properties) {
            throw new RuntimeException(sprintf('There is no PropertyInfo extractor supporting the class "%s".', $resourceClass));
        }

        return new PropertyNameCollection($properties);
    }
751053
public function createInstanceWithProperties( core_kernel_classes_Class $type, $properties)
    {
        $returnValue = null;

        if (isset($properties[OntologyRdf::RDF_TYPE])) {
            throw new core_kernel_persistence_Exception('Additional types in createInstanceWithProperties not permited');
        }
        
        $properties[OntologyRdf::RDF_TYPE] = $type;
		$returnValue = new core_kernel_classes_Resource(common_Utils::getNewUri(), __METHOD__);
		$returnValue->setPropertiesValues($properties);
        
        return $returnValue;
    }