Skip to content

Commit f466f41

Browse files
committed
Updated the Vehicle Table
Created a LoanAppController
1 parent 3e3c73d commit f466f41

6 files changed

Lines changed: 92 additions & 34 deletions

File tree

JavaSource/META-INF/persistence.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
5656
<properties>
5757
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
58-
<property name="hibernate.connection.username" value="javaweb_test"/>
58+
<property name="hibernate.connection.username" value="javaweb_acuteaut"/>
5959
<property name="hibernate.connection.password" value="acuteauto"/>
6060
<property name="hibernate.show_sql" value="true"/>
6161
<property name="hibernate.format_sql" value="true"/>

JavaSource/com/acminds/acuteauto/persistence/entities/AbstractVehicle.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public abstract class AbstractVehicle extends
4040
private String description;
4141
private int year;
4242
private String engine;
43-
private String transmission;
44-
private String driveTrain;
43+
private Integer transType;
44+
private Integer drvTrnType;
4545
private Integer fuelType;
4646
private String vin;
4747
private Integer mileage;
@@ -145,22 +145,22 @@ public void setEngine(String engine) {
145145
this.engine = engine;
146146
}
147147

148-
@Column(name = "TRANSMISSION", length = 60)
149-
public String getTransmission() {
150-
return this.transmission;
148+
@Column(name = "TRANS_TYPE")
149+
public Integer getTransType() {
150+
return this.transType;
151151
}
152152

153-
public void setTransmission(String transmission) {
154-
this.transmission = transmission;
153+
public void setTransType(Integer transType) {
154+
this.transType = transType;
155155
}
156156

157-
@Column(name = "DRIVE_TRAIN", length = 60)
158-
public String getDriveTrain() {
159-
return this.driveTrain;
157+
@Column(name = "DRV_TRN_TYPE")
158+
public Integer getDrvTrnType() {
159+
return this.drvTrnType;
160160
}
161161

162-
public void setDriveTrain(String driveTrain) {
163-
this.driveTrain = driveTrain;
162+
public void setDrvTrnType(Integer drvTrnType) {
163+
this.drvTrnType = drvTrnType;
164164
}
165165

166166
@Column(name = "FUEL_TYPE")
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
*
3+
*/
4+
package com.acminds.acuteauto.ui.controller;
5+
6+
import javax.annotation.PostConstruct;
7+
import javax.annotation.Resource;
8+
import javax.faces.bean.ManagedBean;
9+
import javax.faces.bean.ViewScoped;
10+
11+
import com.acminds.acuteauto.persistence.dto.LoanApplication;
12+
import com.acminds.acuteauto.ui.BaseController;
13+
14+
/**
15+
* @author Mansur
16+
*
17+
*/
18+
@ManagedBean(name="lnCtrl")
19+
@ViewScoped
20+
public class LoanAppController extends BaseController {
21+
22+
@Resource(name="loanApplication")
23+
private LoanApplication loanApp;
24+
public LoanApplication getLoanApp() {
25+
return loanApp;
26+
}
27+
public void setLoanApp(LoanApplication loanApp) {
28+
this.loanApp = loanApp;
29+
}
30+
31+
@PostConstruct
32+
public String createLoan() {
33+
34+
return null;
35+
}
36+
}

JavaSource/com/acminds/acuteauto/ui/filter/SecurityFilter.java

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
import javax.servlet.http.HttpServletRequest;
1616
import javax.servlet.http.HttpServletResponse;
1717

18+
import org.apache.commons.logging.Log;
19+
import org.apache.commons.logging.LogFactory;
20+
1821
import com.acminds.acuteauto.persistence.PersistenceManager;
1922
import com.acminds.acuteauto.persistence.dto.Privilege;
2023
import com.acminds.acuteauto.persistence.dto.UserInfo;
@@ -25,7 +28,10 @@
2528
*
2629
*/
2730
public class SecurityFilter implements Filter {
31+
private Log logger = LogFactory.getLog(SecurityFilter.class);
32+
2833
private static final String UNAUTH_URL = "/home.jsf";
34+
private static final String ERROR_URL = "/error.jsf";
2935

3036
/* (non-Javadoc)
3137
* @see javax.servlet.Filter#destroy()
@@ -45,27 +51,32 @@ public void doFilter(ServletRequest arg0, ServletResponse arg1,
4551
HttpServletResponse response = (HttpServletResponse)arg1;
4652
UserInfo authorizedUser = null;
4753
boolean authorized = false;
48-
if(isURISecure(request.getRequestURI())) {
49-
authorizedUser = (UserInfo)request.getSession().getAttribute("authorizedUser");
50-
if(Utils.isEmpty(authorizedUser)) {
51-
response.sendRedirect(request.getContextPath() + UNAUTH_URL);
52-
PersistenceManager.closeEnityManager();
53-
} else {
54-
List<Privilege> privs = authorizedUser.getRole().getPrivileges();
55-
for(Privilege priv:privs) {
56-
if(request.getRequestURI().contains(priv.getTranUri())) {
57-
authorized = true;
58-
break;
59-
}
60-
}
61-
if(!authorized) {
54+
try {
55+
if(isURISecure(request.getRequestURI())) {
56+
authorizedUser = (UserInfo)request.getSession().getAttribute("authorizedUser");
57+
if(Utils.isEmpty(authorizedUser)) {
6258
response.sendRedirect(request.getContextPath() + UNAUTH_URL);
6359
PersistenceManager.closeEnityManager();
64-
} else
65-
arg2.doFilter(arg0, arg1);
60+
} else {
61+
List<Privilege> privs = authorizedUser.getRole().getPrivileges();
62+
for(Privilege priv:privs) {
63+
if(request.getRequestURI().contains(priv.getTranUri())) {
64+
authorized = true;
65+
break;
66+
}
67+
}
68+
if(!authorized) {
69+
response.sendRedirect(request.getContextPath() + UNAUTH_URL);
70+
PersistenceManager.closeEnityManager();
71+
} else
72+
arg2.doFilter(arg0, arg1);
73+
}
74+
} else {
75+
arg2.doFilter(arg0, arg1);
6676
}
67-
} else {
68-
arg2.doFilter(arg0, arg1);
77+
} catch(Throwable e) {
78+
logger.error("Error occured while trying to serve a request", e);
79+
response.sendRedirect(request.getContextPath() + ERROR_URL);
6980
}
7081
}
7182

JavaSource/sql/db-data.sql

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ INSERT INTO ENUM_TYPE VALUES ('15', 'LOAN_STATUS', 'Status of Loan', null);
100100
INSERT INTO ENUM_TYPE VALUES ('16', 'FINANCE_TYPE', 'Type of Finance', null);
101101
INSERT INTO ENUM_TYPE VALUES ('17', 'ACCOUNT_TYPE', 'Type of Account', null);
102102
INSERT INTO ENUM_TYPE VALUES ('18', 'INQUIRY_TYPE', 'Type of Inquiry', null);
103+
INSERT INTO ENUM_TYPE VALUES ('19', 'TRANSMISSION_TYPE', 'Type of Transmission', null);
104+
INSERT INTO ENUM_TYPE VALUES ('20', 'DRIVE_TRAIN_TYPE', 'Type of Drive Train', null);
103105

104106
-- ----------------------------
105107
-- Records for "ENUM"
@@ -139,6 +141,7 @@ INSERT INTO ENUM VALUES ('72', '7', 'Diesel', null, null);
139141
-- WARRANTY_TYPE
140142
INSERT INTO ENUM VALUES ('80', '8', 'Standard', null, null);
141143
INSERT INTO ENUM VALUES ('81', '8', 'Extended', null, null);
144+
INSERT INTO ENUM VALUES ('82', '8', 'As Is - No Warranty', null, null);
142145
-- VEHICLE_STATUS
143146
INSERT INTO ENUM VALUES ('90', '9', 'Available', null, null);
144147
INSERT INTO ENUM VALUES ('91', '9', 'Sold', null, null);
@@ -173,4 +176,12 @@ INSERT INTO ENUM VALUES ('161', '16', 'Lease', null, null);
173176
INSERT INTO ENUM VALUES ('170', '17', 'Checking', null, null);
174177
INSERT INTO ENUM VALUES ('171', '17', 'Savings', null, null);
175178
-- INQUIRY_TYPE
176-
INSERT INTO ENUM VALUES ('180', '18', 'Reserved', 'For future use', null);
179+
INSERT INTO ENUM VALUES ('180', '18', 'Reserved', 'For future use', null);
180+
-- TRANSMISSION_TYPE
181+
INSERT INTO ENUM VALUES ('190', '19', 'Automatic', 'Automatic Transmission', null);
182+
INSERT INTO ENUM VALUES ('191', '19', '5 Speed Manual', '5 Speed Manual Transmission', null);
183+
-- DRIVE_TRAIN_TYPE
184+
INSERT INTO ENUM VALUES ('210', '20', 'AWD', 'All Wheel Drive', null);
185+
INSERT INTO ENUM VALUES ('211', '20', 'FWD', 'Front Wheel Drive', null);
186+
INSERT INTO ENUM VALUES ('212', '20', 'RWD', 'Rear Wheel Drive', null);
187+
INSERT INTO ENUM VALUES ('213', '20', '4WD', 'Four Wheel Drive', null);

JavaSource/sql/db-schema.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ MODEL_ID INT NOT NULL,
8080
STYLE_ID INT, -- MADE NULLABLE TO SUPPORT ADDING VEHICLE FOR INQUIRY BY CUSTOMERS.
8181
DESCRIPTION VARCHAR(100),
8282
ENGINE VARCHAR(60),
83-
TRANSMISSION VARCHAR(60), -- DEFAULT AUTOMATIC
84-
DRIVE_TRAIN VARCHAR(60),
83+
TRANS_TYPE INT(3), -- AUTOMATIC, 5 SPEED MANUAL
84+
DRV_TRN_TYPE INT(3), -- AWD, FWD, RWD, 4WD
8585
FUEL_TYPE INT(3),
8686
VIN VARCHAR(60),
8787
MILEAGE INT,

0 commit comments

Comments
 (0)