Search in sources :

Example 11 with EntityBean

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;
}
Also used : EntityBean(org.akaza.openclinica.bean.core.EntityBean) Iterator(java.util.Iterator)

Example 12 with EntityBean

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;
}
Also used : EntityBean(org.akaza.openclinica.bean.core.EntityBean) AuditableEntityBean(org.akaza.openclinica.bean.core.AuditableEntityBean) ParseException(java.text.ParseException) PatternSyntaxException(java.util.regex.PatternSyntaxException)

Example 13 with EntityBean

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;
}
Also used : Locale(java.util.Locale) LockedException(org.springframework.security.authentication.LockedException) AuthenticationException(org.springframework.security.core.AuthenticationException) HttpSession(javax.servlet.http.HttpSession) Authentication(org.springframework.security.core.Authentication) EntityBean(org.akaza.openclinica.bean.core.EntityBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) BadCredentialsException(org.springframework.security.authentication.BadCredentialsException) AuthenticationServiceException(org.springframework.security.authentication.AuthenticationServiceException)

Example 14 with EntityBean

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;
}
Also used : EntityBean(org.akaza.openclinica.bean.core.EntityBean)

Example 15 with EntityBean

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);
    }
}
Also used : StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) EntityBean(org.akaza.openclinica.bean.core.EntityBean) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO)

Aggregations

EntityBean (org.akaza.openclinica.bean.core.EntityBean)20 HashMap (java.util.HashMap)10 ArrayList (java.util.ArrayList)7 Iterator (java.util.Iterator)7 AuditableEntityBean (org.akaza.openclinica.bean.core.AuditableEntityBean)4 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)4 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)4 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)4 Date (java.util.Date)3 Map (java.util.Map)3 Set (java.util.Set)3 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)3 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)3 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)3 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)3 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)3 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)3 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)3 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)3 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)2