Example usage for org.apache.wicket.markup.repeater.data DataView DataView

List of usage examples for org.apache.wicket.markup.repeater.data DataView DataView

Introduction

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

Prototype

protected DataView(String id, IDataProvider<T> dataProvider) 

Source Link

Usage

From source file:au.org.theark.phenotypic.web.component.phenodataentry.form.PhenoCollectionListForm.java

License:Open Source License

/**
 * /*from ww  w  .  j  a v a 2  s  .com*/
 * @param iModel
 * @return the pageableListView of PhenoCollection
 */
public DataView<PhenoDataSetCollection> buildDataView(
        ArkDataProvider2<PhenoDataCollectionVO, PhenoDataSetCollection> PhenoCollectionProvider) {

    DataView<PhenoDataSetCollection> PhenoCollectionDataView = new DataView<PhenoDataSetCollection>(
            "PhenoDataSetCollectionList", PhenoCollectionProvider) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final Item<PhenoDataSetCollection> item) {
            item.setOutputMarkupId(true);
            // DO NOT store the item.getModelObject! Checking it is ok...
            final PhenoDataSetCollection PhenoCollection = item.getModelObject();

            idLbl = new Label("phenoDataSetCollection.id", String.valueOf(PhenoCollection.getId()));
            questionnaireLbl = new Label("phenoDataSetCollection.questionnaire",
                    PhenoCollection.getQuestionnaire().getName());
            ArkBusyAjaxLink link = new ArkBusyAjaxLink("link") {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    PhenoDataSetCollection phenoDataSetCollection = (PhenoDataSetCollection) (getParent()
                            .getDefaultModelObject());
                    CompoundPropertyModel<PhenoDataCollectionVO> newModel = new CompoundPropertyModel<PhenoDataCollectionVO>(
                            new PhenoDataCollectionVO());
                    newModel.getObject().setPhenoDataSetCollection(phenoDataSetCollection);
                    showModalWindow(target, newModel);
                }
            };
            link.add(questionnaireLbl);

            //            nameLbl = new Label("PhenoCollection.name", PhenoCollection.getName());
            descriptionLbl = new Label("phenoDataSetCollection.description", PhenoCollection.getDescription());
            statusLbl = new Label("phenoDataSetCollection.status", PhenoCollection.getStatus().getName());

            SimpleDateFormat simpleDateFormat = new SimpleDateFormat(au.org.theark.core.Constants.DD_MM_YYYY);

            recordDateLbl = new Label("phenoDataSetCollection.recordDate",
                    simpleDateFormat.format(PhenoCollection.getRecordDate()));

            if (PhenoCollection.getReviewedDate() == null) {
                reviewedDateLbl = new Label("phenoDataSetCollection.reviewedDate", "");
            } else {
                reviewedDateLbl = new Label("phenoDataSetCollection.reviewedDate",
                        simpleDateFormat.format(PhenoCollection.getReviewedDate()));
            }

            item.add(idLbl);
            item.add(link);
            //            item.add(nameLbl);
            item.add(descriptionLbl);
            item.add(statusLbl);
            item.add(recordDateLbl);
            item.add(reviewedDateLbl);
            item.add(new AttributeModifier("class", new AbstractReadOnlyModel() {

                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? "even" : "odd";
                }
            }));
        }

    };

    return PhenoCollectionDataView;
}

From source file:au.org.theark.registry.web.component.invoice.ProcessResultListPanel.java

License:Open Source License

@SuppressWarnings("serial")
public DataView<Process> buildDataView(ArkDataProvider<Process, IArkCommonService> subjectProvider) {

    DataView<Process> dataView = new DataView<Process>(Constants.RESULT_LIST, subjectProvider) {

        @Override/*from  w  w w  .  j a v  a 2 s. c om*/
        protected void populateItem(final Item<Process> item) {
            Process process = item.getModelObject();

            if (process != null && process.getId() != null) {
                item.add(new Label("id", process.getId().toString()));
            } else {
                item.add(new Label("id", ""));
            }

            item.add(buildLink(item.getModelObject()));
            //item.add(new Label("name", item.getModelObject().getName()));

            if (process != null && process.getDescription() != null) {
                item.add(new Label("description", process.getDescription()));
            } else {
                item.add(new Label("description", ""));
            }

            if (process != null && process.getStartTime() != null) {
                item.add(new Label("startTime", process.getStartTime().toString()));
            } else {
                item.add(new Label("startTime", ""));
            }

            if (process != null && process.getEndTime() != null) {
                item.add(new Label("endTime", process.getEndTime().toString()));
            } else {
                item.add(new Label("endTime", ""));
            }

            if (process != null && process.getCommand() != null) {
                item.add(new Label("command", process.getCommand().getName()));
            } else {
                item.add(new Label("command", ""));
            }

            //            List<Command> commandList = iArkCommonService.getCommands();
            //            ChoiceRenderer<Command> defaultChoiceRenderer = new ChoiceRenderer<Command>(Constants.NAME, Constants.ID);
            //            DropDownChoice<Command> commandChoice = new DropDownChoice<Command>("command", commandList, defaultChoiceRenderer);
            //            item.add(commandChoice);

            item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() {
                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD;
                }
            }));
        }
    };
    return dataView;
}

From source file:au.org.theark.registry.web.component.invoice.SearchResultListPanel.java

License:Open Source License

@SuppressWarnings("serial")
public DataView<Pipeline> buildDataView(ArkDataProvider<Pipeline, IArkCommonService> subjectProvider) {

    DataView<Pipeline> studyCompDataView = new DataView<Pipeline>(Constants.RESULT_LIST, subjectProvider) {

        @Override/*from   w  w  w.  j a v  a  2 s.c  o m*/
        protected void populateItem(final Item<Pipeline> item) {
            Pipeline pipeline = item.getModelObject();

            if (pipeline != null && pipeline.getId() != null) {
                item.add(new Label("id", pipeline.getId().toString()));
            } else {
                item.add(new Label("id", ""));
            }

            item.add(buildLink(item.getModelObject()));
            //item.add(new Label("name", item.getModelObject().getName()));

            if (pipeline != null && pipeline.getDescription() != null) {
                item.add(new Label("description", pipeline.getDescription()));
            } else {
                item.add(new Label("description", ""));
            }

            item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() {
                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD;
                }
            }));
        }
    };
    return studyCompDataView;
}

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

License:Open Source License

/**
 * Build the data view for display and navigate purposes.
 * //from  w w w.j a  v  a2s .co  m
 * @param addressProvider
 * @return
 */
private DataView<Address> buildDataView(ArkDataProvider<Address, IStudyService> addressProvider) {

    DataView<Address> adressListDataView = new DataView<Address>("addressList", addressProvider) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final Item<Address> item) {

            Address address = item.getModelObject();
            item.add(buildLink(address));

            if (address.getCity() != null) {
                item.add(new Label("city", address.getCity()));
            } else {
                item.add(new Label("city", ""));
            }

            if (address.getState() != null && address.getState().getName() != null) {
                item.add(new Label("state.name", address.getState().getName()));// TODO things like this might almost need to be constants
            } else {
                item.add(new Label("state.name",
                        (address.getOtherState() != null && !address.getOtherState().isEmpty())
                                ? ("other: " + address.getOtherState())
                                : "not defined"));
            }

            if (address.getPostCode() != null) {
                item.add(new Label("postCode", address.getPostCode()));
            } else {
                item.add(new Label("postCode", ""));
            }

            if (address.getCountry() != null && address.getCountry().getName() != null) {
                item.add(new Label("country.name", address.getCountry().getName()));
            } else {
                item.add(new Label("country.name", ""));
            }

            if (address.getAddressType() != null && address.getAddressType().getName() != null) {
                item.add(new Label("addressType.name", address.getAddressType().getName()));
            } else {
                item.add(new Label("addressType.name", ""));
            }

            if (address.getDateReceived() != null) {
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat(
                        au.org.theark.core.Constants.DD_MM_YYYY);
                String dateReceived = "";
                dateReceived = simpleDateFormat.format(address.getDateReceived());
                item.add(new Label("address.dateReceived", dateReceived));
            } else {
                item.add(new Label("address.dateReceived", ""));
            }

            if (address.getPreferredMailingAddress() != null && address.getPreferredMailingAddress() == true) {
                item.add(new ContextImage("address.preferredMailingAddress",
                        new Model<String>("images/icons/tick.png")));
            } else {
                item.add(new Label("address.preferredMailingAddress", ""));
            }

            item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {
                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? "even" : "odd";
                }
            }));

        }
    };

    return adressListDataView;
}

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

License:Open Source License

/**
 * Build the data view for export purposes with subject id.
 * /*from   w w w  .j a  v a  2s  .  com*/
 * @param addressProvider
 * @return
 */
private DataView<AddressSubjectVO> buildDataViewWithSubjectStudyID(
        ArkDataProvider<AddressSubjectVO, IStudyService> addressProvider) {

    DataView<AddressSubjectVO> addressListDataView = new DataView<AddressSubjectVO>("addressList",
            addressProvider) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final Item<AddressSubjectVO> item) {

            AddressSubjectVO addressSubjectVO = item.getModelObject();
            // item.add(buildLink(address));

            if (addressSubjectVO.getSubjectUID() != null) {
                item.add(new Label("subjectUID", addressSubjectVO.getSubjectUID()));
            } else {
                item.add(new Label("subjectUID", ""));
            }
            if (addressSubjectVO.getStreetAddress() != null) {
                item.add(new Label("streetAddress", addressSubjectVO.getStreetAddress()));
            } else {
                item.add(new Label("streetAddress", ""));
            }
            if (addressSubjectVO.getCity() != null) {
                item.add(new Label("city", addressSubjectVO.getCity()));
            } else {
                item.add(new Label("city", ""));
            }

            if (addressSubjectVO.getState() != null && addressSubjectVO.getState().getName() != null) {
                item.add(new Label("state.name", addressSubjectVO.getState().getName()));// TODO things like this might almost need to be constants
            } else {
                item.add(new Label("state.name",
                        (addressSubjectVO.getOtherState() != null
                                && !addressSubjectVO.getOtherState().isEmpty())
                                        ? ("other: " + addressSubjectVO.getOtherState())
                                        : "not defined"));
            }

            if (addressSubjectVO.getPostCode() != null) {
                item.add(new Label("postCode", addressSubjectVO.getPostCode()));
            } else {
                item.add(new Label("postCode", ""));
            }

            if (addressSubjectVO.getCountry() != null && addressSubjectVO.getCountry().getName() != null) {
                item.add(new Label("country.name", addressSubjectVO.getCountry().getName()));
            } else {
                item.add(new Label("country.name", ""));
            }

            if (addressSubjectVO.getAddressType() != null
                    && addressSubjectVO.getAddressType().getName() != null) {
                item.add(new Label("addressType.name", addressSubjectVO.getAddressType().getName()));
            } else {
                item.add(new Label("addressType.name", ""));
            }

            if (addressSubjectVO.getDateReceived() != null) {
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat(
                        au.org.theark.core.Constants.DD_MM_YYYY);
                String dateReceived = "";
                dateReceived = simpleDateFormat.format(addressSubjectVO.getDateReceived());
                item.add(new Label("address.dateReceived", dateReceived));
            } else {
                item.add(new Label("address.dateReceived", ""));
            }

            if (addressSubjectVO.getPreferredMailingAddress() != null
                    && addressSubjectVO.getPreferredMailingAddress() == true) {
                item.add(new ContextImage("address.preferredMailingAddress",
                        new Model<String>("images/icons/tick.png")));
            } else {
                item.add(new Label("address.preferredMailingAddress", ""));
            }

            item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {
                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? "even" : "odd";
                }
            }));

        }
    };
    return addressListDataView;
}

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

License:Open Source License

public DataView<SubjectVO> buildDataView(ArkDataProvider<SubjectVO, IArkCommonService> subjectProvider) {

    DataView<SubjectVO> studyCompDataView = new DataView<SubjectVO>("subjectList", subjectProvider) {

        @Override/*from ww w. j ava 2s .c o  m*/
        protected void populateItem(final Item<SubjectVO> item) {
            LinkSubjectStudy subject = item.getModelObject().getLinkSubjectStudy();
            item.add(buildLink(item.getModelObject()));
            item.add(new Label("study", item.getModelObject().getLinkSubjectStudy().getStudy().getName()));
            item.add(new Label(Constants.SUBJECT_FULL_NAME, item.getModelObject().getSubjectFullName()));
            /*
                        if (subject != null && subject.getPerson() != null && subject.getPerson().getPreferredName() != null) {
                           item.add(new Label("linkSubjectStudy.person.preferredName", subject.getPerson().getPreferredName()));
                        }
                        else {
                           item.add(new Label("linkSubjectStudy.person.preferredName", ""));
                        }
               */
            List<PersonLastnameHistory> lastnameHistory = (List<PersonLastnameHistory>) iArkCommonService
                    .getPersonLastNameHistory(subject.getPerson());
            String lastNameString = "";
            if (!lastnameHistory.isEmpty()) {
                lastNameString = lastnameHistory.get(0).getLastName();
                for (int i = 1; i < lastnameHistory.size(); i++) {
                    lastNameString += ", " + lastnameHistory.get(i).getLastName();
                }
            }

            if (subject != null && subject.getPerson() != null
                    && subject.getPerson().getPersonLastnameHistory() != null && !lastNameString.isEmpty()) {
                item.add(new Label("linkSubjectStudy.person.previouslastnamehistory.lastname", lastNameString));
            } else {
                item.add(new Label("linkSubjectStudy.person.previouslastnamehistory.lastname", ""));
            }

            item.add(new Label("linkSubjectStudy.person.genderType.name",
                    subject.getPerson().getGenderType().getName()));

            SimpleDateFormat simpleDateFormat = new SimpleDateFormat(au.org.theark.core.Constants.DD_MM_YYYY);
            String dateOfBirth = "";
            if (subject != null && subject.getPerson() != null
                    && subject.getPerson().getDateOfBirth() != null) {
                dateOfBirth = simpleDateFormat.format(subject.getPerson().getDateOfBirth());
                item.add(new Label("linkSubjectStudy.person.dateOfBirth", dateOfBirth));
            } else {
                item.add(new Label("linkSubjectStudy.person.dateOfBirth", ""));
            }

            item.add(new Label("linkSubjectStudy.person.vitalStatus.name",
                    subject.getPerson().getVitalStatus().getName()));

            item.add(new Label("linkSubjectStudy.subjectStatus.name", subject.getSubjectStatus().getName()));

            if (subject.getConsentStatus() != null) {
                item.add(
                        new Label("linkSubjectStudy.consentStatus.name", subject.getConsentStatus().getName()));
            } else {
                item.add(new Label("linkSubjectStudy.consentStatus.name", ""));
            }

            List<OtherID> otherIDs = iArkCommonService.getOtherIDs(subject.getPerson());
            String otherIDstring = "";
            for (OtherID o : otherIDs) {
                otherIDstring += o.getOtherID_Source() + ": " + o.getOtherID() + "\n";
            }
            if (!otherIDs.isEmpty()) {
                item.add(new MultiLineLabel("linkSubjectStudy.person.otherIDs.otherID", otherIDstring));
            } else {
                item.add(new Label("linkSubjectStudy.person.otherIDs.otherID", ""));
            }

            item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() {
                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD;
                }
            }));
        }
    };
    return studyCompDataView;
}

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

License:Open Source License

public DataView<SubjectVO> buildDataView(ArkDataProvider<SubjectVO, IArkCommonService> subjectProvider,
        final AbstractDetailModalWindow modalWindow, final List<RelationshipVo> relatives,
        final FeedbackPanel feedbackPanel) {

    DataView<SubjectVO> studyCompDataView = new DataView<SubjectVO>("subjectList", subjectProvider) {

        @Override/*from   ww  w .  ja  v a  2  s .c om*/
        protected void populateItem(final Item<SubjectVO> item) {
            LinkSubjectStudy subject = item.getModelObject().getLinkSubjectStudy();
            item.add(buildLink(item, modalWindow, relatives, feedbackPanel));
            item.add(new Label(Constants.SUBJECT_FULL_NAME, item.getModelObject().getSubjectFullName()));
            /*
                        if (subject != null && subject.getPerson() != null && subject.getPerson().getPreferredName() != null) {
                           item.add(new Label("linkSubjectStudy.person.preferredName", subject.getPerson().getPreferredName()));
                        }
                        else {
                           item.add(new Label("linkSubjectStudy.person.preferredName", ""));
                        }
            */
            List<PersonLastnameHistory> lastnameHistory = (List<PersonLastnameHistory>) iArkCommonService
                    .getPersonLastNameHistory(subject.getPerson());
            String lastNameString = "";
            if (!lastnameHistory.isEmpty()) {
                lastNameString = lastnameHistory.get(0).getLastName();
                for (int i = 1; i < lastnameHistory.size(); i++) {
                    lastNameString += ", " + lastnameHistory.get(i).getLastName();
                }
            }

            if (subject != null && subject.getPerson() != null
                    && subject.getPerson().getPersonLastnameHistory() != null && !lastNameString.isEmpty()) {
                item.add(new Label("linkSubjectStudy.person.previouslastnamehistory.lastname", lastNameString));
            } else {
                item.add(new Label("linkSubjectStudy.person.previouslastnamehistory.lastname", ""));
            }

            item.add(new Label("linkSubjectStudy.person.genderType.name",
                    subject.getPerson().getGenderType().getName()));

            SimpleDateFormat simpleDateFormat = new SimpleDateFormat(au.org.theark.core.Constants.DD_MM_YYYY);
            String dateOfBirth = "";
            if (subject != null && subject.getPerson() != null
                    && subject.getPerson().getDateOfBirth() != null) {
                dateOfBirth = simpleDateFormat.format(subject.getPerson().getDateOfBirth());
                item.add(new Label("linkSubjectStudy.person.dateOfBirth", dateOfBirth));
            } else {
                item.add(new Label("linkSubjectStudy.person.dateOfBirth", ""));
            }

            item.add(new Label("linkSubjectStudy.person.vitalStatus.name",
                    subject.getPerson().getVitalStatus().getName()));

            item.add(new Label("linkSubjectStudy.subjectStatus.name", subject.getSubjectStatus().getName()));

            if (subject.getConsentStatus() != null) {
                item.add(
                        new Label("linkSubjectStudy.consentStatus.name", subject.getConsentStatus().getName()));
            } else {
                item.add(new Label("linkSubjectStudy.consentStatus.name", ""));
            }

            item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() {
                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD;
                }
            }));

            List<OtherID> otherIDs = iArkCommonService.getOtherIDs(subject.getPerson());
            String otherIDstring = "";
            for (OtherID o : otherIDs) {
                otherIDstring += o.getOtherID_Source() + ": " + o.getOtherID() + "\n";
            }
            if (!otherIDs.isEmpty()) {
                item.add(new MultiLineLabel("linkSubjectStudy.person.otherIDs.otherID", otherIDstring));
            } else {
                item.add(new Label("linkSubjectStudy.person.otherIDs.otherID", ""));
            }
        }
    };
    return studyCompDataView;
}

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

License:Open Source License

public DataView<SubjectVO> buildDataView(ArkDataProvider<SubjectVO, IArkCommonService> subjectProvider) {

    DataView<SubjectVO> studyCompDataView = new DataView<SubjectVO>("subjectList", subjectProvider) {

        @Override/*from  w w  w.  j  a v  a 2s . co  m*/
        protected void populateItem(final Item<SubjectVO> item) {
            LinkSubjectStudy subject = item.getModelObject().getLinkSubjectStudy();
            item.add(buildLink(item.getModelObject()));
            item.add(new Label(Constants.SUBJECT_FULL_NAME, item.getModelObject().getSubjectFullName()));
            /*
             * if (subject != null && subject.getPerson() != null &&
             * subject.getPerson().getPreferredName() != null) {
             * item.add(new Label("linkSubjectStudy.person.preferredName",
             * subject.getPerson().getPreferredName())); } else {
             * item.add(new Label("linkSubjectStudy.person.preferredName",
             * "")); }
             */
            List<PersonLastnameHistory> lastnameHistory = (List<PersonLastnameHistory>) iArkCommonService
                    .getPersonLastNameHistory(subject.getPerson());
            String lastNameString = "";
            if (!lastnameHistory.isEmpty()) {
                lastNameString = lastnameHistory.get(0).getLastName();
                for (int i = 1; i < lastnameHistory.size(); i++) {
                    lastNameString += ", " + lastnameHistory.get(i).getLastName();
                }
            }

            if (subject != null && subject.getPerson() != null
                    && subject.getPerson().getPersonLastnameHistory() != null && !lastNameString.isEmpty()) {
                item.add(new Label("linkSubjectStudy.person.previouslastnamehistory.lastname", lastNameString));
            } else {
                item.add(new Label("linkSubjectStudy.person.previouslastnamehistory.lastname", ""));
            }

            item.add(new Label("linkSubjectStudy.person.genderType.name",
                    subject.getPerson().getGenderType().getName()));

            SimpleDateFormat simpleDateFormat = new SimpleDateFormat(au.org.theark.core.Constants.DD_MM_YYYY);
            String dateOfBirth = "";
            if (subject != null && subject.getPerson() != null
                    && subject.getPerson().getDateOfBirth() != null) {
                dateOfBirth = simpleDateFormat.format(subject.getPerson().getDateOfBirth());
                item.add(new Label("linkSubjectStudy.person.dateOfBirth", dateOfBirth));
            } else {
                item.add(new Label("linkSubjectStudy.person.dateOfBirth", ""));
            }

            item.add(new Label("linkSubjectStudy.person.vitalStatus.name",
                    subject.getPerson().getVitalStatus().getName()));

            item.add(new Label("linkSubjectStudy.subjectStatus.name", subject.getSubjectStatus().getName()));

            if (subject.getConsentStatus() != null) {
                item.add(
                        new Label("linkSubjectStudy.consentStatus.name", subject.getConsentStatus().getName()));
            } else {
                item.add(new Label("linkSubjectStudy.consentStatus.name", ""));
            }

            List<OtherID> otherIDs = iArkCommonService.getOtherIDs(subject.getPerson());
            String otherIDstring = "";
            for (OtherID o : otherIDs) {
                otherIDstring += o.getOtherID_Source() + ": " + o.getOtherID() + "\n";
            }
            if (!otherIDs.isEmpty()) {
                item.add(new MultiLineLabel("linkSubjectStudy.person.otherIDs.otherID", otherIDstring));
            } else {
                item.add(new Label("linkSubjectStudy.person.otherIDs.otherID", ""));
            }

            item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() {
                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD;
                }
            }));
        }
    };
    return studyCompDataView;
}

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

License:Open Source License

public DataView<SubjectVO> buildDataView(ArkDataProvider<SubjectVO, IArkCommonService> subjectProvider,
        final AbstractDetailModalWindow modalWindow, final List<RelationshipVo> relatives,
        final FeedbackPanel feedbackPanel) {

    DataView<SubjectVO> studyCompDataView = new DataView<SubjectVO>("subjectList", subjectProvider) {

        @Override/*from  w ww .  j a v  a2 s.  c  o m*/
        protected void populateItem(final Item<SubjectVO> item) {
            LinkSubjectStudy subject = item.getModelObject().getLinkSubjectStudy();
            item.add(buildLink(item, modalWindow, relatives, feedbackPanel));
            item.add(new Label(Constants.SUBJECT_FULL_NAME, item.getModelObject().getSubjectFullName()));
            /*
             * if (subject != null && subject.getPerson() != null &&
             * subject.getPerson().getPreferredName() != null) {
             * item.add(new Label("linkSubjectStudy.person.preferredName",
             * subject.getPerson().getPreferredName())); } else {
             * item.add(new Label("linkSubjectStudy.person.preferredName",
             * "")); }
             */
            List<PersonLastnameHistory> lastnameHistory = (List<PersonLastnameHistory>) iArkCommonService
                    .getPersonLastNameHistory(subject.getPerson());
            String lastNameString = "";
            if (!lastnameHistory.isEmpty()) {
                lastNameString = lastnameHistory.get(0).getLastName();
                for (int i = 1; i < lastnameHistory.size(); i++) {
                    lastNameString += ", " + lastnameHistory.get(i).getLastName();
                }
            }

            if (subject != null && subject.getPerson() != null
                    && subject.getPerson().getPersonLastnameHistory() != null && !lastNameString.isEmpty()) {
                item.add(new Label("linkSubjectStudy.person.previouslastnamehistory.lastname", lastNameString));
            } else {
                item.add(new Label("linkSubjectStudy.person.previouslastnamehistory.lastname", ""));
            }

            item.add(new Label("linkSubjectStudy.person.genderType.name",
                    subject.getPerson().getGenderType().getName()));

            SimpleDateFormat simpleDateFormat = new SimpleDateFormat(au.org.theark.core.Constants.DD_MM_YYYY);
            String dateOfBirth = "";
            if (subject != null && subject.getPerson() != null
                    && subject.getPerson().getDateOfBirth() != null) {
                dateOfBirth = simpleDateFormat.format(subject.getPerson().getDateOfBirth());
                item.add(new Label("linkSubjectStudy.person.dateOfBirth", dateOfBirth));
            } else {
                item.add(new Label("linkSubjectStudy.person.dateOfBirth", ""));
            }

            item.add(new Label("linkSubjectStudy.person.vitalStatus.name",
                    subject.getPerson().getVitalStatus().getName()));

            item.add(new Label("linkSubjectStudy.subjectStatus.name", subject.getSubjectStatus().getName()));

            if (subject.getConsentStatus() != null) {
                item.add(
                        new Label("linkSubjectStudy.consentStatus.name", subject.getConsentStatus().getName()));
            } else {
                item.add(new Label("linkSubjectStudy.consentStatus.name", ""));
            }

            item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() {
                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD;
                }
            }));

            List<OtherID> otherIDs = iArkCommonService.getOtherIDs(subject.getPerson());
            String otherIDstring = "";
            for (OtherID o : otherIDs) {
                otherIDstring += o.getOtherID_Source() + ": " + o.getOtherID() + "\n";
            }
            if (!otherIDs.isEmpty()) {
                item.add(new MultiLineLabel("linkSubjectStudy.person.otherIDs.otherID", otherIDstring));
            } else {
                item.add(new Label("linkSubjectStudy.person.otherIDs.otherID", ""));
            }
        }
    };
    return studyCompDataView;
}

From source file:com.asptt.plongee.resa.ui.web.wicket.page.AccueilPage.java

public AccueilPage() {

    //        // add the clock component
    //        Clock clock = new Clock("clock", TimeZone.getTimeZone("Europe/Paris"));
    //        add(clock);
    ///* w w w  . j av  a2s  . c  om*/
    //        // add the ajax behavior which will keep updating the component every 5
    //        // seconds
    //        clock.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(20)));

    setPageTitle("Accueil");
    Adherent adh = getResaSession().getAdherent();

    // Si l'adhrent est identifi mais qu'il n'a pas chang son password (password = licence)
    if (getResaSession().getAdherent().getNumeroLicense()
            .equalsIgnoreCase(getResaSession().getAdherent().getPassword())) {
        setResponsePage(ModifPasswordPage.class);
    }

    IModel<Adherent> model = new Model<Adherent>(adh);
    add(new Label("hello", new StringResourceModel(CatalogueMessages.ACCUEIL_BIENVENUE, this, model,
            new Object[] { new PropertyModel<Adherent>(model, "prenom"), calculerDateCourante() })));

    try {
        List<Message> messages = getResaSession().getAdherentService().rechercherMessage();
        List<Message> msgSepares = new ArrayList();
        Message ligne = new Message();
        ligne.setLibelle(" ");

        if (!messages.isEmpty()) {
            for (Message msg : messages) {
                msgSepares.add(msg);
                msgSepares.add(ligne);
            }
            int ledernier = msgSepares.size();
            msgSepares.remove(ledernier - 1);
        }

        MessageDataProvider pDataProvider = new MessageDataProvider(msgSepares);

        add(new DataView<Message>("listmessages", pDataProvider) {
            @Override
            protected void populateItem(final Item<Message> item) {
                final Message message = item.getModelObject();
                item.add(new Label("libelle", message.getLibelle()));

                item.add(new AttributeModifier("class", true, new AbstractReadOnlyModel<String>() {
                    @Override
                    public String getObject() {
                        String cssClass;
                        if (item.getIndex() % 2 == 1) {
                            cssClass = "even";
                        } else {
                            cssClass = "odd";
                        }
                        return cssClass;
                    }
                }));
            }
        });
        //gestion du message pour le certificat medical perim
        String msgCertificat = "";
        try {
            getResaSession().getPlongeeService().checkCertificatMedical(getResaSession().getAdherent(), null);
        } catch (ResaException e) {
            if (e.getKey().equalsIgnoreCase(CatalogueMessages.CM_PERIME)) {
                StringResourceModel srm = new StringResourceModel(CatalogueMessages.CM_PERIME, this, null);
                msgCertificat = srm.getString();
            } else {
                String nbJour = e.getKey().substring(14);
                StringResourceModel srm = new StringResourceModel(CatalogueMessages.CM_A_RENOUVELER, this,
                        model, new Object[] { new PropertyModel<Adherent>(model, "prenom"), nbJour });
                msgCertificat = srm.getString();
            }
        }
        add(new Label("certificat", msgCertificat));

        //gestion du message pour le cotisation non renouvelle
        try {
            getResaSession().getAdherentService().checkAnneeCotisation(getResaSession().getAdherent());
        } catch (ResaException e) {
            PageParameters pp = new PageParameters();
            StringResourceModel msgCotisation = new StringResourceModel(
                    CatalogueMessages.ACCUEIL_COTISATION_PERIME, this, new Model<Adherent>(adh));
            pp.add("cotisation", msgCotisation.getString());
            setResponsePage(new LoginPage(pp));
        }

    } catch (TechnicalException e) {
        e.printStackTrace();
        ErreurTechniquePage etp = new ErreurTechniquePage(e);
        setResponsePage(etp);
    }

}