[jboss-cvs] JBossAS SVN: r100043 - in projects/snowdrop/examples/trunk/sportsclub: sportsclub-invoicing-webmvc/src/main/java/org/jboss/snowdrop/samples/sportsclub/springmvc and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jan 28 08:18:58 EST 2010
Author: lvlcek at redhat.com
Date: 2010-01-28 08:18:58 -0500 (Thu, 28 Jan 2010)
New Revision: 100043
Added:
projects/snowdrop/examples/trunk/sportsclub/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/repository/criteria/InvoiceSearchCriteria.java
projects/snowdrop/examples/trunk/sportsclub/sportsclub-invoicing-webmvc/src/main/java/org/jboss/snowdrop/samples/sportsclub/springmvc/BooleanOption.java
Modified:
projects/snowdrop/examples/trunk/sportsclub/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/repository/criteria/AccountSearchCriteria.java
projects/snowdrop/examples/trunk/sportsclub/sportsclub-invoicing-webmvc/src/main/java/org/jboss/snowdrop/samples/sportsclub/springmvc/AccountController.java
projects/snowdrop/examples/trunk/sportsclub/sportsclub-invoicing-webmvc/src/main/webapp/WEB-INF/jsp/searchAccount.jsp
projects/snowdrop/examples/trunk/sportsclub/sportsclub-subscriptions-ejb/src/main/java/org/jboss/snowdrop/samples/sportsclub/ejb/SubscriptionService.java
projects/snowdrop/examples/trunk/sportsclub/sportsclub-subscriptions-ejb/src/main/java/org/jboss/snowdrop/samples/sportsclub/ejb/SubscriptionServiceImpl.java
Log:
Spring MVC (work in progress)
Modified: projects/snowdrop/examples/trunk/sportsclub/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/repository/criteria/AccountSearchCriteria.java
===================================================================
--- projects/snowdrop/examples/trunk/sportsclub/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/repository/criteria/AccountSearchCriteria.java 2010-01-28 13:12:02 UTC (rev 100042)
+++ projects/snowdrop/examples/trunk/sportsclub/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/repository/criteria/AccountSearchCriteria.java 2010-01-28 13:18:58 UTC (rev 100043)
@@ -7,6 +7,8 @@
{
private PersonSearchCriteria personSearchCriteria;
+ private InvoiceSearchCriteria invoiceSearchCriteria;
+
private boolean activeOnly;
public PersonSearchCriteria getPersonSearchCriteria()
@@ -29,4 +31,13 @@
this.activeOnly = activeOnly;
}
+ public InvoiceSearchCriteria getInvoiceSearchCriteria()
+ {
+ return invoiceSearchCriteria;
+ }
+
+ public void setInvoiceSearchCriteria(InvoiceSearchCriteria invoiceSearchCriteria)
+ {
+ this.invoiceSearchCriteria = invoiceSearchCriteria;
+ }
}
Added: projects/snowdrop/examples/trunk/sportsclub/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/repository/criteria/InvoiceSearchCriteria.java
===================================================================
--- projects/snowdrop/examples/trunk/sportsclub/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/repository/criteria/InvoiceSearchCriteria.java (rev 0)
+++ projects/snowdrop/examples/trunk/sportsclub/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/repository/criteria/InvoiceSearchCriteria.java 2010-01-28 13:18:58 UTC (rev 100043)
@@ -0,0 +1,19 @@
+package org.jboss.snowdrop.samples.sportsclub.domain.repository.criteria;
+
+/**
+ * @author <a href="mailto:lvlcek at redhat.com">Lukas Vlcek</a>
+ */
+public class InvoiceSearchCriteria
+{
+ private boolean currentInvoice;
+
+ public boolean isCurrentInvoice()
+ {
+ return currentInvoice;
+ }
+
+ public void setCurrentInvoice(boolean currentInvoice)
+ {
+ this.currentInvoice = currentInvoice;
+ }
+}
Modified: projects/snowdrop/examples/trunk/sportsclub/sportsclub-invoicing-webmvc/src/main/java/org/jboss/snowdrop/samples/sportsclub/springmvc/AccountController.java
===================================================================
--- projects/snowdrop/examples/trunk/sportsclub/sportsclub-invoicing-webmvc/src/main/java/org/jboss/snowdrop/samples/sportsclub/springmvc/AccountController.java 2010-01-28 13:12:02 UTC (rev 100042)
+++ projects/snowdrop/examples/trunk/sportsclub/sportsclub-invoicing-webmvc/src/main/java/org/jboss/snowdrop/samples/sportsclub/springmvc/AccountController.java 2010-01-28 13:18:58 UTC (rev 100043)
@@ -18,8 +18,14 @@
public class AccountController
{
- private static final String[] invoiceStatus = new String[]{UserInput.INVOICE_WITH, UserInput.INVOICE_WITHOUT};
+ private static final BooleanOption[] invoiceStatus;
+ static {
+ invoiceStatus = new BooleanOption[2];
+ invoiceStatus[0] = new BooleanOption(UserInput.INVOICE_WITH, true);
+ invoiceStatus[1] = new BooleanOption(UserInput.INVOICE_WITHOUT, false);
+ }
+
@EJB(mappedName = "sportsclub/SubscriptionService")
SubscriptionService subscriptionService;
@@ -44,7 +50,7 @@
{
String nameFragment = userInput.getNameFragment();
Integer maxAccountNum = userInput.getMaxAccountNum();
-
+
List<Account> accountList = subscriptionService.findAccountsBySubscriberName(nameFragment, 0, maxAccountNum);
ModelMap model = new ModelMap();
Added: projects/snowdrop/examples/trunk/sportsclub/sportsclub-invoicing-webmvc/src/main/java/org/jboss/snowdrop/samples/sportsclub/springmvc/BooleanOption.java
===================================================================
--- projects/snowdrop/examples/trunk/sportsclub/sportsclub-invoicing-webmvc/src/main/java/org/jboss/snowdrop/samples/sportsclub/springmvc/BooleanOption.java (rev 0)
+++ projects/snowdrop/examples/trunk/sportsclub/sportsclub-invoicing-webmvc/src/main/java/org/jboss/snowdrop/samples/sportsclub/springmvc/BooleanOption.java 2010-01-28 13:18:58 UTC (rev 100043)
@@ -0,0 +1,37 @@
+package org.jboss.snowdrop.samples.sportsclub.springmvc;
+
+/**
+ * Represents option for HTML select list.
+ * @author <a href="mailto:lvlcek at redhat.com">Lukas Vlcek</a>
+ */
+public class BooleanOption
+{
+ private String label;
+ private boolean value;
+
+ public BooleanOption(String label, boolean value)
+ {
+ this.label = label;
+ this.value = value;
+ }
+
+ public String getLabel()
+ {
+ return label;
+ }
+
+ public void setLabel(String label)
+ {
+ this.label = label;
+ }
+
+ public boolean isValue()
+ {
+ return value;
+ }
+
+ public void setValue(boolean value)
+ {
+ this.value = value;
+ }
+}
Modified: projects/snowdrop/examples/trunk/sportsclub/sportsclub-invoicing-webmvc/src/main/webapp/WEB-INF/jsp/searchAccount.jsp
===================================================================
--- projects/snowdrop/examples/trunk/sportsclub/sportsclub-invoicing-webmvc/src/main/webapp/WEB-INF/jsp/searchAccount.jsp 2010-01-28 13:12:02 UTC (rev 100042)
+++ projects/snowdrop/examples/trunk/sportsclub/sportsclub-invoicing-webmvc/src/main/webapp/WEB-INF/jsp/searchAccount.jsp 2010-01-28 13:18:58 UTC (rev 100043)
@@ -9,7 +9,7 @@
<form:form commandName="userInput">
- Search accounts <form:select path="invoiceStatus" items="${stringList}"/> current invoice by subscriber name:<br/>
+ Search accounts <form:select path="invoiceStatus" items="${booleanOptionList}" itemLabel="label" itemValue="value" /> current invoice by subscriber name:<br/>
<form:input path="nameFragment"/> <input type="submit" value="Search"/><br/>
<span style="font-size:70%">
Display up to
@@ -18,7 +18,7 @@
</span>
</form:form>
-<c:if test="${empty accountList}">
+<c:if test="${(accountList ne null) and (empty accountList)}">
Sorry no result matches...
</c:if>
<c:if test="${not empty accountList}">
Modified: projects/snowdrop/examples/trunk/sportsclub/sportsclub-subscriptions-ejb/src/main/java/org/jboss/snowdrop/samples/sportsclub/ejb/SubscriptionService.java
===================================================================
--- projects/snowdrop/examples/trunk/sportsclub/sportsclub-subscriptions-ejb/src/main/java/org/jboss/snowdrop/samples/sportsclub/ejb/SubscriptionService.java 2010-01-28 13:12:02 UTC (rev 100042)
+++ projects/snowdrop/examples/trunk/sportsclub/sportsclub-subscriptions-ejb/src/main/java/org/jboss/snowdrop/samples/sportsclub/ejb/SubscriptionService.java 2010-01-28 13:18:58 UTC (rev 100043)
@@ -15,8 +15,34 @@
{
int countAccountsBySubscriberName(String name);
+ /**
+ * Search for {@link org.jboss.snowdrop.samples.sportsclub.domain.entity.Account}s
+ * based on provided subscriber name fragment. minIndex and maxIndex parameters
+ * are to allow results pagination.
+ *
+ * @param name subscriber name fragment
+ * @param minIndex start of result index
+ * @param maxIndex end of result index
+ * @return list of related accounts
+ */
List<Account> findAccountsBySubscriberName(String name, int minIndex, int maxIndex);
+ /**
+ * Search for {@link org.jboss.snowdrop.samples.sportsclub.domain.entity.Account}s
+ * based on provided subscriber name fragment. minIndex and maxIndex parameters
+ * are to allow results pagination, currentInvoice flag means whether related
+ * accounts have opened/active invoice or not.
+ *
+ * @see #findAccountsBySubscriberName(String, int, int)
+ *
+ * @param name subscriber name fragment
+ * @param minIndex start of result index
+ * @param maxIndex end of result index
+ * @param currentInvoice active invoice
+ * @return list of related accounts
+ */
+ List<Account> findAccountsBySubscriberName(String name, int minIndex, int maxIndex, boolean currentInvoice);
+
List<String> getMembershipTypes();
Account createAccount(Person person, String membershipCode, BillingType billingType);
Modified: projects/snowdrop/examples/trunk/sportsclub/sportsclub-subscriptions-ejb/src/main/java/org/jboss/snowdrop/samples/sportsclub/ejb/SubscriptionServiceImpl.java
===================================================================
--- projects/snowdrop/examples/trunk/sportsclub/sportsclub-subscriptions-ejb/src/main/java/org/jboss/snowdrop/samples/sportsclub/ejb/SubscriptionServiceImpl.java 2010-01-28 13:12:02 UTC (rev 100042)
+++ projects/snowdrop/examples/trunk/sportsclub/sportsclub-subscriptions-ejb/src/main/java/org/jboss/snowdrop/samples/sportsclub/ejb/SubscriptionServiceImpl.java 2010-01-28 13:18:58 UTC (rev 100043)
@@ -11,6 +11,7 @@
import org.jboss.snowdrop.samples.sportsclub.domain.repository.criteria.AccountSearchCriteria;
import org.jboss.snowdrop.samples.sportsclub.domain.repository.criteria.PersonSearchCriteria;
import org.jboss.snowdrop.samples.sportsclub.domain.repository.criteria.Range;
+import org.jboss.snowdrop.samples.sportsclub.domain.repository.criteria.InvoiceSearchCriteria;
import org.jboss.spring.callback.SpringLifecycleInterceptor;
import javax.ejb.Stateless;
@@ -47,6 +48,20 @@
return accountRepository.findByCriteria(accountSearchCriteria);
}
+ public List<Account> findAccountsBySubscriberName(String name, int minIndex, int maxIndex, boolean currentInvoice)
+ {
+ PersonSearchCriteria personSearchCriteria = new PersonSearchCriteria();
+ personSearchCriteria.setName(name);
+ InvoiceSearchCriteria invoiceSearchCriteria = new InvoiceSearchCriteria();
+ invoiceSearchCriteria.setCurrentInvoice(currentInvoice);
+ AccountSearchCriteria accountSearchCriteria = new AccountSearchCriteria();
+ accountSearchCriteria.setPersonSearchCriteria(personSearchCriteria);
+ accountSearchCriteria.setInvoiceSearchCriteria(invoiceSearchCriteria);
+ accountSearchCriteria.setActiveOnly(true);
+ accountSearchCriteria.setRange(new Range(minIndex, maxIndex));
+ return accountRepository.findByCriteria(accountSearchCriteria);
+ }
+
public int countAccountsBySubscriberName(String name)
{
PersonSearchCriteria personSearchCriteria = new PersonSearchCriteria();
More information about the jboss-cvs-commits
mailing list