Example usage for org.apache.wicket.markup.repeater RepeatingView RepeatingView

List of usage examples for org.apache.wicket.markup.repeater RepeatingView RepeatingView

Introduction

In this page you can find the example usage for org.apache.wicket.markup.repeater RepeatingView RepeatingView.

Prototype

public RepeatingView(String id) 

Source Link

Usage

From source file:au.com.scds.isis.viewer.wicket.ui.components.entity.properties.MyEntityPropertiesForm.java

License:Apache License

private boolean addPropertiesInColumn(MarkupContainer markupContainer, MemberGroupLayoutHint hint,
        ColumnSpans columnSpans) {/*from w  w  w .  j  a  v a  2 s.  c  o m*/
    final int span = hint.from(columnSpans);

    final EntityModel entityModel = (EntityModel) getModel();
    final ObjectAdapter adapter = entityModel.getObject();
    final ObjectSpecification objSpec = adapter.getSpecification();

    final List<ObjectAssociation> associations = visibleProperties(adapter, objSpec, Where.OBJECT_FORMS);

    final RepeatingView memberGroupRv = new RepeatingView(ID_MEMBER_GROUP);
    markupContainer.add(memberGroupRv);

    Map<String, List<ObjectAssociation>> associationsByGroup = ObjectAssociation.Util
            .groupByMemberOrderName(associations);

    final List<String> groupNames = ObjectSpecifications.orderByMemberGroups(objSpec,
            associationsByGroup.keySet(), hint);
    //TODO remove      System.out.println(">>>" + groupNames.toString());

    for (String groupName : groupNames) {
        final List<ObjectAssociation> associationsInGroup = associationsByGroup.get(groupName);
        if (associationsInGroup == null) {
            continue;
        }

        final WebMarkupContainer memberGroupRvContainer = new WebMarkupContainer(memberGroupRv.newChildId());
        memberGroupRv.add(memberGroupRvContainer);
        memberGroupRvContainer.add(new Label(ID_MEMBER_GROUP_NAME, groupName));

        final List<LinkAndLabel> memberGroupActions = Lists.newArrayList();

        final RepeatingView propertyRv = new RepeatingView(ID_PROPERTIES);
        memberGroupRvContainer.add(propertyRv);

        @SuppressWarnings("unused")
        Component component;
        for (final ObjectAssociation association : associationsInGroup) {
            final WebMarkupContainer propertyRvContainer = new UiHintPathSignificantWebMarkupContainer(
                    propertyRv.newChildId());
            propertyRv.add(propertyRvContainer);

            addPropertyToForm(entityModel, (OneToOneAssociation) association, propertyRvContainer,
                    memberGroupActions);
        }

        final List<LinkAndLabel> actionsPanel = LinkAndLabel.positioned(memberGroupActions,
                ActionLayout.Position.PANEL);
        final List<LinkAndLabel> actionsPanelDropDown = LinkAndLabel.positioned(memberGroupActions,
                ActionLayout.Position.PANEL_DROPDOWN);

        AdditionalLinksPanel.addAdditionalLinks(memberGroupRvContainer, ID_ASSOCIATED_ACTION_LINKS_PANEL,
                actionsPanel, AdditionalLinksPanel.Style.INLINE_LIST);
        AdditionalLinksPanel.addAdditionalLinks(memberGroupRvContainer,
                ID_ASSOCIATED_ACTION_LINKS_PANEL_DROPDOWN, actionsPanelDropDown,
                AdditionalLinksPanel.Style.DROPDOWN);
    }

    addClassForSpan(markupContainer, span);
    return !groupNames.isEmpty();
}

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 w  ww  . j a  v  a 2 s  .c om
}

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 v a 2 s  . c  om*/
            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());
        }/* w  ww . j a  v a  2s .com*/

        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 ww  . j av  a  2  s. c om
    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());
        }/*w  w  w .  ja  va  2 s.  co 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(// w  w  w .ja 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  . j  ava 2  s . c o  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 av  a  2s  . 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  .j av a  2  s  . com
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);
}