-
Notifications
You must be signed in to change notification settings - Fork 2
Add the raw_parser option to pass XML directly to the exporter #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,9 @@ sub _build_api { | |
around add => sub { | ||
my $orig = shift; | ||
my ($self, $data) = @_; | ||
if ($self->store->raw_parser == 1) { | ||
return $self->$orig($data); | ||
} | ||
delete $data->{'_id'}; | ||
return $self->$orig($data); | ||
}; | ||
|
@@ -70,7 +73,11 @@ sub get { | |
# Create a new record | ||
sub add { | ||
my ($self, $data) = @_; | ||
return $self->api->update($data->{'id'}, $data->{'_'}); | ||
|
||
if ($self->store->raw_parser == 1) { | ||
return $self->api->add($data->{'_metadata'}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think the Datahub API should make any assumptions about the datamodel of the incoming data. the _metadata construct is a typical ouptput of OAI. I think this would violate the open/closed principle. Maybe a separate optional parser object could be injected here. Maybe not in the API implementation itself, but right before the data is passed of to this method. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, should be part of the transformation (perhaps in a fix?). |
||
} | ||
return $self->api->add($data->{'_'}); | ||
} | ||
|
||
## | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you this here? What's the added benefit of doing an encode_utf8()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
$data
contains non-ascii-characters, the client will fail.