Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Model Driven Health Tools » XSI/Template Processing(Need to update the CDA XSI Type provider)
XSI/Template Processing [message #1740218] Wed, 10 August 2016 14:14 Go to next message
Sean Muir is currently offline Sean MuirFriend
Messages: 52
Registered: September 2015
Member
The current CDA XSI type provider leverages the hierarchy size to determine best fit - This as worked well because until Consol2 - templates followed this pattern
Consol 2 has introduced versions of templates and not all version 2 are inheriting from version 1 introducing a race condition of sorts

Below is a sort approach based on a change to the processing where you collect all possible template classes then sort them and then pop the first one

The first is to check for isa relationships
Second is check for matching template ids - if match check the versions
lastly check the hierarchy size

one option is to add a name space uri preference which could be configured at runtime

Thoughts ?

		Comparator<? super EClass> templateComparator = new Comparator<EClass>() {

			@Override
			public int compare(EClass templatedClass1, EClass templatedClass2) {
				
				// Check hierarchies 
				if (templatedClass1.getEAllSuperTypes().contains(templatedClass2)) {
					return -1;
				}
				
				if (templatedClass2.getEAllSuperTypes().contains(templatedClass1)) {
					return 1;
				}
				
				
				// Check templates - if equal, check and compare versions - assume no version is earlier then version 
				String o1TemplateId = EcoreUtil.getAnnotation( templatedClass1, CDA_ANNOTATION_SOURCE, TEMPLATE_ID_ROOT);
				
				String o2TemplateId = EcoreUtil.getAnnotation( templatedClass2, CDA_ANNOTATION_SOURCE, TEMPLATE_ID_ROOT);
				
				if (!StringUtils.isEmpty(o1TemplateId) && o1TemplateId.equals(o2TemplateId)) {
					
					String o1TemplateVersion = EcoreUtil.getAnnotation(	templatedClass1, CDA_ANNOTATION_SOURCE, TEMPLATE_ID_EXTENSION);
					
					String o2TemplateVersion = EcoreUtil.getAnnotation(	templatedClass1, CDA_ANNOTATION_SOURCE, TEMPLATE_ID_EXTENSION);
					
					if (StringUtils.isEmpty(o1TemplateVersion) && !StringUtils.isEmpty(o2TemplateVersion)) {
						return 1;
					}
					
					if (!StringUtils.isEmpty(o1TemplateVersion) && StringUtils.isEmpty(o2TemplateVersion)) {
						return -1;
					}
					
					if (!StringUtils.isEmpty(o1TemplateVersion) && !StringUtils.isEmpty(o2TemplateVersion)) {
						Date d1 = null;
						Date d2 = null;
						try {
							d1 =DateFormat.getDateInstance().parse(o1TemplateVersion);
							d2 = DateFormat.getDateInstance().parse(o2TemplateVersion);
							return d1.compareTo(d2);
						} catch (ParseException e) {
							if (d1 == null) {
								return 1;
							}
							if (d2 == null) {
								return -1;
							}
						
						}
					}
							
				}
				
				
				// Lastly default to hierarchy depth - this is how currently done
				if (templatedClass1.getEAllSuperTypes().size() > templatedClass2.getEAllSuperTypes().size()) {
					return -1;
				} else if (templatedClass1.getEAllSuperTypes().size() > templatedClass2.getEAllSuperTypes().size()) {
					return 1;
				}
						
				return 0;
			}
			
		};
Re: XSI/Template Processing [message #1740235 is a reply to message #1740218] Wed, 10 August 2016 15:20 Go to previous messageGo to next message
Dan Brown is currently offline Dan BrownFriend
Messages: 19
Registered: December 2015
Junior Member
This looks good.

The only issue I see is this typo:
These lines have a duplicate condition (vs swapping templateClass1/2):
if (templatedClass1.getEAllSuperTypes().size() > templatedClass2.getEAllSuperTypes().size()) {
return -1;
} else if (templatedClass1.getEAllSuperTypes().size() > templatedClass2.getEAllSuperTypes().size()) {
return 1;
}

I like how it is checking the dates. However, it's probably worth looking into if the the date format is universal for CDA or just an R2.1 thing as far as extension values are concerned.

I can give you a sample to test to see how it's working.
Re: XSI/Template Processing [message #1740237 is a reply to message #1740235] Wed, 10 August 2016 15:32 Go to previous messageGo to next message
Sean Muir is currently offline Sean MuirFriend
Messages: 52
Registered: September 2015
Member
i was expecting the consol 2 date format to be the "standard one" is this something to ping struc docs ?
Re: XSI/Template Processing [message #1740323 is a reply to message #1740237] Thu, 11 August 2016 15:25 Go to previous message
Dan Brown is currently offline Dan BrownFriend
Messages: 19
Registered: December 2015
Junior Member
I expect as much as well, but you never know. Wouldn't hurt to ping them but we can always cross that bridge when/if we get there. Up to you.
Previous Topic:Support for JDK1.6
Next Topic:How can I start MDHT project?
Goto Forum:
  


Current Time: Fri Sep 21 09:37:15 GMT 2018

Powered by FUDForum. Page generated in 0.01688 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top