##### Coverage Report - jp.co.y_net.amm.page.OrgEntryListPage

Classes in this File | Line Coverage | Branch Coverage | Complexity

OrgEntryListPage

0% | 0/35

0% | 0/6

0.0;0

OrgEntryListPage$1

0% | 0/12

0% | 0/6

0.0;0

OrgEntryListPage$2

0% | 0/14

0% | 0/2

0.0;0

OrgEntryListPage$2$1

0% | 0/8

N/A | N/A

0.0;0

OrgEntryListPage$3

0% | 0/3

0% | 0/2

0.0;0

OrgEntryListPage$4

0% | 0/4

N/A | N/A

0.0;0

OrgEntryListPage$5

0% | 0/4

N/A | N/A

0.0;0

1

0

     package jp.co.y_net.amm.page;

2

3

     import java.util.ArrayList;

4

     import java.util.Collections;

5

     import java.util.List;

6

     import java.util.Map.Entry;

7

8

     import jp.co.y_net.amm.AppSession;

9

     import jp.co.y_net.amm.common.ChoiceElement;

10

     import jp.co.y_net.amm.common.ResourceReader;

11

     import jp.co.y_net.amm.dao.Org;

12

     import jp.co.y_net.amm.dao.Usr;

13

14

     import org.apache.commons.lang.StringUtils;

15

     import org.apache.wicket.ajax.AjaxRequestTarget;

16

     import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;

17

     import org.apache.wicket.markup.html.WebMarkupContainer;

18

     import org.apache.wicket.markup.html.basic.Label;

19

     import org.apache.wicket.markup.html.form.DropDownChoice;

20

     import org.apache.wicket.markup.html.link.ExternalLink;

21

     import org.apache.wicket.markup.html.link.Link;

22

     import org.apache.wicket.markup.html.list.ListItem;

23

     import org.apache.wicket.markup.html.list.PageableListView;

24

     import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;

25

     import org.apache.wicket.markup.html.panel.FeedbackPanel;

26

     import org.apache.wicket.model.IModel;

27

     import org.apache.wicket.model.LoadableDetachableModel;

28

     import org.apache.wicket.model.Model;

29

     import org.apache.wicket.request.mapper.parameter.PageParameters;

30

31

     public class OrgEntryListPage extends CommonFrameA {

32

             private static final long serialVersionUID = 1L;

33

34

         /**

35

          * ログインチェック定義

36

          * @see jp.co.y_net.amm.page.AppPage#validateLogin()

37

          */

38

         @Override

39

         public boolean validateLogin() {

40

0

             if(AppSession.get().isLogin()) {

41

0

                 if(AppSession.get().getLoginUser().getKind().equals(Usr.KIND_運営管理者)) {

42

0

                     return true;

43

                 }

44

             }

45

0

             return false;

46

         }

47

48

0

         public OrgEntryListPage(PageParameters pageParams) {

49

50

             /* 戻るリンク */

51

0

             add(new ExternalLink("lnkSysAdmin", ResourceReader.getStringQuick("url.back.sysadmin")));

52

53

             /* フィードバックメッセージ */

54

0

             add(new FeedbackPanel("feedback"));

55

56

57

             /* 表示順序 */

58

0

             List<ChoiceElement> sortChoice = new ArrayList<ChoiceElement>();

59

0

             sortChoice.add(new ChoiceElement("1","申請日時の新しい順"));

60

0

             sortChoice.add(new ChoiceElement("2","申請日時の古い順"));

61

0

             final Model<ChoiceElement> sortModel = new Model<ChoiceElement>();

62

0

             ChoiceElement.setDropDownList(sortModel, sortChoice, "1"); // 初期値設定

63

0

             final DropDownChoice<ChoiceElement> sortEntrydate = new DropDownChoice<ChoiceElement>(

64

0

                     "sortEntrydate", sortModel, sortChoice, new ChoiceElement.Renderer());

65

0

             add(sortEntrydate);

66

67

             /* 絞り込み */

68

0

             List<ChoiceElement> filterChoice = new ArrayList<ChoiceElement>();

69

0

             filterChoice.add(new ChoiceElement(" ","全て"));

70

0

             for(Entry<String, String> entry: Org.getStatusMap().entrySet()) {

71

0

                 filterChoice.add(new ChoiceElement(entry.getKey(), entry.getValue()));

72

             }

73

0

             final Model<ChoiceElement> filterModel = new Model<ChoiceElement>();

74

0

             ChoiceElement.setDropDownList(filterModel, filterChoice, " "); // 初期値設定

75

0

             final DropDownChoice<ChoiceElement> filterStatus = new DropDownChoice<ChoiceElement>(

76

0

                     "filterStatus", filterModel, filterChoice, new ChoiceElement.Renderer());

77

0

             add(filterStatus);

78

79

             // LoadableDetachableModel は リクエストの最初に load にてデータを取得するモデル

80

0

             final IModel<List<Org>> orgsModel = new LoadableDetachableModel<List<Org>>() {

81

                 @Override

82

                 protected List<Org> load() {

83

0

                     Org cnd = new Org();

84

0

                     if(filterModel.getObject() != null) {

85

0

                         String filterId = filterModel.getObject().getId();

86

0

                         if(filterId != null && filterId.trim().equals("") == false) {

87

0

                             int iFilterId = Integer.parseInt(filterId);

88

0

                             cnd.setStatus(iFilterId);

89

                         }

90

                     }

91

0

                     List<Org> entryOrgs = orgDao.get(cnd);

92

93

0

                     boolean desc = sortModel.getObject().getId().equals("1");

94

0

                     Collections.sort(entryOrgs, new Org.EntryDateComparator(desc));

95

96

0

                     return entryOrgs;

97

                 }

98

             };

99

100

0

             final WebMarkupContainer container = new WebMarkupContainer("listViewContainer");

101

0

             container.setOutputMarkupId(true);

102

0

             add(container);

103

0

             final PageableListView<Org> listview = new PageableListView<Org>("listview", orgsModel, 20) {

104

                 private static final long serialVersionUID = 1L;

105

                 @Override

106

                 protected void populateItem(ListItem<Org> item) {

107

     //

108

0

                     final Org org = item.getModelObject();

109

110

                     /* 会員種別 */

111

0

                     item.add(new Label("kind", org.getKind_Disp()));

112

113

114

                     /* 名称とリンク */

115

                     //BookmarkablePageLink<Void> lnkName = new BookmarkablePageLink<Void>("lnkName", OrgEntryDetailPage.class, param);

116

0

                     Link<Void> lnkName = new Link<Void>("lnkName"){

117

                         @Override

118

                         public void onClick() {

119

0

                             PageParameters param = new PageParameters();

120

0

                             param.add("orgid", org.getOrgid());

121

0

                             OrgEntryDetailPage nextPage = new OrgEntryDetailPage(param);

122

0

                             nextPage.setReturnPage(getPage()); // このページを戻り先として記録する

123

0

                             setResponsePage(nextPage);

124

0

                         }

125

                     };

126

127

128

0

                     String name = org.getNameOrAdminname();

129

0

                     if(StringUtils.isEmpty(name)) {

130

0

                         name = "※"; // 仮に値が取得できない場合でも、リンクに使用されるため、疑似値を設定した。

131

                     }

132

0

                     Label lnklblName = new Label("lnklblName", name);

133

0

                     lnkName.add(lnklblName);

134

0

                     item.add(lnkName);

135

136

                     /* ステータス */

137

0

                     item.add(new Label("status", org.getStatus_Disp()));

138

139

                     /* 申請日時 */

140

0

                     item.add(new Label("entrydate" , org.getEntrydate_Disp()));

141

0

                 }

142

             };

143

0

             container.add(listview);

144

145

0

             PagingNavigator navigator = new PagingNavigator("paging", listview){

146

                 @Override

147

                 public boolean isVisible() {

148

0

                     return listview.size() > 0;

149

                 }

150

             };

151

0

             add(navigator);

152

153

154

             /* プルダウン変更の挙動 */

155

0

             sortEntrydate.add(new AjaxFormComponentUpdatingBehavior("onchange") {

156

                 @Override

157

                 protected void onUpdate(AjaxRequestTarget target) {

158

0

                     target.add(container);

159

0

                 }

160

             });

161

0

             filterStatus.add(new AjaxFormComponentUpdatingBehavior("onchange") {

162

                 @Override

163

                 protected void onUpdate(AjaxRequestTarget target) {

164

0

                     target.add(container);

165

0

                 }

166

             });

167

0

         }

168

     }