-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Sasankavikum/IT20072506
stock model class
- Loading branch information
Showing
20 changed files
with
366 additions
and
151 deletions.
There are no files selected for viewing
File renamed without changes.
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,87 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Querys> | ||
|
||
<query id="insert_employeedetails"> | ||
<![CDATA[ | ||
insert into employee_details(empFullName, empNIC, empGender, empEmail, empAge, empAddress, empContactNo, empCategory) | ||
values (?, ?, ?, ?, ?, ?, ?, ?) | ||
]]> | ||
</query> | ||
|
||
<query id="all_employeedetails"> | ||
<![CDATA[ | ||
select empId, empFullName, empNIC, empGender, empEmail, empAge, empAddress, empContactNo, empCategory | ||
from employee_details | ||
]]> | ||
</query> | ||
|
||
<query id="employeedetails_by_id"> | ||
<![CDATA[ | ||
select empid, empFullName, empNIC, empGender, empEmail, empAge, empAddress, empContactNo, empCategory | ||
from employee_details | ||
where empId = ? | ||
]]> | ||
</query> | ||
|
||
<query id="remove_employeedetails"> | ||
<![CDATA[ | ||
delete from employee_details where empId = ? | ||
]]> | ||
</query> | ||
|
||
<query id="update_employeedetails"> | ||
<![CDATA[ | ||
update employee_details as g | ||
set g.empFullName = ?, g.empNIC = ?, g.empGender = ?, g.empEmail = ?, | ||
g.empAge = ?, g.empAddress = ?, g.empContactNo = ?, g.empCategory = ? | ||
where g.empId = ? | ||
]]> | ||
</query> | ||
|
||
|
||
<query id="insert_vaccinedetails"> | ||
<![CDATA[ | ||
insert into vaccine_details(batch_number, vaccine_name, receive_date, country, expire_date, quantity) | ||
values (?, ?, ?, ?, ?, ?) | ||
]]> | ||
</query> | ||
|
||
<query id="all_vaccinedetails"> | ||
<![CDATA[ | ||
select vaccineNo, batch_number, vaccine_name, receive_date, country, expire_date, quantity | ||
from vaccine_details | ||
]]> | ||
</query> | ||
|
||
<query id="vaccinedetails_by_id"> | ||
<![CDATA[ | ||
select vaccineNo, batch_number, vaccine_name, receive, country, expire, quantity | ||
from vaccine_details | ||
where vaccineNo = ? | ||
]]> | ||
</query> | ||
|
||
<query id="remove_vaccinedetails"> | ||
<![CDATA[ | ||
delete from vaccine_details where vaccineNo = ? | ||
]]> | ||
</query> | ||
|
||
<query id="update_vaccinedetails"> | ||
<![CDATA[ | ||
update vaccine_details as g | ||
set g.batch_number = ?, g.vaccine_name = ?, g.receive = ?, g.country = ?, | ||
g.expire = ?, g.quantity = ? | ||
where g.vaccineNo = ? | ||
]]> | ||
</query> | ||
|
||
<query id="print_vaccinedetails"> | ||
<![CDATA[ | ||
select vaccineName, COUNT(*) as count | ||
from vaccine_details | ||
group by vaccineName | ||
]]> | ||
</query> | ||
|
||
</Querys> |
Binary file not shown.
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,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"> | ||
<display-name>Red Cross Support Service</display-name> | ||
<welcome-file-list> | ||
<welcome-file>index.jsp</welcome-file> | ||
</welcome-file-list> | ||
</web-app> |
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,71 @@ | ||
package com.rcss.model; | ||
|
||
public class VaccineDetails { | ||
private int vaccineNo; | ||
private String batch_number; | ||
private String vaccine_name; | ||
private String receive_date; | ||
private String country; | ||
private String expire_date; | ||
private int quantity; | ||
|
||
public VaccineDetails() { | ||
super(); | ||
} | ||
public VaccineDetails(int vaccineNo, String batch_number, String vaccine_name, String receive_date, String country, | ||
String expire_date, int quantity) { | ||
super(); | ||
this.vaccineNo = vaccineNo; | ||
this.batch_number = batch_number; | ||
this.vaccine_name = vaccine_name; | ||
this.receive_date = receive_date; | ||
this.country = country; | ||
this.expire_date = expire_date; | ||
this.quantity = quantity; | ||
} | ||
|
||
public int getVaccineNo() { | ||
return vaccineNo; | ||
} | ||
public String getBatch_number() { | ||
return batch_number; | ||
} | ||
public String getVaccine_name() { | ||
return vaccine_name; | ||
} | ||
public String getReceive_date() { | ||
return receive_date; | ||
} | ||
public String getCountry() { | ||
return country; | ||
} | ||
public String getExpire_date() { | ||
return expire_date; | ||
} | ||
public int getQuantity() { | ||
return quantity; | ||
} | ||
public void setVaccineNo(int vaccineNo) { | ||
this.vaccineNo = vaccineNo; | ||
} | ||
public void setBatch_number(String batch_number) { | ||
this.batch_number = batch_number; | ||
} | ||
public void setVaccine_name(String vaccine_name) { | ||
this.vaccine_name = vaccine_name; | ||
} | ||
public void setReceive_date(String receive_date) { | ||
this.receive_date = receive_date; | ||
} | ||
public void setCountry(String country) { | ||
this.country = country; | ||
} | ||
public void setExpire_date(String expire_date) { | ||
this.expire_date = expire_date; | ||
} | ||
public void setQuantity(int quantity) { | ||
this.quantity = quantity; | ||
} | ||
|
||
|
||
} |
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,71 @@ | ||
package com.rcss.servlet; | ||
|
||
import java.io.IOException; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import javax.servlet.http.HttpSession; | ||
import javax.xml.ws.WebEndpoint; | ||
|
||
import com.rcss.model.VaccineDetails; | ||
import com.rcss.service.IVaccineDetailsService; | ||
import com.rcss.service.VaccineDetailsServiceImpl; | ||
|
||
@WebServlet("/VaccineDetails") | ||
public class VaccineDetailsServlet extends HttpServlet { | ||
private static final long serialVersionUID = 1L; | ||
|
||
public VaccineDetailsServlet() { | ||
super(); | ||
} | ||
|
||
@WebEndpoint | ||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
response.sendRedirect("/RedCrossSupportService/VaccineDetails/index.jsp"); | ||
} | ||
|
||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
String action = request.getParameter("action"); | ||
|
||
if(action.equalsIgnoreCase("NE")) { | ||
IVaccineDetailsService vaccineService = new VaccineDetailsServiceImpl(); | ||
vaccineService.addVaccineDetail(new VaccineDetails( | ||
0, | ||
request.getParameter("batch_number"), | ||
request.getParameter("vaccine_name"), | ||
request.getParameter("receive_date"), | ||
request.getParameter("country"), | ||
request.getParameter("expire_date"), | ||
Integer.parseInt(request.getParameter("quantity")) | ||
)); | ||
|
||
response.sendRedirect("/RedCrossSupportService/VaccineDetails/index.jsp"); | ||
} | ||
else if(action.equalsIgnoreCase("UP")) { | ||
IVaccineDetailsService vaccineService = new VaccineDetailsServiceImpl(); | ||
vaccineService.updateVaccine(Integer.parseInt(request.getParameter("vaccineNo")), new VaccineDetails( | ||
Integer.parseInt(request.getParameter("vaccineNo")), | ||
request.getParameter("batch_number"), | ||
request.getParameter("vaccine_name"), | ||
request.getParameter("receive_date"), | ||
request.getParameter("country"), | ||
request.getParameter("expire_date"), | ||
Integer.parseInt(request.getParameter("quantity")) | ||
)); | ||
|
||
response.sendRedirect("/RedCrossSupportService/VaccineDetails/index.jsp"); | ||
} | ||
else if(action.equalsIgnoreCase("DL")) { | ||
IVaccineDetailsService vaccineService = new VaccineDetailsServiceImpl(); | ||
vaccineService.removeVaccineDetail(Integer.parseInt(request.getParameter("vaccineNo"))); | ||
|
||
response.sendRedirect("/RedCrossSupportService/VaccineDetails/index.jsp"); | ||
} | ||
else if(action.equalsIgnoreCase("PR")) { | ||
response.sendRedirect("/RedCrossSupportService/VaccineDetails/vaccineprint.jsp"); | ||
} | ||
} | ||
|
||
} |
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,43 @@ | ||
package com.rcss.util; | ||
|
||
public class CommonConstants { | ||
|
||
public static final String PROPERTY_FILE = "config.properties"; | ||
public static final String TAG_NAME = "query"; | ||
public static final String ATTRIB_ID = "id"; | ||
public static final String URL = "url"; | ||
public static final String USERNAME = "username"; | ||
public static final String PASSWORD = "password"; | ||
public static final String DRIVER_NAME = "driverName"; | ||
|
||
public static final String COMPANY_NAME = "Red Cross Support Service"; | ||
public static final String COMPANY_ADDRESS = "Red Cross, Weera Madduma Bandara Mawatha, Kandy"; | ||
public static final String CONTACT_NO = "0812 222 100"; | ||
|
||
public static final int COLUMN_INDEX_ONE = 1; | ||
public static final int COLUMN_INDEX_TWO = 2; | ||
public static final int COLUMN_INDEX_THREE = 3; | ||
public static final int COLUMN_INDEX_FOUR = 4; | ||
public static final int COLUMN_INDEX_FIVE = 5; | ||
public static final int COLUMN_INDEX_SIX = 6; | ||
public static final int COLUMN_INDEX_SEVEN = 7; | ||
public static final int COLUMN_INDEX_EIGHT = 8; | ||
public static final int COLUMN_INDEX_NINE = 9; | ||
public static final int COLUMN_INDEX_TEN = 10; | ||
public static final int COLUMN_INDEX_ELEVEN = 11; | ||
public static final int COLUMN_INDEX_TWELVE = 12; | ||
public static final int COLUMN_INDEX_THIRTEEN = 13; | ||
|
||
public static final String QUERY_ID_INSERT_EMPLOYEE = "insert_employeedetails"; | ||
public static final String QUERY_ID_ALL_EMPLOYEE = "all_employeedetails"; | ||
public static final String QUERY_ID_GET_EMPLOYEE = "employeedetails_by_id"; | ||
public static final String QUERY_ID_DELETE_EMPLOYEE = "remove_employeedetails"; | ||
public static final String QUERY_ID_UPDATE_EMPLOYEE = "update_employeedetails"; | ||
|
||
public static final String QUERY_ID_INSERT_VACCINE = "insert_vaccinedetails"; | ||
public static final String QUERY_ID_ALL_VACCINE = "all_vaccinedetails"; | ||
public static final String QUERY_ID_GET_VACCINE = "vaccinedetails_by_id"; | ||
public static final String QUERY_ID_DELETE_VACCINE = "remove_vaccinedetails"; | ||
public static final String QUERY_ID_UPDATE_VACCINE = "update_vaccinedetails"; | ||
public static final String QUERY_ID_PRINT_VACCINE = "print_vaccinedetails"; | ||
} |
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,22 @@ | ||
package com.rcss.util; | ||
|
||
import java.io.IOException; | ||
import java.util.Properties; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
import com.rcss.service.IEmployeeDetailsService; | ||
|
||
public class CommonUtil { | ||
|
||
public static final Logger log = Logger.getLogger(IEmployeeDetailsService.class.getName()); | ||
public static final Properties properties = new Properties(); | ||
|
||
static { | ||
try { | ||
properties.load(QueryUtil.class.getResourceAsStream(CommonConstants.PROPERTY_FILE)); | ||
} catch (IOException e) { | ||
log.log(Level.SEVERE, e.getMessage()); | ||
} | ||
} | ||
} |
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,32 @@ | ||
package com.rcss.util; | ||
|
||
import java.sql.Connection; | ||
import java.sql.DriverManager; | ||
import java.sql.SQLException; | ||
|
||
public class DBConnectionUtil extends CommonUtil { | ||
|
||
private static Connection connection; | ||
|
||
private DBConnectionUtil() { } | ||
|
||
public static Connection getDBConnection() throws ClassNotFoundException, SQLException { | ||
if (connection == null || connection.isClosed()) { | ||
|
||
Class.forName(properties.getProperty(CommonConstants.DRIVER_NAME)); | ||
connection = DriverManager.getConnection(properties.getProperty(CommonConstants.URL), | ||
properties.getProperty(CommonConstants.USERNAME), properties.getProperty(CommonConstants.PASSWORD)); | ||
} | ||
return connection; | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
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,28 @@ | ||
package com.rcss.util; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import javax.xml.parsers.DocumentBuilderFactory; | ||
import javax.xml.parsers.ParserConfigurationException; | ||
import org.w3c.dom.Element; | ||
import org.w3c.dom.NodeList; | ||
import org.xml.sax.SAXException; | ||
|
||
public class QueryUtil extends CommonUtil { | ||
|
||
public static String queryByID(String id) throws SAXException, IOException, ParserConfigurationException { | ||
|
||
NodeList nodeList; | ||
Element element = null; | ||
|
||
nodeList = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new File(System.getProperty("catalina.base") + "\\wtpwebapps\\RedCrossSupportService\\WEB-INF\\Query.xml")) | ||
.getElementsByTagName(CommonConstants.TAG_NAME); | ||
|
||
for (int value = 0; value < nodeList.getLength(); value++) { | ||
element = (Element) nodeList.item(value); | ||
if (element.getAttribute(CommonConstants.ATTRIB_ID).equals(id)) | ||
break; | ||
} | ||
return element.getTextContent().trim(); | ||
} | ||
} |
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,5 @@ | ||
url=jdbc:mysql://localhost:3306/vaccination | ||
driverName=com.mysql.jdbc.Driver | ||
username=root | ||
password= | ||
queryFilePath=Query.xml |
Oops, something went wrong.