use of org.akaza.openclinica.bean.submit.ItemGroupBean in project OpenClinica by OpenClinica.
the class ItemGroupDAO method getEntityFromHashMap.
public Object getEntityFromHashMap(HashMap hm) {
ItemGroupBean formGroupBean = new ItemGroupBean();
super.setEntityAuditInformation(formGroupBean, hm);
formGroupBean.setId((Integer) hm.get("item_group_id"));
formGroupBean.setName((String) hm.get("name"));
formGroupBean.setCrfId((Integer) hm.get("crf_id"));
formGroupBean.setOid((String) hm.get("oc_oid"));
formGroupBean.setLayoutGroupPath((String) hm.get("layout_group_path"));
return formGroupBean;
}
use of org.akaza.openclinica.bean.submit.ItemGroupBean in project OpenClinica by OpenClinica.
the class ItemGroupDAO method findTopOneGroupBySectionId.
public ItemGroupBean findTopOneGroupBySectionId(int sectionId) {
ItemGroupBean formGroupBean = new ItemGroupBean();
this.setTypesExpected();
HashMap<Integer, Integer> variables = new HashMap<Integer, Integer>();
variables.put(1, sectionId);
String sql = digester.getQuery("findTopOneGroupBySectionId");
ArrayList listofMap = this.select(sql, variables);
for (Object map : listofMap) {
formGroupBean = (ItemGroupBean) this.getEntityFromHashMap((HashMap) map);
}
return formGroupBean;
}
use of org.akaza.openclinica.bean.submit.ItemGroupBean in project OpenClinica by OpenClinica.
the class ExpressionService method getItemGroupExpression.
public ItemGroupBean getItemGroupExpression(String expression) {
if (expression.split(ESCAPED_SEPERATOR).length < 2) {
return null;
}
String itemGroupKey = getItemGroupOidFromExpression(expression);
logger.debug("Expression : {} , ItemGroup OID : {} " + expression, itemGroupKey);
if (itemGroups.get(itemGroupKey) != null) {
return itemGroups.get(itemGroupKey);
} else {
ItemGroupBean itemGroup = getItemGroupDao().findByOid(itemGroupKey);
if (itemGroup != null) {
itemGroups.put(itemGroupKey, itemGroup);
return itemGroup;
} else {
return null;
}
}
}
use of org.akaza.openclinica.bean.submit.ItemGroupBean in project OpenClinica by OpenClinica.
the class ExpressionService method isExpressionValid.
/**
* Given a Complete Expression check business logic validity of each
* component. Will throw OpenClinicaSystemException with correct
* explanation. This might allow immediate communication of message to user
* .
*
* @param expression
*/
public void isExpressionValid(String expression) {
int length = expression.split(ESCAPED_SEPERATOR).length;
ItemBean item = null;
ItemGroupBean itemGroup = null;
CRFBean crf = null;
boolean isEventStartDateAndStatusParamExist = (expression.endsWith(STARTDATE) || expression.endsWith(STATUS));
if (length > 0 && !isEventStartDateAndStatusParamExist) {
item = getItemFromExpression(expression);
if (item == null)
throw new OpenClinicaSystemException("OCRERR_0023");
// throw new OpenClinicaSystemException("item is Invalid");
}
if (length > 1 && !isEventStartDateAndStatusParamExist) {
String itemGroupOid = getItemGroupOidFromExpression(expression);
itemGroup = getItemGroupDao().findByOid(itemGroupOid);
ArrayList<ItemGroupBean> igBean = (ArrayList<ItemGroupBean>) getItemGroupDao().findGroupsByItemID(item.getId());
if (itemGroup == null || itemGroup.getId() != igBean.get(0).getId())
throw new OpenClinicaSystemException("OCRERR_0022");
// throw new OpenClinicaSystemException("itemGroup is Invalid");
}
if (length > 2 && !isEventStartDateAndStatusParamExist) {
crf = getCRFFromExpression(expression);
if (crf == null || crf.getId() != itemGroup.getCrfId())
throw new OpenClinicaSystemException("OCRERR_0033");
// throw new OpenClinicaSystemException("CRF is Invalid");
}
if (length > 3 && !isEventStartDateAndStatusParamExist) {
StudyEventDefinitionBean studyEventDefinition = getStudyEventDefinitionFromExpression(expression);
crf = getCRFFromExpression(expression);
if (studyEventDefinition == null || crf == null)
throw new OpenClinicaSystemException("OCRERR_0034", new String[] { expression });
// throw new
// OpenClinicaSystemException("StudyEventDefinition is Invalid");
EventDefinitionCRFBean eventDefinitionCrf = getEventDefinitionCRFDao().findByStudyEventDefinitionIdAndCRFId(this.expressionWrapper.getStudyBean(), studyEventDefinition.getId(), crf.getId());
if (eventDefinitionCrf == null || eventDefinitionCrf.getId() == 0)
throw new OpenClinicaSystemException("OCRERR_0034", new String[] { expression });
// throw new
// OpenClinicaSystemException("StudyEventDefinition is Invalid");
}
if (length == 2 && isEventStartDateAndStatusParamExist) {
StudyEventDefinitionBean studyEventDefinition = getStudyEventDefinitionFromExpressionForEventScheduling(expression);
// studyEventDefinition.getOid());
if (studyEventDefinition == null)
throw new OpenClinicaSystemException("OCRERR_0034", new String[] { expression });
}
if (length != 2 && isEventStartDateAndStatusParamExist) {
throw new OpenClinicaSystemException("OCRERR_0034", new String[] { expression });
}
}
use of org.akaza.openclinica.bean.submit.ItemGroupBean in project OpenClinica by OpenClinica.
the class ExpressionService method checkValidityOfItemOrItemGroupOidInCrf.
public String checkValidityOfItemOrItemGroupOidInCrf(String oid, RuleSetBean ruleSet) {
oid = oid.trim();
String[] theOid = oid.split(ESCAPED_SEPERATOR);
if (theOid.length == 2) {
ItemGroupBean itemGroup = getItemGroupDao().findByOid(theOid[0]);
Boolean isItemGroupBePartOfCrfOrNull = ruleSet.getCrfId() != null ? itemGroup.getCrfId().equals(ruleSet.getCrfId()) : true;
if (itemGroup != null && isItemGroupBePartOfCrfOrNull) {
if (ruleSet.getCrfId() != null && itemGroup.getCrfId().equals(ruleSet.getCrfId())) {
return "OK";
}
if (ruleSet.getCrfId() != null && !itemGroup.getCrfId().equals(ruleSet.getCrfId())) {
return oid;
}
ItemBean item = getItemDao().findItemByGroupIdandItemOid(itemGroup.getId(), theOid[1]);
if (item != null) {
return "OK";
}
}
}
if (theOid.length == 1) {
ItemGroupBean itemGroup = getItemGroupDao().findByOid(oid);
if (itemGroup != null) {
if (ruleSet.getCrfId() != null && itemGroup.getCrfId().equals(ruleSet.getCrfId())) {
return "OK";
}
if (ruleSet.getCrfId() != null && !itemGroup.getCrfId().equals(ruleSet.getCrfId())) {
return oid;
}
return "OK";
}
// ItemBean item =
// getItemDao().findItemByGroupIdandItemOid(getItemGroupExpression(ruleSet.getTarget().getValue()).getId(),
// oid);
ArrayList<ItemBean> items = (ArrayList<ItemBean>) getItemDao().findByOid(oid);
if (items == null || items.size() != 0) {
return "OK";
}
}
return oid;
}
Aggregations