From 6157211d6c0ce9372d1e3272c65817058818fe5b Mon Sep 17 00:00:00 2001 From: gopi17701 Date: Sat, 26 Jan 2019 21:34:36 -0500 Subject: [PATCH] Fixed defects. --- .../com/astute/model/CustomerContact.java | 107 ++++++++++++++++++ .../requests/CustomerContactRequest.java | 107 ++++++++++++++++++ .../astute/requests/ServiceTypeRequest.java | 28 +++++ .../resources/CustomerContactResource.java | 62 ++++++++++ .../astute/resources/ServiceTypeResource.java | 60 ++++++++++ .../service/CustomerContactService.java | 31 +++++ .../astute/service/ServiceTypeService.java | 34 ++++++ 7 files changed, 429 insertions(+) create mode 100644 AstuteSystem/src/main/java/com/astute/model/CustomerContact.java create mode 100644 AstuteSystem/src/main/java/com/astute/requests/CustomerContactRequest.java create mode 100644 AstuteSystem/src/main/java/com/astute/requests/ServiceTypeRequest.java create mode 100644 AstuteSystem/src/main/java/com/astute/resources/CustomerContactResource.java create mode 100644 AstuteSystem/src/main/java/com/astute/resources/ServiceTypeResource.java create mode 100644 AstuteSystem/src/main/java/com/astute/service/CustomerContactService.java create mode 100644 AstuteSystem/src/main/java/com/astute/service/ServiceTypeService.java diff --git a/AstuteSystem/src/main/java/com/astute/model/CustomerContact.java b/AstuteSystem/src/main/java/com/astute/model/CustomerContact.java new file mode 100644 index 0000000..1e4e579 --- /dev/null +++ b/AstuteSystem/src/main/java/com/astute/model/CustomerContact.java @@ -0,0 +1,107 @@ +package com.astute.model; + +public class CustomerContact { + String customerId; + int contactId; + String name; + String title; + int workPhone; + int phExt; + int mobile; + int fax; + String email; + String address; + + public CustomerContact(String customerId,int contactId,String name,String title,int workPhone,int phExt,int mobile, int fax, String email, String address) { + this.customerId = customerId; + this.contactId = contactId; + this.name = name; + this.title = title; + this.workPhone = workPhone; + this.phExt = phExt; + this.mobile = mobile; + this.fax = fax; + this.email = email; + this.address = address; + } + + public String getCustomerId() { + return customerId; + } + + public void setCustomerId(String customerId) { + this.customerId = customerId; + } + + public int getContactId() { + return contactId; + } + + public void setContactId(int contactId) { + this.contactId = contactId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public int getWorkPhone() { + return workPhone; + } + + public void setWorkPhone(int workPhone) { + this.workPhone = workPhone; + } + + public int getPhExt() { + return phExt; + } + + public void setPhExt(int phExt) { + this.phExt = phExt; + } + + public int getMobile() { + return mobile; + } + + public void setMobile(int mobile) { + this.mobile = mobile; + } + + public int getFax() { + return fax; + } + + public void setFax(int fax) { + this.fax = fax; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } +} diff --git a/AstuteSystem/src/main/java/com/astute/requests/CustomerContactRequest.java b/AstuteSystem/src/main/java/com/astute/requests/CustomerContactRequest.java new file mode 100644 index 0000000..d1a776c --- /dev/null +++ b/AstuteSystem/src/main/java/com/astute/requests/CustomerContactRequest.java @@ -0,0 +1,107 @@ +package com.astute.requests; + +public class CustomerContactRequest { + String customerId; + int contactId; + String name; + String title; + int workPhone; + int phExt; + int mobile; + int fax; + String email; + String address; + + public CustomerContactRequest(String customerId,int contactId,String name,String title,int workPhone,int phExt,int mobile, int fax, String email, String address) { + this.customerId = customerId; + this.contactId = contactId; + this.name = name; + this.title = title; + this.workPhone = workPhone; + this.phExt = phExt; + this.mobile = mobile; + this.fax = fax; + this.email = email; + this.address = address; + } + + public String getCustomerId() { + return customerId; + } + + public void setCustomerId(String customerId) { + this.customerId = customerId; + } + + public int getContactId() { + return contactId; + } + + public void setContactId(int contactId) { + this.contactId = contactId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public int getWorkPhone() { + return workPhone; + } + + public void setWorkPhone(int workPhone) { + this.workPhone = workPhone; + } + + public int getPhExt() { + return phExt; + } + + public void setPhExt(int phExt) { + this.phExt = phExt; + } + + public int getMobile() { + return mobile; + } + + public void setMobile(int mobile) { + this.mobile = mobile; + } + + public int getFax() { + return fax; + } + + public void setFax(int fax) { + this.fax = fax; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } +} diff --git a/AstuteSystem/src/main/java/com/astute/requests/ServiceTypeRequest.java b/AstuteSystem/src/main/java/com/astute/requests/ServiceTypeRequest.java new file mode 100644 index 0000000..6024c20 --- /dev/null +++ b/AstuteSystem/src/main/java/com/astute/requests/ServiceTypeRequest.java @@ -0,0 +1,28 @@ +package com.astute.requests; + +public class ServiceTypeRequest { + int serviceTypeId; + String desc; + + public int getServiceTypeId() { + return serviceTypeId; + } + + public void setServiceTypeId(int serviceTypeId) { + this.serviceTypeId = serviceTypeId; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public ServiceTypeRequest(int serviceTypeId, String desc) { + this.serviceTypeId = serviceTypeId; + this.desc = desc; + } + +} diff --git a/AstuteSystem/src/main/java/com/astute/resources/CustomerContactResource.java b/AstuteSystem/src/main/java/com/astute/resources/CustomerContactResource.java new file mode 100644 index 0000000..79faca4 --- /dev/null +++ b/AstuteSystem/src/main/java/com/astute/resources/CustomerContactResource.java @@ -0,0 +1,62 @@ +package com.astute.resources; + +import com.astute.exceptions.AstuteException; +import com.astute.requests.CustomerContactRequest; +import com.astute.requests.CustomerRequest; +import com.astute.response.ApiResponse; +import com.astute.service.AuthService; +import com.astute.service.CustomerContactService; +import com.astute.service.CustomerService; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.sql.SQLException; + +@Path("/customer/contact") +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +public class CustomerContactResource { + + private com.astute.service.CustomerContactService service = new CustomerContactService(); + private com.astute.service.AuthService authService = new AuthService(); + + public CustomerContactResource() { + } + + @GET + public Response getCustomerContacts(@QueryParam("customerId") String customerId) + throws AstuteException { + // TODO , @QueryParam("sessionId") String sessionId +// authService.getUser(sessionId); + return new ApiResponse(service.getCustomerContacts(customerId)).toResponse(); + } + + @Path("/{customerId}/{contactId}") + @PUT + public Response updateCustomerContact(@PathParam("customerId") String customerId, CustomerContactRequest request) + throws AstuteException { + System.out.println("in updateCustomerContact()"); + service.updateCustomerContact(customerId, request.getContactId(), request.getName(), request.getTitle(), request.getWorkPhone(), + request.getPhExt(), request.getMobile(), request.getFax(), request.getEmail(), request.getAddress()); + return new ApiResponse(ApiResponse.UPDATE_ACCESS_SUCESS).toResponse(); + } + + @Path("/{customerId}/{contactId}/delete") + @PUT + public Response deleteCustomerContact(@PathParam("customerId") String customerId, @PathParam("contactId") int contactId) + throws AstuteException { + System.out.println("in deleteCustomerContact()"); + service.deleteCustomerContact(customerId, contactId); + return new ApiResponse(ApiResponse.UPDATE_ACCESS_SUCESS).toResponse(); + } + + @POST + public Response createCustomerContact(CustomerContactRequest request) + throws AstuteException { + System.out.println("in AstuteSyste CustomerContactRequest()"); + service.createCustomerContact(request.getCustomerId(), request.getName(), request.getTitle(), request.getWorkPhone(), + request.getPhExt(), request.getMobile(), request.getFax(), request.getEmail(), request.getAddress()); + return new ApiResponse(ApiResponse.UPDATE_ACCESS_SUCESS).toResponse(); + } +} diff --git a/AstuteSystem/src/main/java/com/astute/resources/ServiceTypeResource.java b/AstuteSystem/src/main/java/com/astute/resources/ServiceTypeResource.java new file mode 100644 index 0000000..5042bb0 --- /dev/null +++ b/AstuteSystem/src/main/java/com/astute/resources/ServiceTypeResource.java @@ -0,0 +1,60 @@ +package com.astute.resources; + +import com.astute.exceptions.AstuteException; +import com.astute.requests.CustomerRequest; +import com.astute.requests.ServiceTypeRequest; +import com.astute.response.ApiResponse; +import com.astute.service.AuthService; +import com.astute.service.CustomerService; +import com.astute.service.ServiceTypeService; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.sql.SQLException; + +@Path("/serviceType") +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +public class ServiceTypeResource { + + private com.astute.service.ServiceTypeService service = new ServiceTypeService(); + private com.astute.service.AuthService authService = new AuthService(); + + public ServiceTypeResource() { + } + + @GET + public Response getServiceTypes() + throws AstuteException { + // TODO , @QueryParam("sessionId") String sessionId +// authService.getUser(sessionId); + return new ApiResponse(service.getServiceTypes()).toResponse(); + } + + @Path("/{serviceTypeId}") + @PUT + public Response updateServiceType(@PathParam("serviceTypeId") int serviceTypeId, @QueryParam("desc") String desc) + throws AstuteException { + System.out.println("in updateServiceType()"); + service.updateServiceType(serviceTypeId, desc); + return new ApiResponse(ApiResponse.UPDATE_ACCESS_SUCESS).toResponse(); + } + + @Path("/{serviceTypeId}/delete") + @PUT + public Response deleteServiceType(@PathParam("serviceTypeId") int serviceTypeId) + throws AstuteException { + System.out.println("in deleteServiceType()"); + service.deleteServiceType(serviceTypeId); + return new ApiResponse(ApiResponse.UPDATE_ACCESS_SUCESS).toResponse(); + } + + @POST + public Response createServiceType(ServiceTypeRequest request) + throws AstuteException { + System.out.println("in AstuteSyste createServiceType()"); + service.createServiceType(request.getDesc()); + return new ApiResponse(ApiResponse.UPDATE_ACCESS_SUCESS).toResponse(); + } +} diff --git a/AstuteSystem/src/main/java/com/astute/service/CustomerContactService.java b/AstuteSystem/src/main/java/com/astute/service/CustomerContactService.java new file mode 100644 index 0000000..ec8a065 --- /dev/null +++ b/AstuteSystem/src/main/java/com/astute/service/CustomerContactService.java @@ -0,0 +1,31 @@ +package com.astute.service; + +import com.astute.exceptions.AstuteException; +import com.astute.model.CustomerContact; + +import java.util.List; + +import static com.astute.dao.DAO.getDao; + +public class CustomerContactService extends Service{ + public CustomerContactService(){ + super(); + } + + public List getCustomerContacts(String customerId) + throws AstuteException { + return getDao().getCustomerContacts(customerId); + } + + public String createCustomerContact(String customerId, String name,String title,int workPhone,int phExt,int mobile, int fax, String email, String address) throws AstuteException { + return getDao().createCustomerContact(customerId, name, title, workPhone, phExt, mobile, fax, email, address); + } + + public void updateCustomerContact(String customerId, int contactId, String name,String title,int workPhone,int phExt,int mobile, int fax, String email, String address) throws AstuteException { + getDao().updateCustomerContact(customerId, contactId, name,title,workPhone,phExt,mobile, fax, email, address); + } + + public void deleteCustomerContact(String customerId, int contactId) throws AstuteException { + getDao().deleteCustomerContact(customerId, contactId); + } +} diff --git a/AstuteSystem/src/main/java/com/astute/service/ServiceTypeService.java b/AstuteSystem/src/main/java/com/astute/service/ServiceTypeService.java new file mode 100644 index 0000000..8838e33 --- /dev/null +++ b/AstuteSystem/src/main/java/com/astute/service/ServiceTypeService.java @@ -0,0 +1,34 @@ +package com.astute.service; + +import com.astute.exceptions.AstuteException; +import com.astute.model.ServiceType; +import com.astute.model.User; + +import java.util.List; + +import static com.astute.dao.DAO.getDao; +import static com.astute.exceptions.AstuteException.AUTH_ERROR; + +public class ServiceTypeService extends Service{ + public ServiceTypeService(){ + super(); + } + + public List getServiceTypes() + throws AstuteException { + return getDao().getServiceTypes(); + } + + public void createServiceType(String desc) throws AstuteException { + getDao().createServiceType(desc); + } + + public void updateServiceType(int serviceTypeId, String desc) throws AstuteException { + getDao().updateServiceType(serviceTypeId, desc); + } + + public void deleteServiceType(int serviceTypeId) throws AstuteException { + getDao().deleteServiceType(serviceTypeId); + } + +}