Skip to content

Commit

Permalink
fix: Property label showed in schema changed form for neo4j
Browse files Browse the repository at this point in the history
  • Loading branch information
yaraslau-kavaliou committed Dec 11, 2023
1 parent b481bea commit 77b9037
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions core/kernel/persistence/starsql/class.Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,22 +543,28 @@ public function getPropertiesValues(core_kernel_classes_Resource $resource, $pro
foreach ($result->get('resource')->getProperties() as $key => $value) {
if (in_array($key, $propertyUris)) {
if (is_iterable($value)) {
$returnValue[$key] = array_merge(
$returnValue[$key] ?? [],
$this->getLanguageProcessor()->filterByLanguage($value, [$dataLanguage, $defaultLanguage])
);
$returnValue[$key] =
array_map(
fn($value) => $this->formatValue($value),
array_merge(
$returnValue[$key] ?? [],
$this->getLanguageProcessor()->filterByLanguage(
$value,
[$dataLanguage, $defaultLanguage]
)
)
);
} else {
$returnValue[$key][] = common_Utils::isUri($value)
? $this->getModel()->getResource($value)
: new core_kernel_classes_Literal($this->getLanguageProcessor()->parseTranslatedValue($value));
$returnValue[$key][] = $this->formatValue(
$value,
[$this->getLanguageProcessor(), 'parseTranslatedValue']
);
}
}
}
foreach ($result->get('relationships') as $relationship) {
if (in_array($relationship['relationship'], $propertyUris)) {
$returnValue[$relationship['relationship']][] = common_Utils::isUri($relationship['relatedResourceUri'])
? $this->getModel()->getResource($relationship['relatedResourceUri'])
: new core_kernel_classes_Literal($relationship['relatedResourceUri']);
$returnValue[$relationship['relationship']][] = $this->formatValue($relationship['relatedResourceUri']);
}
}

Expand Down Expand Up @@ -639,4 +645,15 @@ private function buildTriplesFromNode(core_kernel_classes_ContainerCollection $t

return $tripleCollection;
}

private function formatValue($value, array $literalValueProcessingCallback = [])
{
return common_Utils::isUri($value) ?
$this->getModel()->getResource($value)
: new core_kernel_classes_Literal(
!empty($literalValueProcessingCallback)
? call_user_func($literalValueProcessingCallback, $value)
: $value
);
}
}

0 comments on commit 77b9037

Please sign in to comment.