Skip to content
This repository has been archived by the owner on Mar 13, 2022. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
OoiJunHao committed Apr 17, 2021
2 parents 1ce9269 + d9e8a60 commit 39e3042
Show file tree
Hide file tree
Showing 74 changed files with 129 additions and 104 deletions.
2 changes: 1 addition & 1 deletion OTFood-ejb/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ j2ee.compile.on.save=true
j2ee.deploy.on.save=true
j2ee.platform=1.8
j2ee.platform.classpath=${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/cdi-api.jar:${j2ee.server.home}/modules/endorsed/grizzly-npn-bootstrap.jar:${j2ee.server.home}/modules/endorsed/jakarta.annotation-api.jar:${j2ee.server.home}/modules/endorsed/jakarta.xml.bind-api.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/javax.batch-api.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar:${j2ee.server.middleware}/mq/lib/jaxm-api.jar
j2ee.platform.classpath=${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/cdi-api.jar:${j2ee.server.home}/modules/endorsed/grizzly-npn-bootstrap.jar:${j2ee.server.home}/modules/endorsed/jakarta.annotation-api.jar:${j2ee.server.home}/modules/endorsed/jakarta.xml.bind-api.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/javax.batch-api.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar:${j2ee.server.middleware}/mq/lib/jaxm-api.jar
j2ee.platform.classpath=
j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar
j2ee.platform.wscompile.classpath=${j2ee.server.home}/modules/webservices-osgi.jar
j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
@Stateless
public class CreditCardEntitySessionBean implements CreditCardEntitySessionBeanLocal {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
@Local
public interface CreditCardEntitySessionBeanLocal {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
@Stateless
public class FaqSessionBean implements FaqSessionBeanLocal {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
@Local
public interface FaqSessionBeanLocal {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public interface MealEntitySessionBeanLocal {

public MealEntity retrieveMealById(Long mealId) throws MealNotFoundException;

public Long createNewMeal(MealEntity meal) throws InputDataValidationException, UnknownPersistenceException, MealExistsException;
public Long createNewMeal(MealEntity meal) throws InputDataValidationException, UnknownPersistenceException, MealExistsException;

public List<MealEntity> retrieveTop5MealEntityByRating();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
@Stateless
public class OTUserEntitySessionBean implements OTUserEntitySessionBeanLocal {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
@Local
public interface OTUserEntitySessionBeanLocal {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
@Stateless
public class PromoSessionBean implements PromoSessionBeanLocal {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
@Local
public interface PromoSessionBeanLocal {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
@Stateless
public class StaffEntitySessionBean implements StaffEntitySessionBeanLocal {
Expand Down Expand Up @@ -107,14 +107,14 @@ public StaffEntity staffLogin(String username, String password) throws InvalidLo
try {
StaffEntity staff = retrieveStaffByUsername(username);
String passwordHash = CryptographicHelper.getInstance().byteArrayToHexString(CryptographicHelper.getInstance().doMD5Hashing(password + staff.getSalt()));

System.out.println(passwordHash);
if (staff.getPassword().equals(passwordHash)) {
return staff;
} else {
throw new InvalidLoginCredentialException("Username does not exist or invalid password");
}
} catch (StaffNotFoundException ex) {
throw new InvalidLoginCredentialException("Username does not exist or invalid password");
throw new InvalidLoginCredentialException("Staff not found: " + ex.getMessage());
}
}

Expand All @@ -130,7 +130,7 @@ public void updateStaff(StaffEntity staff) throws StaffNotFoundException, Update
if (staffToUpdate.getUsername().equals(staff.getUsername())) {
staffToUpdate.setFirstname(staff.getFirstname());
staffToUpdate.setLastName(staff.getLastName());
staffToUpdate.setType(staff.getType());
staffToUpdate.setType(staff.getType());
} else {
throw new UpdateStaffException("Username of staff to be updated does not match exiting records");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
@Local
public interface StaffEntitySessionBeanLocal {
Expand Down
2 changes: 1 addition & 1 deletion OTFood-ejb/src/java/entity/FaqEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
@Entity
public class FaqEntity implements Serializable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
public class CardCreationException extends Exception {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
public class CreditCardExistException extends Exception {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
public class CreditCardNotFoundException extends Exception {

Expand Down
2 changes: 1 addition & 1 deletion OTFood-ejb/src/java/util/exception/FaqExistException.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
public class FaqExistException extends Exception {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
public class InputDataValidationException extends Exception {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
public class InvalidLoginCredentialException extends Exception {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
public class PromoCodeExistException extends Exception {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
public class PromotionNotFoundException extends Exception {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
public class StaffNotFoundException extends Exception {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
public class StaffUsernameExistException extends Exception {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
public class UnknownPersistenceException extends Exception {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
public class UpdateDriverException extends Exception {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
public class UpdateIngredientException extends Exception {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
public class UpdateStaffException extends Exception {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
public class UpdateUserException extends Exception {

Expand Down
2 changes: 1 addition & 1 deletion OTFood-ejb/src/java/util/exception/UserExistException.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
public class UserExistException extends Exception {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
public class UserNotFoundException extends Exception {

Expand Down
2 changes: 1 addition & 1 deletion OTFood-war/src/java/jsf/managedbean/FaqManagedBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
@Named(value = "faqManagedBean")
@RequestScoped
Expand Down
2 changes: 1 addition & 1 deletion OTFood-war/src/java/jsf/managedbean/FooterManagedBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
@Named(value = "footerManagedBean")
@RequestScoped
Expand Down
23 changes: 15 additions & 8 deletions OTFood-war/src/java/jsf/managedbean/IndexManagedBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@
import ejb.session.stateless.ReviewEntitySessionBeanLocal;
import entity.MealEntity;
import entity.ReviewEntity;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.inject.Named;
import javax.enterprise.context.RequestScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;

/**
*
Expand All @@ -30,25 +33,29 @@ public class IndexManagedBean {

@EJB(name = "MealEntitySessionBeanLocal")
private MealEntitySessionBeanLocal mealEntitySessionBeanLocal;

private List<MealEntity> top5Meals;
private List<ReviewEntity> latestReviews;
private List<RankingMeal> mealsWithRank;

public IndexManagedBean() {
mealsWithRank = new ArrayList<>();
top5Meals = new ArrayList<>();
mealsWithRank = new ArrayList<>();
}

@PostConstruct
public void postConstruct() {
top5Meals = mealEntitySessionBeanLocal.retrieveTop5MealEntityByRating();
latestReviews = reviewEntitySessionBeanLocal.retrieveLatestReviews();
for (int i = 0; i < top5Meals.size(); i++) {
mealsWithRank.add(new RankingMeal(top5Meals.get(i), i+1));
mealsWithRank.add(new RankingMeal(top5Meals.get(i), i + 1));
}


}

public void redirectToBentoPage(ActionEvent event) throws IOException {
FacesContext.getCurrentInstance().getExternalContext().redirect(FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath() + "/userPages/bento.xhtml");
}

public List<MealEntity> getTop5Meals() {
Expand All @@ -73,6 +80,6 @@ public List<ReviewEntity> getLatestReviews() {

public void setLatestReviews(List<ReviewEntity> latestReviews) {
this.latestReviews = latestReviews;
}
}
}

}
2 changes: 1 addition & 1 deletion OTFood-war/src/java/jsf/managedbean/LoginManagedBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

/**
*
* @author Mitsuki
* @author Ong Bik Jeun
*/
@Named(value = "loginManagedBean")
@RequestScoped
Expand Down
Loading

0 comments on commit 39e3042

Please sign in to comment.