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

Enable content switching on type- and formatCode #7

Closed
hnnesv opened this issue Jul 9, 2014 · 4 comments · Fixed by #8
Closed

Enable content switching on type- and formatCode #7

hnnesv opened this issue Jul 9, 2014 · 4 comments · Fixed by #8

Comments

@hnnesv
Copy link
Contributor

hnnesv commented Jul 9, 2014

Issue raised by Justin on the wiki:

Would it be beneficial to include the formatCode and/or typeCode in the get/deregister methods? I'm just thinking it might be useful information for determining which handler to call. Many different types of document may have "text/xml" as their mimeType and this might be insufficient for determining the appropriate contenthandler.
See: http://motorcycleguy.blogspot.ca/2013/05/classifying-documents-in-xds.html.

We could alter the signatures as follows:

ContentHandler getContentHandler(String contentType, String typeCode, String formatCode);
void registerContentHandler(String contentType, String typeCode, String formatCode, ContentHandler prototype) ...;

Perhaps we should even take out the use of contentType and just switch on type- and formatCode? It sounds like they are more useful ito SHR usage?

For generic purposes switching on contentType could be useful I suppose, so we could have two matching paths:

ContentHandler getContentHandler(String contentType);
void registerContentHandler(String contentType, ContentHandler prototype) ...;

ContentHandler getContentHandler(String typeCode, String formatCode);
void registerContentHandler(String typeCode, String formatCode, ContentHandler prototype) ...;

allowing for one or the other...

@rcrichton
Copy link
Member

Thanks @justin-fyfe @devcritter.

I completely agree, we should use typeCode and formatCode for the switching if content type is not going to be sufficient. Maybe we should just switch on those and if we have a use case for content type as well in the future then we can add it in.

@justin-fyfe
Copy link

One question, would it be possible for a content handler to be able to register itself (or subscribe) to multiple formatCodes? I assume that it is possible for a generic CDA handler (that could handle several PCC templates) to call register for each template that can be handled.

@rcrichton
Copy link
Member

I'm not sure if this is possible at the moment, maybe @devcritter can comment further. I definitely think that a content handler should be able to do that though.

@hnnesv
Copy link
Contributor Author

hnnesv commented Jul 9, 2014

Yup, they can at the moment (well on contentType).

hnnesv added a commit that referenced this issue Jul 14, 2014
added type code to Content object,
added type- formatCode handler map in service,
type- formatCode handling for the unstructured data handler.
hnnesv added a commit that referenced this issue Jul 14, 2014
ServiceImpl: Switch InvalidContentTypeException -> InvalidCodedValueException
@hnnesv hnnesv mentioned this issue Jul 14, 2014
@hnnesv hnnesv closed this as completed in #8 Jul 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants