Criterion C: Development
Outline of Complex Techniques and Tools
File Organization
Figure 1. File Organization (*Note: Red boxed files are the most important files)
Package com.example.properties - Main package with main files “Entity.java”, “Product.java”,
“readwriteexcel.java”
Entity.java - the superclass for Product.java
Readwriteexcel.java - the main class used to modify and read the excel file.
FileUploadController.java - Controls the upload of the file (com.example.uploadingfiles)
UploadingFilesApplication.java - Handles running the FileUploadController.java
(com.example.uploadingfiles)
All files under uploadingfiles.storage package handles file uploading (more details below)
Imported Libraries
Figure 2. Imported Libraries (Spring.io)
time.LocalDate - Used to determine the date at any time and is formatted using the
format.DateTimeFormatter into the standard time form used (MM/dd/yy)
Apache.poi - Used to modify and create the modified excel sheet.
List of Techniques
1. Inheritance
2. Object arrays w/ user defined objects
3. Sorting algorithm
4. Additional libraries (seen above)
5. Polymorphism
IDE Used
Spring Tool Framework IDE was used as I needed to implement Spring to connect with the java
backend of my excel sheet modifier. I decided on this specific IDE because its features closely
resembled and are linked to Eclipse which is the normal IDE that I use in class. In other words, it
was convenient and a tool I was already familiar with.
Demonstration of Complex Techniques and Tools Used
Inheritance
Inheritance – A parent object/class holds data and attributes that can then be inherited from a
child class/object. The usage of inheritance allows for more efficiency in the code as well as
eliminating the repetition of certain attributes that needed to be used in other classes. In this
project, inheritance was used in the Entity and Product classes. The variables “ID” (changed to
RD in Product class) and “Country” were inherited from the Entity class.
Figure 3. UML diagram illustrating the inheriting of entity from product
The above code block demonstrates the usage of inheritance through the Product class inheriting
some attributes and properties from Entity.
The Entity class was originally made to contain those two variables due to an Employee class,
however the client decided against this Employee class later in the process. The Entity class was
still kept in, in the event that the client did want to add in Employee security in an Employee
class. (Appendix A, interview 2)
Inheritance was also used in classes that specifically looked at error exceptions. For example the
StorageException class extends the RuntimeException from Java as seen below.
Another case of inheritance is used in another class of storage exceptions called
StorageFileNotFoundException. This class extends the StorageException class. (“Spring
Projects”)
This image above provides an overview of the usage of inheritance used in this project.
Object arraylist
Object arraylist – A data structure consisting of objects that are a part of a certain class.
Figure 4. Object arraylist and creating excel sheet
Arraylist of objects that represent the products being put into the excel sheet. Each product object
carries attributes that modify the excel sheet when sorted. The storage of the objects into the
arraylist works as follows:
As seen above, the data is collected from each cell and stored into the product object which is
then stored into the product arraylist. There is a special case however if there is a date variable as
the date variable needs to be parsed into the correct format.
The above image shows the retrieving of cell values from the original spreadsheet.
Figure 5. Parsing of date variable
Figure 5 is repeated for each of the date variables that need to be parsed in the excel sheet. For
the different variable types (String or numeric), the cells are modified in a different way. In
figure 5, a date type value was formatted but an if statement was implemented for checking if the
cell held a string or date value so date-sorting could be used later on.
Figure 5.1 Implementation of modification of cell as shown in figure 5
The above code saves the product objects into the product arraylist for later usage.
Exception handling above is used to make sure that the right variable is in the right column and
thus can be parsed and stored correctly into the Product arraylist.
For example, the P1UOrder # is supposed to have longs as the variable type. However, if
someone were to type a string, a variable type mismatch error would be thrown and thus the
sheet would not be modified.
Sorting algorithm
Figure 6. Sorting Algorithm Implementation
Figure 6 shows a collections.sort which uses a MergeSort algorithm to sort the dates in order.
The MergeSort algorithm proved to be very efficient when sorting the items and did not take a
long time. Collections.sort was also much easier to use as it used built in methods from other
classes that java has and worked well with the comparison and sorting methods that the project
required.
The sorting algorithm implementation is shown here in the UI where the excel file modifies the
products based on the difference in HandOffDate and TargetDeliveryDate.
In addition to the sorting algorithm, the products also need to have comments written on them
based on the difference in date.
The comment would be seen as a sticky note attached to the cell that the user can view when
hovering over it.
As shown below, the comments and the day difference correspond to each other.
Polymorphism
Polymorphism - A mix of inherited behaviours that make them unique to their own class. In this
project, overriding, a form of polymorphism was used.
As seen in the figure above, the different methods from FileSystemStorageService class
(com.example.uploadingfiles.storage) are overriding the methods that are in the interface
StorageService. This is good for clarity and also to catch errors at compile-time. Therefore
making the code more maintainable and less error prone.
Outline of Algorithmic Thinking
Figure 7. UML Diagram of Classes
Figure 7 gives a brief overview of the classes used and how they correspond with each other.
(Link to figure 7 is hyperlinked). Below is a list of algorithmic thinking used:
1. Algorithm of calculating the difference between two time variables after they have been
passed.
2. Algorithm of comparing and sorting according to the difference in days of two variables
3. Algorithm to add comments to certain orders depending on priority dates
4. Algorithm to upload and return processed file
5. Algorithm to rewrite the new sorted information into the file
Demonstration of Algorithmic Thinking
Calculating the difference between two time variables after they have been passed
Brief overview:
Figure 8 gives an overview of the whole algorithm. There’s two variables called HandOffDate
and TargetDeliveryDate which are then subtracted from each other and taken the absolute value
of. This is then stored in getDaysDifference in order to be used in a later algorithm (algorithm 2).
Implementation:
Figure 8. Flowchart demonstrating calculating the difference between two time variables after
they have been passed
Figure 9. Code showing the implementation of getting the two variables from the sheet, parsing
them where necessary and finding the difference
The dates are all modified into a standard month, date, year system.
Comparing and sorting according to the difference in days of two variables
Brief overview:
The comparison and sorting of the two variables needed to be done in order to properly display
the products in order of priority in the modified excel sheet. The implementation included the
usage of a sorting algorithm (MergeSort, which is described in further detail in the sorting
algorithm section).
Implementation:
Figure 10. Code implementation of sorting and comparison of products
A Collections.sort method was used as well as a comparator to compare between the difference
of the days in products. Below that, the sorted products were then written back to the modified
excel file.
Add comments to certain orders depending on priority dates
Brief overview:
Comments needed to be added to the excel spreadsheet depending on the difference in day. The
algorithm for this is shown in the flowchart below:
Figure 11. Flowchart representing the planning stage of comment assignments
Implementation
Figure 12. Code implementation of comment algorithm
The if statements above use the daysDifference who’s calculation is seen in Figure 9. The
program then determines whether the daysDifference falls between certain integer boundaries.
Depending on the boundaries, a different comment would be made and added into the comment
cell. This implementation on the UI is seen in the sorting algorithm section.
Upload and return processed file
Brief overview:
1. Send path file of modified excel sheet to storage of Spring
2. Spring would then upload the file to file-upload template of HTML file
3. HTML file would allow for user to download the file and open it in excel
This method is a simplified approach of what Spring goes through.
Implementation:
The above code highlights the interface that is being and consists of deleting, storing and loading
the file to the correct place.
This style sheet was used solely because it was very simple for the client to use. It allows for
easy uploading of files and displays the file name on there to make sure that the correct file is
being uploaded. (Appendix A, interview 2)
This error occurs when the URL used to connect to the server is incorrect or improperly
formatted. (com.example.uploadingfiles.storage.)
Rewrite the new sorted information into the file
Brief overview:
An algorithm needed to be used in order to rewrite the newly sorted products into the spreadsheet
file so when opened, there would be a spreadsheet of products listed in terms of priority.
Implementation:
Word count: 1200
Works Cited
“Spring Projects.” Spring.io, 2017, spring.io/projects/spring-framework. Accessed 27 Sept. 2023.
com.example.uploadingfiles. Spring Framework, VMware Tanzu, 2016. Github,
https://github.com/spring-guides/gs-uploading-files/tree/main/complete/src/main/java/co
m/example/uploadingfiles
com.example.uploadingfiles.storage. Spring Framework, VMware Tanzu, 2016. Github,
https://github.com/spring-guides/gs-uploading-files/tree/main/complete/src/main/java/co
m/example/uploadingfiles/storage