/** * @return <code>true</code> if datatype is representation of date (but NOT a time or * datatime--see containsDate() and containsTime()) */ public boolean isDate() { return DATE_UUID.equals(getUuid()); }
/** * @return <code>true</code> if datatype is N/A, i.e. this concept is only an answer, not a * question */ public boolean isAnswerOnly() { return N_A_UUID.equals(getUuid()); }
/** * @return <code>true</code> if datatype is a numeric datatype */ public boolean isNumeric() { return NUMERIC_UUID.equals(getUuid()); }
/** * @return <code>true</code> if datatype is representation of time * @since 1.7 */ public boolean isTime() { return TIME_UUID.equals(getUuid()); }
/** * @return <code>true</code> if datatype is coded (i.e., an identifier from a vocabulary) */ public boolean isCoded() { return CODED_UUID.equals(getUuid()); }
/** * @return <code>true</code> if datatype is representation of Datetime * @since 1.7 */ public boolean isDateTime() { return DATETIME_UUID.equals(getUuid()); }
/** * @return <code>true</code> if datatype is boolean */ public boolean isBoolean() { return BOOLEAN_UUID.equals(getUuid()); }
/** * @return <code>true</code> if datatype is complex * @since 1.7 */ public boolean isComplex() { return COMPLEX_UUID.equals(getUuid()); }
/** * @return <code>true</code> if datatype is a rule * @since 1.7 */ public boolean isRule() { return RULE_UUID.equals(getUuid()); }
/** * Given a FormField, infers the related widget from the ConceptDatatype associated with that FormField. */ public static WidgetTypeHint inferWidgetTypeHint(FormField formField) { ConceptDatatype dt = formField.getField().getConcept().getDatatype(); if (dt.isText()) { return WidgetTypeHint.TEXT; } else if (dt.isNumeric()) { return WidgetTypeHint.NUMBER; } else if (dt.isDate()) { return WidgetTypeHint.DATE; } else if (dt.isCoded()) { if (formField.getField().isSelectMultiple()) return WidgetTypeHint.CHECKBOX_LIST; else if (formField.getField().getDefaultValue() != null) return WidgetTypeHint.CHECKBOX; else return WidgetTypeHint.DROPDOWN; } else if (HtmlFormEntryConstants.COMPLEX_UUID.equals(dt.getUuid())) { return WidgetTypeHint.UPLOAD_WIDGET; } else { throw new IllegalArgumentException( "Autodetecting widget type from concept datatype not yet implemented for " + dt.getName()); } }
@Test public void shouldGetAConceptDatatypeByName() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI() + "/Coded"); SimpleObject result = deserialize(handle(req)); ConceptDatatype conceptDataType = service.getConceptDatatypeByName("Coded"); Assert.assertEquals(conceptDataType.getUuid(), PropertyUtils.getProperty(result, "uuid")); Assert.assertEquals(conceptDataType.getName(), PropertyUtils.getProperty(result, "name")); }
@Test public void shouldGetAConceptDatatypeByName() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI() + "/Coded"); SimpleObject result = deserialize(handle(req)); ConceptDatatype conceptDataType = service.getConceptDatatypeByName("Coded"); Assert.assertEquals(conceptDataType.getUuid(), PropertyUtils.getProperty(result, "uuid")); Assert.assertEquals(conceptDataType.getName(), PropertyUtils.getProperty(result, "name")); }
if (dt.isNumeric()) { obs.setValueNumeric(Double.parseDouble(value.toString())); } else if (HtmlFormEntryConstants.COMPLEX_UUID.equals(dt.getUuid())) { obs.setComplexData((ComplexData) value); obs.setValueComplex(obs.getComplexData().getTitle());
@Test public void shouldGetAConceptDatatypeByUuid() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI() + "/" + getUuid()); SimpleObject result = deserialize(handle(req)); ConceptDatatype conceptDataType = service.getConceptDatatypeByUuid(getUuid()); Assert.assertEquals(conceptDataType.getUuid(), PropertyUtils.getProperty(result, "uuid")); Assert.assertEquals(conceptDataType.getName(), PropertyUtils.getProperty(result, "name")); }
@Test public void shouldGetAConceptDatatypeByUuid() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI() + "/" + getUuid()); SimpleObject result = deserialize(handle(req)); ConceptDatatype conceptDataType = service.getConceptDatatypeByUuid(getUuid()); Assert.assertEquals(conceptDataType.getUuid(), PropertyUtils.getProperty(result, "uuid")); Assert.assertEquals(conceptDataType.getName(), PropertyUtils.getProperty(result, "name")); }