Skip to content

Commit

Permalink
Merged the settings "property_identifier" and "identifier_property".
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel-KM committed Dec 1, 2019
1 parent fc71685 commit b34a79a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 33 deletions.
3 changes: 1 addition & 2 deletions config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@
'csv_import_multivalue_separator' => ',',
'csv_import_rows_by_batch' => 20,
'csv_import_global_language' => '',
'csv_import_property_identifier' => 'dcterms:identifier',
'csv_import_identifier_property' => '',
'csv_import_identifier_property' => 'dcterms:identifier',
'csv_import_automap_check_names_alone' => false,
],
],
Expand Down
34 changes: 8 additions & 26 deletions src/Form/MappingForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,18 +266,21 @@ public function init()
]);

$basicSettingsFieldset->add([
'name' => 'property_identifier',
'name' => 'identifier_property',
'type' => PropertySelect::class,
'options' => [
'label' => 'Property used as identifier of linked resources', // @translate
'info' => 'Allows to create a link to the resources identified by the values in a cell.', // @translate
'label' => 'Resource identifier property', // @translate
'info' => 'Use this property, generally "dcterms:identifier", to identify the existing resources to link or to get. In all cases, it is strongly recommended to add one or more unique identifiers to all your resources.', // @translate
'empty_option' => 'Select below', // @translate
'prepend_value_options' => [
'o:id' => 'Internal ID', // @translate
],
'term_as_value' => true,
],
'attributes' => [
'value' => $userSettings->get(
'csv_import_property_identifier',
$default['csv_import_property_identifier']),
'csv_import_identifier_property',
$default['csv_import_identifier_property']),
'class' => 'chosen-select',
'data-placeholder' => 'Select a property', // @translate
],
Expand Down Expand Up @@ -337,27 +340,6 @@ public function init()
]);
}

$advancedSettingsFieldset->add([
'name' => 'identifier_property',
'type' => PropertySelect::class,
'options' => [
'label' => 'Resource identifier property', // @translate
'info' => 'Use this property, generally "dcterms:identifier", to identify the existing resources, so it will be possible to update them. One column of the file must map the selected property. In all cases, it is strongly recommended to add one ore more unique identifiers to all your resources.', // @translate
'empty_option' => 'Select below', // @translate
'prepend_value_options' => [
'o:id' => 'Internal ID', // @translate
],
'term_as_value' => true,
],
'attributes' => [
'value' => $userSettings->get(
'csv_import_identifier_property',
$default['csv_import_identifier_property']),
'class' => 'action-option chosen-select',
'data-placeholder' => 'Select a property', // @translate
],
]);

$advancedSettingsFieldset->add([
'name' => 'action_unidentified',
'type' => 'radio',
Expand Down
2 changes: 1 addition & 1 deletion src/Job/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function perform()
// The main identifier property may be used as term or as id in some
// places, so prepare it one time only.
if (empty($args['identifier_property']) || $args['identifier_property'] === 'o:id') {
$this->identifierPropertyId = $args['identifier_property'];
$this->identifierPropertyId = 'o:id';
} elseif (is_numeric($args['identifier_property'])) {
$this->identifierPropertyId = (int) $args['identifier_property'];
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/Mapping/PropertyMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ public function init(array $args, ServiceLocatorInterface $serviceLocator)

// The main identifier property may be used as term or as id in some
// places, so prepare it one time only.
if (empty($args['property_identifier']) || $args['property_identifier'] === 'o:id') {
if (empty($args['identifier_property']) || $args['identifier_property'] === 'o:id') {
$this->propertyIdentifier = 'o:id';
} elseif (is_numeric($args['property_identifier'])) {
$this->propertyIdentifier = (int) $args['property_identifier'];
} elseif (is_numeric($args['identifier_property'])) {
$this->propertyIdentifier = (int) $args['identifier_property'];
} else {
$result = $this->api
->searchOne('properties', ['term' => $args['property_identifier']])->getContent();
->searchOne('properties', ['term' => $args['identifier_property']])->getContent();
$this->propertyIdentifier = $result ? $result->id() : 'o:id';
}
}
Expand Down

0 comments on commit b34a79a

Please sign in to comment.