List parUseAssociated = new ArrayList();
Iterator parusesIter = paruses.iterator();
while(parusesIter.hasNext()) {
SbiParuse hibParuse = (SbiParuse)parusesIter.next();
Iterator paruseDetsIter = hibParuse.getSbiParuseDets().iterator();
while(paruseDetsIter.hasNext()){
SbiParuseDet hibParuseDet = (SbiParuseDet)paruseDetsIter.next();
if (hibParuseDet.getId().getSbiExtRoles().getExtRoleId().equals(role.getId())){
parUseAssociated.add(hibParuse);
}
}
}
if(parUseAssociated.size() == 1) {
SbiParuse hibParuse = (SbiParuse)parUseAssociated.get(0);
SbiLov sbiLov = hibParuse.getSbiLov();
//if modval is null, then the parameter always has a man_in modality
//force the man_in modality to the parameter
Integer man_in = hibParuse.getManualInput();
//Integer sbiLovId = sbiLov.getLovId();
if(man_in.intValue() == 1){
ModalitiesValue manInModVal = new ModalitiesValue();
manInModVal.setITypeCd("MAN_IN");
manInModVal.setITypeId("37");
parameter.setModalityValue(manInModVal);
}else{
ModalitiesValue modVal = DAOFactory.getModalitiesValueDAO().loadModalitiesValueByID(hibParuse.getSbiLov().getLovId());
modVal.setSelectionType(hibParuse.getSelectionType());
modVal.setMultivalue(hibParuse.getMultivalue() != null && hibParuse.getMultivalue().intValue() > 0);
parameter.setModalityValue(modVal);
}
ParameterUse aParameterUse = DAOFactory.getParameterUseDAO().loadByUseID(hibParuse.getUseId());
parameter.setChecks(aParameterUse.getAssociatedChecks());
} else {
// this part of code wouldn't never be executed because one role can have only one parameteruse
// for each parameter. The control is executed before the load of the object so
// the list would have to contain only one element but if the list contains more than one