{
private Pattern pattern;
@@ -37,41 +38,23 @@
}
/**
- * @see org.openmrs.customdatatype.CustomDatatype#toReferenceString(java.lang.Object)
+ * @see org.openmrs.customdatatype.SerializingCustomDatatype#serialize(java.lang.Object)
* @should fail if the string does not match the regex
*/
@Override
- public String toReferenceString(String typedValue) throws InvalidCustomValueException {
- validate(typedValue);
+ public String serialize(String typedValue) {
return typedValue;
}
/**
- * @see org.openmrs.customdatatype.CustomDatatype#fromReferenceString(java.lang.String)
+ * @see org.openmrs.customdatatype.SerializingCustomDatatype#deserialize(java.lang.String)
*/
@Override
- public String fromReferenceString(String persistedValue) throws InvalidCustomValueException {
- validate(persistedValue);
- return persistedValue;
+ public String deserialize(String serializedValue) {
+ return serializedValue;
}
/**
- * @see org.openmrs.customdatatype.CustomDatatype#render(java.lang.String, java.lang.String)
- */
- @Override
- public String render(String persistedValue, String view) {
- return persistedValue;
- }
-
- /**
- * @see org.openmrs.customdatatype.CustomDatatype#validateReferenceString(java.lang.String)
- */
- @Override
- public void validateReferenceString(String persistedValue) throws InvalidCustomValueException {
- validate(persistedValue);
- }
-
- /**
* @see org.openmrs.customdatatype.CustomDatatype#validate(java.lang.Object)
* @should accept a string that matches the regex
* @should fail if the string does not match the regex
Index: api/src/main/java/org/openmrs/api/AdministrationService.java
===================================================================
--- api/src/main/java/org/openmrs/api/AdministrationService.java (wersja 24555)
+++ api/src/main/java/org/openmrs/api/AdministrationService.java (kopia robocza)
@@ -41,6 +41,8 @@
import org.openmrs.reporting.Report;
import org.openmrs.util.OpenmrsConstants;
import org.openmrs.util.PrivilegeConstants;
+import org.springframework.transaction.annotation.Isolation;
+import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
/**
@@ -49,6 +51,7 @@
* Use:
*
*
+ *
* List<GlobalProperty> globalProperties = Context.getAdministrationService().getGlobalProperties();
*
*
@@ -711,10 +714,14 @@
public T getGlobalPropertyValue(String propertyName, T defaultValue) throws APIException;
/**
- *
* @param aClass class of object getting length for
* @param fieldName name of the field to get the length for
* @return the max field length of a property
*/
public int getMaximumPropertyLength(Class extends OpenmrsObject> aClass, String fieldName);
+
+ //@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW, isolation = Isolation.READ_COMMITTED)
+ //@Transactional(readOnly = true, propagation = Propagation.NESTED)
+ @Transactional(readOnly = true)
+ public void validateInNewTransaction(Object mainArgument);
}
Index: api/src/main/java/org/openmrs/customdatatype/datatype/FreeTextDatatype.java
===================================================================
--- api/src/main/java/org/openmrs/customdatatype/datatype/FreeTextDatatype.java (wersja 24555)
+++ api/src/main/java/org/openmrs/customdatatype/datatype/FreeTextDatatype.java (kopia robocza)
@@ -13,63 +13,30 @@
*/
package org.openmrs.customdatatype.datatype;
-import org.openmrs.customdatatype.CustomDatatype;
-import org.openmrs.customdatatype.InvalidCustomValueException;
+import org.openmrs.customdatatype.SerializingCustomDatatype;
import org.springframework.stereotype.Component;
/**
* Free-text datatype, represented by a plain java.lang.String.
+ *
* @since 1.9
*/
@Component
-public class FreeTextDatatype implements CustomDatatype {
+public class FreeTextDatatype extends SerializingCustomDatatype {
/**
- * @see org.openmrs.customdatatype.CustomDatatype#toReferenceString(java.lang.Object)
+ * @see org.openmrs.customdatatype.SerializingCustomDatatype#serialize(java.lang.Object)
*/
@Override
- public String toReferenceString(String typedValue) throws InvalidCustomValueException {
- return typedValue;
+ public String serialize(String typedValue) {
+ return (String) typedValue;
}
/**
- * @see org.openmrs.customdatatype.CustomDatatype#fromReferenceString(java.lang.String)
+ * @see org.openmrs.customdatatype.SerializingCustomDatatype#deserialize(java.lang.String)
*/
@Override
- public String fromReferenceString(String persistedValue) throws InvalidCustomValueException {
- return persistedValue;
+ public String deserialize(String serializedValue) {
+ return serializedValue;
}
-
- /**
- * @see org.openmrs.customdatatype.CustomDatatype#render(java.lang.String, java.lang.String)
- */
- @Override
- public String render(String persistedValue, String view) {
- return persistedValue;
- }
-
- /**
- * @see org.openmrs.customdatatype.CustomDatatype#validateReferenceString(java.lang.String)
- */
- @Override
- public void validateReferenceString(String persistedValue) throws InvalidCustomValueException {
- // pass
- }
-
- /**
- * @see org.openmrs.customdatatype.CustomDatatype#validate(java.lang.Object)
- */
- @Override
- public void validate(String typedValue) throws InvalidCustomValueException {
- //pass
- }
-
- /**
- * @see org.openmrs.customdatatype.CustomDatatype#setConfiguration(java.lang.String)
- */
- @Override
- public void setConfiguration(String config) {
- // not used
- }
-
}
Index: api/src/test/java/org/openmrs/validator/VisitValidatorTest.java
===================================================================
--- api/src/test/java/org/openmrs/validator/VisitValidatorTest.java (wersja 24555)
+++ api/src/test/java/org/openmrs/validator/VisitValidatorTest.java (kopia robocza)
@@ -91,7 +91,7 @@
private VisitAttribute makeAttribute(String serializedValue) {
VisitAttribute attr = new VisitAttribute();
attr.setAttributeType(service.getVisitAttributeType(1));
- attr.setValueReference(serializedValue);
+ attr.setValueReferenceInternal(serializedValue);
return attr;
}
@@ -168,6 +168,7 @@
encounter.setVisit(visit);
encounter.setEncounterDatetime(visit.getStartDatetime());
Context.getEncounterService().saveEncounter(encounter);
+ Context.flushSession();
//Set visit start date to after the encounter date.
Date date = new Date(encounter.getEncounterDatetime().getTime() + 1);
Index: api/src/test/java/org/openmrs/customdatatype/datatype/RegexValidatedTextTest.java
===================================================================
--- api/src/test/java/org/openmrs/customdatatype/datatype/RegexValidatedTextTest.java (wersja 24555)
+++ api/src/test/java/org/openmrs/customdatatype/datatype/RegexValidatedTextTest.java (kopia robocza)
@@ -15,7 +15,7 @@
}
/**
- * @see RegexValidatedTextDatatype#validate(String)
+ * @see RegexValidatedText#validate(String)
* @verifies accept a string that matches the regex
*/
@Test
@@ -24,7 +24,7 @@
}
/**
- * @see RegexValidatedTextDatatype#validate(String)
+ * @see RegexValidatedText#validate(String)
* @verifies fail if the string does not match the regex
*/
@Test(expected = InvalidCustomValueException.class)
@@ -33,11 +33,11 @@
}
/**
- * @see RegexValidatedTextDatatype#toReferenceString(String)
+ * @see RegexValidatedText#save(String, String))
* @verifies fail if the string does not match the regex
*/
@Test(expected = InvalidCustomValueException.class)
public void toPersistentString_shouldFailIfTheStringDoesNotMatchTheRegex() throws Exception {
- datatype.toReferenceString("spaces not allowed");
+ datatype.save("spaces not allowed", null);
}
}
Index: web/src/main/java/org/openmrs/web/controller/concept/ConceptStopWordListController.java
===================================================================
--- web/src/main/java/org/openmrs/web/controller/concept/ConceptStopWordListController.java (wersja 24555)
+++ web/src/main/java/org/openmrs/web/controller/concept/ConceptStopWordListController.java (kopia robocza)
@@ -64,6 +64,7 @@
for (String conceptStopWordToBeDeleted : conceptStopWordsToBeDeleted) {
try {
conceptService.deleteConceptStopWord(new Integer(conceptStopWordToBeDeleted));
+ Context.flushSession();
session.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "general.deleted");
}
catch (ConceptStopWordException e) {
Index: api/src/main/resources/org/openmrs/api/db/hibernate/VisitAttribute.hbm.xml
===================================================================
--- api/src/main/resources/org/openmrs/api/db/hibernate/VisitAttribute.hbm.xml (wersja 24555)
+++ api/src/main/resources/org/openmrs/api/db/hibernate/VisitAttribute.hbm.xml (kopia robocza)
@@ -20,7 +20,7 @@
-
+
Index: api/src/main/java/org/openmrs/customdatatype/NotYetPersistedException.java
===================================================================
--- api/src/main/java/org/openmrs/customdatatype/NotYetPersistedException.java (wersja 0)
+++ api/src/main/java/org/openmrs/customdatatype/NotYetPersistedException.java (wersja 0)
@@ -0,0 +1,23 @@
+/**
+ * The contents of this file are subject to the OpenMRS Public License
+ * Version 1.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://license.openmrs.org
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * Copyright (C) OpenMRS, LLC. All Rights Reserved.
+ */
+package org.openmrs.customdatatype;
+
+import org.openmrs.api.APIException;
+
+/**
+ * Indicates that you tried to access the valueReference of a {@link SingleCustomValue} that has not yet been persisted
+ */
+public class NotYetPersistedException extends APIException {
+
+}
Index: api/src/test/java/org/openmrs/reporting/export/DataExportTest.java
===================================================================
--- api/src/test/java/org/openmrs/reporting/export/DataExportTest.java (wersja 24555)
+++ api/src/test/java/org/openmrs/reporting/export/DataExportTest.java (kopia robocza)
@@ -627,7 +627,7 @@
DataExportUtil.generateExport(export, patients, "\t", null);
File exportFile = DataExportUtil.getGeneratedFile(export);
- String expectedOutput = "PATIENT_ID \"FOOD ASSISTANCE\" \"DATE OF FOOD ASSISTANCE\" \"FAVORITE FOOD, NON-CODED\" \"WEIGHT\"\n7 1.0 14/08/2008 PB and J 50.0\n8 \n";
+ String expectedOutput = "PATIENT_ID \"FOOD ASSISTANCE\" \"DATE OF FOOD ASSISTANCE\" \"FAVORITE FOOD, NON-CODED\" \"WEIGHT\"\n7 YES 14/08/2008 PB and J 50.0\n8 \n";
String output = OpenmrsUtil.getFileAsString(exportFile);
exportFile.delete();
Index: web/src/main/java/org/openmrs/web/controller/maintenance/SettingsController.java
===================================================================
--- web/src/main/java/org/openmrs/web/controller/maintenance/SettingsController.java (wersja 24555)
+++ web/src/main/java/org/openmrs/web/controller/maintenance/SettingsController.java (kopia robocza)
@@ -76,7 +76,7 @@
try {
Object value = WebAttributeUtil.getValue(request, dt, handler, "settings[" + i
+ "].globalProperty.propertyValue");
- property.getGlobalProperty().setPropertyValue(dt.toReferenceString(value));
+ property.getGlobalProperty().setValue(value);
}
catch (Exception ex) {
String originalValue = request.getParameter("originalValue[" + i + "]");
Index: api/src/test/java/org/openmrs/api/OrderServiceTest.java
===================================================================
--- api/src/test/java/org/openmrs/api/OrderServiceTest.java (wersja 24555)
+++ api/src/test/java/org/openmrs/api/OrderServiceTest.java (kopia robocza)
@@ -107,6 +107,7 @@
Patient p = Context.getPatientService().getPatient(2);
Assert.assertFalse(p.isVoided());
Context.getOrderService().voidDrugSet(p, "1", "Reason", OrderService.SHOW_ALL);
+ Context.flushSession();
Assert.assertFalse(p.isVoided());
}
}
Index: web/src/test/java/org/openmrs/web/controller/concept/ConceptStopWordListControllerTest.java
===================================================================
--- web/src/test/java/org/openmrs/web/controller/concept/ConceptStopWordListControllerTest.java (wersja 24555)
+++ web/src/test/java/org/openmrs/web/controller/concept/ConceptStopWordListControllerTest.java (kopia robocza)
@@ -20,6 +20,7 @@
import org.junit.Assert;
import org.junit.Test;
import org.openmrs.ConceptStopWord;
+import org.openmrs.api.context.Context;
import org.openmrs.test.Verifies;
import org.openmrs.web.WebConstants;
import org.openmrs.web.test.BaseWebContextSensitiveTest;
Index: api/src/main/java/org/openmrs/BaseCustomizableMetadata.java
===================================================================
--- api/src/main/java/org/openmrs/BaseCustomizableMetadata.java (wersja 24555)
+++ api/src/main/java/org/openmrs/BaseCustomizableMetadata.java (kopia robocza)
@@ -30,7 +30,7 @@
*/
public abstract class BaseCustomizableMetadata extends BaseOpenmrsMetadata implements Customizable {
- private Set attributes;
+ private Set attributes = new LinkedHashSet();
/**
* @see org.openmrs.customdatatype.Customizable#getAttributes()
Index: api/src/main/java/org/openmrs/reporting/export/DataExportFunctions.java
===================================================================
--- api/src/main/java/org/openmrs/reporting/export/DataExportFunctions.java (wersja 24555)
+++ api/src/main/java/org/openmrs/reporting/export/DataExportFunctions.java (kopia robocza)
@@ -37,6 +37,7 @@
import org.openmrs.Encounter;
import org.openmrs.EncounterType;
import org.openmrs.Location;
+import org.openmrs.Obs;
import org.openmrs.Patient;
import org.openmrs.PatientIdentifier;
import org.openmrs.PatientIdentifierType;
@@ -1186,6 +1187,8 @@
return ((EncounterType) o).getName();
else if (o instanceof Date)
return formatDate(null, (Date) o);
+ else if (o instanceof Obs)
+ return ((Obs) o).getValueAsString(Context.getLocale());
else
return o.toString();
}
Index: api/src/main/resources/org/openmrs/api/db/hibernate/ProviderAttribute.hbm.xml
===================================================================
--- api/src/main/resources/org/openmrs/api/db/hibernate/ProviderAttribute.hbm.xml (wersja 24555)
+++ api/src/main/resources/org/openmrs/api/db/hibernate/ProviderAttribute.hbm.xml (kopia robocza)
@@ -18,7 +18,7 @@
-
+
Index: web/src/test/java/org/openmrs/web/controller/GlobalPropertyPortletControllerTest.java
===================================================================
--- web/src/test/java/org/openmrs/web/controller/GlobalPropertyPortletControllerTest.java (wersja 24555)
+++ web/src/test/java/org/openmrs/web/controller/GlobalPropertyPortletControllerTest.java (kopia robocza)
@@ -49,6 +49,7 @@
GlobalProperty[] globalProperties = { new GlobalProperty("file.started", ""),
new GlobalProperty("file.mandatory", ""), new GlobalProperty("file.other", "") };
Context.getAdministrationService().saveGlobalProperties(Arrays.asList(globalProperties));
+ Context.flushSession();
//then
portletController.populateModel(request, model);
Index: api/src/main/java/org/openmrs/api/impl/ProviderServiceImpl.java
===================================================================
--- api/src/main/java/org/openmrs/api/impl/ProviderServiceImpl.java (wersja 24555)
+++ api/src/main/java/org/openmrs/api/impl/ProviderServiceImpl.java (kopia robocza)
@@ -101,12 +101,7 @@
*/
@Override
public Provider saveProvider(Provider provider) {
- //remove this validation when TRUNK-2393 is done
- Errors errors = new BindException(provider, "provider");
- new ProviderValidator().validate(provider, errors);
- if (errors.hasErrors())
- throw new APIException(Context.getMessageSourceService().getMessage("error.foundValidationErrors"));
-
+ CustomDatatypeUtil.saveAttributesIfNecessary(provider);
return dao.saveProvider(provider);
}
Index: api/src/main/java/org/openmrs/validator/UserValidator.java
===================================================================
--- api/src/main/java/org/openmrs/validator/UserValidator.java (wersja 24555)
+++ api/src/main/java/org/openmrs/validator/UserValidator.java (kopia robocza)
@@ -105,7 +105,12 @@
* @should not validate when username is whitespace only
*/
public boolean isUserNameValid(String username) {
- //Initialize reg ex for userName pattern
+ //Initialize reg ex for userName pattern
+ // ^ = start of line
+ // \w = [a-zA-Z_0-9]
+ // \Q = quote everything until \E
+ // $ = end of line
+ // complete meaning = 2-50 characters, the first must be a letter, digit, or _, and the rest may also be - or .
String expression = "^[\\w][\\Q_\\E\\w-\\.]{1,49}$";
// empty usernames are allowed
Index: api/src/test/java/org/openmrs/report/ReportSchemaXmlTest.java
===================================================================
--- api/src/test/java/org/openmrs/report/ReportSchemaXmlTest.java (wersja 24555)
+++ api/src/test/java/org/openmrs/report/ReportSchemaXmlTest.java (kopia robocza)
@@ -112,6 +112,7 @@
// delete the just created report schema xml object
rs.deleteReportSchemaXml(reportSchemaXmlFromDB);
+ Context.flushSession();
// try to fetch that deleted xml object, expect null
ReportSchemaXml deletedXml = rs.getReportSchemaXml(1);
Index: api/src/main/java/org/openmrs/api/impl/AdministrationServiceImpl.java
===================================================================
--- api/src/main/java/org/openmrs/api/impl/AdministrationServiceImpl.java (wersja 24555)
+++ api/src/main/java/org/openmrs/api/impl/AdministrationServiceImpl.java (kopia robocza)
@@ -58,6 +58,8 @@
import org.openmrs.api.GlobalPropertyListener;
import org.openmrs.api.context.Context;
import org.openmrs.api.db.AdministrationDAO;
+import org.openmrs.customdatatype.CustomDatatypeUtil;
+import org.openmrs.customdatatype.SingleCustomValue;
import org.openmrs.module.Module;
import org.openmrs.module.ModuleFactory;
import org.openmrs.module.ModuleUtil;
@@ -67,6 +69,7 @@
import org.openmrs.util.OpenmrsConstants;
import org.openmrs.util.OpenmrsUtil;
import org.openmrs.util.PrivilegeConstants;
+import org.openmrs.validator.ValidateUtil;
import org.springframework.util.StringUtils;
/**
@@ -775,9 +778,9 @@
* @see org.openmrs.api.AdministrationService#saveGlobalProperty(org.openmrs.GlobalProperty)
*/
public GlobalProperty saveGlobalProperty(GlobalProperty gp) throws APIException {
-
// only try to save it if the global property has a key
if (gp.getProperty() != null && gp.getProperty().length() > 0) {
+ CustomDatatypeUtil.saveIfDirty(gp);
dao.saveGlobalProperty(gp);
notifyGlobalPropertyChange(gp);
return gp;
@@ -1212,4 +1215,12 @@
public int getMaximumPropertyLength(Class extends OpenmrsObject> aClass, String fieldName) {
return dao.getMaximumPropertyLength(aClass, fieldName);
}
+
+ /**
+ * @see org.openmrs.api.AdministrationService#validateInNewTransaction(java.lang.Object)
+ */
+ @Override
+ public void validateInNewTransaction(Object mainArgument) {
+ ValidateUtil.validate(mainArgument);
+ }
}
Index: api/src/test/java/org/openmrs/api/ConceptServiceTest.java
===================================================================
--- api/src/test/java/org/openmrs/api/ConceptServiceTest.java (wersja 24555)
+++ api/src/test/java/org/openmrs/api/ConceptServiceTest.java (kopia robocza)
@@ -1072,8 +1072,9 @@
assertNotNull(concept);
ObsService obsService = Context.getObsService();
- obsService.saveObs(new Obs(new Person(1), concept, new Date(), new Location(1)),
- "Creating a new observation with a concept");
+ Obs obs = new Obs(new Person(1), concept, new Date(), new Location(1));
+ obs.setValueCoded(Context.getConceptService().getConcept(7));
+ obsService.saveObs(obs, "Creating a new observation with a concept");
ConceptDatatype newDatatype = conceptService.getConceptDatatypeByName("Text");
concept.setDatatype(newDatatype);
@@ -1095,8 +1096,9 @@
assertNotNull(concept);
ObsService obsService = Context.getObsService();
- obsService.saveObs(new Obs(new Person(1), concept, new Date(), new Location(1)),
- "Creating a new observation with a concept");
+ Obs obs = new Obs(new Person(1), concept, new Date(), new Location(1));
+ obs.setValueCoded(Context.getConceptService().getConcept(7));
+ obsService.saveObs(obs, "Creating a new observation with a concept");
conceptService.saveConcept(concept);
}
@@ -1260,7 +1262,7 @@
@Verifies(value = "should fail if any of the conceptNames of the concept is being used by an obs", method = "purgeConcept(Concept)")
public void purgeConcept_shouldFailIfAnyOfTheConceptNamesOfTheConceptIsBeingUsedByAnObs() throws Exception {
Obs o = new Obs();
- o.setConcept(new Concept(3));
+ o.setConcept(Context.getConceptService().getConcept(3));
o.setPerson(new Patient(2));
o.setEncounter(new Encounter(3));
o.setObsDatetime(new Date());
@@ -1446,6 +1448,7 @@
conceptService.deleteConceptStopWord(2);
conceptService.deleteConceptStopWord(3);
conceptService.deleteConceptStopWord(4);
+ Context.flushSession();
List conceptStopWords = conceptService.getAllConceptStopWords();
assertEquals(0, conceptStopWords.size());
@@ -1472,6 +1475,7 @@
assertEquals(1, conceptStopWords.size());
conceptService.deleteConceptStopWord(4);
+ Context.flushSession();
conceptStopWords = conceptService.getConceptStopWords(Locale.US);
assertEquals(0, conceptStopWords.size());
@@ -1743,6 +1747,7 @@
mapType.setName("random name");
mapType.setDescription("random description");
ConceptMapType editedMapType = Context.getConceptService().saveConceptMapType(mapType);
+ Context.flushSession();
Assert.assertEquals("random name", editedMapType.getName());
Assert.assertEquals("random description", editedMapType.getDescription());
//date changed and changed by should have been updated
@@ -1886,6 +1891,7 @@
term.setConceptSource(conceptSource2);
ConceptReferenceTerm editedTerm = Context.getConceptService().saveConceptReferenceTerm(term);
+ Context.flushSession();
Assert.assertEquals("new name", editedTerm.getName());
Assert.assertEquals("new code", editedTerm.getCode());
Assert.assertEquals("new descr", editedTerm.getDescription());
Index: web/src/test/java/org/openmrs/web/controller/patient/ShortPatientFormValidatorTest.java
===================================================================
--- web/src/test/java/org/openmrs/web/controller/patient/ShortPatientFormValidatorTest.java (wersja 24555)
+++ web/src/test/java/org/openmrs/web/controller/patient/ShortPatientFormValidatorTest.java (kopia robocza)
@@ -248,6 +248,7 @@
PersonName name = new PersonName("my", "duplicate", "name");
patient.addName(name);
Context.getPatientService().savePatient(patient);
+ Context.flushSession();
Assert.assertNotNull(name.getId());//should have been added
ShortPatientModel model = new ShortPatientModel(patient);
@@ -280,6 +281,7 @@
address.setAddress2("address2");
patient.addAddress(address);
Context.getPatientService().savePatient(patient);
+ Context.flushSession();
Assert.assertNotNull(address.getId());//should have been added
ShortPatientModel model = new ShortPatientModel(patient);
Index: api/src/main/java/org/openmrs/api/db/hibernate/HibernatePatientSetDAO.java
===================================================================
--- api/src/main/java/org/openmrs/api/db/hibernate/HibernatePatientSetDAO.java (wersja 24555)
+++ api/src/main/java/org/openmrs/api/db/hibernate/HibernatePatientSetDAO.java (kopia robocza)
@@ -579,7 +579,6 @@
String stringValue = null;
Concept codedValue = null;
Date dateValue = null;
- Boolean booleanValue = null;
String valueSql = null;
if (value != null) {
if (concept == null) {
@@ -619,11 +618,18 @@
}
valueSql = "o.value_datetime";
} else if (concept.getDatatype().isBoolean()) {
- if (value instanceof Boolean)
- booleanValue = (Boolean) value;
- else
- booleanValue = Boolean.valueOf(value.toString());
- valueSql = "o.value_numeric";
+ if (value instanceof Concept) {
+ codedValue = (Concept) value;
+ } else {
+ boolean asBoolean = false;
+ if (value instanceof Boolean)
+ asBoolean = ((Boolean) value).booleanValue();
+ else
+ asBoolean = Boolean.valueOf(value.toString());
+ codedValue = asBoolean ? Context.getConceptService().getTrueConcept() : Context.getConceptService()
+ .getFalseConcept();
+ }
+ valueSql = "o.value_coded";
}
}
@@ -699,8 +705,6 @@
query.setString("value", stringValue);
else if (dateValue != null)
query.setDate("value", dateValue);
- else if (booleanValue != null)
- query.setDouble("value", booleanValue ? 1.0 : 0.0);
else
throw new IllegalArgumentException(
"useValue is true, but numeric, coded, string, boolean, and date values are all null");
@@ -1236,7 +1240,7 @@
List columns = new Vector();
if (abbrev.equals("BIT"))
- columns.add("valueNumeric");
+ columns.add("valueCoded");
else if (abbrev.equals("CWE")) {
columns.add("valueDrug");
columns.add("valueCoded");