100 | --%>
101 |
102 |
103 |
104 |
105 |
120 |
121 | <%--
122 |
123 |
124 |
125 |
126 | |
127 | |
128 |
129 |
130 | Recipient Name |
131 | |
132 |
133 |
134 | Recipient Address |
135 | |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 | --%>
144 |
145 |
146 |
147 |
148 |
149 |
--------------------------------------------------------------------------------
/WebContent/WEB-INF/jsp/Hello.jsp:
--------------------------------------------------------------------------------
1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
2 | pageEncoding="ISO-8859-1"%>
3 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
4 | <%@page session="true"%>
5 |
6 |
7 |
8 |
9 |
Insert title here
10 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
43 |
44 |
45 |
48 |
49 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/WebContent/WEB-INF/jsp/ItemRecord.jsp:
--------------------------------------------------------------------------------
1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
2 | pageEncoding="ISO-8859-1"%>
3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
4 | <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
5 | <%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
6 |
7 |
8 |
9 |
10 |
Insert title here
11 |
63 |
64 | <%-- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// --%>
65 |
66 |
67 |
68 |
69 |
70 |
71 | <%-- //////////////////////////////////////////////////////////////// --%>
72 |
73 |
74 | Filter Item By Category
75 |
76 |
77 |
78 |
79 |
99 |
100 |
101 |
102 |
103 |
104 | <%-- //////////////////////////////////////////////////////// --%>
105 |
106 |
107 |
108 |
109 |
110 | <%-- CategoryId | --%>
111 | CategoryName |
112 |
113 |
114 |
115 |
116 | <%-- | --%>
117 | |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 | <%-- ItemId | --%>
132 | ItemName |
133 | ItemPrice |
134 | ItemContent |
135 | ItemImage |
136 | Add to Cart |
137 | <%-- UserName | --%>
138 |
139 |
140 |
141 |
142 | <%-- | --%>
143 | |
144 | |
145 | |
146 |  |
147 | Add
148 |
149 | <%-- | ${userName} | --%>
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
163 |
164 |
165 |
--------------------------------------------------------------------------------
/WebContent/WEB-INF/jsp/addCategory.jsp:
--------------------------------------------------------------------------------
1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
2 | pageEncoding="ISO-8859-1"%>
3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
4 | <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
5 |
6 |
7 |
8 |
9 |
Insert title here
10 |
11 |
12 |
13 | Create New Record
14 |
15 |
16 |
17 |
18 |
19 | |
20 | |
21 |
22 |
23 |
24 | Category Name |
25 | |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/WebContent/WEB-INF/jsp/addItem.jsp:
--------------------------------------------------------------------------------
1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
2 | pageEncoding="ISO-8859-1"%>
3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
4 | <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
5 | <%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
6 |
7 |
8 |
9 |
10 |
11 |
Insert title here
12 |
37 |
38 |
39 |
40 |
41 |
Add New Item
42 |
43 |
44 |
45 |
46 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/WebContent/WEB-INF/jsp/admin.jsp:
--------------------------------------------------------------------------------
1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
2 | pageEncoding="ISO-8859-1"%>
3 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
4 | <%@page session="true"%>
5 |
6 |
7 |
8 |
9 |
Insert title here
10 |
34 |
35 |
36 | <%
37 | session = request.getSession(false);
38 |
39 | %>
40 |
41 |
42 |
45 |
46 |
47 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/WebContent/WEB-INF/jsp/editCategory.jsp:
--------------------------------------------------------------------------------
1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
2 | pageEncoding="ISO-8859-1"%>
3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
4 | <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
5 |
6 |
7 |
8 |
9 |
Insert title here
10 |
33 |
34 |
35 |
36 |
37 |
38 |
Edit Category
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | CategoryId: |
48 | |
49 |
50 |
51 |
52 | CategoryName: |
53 | |
54 |
55 |
56 |
57 |
58 |
59 |
60 | ItemId |
61 | ItemName |
62 | ItemPrice |
63 | ItemFeatures |
64 | Edit |
65 | Delete |
66 | ItemImage |
67 | ShowImage |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 | |
78 | |
79 | |
80 | |
81 |
82 | EditItem |
83 | DeleteItem |
84 |
85 |
86 |  |
87 |
88 | ShowImage |
89 |
90 |
91 |
92 |
93 |
94 | Add Item
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/WebContent/WEB-INF/jsp/editItem.jsp:
--------------------------------------------------------------------------------
1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
2 | pageEncoding="ISO-8859-1"%>
3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
4 | <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
5 |
6 |
7 |
8 |
9 |
Insert title here
10 |
37 |
38 |
39 |
40 |
41 |
42 |
Edit Existing Item
43 |
44 |
45 |
46 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/WebContent/WEB-INF/jsp/error.jsp:
--------------------------------------------------------------------------------
1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
2 | pageEncoding="ISO-8859-1"%>
3 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
4 | <%@page session="true"%>
5 |
6 |
7 |
8 |
9 |
Insert title here
10 |
34 |
35 |
36 | <%
37 | session = request.getSession(false);
38 |
39 | %>
40 |
41 |
42 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/WebContent/WEB-INF/jsp/login.jsp:
--------------------------------------------------------------------------------
1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
2 | pageEncoding="ISO-8859-1"%>
3 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
4 | <%@page session="false"%>
5 |
6 |
7 |
8 |
9 |
10 |
Insert title here
11 |
24 |
25 |
26 |
27 |
28 |
29 |
Enter Login Details
30 |
31 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/WebContent/WEB-INF/jsp/logout.jsp:
--------------------------------------------------------------------------------
1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
2 | pageEncoding="ISO-8859-1"%>
3 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
4 | <%@page session="true"%>
5 |
6 |
7 |
8 |
9 |
Insert title here
10 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
Successfully logged off
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/WebContent/WEB-INF/jsp/record.jsp:
--------------------------------------------------------------------------------
1 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
2 | <%@ page language="java" contentType="text/html; charset=UTF-8"
3 | pageEncoding="UTF-8"%>
4 |
5 |
6 |
7 |
8 |
Insert title here
9 |
10 |
11 |
Records
12 |
13 |
14 |
15 |
16 | UserId |
17 | UserName |
18 |
19 | RoleId |
20 | RoleName |
21 |
22 | ItemId |
23 | ItemName |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 | |
34 | |
35 |
36 |
37 |
38 | |
39 | |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | |
48 | |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/WebContent/WEB-INF/jsp/userCheckOut.jsp:
--------------------------------------------------------------------------------
1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
2 | pageEncoding="ISO-8859-1"%>
3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
4 | <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
5 |
6 |
7 |
8 |
9 |
Insert title here
10 |
70 |
71 |
72 |
73 |
74 |
75 |
78 |
79 |
80 |
81 |
82 |
83 | <%--
84 |
85 | --%>
86 |
87 |
88 |
89 | CartHolderName |
90 | ${loggedUser.userName} |
91 |
92 |
93 | Recipient Name |
94 | ${rName} |
95 |
96 |
97 | Billing Address |
98 | ${rAddress} |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
Ordered Items
106 |
107 |
108 | ItemName |
109 | ItemPrice |
110 | ItemImage |
111 |
112 |
113 |
114 |
115 |
116 | |
117 | |
118 |  |
119 |
120 |
121 |
122 | |
123 | Amount payable |
124 | |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
137 |
138 |
139 |
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/activation-1.0.2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/activation-1.0.2.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/antlr-2.7.6.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/antlr-2.7.6.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/aopalliance-1.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/aopalliance-1.0.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/asm-1.5.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/asm-1.5.3.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/asm-attrs-1.5.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/asm-attrs-1.5.3.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/cglib-2.1_3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/cglib-2.1_3.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/commons-beanutils-1.7.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/commons-beanutils-1.7.0.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/commons-codec-1.9-javadoc.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/commons-codec-1.9-javadoc.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/commons-codec-1.9-sources.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/commons-codec-1.9-sources.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/commons-codec-1.9-test-sources.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/commons-codec-1.9-test-sources.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/commons-codec-1.9-tests.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/commons-codec-1.9-tests.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/commons-codec-1.9.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/commons-codec-1.9.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/commons-collections-2.1.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/commons-collections-2.1.1.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/commons-digester-1.8.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/commons-digester-1.8.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/commons-email-1.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/commons-email-1.0.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/commons-fileupload-1.1.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/commons-fileupload-1.1.1.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/commons-io-1.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/commons-io-1.1.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/commons-lang-2.5.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/commons-lang-2.5.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/commons-logging-1.1.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/commons-logging-1.1.1.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/dom4j-1.6.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/dom4j-1.6.1.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/dumbster-1.6.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/dumbster-1.6.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/ehcache-1.2.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/ehcache-1.2.3.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/hibernate-3.2.6.ga.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/hibernate-3.2.6.ga.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/hibernate-annotations-3.3.1.GA.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/hibernate-annotations-3.3.1.GA.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/hibernate-commons-annotations-3.0.0.ga.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/hibernate-commons-annotations-3.0.0.ga.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/hibernate-entitymanager-3.3.2.GA.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/hibernate-entitymanager-3.3.2.GA.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/hibernate-search-3.0.0.GA.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/hibernate-search-3.0.0.GA.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/hibernate-validator-4.0.2.GA.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/hibernate-validator-4.0.2.GA.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/icu4j-2.6.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/icu4j-2.6.1.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/javassist-3.4.GA.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/javassist-3.4.GA.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/jaxb-api-2.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/jaxb-api-2.1.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/jaxb-impl-2.1.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/jaxb-impl-2.1.3.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/jaxen-1.1.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/jaxen-1.1.1.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/jdom-1.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/jdom-1.0.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/jstl-1.2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/jstl-1.2.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/jta-1.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/jta-1.1.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/log4j-1.2.14.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/log4j-1.2.14.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/lucene-core-2.3.2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/lucene-core-2.3.2.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/lucene-highlighter-2.0.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/lucene-highlighter-2.0.0.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/mail-1.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/mail-1.4.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/mysql-connector-java-5.0.5.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/mysql-connector-java-5.0.5.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/persistence-api-1.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/persistence-api-1.0.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/quartz-1.5.2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/quartz-1.5.2.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/slf4j-api-1.5.6.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/slf4j-api-1.5.6.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/slf4j-log4j12-1.5.6.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/slf4j-log4j12-1.5.6.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/spring-aop-3.0.1.RELEASE.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/spring-aop-3.0.1.RELEASE.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/spring-asm-3.0.1.RELEASE.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/spring-asm-3.0.1.RELEASE.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/spring-beans-3.0.1.RELEASE.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/spring-beans-3.0.1.RELEASE.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/spring-context-3.0.1.RELEASE.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/spring-context-3.0.1.RELEASE.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/spring-core-3.0.1.RELEASE.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/spring-core-3.0.1.RELEASE.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/spring-expression-3.0.1.RELEASE.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/spring-expression-3.0.1.RELEASE.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/spring-jdbc-3.0.1.RELEASE.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/spring-jdbc-3.0.1.RELEASE.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/spring-orm-3.0.1.RELEASE.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/spring-orm-3.0.1.RELEASE.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/spring-tx-3.0.1.RELEASE.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/spring-tx-3.0.1.RELEASE.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/spring-web-3.0.1.RELEASE.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/spring-web-3.0.1.RELEASE.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/spring-webmvc-3.0.1.RELEASE.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/spring-webmvc-3.0.1.RELEASE.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/stax-api-1.0-2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/stax-api-1.0-2.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/validation-api-1.0.0.GA.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/validation-api-1.0.0.GA.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/xalan-2.6.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/xalan-2.6.0.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/xercesImpl-2.6.2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/xercesImpl-2.6.2.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/xml-apis-1.3.02.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/xml-apis-1.3.02.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/xmlParserAPIs-2.6.2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/xmlParserAPIs-2.6.2.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/lib/xom-1.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bkrockx/Basic-shopping-cart-application-using-spring-mvc-and-hibernate/1bf452b7d20103bd7d4e2a60b318d61e631eaafa/WebContent/WEB-INF/lib/xom-1.0.jar
--------------------------------------------------------------------------------
/WebContent/WEB-INF/spring-servlet.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
13 |
14 |
15 |
16 |
19 |
21 |
22 |
23 |
24 |
25 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
36 |
37 |
38 |
39 | Model.User
40 | Model.Role
41 | Model.Category
42 | Model.Item
43 | Model.billable
44 |
45 |
46 |
47 |
48 |
49 | org.hibernate.dialect.MySQL5Dialect
50 | true
51 | update
52 |
53 |
54 |
55 |
56 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/WebContent/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 | Project1
8 |
9 | spring
10 |
11 | org.springframework.web.servlet.DispatcherServlet
12 |
13 | 1
14 |
15 |
16 | spring
17 | /
18 |
19 |
20 |
21 | MyFilter
22 | Filter.MyFilter
23 |
24 |
25 |
26 |
27 | MyFilter
28 | /*
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/Controller/CategoryController.java:
--------------------------------------------------------------------------------
1 | package Controller;
2 |
3 | import java.util.*;
4 |
5 | import javax.annotation.Resource;
6 | import javax.servlet.http.Cookie;
7 | import javax.servlet.http.HttpServlet;
8 | import javax.servlet.http.HttpServletRequest;
9 | import javax.servlet.http.HttpSession;
10 |
11 | import Model.*;
12 | import Dto.*;
13 | import Service.*;
14 |
15 | import org.springframework.context.annotation.Scope;
16 | import org.springframework.stereotype.Controller;
17 | import org.springframework.ui.Model;
18 | import org.springframework.web.bind.annotation.ModelAttribute;
19 | import org.springframework.web.bind.annotation.RequestMapping;
20 | import org.springframework.web.bind.annotation.RequestMethod;
21 | import org.springframework.web.bind.annotation.RequestParam;
22 | import org.springframework.web.bind.annotation.SessionAttributes;
23 | import java.sql.Blob;
24 |
25 | @Controller
26 | @RequestMapping("/category")
27 | public class CategoryController {
28 |
29 | @Resource(name="categoryService")
30 | private CategoryService categoryService;
31 |
32 | @Resource(name="itemService")
33 | private ItemService itemService;
34 |
35 | @RequestMapping(value = "/list", method = RequestMethod.GET)
36 | public String getRecords(Model model) {
37 |
38 | List
categories = categoryService.getAll();
39 |
40 | List categoryDTO = new ArrayList();
41 |
42 | for (Category category: categories) {
43 | CategoryDTO dto = new CategoryDTO();
44 |
45 | dto.setCategoryId(category.getCategoryId());
46 | dto.setCategoryName(category.getCategoryName());
47 |
48 | dto.setItem(itemService.getAll(category.getCategoryId()));
49 |
50 | categoryDTO.add(dto);
51 | }
52 |
53 | model.addAttribute("categories", categoryDTO);
54 | return "AdminRecord";
55 | }
56 |
57 | @RequestMapping(value = "/add", method = RequestMethod.GET)
58 | public String getAdd(Model model) {
59 |
60 | model.addAttribute("categoryAttribute", new Category());
61 |
62 | return "addCategory";
63 | }
64 |
65 |
66 | @RequestMapping(value = "/add", method = RequestMethod.POST)
67 | public String postAdd(@ModelAttribute("categoryAttribute") Category category) {
68 |
69 | categoryService.add(category);
70 | return "redirect:/category/list";
71 | }
72 |
73 |
74 | @RequestMapping(value = "/delete", method = RequestMethod.GET)
75 | public String getDelete(@RequestParam("id") Integer categoryId) {
76 |
77 | categoryService.delete(categoryId);
78 | return "redirect:/category/list";
79 | }
80 |
81 | @RequestMapping(value = "/edit", method = RequestMethod.GET)
82 | public String getEdit(@RequestParam("id") Integer categoryId, Model model) {
83 |
84 | Category category1 = categoryService.get(categoryId);
85 | model.addAttribute("categoryAttribute",category1);
86 |
87 | return "editCategory";
88 | }
89 |
90 | @RequestMapping(value = "/edit", method = RequestMethod.POST)
91 | public String postEdit(@RequestParam("id") Integer categoryId,
92 | @ModelAttribute("categoryAttribute") Category category) {
93 |
94 | category.setCategoryId(categoryId);
95 | categoryService.edit(category);
96 | return "redirect:/category/list";
97 | }
98 |
99 | }
100 |
101 |
--------------------------------------------------------------------------------
/src/Controller/ImageController.java:
--------------------------------------------------------------------------------
1 | package Controller;
2 | import javax.annotation.Resource;
3 | import javax.servlet.http.HttpServletRequest;
4 | import javax.servlet.http.HttpServletResponse;
5 |
6 | import Model.*;
7 | import Service.*;
8 |
9 | import org.apache.commons.codec.binary.Base64;
10 | import org.springframework.stereotype.Controller;
11 | import org.springframework.ui.Model;
12 | import org.springframework.ui.ModelMap;
13 | import org.springframework.web.bind.annotation.ModelAttribute;
14 | import org.springframework.web.bind.annotation.RequestMapping;
15 | import org.springframework.web.bind.annotation.RequestMethod;
16 | import org.springframework.web.bind.annotation.RequestParam;
17 |
18 | import java.io.BufferedInputStream;
19 | import java.io.BufferedOutputStream;
20 | import java.io.Closeable;
21 | import java.io.IOException;
22 | import java.sql.SQLException;
23 |
24 | import javax.servlet.ServletException;
25 | import javax.servlet.http.HttpServletResponse;
26 | import javax.websocket.server.PathParam;
27 |
28 | import java.sql.Blob;
29 |
30 |
31 | @Controller
32 | @RequestMapping("/myImage")
33 | public class ImageController {
34 |
35 | @Resource(name="categoryService")
36 | private CategoryService categoryService;
37 |
38 | @Resource(name="itemService")
39 | private ItemService itemService;
40 |
41 | private final int DEFAULT_BUFFER_SIZE = 10240;
42 |
43 | @RequestMapping(value = "/imageDisplay", method = RequestMethod.GET)
44 | public void showImage(@RequestParam("id") Integer itemId, HttpServletResponse response,HttpServletRequest request)
45 | throws ServletException, IOException{
46 |
47 | System.out.println(itemId);
48 | Item item = itemService.get(itemId);
49 | System.out.println(itemId);
50 | response.setContentType("image/jpeg, image/jpg, image/png, image/gif");
51 |
52 | //String yourBase64EncodedBytesString = new String(Base64.encodeBase64(content));
53 | //System.out.println(new String(item.getItemImage()));
54 |
55 | response.getOutputStream().write(item.getItemImage());
56 |
57 | System.out.println("Image is");
58 |
59 | response.getOutputStream().close();
60 | /*
61 | byte[] encoded=Base64.encodeBase64(item.getItemImage());
62 | String encodedString = new String(encoded);
63 | request.setAttribute("image", encodedString);
64 | ModelMap map = new ModelMap();
65 | map.put("image", encodedString);
66 | */
67 |
68 | }
69 |
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/src/Controller/ItemController.java:
--------------------------------------------------------------------------------
1 | package Controller;
2 |
3 | import java.io.ByteArrayInputStream;
4 | import java.io.IOException;
5 | import java.io.InputStream;
6 | import java.util.*;
7 |
8 | import javax.annotation.Resource;
9 | import javax.servlet.ServletException;
10 | import javax.servlet.http.HttpServletRequest;
11 | import javax.servlet.http.HttpSession;
12 |
13 | import org.springframework.stereotype.Controller;
14 | import org.springframework.ui.Model;
15 | import org.springframework.web.bind.ServletRequestDataBinder;
16 | import org.springframework.web.bind.annotation.InitBinder;
17 | import org.springframework.web.bind.annotation.ModelAttribute;
18 | import org.springframework.web.bind.annotation.RequestMapping;
19 | import org.springframework.web.bind.annotation.RequestMethod;
20 | import org.springframework.web.bind.annotation.RequestParam;
21 | import org.springframework.web.multipart.MultipartFile;
22 | import org.springframework.web.multipart.support.ByteArrayMultipartFileEditor;
23 |
24 | import Dto.*;
25 | import Model.*;
26 | import Service.*;
27 |
28 | @Controller
29 | @RequestMapping("/item")
30 | public class ItemController {
31 |
32 | @Resource(name="categoryService")
33 | private CategoryService categoryService;
34 |
35 | @Resource(name="itemService")
36 | private ItemService itemService;
37 |
38 | @Resource(name="userService")
39 | private UserService userService;
40 |
41 | @Resource(name="billableService")
42 | private BillableService billableService;
43 |
44 | //---------------------------- to list all the items(GET)-------------------------------------------//
45 | @RequestMapping(value = "/list", method = RequestMethod.GET)
46 | public String getRecords(Model model,HttpSession sess,HttpServletRequest request) {
47 |
48 | sess = request.getSession(false);
49 | String userName = (String)sess.getAttribute("users");
50 |
51 | List- items = itemService.getAll();
52 |
53 | List itemDTO = new ArrayList();
54 |
55 | for (Item item: items) {
56 | ItemDTO dto = new ItemDTO();
57 |
58 | dto.setItemId(item.getItemId());
59 | dto.setItemName(item.getItemName());
60 | dto.setItemPrice(item.getItemPrice());
61 | dto.setItemContent(item.getItemContent());
62 | dto.setItemImage(item.getItemImage());
63 |
64 | itemDTO.add(dto);
65 |
66 | }
67 | List categories = categoryService.getAll();
68 |
69 | List categoryDTO = new ArrayList();
70 |
71 | for (Category category: categories) {
72 | CategoryDTO dto = new CategoryDTO();
73 |
74 | dto.setCategoryId(category.getCategoryId());
75 | dto.setCategoryName(category.getCategoryName());
76 |
77 | dto.setItem(itemService.getAll(category.getCategoryId()));
78 |
79 | categoryDTO.add(dto);
80 | }
81 |
82 | Category category = new Category();
83 | model.addAttribute("userName",userName);
84 | model.addAttribute("items",itemDTO);
85 | model.addAttribute("categories", categoryDTO);
86 | model.addAttribute("categoryAttribute",category);
87 | return "ItemRecord";
88 | }
89 |
90 | //---------------------------- to list all the items(POST)--------------------------------------------//
91 | @RequestMapping(value = "/list", method = RequestMethod.POST)
92 | public String postRecords(HttpSession session1,HttpServletRequest req,@ModelAttribute("categoryAttribute")Category cat,Model model) {
93 |
94 | session1 = req.getSession(false);
95 | String userName = (String) session1.getAttribute("users");
96 |
97 | Category catg = categoryService.getCategoryByName(cat.getCategoryName());
98 | List
- items = itemService.getAll(catg.getCategoryId());
99 |
100 | List itemDTO = new ArrayList();
101 |
102 | for (Item item: items) {
103 | ItemDTO dto = new ItemDTO();
104 |
105 | dto.setItemId(item.getItemId());
106 | dto.setItemName(item.getItemName());
107 | dto.setItemPrice(item.getItemPrice());
108 | dto.setItemContent(item.getItemContent());
109 | dto.setItemImage(item.getItemImage());
110 |
111 | itemDTO.add(dto);
112 |
113 | }
114 | List categories = categoryService.getAll();
115 |
116 | List categoryDTO = new ArrayList();
117 |
118 | for (Category category: categories) {
119 | CategoryDTO dto = new CategoryDTO();
120 |
121 | dto.setCategoryId(category.getCategoryId());
122 | dto.setCategoryName(category.getCategoryName());
123 |
124 | dto.setItem(itemService.getAll(category.getCategoryId()));
125 |
126 | categoryDTO.add(dto);
127 | }
128 |
129 | model.addAttribute("userName",userName);
130 | model.addAttribute("items",itemDTO);
131 | model.addAttribute("categories", categoryDTO);
132 | model.addAttribute("categoryAttribute",catg);
133 | return "ItemRecord";
134 | }
135 |
136 | //---------------------------------- adding items to category(GET)--------------------------------//
137 | @RequestMapping(value="/add",method = RequestMethod.GET)
138 | public String getAdd(@RequestParam("id")Integer categoryId,Model model){
139 |
140 | Item item = new Item();
141 |
142 | model.addAttribute("categoryId",categoryId);
143 | model.addAttribute("itemAttribute",item);
144 |
145 | return "addItem";
146 | }
147 |
148 | //
149 | @RequestMapping(value="/add", method = RequestMethod.POST)
150 | public String postAdd(@RequestParam("file")MultipartFile file,@RequestParam("id")Integer categoryId,@ModelAttribute("itemAttribute")Item item) throws IOException{
151 |
152 | itemService.add(categoryId, item,file);
153 | return "redirect:/category/list";
154 | }
155 |
156 | //-------------------adding item to cart of user---------------------------//
157 |
158 | @RequestMapping(value="/addToUser")
159 | public String getAddToUser(@RequestParam("bid")String userName,@RequestParam("cid")Integer itemId,Model model){
160 |
161 | User user = userService.getuserByName(userName);
162 | Item item = itemService.get(itemId);
163 |
164 | itemService.addItemToUser(user.getUserId(),item.getItemId());
165 |
166 | List
- items = itemService.getAllItem(user.getUserId());
167 |
168 | int sum = 0;
169 | for(Item item1: items){
170 | System.out.println(item1.getItemName());
171 | System.out.println(item1.getItemPrice());
172 | sum = sum + item1.getItemPrice();
173 | }
174 |
175 | System.out.println(sum);
176 | System.out.println(user.getUserName());
177 |
178 | model.addAttribute("CurrentUser",user);
179 | model.addAttribute("CurrentItems",items);
180 | model.addAttribute("Total",sum);
181 | model.addAttribute("billableAttribute",new billable());
182 |
183 | return "CartRecord";
184 |
185 | }
186 | // -----------------------------------------------------------------------------------//
187 |
188 | // -------------------------- checkOut -----------------------------------------------//
189 | @RequestMapping(value="/checkOut",method = RequestMethod.POST)
190 | public String checkOut(@RequestParam("id")String userName,@RequestParam("rName")String rName,@RequestParam("bAddress")String bAddress,Model model){
191 |
192 | billable bill = new billable();
193 | bill.setBillableName(rName);
194 | bill.setBillableAddress(bAddress);
195 |
196 | User user = userService.getuserByName(userName);
197 |
198 | bill.setUser(user);
199 |
200 | Set
- s = (Set)user.getItem();
201 | Set
- items1 = new HashSet
- ();
202 |
203 | for(Item i:s){
204 | Item myItem = (Item)i;
205 | //myItem.setUser(user);
206 | //myItem.setBillable(bill);
207 | itemService.saveItem(myItem);
208 | items1.add(myItem);
209 | }
210 |
211 | bill.setItem(items1);
212 |
213 | /*
214 | Set
- s1 = (Set)bill.getItem();
215 |
216 | Iterator iter = s1.iterator();
217 | while(iter.hasNext()){
218 | int i = 1;
219 | System.out.println(i);
220 | Item item4 = (Item)iter.next();
221 | System.out.println(item4.getItemName());
222 | i++;
223 | }
224 |
225 | */
226 |
227 | billableService.add(bill);
228 |
229 | List
- items = itemService.getAllItem(user.getUserId());
230 |
231 | model.addAttribute("orderedItems",items);
232 | model.addAttribute("loggedUser",user);
233 | model.addAttribute("rName",rName);
234 | model.addAttribute("rAddress",bAddress);
235 |
236 | int total = 0;
237 | for(Item item2: items){
238 | System.out.println(item2.getItemName());
239 | total = total + item2.getItemPrice();
240 | System.out.println(total);
241 | }
242 | model.addAttribute("Total",total);
243 | /*
244 | List
- items1 = itemService.getAllItem(user.getUserId());
245 |
246 | Iterator
- iter = items1.iterator();
247 | while (iter.hasNext()) {
248 | iter.remove();
249 | }
250 | */
251 |
252 | itemService.removeAllItems(user.getUserId());
253 | return "userCheckOut";
254 |
255 | }
256 | // ------------------------------------------------------------------------------------- //
257 |
258 | @RequestMapping(value = "/delete", method = RequestMethod.GET)
259 | public String getDelete(@RequestParam("id") Integer itemId) {
260 |
261 | itemService.delete(itemId);
262 | return "redirect:/category/list";
263 | }
264 |
265 |
266 | @RequestMapping(value = "/edit", method = RequestMethod.GET)
267 | public String getEdit(@RequestParam("bid") Integer categoryId,@RequestParam("cid") Integer itemId, Model model) {
268 |
269 | Item item2 = itemService.get(itemId);
270 |
271 | model.addAttribute("categoryId",categoryId);
272 | model.addAttribute("itemAttribute",item2);
273 |
274 | return "editItem";
275 | }
276 |
277 | @RequestMapping(value = "/edit", method = RequestMethod.POST)
278 | public String postEdit(@RequestParam("file")MultipartFile file,@RequestParam("id") Integer itemId,
279 | @ModelAttribute("itemAttribute") Item item) throws IOException {
280 |
281 | item.setItemId(itemId);
282 | itemService.edit(item,file);
283 |
284 | return "redirect:/category/list";
285 | }
286 |
287 | }
288 |
289 |
--------------------------------------------------------------------------------
/src/Controller/MainController.java:
--------------------------------------------------------------------------------
1 | package Controller;
2 |
3 | import java.util.*;
4 |
5 |
6 | import javax.annotation.Resource;
7 | import javax.servlet.http.Cookie;
8 | import javax.servlet.http.HttpServlet;
9 | import javax.servlet.http.HttpServletRequest;
10 | import javax.servlet.http.HttpSession;
11 |
12 | import Model.*;
13 | import Dto.*;
14 | import Service.*;
15 |
16 | import org.springframework.context.annotation.Scope;
17 | import org.springframework.stereotype.Controller;
18 | import org.springframework.ui.Model;
19 | import org.springframework.web.bind.annotation.ModelAttribute;
20 | import org.springframework.web.bind.annotation.RequestMapping;
21 | import org.springframework.web.bind.annotation.RequestMethod;
22 | import org.springframework.web.bind.annotation.RequestParam;
23 | import org.springframework.web.bind.annotation.SessionAttributes;
24 |
25 |
26 | @Controller
27 | @RequestMapping("/record")
28 | public class MainController {
29 |
30 | @Resource(name="userService")
31 | private UserService userService;
32 |
33 | @Resource(name="roleService")
34 | private RoleService roleService;
35 |
36 | @RequestMapping(value="/login")
37 | public String GetFront(Model model){
38 | return "login";
39 | }
40 |
41 | /*
42 | @RequestMapping(value="/admin")
43 | public String Front1(Model model){
44 | return "admin";
45 | }
46 |
47 | @RequestMapping(value="/Hello")
48 | public String Front2(Model model){
49 | return "Hello";
50 | }
51 |
52 | @RequestMapping(value="/error")
53 | public String Front3(Model model){
54 | return "error";
55 | }
56 | */
57 |
58 | @RequestMapping(value="/authenticate",method = RequestMethod.POST)
59 | public String authenticate(@RequestParam("uname")String userName,@RequestParam("pass")String password,
60 | HttpSession session,HttpServletRequest request,Model model){
61 |
62 | boolean success = userService.validate(userName,password);
63 | User user = userService.getuserByName(userName);
64 | Set roles = user.getRole();
65 | String role = null;
66 |
67 | for (Role role1: roles) {
68 | if(role1.getRoleName().equalsIgnoreCase("admin")){
69 | role = "admin";
70 | }
71 | }
72 |
73 | if(success){
74 | session = request.getSession();
75 | session.setAttribute("users",userName);
76 | session.setAttribute("role", roles);
77 | return "Hello";
78 | }
79 | else{
80 | return "error";
81 | }
82 |
83 | }
84 |
85 | /*
86 | @RequestMapping(value="/admin")
87 | public String admin(HttpSession session,HttpServletRequest request,Model model){
88 |
89 | HttpSession session3 = request.getSession(false);
90 | Set roles = (Set) session3.getAttribute("role");
91 | boolean permit = false;
92 |
93 | for (Role role1: roles) {
94 | if(role1.getRoleName().equalsIgnoreCase("admin")){
95 | permit = true;
96 | }
97 | }
98 |
99 | if(permit){
100 | return "admin";
101 | }
102 | else{
103 | return "error";
104 | }
105 | }
106 | */
107 |
108 | @RequestMapping(value="/Logout")
109 | public String Logout(HttpSession session,HttpServletRequest request,Model model){
110 | HttpSession session2 = request.getSession(false);
111 | session2.removeAttribute("users");
112 | session2.removeAttribute("role");
113 | if(session2!=null){
114 | session2.invalidate();
115 | }
116 | return "logout";
117 | }
118 |
119 |
120 | @RequestMapping(value = "/list", method = RequestMethod.GET)
121 | public String getRecords(Model model) {
122 |
123 | List users = userService.getAll();
124 |
125 | List userDTO = new ArrayList();
126 |
127 | for (User user: users) {
128 | UserDTO dto = new UserDTO();
129 |
130 | dto.setUserId(user.getUserId());
131 | dto.setUserName(user.getUserName());
132 | dto.setPassword(user.getPassword());
133 | dto.setRole(roleService.getAll(user.getUserId()));
134 |
135 | userDTO.add(dto);
136 | }
137 |
138 | model.addAttribute("users", userDTO);
139 | return "record";
140 | }
141 |
142 | @RequestMapping(value = "/add", method = RequestMethod.GET)
143 | public String getAdd(Model model) {
144 |
145 | model.addAttribute("userAttribute", new User());
146 |
147 | return "addUser";
148 | }
149 |
150 |
151 | @RequestMapping(value = "/add", method = RequestMethod.POST)
152 | public String postAdd(@ModelAttribute("userAttribute") User user) {
153 |
154 | userService.add(user);
155 | return "redirect:/record/list";
156 | }
157 |
158 |
159 | @RequestMapping(value = "/delete", method = RequestMethod.GET)
160 | public String getDelete(@RequestParam("id") Integer userId) {
161 |
162 | userService.delete(userId);
163 | return "redirect:/record/list";
164 | }
165 |
166 | @RequestMapping(value = "/edit", method = RequestMethod.GET)
167 | public String getEdit(@RequestParam("id") Integer userId, Model model) {
168 |
169 | User user1 = userService.get(userId);
170 | model.addAttribute("userAttribute",user1);
171 |
172 | return "editUser";
173 | }
174 |
175 | @RequestMapping(value = "/edit", method = RequestMethod.POST)
176 | public String postEdit(@RequestParam("id") Integer userId,
177 | @ModelAttribute("userAttribute") User user) {
178 |
179 | user.setUserId(userId);
180 | userService.edit(user);
181 | return "redirect:/record/list";
182 | }
183 |
184 | }
185 |
--------------------------------------------------------------------------------
/src/Controller/RoleController.java:
--------------------------------------------------------------------------------
1 | package Controller;
2 | import javax.annotation.Resource;
3 |
4 | import Model.*;
5 | import Service.*;
6 |
7 | import org.springframework.stereotype.Controller;
8 | import org.springframework.ui.Model;
9 | import org.springframework.web.bind.annotation.ModelAttribute;
10 | import org.springframework.web.bind.annotation.RequestMapping;
11 | import org.springframework.web.bind.annotation.RequestMethod;
12 | import org.springframework.web.bind.annotation.RequestParam;
13 |
14 | @Controller
15 | @RequestMapping("/role")
16 | public class RoleController {
17 |
18 | @Resource(name="roleService")
19 | private RoleService roleService;
20 |
21 | @RequestMapping(value="/add",method=RequestMethod.GET)
22 | public String getAdd(@RequestParam("id")Integer userId,Model model){
23 |
24 | Role role = new Role();
25 |
26 | model.addAttribute("userId",userId);
27 | model.addAttribute("roleAttribute",role);
28 |
29 | return "addRole";
30 | }
31 |
32 | @RequestMapping(value="/add", method = RequestMethod.POST)
33 | public String postAdd(@RequestParam("id")Integer userId,@ModelAttribute("roleAttribute")Role role){
34 |
35 | roleService.add(userId, role);
36 | return "redirect:/record/list";
37 | }
38 |
39 | @RequestMapping(value = "/delete", method = RequestMethod.GET)
40 | public String getDelete(@RequestParam("id") Integer roleId) {
41 |
42 | roleService.delete(roleId);
43 | return "redirect:/record/list";
44 | }
45 |
46 |
47 | @RequestMapping(value = "/edit", method = RequestMethod.GET)
48 | public String getEdit(@RequestParam("uid") Integer userId,@RequestParam("rid") Integer roleId, Model model) {
49 |
50 | Role role1 = roleService.get(roleId);
51 |
52 | model.addAttribute("userId",userId);
53 | model.addAttribute("roleAttribute",role1);
54 |
55 | return "editChapter";
56 | }
57 |
58 | @RequestMapping(value = "/edit", method = RequestMethod.POST)
59 | public String postEdit(@RequestParam("id") Integer roleId,
60 | @ModelAttribute("roleAttribute") Role role) {
61 |
62 | role.setRoleId(roleId);
63 | roleService.edit(role);
64 |
65 | return "redirect:/record/list";
66 | }
67 |
68 | }
69 |
70 |
--------------------------------------------------------------------------------
/src/Dto/CategoryDTO.java:
--------------------------------------------------------------------------------
1 | package Dto;
2 |
3 | import java.util.*;
4 |
5 | import Model.*;
6 |
7 | public class CategoryDTO {
8 |
9 | private Integer categoryId;
10 | private String categoryName;
11 | private List
- Item;
12 |
13 | public Integer getCategoryId() {
14 | return categoryId;
15 | }
16 | public void setCategoryId(Integer categoryId) {
17 | this.categoryId = categoryId;
18 | }
19 | public String getCategoryName() {
20 | return categoryName;
21 | }
22 | public void setCategoryName(String categoryName) {
23 | this.categoryName = categoryName;
24 | }
25 | public List
- getItem() {
26 | return Item;
27 | }
28 | public void setItem(List
- item) {
29 | Item = item;
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/Dto/ItemDTO.java:
--------------------------------------------------------------------------------
1 | package Dto;
2 |
3 | import java.util.*;
4 |
5 | import com.mysql.jdbc.Blob;
6 |
7 | import Model.*;
8 |
9 | public class ItemDTO {
10 |
11 | private Integer itemId;
12 | private String itemName;
13 | private String itemContent;
14 | private int itemPrice;
15 | private byte[] itemImage;
16 |
17 | private List category;
18 |
19 | public Integer getItemId() {
20 | return itemId;
21 | }
22 |
23 | public void setItemId(Integer itemId) {
24 | this.itemId = itemId;
25 | }
26 |
27 | public String getItemName() {
28 | return itemName;
29 | }
30 |
31 | public void setItemName(String itemName) {
32 | this.itemName = itemName;
33 | }
34 |
35 | public String getItemContent() {
36 | return itemContent;
37 | }
38 |
39 | public void setItemContent(String itemContent) {
40 | this.itemContent = itemContent;
41 | }
42 |
43 | public int getItemPrice() {
44 | return itemPrice;
45 | }
46 |
47 | public void setItemPrice(int itemPrice) {
48 | this.itemPrice = itemPrice;
49 | }
50 |
51 | public List getCategory() {
52 | return category;
53 | }
54 |
55 | public void setCategory(List category) {
56 | this.category = category;
57 | }
58 |
59 | public byte[] getItemImage() {
60 | return itemImage;
61 | }
62 |
63 | public void setItemImage(byte[] itemImage) {
64 | this.itemImage = itemImage;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/Dto/RoleDTO.java:
--------------------------------------------------------------------------------
1 | package Dto;
2 |
3 | import java.util.*;
4 | import Model.*;
5 |
6 | public class RoleDTO {
7 |
8 | private Integer roleId;
9 | private String roleName;
10 | private Listuser;
11 |
12 | public Integer getRoleId() {
13 | return roleId;
14 | }
15 |
16 | public void setRoleId(Integer roleId) {
17 | this.roleId = roleId;
18 | }
19 |
20 | public String getRoleName() {
21 | return roleName;
22 | }
23 |
24 | public void setRoleName(String roleName) {
25 | this.roleName = roleName;
26 | }
27 |
28 | public List getUser() {
29 | return user;
30 | }
31 |
32 | public void setUser(List user) {
33 | this.user = user;
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/Dto/UserDTO.java:
--------------------------------------------------------------------------------
1 | package Dto;
2 |
3 | import java.util.*;
4 | import Model.*;
5 |
6 | public class UserDTO {
7 |
8 | private Integer userId;
9 | private String userName;
10 | private String password;
11 | private List role;
12 | private List
- item;
13 |
14 | public List
- getItem() {
15 | return item;
16 | }
17 |
18 | public void setItem(List
- item) {
19 | this.item = item;
20 | }
21 |
22 | public Integer getUserId() {
23 | return userId;
24 | }
25 |
26 | public void setUserId(Integer userId) {
27 | this.userId = userId;
28 | }
29 |
30 | public String getUserName() {
31 | return userName;
32 | }
33 |
34 | public void setUserName(String userName) {
35 | this.userName = userName;
36 | }
37 |
38 | public String getPassword() {
39 | return password;
40 | }
41 |
42 | public void setPassword(String password) {
43 | this.password = password;
44 | }
45 |
46 | public List getRole() {
47 | return role;
48 | }
49 |
50 | public void setRole(List role) {
51 | this.role = role;
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/Filter/MyFilter.java:
--------------------------------------------------------------------------------
1 | package Filter;
2 |
3 | import java.io.IOException;
4 |
5 | import java.io.PrintWriter;
6 | import java.util.Set;
7 |
8 | import javax.servlet.Filter;
9 | import javax.servlet.FilterChain;
10 | import javax.servlet.FilterConfig;
11 | import javax.servlet.ServletContext;
12 | import javax.servlet.ServletException;
13 | import javax.servlet.ServletRequest;
14 | import javax.servlet.ServletResponse;
15 | import javax.servlet.annotation.WebFilter;
16 | import javax.servlet.http.HttpServletRequest;
17 | import javax.servlet.http.HttpServletResponse;
18 | import javax.servlet.http.HttpSession;
19 |
20 | import Model.*;
21 |
22 |
23 | //@WebFilter(urlPatterns={"/*"})
24 | public class MyFilter implements Filter {
25 |
26 |
27 | private ServletContext context;
28 |
29 |
30 | public MyFilter() {
31 | // TODO Auto-generated constructor stub
32 | }
33 |
34 |
35 | public void destroy() {
36 | // TODO Auto-generated method stub
37 | }
38 |
39 |
40 | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
41 |
42 | response.setContentType("text/html");
43 |
44 | HttpServletRequest request1 = (HttpServletRequest)request;
45 | HttpServletResponse response1 = (HttpServletResponse)response;
46 | HttpSession session = request1.getSession(false);
47 |
48 | String uri = request1.getRequestURI();
49 | // (If session is not set)
50 | if( (session==null || session.getAttribute("users")==null)&& (!uri.endsWith("login.jsp") && !uri.endsWith("record/authenticate"))){
51 | request1.getRequestDispatcher("/WEB-INF/jsp/login.jsp").forward(request1, response1);
52 | }
53 | //(if session is set)
54 | else{
55 | boolean permit = false;
56 | // If URL ends with admin
57 |
58 | if(uri.contains("record/admin")){
59 | //System.out.println("entered");
60 | System.out.println(request1.getSession(false).getId());
61 | Set roles = (Set) session.getAttribute("role");
62 | for (Role role1: roles) {
63 | if(role1.getRoleName().equalsIgnoreCase("admin")){
64 | permit = true;
65 | }
66 | }
67 |
68 | if(permit){
69 | //chain.doFilter(request,response);
70 | System.out.println("permission given");
71 | request1.getRequestDispatcher("/WEB-INF/jsp/admin.jsp").forward(request1,response1);
72 | }
73 | else{
74 | request1.getRequestDispatcher("/WEB-INF/jsp/error.jsp").forward(request1, response1);
75 | }
76 | }
77 | else{
78 | chain.doFilter(request,response);
79 | }
80 |
81 | }
82 | }
83 |
84 |
85 | public void init(FilterConfig fConfig) throws ServletException {
86 | this.context = fConfig.getServletContext();
87 | }
88 |
89 | }
--------------------------------------------------------------------------------
/src/Model/Category.java:
--------------------------------------------------------------------------------
1 | package Model;
2 | import java.util.Set;
3 |
4 | import javax.persistence.CascadeType;
5 | import javax.persistence.Column;
6 | import javax.persistence.Entity;
7 | import javax.persistence.FetchType;
8 | import javax.persistence.GeneratedValue;
9 | import javax.persistence.Id;
10 | import javax.persistence.JoinColumn;
11 | import javax.persistence.JoinTable;
12 | import javax.persistence.OneToMany;
13 | import javax.persistence.Table;
14 |
15 | import java.io.Serializable;
16 | import java.sql.Blob;
17 | @Entity
18 | @Table(name="category")
19 | public class Category implements Serializable{
20 |
21 | @Id
22 | @Column(name="categoryId")
23 | @GeneratedValue
24 | private Integer categoryId;
25 |
26 | @Column(name="categoryName")
27 | private String categoryName;
28 |
29 | @OneToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
30 | @JoinTable(
31 | name="CategoryItem",
32 | joinColumns = @JoinColumn(name="CATEGORY_ID"),
33 | inverseJoinColumns = @JoinColumn(name="ITEM_ID")
34 | )
35 | public Set
- item;
36 |
37 |
38 | public Integer getCategoryId() {
39 | return categoryId;
40 | }
41 |
42 | public void setCategoryId(Integer categoryId) {
43 | this.categoryId = categoryId;
44 | }
45 |
46 | public String getCategoryName() {
47 | return categoryName;
48 | }
49 |
50 | public void setCategoryName(String categoryName) {
51 | this.categoryName = categoryName;
52 | }
53 |
54 | public Set
- getItem() {
55 | return item;
56 | }
57 |
58 | public void setItem(Set
- item) {
59 | this.item = item;
60 | }
61 |
62 | }
63 |
64 |
--------------------------------------------------------------------------------
/src/Model/Item.java:
--------------------------------------------------------------------------------
1 | package Model;
2 |
3 | import java.io.Serializable;
4 |
5 | import javassist.bytecode.ByteArray;
6 |
7 | import javax.persistence.CascadeType;
8 | import javax.persistence.Column;
9 | import javax.persistence.Entity;
10 | import javax.persistence.FetchType;
11 | import javax.persistence.GeneratedValue;
12 | import javax.persistence.Id;
13 | import javax.persistence.JoinColumn;
14 | import javax.persistence.JoinTable;
15 | import javax.persistence.ManyToOne;
16 | import javax.persistence.Table;
17 |
18 | import java.sql.Blob;
19 |
20 | @Entity
21 | @Table(name="item")
22 | public class Item implements Serializable{
23 |
24 | @Id
25 | @Column(name="ItemId")
26 | @GeneratedValue
27 | private Integer itemId;
28 |
29 | @Column(name="ItemName")
30 | private String itemName;
31 |
32 | @Column(name="ItemContent")
33 | private String itemContent;
34 |
35 | @Column(name="ItemPrice")
36 | private int itemPrice;
37 |
38 | @Column(name="ItemImage")
39 | private byte[] itemImage;
40 |
41 | //---------------------------------------item mapped to category------------------------------------------//
42 | @ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
43 | @JoinTable(
44 | name="CategoryItem",
45 | joinColumns= @JoinColumn(name="ITEM_ID")
46 | )
47 | private Category category;
48 | //--------------------------------------------------------------------------------------------------------//
49 |
50 | //------------------------------------------Item mapped to User--------------------------------------------//
51 | @ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
52 | @JoinTable(
53 | name="UserItem",
54 | joinColumns= @JoinColumn(name="ITEM_ID"),
55 | inverseJoinColumns = @JoinColumn(name="USER_ID")
56 | )
57 | private User user;
58 | //--------------------------------------------------------------------------------------------------------//
59 |
60 | //-------------------------------------item mapped to billable--------------------------------------------//
61 | @ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
62 | @JoinTable(
63 | name="BillableItem",
64 | joinColumns = @JoinColumn(name = "ITEM_ID"),
65 | inverseJoinColumns = @JoinColumn(name="BILLABLE_ID")
66 | )
67 | public billable billable;
68 | //--------------------------------------------------------------------------------------------------------//
69 |
70 | public Integer getItemId() {
71 | return itemId;
72 | }
73 |
74 | public void setItemId(Integer itemId) {
75 | this.itemId = itemId;
76 | }
77 |
78 | public String getItemName() {
79 | return itemName;
80 | }
81 |
82 | public void setItemName(String itemName) {
83 | this.itemName = itemName;
84 | }
85 |
86 | public String getItemContent() {
87 | return itemContent;
88 | }
89 |
90 | public void setItemContent(String itemContent) {
91 | this.itemContent = itemContent;
92 | }
93 |
94 | public int getItemPrice() {
95 | return itemPrice;
96 | }
97 |
98 | public void setItemPrice(int itemPrice) {
99 | this.itemPrice = itemPrice;
100 | }
101 |
102 | public Category getCategory() {
103 | return category;
104 | }
105 |
106 | public void setCategory(Category category) {
107 | this.category = category;
108 | }
109 |
110 | public byte[] getItemImage() {
111 | return itemImage;
112 | }
113 |
114 | public void setItemImage(byte[] itemImage) {
115 | this.itemImage = itemImage;
116 | }
117 |
118 | public User getUser() {
119 | return user;
120 | }
121 |
122 | public void setUser(User user) {
123 | this.user = user;
124 | }
125 |
126 | public billable getBillable() {
127 | return billable;
128 | }
129 |
130 | public void setBillable(billable billable) {
131 | this.billable = billable;
132 | }
133 |
134 | }
135 |
136 |
--------------------------------------------------------------------------------
/src/Model/Role.java:
--------------------------------------------------------------------------------
1 | package Model;
2 |
3 | import java.io.Serializable;
4 |
5 | import javax.persistence.CascadeType;
6 | import javax.persistence.Column;
7 | import javax.persistence.Entity;
8 | import javax.persistence.GeneratedValue;
9 | import javax.persistence.Id;
10 | import javax.persistence.JoinColumn;
11 | import javax.persistence.JoinTable;
12 | import javax.persistence.ManyToOne;
13 | import javax.persistence.Table;
14 |
15 |
16 | @Entity
17 | @Table(name="role")
18 | public class Role implements Serializable{
19 |
20 | @Id
21 | @Column(name="roleId")
22 | @GeneratedValue
23 | private Integer roleId;
24 |
25 | @Column(name="roleName")
26 | private String roleName;
27 |
28 | @ManyToOne(cascade = CascadeType.ALL)
29 | @JoinTable(
30 | name="UserRole",
31 | joinColumns= @JoinColumn(name="ROLE_ID"),
32 | inverseJoinColumns = @JoinColumn(name="USER_ID")
33 | )
34 | private User user;
35 |
36 | public Integer getRoleId() {
37 | return roleId;
38 | }
39 |
40 | public void setRoleId(Integer roleId) {
41 | this.roleId = roleId;
42 | }
43 |
44 | public String getRoleName() {
45 | return roleName;
46 | }
47 |
48 | public void setRoleName(String roleName) {
49 | this.roleName = roleName;
50 | }
51 |
52 | public User getUser() {
53 | return user;
54 | }
55 |
56 | public void setUser(User user) {
57 | this.user = user;
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/Model/User.java:
--------------------------------------------------------------------------------
1 | package Model;
2 |
3 | import java.io.Serializable;
4 |
5 |
6 | import java.util.*;
7 |
8 | import javax.persistence.CascadeType;
9 | import javax.persistence.Column;
10 | import javax.persistence.Entity;
11 | import javax.persistence.FetchType;
12 | import javax.persistence.GeneratedValue;
13 | import javax.persistence.Id;
14 | import javax.persistence.JoinColumn;
15 | import javax.persistence.JoinTable;
16 | import javax.persistence.OneToMany;
17 | import javax.persistence.Table;
18 |
19 | @Entity
20 | @Table(name="user")
21 | public class User implements Serializable{
22 |
23 | @Id
24 | @Column(name="userId")
25 | @GeneratedValue
26 | private Integer userId;
27 |
28 | @Column(name="userName")
29 | private String userName;
30 |
31 | @Column(name="password")
32 | private String password;
33 |
34 | @Column(name="userAddress")
35 | private String userAddress;
36 |
37 | //----------------------------------User to role mapping------------------------------------------//
38 | @OneToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
39 | @JoinTable(
40 | name="UserRole",
41 | joinColumns = @JoinColumn(name="USER_ID"),
42 | inverseJoinColumns = @JoinColumn(name="ROLE_ID")
43 | )
44 | private Set role;
45 | //--------------------------------------------------------------------------------------------------//
46 |
47 |
48 |
49 | //-----------------------------------User to Item mapping-------------------------------------------//
50 | @OneToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
51 | @JoinTable(
52 | name="UserItem",
53 | joinColumns = @JoinColumn(name="USER_ID"),
54 | inverseJoinColumns = @JoinColumn(name="ITEM_ID")
55 | )
56 | private Set
- item;
57 | //--------------------------------------------------------------------------------------------------//
58 |
59 |
60 |
61 | //-----------------------------user billable mapping---------------------------------------------//
62 | /*
63 | @OneToMany(mappedBy="user",cascade=CascadeType.ALL,fetch=FetchType.EAGER)
64 | private Set billable;
65 | */
66 |
67 | @OneToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
68 | @JoinTable(
69 | name="UserBillable",
70 | joinColumns = @JoinColumn(name="USER_ID"),
71 | inverseJoinColumns = @JoinColumn(name="BILLABLE_ID")
72 | )
73 | private Set billable;
74 | //-------------------------------------------------------------------------------------------------//
75 |
76 |
77 |
78 | public Integer getUserId() {
79 | return userId;
80 | }
81 |
82 | public void setUserId(Integer userId) {
83 | this.userId = userId;
84 | }
85 |
86 | public String getUserName() {
87 | return userName;
88 | }
89 |
90 | public void setUserName(String userName) {
91 | this.userName = userName;
92 | }
93 |
94 | public String getPassword() {
95 | return password;
96 | }
97 |
98 | public void setPassword(String password) {
99 | this.password = password;
100 | }
101 |
102 | public String getUserAddress() {
103 | return userAddress;
104 | }
105 |
106 | public void setUserAddress(String userAddress) {
107 | this.userAddress = userAddress;
108 | }
109 |
110 | public Set getRole() {
111 | return role;
112 | }
113 |
114 | public void setRole(Set role) {
115 | this.role = role;
116 | }
117 |
118 | public Set
- getItem() {
119 | return item;
120 | }
121 |
122 | public void setItem(Set
- item) {
123 | this.item = item;
124 | }
125 |
126 | public Set getBillable() {
127 | return billable;
128 | }
129 |
130 | public void setBillable(Set billable) {
131 | this.billable = billable;
132 | }
133 |
134 | }
135 |
--------------------------------------------------------------------------------
/src/Model/billable.java:
--------------------------------------------------------------------------------
1 | package Model;
2 |
3 | import java.io.Serializable;
4 | import java.util.*;
5 |
6 | import javax.persistence.CascadeType;
7 | import javax.persistence.Column;
8 | import javax.persistence.Entity;
9 | import javax.persistence.FetchType;
10 | import javax.persistence.GeneratedValue;
11 | import javax.persistence.Id;
12 | import javax.persistence.JoinColumn;
13 | import javax.persistence.JoinTable;
14 | import javax.persistence.ManyToOne;
15 | import javax.persistence.OneToMany;
16 | import javax.persistence.Table;
17 |
18 | @Entity
19 | @Table(name="billable")
20 | public class billable implements Serializable{
21 |
22 | @Id
23 | @Column(name="billableId")
24 | @GeneratedValue
25 | private Integer billableId;
26 |
27 | @Column(name="billableName")
28 | private String billableName;
29 |
30 | @Column(name="billableAddress")
31 | private String billableAddress;
32 | /*
33 | @ManyToOne(cascade = CascadeType.ALL)
34 | private User user;
35 | */
36 |
37 | //------------------------------------------------billable mapped to User-------------------------------------------//
38 | @ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
39 | @JoinTable(
40 | name="UserBillable",
41 | joinColumns = @JoinColumn(name = "BILLABLE_ID"),
42 | inverseJoinColumns = @JoinColumn(name="USER_ID")
43 | )
44 | private User user;
45 | //-------------------------------------------------------------------------------------------------------------------//
46 |
47 |
48 | /*
49 |
50 | @OneToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
51 | @JoinTable(
52 | name = "BillableItem",
53 | joinColumns = @JoinColumn(name="BILLABLE_ID"),
54 | inverseJoinColumns = @JoinColumn(name="ITEM_ID")
55 | )
56 | public Set
- item;
57 |
58 | */
59 |
60 |
61 |
62 | //--------------------------billable mapped to item---------------------------------------------//
63 |
64 | /*
65 | @OneToMany(mappedBy="billable",cascade=CascadeType.ALL,fetch=FetchType.EAGER)
66 | private Set
- item;
67 | */
68 |
69 | @OneToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
70 | @JoinTable(
71 | name = "BillableItem",
72 | joinColumns = @JoinColumn(name="BILLABLE_ID"),
73 | inverseJoinColumns = @JoinColumn(name="ITEM_ID")
74 | )
75 | public Set
- item;
76 | //----------------------------------------------------------------------------------------------//
77 |
78 |
79 |
80 | public User getUser() {
81 | return user;
82 | }
83 |
84 | public void setUser(User user) {
85 | this.user = user;
86 | }
87 |
88 | public Set
- getItem() {
89 | return item;
90 | }
91 |
92 | public void setItem(Set
- item) {
93 | this.item = item;
94 | }
95 |
96 | public Integer getBillableId() {
97 | return billableId;
98 | }
99 |
100 | public void setBillableId(Integer billableId) {
101 | this.billableId = billableId;
102 | }
103 |
104 | public String getBillableName() {
105 | return billableName;
106 | }
107 |
108 | public void setBillableName(String billableName) {
109 | this.billableName = billableName;
110 | }
111 |
112 | public String getBillableAddress() {
113 | return billableAddress;
114 | }
115 |
116 | public void setBillableAddress(String billableAddress) {
117 | this.billableAddress = billableAddress;
118 | }
119 |
120 | }
121 |
--------------------------------------------------------------------------------
/src/Service/BillableService.java:
--------------------------------------------------------------------------------
1 | package Service;
2 | import java.util.ArrayList;
3 | import java.util.List;
4 | import java.util.Set;
5 |
6 | import javax.annotation.Resource;
7 |
8 | import org.hibernate.Criteria;
9 | import org.hibernate.Query;
10 | import org.hibernate.Session;
11 | import org.hibernate.SessionFactory;
12 | import org.hibernate.criterion.CriteriaSpecification;
13 | import org.hibernate.criterion.Criterion;
14 | import org.hibernate.criterion.LogicalExpression;
15 | import org.hibernate.criterion.Order;
16 | import org.hibernate.criterion.Restrictions;
17 |
18 | import Model.*;
19 |
20 | import org.springframework.stereotype.Service;
21 | import org.springframework.transaction.annotation.Transactional;
22 |
23 | @Service("billableService")
24 | @Transactional
25 | public class BillableService {
26 |
27 | @Resource(name="sessionFactory")
28 | private SessionFactory sessionFactory;
29 |
30 | public List getAll(){
31 | Session session = sessionFactory.getCurrentSession();
32 | Query query = session.createQuery("FROM billable");
33 | return query.list();
34 | }
35 |
36 | public billable get(Integer billableId){
37 | Session session = sessionFactory.getCurrentSession();
38 | return (billable)session.get(billable.class,billableId);
39 | }
40 |
41 | public billable getBillableByName(String billableName){
42 | Session session = sessionFactory.getCurrentSession();
43 | Criteria criteria = session.createCriteria(billable.class);
44 | criteria.add(Restrictions.like("billableName",billableName));
45 |
46 | Object result = criteria.uniqueResult();
47 | billable bill = (billable) result;
48 |
49 | return bill;
50 |
51 | }
52 |
53 | public void add(billable bill) {
54 | Session session = sessionFactory.getCurrentSession();
55 | session.save(bill);
56 | }
57 |
58 | public void delete(Integer billableId){
59 | Session session = sessionFactory.getCurrentSession();
60 | billable bill = (billable)session.get(billable.class,billableId);
61 | session.delete(bill);
62 | }
63 |
64 | public void edit(billable bill){
65 | Session session = sessionFactory.getCurrentSession();
66 | billable bill2 = (billable)session.get(billable.class,bill.getBillableId());
67 |
68 | bill2.setBillableName(bill.getBillableName());
69 | bill2.setBillableAddress(bill.getBillableAddress());
70 | session.save(bill2);
71 | }
72 |
73 | }
74 |
75 |
--------------------------------------------------------------------------------
/src/Service/CategoryService.java:
--------------------------------------------------------------------------------
1 | package Service;
2 |
3 | import java.util.ArrayList;
4 |
5 | import java.util.List;
6 | import java.util.Set;
7 |
8 | import javax.annotation.Resource;
9 |
10 | import org.hibernate.Criteria;
11 | import org.hibernate.Query;
12 | import org.hibernate.Session;
13 | import org.hibernate.SessionFactory;
14 | import org.hibernate.criterion.CriteriaSpecification;
15 | import org.hibernate.criterion.Criterion;
16 | import org.hibernate.criterion.LogicalExpression;
17 | import org.hibernate.criterion.Order;
18 | import org.hibernate.criterion.Restrictions;
19 |
20 | import Model.*;
21 |
22 | import org.springframework.stereotype.Service;
23 | import org.springframework.transaction.annotation.Transactional;
24 |
25 | @Service("categoryService")
26 | @Transactional
27 | public class CategoryService {
28 |
29 | @Resource(name="sessionFactory")
30 | private SessionFactory sessionFactory;
31 |
32 | public List getAll(){
33 | Session session = sessionFactory.getCurrentSession();
34 | Query query = session.createQuery("FROM Category");
35 | return query.list();
36 | }
37 |
38 | public Category get(Integer categoryId){
39 | Session session = sessionFactory.getCurrentSession();
40 | return (Category)session.get(Category.class,categoryId);
41 | }
42 |
43 | public Category getCategoryByName(String categoryName){
44 | Session session = sessionFactory.getCurrentSession();
45 | Criteria criteria = session.createCriteria(Category.class);
46 | criteria.add(Restrictions.like("categoryName",categoryName));
47 |
48 | Object result = criteria.uniqueResult();
49 | Category category = (Category) result;
50 |
51 | return category;
52 |
53 | }
54 |
55 | public void add(Category category) {
56 | Session session = sessionFactory.getCurrentSession();
57 | session.save(category);
58 | }
59 |
60 | public void delete(Integer categoryId){
61 | Session session = sessionFactory.getCurrentSession();
62 | Category category = (Category)session.get(Category.class,categoryId);
63 | session.delete(category);
64 | }
65 |
66 | public void edit(Category category){
67 | Session session = sessionFactory.getCurrentSession();
68 | Category category2 = (Category)session.get(Category.class,category.getCategoryId());
69 |
70 | category2.setCategoryName(category.getCategoryName());
71 | session.save(category2);
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/src/Service/ItemService.java:
--------------------------------------------------------------------------------
1 | package Service;
2 |
3 | import java.util.*;
4 |
5 | import javax.annotation.Resource;
6 |
7 | import org.hibernate.Criteria;
8 | import org.hibernate.Query;
9 | import org.hibernate.Session;
10 | import org.hibernate.SessionFactory;
11 | import org.hibernate.criterion.Restrictions;
12 |
13 | import Model.*;
14 |
15 | import org.springframework.stereotype.Service;
16 | import org.springframework.transaction.annotation.Transactional;
17 |
18 | import java.io.File;
19 | import java.io.FileInputStream;
20 | import java.io.IOException;
21 | import java.sql.Blob;
22 |
23 | import org.springframework.web.multipart.MultipartFile;
24 |
25 | @Service("itemService")
26 | @Transactional
27 | public class ItemService {
28 |
29 | @Resource(name="sessionFactory")
30 | private SessionFactory sessionFactory;
31 |
32 | public List
- getAll(Integer categoryId){
33 | Session session = sessionFactory.getCurrentSession();
34 | Query query = session.createQuery("FROM Category as c WHERE c.id="+categoryId);
35 | Category category = (Category)query.uniqueResult();
36 | return new ArrayList
- (category.getItem());
37 | }
38 |
39 | public List
- getAllItem(Integer userId){
40 | Session session = sessionFactory.getCurrentSession();
41 | Query query = session.createQuery("FROM User as u WHERE u.id="+userId);
42 | User user = (User)query.uniqueResult();
43 | return new ArrayList
- (user.getItem());
44 | }
45 |
46 | public List
- getAll(){
47 | Session session = sessionFactory.getCurrentSession();
48 | Query query = session.createQuery("FROM Item");
49 | return query.list();
50 | }
51 |
52 | public Item get(Integer itemId){
53 | Session session = sessionFactory.getCurrentSession();
54 | Item item = (Item)session.get(Item.class,itemId);
55 | return item;
56 | }
57 |
58 | public void add(Integer categoryId,Item item,MultipartFile file) throws IOException{
59 |
60 | Session session = sessionFactory.getCurrentSession();
61 | Item item1 = new Item();
62 | item1.setItemImage(file.getBytes());
63 | item1.setItemId(item.getItemId());
64 | item1.setItemName(item.getItemName());
65 | item1.setItemContent(item.getItemContent());
66 | item1.setItemPrice(item.getItemPrice());
67 |
68 | session.save(item1);
69 |
70 | Category category1 = (Category)session.get(Category.class,categoryId);
71 | category1.getItem().add(item1);
72 |
73 | session.save(category1);
74 | }
75 |
76 | // To save item //
77 | public void saveItem(Item item){
78 | Session session = sessionFactory.getCurrentSession();
79 | session.saveOrUpdate(item);
80 | }
81 |
82 | // To add item to user //
83 | public void addItemToUser(Integer userId,Integer itemId){
84 | Session session = sessionFactory.getCurrentSession();
85 | Item item2 = (Item)session.get(Item.class,itemId);
86 |
87 | User user2 = (User)session.get(User.class,userId);
88 | user2.getItem().add(item2);
89 |
90 | session.save(user2);
91 | }
92 |
93 | public void removeAllItems(Integer userId){
94 | Session session = sessionFactory.getCurrentSession();
95 | User user3 = (User) session.get(User.class,userId);
96 | user3.getItem().clear();
97 | }
98 |
99 | public void delete(Integer itemId){
100 | Session session = sessionFactory.getCurrentSession();
101 |
102 | Item item = (Item)session.get(Item.class,itemId);
103 | session.delete(item);
104 | }
105 |
106 | public void edit(Item item,MultipartFile file) throws IOException{
107 | Session session = sessionFactory.getCurrentSession();
108 | Item item2 = (Item)session.get(Item.class,item.getItemId());
109 |
110 | item2.setItemName(item.getItemName());
111 | item2.setItemContent(item.getItemContent());
112 | //Item2.setItemImage(Item.getItemImage());
113 | item2.setItemPrice(item.getItemPrice());
114 | item2.setItemImage(file.getBytes());
115 | session.save(item2);
116 | }
117 |
118 | }
119 |
120 |
121 |
--------------------------------------------------------------------------------
/src/Service/RoleService.java:
--------------------------------------------------------------------------------
1 | package Service;
2 |
3 | import java.util.*;
4 | import javax.annotation.Resource;
5 | import org.hibernate.Criteria;
6 | import org.hibernate.Query;
7 | import org.hibernate.Session;
8 | import org.hibernate.SessionFactory;
9 | import org.hibernate.criterion.Restrictions;
10 |
11 | import Model.*;
12 |
13 | import org.springframework.stereotype.Service;
14 | import org.springframework.transaction.annotation.Transactional;
15 |
16 | @Service("roleService")
17 | @Transactional
18 | public class RoleService {
19 |
20 | @Resource(name="sessionFactory")
21 | private SessionFactory sessionFactory;
22 |
23 | public List getAll(Integer userId){
24 | Session session = sessionFactory.getCurrentSession();
25 | Query query = session.createQuery("FROM User as u WHERE u.id="+userId);
26 | User user = (User)query.uniqueResult();
27 | return new ArrayList(user.getRole());
28 | }
29 |
30 | public ListgetAll(){
31 | Session session = sessionFactory.getCurrentSession();
32 | Query query = session.createQuery("FROM Role");
33 | return query.list();
34 | }
35 |
36 | public Role get(Integer roleId){
37 | Session session = sessionFactory.getCurrentSession();
38 | Role role = (Role)session.get(Role.class,roleId);
39 | return role;
40 | }
41 |
42 | public void add(Integer userId,Role role){
43 | Session session = sessionFactory.getCurrentSession();
44 | session.save(role);
45 |
46 | User user1 = (User)session.get(User.class,userId);
47 | user1.getRole().add(role);
48 |
49 | session.save(user1);
50 | }
51 |
52 | public void delete(Integer roleId){
53 | Session session = sessionFactory.getCurrentSession();
54 |
55 | Role role = (Role)session.get(Role.class,roleId);
56 | session.delete(role);
57 | }
58 |
59 | public void edit(Role role){
60 | Session session = sessionFactory.getCurrentSession();
61 | Role role1 = (Role)session.get(Role.class,role.getRoleId());
62 |
63 | role1.setRoleName(role.getRoleName());
64 | session.save(role1);
65 | }
66 |
67 | }
68 |
69 |
--------------------------------------------------------------------------------
/src/Service/UserService.java:
--------------------------------------------------------------------------------
1 | package Service;
2 |
3 | import java.util.ArrayList;
4 |
5 | import java.util.List;
6 | import java.util.Set;
7 |
8 | import javax.annotation.Resource;
9 |
10 | import org.hibernate.Criteria;
11 | import org.hibernate.Query;
12 | import org.hibernate.Session;
13 | import org.hibernate.SessionFactory;
14 | import org.hibernate.criterion.CriteriaSpecification;
15 | import org.hibernate.criterion.Criterion;
16 | import org.hibernate.criterion.LogicalExpression;
17 | import org.hibernate.criterion.Order;
18 | import org.hibernate.criterion.Restrictions;
19 |
20 | import Model.*;
21 |
22 | import org.springframework.stereotype.Service;
23 | import org.springframework.transaction.annotation.Transactional;
24 |
25 | @Service("userService")
26 | @Transactional
27 | public class UserService {
28 |
29 | @Resource(name="sessionFactory")
30 | private SessionFactory sessionFactory;
31 |
32 | public List getAll(){
33 | Session session = sessionFactory.getCurrentSession();
34 | Query query = session.createQuery("FROM User");
35 | return query.list();
36 | }
37 |
38 | public User get(Integer userId){
39 | Session session = sessionFactory.getCurrentSession();
40 | return (User)session.get(User.class,userId);
41 | }
42 |
43 | public User getuserByName(String userName){
44 | Session session = sessionFactory.getCurrentSession();
45 | Criteria criteria = session.createCriteria(User.class);
46 | criteria.add(Restrictions.like("userName",userName));
47 |
48 | Object result = criteria.uniqueResult();
49 | User user = (User) result;
50 |
51 | return user;
52 | }
53 |
54 | public boolean validate(String userName,String password){
55 |
56 | Session session = sessionFactory.getCurrentSession();
57 | Criteria criteria = session.createCriteria(User.class);
58 | criteria.add(Restrictions.like("userName",userName));
59 |
60 | boolean flag = false;
61 | Object result = criteria.uniqueResult();
62 | if(result!=null){
63 | User user = (User) result;
64 | if(user.getPassword().equalsIgnoreCase(password)){
65 | flag = true;
66 | }
67 | }
68 |
69 | if(flag==true){
70 | return true;
71 | }
72 | else{
73 | return false;
74 | }
75 | }
76 |
77 | public void add(User user) {
78 | Session session = sessionFactory.getCurrentSession();
79 | session.save(user);
80 | }
81 |
82 | public void delete(Integer userId){
83 | Session session = sessionFactory.getCurrentSession();
84 | User user = (User)session.get(User.class,userId);
85 | session.delete(user);
86 | }
87 |
88 | public void edit(User user){
89 | Session session = sessionFactory.getCurrentSession();
90 | User user1 = (User)session.get(User.class,user.getUserId());
91 |
92 | user1.setUserName(user.getUserName());
93 | user1.setPassword(user.getPassword());
94 |
95 | session.save(user1);
96 | }
97 |
98 | }
99 |
100 |
--------------------------------------------------------------------------------