Skip to content

Commit 3221260

Browse files
authored
Merge pull request #97 from HrBjarup/revert-91-Task#102
Revert "Task#102 combined SVG"
2 parents 41ca7d5 + 461fefb commit 3221260

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

+1616
-4401
lines changed

FogCarport/pom.xml

Lines changed: 3 additions & 23 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.8.0</version>
57+
<version>3.1</version>
5858
<configuration>
59-
<source>1.8</source>
60-
<target>1.8</target>
59+
<source>1.7</source>
60+
<target>1.7</target>
6161
<compilerArguments>
6262
<endorseddirs>${endorsed.dir}</endorseddirs>
6363
</compilerArguments>
@@ -104,26 +104,6 @@
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>
127107
</plugins>
128108
</build>
129109

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

33
import data.exceptions.LoginException;
4-
import data.models.CustomerModel;
5-
import data.models.EmployeeModel;
64
import data.models.MaterialModel;
75
import data.models.OrderModel;
86
import data.models.PartslistModel;
9-
import java.util.List;
107

118
public interface DataFacade
129
{
@@ -19,14 +16,4 @@ public interface DataFacade
1916
public PartslistModel getOrderDetails(int id) throws LoginException;
2017

2118
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;
3219
}

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

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

33
import data.databaseAccessObjects.mappers.MaterialMapper;
44
import data.databaseAccessObjects.mappers.OrderMapper;
5-
import data.databaseAccessObjects.mappers.UserMapper;
65
import data.exceptions.LoginException;
7-
import data.models.CustomerModel;
8-
import data.models.EmployeeModel;
96
import data.models.MaterialModel;
107
import data.models.OrderModel;
118
import data.models.PartslistModel;
12-
import java.util.List;
139

1410
/**
1511
*
@@ -58,34 +54,4 @@ public void createOrder(OrderModel order) throws LoginException
5854
OrderMapper.getInstance().createOrder(order);
5955
}
6056

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-
9157
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
package data.databaseAccessObjects;
32

43
import java.sql.Connection;

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

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

43
import data.databaseAccessObjects.DBConnector;
@@ -12,17 +11,22 @@
1211

1312
/**
1413
*
15-
* @author
14+
* @author
1615
*/
17-
public class MaterialMapper {
16+
public class MaterialMapper
17+
{
1818

1919
private static MaterialMapper materialMapper;
2020

21-
private MaterialMapper() {
21+
private MaterialMapper()
22+
{
23+
2224
}
2325

24-
public static MaterialMapper getInstance() {
25-
if (materialMapper == null) {
26+
public static MaterialMapper getInstance()
27+
{
28+
if (materialMapper == null)
29+
{
2630
materialMapper = new MaterialMapper();
2731
}
2832
return materialMapper;
@@ -36,22 +40,25 @@ public static MaterialMapper getInstance() {
3640
* @return name of the category.
3741
* @throws LoginException Should most likely throw something else.
3842
*/
39-
public String getCategory(int id) throws LoginException {
43+
public String getCategory(int id) throws LoginException
44+
{
4045
String SQL = "SELECT `category`.`category_name`\n"
4146
+ "FROM `carportdb`.`category`\n"
4247
+ "WHERE `category`.`id_category` = ?;";
43-
44-
try {
45-
Connection con = DBConnector.connection();
46-
PreparedStatement ps = con.prepareStatement(SQL);
48+
// Using try-with resources, so they automatically close afterwards.
49+
try (Connection con = DBConnector.connection();
50+
PreparedStatement ps = con.prepareStatement(SQL);)
51+
{
4752
String category = "";
4853
ps.setInt(1, id);
4954
ResultSet rs = ps.executeQuery();
50-
while (rs.next()) {
55+
while (rs.next())
56+
{
5157
category = rs.getString("category_name");
5258
}
5359
return category;
54-
} catch (SQLException ex) {
60+
} catch (SQLException ex)
61+
{
5562
// Should most likely be another exception.
5663
throw new LoginException(ex.getMessage()); // ex.getMessage() Should not be in production.
5764
}
@@ -66,24 +73,23 @@ public String getCategory(int id) throws LoginException {
6673
* @return MaterialModel
6774
* @throws LoginException Should probably be something else later on.
6875
*/
69-
public MaterialModel getMaterial(int id) throws LoginException {
76+
public MaterialModel getMaterial(int id) throws LoginException
77+
{
7078
MaterialModel material = new MaterialModel();
7179

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);
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+
{
8186
material.setID(id);
8287

8388
ps.setInt(1, id);
8489
ResultSet rs = ps.executeQuery();
8590

86-
while (rs.next()) {
91+
while (rs.next())
92+
{
8793
String description = rs.getString("description");
8894
material.setDescription(description);
8995

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

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

114+
108115
}
109-
} catch (SQLException ex) {
116+
} catch (SQLException ex)
117+
{
110118
// Should most likely be another exception.
111119
throw new LoginException(ex.getMessage()); // ex.getMessage() Should not be in production.
112120
}
@@ -123,21 +131,25 @@ public MaterialModel getMaterial(int id) throws LoginException {
123131
* @return name of the category.
124132
* @throws LoginException Should most likely throw something else.
125133
*/
126-
public String getOrderDetailsCategory(int id) throws LoginException {
134+
public String getOrderDetailsCategory(int id) throws LoginException
135+
{
127136
String SQL = "SELECT `order_details_category`.`details_category_name`\n"
128137
+ "FROM `carportdb`.`order_details_category`\n"
129138
+ "WHERE `order_details_category`.`id_order_details_category` = ?;";
130-
try {
131-
Connection con = DBConnector.connection();
132-
PreparedStatement ps = con.prepareStatement(SQL);
139+
// Using try-with resources, so they automatically close afterwards.
140+
try (Connection con = DBConnector.connection();
141+
PreparedStatement ps = con.prepareStatement(SQL);)
142+
{
133143
String category = "";
134144
ps.setInt(1, id);
135145
ResultSet rs = ps.executeQuery();
136-
while (rs.next()) {
146+
while (rs.next())
147+
{
137148
category = rs.getString("details_category_name");
138149
}
139150
return category;
140-
} catch (SQLException ex) {
151+
} catch (SQLException ex)
152+
{
141153
// Should most likely be another exception.
142154
throw new LoginException(ex.getMessage()); // ex.getMessage() Should not be in production.
143155
}
@@ -147,27 +159,30 @@ public String getOrderDetailsCategory(int id) throws LoginException {
147159
// <editor-fold defaultstate="collapsed" desc="Get all Materials for an Order Details">
148160
/**
149161
* Get a List of Materials.
150-
*
151162
* @param id of the Order Details.
152163
* @return List of MaterialModel.
153164
* @throws LoginException Should most likely throw something else.
154165
*/
155-
public PartslistModel getMaterials(int id) throws LoginException {
166+
public PartslistModel getMaterials(int id) throws LoginException
167+
{
156168
PartslistModel materials = new PartslistModel();
157169
String SQL = "SELECT `order_details`.`id_material`\n"
158170
+ "FROM `carportdb`.`order_details`\n"
159171
+ "WHERE `order_details`.`id_order_details` = ?;";
160172

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

0 commit comments

Comments
 (0)