Fixed defects.

This commit is contained in:
gopi17701 2019-01-26 21:34:36 -05:00
parent 91a5c8f590
commit 6157211d6c
7 changed files with 429 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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<CustomerContact> 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);
}
}

View File

@ -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<ServiceType> 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);
}
}