Permalink
Browse files

code review, still need to move unit test to groovy

  • Loading branch information...
1 parent b8adfa6 commit dc7de7e725d8836726d5215c55f55ed67e11db3b @ccordenier committed Oct 27, 2010
Showing with 80 additions and 1,230 deletions.
  1. +1 −1 src/main/java/com/tap5/hotelbooking/annotations/AnonymousAccess.java
  2. +4 −2 src/main/java/com/tap5/hotelbooking/components/AjaxLoader.java
  3. +4 −4 src/main/java/com/tap5/hotelbooking/components/HotelClass.java
  4. +2 −9 src/main/java/com/tap5/hotelbooking/components/Layout.java
  5. +1 −2 src/main/java/com/tap5/hotelbooking/components/Workspace.java
  6. +4 −4 src/main/java/com/tap5/hotelbooking/components/YourBookings.java
  7. +0 −1 src/main/java/com/tap5/hotelbooking/data/BedType.java
  8. +0 −17 src/main/java/com/tap5/hotelbooking/data/HotelBookingConstants.java
  9. +3 −4 src/main/java/com/tap5/hotelbooking/data/UserWorkspace.java
  10. +0 −3 src/main/java/com/tap5/hotelbooking/data/Years.java
  11. +0 −96 src/main/java/com/tap5/hotelbooking/domain/CrudServiceDAO.java
  12. +0 −97 src/main/java/com/tap5/hotelbooking/domain/HibernateCrudServiceDAO.java
  13. +0 −44 src/main/java/com/tap5/hotelbooking/domain/HibernateModule.java
  14. +0 −37 src/main/java/com/tap5/hotelbooking/domain/QueryParameters.java
  15. +0 −311 src/main/java/com/tap5/hotelbooking/domain/entities/Booking.java
  16. +0 −6 src/main/java/com/tap5/hotelbooking/domain/entities/CreditCardType.java
  17. +0 −201 src/main/java/com/tap5/hotelbooking/domain/entities/Hotel.java
  18. +0 −154 src/main/java/com/tap5/hotelbooking/domain/entities/User.java
  19. +3 −3 src/main/java/com/tap5/hotelbooking/pages/Book.java
  20. +1 −8 src/main/java/com/tap5/hotelbooking/pages/Index.java
  21. +1 −2 src/main/java/com/tap5/hotelbooking/pages/Search.java
  22. +2 −2 src/main/java/com/tap5/hotelbooking/pages/Settings.java
  23. +3 −3 src/main/java/com/tap5/hotelbooking/pages/Signup.java
  24. +3 −3 src/main/java/com/tap5/hotelbooking/pages/View.java
  25. +0 −4 src/main/java/com/tap5/hotelbooking/security/AuthenticationException.java
  26. +6 −12 src/main/java/com/tap5/hotelbooking/security/AuthenticationFilter.java
  27. +1 −1 src/main/java/com/tap5/hotelbooking/services/Authenticator.java
  28. +3 −3 src/main/java/com/tap5/hotelbooking/services/BasicAuthenticator.java
  29. +0 −131 src/main/java/com/tap5/hotelbooking/services/DemoDataModule.java
  30. +11 −10 src/main/java/com/tap5/hotelbooking/services/HotelBookingModule.java
  31. +0 −2 src/test/java/com/tap5/hotelbooking/test/integration/BaseIntegrationTestSuite.java
  32. +11 −10 src/test/java/com/tap5/hotelbooking/test/integration/BookHotelTest.java
  33. +15 −13 src/test/java/com/tap5/hotelbooking/test/integration/SearchPageTest.java
  34. +0 −26 src/test/java/com/tap5/hotelbooking/test/services/TestModule.java
  35. +1 −4 src/test/java/com/tap5/hotelbooking/test/unit/BaseUnitTestSuite.java
@@ -8,7 +8,7 @@
/**
* Security annotation for Tapestry Pages. Enables anonymous access to pages, so the user does not
- * have to be logged in
+ * have to be logged in.
*
* @author karesti
* @version 1.0
@@ -3,6 +3,7 @@
import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.MarkupWriter;
+import org.apache.tapestry5.annotations.AfterRender;
import org.apache.tapestry5.annotations.BeginRender;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.ioc.annotations.Inject;
@@ -55,7 +56,7 @@ String defaultElement()
}
@BeginRender
- void initMoreLink(MarkupWriter writer)
+ void initAjaxLoader(MarkupWriter writer)
{
loader = javascriptSupport.allocateClientId("loader");
@@ -66,7 +67,8 @@ void initMoreLink(MarkupWriter writer)
javascriptSupport.addInitializerCall(InitializationPriority.LATE, "initAjaxLoader", data);
}
- void afterRender(MarkupWriter writer)
+ @AfterRender
+ void writeAjaxLoader(MarkupWriter writer)
{
writer.element(element, "id", loader, "class", this.loaderClass, "style", "display:none;");
writer.end();
@@ -7,16 +7,16 @@
import org.apache.tapestry5.services.AssetSource;
/**
- * Use this component with beandisplay to display an images for hotel's class.
- * It will display the image that corresponds to the number of stars of the hotel.
- *
+ * Use this component with beandisplay to display an images for hotel's class. It will display the
+ * image that corresponds to the number of stars of the hotel.
+ *
* @author ccordenier
*/
public class HotelClass
{
@Parameter(required = true)
@Property
- private Long stars;
+ private long stars;
@Inject
private AssetSource assetSource;
@@ -9,7 +9,7 @@
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
-import com.tap5.hotelbooking.domain.entities.User;
+import com.tap5.hotelbooking.entities.User;
import com.tap5.hotelbooking.pages.Index;
import com.tap5.hotelbooking.services.Authenticator;
@@ -47,14 +47,7 @@ public String getClassForPageName()
public User getUser()
{
- User user = null;
-
- if (authenticator.isLoggedIn())
- {
- user = authenticator.getLoggedUser();
- }
-
- return user;
+ return authenticator.isLoggedIn() ? authenticator.getLoggedUser() : null;
}
@Log
@@ -11,7 +11,7 @@
import org.apache.tapestry5.services.PageRenderLinkSource;
import com.tap5.hotelbooking.data.UserWorkspace;
-import com.tap5.hotelbooking.domain.entities.Booking;
+import com.tap5.hotelbooking.entities.Booking;
/**
* Display the list of current booking that has not been confirmed yet. You can click on displayed
@@ -22,7 +22,6 @@
*/
public class Workspace
{
-
@SessionState
@Property
private UserWorkspace userWorkspace;
@@ -7,9 +7,9 @@
import org.apache.tapestry5.annotations.SetupRender;
import org.apache.tapestry5.ioc.annotations.Inject;
-import com.tap5.hotelbooking.domain.CrudServiceDAO;
-import com.tap5.hotelbooking.domain.QueryParameters;
-import com.tap5.hotelbooking.domain.entities.Booking;
+import com.tap5.hotelbooking.dal.CrudServiceDAO;
+import com.tap5.hotelbooking.dal.QueryParameters;
+import com.tap5.hotelbooking.entities.Booking;
import com.tap5.hotelbooking.services.Authenticator;
/**
@@ -34,7 +34,7 @@
/**
* Prepare the list of booking to display, extract all the booking associated to the current
- * user.
+ * logged user.
*
* @return
*/
@@ -28,7 +28,6 @@ public BedType()
public List<OptionGroupModel> getOptionGroups()
{
- // TODO Auto-generated method stub
return null;
}
@@ -1,17 +0,0 @@
-package com.tap5.hotelbooking.data;
-
-/**
- * Define the Hotel booking symbols constants.
- *
- * @author ccordenier
- */
-public class HotelBookingConstants
-{
-
- public static final String DEFAULT_PAGE = "hotelbooking.default-page";
-
- public static final String SIGNIN_PAGE = "hotelbooking.signin-page";
-
- public static final String SIGNUP_PAGE = "hotelbooking.signup-page";
-
-}
@@ -3,9 +3,9 @@
import java.util.ArrayList;
import java.util.List;
-import com.tap5.hotelbooking.domain.entities.Booking;
-import com.tap5.hotelbooking.domain.entities.Hotel;
-import com.tap5.hotelbooking.domain.entities.User;
+import com.tap5.hotelbooking.entities.Booking;
+import com.tap5.hotelbooking.entities.Hotel;
+import com.tap5.hotelbooking.entities.User;
/**
* Use this object to store user's booking
@@ -72,7 +72,6 @@ public Booking restoreBooking(Long bookId)
public void cancelCurrentBooking(Booking booking)
{
removeCurrentBooking(booking);
-
}
public void confirmCurrentBooking(Booking booking)
@@ -16,18 +16,15 @@
public Years()
{
-
int year = Calendar.getInstance().get(Calendar.YEAR);
for (int i = 0; i < 6; i++)
{
options.add(new OptionModelImpl(year + i + ""));
}
-
}
public List<OptionGroupModel> getOptionGroups()
{
- // TODO Auto-generated method stub
return null;
}
@@ -1,96 +0,0 @@
-package com.tap5.hotelbooking.domain;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.tapestry5.hibernate.annotations.CommitAfter;
-
-/**
- * CrudServiceDAO interface.
- *
- * @author karesti
- */
-public interface CrudServiceDAO
-{
- /**
- * Creates a new object for the given type
- *
- * @param <T>
- * @param t
- * @return persisted Object
- */
- @CommitAfter
- <T> T create(T t);
-
- /**
- * Updates the given object
- *
- * @param <T>
- * @param t
- * @return persisted object
- */
- @CommitAfter
- <T> T update(T t);
-
- /**
- * Deletes the given object by id
- *
- * @param <T>
- * @param <PK>
- * @param type
- * , entity class type
- * @param id
- */
- @CommitAfter
- <T, PK extends Serializable> void delete(Class<T> type, PK id);
-
- /**
- * Finds an object by id
- *
- * @param <T>
- * @param <PK>
- * @param type
- * @param id
- * @return the object
- */
- <T, PK extends Serializable> T find(Class<T> type, PK id);
-
- /**
- * Finds a list of objects for the given query name
- *
- * @param <T>
- * @param queryName
- * @return returns a list of objects
- */
- <T> List<T> findWithNamedQuery(String queryName);
-
- /**
- * Find a query with parameters
- *
- * @param <T>
- * @param queryName
- * @param params
- * @return resulting list
- */
- <T> List<T> findWithNamedQuery(String queryName, Map<String, Object> params);
-
- /**
- * Returns one result, query without parameters
- *
- * @param <T>
- * @param queryName
- * @return T object
- */
- <T> T findUniqueWithNamedQuery(String queryName);
-
- /**
- * Returns just one result with a named query and parameters
- *
- * @param <T>
- * @param queryName
- * @param params
- * @return T object
- */
- <T> T findUniqueWithNamedQuery(String queryName, Map<String, Object> params);
-}
@@ -1,97 +0,0 @@
-package com.tap5.hotelbooking.domain;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.hibernate.Query;
-import org.hibernate.Session;
-
-/**
- * Hibernate CrudService
- *
- * @author karesti
- * @param <T>, type entity
- * @param <PK>, primarykey, the primary key
- */
-public class HibernateCrudServiceDAO implements CrudServiceDAO
-{
-
- @Inject
- private Session session;
-
- public <T> HibernateCrudServiceDAO(Class<T> type)
- {
-
- }
-
- public <T> T create(T t)
- {
- session.persist(t);
- session.flush();
- session.refresh(t);
- return t;
- }
-
- @SuppressWarnings("unchecked")
- public <T, PK extends Serializable> T find(Class<T> type, PK id)
- {
- return (T) session.get(type, id);
- }
-
- public <T> T update(T type)
- {
- session.merge(type);
- return type;
- }
-
- public <T, PK extends Serializable> void delete(Class<T> type, PK id)
- {
- @SuppressWarnings("unchecked")
- T ref = (T) session.get(type, id);
- session.delete(ref);
- }
-
- @SuppressWarnings("unchecked")
- public <T> List<T> findWithNamedQuery(String queryName)
- {
- return session.getNamedQuery(queryName).list();
- }
-
- @SuppressWarnings("unchecked")
- public <T> List<T> findWithNamedQuery(String queryName, Map<String, Object> params)
- {
- Set<Entry<String, Object>> rawParameters = params.entrySet();
- Query query = session.getNamedQuery(queryName);
-
- for (Entry<String, Object> entry : rawParameters)
- {
- query.setParameter(entry.getKey(), entry.getValue());
-
- }
- return query.list();
- }
-
- @SuppressWarnings("unchecked")
- public <T> T findUniqueWithNamedQuery(String queryName)
- {
- return (T) session.getNamedQuery(queryName).uniqueResult();
- }
-
- @SuppressWarnings("unchecked")
- public <T> T findUniqueWithNamedQuery(String queryName, Map<String, Object> params)
- {
- Set<Entry<String, Object>> rawParameters = params.entrySet();
- Query query = session.getNamedQuery(queryName);
-
- for (Entry<String, Object> entry : rawParameters)
- {
- query.setParameter(entry.getKey(), entry.getValue());
-
- }
- return (T) query.uniqueResult();
- }
-}
Oops, something went wrong.

0 comments on commit dc7de7e

Please sign in to comment.