Skip to content

Commit 41ca7d5

Browse files
authored
Merge pull request #91 from HrBjarup/Task#102
Task#102 combined SVG
2 parents 2b6bf69 + 3c2d0a2 commit 41ca7d5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+4401
-1616
lines changed

FogCarport/pom.xml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@
5454
<plugin>
5555
<groupId>org.apache.maven.plugins</groupId>
5656
<artifactId>maven-compiler-plugin</artifactId>
57-
<version>3.1</version>
57+
<version>3.8.0</version>
5858
<configuration>
59-
<source>1.7</source>
60-
<target>1.7</target>
59+
<source>1.8</source>
60+
<target>1.8</target>
6161
<compilerArguments>
6262
<endorseddirs>${endorsed.dir}</endorseddirs>
6363
</compilerArguments>
@@ -104,6 +104,26 @@
104104
<reportOutputDirectory>${basedir}</reportOutputDirectory>
105105
</configuration>
106106
</plugin>
107+
<plugin>
108+
<groupId>org.jacoco</groupId>
109+
<artifactId>jacoco-maven-plugin</artifactId>
110+
<version>0.8.3</version>
111+
<executions>
112+
<execution>
113+
<id>default-prepare-agent</id>
114+
<goals>
115+
<goal>prepare-agent</goal>
116+
</goals>
117+
</execution>
118+
<execution>
119+
<id>default-report</id>
120+
<phase>prepare-package</phase>
121+
<goals>
122+
<goal>report</goal>
123+
</goals>
124+
</execution>
125+
</executions>
126+
</plugin>
107127
</plugins>
108128
</build>
109129

FogCarport/src/main/java/data/DataFacade.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package data;
22

33
import data.exceptions.LoginException;
4+
import data.models.CustomerModel;
5+
import data.models.EmployeeModel;
46
import data.models.MaterialModel;
57
import data.models.OrderModel;
68
import data.models.PartslistModel;
9+
import java.util.List;
710

811
public interface DataFacade
912
{
@@ -16,4 +19,14 @@ public interface DataFacade
1619
public PartslistModel getOrderDetails(int id) throws LoginException;
1720

1821
public void createOrder(OrderModel order) throws LoginException;
22+
23+
public List<Integer> getAllOrderIds() throws LoginException;
24+
25+
public EmployeeModel getEmployee(int id) throws LoginException;
26+
27+
public CustomerModel getCustomer(int id) throws LoginException;
28+
29+
public void createCustomer(CustomerModel customer) throws LoginException;
30+
31+
public void createEmployee(EmployeeModel employee) throws LoginException;
1932
}

FogCarport/src/main/java/data/DataFacadeImpl.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22

33
import data.databaseAccessObjects.mappers.MaterialMapper;
44
import data.databaseAccessObjects.mappers.OrderMapper;
5+
import data.databaseAccessObjects.mappers.UserMapper;
56
import data.exceptions.LoginException;
7+
import data.models.CustomerModel;
8+
import data.models.EmployeeModel;
69
import data.models.MaterialModel;
710
import data.models.OrderModel;
811
import data.models.PartslistModel;
12+
import java.util.List;
913

1014
/**
1115
*
@@ -54,4 +58,34 @@ public void createOrder(OrderModel order) throws LoginException
5458
OrderMapper.getInstance().createOrder(order);
5559
}
5660

61+
@Override
62+
public List<Integer> getAllOrderIds() throws LoginException
63+
{
64+
return OrderMapper.getInstance().getAllOrderIds();
65+
}
66+
67+
@Override
68+
public EmployeeModel getEmployee(int id) throws LoginException
69+
{
70+
return UserMapper.getInstance().getEmployee(id);
71+
}
72+
73+
@Override
74+
public CustomerModel getCustomer(int id) throws LoginException
75+
{
76+
return UserMapper.getInstance().getCustomer(id);
77+
}
78+
79+
@Override
80+
public void createCustomer(CustomerModel customer) throws LoginException
81+
{
82+
UserMapper.getInstance().createCustomer(customer);
83+
}
84+
85+
@Override
86+
public void createEmployee(EmployeeModel employee) throws LoginException
87+
{
88+
UserMapper.getInstance().createEmployee(employee);
89+
}
90+
5791
}

FogCarport/src/main/java/data/databaseAccessObjects/DBConnector.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
package data.databaseAccessObjects;
23

34
import java.sql.Connection;

FogCarport/src/main/java/data/databaseAccessObjects/mappers/MaterialMapper.java

Lines changed: 39 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
package data.databaseAccessObjects.mappers;
23

34
import data.databaseAccessObjects.DBConnector;
@@ -11,22 +12,17 @@
1112

1213
/**
1314
*
14-
* @author
15+
* @author
1516
*/
16-
public class MaterialMapper
17-
{
17+
public class MaterialMapper {
1818

1919
private static MaterialMapper materialMapper;
2020

21-
private MaterialMapper()
22-
{
23-
21+
private MaterialMapper() {
2422
}
2523

26-
public static MaterialMapper getInstance()
27-
{
28-
if (materialMapper == null)
29-
{
24+
public static MaterialMapper getInstance() {
25+
if (materialMapper == null) {
3026
materialMapper = new MaterialMapper();
3127
}
3228
return materialMapper;
@@ -40,25 +36,22 @@ public static MaterialMapper getInstance()
4036
* @return name of the category.
4137
* @throws LoginException Should most likely throw something else.
4238
*/
43-
public String getCategory(int id) throws LoginException
44-
{
39+
public String getCategory(int id) throws LoginException {
4540
String SQL = "SELECT `category`.`category_name`\n"
4641
+ "FROM `carportdb`.`category`\n"
4742
+ "WHERE `category`.`id_category` = ?;";
48-
// Using try-with resources, so they automatically close afterwards.
49-
try (Connection con = DBConnector.connection();
50-
PreparedStatement ps = con.prepareStatement(SQL);)
51-
{
43+
44+
try {
45+
Connection con = DBConnector.connection();
46+
PreparedStatement ps = con.prepareStatement(SQL);
5247
String category = "";
5348
ps.setInt(1, id);
5449
ResultSet rs = ps.executeQuery();
55-
while (rs.next())
56-
{
50+
while (rs.next()) {
5751
category = rs.getString("category_name");
5852
}
5953
return category;
60-
} catch (SQLException ex)
61-
{
54+
} catch (SQLException ex) {
6255
// Should most likely be another exception.
6356
throw new LoginException(ex.getMessage()); // ex.getMessage() Should not be in production.
6457
}
@@ -73,23 +66,24 @@ public String getCategory(int id) throws LoginException
7366
* @return MaterialModel
7467
* @throws LoginException Should probably be something else later on.
7568
*/
76-
public MaterialModel getMaterial(int id) throws LoginException
77-
{
69+
public MaterialModel getMaterial(int id) throws LoginException {
7870
MaterialModel material = new MaterialModel();
7971

80-
String SQL = "SELECT `description`, height, width, length, cost_price, unit, category_name "
81-
+ "FROM materials INNER JOIN `category` ON `materials`.`id_category` = `category`.`id_category`;";
82-
// Using try-with resources, so they automatically close afterwards.
83-
try (Connection con = DBConnector.connection();
84-
PreparedStatement ps = con.prepareStatement(SQL);)
85-
{
72+
String SQL = "SELECT `description`, height, width, length, cost_price, unit, category_name \n"
73+
+ "FROM materials \n"
74+
+ "INNER JOIN `category` \n"
75+
+ "ON `materials`.`id_category` = `category`.`id_category` \n"
76+
+ "WHERE `materials`.`id_material` = ?;";
77+
78+
try {
79+
Connection con = DBConnector.connection();
80+
PreparedStatement ps = con.prepareStatement(SQL);
8681
material.setID(id);
8782

8883
ps.setInt(1, id);
8984
ResultSet rs = ps.executeQuery();
9085

91-
while (rs.next())
92-
{
86+
while (rs.next()) {
9387
String description = rs.getString("description");
9488
material.setDescription(description);
9589

@@ -109,12 +103,10 @@ public MaterialModel getMaterial(int id) throws LoginException
109103
material.setUnit(unit);
110104

111105
String categoryname = rs.getString("category_name");
112-
material.setCategory(categoryname);
106+
material.setCategory(categoryname);
113107

114-
115108
}
116-
} catch (SQLException ex)
117-
{
109+
} catch (SQLException ex) {
118110
// Should most likely be another exception.
119111
throw new LoginException(ex.getMessage()); // ex.getMessage() Should not be in production.
120112
}
@@ -131,25 +123,21 @@ public MaterialModel getMaterial(int id) throws LoginException
131123
* @return name of the category.
132124
* @throws LoginException Should most likely throw something else.
133125
*/
134-
public String getOrderDetailsCategory(int id) throws LoginException
135-
{
126+
public String getOrderDetailsCategory(int id) throws LoginException {
136127
String SQL = "SELECT `order_details_category`.`details_category_name`\n"
137128
+ "FROM `carportdb`.`order_details_category`\n"
138129
+ "WHERE `order_details_category`.`id_order_details_category` = ?;";
139-
// Using try-with resources, so they automatically close afterwards.
140-
try (Connection con = DBConnector.connection();
141-
PreparedStatement ps = con.prepareStatement(SQL);)
142-
{
130+
try {
131+
Connection con = DBConnector.connection();
132+
PreparedStatement ps = con.prepareStatement(SQL);
143133
String category = "";
144134
ps.setInt(1, id);
145135
ResultSet rs = ps.executeQuery();
146-
while (rs.next())
147-
{
136+
while (rs.next()) {
148137
category = rs.getString("details_category_name");
149138
}
150139
return category;
151-
} catch (SQLException ex)
152-
{
140+
} catch (SQLException ex) {
153141
// Should most likely be another exception.
154142
throw new LoginException(ex.getMessage()); // ex.getMessage() Should not be in production.
155143
}
@@ -159,30 +147,27 @@ public String getOrderDetailsCategory(int id) throws LoginException
159147
// <editor-fold defaultstate="collapsed" desc="Get all Materials for an Order Details">
160148
/**
161149
* Get a List of Materials.
150+
*
162151
* @param id of the Order Details.
163152
* @return List of MaterialModel.
164153
* @throws LoginException Should most likely throw something else.
165154
*/
166-
public PartslistModel getMaterials(int id) throws LoginException
167-
{
155+
public PartslistModel getMaterials(int id) throws LoginException {
168156
PartslistModel materials = new PartslistModel();
169157
String SQL = "SELECT `order_details`.`id_material`\n"
170158
+ "FROM `carportdb`.`order_details`\n"
171159
+ "WHERE `order_details`.`id_order_details` = ?;";
172160

173-
// Using try-with resources, so they automatically close afterwards.
174-
try (Connection con = DBConnector.connection();
175-
PreparedStatement ps = con.prepareStatement(SQL);)
176-
{
161+
try {
162+
Connection con = DBConnector.connection();
163+
PreparedStatement ps = con.prepareStatement(SQL);
177164
ps.setInt(1, id);
178165
ResultSet rs = ps.executeQuery();
179-
while (rs.next())
180-
{
166+
while (rs.next()) {
181167
MaterialModel material = getMaterial(rs.getInt("id_material"));
182168
materials.addMaterial(material);
183169
}
184-
} catch (SQLException ex)
185-
{
170+
} catch (SQLException ex) {
186171
// Should most likely be another exception.
187172
throw new LoginException(ex.getMessage()); // ex.getMessage() Should not be in production.
188173
}

0 commit comments

Comments
 (0)