Example usage for org.apache.wicket.extensions.markup.html.repeater.data.table DataTable DataTable

List of usage examples for org.apache.wicket.extensions.markup.html.repeater.data.table DataTable DataTable

Introduction

In this page you can find the example usage for org.apache.wicket.extensions.markup.html.repeater.data.table DataTable DataTable.

Prototype

public DataTable(final String id, final List<? extends IColumn<T, S>> columns,
        final IDataProvider<T> dataProvider, final long rowsPerPage) 

Source Link

Document

Constructor

Usage

From source file:au.org.theark.core.web.component.customfield.SearchResultListPanel.java

License:Open Source License

private void addToolbars(DataView<CustomField> customFieldDataView) {
    List<IColumn<CustomField>> columns = new ArrayList<IColumn<CustomField>>();
    columns.add(new ExportableTextColumn<CustomField>(Model.of("name"), "name"));
    columns.add(new ExportableTextColumn<CustomField>(Model.of("fieldType"), "fieldType.name"));
    columns.add(new ExportableTextColumn<CustomField>(Model.of("description"), "description"));
    columns.add(new ExportableTextColumn<CustomField>(Model.of("fieldLabel"), "fieldLabel"));
    columns.add(new ExportableTextColumn<CustomField>(Model.of("unitType"), "unitType.name"));
    columns.add(new ExportableTextColumn<CustomField>(Model.of("encodedValues"), "encodedValues"));
    columns.add(new ExportableTextColumn<CustomField>(Model.of("minValue"), "minValue"));
    columns.add(new ExportableTextColumn<CustomField>(Model.of("maxValue"), "maxValue"));
    columns.add(new ExportableTextColumn<CustomField>(Model.of("missingValue"), "missingValue"));

    DataTable table = new DataTable("datatable", columns, customFieldDataView.getDataProvider(),
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());
    List<String> headers = new ArrayList<String>(0);
    headers.add("FIELD_NAME");
    headers.add("FIELD_TYPE");
    headers.add("DESCRIPTION");
    headers.add("QUESTION");
    headers.add("UNITS");
    headers.add("ENCODED_VALUES");
    headers.add("MINIMUM_VALUE");
    headers.add("MAXIMUM_VALUE");
    headers.add("MISSING_VALUE");

    String filename = "data_dictionary";
    RepeatingView toolbars = new RepeatingView("toolbars");
    ExportToolbar<String> exportToolBar = new ExportToolbar<String>(table, headers, filename);
    toolbars.add(new Component[] { exportToolBar });
    add(toolbars);//from   ww w . j  a  va 2s  . c  o  m
}

From source file:au.org.theark.core.web.component.customfieldcategory.SearchResultListPanel.java

License:Open Source License

private void addToolbars(DataView<CustomFieldCategory> customFieldCategoryDataView) {
    List<IColumn<CustomFieldCategory>> columns = new ArrayList<IColumn<CustomFieldCategory>>();
    columns.add(new ExportableTextColumn<CustomFieldCategory>(Model.of("name"), "name"));
    columns.add(//from w ww.j a va 2 s.  com
            new ExportableTextColumn<CustomFieldCategory>(Model.of("customFieldType"), "customFieldType.name"));
    columns.add(new ExportableTextColumn<CustomFieldCategory>(Model.of("description"), "description"));
    columns.add(
            new ExportableTextColumn<CustomFieldCategory>(Model.of("parentCategory"), "parentCategory.name"));
    columns.add(new ExportableTextColumn<CustomFieldCategory>(Model.of("orderNumber"), "orderNumber"));

    DataTable table = new DataTable("datatable", columns, customFieldCategoryDataView.getDataProvider(),
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());
    List<String> headers = new ArrayList<String>(0);
    headers.add("FIELD_NAME");
    headers.add("CUSTOM_FIELD_TYPE");
    headers.add("DESCRIPTION");
    headers.add("PARENT_CATEGORY");
    headers.add("ORDER_NUMBER");

    String filename = "data_dictionary";
    RepeatingView toolbars = new RepeatingView("toolbars");
    ExportToolbar<String> exportToolBar = new ExportToolbar<String>(table, headers, filename);
    toolbars.add(new Component[] { exportToolBar });
    add(toolbars);
}

From source file:au.org.theark.lims.web.component.biospecimen.form.BiospecimenListForm.java

License:Open Source License

private void initialiseDataView() {
    dataViewListWMC = new WebMarkupContainer("dataViewListWMC");
    dataViewListWMC.setOutputMarkupId(true);
    // Data provider to paginate resultList
    biospecimenProvider = new ArkDataProvider2<LimsVO, Biospecimen>() {

        private static final long serialVersionUID = 1L;

        public int size() {
            return (int) iLimsService.getBiospecimenCount(criteriaModel.getObject());
        }//from w  w w. jav a  2  s. c o m

        public Iterator<Biospecimen> iterator(int first, int count) {
            List<Biospecimen> biospecimenList = new ArrayList<Biospecimen>();
            if (ArkPermissionHelper.isActionPermitted(au.org.theark.core.Constants.SEARCH)) {
                biospecimenList = iLimsService.searchPageableBiospecimens(criteriaModel.getObject(), first,
                        count);
            }
            return biospecimenList.iterator();
        }
    };
    // Set the criteria into the data provider's model
    biospecimenProvider.setCriteriaModel(cpModel);

    dataView = buildDataView(biospecimenProvider);
    dataView.setItemsPerPage(
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());

    AjaxPagingNavigator pageNavigator = new AjaxPagingNavigator("navigator", dataView) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onAjaxEvent(AjaxRequestTarget target) {
            target.add(dataViewListWMC);
        }
    };
    dataViewListWMC.add(pageNavigator);
    dataViewListWMC.add(dataView);

    List<IColumn<Biospecimen>> columns = new ArrayList<IColumn<Biospecimen>>();
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("BiospecimenUID"), "biospecimenUid"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Study"), "study.name"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("SubjectUID"), "linkSubjectStudy.subjectUID"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("ParentUID"), "parentUid"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Collection"), "bioCollection.name"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Sample Type"), "sampleType.name"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Quantity"), "quantity"));

    DataTable table = new DataTable("datatable", columns, dataView.getDataProvider(),
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());
    List<String> headers = new ArrayList<String>(0);
    headers.add("BiospecimenUID");
    headers.add("Study");
    headers.add("SubjectUID");
    headers.add("ParentUID");
    headers.add("Collection");
    headers.add("Sample Type");
    headers.add("Quantity");

    String filename = "biospecimens";
    RepeatingView toolbars = new RepeatingView("toolbars");
    ExportToolbar<String> exportToolBar = new ExportToolbar<String>(table, headers, filename);
    toolbars.add(new Component[] { exportToolBar });
    dataViewListWMC.add(toolbars);
    add(dataViewListWMC);
}

From source file:au.org.theark.lims.web.component.global.biospecimen.form.BiospecimenListForm.java

License:Open Source License

private void initialiseDataView() {

    Subject currentUser = SecurityUtils.getSubject();
    ArkUser arkUser;/*from w w w.j a  v  a 2s  .co  m*/
    try {
        arkUser = iArkCommonService.getArkUser(currentUser.getPrincipal().toString());
        ArkUserVO arkUserVo = new ArkUserVO();
        arkUserVo.setArkUserEntity(arkUser);
        studyListForUser = iArkCommonService.getStudyListForUser(arkUserVo); //getParentAndChildStudies(sessionStudyId);
    } catch (EntityNotFoundException e) {
        e.printStackTrace();
    }

    dataViewListWMC = new WebMarkupContainer("dataViewListWMC");
    dataViewListWMC.setOutputMarkupId(true);
    // Data provider to paginate resultList
    biospecimenProvider = new ArkDataProvider2<LimsVO, Biospecimen>() {

        private static final long serialVersionUID = 1L;

        public int size() {
            return (int) iLimsService.getBiospecimenCount(criteriaModel.getObject());
        }

        public Iterator<Biospecimen> iterator(int first, int count) {
            List<Biospecimen> biospecimenList = new ArrayList<Biospecimen>();
            if (ArkPermissionHelper.isActionPermitted(au.org.theark.core.Constants.SEARCH)) {
                biospecimenList = iLimsService.searchPageableBiospecimens(criteriaModel.getObject(), first,
                        count);
            }
            return biospecimenList.iterator();
        }
    };
    // Set the criteria into the data provider's model
    biospecimenProvider.setCriteriaModel(cpModel);

    dataView = buildDataView(biospecimenProvider);
    dataView.setItemsPerPage(
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());

    final IModel<String> amountModel = new Model<String>(Integer.toString(biospecimenProvider.size()));
    dataViewListWMC.add(new Label("total", amountModel) {
        private static final long serialVersionUID = 1L;

        protected void onBeforeRender() {
            amountModel.setObject(Integer.toString(biospecimenProvider.size()));
            super.onBeforeRender();
        };
    });

    AjaxPagingNavigator pageNavigator = new AjaxPagingNavigator("navigator", dataView) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onAjaxEvent(AjaxRequestTarget target) {
            target.add(dataViewListWMC);
        }
    };
    dataViewListWMC.add(pageNavigator);
    dataViewListWMC.add(dataView);

    List<IColumn<Biospecimen>> columns = new ArrayList<IColumn<Biospecimen>>();
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("BiospecimenUID"), "biospecimenUid"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Study"), "study.name"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("SubjectUID"), "linkSubjectStudy.subjectUID"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("ParentUID"), "parentUid"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Collection"), "bioCollection.name"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Sample Type"), "sampleType.name"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Quantity"), "quantity"));

    DataTable table = new DataTable("datatable", columns, dataView.getDataProvider(),
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());
    List<String> headers = new ArrayList<String>(0);
    headers.add("BiospecimenUID");
    headers.add("Study");
    headers.add("SubjectUID");
    headers.add("ParentUID");
    headers.add("Collection");
    headers.add("Sample Type");
    headers.add("Quantity");

    String filename = "biospecimens";
    RepeatingView toolbars = new RepeatingView("toolbars");
    ExportToolbar<String> exportToolBar = new ExportToolbar<String>(table, headers, filename);
    toolbars.add(new Component[] { exportToolBar });
    dataViewListWMC.add(toolbars);
    add(dataViewListWMC);
}

From source file:au.org.theark.lims.web.component.subjectlims.lims.biospecimen.form.BiospecimenListForm.java

License:Open Source License

private void initialiseDataView() {
    dataViewListWMC = new WebMarkupContainer("dataViewListWMC");
    dataViewListWMC.setOutputMarkupId(true);
    // Data provider to paginate resultList
    biospecimenProvider = new ArkDataProvider2<LimsVO, Biospecimen>() {

        private static final long serialVersionUID = 1L;

        public int size() {
            return (int) iLimsService.getBiospecimenCount(criteriaModel.getObject());
        }//from w  ww  .j a  va 2  s.  c  o  m

        public Iterator<Biospecimen> iterator(int first, int count) {
            List<Biospecimen> biospecimenList = new ArrayList<Biospecimen>();
            if (ArkPermissionHelper.isActionPermitted(au.org.theark.core.Constants.SEARCH)) {
                biospecimenList = iLimsService.searchPageableBiospecimens(criteriaModel.getObject(), first,
                        count);
            }
            return biospecimenList.iterator();
        }
    };
    // Set the criteria into the data provider's model
    biospecimenProvider.setCriteriaModel(cpModel);

    dataView = buildDataView(biospecimenProvider);
    dataView.setItemsPerPage(
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());

    AjaxPagingNavigator pageNavigator = new AjaxPagingNavigator("navigator", dataView) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onAjaxEvent(AjaxRequestTarget target) {
            target.add(dataViewListWMC);
        }
    };

    dataViewListWMC.add(pageNavigator);
    dataViewListWMC.add(dataView);

    List<IColumn<Biospecimen>> columns = new ArrayList<IColumn<Biospecimen>>();
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("BiospecimenUID"), "biospecimenUid"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Study"), "study.name"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("SubjectUID"), "linkSubjectStudy.subjectUID"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("ParentUID"), "ParentUid"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Collection"), "bioCollection.name"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Sample Type"), "sampleType.name"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Quantity"), "quantity"));

    DataTable table = new DataTable("datatable", columns, dataView.getDataProvider(),
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());
    List<String> headers = new ArrayList<String>(0);
    headers.add("BiospecimenUID");
    headers.add("Study");
    headers.add("SubjectUID");
    headers.add("ParentUID");
    headers.add("Collection");
    headers.add("Sample Type");
    headers.add("Quantity");

    String filename = "biospecimens";
    RepeatingView toolbars = new RepeatingView("toolbars");
    ExportToolbar<String> exportToolBar = new ExportToolbar<String>(table, headers, filename);
    toolbars.add(new Component[] { exportToolBar });
    dataViewListWMC.add(toolbars);

    add(dataViewListWMC);
}

From source file:au.org.theark.phenotypic.web.component.phenodatacategory.SearchResultListPanel.java

License:Open Source License

private void addToolbars(DataView<PhenoDataSetCategory> phenoDataSetCategoryDataView) {
    List<IColumn<PhenoDataSetCategory>> columns = new ArrayList<IColumn<PhenoDataSetCategory>>();
    columns.add(new ExportableTextColumn<PhenoDataSetCategory>(Model.of("name"), "name"));
    columns.add(new ExportableTextColumn<PhenoDataSetCategory>(Model.of("description"), "description"));
    columns.add(/*from   w  w w.j a  v  a 2 s  . c  o  m*/
            new ExportableTextColumn<PhenoDataSetCategory>(Model.of("parentCategory"), "parentCategory.name"));
    columns.add(new ExportableTextColumn<PhenoDataSetCategory>(Model.of("orderNumber"), "orderNumber"));

    DataTable table = new DataTable("datatable", columns, phenoDataSetCategoryDataView.getDataProvider(),
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());

    List<String> headers = new ArrayList<String>(0);
    headers.add("FIELD_NAME");
    headers.add("DESCRIPTION");
    String filename = "pheno_dataset_category";
    RepeatingView toolbars = new RepeatingView("toolbars");
    ExportToolbar<String> exportToolBar = new ExportToolbar<String>(table, headers, filename);
    toolbars.add(new Component[] { exportToolBar });
    add(toolbars);
}

From source file:au.org.theark.phenotypic.web.component.phenodatadictionary.SearchResultListPanel.java

License:Open Source License

private void addToolbars(DataView<PhenoDataSetField> phenoDataSetFieldDataView) {
    List<IColumn<PhenoDataSetField>> columns = new ArrayList<IColumn<PhenoDataSetField>>();
    columns.add(new ExportableTextColumn<PhenoDataSetField>(Model.of("name"), "name"));
    columns.add(new ExportableTextColumn<PhenoDataSetField>(Model.of("fieldType"), "fieldType.name"));
    columns.add(new ExportableTextColumn<PhenoDataSetField>(Model.of("description"), "description"));
    columns.add(new ExportableTextColumn<PhenoDataSetField>(Model.of("fieldLabel"), "fieldLabel"));
    columns.add(new ExportableTextColumn<PhenoDataSetField>(Model.of("unitTypeInText"), "unitTypeInText"));
    columns.add(new ExportableTextColumn<PhenoDataSetField>(Model.of("encodedValues"), "encodedValues"));
    columns.add(new ExportableTextColumn<PhenoDataSetField>(Model.of("minValue"), "minValue"));
    columns.add(new ExportableTextColumn<PhenoDataSetField>(Model.of("maxValue"), "maxValue"));
    columns.add(new ExportableTextColumn<PhenoDataSetField>(Model.of("missingValue"), "missingValue"));
    columns.add(new ExportableTextColumn<PhenoDataSetField>(Model.of("defaultValue"), "defaultValue"));
    columns.add(new ExportableTextColumn<PhenoDataSetField>(Model.of("required"), "required"));

    DataTable table = new DataTable("datatable", columns, phenoDataSetFieldDataView.getDataProvider(),
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());
    List<String> headers = new ArrayList<String>(0);
    headers.add("FIELD_NAME");
    headers.add("FIELD_TYPE");
    headers.add("DESCRIPTION");
    headers.add("QUESTION");
    headers.add("UNITS");
    headers.add("ENCODED_VALUES");
    headers.add("MINIMUM_VALUE");
    headers.add("MAXIMUM_VALUE");
    headers.add("MISSING_VALUE");
    headers.add("DEFAULT_VALUE");
    headers.add("REQUIRED");

    String filename = "pheno_dataset_dictionary";
    RepeatingView toolbars = new RepeatingView("toolbars");
    ExportToolbar<String> exportToolBar = new ExportToolbar<String>(table, headers, filename);
    toolbars.add(new Component[] { exportToolBar });
    add(toolbars);// ww w  .ja v a2  s . co  m
}

From source file:au.org.theark.study.web.component.contact.AddressListPanel.java

License:Open Source License

/**
 * Initialize the data view relevant to phone list.
 *//*  ww w .j a  va2s.  c om*/
private void initialiseDataview() {
    sessionPersonId = (Long) SecurityUtils.getSubject().getSession()
            .getAttribute(au.org.theark.core.Constants.PERSON_CONTEXT_ID);
    /**
     * This is the address provider to the page able view.
     */
    addressProvider = new ArkDataProvider<Address, IStudyService>(studyService) {
        private static final long serialVersionUID = 1L;
        private List<Address> listAddress;
        private List<Address> listAddressForSize;

        public int size() {
            try {
                if (sessionPersonId != null) {
                    person = studyService.getPerson(sessionPersonId);
                    containerForm.getModelObject().getAddressVo().getAddress().setPerson(person);
                    listAddressForSize = studyService.getPersonAddressList(sessionPersonId,
                            containerForm.getModelObject().getAddressVo().getAddress());
                    return listAddressForSize.size();

                } else {
                    return 0;
                }

            } catch (ArkSystemException e) {
                e.printStackTrace();
                return 0;
            } catch (EntityNotFoundException e) {
                e.printStackTrace();
                return 0;
            }
        }

        public Iterator<? extends Address> iterator(int first, int count) {
            listAddress = studyService.pageablePersonAddressList(sessionPersonId,
                    containerForm.getModelObject().getAddressVo().getAddress(), first, count);
            return listAddress.iterator();
        }
    };
    /**
     * This is the address provider with subject uid. for export report.
     */
    addressSubjectProvider = new ArkDataProvider<AddressSubjectVO, IStudyService>(studyService) {
        private static final long serialVersionUID = 1L;
        private List<Address> listAddress;
        private List<Address> listAddressForSize;

        public int size() {
            try {
                if (sessionPersonId != null) {
                    person = studyService.getPerson(sessionPersonId);
                    containerForm.getModelObject().getAddressVo().getAddress().setPerson(person);
                    listAddressForSize = studyService.getPersonAddressList(sessionPersonId,
                            containerForm.getModelObject().getAddressVo().getAddress());
                    return listAddressForSize.size();
                } else {

                    return 0;
                }

            } catch (ArkSystemException e) {
                e.printStackTrace();
                return 0;
            } catch (EntityNotFoundException e) {
                e.printStackTrace();
                return 0;
            }
        }

        public Iterator<? extends AddressSubjectVO> iterator(int first, int count) {
            listAddress = studyService.pageablePersonAddressList(sessionPersonId,
                    containerForm.getModelObject().getAddressVo().getAddress(), first, count);
            List<AddressSubjectVO> addressVoList = new ArrayList<AddressSubjectVO>();
            for (Address address : listAddress) {
                String sessionSubjectUId = SecurityUtils.getSubject().getSession()
                        .getAttribute(au.org.theark.core.Constants.SUBJECTUID).toString();
                addressVoList.add(new AddressSubjectVO(address, sessionSubjectUId));
            }
            return addressVoList.iterator();
        }
    };

    addressProvider.setModel(Model.of(containerForm.getModelObject().getAddressVo().getAddress()));
    dataViewAddress = buildDataView(addressProvider);
    dataViewAddress.setItemsPerPage(
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());
    dataViewAddressSubjectVO = buildDataViewWithSubjectStudyID(addressSubjectProvider);
    AjaxPagingNavigator pageNavigator = new AjaxPagingNavigator("addressNavigator", dataViewAddress);
    add(pageNavigator);

    List<IColumn<AddressSubjectVO>> columns = new ArrayList<IColumn<AddressSubjectVO>>();
    columns.add(new ExportableTextColumn<AddressSubjectVO>(Model.of("Subjetc UID"), "subjectUID"));
    columns.add(new ExportableTextColumn<AddressSubjectVO>(Model.of("Street Address"), "streetAddress"));
    columns.add(new ExportableTextColumn<AddressSubjectVO>(Model.of("City"), "city"));
    columns.add(new ExportableTextColumn<AddressSubjectVO>(Model.of("State"), "state.name"));
    columns.add(new ExportableTextColumn<AddressSubjectVO>(Model.of("Post Code"), "postCode"));
    columns.add(new ExportableTextColumn<AddressSubjectVO>(Model.of("Country"), "country.name"));
    columns.add(new ExportableTextColumn<AddressSubjectVO>(Model.of("Address Type"), "addressType.name"));
    columns.add(new ExportableTextColumn<AddressSubjectVO>(Model.of("DateReceived"), "dateReceived"));
    columns.add(new ExportableTextColumn<AddressSubjectVO>(Model.of("Preferred Mailing Address"),
            "preferredMailingAddress"));

    DataTable table = new DataTable("datatable", columns, dataViewAddressSubjectVO.getDataProvider(),
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());
    List<String> headers = new ArrayList<String>(0);
    headers.add("Subject UID:");
    headers.add("Street Address:");
    headers.add("City:");
    headers.add("State:");
    headers.add("Post Code:");
    headers.add("Country:");
    headers.add("Address Type:");
    headers.add("DateReceived:");
    headers.add("Preferred Mailing Address:");

    String filename = sessionPersonId != null ? String.valueOf(sessionPersonId) + "_addressList"
            : "unknown" + "_addressList";
    RepeatingView toolbars = new RepeatingView("toolbars");
    //Disable the tool bar if session person not exsists.
    if (sessionPersonId == null) {
        toolbars.setEnabled(false);
    } else {
        toolbars.setEnabled(true);
    }
    ExportToolbar<String> exportToolBar = new ExportToolbar<String>(table, headers, filename);
    toolbars.add(new Component[] { exportToolBar });
    add(toolbars);
    add(dataViewAddress);

}

From source file:au.org.theark.study.web.component.contact.PhoneListPanel.java

License:Open Source License

/**
 * Initialize the data view relevant to phone list.
 *///from   ww  w.ja va 2 s.  co m
private void initialiseDataview() {
    dataContainer = new WebMarkupContainer("dataContainer");
    dataContainer.setOutputMarkupId(true);
    sessionPersonId = (Long) SecurityUtils.getSubject().getSession()
            .getAttribute(au.org.theark.core.Constants.PERSON_CONTEXT_ID);

    /**
     * phone Provider for the pageable list.
     */
    phoneProvider = new ArkDataProvider<Phone, IStudyService>(studyService) {
        private static final long serialVersionUID = 1L;
        private List<Phone> listPhoneForSize;
        private List<Phone> listPhone;

        public int size() {
            try {
                if (sessionPersonId != null) {
                    person = studyService.getPerson(sessionPersonId);
                    containerForm.getModelObject().getPhoneVo().getPhone().setPerson(person);
                    listPhoneForSize = studyService.getPersonPhoneList(sessionPersonId,
                            containerForm.getModelObject().getPhoneVo().getPhone());
                    return listPhoneForSize.size();
                } else {
                    return 0;
                }

            } catch (ArkSystemException e) {
                e.printStackTrace();
                return 0;
            } catch (EntityNotFoundException e) {
                e.printStackTrace();
                return 0;
            }
        }

        public Iterator<Phone> iterator(int first, int count) {
            listPhone = studyService.pageablePersonPhoneList(sessionPersonId,
                    containerForm.getModelObject().getPhoneVo().getPhone(), first, count);
            return listPhone.iterator();
        }
    };
    /**
     * Subject phone provider for to include the subject id.
     */
    subjectPhoneProvider = new ArkDataProvider<PhoneSubjectVO, IStudyService>(studyService) {
        private static final long serialVersionUID = 1L;
        private List<Phone> listPhoneForSize;
        private List<Phone> listPhone;

        public int size() {
            try {
                if (sessionPersonId != null) {
                    person = studyService.getPerson(sessionPersonId);
                    containerForm.getModelObject().getPhoneVo().getPhone().setPerson(person);
                    listPhoneForSize = studyService.getPersonPhoneList(sessionPersonId,
                            containerForm.getModelObject().getPhoneVo().getPhone());
                    return listPhoneForSize.size();
                } else {
                    return 0;
                }

            } catch (ArkSystemException e) {
                e.printStackTrace();
                return 0;
            } catch (EntityNotFoundException e) {
                e.printStackTrace();
                return 0;
            }
        }

        public Iterator<PhoneSubjectVO> iterator(int first, int count) {
            listPhone = studyService.pageablePersonPhoneList(sessionPersonId,
                    containerForm.getModelObject().getPhoneVo().getPhone(), first, count);
            List<PhoneSubjectVO> phoneVoList = new ArrayList<PhoneSubjectVO>();
            for (Phone phone : listPhone) {
                String sessionSubjectUId = SecurityUtils.getSubject().getSession()
                        .getAttribute(au.org.theark.core.Constants.SUBJECTUID).toString();
                phoneVoList.add(new PhoneSubjectVO(phone, sessionSubjectUId));
            }
            return phoneVoList.iterator();
        }
    };

    phoneProvider.setModel(Model.of(containerForm.getModelObject().getPhoneVo().getPhone()));
    dataViewPhone = buildDataView(phoneProvider);
    dataViewPhoneSubject = buildDataViewWithStudySubjectID(subjectPhoneProvider);
    AjaxPagingNavigator pageNavigator = new AjaxPagingNavigator("phoneNavigator", dataViewPhone) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onAjaxEvent(AjaxRequestTarget target) {
            target.add(dataContainer);
        }
    };
    dataContainer.add(pageNavigator);

    List<IColumn<PhoneSubjectVO>> exportColumns = new ArrayList<IColumn<PhoneSubjectVO>>();
    exportColumns.add(new ExportableTextColumn<PhoneSubjectVO>(Model.of("Subject UID"), "subjectUID"));
    exportColumns.add(new ExportableTextColumn<PhoneSubjectVO>(Model.of("ID"), "id"));
    exportColumns.add(new ExportableTextColumn<PhoneSubjectVO>(Model.of("Area Code"), "areaCode"));
    exportColumns.add(new ExportableTextColumn<PhoneSubjectVO>(Model.of("Phone Number"), "phoneNumber"));
    exportColumns.add(new ExportableTextColumn<PhoneSubjectVO>(Model.of("Phone Type"), "phone.phoneType.name"));
    exportColumns
            .add(new ExportableTextColumn<PhoneSubjectVO>(Model.of("Phone Status"), "phone.phoneStatus.name"));
    exportColumns.add(new ExportableTextColumn<PhoneSubjectVO>(Model.of("Phone Valid From"), "validFrom"));
    exportColumns.add(new ExportableTextColumn<PhoneSubjectVO>(Model.of("Phone Valid To"), "validTo"));

    DataTable exportTable = new DataTable("datatable", exportColumns, dataViewPhoneSubject.getDataProvider(),
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());
    List<String> headers = new ArrayList<String>(0);
    headers.add("Subject UID:");
    headers.add("ID:");
    headers.add("Area Code:");
    headers.add("Phone Number:");
    headers.add("Phone Type:");
    headers.add("Phone Status:");
    headers.add("Phone Valid From:");
    headers.add("Phone Valid To:");

    String filename = sessionPersonId != null ? String.valueOf(sessionPersonId) + "_phoneNumberList"
            : "unknown" + "_phoneNumberList";
    RepeatingView toolbars = new RepeatingView("toolbars");
    //Disable the tool bar if session person not exsists.
    if (sessionPersonId == null) {
        toolbars.setEnabled(false);
    } else {
        toolbars.setEnabled(true);
    }
    ExportToolbar<String> exportToolBar = new ExportToolbar<String>(exportTable, headers, filename);
    toolbars.add(new Component[] { exportToolBar });
    dataContainer.add(toolbars);
    dataContainer.add(dataViewPhone);
    add(dataContainer);
}

From source file:au.org.theark.study.web.component.global.subject.SubjectContainerPanel.java

License:Open Source License

@SuppressWarnings("unchecked")
protected WebMarkupContainer initialiseSearchResults() {
    searchResultsPanel = new SearchResultListPanel("searchResults", arkContextMarkup, containerForm,
            arkCrudContainerVO, studyNameMarkup, studyLogoMarkup, mainTabs);

    Subject currentUser = SecurityUtils.getSubject();
    ArkUser arkUser;/*from w w w  .  ja v  a  2 s .co  m*/
    try {
        arkUser = iArkCommonService.getArkUser(currentUser.getPrincipal().toString());
        ArkUserVO arkUserVo = new ArkUserVO();
        arkUserVo.setArkUserEntity(arkUser);
        studyListForUser = iArkCommonService.getStudyListForUser(arkUserVo); //getParentAndChildStudies(sessionStudyId);
    } catch (EntityNotFoundException e) {
        e.printStackTrace();
    }

    if (sessionStudyId != null) {
        LinkSubjectStudy linkSubjectStudy = new LinkSubjectStudy();
        linkSubjectStudy.setStudy(study);
        //containerForm.getModelObject().setLinkSubjectStudy(linkSubjectStudy);
    }

    // Data providor to paginate resultList
    subjectProvider = new ArkDataProvider<SubjectVO, IArkCommonService>(iArkCommonService) {

        private static final long serialVersionUID = 1L;

        public int size() {
            return (int) service.getStudySubjectCount(model.getObject());
        }

        public Iterator<SubjectVO> iterator(int first, int count) {
            List<SubjectVO> listSubjects = new ArrayList<SubjectVO>();
            if (isActionPermitted()) {
                listSubjects = iArkCommonService.searchPageableSubjects(model.getObject(), first, count);
            }
            return listSubjects.iterator();
        }
    };

    TextField<OtherID> txtFld = ((TextField<OtherID>) containerForm
            .get("searchContainer:searchComponentPanel:searchForm:otherID"));
    String otherIDSearch = txtFld != null ? txtFld.getValue() : null;
    if (otherIDSearch != null) {
        OtherID o;
        o = new OtherID();
        o.setOtherID(otherIDSearch);
        //         List<OtherID> otherIDs = new ArrayList<OtherID>();
        //         otherIDs.add(o);
        cpModel.getObject().getLinkSubjectStudy().getPerson().getOtherIDs().clear();//setOtherIDs(otherIDs);
        cpModel.getObject().getLinkSubjectStudy().getPerson().getOtherIDs().add(o);
    }

    subjectProvider.setModel(this.cpModel);

    dataView = searchResultsPanel.buildDataView(subjectProvider);
    dataView.setItemsPerPage(
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());

    if (containerForm.getModelObject().getStudyList().isEmpty()) {
        containerForm.getModelObject().setStudyList(studyListForUser);
    }
    IModel<String> amountModel = new Model<String>(Integer.toString(subjectProvider.size()));
    resultsWmc.add(new Label("total", amountModel) {
        private static final long serialVersionUID = 1L;

        protected void onBeforeRender() {
            amountModel.setObject(Integer.toString(subjectProvider.size()));
            super.onBeforeRender();
        };
    });

    PagingNavigator pageNavigator = new PagingNavigator("navigator", dataView);
    resultsWmc.add(pageNavigator);

    List<IColumn<SubjectVO>> columns = new ArrayList<IColumn<SubjectVO>>();
    columns.add(new ExportableTextColumn<SubjectVO>(Model.of("SubjectUID"), "subjectUID"));
    columns.add(new ExportableTextColumn<SubjectVO>(Model.of("Study"), "linkSubjectStudy.study.name"));
    columns.add(new ExportableTextColumn<SubjectVO>(Model.of("Full Name"), "subjectFullName"));
    columns.add(new ExportableTextColumn<SubjectVO>(Model.of("Last Name History"),
            "linkSubjectStudy.person.descriptiveLastNameHistory"));
    columns.add(new ExportableDateColumn<SubjectVO>(Model.of("Date Of Birth"),
            "linkSubjectStudy.person.dateOfBirth", au.org.theark.core.Constants.DD_MM_YYYY));
    columns.add(new ExportableTextColumn<SubjectVO>(Model.of("Vital Status"),
            "linkSubjectStudy.person.vitalStatus.name"));
    columns.add(
            new ExportableTextColumn<SubjectVO>(Model.of("Gender"), "linkSubjectStudy.person.genderType.name"));
    columns.add(new ExportableTextColumn<SubjectVO>(Model.of("Subject Status"),
            "linkSubjectStudy.subjectStatus.name"));
    columns.add(new ExportableTextColumn<SubjectVO>(Model.of("Consent Status"),
            "linkSubjectStudy.consentStatus.name"));
    columns.add(new ExportableTextColumn<SubjectVO>(Model.of("Other IDs"),
            "linkSubjectStudy.person.descriptiveOtherIDs"));

    DataTable table = new DataTable("datatable", columns, dataView.getDataProvider(),
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());
    List<String> headers = new ArrayList<String>(0);
    headers.add("SubjectUID");
    headers.add("Study");
    headers.add("Full Name");
    headers.add("Last Name History");
    headers.add("Date of Birth");
    headers.add("Vital Status");
    headers.add("Gender");
    headers.add("Subject Status");
    headers.add("Consent Status");
    headers.add("Other IDs");

    String filename = "subjects";
    RepeatingView toolbars = new RepeatingView("toolbars");
    ExportToolbar<String> exportToolBar = new ExportToolbar<String>(table, headers, filename);
    toolbars.add(new Component[] { exportToolBar });
    resultsWmc.add(toolbars);

    resultsWmc.add(dataView);
    searchResultsPanel.add(resultsWmc);
    arkCrudContainerVO.getSearchResultPanelContainer().add(searchResultsPanel);
    return arkCrudContainerVO.getSearchResultPanelContainer();
}