Skip to content

Commit

Permalink
OOAD , Workflow , SMTP Mail Service Integrated
Browse files Browse the repository at this point in the history
  • Loading branch information
cooligc committed Sep 5, 2015
1 parent ae20ff3 commit ec15e3c
Show file tree
Hide file tree
Showing 58 changed files with 2,453 additions and 200 deletions.
4 changes: 4 additions & 0 deletions TicketBookingSystem/booking-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>


<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.ticketbooking.core.api.web.customer;

import javax.annotation.Resource;

import org.ticketbooking.core.api.jaxb.user.UserDetails;
import org.ticketbooking.core.domain.user.Customer;
import org.ticketbooking.core.service.customer.CustomerService;

public abstract class AbstractCustomerApiService implements CustomerApiService {

@Resource(name = "customerService")
protected CustomerService customerService;

protected Customer performCustomerCreation(UserDetails userDetails) {
return customerService.performCustomerCreation(userDetails);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.ticketbooking.core.api.web.customer;

import java.util.Set;

import javax.annotation.Resource;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
Expand All @@ -14,10 +12,6 @@

import org.springframework.stereotype.Service;
import org.ticketbooking.core.api.jaxb.user.UserDetails;
import org.ticketbooking.core.domain.user.AddressImpl;
import org.ticketbooking.core.domain.user.Customer;
import org.ticketbooking.core.domain.user.CustomerImpl;
import org.ticketbooking.core.helper.AddressHelper;
import org.ticketbooking.core.service.customer.CustomerService;

import com.wordnik.swagger.annotations.Api;
Expand All @@ -27,37 +21,24 @@
@Api(value="CustomerDetails",description="Service to get the details about Customer")
@Path("/user")
@Service("apiCustomer")
public class CusomerApiServiceImpl implements CustomerApiService{
public class CusomerApiServiceImpl extends AbstractCustomerApiService {

@Resource(name="customerService")
CustomerService customerService;

@Resource(name="addressHelper")
AddressHelper addressHelper;


@ApiOperation(httpMethod="POST",value="To create a customer")
@POST
@Produces(value={MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
@Consumes(value={MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
public Response createCustomer(@ApiParam(name="userDetails",value="XML/JSON for creating user")UserDetails userDetails) {

Customer customer = new CustomerImpl();
customer.setUsername(userDetails.getUserName());
customer.setFirstName(userDetails.getFirstName());
customer.setLastName(userDetails.getLastName());
customer.setMiddleName(userDetails.getMiddleName());
customer.setEmail(userDetails.getEmail());
customer.setPhone(userDetails.getPhone());
customer.setPassword(userDetails.getPassword());
customer.setUsername(userDetails.getUserName());
customerService.createCustomer(customer);
Set<AddressImpl> address = addressHelper.convertAddressEntity(userDetails.getAddresses());
//TODO Logic to be changed
addressHelper.createCustomerAddress(customer,address.iterator().next());
performCustomerCreation(userDetails);
return Response.status(Status.CREATED).header("X-header-message", "User created").build();
}




@Path("/{username}")
@PUT
@Produces(value={MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.ticketbooking.core.dao.address;

import org.ticketbooking.core.domain.user.AddressImpl;
import org.ticketbooking.core.domain.user.Address;

public interface AddressDao {
void createAddress(AddressImpl address);
void createAddress(Address address);
void deleteAddress(Long id);
AddressImpl fetchAddress(Long id);
Address fetchAddress(Long id);
//List<AddressImpl> fetchAddressByCustomer(Long customerId);
void updateAddress(AddressImpl address);
void updateAddress(Address address);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Repository;
import org.ticketbooking.core.domain.user.Address;
import org.ticketbooking.core.domain.user.AddressImpl;

@Repository("addressDao")
Expand All @@ -12,16 +13,16 @@ public class AddressDaoImpl implements AddressDao{
@PersistenceContext
EntityManager entityManager;

public void createAddress(AddressImpl address) {
public void createAddress(Address address) {
entityManager.persist(address);
}

public void deleteAddress(Long id) {
AddressImpl address = fetchAddress(id);
Address address = fetchAddress(id);
entityManager.remove(address);
}

public AddressImpl fetchAddress(Long id) {
public Address fetchAddress(Long id) {
return entityManager.find(AddressImpl.class, id);
}

Expand All @@ -32,7 +33,7 @@ public List<AddressImpl> fetchAddressByCustomer(Long customerId) {
return query.getResultList();
}*/

public void updateAddress(AddressImpl address) {
public void updateAddress(Address address) {
entityManager.merge(address);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package org.ticketbooking.core.dao.address.country;

import org.ticketbooking.core.domain.user.Country;
import org.ticketbooking.core.domain.user.CountryImpl;

public interface CountryDao {
void createCountry(CountryImpl country);
void createCountry(Country country);
CountryImpl fetchCountry(Long id);
CountryImpl fetchCountryByName(String name);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import javax.persistence.Query;

import org.springframework.stereotype.Repository;
import org.ticketbooking.core.domain.user.Country;
import org.ticketbooking.core.domain.user.CountryImpl;

@Repository("countryDao")
Expand All @@ -13,7 +14,7 @@ public class CountryDaoImpl implements CountryDao{
@PersistenceContext
EntityManager entityManager;

public void createCountry(CountryImpl country) {
public void createCountry(Country country) {
entityManager.persist(country);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.ticketbooking.core.dao.address.state;

import org.ticketbooking.core.domain.user.StateImpl;
import org.ticketbooking.core.domain.user.State;

public interface StateDao {
void createState(StateImpl state);
StateImpl fetchState(Long id);
StateImpl fetchStateByName(String name);
void createState(State state);
State fetchState(Long id);
State fetchStateByName(String name);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import javax.persistence.Query;

import org.springframework.stereotype.Repository;
import org.ticketbooking.core.domain.user.State;
import org.ticketbooking.core.domain.user.StateImpl;

@Repository("stateDao")
Expand All @@ -13,15 +14,15 @@ public class StateDaoImpl implements StateDao{
@PersistenceContext
EntityManager entityManager;

public void createState(StateImpl state) {
public void createState(State state) {
entityManager.persist(state);
}

public StateImpl fetchState(Long id) {
public State fetchState(Long id) {
return entityManager.find(StateImpl.class, id);
}

public StateImpl fetchStateByName(String name) {
public State fetchStateByName(String name) {
Query query = entityManager.createNamedQuery("StateImpl.fetchByStateName");
query.setParameter("name", name);
return (StateImpl) query.getSingleResult();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package org.ticketbooking.core.dao.customer.address;

import org.ticketbooking.core.domain.user.CustomerAddressImpl;


import org.ticketbooking.core.domain.user.CustomerAddress;

public interface CustomerAddressDao{
void createCustomerAddress(CustomerAddressImpl customerAddress);
void createCustomerAddress(CustomerAddress customerAddress);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Repository;
import org.ticketbooking.core.domain.user.CustomerAddressImpl;
import org.ticketbooking.core.domain.user.CustomerAddress;

@Repository("customerAddressDao")
public class CustomerAddressDaoImpl implements CustomerAddressDao{

@PersistenceContext
EntityManager entityManager;
public void createCustomerAddress(CustomerAddressImpl customerAddress){

public void createCustomerAddress(CustomerAddress customerAddress) {
entityManager.persist(customerAddress);
}



}
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package org.ticketbooking.core.domain.other;

import java.io.Serializable;

import org.ticketbooking.core.domain.user.Country;
import org.ticketbooking.core.domain.user.CountryImpl;


public interface Locale {
public interface Locale extends Serializable{
public Long getId();
public void setId(Long id);
public String getName();
public void setName(String name);
public String getTimeZone();
public void setTimeZone(String timeZone);
public Country getCountry();
public void setCountry(CountryImpl country);
public void setCountry(Country country);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.ticketbooking.core.domain.other;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
Expand All @@ -16,7 +14,7 @@

@Entity
@Table(name="TBS_LOCALE")
public class LocaleImpl implements Serializable,Locale{
public class LocaleImpl implements Locale{
/**
*
*/
Expand All @@ -33,9 +31,9 @@ public class LocaleImpl implements Serializable,Locale{
@Column(name="TBS_LOCALE_TIMEZONE")
private String timeZone;

@OneToOne
@OneToOne(targetEntity=CountryImpl.class)
@PrimaryKeyJoinColumn
CountryImpl country;
Country country;

public Long getId() {
return id;
Expand All @@ -58,7 +56,7 @@ public void setTimeZone(String timeZone) {
public Country getCountry() {
return country;
}
public void setCountry(CountryImpl country) {
public void setCountry(Country country) {
this.country = country;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public interface Address extends Serializable{
public Long getPin();
public void setPin(Long pin);
public State getState();
public void setState(StateImpl state);
public void setState(State state);
public boolean isDefaultAddress();
public void setDefaultAddress(boolean isDefaultAddress);
public boolean isActiveAddress();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public class AddressImpl implements Address{
@Column(name="TBS_ACTIVE_ADDRESS")
private boolean isActiveAddress;

@ManyToOne
@ManyToOne(targetEntity=StateImpl.class)
@JoinColumn(name="TBS_STATE_ID",nullable=false)
private StateImpl state;
private State state;


public Long getId() {
Expand Down Expand Up @@ -88,7 +88,7 @@ public State getState() {
return state;
}

public void setState(StateImpl state) {
public void setState(State state) {
this.state = state;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package org.ticketbooking.core.domain.user;

import org.ticketbooking.core.domain.other.Locale;
import org.ticketbooking.core.domain.other.LocaleImpl;

public interface Country {
public Long getId();
public void setId(Long id);
public String getName();
public void setName(String name);
public Locale getLocale();
public void setLocale(LocaleImpl locale);
public void setLocale(Locale locale);
public State getState();
public void setState(StateImpl state);
public void setState(State state);
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ public class CountryImpl implements Serializable,Country{
@Column(name="TBS_COUNTRY_NAME",unique=true)
private String name;

@OneToOne(mappedBy="country",cascade=CascadeType.ALL)
private LocaleImpl locale;
@OneToOne(mappedBy="country",cascade=CascadeType.ALL,targetEntity=LocaleImpl.class)
private Locale locale;

@OneToOne(mappedBy="country",cascade=CascadeType.ALL)
private StateImpl state;
@OneToOne(mappedBy="country",cascade=CascadeType.ALL,targetEntity=StateImpl.class)
private State state;

public Long getId() {
return id;
Expand All @@ -62,15 +62,15 @@ public Locale getLocale() {
return locale;
}

public void setLocale(LocaleImpl locale) {
public void setLocale(Locale locale) {
this.locale = locale;
}

public State getState() {
return state;
}

public void setState(StateImpl state) {
public void setState(State state) {
this.state = state;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ public interface Customer extends Serializable {
public void setPhone(String phone);
public boolean isActive();
public void setActive(boolean isActive);

public boolean isVarified();
public void setVarified(boolean isVarified);
}
Loading

0 comments on commit ec15e3c

Please sign in to comment.