Skip to content

Commit 4fe4756

Browse files
committed
Initial Push of Inventory Maintenance changes
1 parent d4a0402 commit 4fe4756

10 files changed

Lines changed: 288 additions & 11 deletions

File tree

JavaSource/com/acminds/acuteauto/persistence/dto/Vehicle.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,14 @@
55
import java.util.ArrayList;
66
import java.util.List;
77

8+
import javax.faces.bean.ManagedBean;
89
import javax.persistence.Entity;
910
import javax.persistence.Table;
1011
import javax.persistence.Transient;
1112

12-
/**
13-
* Vehicle generated by customhbm2java
14-
*/
15-
import javax.faces.bean.ManagedBean;
16-
1713
import com.acminds.acuteauto.persistence.entities.AbstractVehicle;
18-
import com.acminds.acuteauto.utils.Utils;
1914
import com.acminds.acuteauto.utils.EnumConstants.ImageType;
15+
import com.acminds.acuteauto.utils.Utils;
2016

2117
@ManagedBean(name = "vehicle")
2218
@Entity
@@ -57,5 +53,13 @@ public List<FeatureGroup> getDistinctGroups() {
5753
return distinctGroups;
5854
}
5955

56+
private List<Feature> selectedFeatures;
57+
@Transient
58+
public List<Feature> getSelectedFeatures() {
59+
return selectedFeatures;
60+
}
61+
public void setSelectedFeatures(List<Feature> selectedFeatures) {
62+
this.selectedFeatures = selectedFeatures;
63+
}
6064

6165
}

JavaSource/com/acminds/acuteauto/service/InventoryService.java

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@
66
import java.util.ArrayList;
77
import java.util.List;
88

9+
import javax.faces.application.FacesMessage;
10+
911
import com.acminds.acuteauto.persistence.dao.InventoryDAO;
1012
import com.acminds.acuteauto.persistence.dto.Advertisement;
13+
import com.acminds.acuteauto.persistence.dto.Feature;
1114
import com.acminds.acuteauto.persistence.dto.Make;
1215
import com.acminds.acuteauto.persistence.dto.Vehicle;
1316
import com.acminds.acuteauto.utils.Utils;
17+
import com.acminds.acuteauto.utils.WebUtils;
1418

1519

1620
/**
@@ -53,8 +57,31 @@ public List<Vehicle> getCarsByCategory(int id, String name) {
5357
return dao.getCarsByCategory(id, name);
5458
}
5559

56-
public void saveOrUpdateCar() {
57-
60+
public void saveOrUpdateCar(Vehicle car) throws Exception{
61+
62+
try {
63+
List<Feature> rem = new ArrayList<Feature>();
64+
for(Feature p:car.getFeatures()) {
65+
if(!car.getSelectedFeatures().contains(p)) {
66+
p.getVehicles().remove(car);
67+
rem.add(p);
68+
}
69+
}
70+
car.getFeatures().removeAll(rem);
71+
for(Feature p:car.getSelectedFeatures()) {
72+
if(!car.getFeatures().contains(p)) {
73+
car.getFeatures().add(p);
74+
p.getVehicles().add(car);
75+
}
76+
saveOrUpdate(p, false);
77+
}
78+
saveOrUpdate(car, false);
79+
commit();
80+
logger.info("Vehicle saved successfully.");
81+
} catch(Exception e) {
82+
rollback();
83+
logger.error("Role could not be saved due to an internal error.", e);
84+
}
5885
}
5986

6087
public void saveOrUpdateCarImages() {

JavaSource/resources.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,9 @@ activeRoleUsers : Active Users associated to this Role.
1818
saveRoleSuccessful : Role has been saved successfully.
1919
delRoleSuccessful : Role has been deleted successfully.
2020

21+
saveCarSuccessful : Vehicle has been saved successfully.
22+
saveImgSuccessful : Images have been saved successfully.
23+
delCarSuccessful : Vehicle has been deleted successfully.
24+
25+
2126
loanTerms : I certify that the above information is complete and accurate to the best of my knowledge. Creditors receiving this application will retain the application whether or not it is approved. Creditors may rely on this application in deciding whether to grant the requested credit. False statements may subject me to criminal penalties. I authorize the creditors to obtain credit reports about me on an ongoing basis during this credit transaction and to check my credit and employment history on an ongoing basis during the term of the credit transaction. If this application is approved, I authorize the creditor to give credit information about me to its affiliates.
308 KB
Binary file not shown.

WebContent/sec/adminConsole.xhtml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@
5858
<h3>Inventory Maintenance</h3>
5959
<div id="adminConsole">
6060
<ul>
61-
<li><a href="#">Add New Car</a></li>
62-
<li><a href="#">Search / Manage Cars</a></li>
61+
<li><a href="#{facesContext.externalContext.requestContextPath}/sec/inv/invEdit.jsf?carId=0">Add New Car</a></li>
62+
<li><a href="#">Manage Cars</a></li>
6363
</ul>
6464
</div>
6565
</h:panelGroup>
@@ -68,7 +68,7 @@
6868
<div id="adminConsole">
6969
<ul>
7070
<li><a href="#">Add New Category</a></li>
71-
<li><a href="#">Search / Manage Categories</a></li>
71+
<li><a href="#">Manage Categories</a></li>
7272
</ul>
7373
</div>
7474
</h:panelGroup>

WebContent/sec/inv/invEdit.xhtml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2+
<html xmlns="http://www.w3.org/1999/xhtml"
3+
xmlns:h="http://java.sun.com/jsf/html"
4+
xmlns:f="http://java.sun.com/jsf/core"
5+
xmlns:ui="http://java.sun.com/jsf/facelets"
6+
xmlns:rich="http://richfaces.org/rich"
7+
xmlns:c="http://java.sun.com/jsp/jstl/core"
8+
xmlns:a4j="http://richfaces.org/a4j">
9+
<ui:composition template="/templates/baseLayout.xhtml">
10+
<ui:define name="body">
11+
<f:metadata>
12+
<f:viewParam id="carId" name="carId" value="#{invCtrl.car}" converter="entityConverter">
13+
<f:param name="entityName" value="Vehicle"/>
14+
</f:viewParam>
15+
<f:event listener="#{invCtrl.addVehicle}" type="preRenderView" />
16+
</f:metadata>
17+
<section id="content">
18+
<div class="row-2 p1">
19+
<h3>Add/Update Vehicle</h3>
20+
<div class="wrapper aligncenter">
21+
<div class="col-1" style="width:100%;">
22+
<div class="loanbox" style="width:100%; min-height:320px;">
23+
<h:panelGrid width="100%">
24+
<h:form>
25+
<rich:togglePanel switchType="ajax">
26+
<rich:togglePanelItem>
27+
<ui:include src="/sec/inv/invInfo.xhtml" />
28+
</rich:togglePanelItem>
29+
<rich:togglePanelItem>
30+
<ui:include src="/sec/inv/invOptions.xhtml" />
31+
</rich:togglePanelItem>
32+
<rich:togglePanelItem>
33+
<ui:include src="/sec/inv/invImages.xhtml" />
34+
</rich:togglePanelItem>
35+
</rich:togglePanel>
36+
</h:form>
37+
</h:panelGrid>
38+
</div>
39+
</div>
40+
</div>
41+
</div>
42+
</section>
43+
</ui:define>
44+
</ui:composition>
45+
</html>

WebContent/sec/inv/invImages.xhtml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
2+
xmlns:ui="http://java.sun.com/jsf/facelets"
3+
xmlns:h="http://java.sun.com/jsf/html"
4+
xmlns:f="http://java.sun.com/jsf/core"
5+
xmlns:a4j="http://richfaces.org/a4j"
6+
xmlns:rich="http://richfaces.org/rich">
7+
8+
<div>
9+
<div class="wizard-steps">
10+
<div class="completed-step"><a href="#"><span>1</span> Vehicle Info</a></div>
11+
<div class="completed-step"><a href="#"><span>2</span> Vehicle Options</a></div>
12+
<div class="active-step"><a href="#"><span>3</span> Upload Images</a></div>
13+
</div>
14+
<h:panelGrid width="100%">
15+
<f:facet name="header">
16+
<h3>Options</h3>
17+
</f:facet>
18+
<rich:dataGrid columns="4" elements="12" value="#{invCtrl.car.distinctGroups}" var="group" style="width: 100%;">
19+
<h:panelGrid width="100%" headerClass="subHeader nowrap">
20+
<f:facet name="header">
21+
#{group.name}
22+
</f:facet>
23+
<rich:list value="#{invCtrl.car.features}" var="feat" styleClass="list-1">
24+
<h:outputText value="#{feat.featureValue}" rendered="#{group.name == feat.featureGroup.name}" styleClass="text-1"/>
25+
</rich:list>
26+
</h:panelGrid>
27+
</rich:dataGrid>
28+
</h:panelGrid>
29+
<div class="navPanel">
30+
<a4j:commandButton value="&lt;&lt;Previous" styleClass="button1 alignright" immediate="true">
31+
<rich:toggleControl targetItem="@prev" event="click" />
32+
</a4j:commandButton>
33+
<a4j:commandButton styleClass="fright button1" value="Next &gt;&gt;" rendered="#{invCtrl.car.persistent}">
34+
<rich:toggleControl targetItem="@next" event="click"/>
35+
</a4j:commandButton>
36+
<a4j:commandButton styleClass="fright button1" value="Submit" action="#{invCtrl.submitInventory}" render="@all">
37+
</a4j:commandButton>
38+
</div>
39+
</div>
40+
</ui:composition>

WebContent/sec/inv/invInfo.xhtml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
2+
xmlns:ui="http://java.sun.com/jsf/facelets"
3+
xmlns:h="http://java.sun.com/jsf/html"
4+
xmlns:f="http://java.sun.com/jsf/core"
5+
xmlns:a4j="http://richfaces.org/a4j"
6+
xmlns:rich="http://richfaces.org/rich">
7+
8+
<div>
9+
<div class="wizard-steps">
10+
<div class="active-step"><a href="#"><span>1</span> Vehicle Info</a></div>
11+
<div><a href="#"><span>2</span> Vehicle Options</a></div>
12+
<h:panelGroup layout="block" rendered="#{invCtrl.car.persistent}"><a href="#"><span>3</span> Upload Images</a></h:panelGroup>
13+
</div>
14+
<h:panelGrid rowClasses="s1row" columns="6" columnClasses="rightAlign col-padding, leftAlign col-padding,
15+
rightAlign col-padding, leftAlign col-padding, rightAlign col-padding, leftAlign col-padding" width="100%">
16+
<h:outputText value="Year:" />
17+
<h:selectOneListbox value="#{invCtrl.car.year}" size="1" required="true" label="Year">
18+
<f:selectItem itemLabel="Please Select"/>
19+
<f:selectItems value="#{uiTypes.years}"/>
20+
</h:selectOneListbox>
21+
<h:outputText value="Make:" />
22+
<h:selectOneListbox value="#{invCtrl.car.make}" size="1" converter="entityConverter" required="true" label="Make">
23+
<f:selectItem itemLabel="Please Select" itemValue="0"/>
24+
<f:selectItems value="#{invCtrl.allMakes}" var="make" itemLabel="#{make.name}" itemValue="#{make}"/>
25+
<f:ajax event="change" render="Model"/>
26+
<f:param name="entityName" value="Make"/>
27+
</h:selectOneListbox>
28+
<h:outputText value="Model:" />
29+
<h:selectOneListbox id="Model" value="#{invCtrl.car.model}" size="1" disabled="#{invCtrl.car.make == null}" converter="entityConverter" required="true" label="Model">
30+
<f:selectItem itemLabel="Please Select" itemValue="0"/>
31+
<f:selectItems value="#{invCtrl.car.make.models}" var="model" itemLabel="#{model.name}" itemValue="#{model}"/>
32+
<f:ajax event="change" render="Style"/>
33+
<f:param name="entityName" value="Model"/>
34+
</h:selectOneListbox>
35+
<h:outputText value="Style:" />
36+
<h:selectOneListbox id="Style" value="#{invCtrl.car.style}" size="1" disabled="#{invCtrl.car.model == null}" converter="entityConverter" required="true" label="Style">
37+
<f:selectItem itemLabel="Please Select" itemValue="0"/>
38+
<f:selectItems value="#{invCtrl.car.model.styles}" var="style" itemLabel="#{style.name}" itemValue="#{style}"/>
39+
<f:param name="entityName" value="Style"/>
40+
</h:selectOneListbox>
41+
42+
<h:outputText value="Stock Number:" />
43+
<h:inputText value="#{invCtrl.car.stockNbr}" label="Stock Number" required="true"/>
44+
45+
<h:outputText value="Engine:" />
46+
<h:inputText value="#{invCtrl.car.engine}" label="Engine" required="true"/>
47+
48+
<h:outputText value="Transmission:" />
49+
<h:selectOneListbox value="#{invCtrl.car.transType}" label="Transmission" size="1" required="true">
50+
<f:selectItems value="#{uiTypes.transmissionTypes}"/>
51+
</h:selectOneListbox>
52+
53+
<h:outputText value="Drive Train:" />
54+
<h:selectOneListbox value="#{invCtrl.car.drvTrnType}" label="Drive Train" size="1" required="true">
55+
<f:selectItems value="#{uiTypes.driveTrainTypes}"/>
56+
</h:selectOneListbox>
57+
58+
<h:outputText value="Fuel Type:" />
59+
<h:selectOneListbox value="#{invCtrl.car.fuelType}" label="Fuel Type" size="1" required="true">
60+
<f:selectItems value="#{uiTypes.fuelTypes}"/>
61+
</h:selectOneListbox>
62+
63+
<h:outputText value="VIN:" />
64+
<h:inputText value="#{invCtrl.car.vin}" label="VIN" />
65+
66+
<h:outputText value="Mileage:" />
67+
<h:inputText value="#{invCtrl.car.mileage}" label="Mileage" required="true"/>
68+
69+
<h:outputText value="Dealer Price:" />
70+
<h:inputText value="#{invCtrl.car.dealerPrice}" label="Dealer Price" />
71+
72+
<h:outputText value="Sale Price:" />
73+
<h:inputText value="#{invCtrl.car.salePrice}" label="Sale Price" required="true" />
74+
75+
<h:outputText value="Special Price:" />
76+
<h:inputText value="#{invCtrl.car.specialPrice}" label="Special Price" />
77+
78+
<h:outputText value="External:" />
79+
<h:inputText value="#{invCtrl.car.colorExt}" label="External" />
80+
81+
<h:outputText value="Internal:" />
82+
<h:inputText value="#{invCtrl.car.colorInt}" label="Internal" />
83+
84+
<h:outputText value="Warranty:" />
85+
<h:selectOneListbox value="#{invCtrl.car.warrantyType}" label="Warranty Type" size="1" required="true">
86+
<f:selectItems value="#{uiTypes.warrantyTypes}"/>
87+
</h:selectOneListbox>
88+
89+
<h:outputText value="Status:" />
90+
<h:selectOneListbox value="#{invCtrl.car.status}" label="Status" size="1" required="true">
91+
<f:selectItems value="#{uiTypes.vehicleStatus}"/>
92+
</h:selectOneListbox>
93+
94+
<h:outputText value="Condition:" />
95+
<h:selectOneListbox value="#{invCtrl.car.vehCondition}" label="Condition" size="1" required="true">
96+
<f:selectItems value="#{uiTypes.vehicleConditions}"/>
97+
</h:selectOneListbox>
98+
99+
<h:outputText value="Carfax URL:" />
100+
<h:inputText value="#{invCtrl.car.carfaxApprvUrl}" label="Carfax URL"/>
101+
102+
<h:outputText value="Short Description:" />
103+
<h:inputText value="#{invCtrl.car.description}" label="Short Description"/>
104+
105+
</h:panelGrid>
106+
<br/>
107+
<hr/>
108+
<br/>
109+
<h:panelGrid columnClasses="centerAlign" width="100%">
110+
<h:outputText value="Additional Info" />
111+
<h:inputTextarea value="#{invCtrl.car.additionalInfo}" label="Additional Info" cols="110" rows="5"/>
112+
</h:panelGrid>
113+
<div class="navPanel">
114+
<a4j:commandButton styleClass="fright button1" value="Next &gt;&gt;">
115+
<rich:toggleControl targetItem="@next" event="click"/>
116+
</a4j:commandButton>
117+
</div>
118+
</div>
119+
</ui:composition>

WebContent/sec/inv/invList.xhtml

Whitespace-only changes.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
2+
xmlns:ui="http://java.sun.com/jsf/facelets"
3+
xmlns:h="http://java.sun.com/jsf/html"
4+
xmlns:f="http://java.sun.com/jsf/core"
5+
xmlns:a4j="http://richfaces.org/a4j"
6+
xmlns:rich="http://richfaces.org/rich">
7+
8+
<div>
9+
<div class="wizard-steps">
10+
<div class="completed-step"><a href="#"><span>1</span> Vehicle Info</a></div>
11+
<div class="active-step"><a href="#"><span>2</span> Vehicle Options</a></div>
12+
<h:panelGroup layout="block" rendered="#{invCtrl.car.persistent}"><a href="#"><span>3</span> Upload Images</a></h:panelGroup>
13+
</div>
14+
<h:panelGrid width="100%">
15+
<rich:dataGrid columns="4" elements="12" value="#{invCtrl.car.distinctGroups}" var="group" style="width: 100%;">
16+
<h:panelGrid width="100%" headerClass="subHeader nowrap">
17+
<f:facet name="header">
18+
#{group.name}
19+
</f:facet>
20+
<rich:list value="#{invCtrl.car.features}" var="feat" styleClass="list-1">
21+
<h:outputText value="#{feat.featureValue}" rendered="#{group.name == feat.featureGroup.name}" styleClass="text-1"/>
22+
</rich:list>
23+
</h:panelGrid>
24+
</rich:dataGrid>
25+
</h:panelGrid>
26+
<div class="navPanel">
27+
<a4j:commandButton value="&lt;&lt;Previous" styleClass="button1 alignright" immediate="true">
28+
<rich:toggleControl targetItem="@prev" event="click" />
29+
</a4j:commandButton>
30+
<a4j:commandButton styleClass="fright button1" value="Next &gt;&gt;" rendered="#{invCtrl.car.persistent}">
31+
<rich:toggleControl targetItem="@next" event="click"/>
32+
</a4j:commandButton>
33+
<a4j:commandButton styleClass="fright button1" value="Submit" action="#{invCtrl.submitInventory}" render="@all">
34+
</a4j:commandButton>
35+
</div>
36+
</div>
37+
</ui:composition>

0 commit comments

Comments
 (0)