use of org.akaza.openclinica.bean.core.EntityBean in project OpenClinica by OpenClinica.
the class Table method showTable.
/**
* @deprecated
*/
@Deprecated
public String showTable() {
if (rows.size() <= 0) {
return "<p><i>There are no " + getEntitiesNamePlural() + " available for display.</i></p>";
}
String table = showHeader();
Iterator rowsIt = rows.iterator();
while (rowsIt.hasNext()) {
EntityBean e = (EntityBean) rowsIt.next();
table += showRow(e);
}
table += showFooter();
return table;
}
use of org.akaza.openclinica.bean.core.EntityBean in project OpenClinica by OpenClinica.
the class Validator method entityExists.
protected boolean entityExists(String fieldName, EntityDAO edao) {
String fieldValue = getFieldValue(fieldName);
if (fieldValue == null) {
return false;
}
try {
int id = Integer.parseInt(fieldValue);
EntityBean e = edao.findByPK(id);
if (!e.isActive()) {
return false;
}
} catch (Exception e) {
return false;
}
return true;
}
use of org.akaza.openclinica.bean.core.EntityBean in project OpenClinica by OpenClinica.
the class OpenClinicaUsernamePasswordAuthenticationFilter method attemptAuthentication.
//~ Methods ========================================================================================================
@Override
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException {
if (postOnly && !request.getMethod().equals("POST")) {
throw new AuthenticationServiceException("Authentication method not supported: " + request.getMethod());
}
String username = obtainUsername(request);
String password = obtainPassword(request);
if (username == null) {
username = "";
}
if (password == null) {
password = "";
}
username = username.trim();
UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(username, password);
// Place the last username attempted into HttpSession for views
HttpSession session = request.getSession(false);
if (session != null || getAllowSessionCreation()) {
request.getSession().setAttribute(SPRING_SECURITY_LAST_USERNAME_KEY, TextEscapeUtils.escapeEntities(username));
}
// Allow subclasses to set the "details" property
setDetails(request, authRequest);
Authentication authentication = null;
UserAccountBean userAccountBean = null;
ResourceBundleProvider.updateLocale(new Locale("en_US"));
try {
EntityBean eb = getUserAccountDao().findByUserName(username);
userAccountBean = eb.getId() != 0 ? (UserAccountBean) eb : null;
authentication = this.getAuthenticationManager().authenticate(authRequest);
auditUserLogin(username, LoginStatus.SUCCESSFUL_LOGIN, userAccountBean);
resetLockCounter(username, LoginStatus.SUCCESSFUL_LOGIN, userAccountBean);
} catch (LockedException le) {
auditUserLogin(username, LoginStatus.FAILED_LOGIN_LOCKED, userAccountBean);
throw le;
} catch (BadCredentialsException au) {
auditUserLogin(username, LoginStatus.FAILED_LOGIN, userAccountBean);
lockAccount(username, LoginStatus.FAILED_LOGIN, userAccountBean);
throw au;
} catch (AuthenticationException ae) {
throw ae;
}
return authentication;
}
use of org.akaza.openclinica.bean.core.EntityBean in project OpenClinica by OpenClinica.
the class FormProcessor method getEntity.
/**
* @param fieldName
* The name of the HTML form field which holds the Entity's
* primary key.
* @param edao
* The data source for the Entity.
* @return The Entity whose primary key is specified by fieldName, and which
* can be retrieved by edao.
* @throws OpenClinicaException
*/
public EntityBean getEntity(String fieldName, EntityDAO edao) throws OpenClinicaException {
int id = getInt(fieldName);
EntityBean result = edao.findByPK(id);
return result;
}
use of org.akaza.openclinica.bean.core.EntityBean in project OpenClinica by OpenClinica.
the class FindStudyEventServlet method processRequest.
/*
* (non-Javadoc)
*
* @see org.akaza.openclinica.control.core.SecureController#processRequest()
*/
@Override
protected void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
String browseBy = fp.getString(INPUT_BROWSEBY);
int id = fp.getInt(INPUT_ID);
// User is going to Step 1
if (browseBy.equals("")) {
forwardPage(Page.FIND_STUDY_EVENTS_STEP1);
} else if (invalidBrowseBy(browseBy)) {
addPageMessage(respage.getString("must_browse_study_events_by_subject_or_event_definition"));
forwardPage(Page.FIND_STUDY_EVENTS_STEP1);
} else // User was at Step 1, is going to Step 2
if (id <= 0) {
int pageNum = fp.getInt(INPUT_PAGENUM);
ArrayList allDisplayEntities = new ArrayList();
if (browseBy.equals(ARG_BROWSEBY_SUBJECT)) {
StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
allDisplayEntities = ssdao.findAllWithStudyEvent(currentStudy);
} else {
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
allDisplayEntities = seddao.findAllWithStudyEvent(currentStudy);
}
if (pageNum < 0) {
pageNum = 0;
} else if (pageNum > allDisplayEntities.size() / NUM_ENTITIES_PER_PAGE) {
pageNum = allDisplayEntities.size() / NUM_ENTITIES_PER_PAGE;
}
int firstIndex = NUM_ENTITIES_PER_PAGE * pageNum;
int lastIndex = NUM_ENTITIES_PER_PAGE * (pageNum + 1);
if (allDisplayEntities.size() > lastIndex) {
request.setAttribute(BEAN_DISPLAY_NEXT_PAGE, ARG_DISPLAY_NEXT_PAGE_YES);
} else {
request.setAttribute(BEAN_DISPLAY_NEXT_PAGE, ARG_DISPLAY_NEXT_PAGE_NO);
lastIndex = allDisplayEntities.size();
}
List displayEntities = allDisplayEntities.subList(firstIndex, lastIndex);
request.setAttribute(INPUT_BROWSEBY, browseBy);
request.setAttribute(BEAN_DISPLAY_ENTITIES, displayEntities);
request.setAttribute(INPUT_PAGENUM, new Integer(pageNum));
forwardPage(Page.FIND_STUDY_EVENTS_STEP2);
} else // User is coming from Step 2, is going to Step 3
{
StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
ArrayList events = new ArrayList();
EntityBean entityWithStudyEvents;
if (browseBy.equals(ARG_BROWSEBY_SUBJECT)) {
events = sedao.findAllByStudyAndStudySubjectId(currentStudy, id);
StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
entityWithStudyEvents = ssdao.findByPK(id);
} else {
events = sedao.findAllByStudyAndEventDefinitionId(currentStudy, id);
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
entityWithStudyEvents = seddao.findByPK(id);
}
request.setAttribute(INPUT_BROWSEBY, browseBy);
request.setAttribute(BEAN_DISPLAY_ENTITIES, events);
request.setAttribute(BEAN_ENTITY_WITH_STUDY_EVENTS, entityWithStudyEvents);
forwardPage(Page.FIND_STUDY_EVENTS_STEP3);
}
}
Aggregations