-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
49 changed files
with
2,034 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 4 additions & 5 deletions
9
...em/booking-core/src/main/java/org/ticketbooking/core/api/config/ApiApplicationConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...BookingSystem/booking-core/src/main/java/org/ticketbooking/core/api/jaxb/other/Links.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.ticketbooking.core.api.jaxb.other; | ||
|
||
import javax.xml.bind.annotation.XmlElement; | ||
import javax.xml.bind.annotation.XmlRootElement; | ||
|
||
@XmlRootElement(name = "links") | ||
public class Links { | ||
private String relationType; | ||
private String url; | ||
|
||
public Links(String relationType, String url) { | ||
super(); | ||
this.relationType = relationType; | ||
this.url = url; | ||
} | ||
public Links() {} | ||
|
||
@XmlElement(name="rel") | ||
public String getRelationType() { | ||
return relationType; | ||
} | ||
public void setRelationType(String relationType) { | ||
this.relationType = relationType; | ||
} | ||
@XmlElement(name="_href") | ||
public String getUrl() { | ||
return url; | ||
} | ||
public void setUrl(String url) { | ||
this.url = url; | ||
} | ||
|
||
|
||
} |
52 changes: 52 additions & 0 deletions
52
...ookingSystem/booking-core/src/main/java/org/ticketbooking/core/api/jaxb/user/Address.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.ticketbooking.core.api.jaxb.user; | ||
|
||
import javax.xml.bind.annotation.XmlElement; | ||
import javax.xml.bind.annotation.XmlRootElement; | ||
|
||
@XmlRootElement(name="addresses") | ||
public class Address { | ||
private String street1; | ||
private String street2; | ||
private String state; | ||
private String country; | ||
private Long pin; | ||
|
||
@XmlElement(name="street1") | ||
public String getStreet1() { | ||
return street1; | ||
} | ||
public void setStreet1(String street1) { | ||
this.street1 = street1; | ||
} | ||
|
||
@XmlElement(name="street2") | ||
public String getStreet2() { | ||
return street2; | ||
} | ||
public void setStreet2(String street2) { | ||
this.street2 = street2; | ||
} | ||
@XmlElement(name="state") | ||
public String getState() { | ||
return state; | ||
} | ||
public void setState(String state) { | ||
this.state = state; | ||
} | ||
@XmlElement(name="country") | ||
public String getCountry() { | ||
return country; | ||
} | ||
public void setCountry(String country) { | ||
this.country = country; | ||
} | ||
@XmlElement(name="pin") | ||
public Long getPin() { | ||
return pin; | ||
} | ||
public void setPin(Long pin) { | ||
this.pin = pin; | ||
} | ||
|
||
|
||
} |
93 changes: 93 additions & 0 deletions
93
...ngSystem/booking-core/src/main/java/org/ticketbooking/core/api/jaxb/user/UserDetails.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package org.ticketbooking.core.api.jaxb.user; | ||
|
||
import java.util.List; | ||
|
||
import javax.xml.bind.annotation.XmlElement; | ||
import javax.xml.bind.annotation.XmlElementWrapper; | ||
import javax.xml.bind.annotation.XmlRootElement; | ||
|
||
import org.ticketbooking.core.api.jaxb.other.Links; | ||
|
||
|
||
@XmlRootElement(name="user") | ||
public class UserDetails { | ||
|
||
private String userName; | ||
private String password; | ||
private String firstName; | ||
private String middleName; | ||
private String lastName; | ||
private String email; | ||
private String phone; | ||
private List<Address> addresses; | ||
private List<Links> links; | ||
|
||
@XmlElement(name="username") | ||
public String getUserName() { | ||
return userName; | ||
} | ||
public void setUserName(String userName) { | ||
this.userName = userName; | ||
} | ||
// @XmlElement(name="password") | ||
public String getPassword() { | ||
return password; | ||
} | ||
public void setPassword(String password) { | ||
this.password = password; | ||
} | ||
@XmlElement(name="firstname") | ||
public String getFirstName() { | ||
return firstName; | ||
} | ||
public void setFirstName(String firstName) { | ||
this.firstName = firstName; | ||
} | ||
@XmlElement(name="middlename") | ||
public String getMiddleName() { | ||
return middleName; | ||
} | ||
public void setMiddleName(String middleName) { | ||
this.middleName = middleName; | ||
} | ||
@XmlElement(name="lastname") | ||
public String getLastName() { | ||
return lastName; | ||
} | ||
public void setLastName(String lastName) { | ||
this.lastName = lastName; | ||
} | ||
@XmlElement(name="email") | ||
public String getEmail() { | ||
return email; | ||
} | ||
public void setEmail(String email) { | ||
this.email = email; | ||
} | ||
@XmlElement(name="phone") | ||
public String getPhone() { | ||
return phone; | ||
} | ||
public void setPhone(String phone) { | ||
this.phone = phone; | ||
} | ||
@XmlElementWrapper | ||
@XmlElement(name="address") | ||
public List<Address> getAddresses() { | ||
return addresses; | ||
} | ||
public void setAddresses(List<Address> addresses) { | ||
this.addresses = addresses; | ||
} | ||
@XmlElementWrapper | ||
@XmlElement(name="link") | ||
public List<Links> getLinks() { | ||
return links; | ||
} | ||
public void setLinks(List<Links> links) { | ||
this.links = links; | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...ing-core/src/main/java/org/ticketbooking/core/api/web/customer/CusomerApiServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package org.ticketbooking.core.api.web.customer; | ||
|
||
import javax.annotation.Resource; | ||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.POST; | ||
import javax.ws.rs.PUT; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.Response; | ||
import javax.ws.rs.core.Response.Status; | ||
|
||
import org.springframework.stereotype.Service; | ||
import org.ticketbooking.core.api.jaxb.user.UserDetails; | ||
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; | ||
|
||
@Path("/user") | ||
@Service("apiCustomer") | ||
public class CusomerApiServiceImpl implements CustomerApiService{ | ||
|
||
@Resource(name="customerService") | ||
CustomerService customerService; | ||
|
||
@Resource(name="addressHelper") | ||
AddressHelper addressHelper; | ||
|
||
@POST | ||
@Produces(value={MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) | ||
@Consumes(value={MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) | ||
public Response createCustomer(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.setAddresses(addressHelper.convertAddressEntity(userDetails.getAddresses())); | ||
customer.setUsername(userDetails.getUserName()); | ||
customer.setUsername(userDetails.getUserName()); | ||
customerService.createCustomer(customer); | ||
|
||
return Response.status(Status.CREATED).header("X-header-message", "User created").build(); | ||
} | ||
|
||
@Path("/{username}") | ||
@PUT | ||
@Produces(value={MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) | ||
@Consumes(value={MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) | ||
public Response updateCustomer(UserDetails details) { | ||
return null; | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
...ooking-core/src/main/java/org/ticketbooking/core/api/web/customer/CustomerApiService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.ticketbooking.core.api.web.customer; | ||
|
||
import javax.ws.rs.core.Response; | ||
|
||
import org.ticketbooking.core.api.jaxb.user.UserDetails; | ||
|
||
public interface CustomerApiService { | ||
Response createCustomer(UserDetails details); | ||
Response updateCustomer(UserDetails details); | ||
} |
13 changes: 13 additions & 0 deletions
13
...okingSystem/booking-core/src/main/java/org/ticketbooking/core/dao/address/AddressDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.ticketbooking.core.dao.address; | ||
|
||
import java.util.List; | ||
|
||
import org.ticketbooking.core.domain.user.AddressImpl; | ||
|
||
public interface AddressDao { | ||
void createAddress(AddressImpl address); | ||
void deleteAddress(Long id); | ||
AddressImpl fetchAddress(Long id); | ||
List<AddressImpl> fetchAddressByCustomer(Long customerId); | ||
void updateAddress(AddressImpl address); | ||
} |
42 changes: 42 additions & 0 deletions
42
...gSystem/booking-core/src/main/java/org/ticketbooking/core/dao/address/AddressDaoImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.ticketbooking.core.dao.address; | ||
|
||
import java.util.List; | ||
|
||
import javax.persistence.EntityManager; | ||
import javax.persistence.PersistenceContext; | ||
import javax.persistence.Query; | ||
|
||
import org.springframework.stereotype.Repository; | ||
import org.ticketbooking.core.domain.user.AddressImpl; | ||
|
||
@Repository("addressDao") | ||
public class AddressDaoImpl implements AddressDao{ | ||
|
||
@PersistenceContext | ||
EntityManager entityManager; | ||
|
||
public void createAddress(AddressImpl address) { | ||
entityManager.persist(address); | ||
} | ||
|
||
public void deleteAddress(Long id) { | ||
AddressImpl address = fetchAddress(id); | ||
entityManager.remove(address); | ||
} | ||
|
||
public AddressImpl fetchAddress(Long id) { | ||
return entityManager.find(AddressImpl.class, id); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public List<AddressImpl> fetchAddressByCustomer(Long customerId) { | ||
Query query = entityManager.createNamedQuery("AddressImpl.fetchByCustomer"); | ||
query.setParameter("id", customerId); | ||
return query.getResultList(); | ||
} | ||
|
||
public void updateAddress(AddressImpl address) { | ||
entityManager.merge(address); | ||
} | ||
|
||
} |
Oops, something went wrong.