Skip to content
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

add <tags> to goobi notify call with object tags in specified format #139

Merged
merged 2 commits into from
Aug 29, 2018

Conversation

peetucket
Copy link
Member

fixes #138

@coveralls
Copy link

coveralls commented Aug 24, 2018

Coverage Status

Coverage remained the same at 99.473% when pulling 88f3122 on send-tags-to-goobi into 9c2e064 on master.

@@ -31,6 +31,9 @@ def xml_request
<sdrWorkflow>#{Dor::Config.goobi.dpg_workflow_name}</sdrWorkflow>
<goobiWorkflow>#{goobi_workflow_name}</goobiWorkflow>
<ocr>#{goobi_ocr_tag_present?}</ocr>
<tags>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe extract this into a method that just generates the <tags> element? That would make this method less complex and easier to test the behavior.

# @return [Array]
def goobi_tag_list
@druid_obj.tags.map do |tag|
tag_split = tag.split(':', 2).map(&:strip) # only split on the first colon
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about instantiating a Tag object that responds to name and value?

Copy link
Member Author

@peetucket peetucket Aug 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So create a new tag object in the "Dor" namespace we already have setup and use it here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, It could even be a nested class in ServiceItem, if we aren't going to use it externally.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't sure what you meant about nesting inside of ServiceItem, but did an experiment with a standalone GoobiTag class here: #140


# returns an array of arrays, each element contains an array of [name, value] of DOR object tags in the format expected to pass to Goobi
# the name of the tag is the first namespace part of the tag (before first colon), value of the tag is everything after this
# @return [Array]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please specify what the Array contains.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Described current behavior, but if we move to a new Tag object, this would change the return structure to an array of Tags...do you think its worth creating a new Tag class for this use (agree the array of array is not ideal, but the name of a tag can be repeated as we define it, so we can't use a hash)


it 'creates the correct xml request with no tags present' do
allow(item).to receive(:tags).and_return([])
expect(@goobi.xml_request).to be_equivalent_to <<-END
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test might be easier to read if we do
...to include('<tags></tags>')

@@ -42,6 +42,27 @@
end
end

describe '.goobi_tag_list' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typically instance methods would be described as #goobi_tag_list

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, will update the rest of the describe blocks in this spec too

@jcoyne
Copy link
Contributor

jcoyne commented Aug 25, 2018

Thanks @peetucket. This looks good. It's still [WIP] though, right?

@peetucket
Copy link
Member Author

Yeah, still WIP -- waiting for some additional stakeholder verification/clarification.

@peetucket peetucket changed the title [WIP] add <tags> to goobi notify call with object tags in specified format add <tags> to goobi notify call with object tags in specified format Aug 28, 2018
@peetucket
Copy link
Member Author

No longer WIP - we can move forward with this

@jcoyne jcoyne merged commit 7d1a6fb into master Aug 29, 2018
@jcoyne jcoyne deleted the send-tags-to-goobi branch December 5, 2018 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

notify_goobi call needs to add all tags to XML request sent to goobi
3 participants