use of org.akaza.openclinica.bean.core.ItemDataType in project OpenClinica by OpenClinica.
the class ItemDataDAO method updateValue.
/**
* This will update item data value
*
* @param eb
* @return
*/
public EntityBean updateValue(EntityBean eb, String current_df_string) {
ItemDataBean idb = (ItemDataBean) eb;
ItemDataType dataType = getDataType(idb.getItemId());
setItemDataBeanIfDateOrPdate(idb, current_df_string, dataType);
idb.setActive(false);
HashMap<Integer, Comparable> variables = new HashMap<Integer, Comparable>();
variables.put(new Integer(1), new Integer(idb.getStatus().getId()));
variables.put(new Integer(2), idb.getValue());
variables.put(new Integer(3), new Integer(idb.getUpdaterId()));
variables.put(new Integer(4), new Integer(idb.getId()));
this.execute(digester.getQuery("updateValue"), variables);
if (isQuerySuccessful()) {
idb.setActive(true);
}
return idb;
}
use of org.akaza.openclinica.bean.core.ItemDataType in project OpenClinica by OpenClinica.
the class OpenClinicaVariableNode method testCalculate.
@Override
String testCalculate() throws OpenClinicaSystemException {
validate();
String variableValue = testCalculateVariable();
boolean isEventStatusParamExist = number.endsWith(STATUS);
boolean isEventStartDateParamExist = number.endsWith(STARTDATE);
boolean isEventStartDateAndStatusParamExist = (number.endsWith(STARTDATE) || number.endsWith(STATUS));
if (variableValue != null) {
return variableValue;
}
ItemBean item = getExpressionService().getItemBeanFromExpression(number);
String testString = "test";
String testInt = "1";
String testBoolean = "true";
String testDate = "2008-01-01";
String testPDate = "";
if (item != null) {
ItemDataType itemDataType = ItemDataType.get(item.getItemDataTypeId());
switch(itemDataType.getId()) {
case 1:
{
return theTest(testBoolean);
}
case 2:
{
return theTest(testBoolean);
}
case 3:
{
return theTest(testString);
}
case 4:
{
return theTest(testString);
}
case 5:
{
return theTest(testString);
}
case 6:
{
return theTest(testInt);
}
case 7:
{
return theTest(testInt);
}
case 8:
{
return theTest(testString);
}
case 9:
{
return theTest(testDate);
}
case 10:
{
return theTest(testPDate);
}
case 11:
{
return theTest(testString + ".txt");
}
default:
throw new OpenClinicaSystemException("OCRERR_0011");
}
} else if (isEventStartDateAndStatusParamExist) {
if (isEventStatusParamExist)
return theTest(testString);
else if (isEventStartDateParamExist)
return theTest(testDate);
else
return null;
} else {
throw new OpenClinicaSystemException("OCRERR_0012", new String[] { number });
}
}
use of org.akaza.openclinica.bean.core.ItemDataType in project OpenClinica by OpenClinica.
the class ImportHelper method validateDisplayItemBeanText.
/**
* Peform validation on a item which has a TEXT or TEXTAREA response type.
* If the item has a null value, it's automatically validated. Otherwise,
* it's checked against its data type.
*
* @param v
* The Validator to add validations to.
* @param dib
* The DisplayItemBean to validate.
* @return The DisplayItemBean which is validated.
*/
public DisplayItemBean validateDisplayItemBeanText(DiscrepancyValidator discValidator, DisplayItemBean dib, String inputName) {
if (StringUtil.isBlank(inputName)) {
// for single items
inputName = getInputName(dib);
}
ItemBean ib = dib.getItem();
ItemFormMetadataBean ibMeta = dib.getMetadata();
ItemDataType idt = ib.getDataType();
ItemDataBean idb = dib.getData();
boolean isNull = false;
if (!isNull) {
if (StringUtil.isBlank(idb.getValue())) {
// check required first
if (ibMeta.isRequired()) {
discValidator.addValidation(inputName, Validator.IS_REQUIRED);
}
} else {
if (idt.equals(ItemDataType.ST)) {
// a string's size could be more than 255, which is more
// than
// the db field length
discValidator.addValidation(inputName, Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 3999);
} else if (idt.equals(ItemDataType.INTEGER)) {
// hard edit check, will comment out for now, tbh 05/2008
// v.addValidation(inputName, Validator.IS_AN_INTEGER);
// v.alwaysExecuteLastValidation(inputName);
} else if (idt.equals(ItemDataType.REAL)) {
// hard edit check, will comment out for now, tbh 05/08
// v.addValidation(inputName, Validator.IS_A_NUMBER);
// v.alwaysExecuteLastValidation(inputName);
} else if (idt.equals(ItemDataType.BL)) {
// there is no validation here since this data type is
// explicitly
// allowed to be null
// if the string input for this field parses to a non-zero
// number, the
// value will be true; otherwise, 0
} else if (idt.equals(ItemDataType.BN)) {
} else if (idt.equals(ItemDataType.SET)) {
// v.addValidation(inputName, Validator.NO_BLANKS_SET);
discValidator.addValidation(inputName, Validator.IN_RESPONSE_SET_SINGLE_VALUE, dib.getMetadata().getResponseSet());
} else if (idt.equals(ItemDataType.DATE)) {
// hard edit check, will comment out for now, tbh 05/08
//v.addValidation(inputName, Validator.IS_A_DATE);
// v.alwaysExecuteLastValidation(inputName);
}
String customValidationString = dib.getMetadata().getRegexp();
if (!StringUtil.isBlank(customValidationString)) {
Validation customValidation = null;
if (customValidationString.startsWith("func:")) {
try {
customValidation = Validator.processCRFValidationFunction(customValidationString);
} catch (Exception e) {
e.printStackTrace();
}
} else if (customValidationString.startsWith("regexp:")) {
try {
customValidation = Validator.processCRFValidationRegex(customValidationString);
} catch (Exception e) {
}
}
if (customValidation != null) {
customValidation.setErrorMessage(dib.getMetadata().getRegexpErrorMsg());
discValidator.addValidation(inputName, customValidation);
}
}
}
}
return dib;
}
use of org.akaza.openclinica.bean.core.ItemDataType in project OpenClinica by OpenClinica.
the class BeanFactory method createItemBean.
/*
* Create an ItemBean from a Map specifying its property values, as in
* {item_name: Item1, ...) etc.
*/
public ItemBean createItemBean(Map<String, String> itemValuesMap) {
ItemBean iBean = new ItemBean();
String itemDesc = itemValuesMap.get("description_label");
String itemDataType;
iBean.setDescription(itemDesc);
itemDesc = itemValuesMap.get("item_name");
iBean.setName(itemDesc);
itemDesc = itemValuesMap.get("units");
iBean.setUnits(itemDesc);
itemDataType = itemValuesMap.get("data_type");
// TODO: solve the problem with the getByName method
ItemDataType itemDT = ItemDataType.getByName(itemDataType);
iBean.setItemDataTypeId(itemDT.getId());
return iBean;
}
Aggregations