• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mybatis / jpetstore-6 / #1229

pending completion
#1229

push

github

web-flow
Merge pull request #710 from mybatis/renovate/org.apache.maven.plugins-maven-failsafe-plugin-3.x

chore(deps): update dependency org.apache.maven.plugins:maven-failsafe-plugin to v3.1.2

421 of 612 relevant lines covered (68.79%)

0.69 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

18.64
/src/main/java/org/mybatis/jpetstore/web/actions/CatalogActionBean.java
1
/*
2
 *    Copyright 2010-2022 the original author or authors.
3
 *
4
 *    Licensed under the Apache License, Version 2.0 (the "License");
5
 *    you may not use this file except in compliance with the License.
6
 *    You may obtain a copy of the License at
7
 *
8
 *       https://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 *    Unless required by applicable law or agreed to in writing, software
11
 *    distributed under the License is distributed on an "AS IS" BASIS,
12
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 *    See the License for the specific language governing permissions and
14
 *    limitations under the License.
15
 */
16
package org.mybatis.jpetstore.web.actions;
17

18
import java.util.List;
19

20
import net.sourceforge.stripes.action.DefaultHandler;
21
import net.sourceforge.stripes.action.ForwardResolution;
22
import net.sourceforge.stripes.action.SessionScope;
23
import net.sourceforge.stripes.integration.spring.SpringBean;
24

25
import org.mybatis.jpetstore.domain.Category;
26
import org.mybatis.jpetstore.domain.Item;
27
import org.mybatis.jpetstore.domain.Product;
28
import org.mybatis.jpetstore.service.CatalogService;
29

30
/**
31
 * The Class CatalogActionBean.
32
 *
33
 * @author Eduardo Macarron
34
 */
35
@SessionScope
36
public class CatalogActionBean extends AbstractActionBean {
1✔
37

38
  private static final long serialVersionUID = 5849523372175050635L;
39

40
  private static final String MAIN = "/WEB-INF/jsp/catalog/Main.jsp";
41
  private static final String VIEW_CATEGORY = "/WEB-INF/jsp/catalog/Category.jsp";
42
  private static final String VIEW_PRODUCT = "/WEB-INF/jsp/catalog/Product.jsp";
43
  private static final String VIEW_ITEM = "/WEB-INF/jsp/catalog/Item.jsp";
44
  private static final String SEARCH_PRODUCTS = "/WEB-INF/jsp/catalog/SearchProducts.jsp";
45

46
  @SpringBean
47
  private transient CatalogService catalogService;
48

49
  private String keyword;
50

51
  private String categoryId;
52
  private Category category;
53
  private List<Category> categoryList;
54

55
  private String productId;
56
  private Product product;
57
  private List<Product> productList;
58

59
  private String itemId;
60
  private Item item;
61
  private List<Item> itemList;
62

63
  public String getKeyword() {
64
    return keyword;
1✔
65
  }
66

67
  public void setKeyword(String keyword) {
68
    this.keyword = keyword;
×
69
  }
×
70

71
  public String getCategoryId() {
72
    return categoryId;
1✔
73
  }
74

75
  public void setCategoryId(String categoryId) {
76
    this.categoryId = categoryId;
×
77
  }
×
78

79
  public String getProductId() {
80
    return productId;
1✔
81
  }
82

83
  public void setProductId(String productId) {
84
    this.productId = productId;
×
85
  }
×
86

87
  public String getItemId() {
88
    return itemId;
1✔
89
  }
90

91
  public void setItemId(String itemId) {
92
    this.itemId = itemId;
×
93
  }
×
94

95
  public Category getCategory() {
96
    return category;
1✔
97
  }
98

99
  public void setCategory(Category category) {
100
    this.category = category;
×
101
  }
×
102

103
  public Product getProduct() {
104
    return product;
1✔
105
  }
106

107
  public void setProduct(Product product) {
108
    this.product = product;
×
109
  }
×
110

111
  public Item getItem() {
112
    return item;
1✔
113
  }
114

115
  public void setItem(Item item) {
116
    this.item = item;
×
117
  }
×
118

119
  public List<Category> getCategoryList() {
120
    return categoryList;
1✔
121
  }
122

123
  public void setCategoryList(List<Category> categoryList) {
124
    this.categoryList = categoryList;
×
125
  }
×
126

127
  public List<Product> getProductList() {
128
    return productList;
1✔
129
  }
130

131
  public void setProductList(List<Product> productList) {
132
    this.productList = productList;
×
133
  }
×
134

135
  public List<Item> getItemList() {
136
    return itemList;
1✔
137
  }
138

139
  public void setItemList(List<Item> itemList) {
140
    this.itemList = itemList;
×
141
  }
×
142

143
  @DefaultHandler
144
  public ForwardResolution viewMain() {
145
    return new ForwardResolution(MAIN);
×
146
  }
147

148
  /**
149
   * View category.
150
   *
151
   * @return the forward resolution
152
   */
153
  public ForwardResolution viewCategory() {
154
    if (categoryId != null) {
×
155
      productList = catalogService.getProductListByCategory(categoryId);
×
156
      category = catalogService.getCategory(categoryId);
×
157
    }
158
    return new ForwardResolution(VIEW_CATEGORY);
×
159
  }
160

161
  /**
162
   * View product.
163
   *
164
   * @return the forward resolution
165
   */
166
  public ForwardResolution viewProduct() {
167
    if (productId != null) {
×
168
      itemList = catalogService.getItemListByProduct(productId);
×
169
      product = catalogService.getProduct(productId);
×
170
    }
171
    return new ForwardResolution(VIEW_PRODUCT);
×
172
  }
173

174
  /**
175
   * View item.
176
   *
177
   * @return the forward resolution
178
   */
179
  public ForwardResolution viewItem() {
180
    item = catalogService.getItem(itemId);
×
181
    product = item.getProduct();
×
182
    return new ForwardResolution(VIEW_ITEM);
×
183
  }
184

185
  /**
186
   * Search products.
187
   *
188
   * @return the forward resolution
189
   */
190
  public ForwardResolution searchProducts() {
191
    if (keyword == null || keyword.length() < 1) {
×
192
      setMessage("Please enter a keyword to search for, then press the search button.");
×
193
      return new ForwardResolution(ERROR);
×
194
    } else {
195
      productList = catalogService.searchProductList(keyword.toLowerCase());
×
196
      return new ForwardResolution(SEARCH_PRODUCTS);
×
197
    }
198
  }
199

200
  /**
201
   * Clear.
202
   */
203
  public void clear() {
204
    keyword = null;
×
205

206
    categoryId = null;
×
207
    category = null;
×
208
    categoryList = null;
×
209

210
    productId = null;
×
211
    product = null;
×
212
    productList = null;
×
213

214
    itemId = null;
×
215
    item = null;
×
216
    itemList = null;
×
217
  }
×
218

219
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc