Description of the problem3.1 Use case diagram, package diagram and class diagram.*Use case diagram: - In our program, when user wants to collect data, the program will collect all the d
Trang 1School of Information and Communication Technology
Class: 131118
Teacher: Trinh Tuan Dat
Trang 3In the course OOP, we have studied a lot about Object Oriented Programming theory, including UML diagram, java basics, exceptions, javafx , the four principles of OOP :encapsulation, abstraction, inheritance, and polymorphism , and so on
In this report, we present the Collecting Vietnam Tourism Data problem and propose some “OOP” way for solving this problem We will also concentrate on explaining in detail how each part of the program works and how it interacts with each other
Trang 41.Presentation of the subject
*Aims:
-The aim of the program is to collect tourism data from tourism websites and store the data in files using the turtle format Each topic needs to be stored in separate files
*Some knowledge used:
-Sparql Query: SPARQL is the standard query language and protocol for Linked Open Data and RDF databases Having been designed to query a great variety of data, it can efficiently extract information hidden in non-uniform data and stored in various formats and sources
-Library Apache Jena: A free and open-source Java framework for building Semantic Web and Linked Data applications
-DBPedia: a crowd-sourced community effort to extract structured content from the information created in various Wikimedia projects
*Our solution
- Our team decided to use Sparql Query to query data from DBPedia To do so in
Java, we will apply the Library Apache Jena to our program
Trang 5● First you download our project and open it inside your Eclipse IDE Our project is
a Maven project so it will have a file named pom.xml
● Open file pom.xml, make sure it has this part
Trang 6● Right click on the VnTourism (the project name) then choose Run As-> Maven build Now you have installed all the dependencies you need.
● Now you have to apply the JavaFx to our project
- To do this, you can watch this video here and follow its instructionJavaFX install & setup (Eclipse) � by youtuber Bro Code
● After installing the JavaFx, now you can run our project without any bugs
Trang 73 Description of the problem
3.1 Use case diagram, package diagram and class diagram
*Use case diagram:
- In our program, when user wants to collect data, the program will collect all the data related to it from DBPedia, store it in a ttl (we name it with prefix rawRDF) For example, when we want to collect data about Lakes in Vietnam, we will collect all data about Lake from DBPedia and store it in rawRDF_Lake.ttl
- After that, we extract the data we need to Lake.ttl then we delete rawRDF_Lake.ttl
*Package diagram :
Trang 9+ createSparqlQuery(): create sparql query to query data.
+ createFileName(): create a file name of the information we want to get.
+ createRawFileName(): create a file name for the whole data we query from the internet
Trang 10+In each class from class TouristAttraction to last subclass there are corresponding attributes and
the method overridden createSparqlQuery() For example, in class TouristAttraction:
+ Each attribute will be initialized in the constructor with the information we want to query,and will be used inside the sparql query
+ Getters
Trang 12+ Prefix.java declares all prefixes of SPARQL will be used in the Sparql query in the
whole program
3.3 Detailed description of front end
To implement UI for our program, we use JavaFx
We use Grid Pane layout to design the UI; ComboBox, Button, ToggleButton and RadioButton elements are used to show available choices that user can pick ToggleGroup is used to group therelevant RadioButton and ToggleButton elements
Trang 13Anytime a user wants to quit the application, the user clicks on the “Exit” button.
To get started, users will click on the “Tourist Attraction” option When the “Tourist Attraction” option is clicked, the “All” option is selected by default and the “Get” button is enabled
Figure 2: "Tourist Attraction" option is selected
The reason we set two buttons “All” and “Detail” is to simulate the inheritance relation between the classes we implement in our program “Tourist Attraction” is the parent class of all other classes
Choosing “All” will collect all the data about every attraction from the database
Trang 14If user wishes to choose a more specific kind of attraction, click “Detail”
Figure 3: "Detail" option is selected
We have 2 sub-categories: Man-made attraction and Natural Attraction Selecting any option of these will show up the “All” and “Detail” button, like the “Tourist Attraction” option, and disablethe “Get” button
The “Get” button will be enabled again when user choose an option
Figure 4:"Natural Attraction" is selected, with "Detail" chosen
If the “All” option is selected, data about all natural attractions or man-made attractions will be collected Otherwise, when “Detail” is selected, a ChoiceBox element will show up Users can specify the choice here
Here is the available options for the sub-categories:
Trang 16is shown.
Figure 7:"Modern Architecture" option selected
Similarly, if the user chooses the “Body of Water” option in natural attraction, another ChoiceBox is shown
Trang 17When the user makes his choice and clicks “Get”, a confirmation dialog will show.
Trang 18Click “Cancel” will return to the main menu.
When the user chooses “OK”, the collect process will start A dialog will show the output of the process
Trang 19When the process is completed successfully, a dialog will show.
Trang 20Users can see the output in the text area.
If the process fails, a dialog will show to inform the user that the task is not successful.For each element, we have set the corresponding listener and handler so that the proper choice will be shown/hidden/enabled/disabled
Trang 214 OOP techniques used in the program
4.1 Abstraction:
=> It reduces the complexity of viewing things
=> Avoids code duplication and increases reusability
=> Helps to increase the security of an application or program as only essential details are provided to the user
=> It improves the maintainability of the application
4.2 Encapsulation:
● Data/attributes and behaviors/methods are encapsulated in a class
● Every single class in package touristattraction follows this rule For example, in the class TouristAttraction:
Trang 22=> Protects an object from unwanted access
=>Simplifies the maintenance of the application
=> Makes the application easier to understand
Trang 23=> ensures exclusive data access to class members and protects object integrity by preventing unintended or intended changes
Trang 24=> store the variable we have to reuse many times in the project.4.5 Variable arguments
- In interface IDataProcess,we use this technique
=> To pass an arbitrary number of arguments
4.6 Utility classes in Java
- In class App, we have used Number class
=>To use all the functions Java has had
Trang 25We have the diagram of package touristattraction.
=>Code reuse
=> Provides a clear model structure which is easy to understand
4.8 JavaFX
- You can check class App to see the JavaFx Application we have created
4.9 Catching and handling exceptions, nested try – catch blocks
- In interface IDataProcess, we have use try catch finally to handle the exceptions
Trang 264.10 Generic programming: using Wildcard
- In class App
=> Elimination of casts
5.Conclusion and further discussions
-So, with the help of OOP, we have finished the assignment Thanks to the hard work of the team, we have done quite well, though there are a lot more needed to be done We have learned
to use a lot of techniques in OOP, how to model a program so that it can run better
- In the future, we can upgrade our program to make it better This can be done with ease since our model follows high cohesion and loose coupling In the future, our team will keep enhancing this program Special thanks to Mr Trinh Tuan Dat for helping us with OOP lectures
Trang 276 Task contribution:
6.1 Programming tasks:
- Modelling the project, the logic of code: Đỗ Tuấn Minh
-Code package backend:
+Code package rdfconstant, dataprocess: Đỗ Tuấn Minh
+Code package touristattraction: Đỗ Tuấn Minh, Nguyễn Phương Quang
-Code package frontend : Nguyễn Hoàng Hải
6.2 Other tasks:
- Create use case diagram: Đỗ Tuấn Minh
- Create package diagram, class diagram: Nguyễn Hoàng Hải
- Write the report:
+ 1,2,3.1,4,6: Đỗ Tuấn Minh
+ 3.2: Nguyễn Phương Quang
+ 3.3: Nguyễn Hoàng Hải
- Formatting the report: Nguyễn Kim Tuyến
- Demo video: Đỗ Tuấn Minh
- Make the powerpoint: Nguyễn Phương Quang
- Presenter: Đỗ Tuấn Minh
7 List of bibliographic reference:
- https://www.ontotext.com/knowledgehub/fundamentals/what-is-sparql/
- https://jena.apache.org/
- https://drive.google.com/drive/folders/1Q8aSZ3O_jWDxp60yqcc9pOSIqxrORRsY