Advertisement
Guest User

Untitled

a guest
Feb 27th, 2013
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. /**
  2.  
  3. * The contents of this file are subject to the OpenMRS Public License
  4.  
  5. * Version 1.0 (the "License"); you may not use this file except in
  6.  
  7. * compliance with the License. You may obtain a copy of the License at
  8.  
  9. * http://license.openmrs.org
  10.  
  11. *
  12.  
  13. * Software distributed under the License is distributed on an "AS IS"
  14.  
  15. * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
  16.  
  17. * License for the specific language governing rights and limitations
  18.  
  19. * under the License.
  20.  
  21. *
  22.  
  23. * Copyright (C) OpenMRS, LLC. All Rights Reserved.
  24.  
  25. */
  26.  
  27. package org.openmrs.customdatatype.datatype;
  28.  
  29.  
  30.  
  31. import org.apache.commons.lang.StringUtils;
  32.  
  33. import org.openmrs.Concept;
  34.  
  35. import org.openmrs.api.ConceptService;
  36.  
  37. import org.openmrs.api.context.Context;
  38.  
  39. import org.openmrs.Obs;
  40.  
  41. import org.openmrs.customdatatype.SerializingCustomDatatype;
  42.  
  43. import org.springframework.stereotype.Component;
  44.  
  45.  
  46.  
  47. /**
  48.  
  49. * Datatype for Concept, represented by org.openmrs.Concept.
  50.  
  51. * @since 1.9
  52.  
  53. */
  54.  
  55. @Component
  56.  
  57. public class ConceptDatatype extends SerializingCustomDatatype<Concept> {
  58.  
  59.  
  60.  
  61. ConceptService concept = Context.getConceptService();
  62.  
  63.  
  64.  
  65. /**
  66.  
  67. * @see org.openmrs.customdatatype.SerializingCustomDatatype#doGetTextSummary(java.lang.Object)
  68.  
  69. */
  70.  
  71. @Override
  72.  
  73. public String serialize(Concept typedValue) {
  74.  
  75. if (typedValue == null)
  76.  
  77. return null;
  78.  
  79. return typedValue.getUuid();
  80.  
  81. }
  82.  
  83.  
  84.  
  85. /**
  86.  
  87. * @see org.openmrs.customdatatype.SerializingCustomDatatype#doGetTextSummary(java.lang.Object)
  88.  
  89. */
  90.  
  91. @Override
  92.  
  93. public Concept deserialize(String serializedValue) {
  94.  
  95. if (StringUtils.isEmpty(serializedValue))
  96.  
  97. return null;
  98.  
  99. return concept.getConceptByUuid(serializedValue);
  100.  
  101. }
  102.  
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement