Search in sources :

Example 11 with TableFacade

use of org.jmesa.facade.TableFacade in project OpenClinica by OpenClinica.

the class AuditDatabaseServlet method renderAuditDatabaseTable.

private String renderAuditDatabaseTable(List<DatabaseChangeLogBean> databaseChangeLogs) {
    // Collection<StudyRowContainer> items = getStudyRows(studyBeans);
    TableFacade tableFacade = createTableFacade("databaseChangeLogs", request);
    tableFacade.setColumnProperties("id", "author", "fileName", "dataExecuted", "md5Sum", "description", "comments", "tag", "liquibase");
    tableFacade.setItems(databaseChangeLogs);
    // Fix column titles
    HtmlTable table = (HtmlTable) tableFacade.getTable();
    table.setCaption("");
    HtmlRow row = table.getRow();
    HtmlColumn id = row.getColumn("id");
    id.setTitle("Id");
    HtmlColumn author = row.getColumn("author");
    author.setTitle("Author");
    HtmlColumn fileName = row.getColumn("fileName");
    fileName.setTitle("File Name");
    HtmlColumn dataExecuted = row.getColumn("dataExecuted");
    dataExecuted.setTitle("Date Executed");
    dataExecuted.getCellRenderer().setCellEditor(new DateCellEditor("yyyy-MM-dd hh:mm:ss"));
    HtmlColumn md5Sum = row.getColumn("md5Sum");
    md5Sum.setTitle("md5 sum");
    HtmlColumn description = row.getColumn("description");
    description.setTitle("Description");
    HtmlColumn comments = row.getColumn("comments");
    comments.setTitle("Comments");
    HtmlColumn tag = row.getColumn("tag");
    tag.setTitle("Tag");
    HtmlColumn liquibase = row.getColumn("liquibase");
    liquibase.setTitle("Liquibase");
    return tableFacade.render();
}
Also used : HtmlTable(org.jmesa.view.html.component.HtmlTable) TableFacadeFactory.createTableFacade(org.jmesa.facade.TableFacadeFactory.createTableFacade) TableFacade(org.jmesa.facade.TableFacade) HtmlRow(org.jmesa.view.html.component.HtmlRow) DateCellEditor(org.jmesa.view.editor.DateCellEditor) HtmlColumn(org.jmesa.view.html.component.HtmlColumn)

Example 12 with TableFacade

use of org.jmesa.facade.TableFacade in project OpenClinica by OpenClinica.

the class ScheduledJobController method listScheduledJobs.

@RequestMapping("/listCurrentScheduledJobs")
public ModelMap listScheduledJobs(HttpServletRequest request, HttpServletResponse response) throws SchedulerException {
    Locale locale = LocaleResolver.getLocale(request);
    ResourceBundleProvider.updateLocale(locale);
    ModelMap gridMap = new ModelMap();
    String[] triggerNames;
    boolean showMoreLink = false;
    if (request.getParameter("showMoreLink") != null) {
        showMoreLink = Boolean.parseBoolean(request.getParameter("showMoreLink").toString());
    } else {
        showMoreLink = true;
    }
    request.setAttribute("showMoreLink", showMoreLink + "");
    // request.setAttribute("studySubjectId",studySubjectId);
    /*SubjectIdSDVFactory tableFactory = new SubjectIdSDVFactory();
        * @RequestParam("studySubjectId") int studySubjectId,*/
    request.setAttribute("imagePathPrefix", "../");
    ArrayList<String> pageMessages = (ArrayList<String>) request.getAttribute("pageMessages");
    if (pageMessages == null) {
        pageMessages = new ArrayList<String>();
    }
    request.setAttribute("pageMessages", pageMessages);
    List<JobExecutionContext> listCurrentJobs = new ArrayList<JobExecutionContext>();
    listCurrentJobs = scheduler.getCurrentlyExecutingJobs();
    Iterator<JobExecutionContext> itCurrentJobs = listCurrentJobs.iterator();
    List<String> currentJobList = new ArrayList<String>();
    while (itCurrentJobs.hasNext()) {
        JobExecutionContext temp = itCurrentJobs.next();
        currentJobList.add(temp.getTrigger().getJobKey().getName() + temp.getTrigger().getKey().getGroup());
    }
    List<String> triggerGroupNames = scheduler.getTriggerGroupNames();
    String[] triggerGroups = triggerGroupNames.stream().toArray(String[]::new);
    List<SimpleTrigger> simpleTriggers = new ArrayList<SimpleTrigger>();
    int index1 = 0;
    for (String triggerGroup : triggerGroups) {
        logger.debug("Group: " + triggerGroup + " contains the following triggers");
        Set<TriggerKey> triggerKeys = scheduler.getTriggerKeys(GroupMatcher.triggerGroupEquals(triggerGroup));
        triggerNames = triggerKeys.stream().toArray(String[]::new);
        for (String triggerName : triggerNames) {
            Trigger.TriggerState state = scheduler.getTriggerState(TriggerKey.triggerKey(triggerName, triggerGroup));
            logger.debug("- " + triggerName);
            if (state != Trigger.TriggerState.PAUSED) {
                simpleTriggers.add(index1, (SimpleTrigger) scheduler.getTrigger(TriggerKey.triggerKey(triggerName, triggerGroup)));
                index1++;
            }
        }
    }
    List<ScheduledJobs> jobsScheduled = new ArrayList<ScheduledJobs>();
    int index = 0;
    for (SimpleTrigger st : simpleTriggers) {
        boolean isExecuting = currentJobList.contains(st.getJobKey().getName() + st.getJobKey().getGroup());
        ScheduledJobs jobs = new ScheduledJobs();
        ExtractPropertyBean epBean = null;
        if (st.getJobDataMap() != null) {
            epBean = (ExtractPropertyBean) st.getJobDataMap().get(EP_BEAN);
        }
        if (epBean != null) {
            StringBuilder checkbox = new StringBuilder();
            checkbox.append("<input style='margin-right: 5px' type='checkbox'/>");
            StringBuilder actions = new StringBuilder("<table><tr><td>");
            if (isExecuting) {
                actions.append("&nbsp;");
            } else {
                String contextPath = request.getContextPath();
                StringBuilder jsCodeString = new StringBuilder("this.form.method='GET'; this.form.action='").append(contextPath).append("/pages/cancelScheduledJob").append("';").append("this.form.theJobName.value='").append(st.getJobKey().getName()).append("';").append("this.form.theJobGroupName.value='").append(st.getJobKey().getGroup()).append("';").append("this.form.theTriggerName.value='").append(st.getJobKey().getName()).append("';").append("this.form.theTriggerGroupName.value='").append(st.getJobKey().getGroup()).append("';").append("this.form.submit();");
                actions.append("<td><input type=\"submit\" class=\"button\" value=\"Cancel Job\" ").append("name=\"cancelJob\" onclick=\"").append(jsCodeString.toString()).append("\" />");
            }
            actions.append("</td></tr></table>");
            jobs.setCheckbox(checkbox.toString());
            jobs.setDatasetId(epBean.getDatasetName());
            String fireTime = st.getStartTime() != null ? longFormat(locale).format(st.getStartTime()) : "";
            jobs.setFireTime(fireTime);
            if (st.getNextFireTime() != null) {
                jobs.setScheduledFireTime(longFormat(locale).format(st.getNextFireTime()));
            }
            jobs.setExportFileName(epBean.getExportFileName()[0]);
            jobs.setAction(actions.toString());
            jobs.setJobStatus(isExecuting ? "Currently Executing" : "Scheduled");
            jobsScheduled.add(index, jobs);
            index++;
        }
    }
    logger.debug("totalRows" + index);
    request.setAttribute("totalJobs", index);
    request.setAttribute("jobs", jobsScheduled);
    TableFacade facade = scheduledJobTableFactory.createTable(request, response);
    String sdvMatrix = facade.render();
    gridMap.addAttribute(SCHEDULED_TABLE_ATTRIBUTE, sdvMatrix);
    return gridMap;
}
Also used : ModelMap(org.springframework.ui.ModelMap) TriggerBuilder.newTrigger(org.quartz.TriggerBuilder.newTrigger) TableFacade(org.jmesa.facade.TableFacade) ScheduledJobs(org.akaza.openclinica.web.table.scheduledjobs.ScheduledJobs) ExtractPropertyBean(org.akaza.openclinica.bean.extract.ExtractPropertyBean) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 13 with TableFacade

use of org.jmesa.facade.TableFacade in project OpenClinica by OpenClinica.

the class SDVController method renderSubjectsTable.

/*
    Create a JMesa-based table for showing the event CRFs.
    */
private String renderSubjectsTable(List<EventCRFBean> eventCRFBeans, int studySubjectId, HttpServletRequest request) {
    StudySubjectDAO studySubjectDAO = new StudySubjectDAO(dataSource);
    StudySubjectBean subjectBean = (StudySubjectBean) studySubjectDAO.findByPK(studySubjectId);
    Collection<SubjectSDVContainer> items = sdvUtil.getSubjectRows(eventCRFBeans, request);
    //The number of items represents the total number of returned rows
    int totalRowCount = 0;
    if (items != null && items.size() > 0) {
        totalRowCount = items.size();
    }
    TableFacade tableFacade = createTableFacade("sdv", request);
    //set to the total row count
    if (totalRowCount > 1) {
        tableFacade.setMaxRowsIncrements(15, 50, totalRowCount);
    }
    tableFacade.setColumnProperties("studySubjectId", "personId", "secondaryId", "eventName", "eventDate", "enrollmentDate", "subjectStatus", "crfNameVersion", "crfStatus", "lastUpdatedDate", "lastUpdatedBy", "sdvStatusActions");
    tableFacade.setItems(items);
    //Fix column titles
    HtmlTable table = (HtmlTable) tableFacade.getTable();
    //i18n caption; TODO: convert to Spring messages
    ResourceBundle resourceBundle = ResourceBundle.getBundle("org.akaza.openclinica.i18n.words", LocaleResolver.getLocale(request));
    String[] allTitles = { resourceBundle.getString("study_subject_ID"), resourceBundle.getString("person_ID"), resourceBundle.getString("secondary_ID"), resourceBundle.getString("event_name"), resourceBundle.getString("event_date"), resourceBundle.getString("enrollment_date"), resourceBundle.getString("subject_status"), resourceBundle.getString("CRF_name") + " / " + resourceBundle.getString("version"), resourceBundle.getString("CRF_status"), resourceBundle.getString("last_updated_date"), resourceBundle.getString("last_updated_by"), resourceBundle.getString("SDV_status") + " / " + resourceBundle.getString("actions") };
    setTitles(allTitles, table);
    table.getTableRenderer().setWidth("800");
    return tableFacade.render();
}
Also used : HtmlTable(org.jmesa.view.html.component.HtmlTable) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) TableFacadeFactory.createTableFacade(org.jmesa.facade.TableFacadeFactory.createTableFacade) TableFacade(org.jmesa.facade.TableFacade) ResourceBundle(java.util.ResourceBundle) SubjectSDVContainer(org.akaza.openclinica.controller.helper.table.SubjectSDVContainer) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO)

Example 14 with TableFacade

use of org.jmesa.facade.TableFacade in project OpenClinica by OpenClinica.

the class SDVController method viewSubjectAggregateHandler.

@RequestMapping("/viewSubjectAggregate")
public ModelMap viewSubjectAggregateHandler(HttpServletRequest request, HttpServletResponse response, @RequestParam("studyId") int studyId) {
    if (!mayProceed(request)) {
        try {
            response.sendRedirect(request.getContextPath() + "/MainMenu?message=authentication_failed");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    ModelMap gridMap = new ModelMap();
    HttpSession session = request.getSession();
    boolean showMoreLink = false;
    if (session.getAttribute("sSdvRestore") != null && session.getAttribute("sSdvRestore") == "false") {
        session.setAttribute("sSdvRestore", "true");
        showMoreLink = true;
    } else if (request.getParameter("showMoreLink") != null) {
        showMoreLink = Boolean.parseBoolean(request.getParameter("showMoreLink").toString());
    } else if (session.getAttribute("s_sdv_showMoreLink") != null) {
        showMoreLink = Boolean.parseBoolean(session.getAttribute("s_sdv_showMoreLink") + "");
    } else {
        showMoreLink = true;
    }
    request.setAttribute("showMoreLink", showMoreLink + "");
    session.setAttribute("s_sdv_showMoreLink", showMoreLink + "");
    request.setAttribute("studyId", studyId);
    String restore = (String) request.getAttribute("s_sdv_restore");
    restore = restore != null && restore.length() > 0 ? restore : "false";
    request.setAttribute("s_sdv_restore", restore);
    // request.setAttribute("studySubjectId",studySubjectId);
    /*SubjectIdSDVFactory tableFactory = new SubjectIdSDVFactory();
        * @RequestParam("studySubjectId") int studySubjectId,*/
    request.setAttribute("imagePathPrefix", "../");
    ArrayList<String> pageMessages = (ArrayList<String>) request.getAttribute("pageMessages");
    if (pageMessages == null) {
        pageMessages = new ArrayList<String>();
    }
    request.setAttribute("pageMessages", pageMessages);
    sdvFactory.showMoreLink = showMoreLink;
    TableFacade facade = sdvFactory.createTable(request, response);
    String sdvMatrix = facade.render();
    gridMap.addAttribute(SUBJECT_SDV_TABLE_ATTRIBUTE, sdvMatrix);
    return gridMap;
}
Also used : TableFacadeFactory.createTableFacade(org.jmesa.facade.TableFacadeFactory.createTableFacade) TableFacade(org.jmesa.facade.TableFacade) HttpSession(javax.servlet.http.HttpSession) ModelMap(org.springframework.ui.ModelMap) ArrayList(java.util.ArrayList) ParseException(java.text.ParseException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

TableFacade (org.jmesa.facade.TableFacade)14 TableFacadeFactory.createTableFacade (org.jmesa.facade.TableFacadeFactory.createTableFacade)7 HtmlTable (org.jmesa.view.html.component.HtmlTable)6 ResourceBundle (java.util.ResourceBundle)4 HtmlColumn (org.jmesa.view.html.component.HtmlColumn)4 HtmlRow (org.jmesa.view.html.component.HtmlRow)4 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)3 ArrayList (java.util.ArrayList)2 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)2 SDVToolbar (org.akaza.openclinica.controller.helper.table.SDVToolbar)2 SubjectSDVContainer (org.akaza.openclinica.controller.helper.table.SubjectSDVContainer)2 MatcherKey (org.jmesa.core.filter.MatcherKey)2 Limit (org.jmesa.limit.Limit)2 ModelMap (org.springframework.ui.ModelMap)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1