Skip to content

Commit

Permalink
fehlersuche
Browse files Browse the repository at this point in the history
  • Loading branch information
BFallert committed Oct 23, 2024
1 parent 32c83bb commit a45bd4a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
20 changes: 15 additions & 5 deletions Classes/Common/Indexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,10 @@ protected static function processLogical(Document $document, array $logicalUnit)
$doc = $document->getCurrentDocument();
$doc->cPid = $document->getPid();
// Get metadata for logical unit.
if (($logicalUnit['id'] != 'LOG_0001') and ($logicalUnit['id'] != 'LOG_0002') and ($logicalUnit['id'] != 'LOG_0003') and ($logicalUnit['id'] != 'LOG_0004') ) {
$metadata = $doc->metadataArray[$logicalUnit['id']];
//$this->logger->error('metadata ' . serialize($metadata) );
//self::handleException('metadata ' . serialize($metadata));
if (!empty($metadata)) {
$extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey, 'general');
$validator = new DocumentValidator($metadata, explode(',', $extConf['requiredMetadataFields']));
Expand All @@ -356,7 +359,9 @@ protected static function processLogical(Document $document, array $logicalUnit)
// There can be only one toplevel unit per UID, independently of backend configuration
$solrDoc->setField('toplevel', $logicalUnit['id'] == $doc->toplevelId ? true : false);
$solrDoc->setField('title', $metadata['title'][0]);
$solrDoc->setField('volume', $metadata['volume'][0]);
if ( count($metadata['volume']) > 0 ){
$solrDoc->setField('volume', $metadata['volume'][0]);
}
// verify date formatting
if(strtotime($metadata['date'][0])) {
$solrDoc->setField('date', self::getFormattedDate($metadata['date'][0]));
Expand All @@ -368,9 +373,11 @@ protected static function processLogical(Document $document, array $logicalUnit)
$solrDoc->setField('license', $metadata['license']);
$solrDoc->setField('terms', $metadata['terms']);
$solrDoc->setField('restrictions', $metadata['restrictions']);
$coordinates = json_decode($metadata['coordinates'][0]);
if (is_object($coordinates)) {
$solrDoc->setField('geom', json_encode($coordinates->features[0]));
if ( array_key_exists('coordinates', $metadata) ) {
$coordinates = json_decode($metadata['coordinates'][0]);
if (is_object($coordinates)) {
$solrDoc->setField('geom', json_encode($coordinates->features[0]));
}
}
$autocomplete = self::processMetadata($document, $metadata, $solrDoc);
// Add autocomplete values to index.
Expand All @@ -396,6 +403,7 @@ protected static function processLogical(Document $document, array $logicalUnit)
Helper::log('Tip: If "record_id" field is missing then there is possibility that METS file still contains it but with the wrong source type attribute in "recordIdentifier" element', LOG_SEVERITY_NOTICE);
return false;
}
}
}
// Check for child elements...
if (!empty($logicalUnit['children'])) {
Expand Down Expand Up @@ -522,7 +530,9 @@ private static function processMetadata($document, $metadata, &$solrDoc): array
$solrDoc->setField(self::getIndexFieldName($indexName, $document->getPid()), $data);
if (in_array($indexName, self::$fields['sortables'])) {
// Add sortable fields to index.
$solrDoc->setField($indexName . '_sorting', $metadata[$indexName . '_sorting'][0]);
if ( array_key_exists($indexName . '_sorting', $metadata) ) {
$solrDoc->setField($indexName . '_sorting', $metadata[$indexName . '_sorting'][0]);
}
}
if (in_array($indexName, self::$fields['facets'])) {
// Add facets to index.
Expand Down
5 changes: 5 additions & 0 deletions Classes/Common/MetsDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,10 @@ private function processAdditionalMetadata(array $additionalMetadata, DOMXPath $
private function setMetadataFieldValues(array $resArray, DOMXPath $domXPath, DOMElement $domNode, array &$metadata, array $subentryResults): void
{
if ($resArray['format'] > 0 && !empty($resArray['xpath'])) {
//var_dump($resArray['xpath']);
//$this->logger->error("TEST". serialize($resArray['xpath']));
$this->logger->error("TEST". $resArray['xpath']);
if ($resArray['xpath'] !== './mods:extension/ns3:ubma/ns3:branchindustry') {
$values = $domXPath->evaluate($resArray['xpath'], $domNode);
if ($values instanceof DOMNodeList && $values->length > 0) {
$metadata[$resArray['index_name']] = [];
Expand All @@ -808,6 +812,7 @@ private function setMetadataFieldValues(array $resArray, DOMXPath $domXPath, DOM
} elseif (!($values instanceof DOMNodeList)) {
$metadata[$resArray['index_name']] = [trim((string) $values)];
}
}
}
}

Expand Down

0 comments on commit a45bd4a

Please sign in to comment.