-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexemplar_execution.py
82 lines (68 loc) · 3.56 KB
/
exemplar_execution.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# -*- coding: utf-8 -*-
# Copyright (c) 2023, Silvio Peroni <[email protected]>
#
# Permission to use, copy, modify, and/or distribute this software for any purpose
# with or without fee is hereby granted, provided that the above copyright notice
# and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
# OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
# SOFTWARE.
# Supposing that all the classes developed for the project
# are contained in the file 'impl.py', then:
# 1) Importing all the classes for handling the relational database
from impl import ProcessDataUploadHandler, ProcessDataQueryHandler
# 2) Importing all the classes for handling graph database
from impl import MetadataUploadHandler, MetadataQueryHandler
# 3) Importing the class for dealing with mashup queries
from impl import AdvancedMashup
# Once all the classes are imported, first create the relational
# database using the related source data
rel_path = "relational.db"
process = ProcessDataUploadHandler()
process.setDbPathOrUrl(rel_path)
process.pushDataToDb("C:\\kucing\\peroni\\DataScience-DHDK-gp24\\data\\process.json")
# Please remember that one could, in principle, push one or more files
# calling the method one or more times (even calling the method twice
# specifying the same file!)
# Then, create the graph database (remember first to run the
# Blazegraph instance) using the related source data
grp_endpoint = "http://127.0.0.1:9999/blazegraph/sparql"
metadata = MetadataUploadHandler()
metadata.setDbPathOrUrl(grp_endpoint)
metadata.pushDataToDb("C:\\kucing\\peroni\\DataScience-DHDK-gp24\\data\\meta.csv")
# Please remember that one could, in principle, push one or more files
# calling the method one or more times (even calling the method twice
# specifying the same file!)
# In the next passage, create the query handlers for both
# the databases, using the related classes
process_qh = ProcessDataQueryHandler()
process_qh.setDbPathOrUrl(rel_path)
metadata_qh = MetadataQueryHandler()
metadata_qh.setDbPathOrUrl(grp_endpoint)
# Finally, create a advanced mashup object for asking
# about data
mashup = AdvancedMashup()
mashup.addProcessHandler(process_qh)
mashup.addMetadataHandler(metadata_qh)
result_q1 = mashup.getEntityById("VIAF:78822798")
result_q2 = mashup.getAllPeople()
result_q3 = mashup.getAllCulturalHeritageObjects()
result_q4 = mashup.getAuthorsOfCulturalHeritageObject("1")
result_q5 = mashup.getCulturalHeritageObjectsAuthoredBy("VIAF:78822798")
result_q6 = mashup.getAllActivities()
result_q7 = mashup.getActivitiesByResponsibleInstitution("Council")
result_q8 = mashup.getActivitiesByResponsiblePerson("Liddell")
result_q9 = mashup.getActivitiesUsingTool("Blender")
result_q10 = mashup.getActivitiesStartedAfter("2023-05-08")
result_q11 = mashup.getActivitiesEndedBefore("2023-05-09")
result_q12 = mashup.getAcquisitionsByTechnique("Photogrammetry")
result_q13 = mashup.getActivitiesOnObjectsAuthoredBy("VIAF:78822798")
result_q14 = mashup.getObjectsHandledByResponsiblePerson("Liddell")
result_q15 = mashup.getObjectsHandledByResponsibleInstitution("Council")
result_q16 = mashup.getAuthorsOfObjectsAcquiredInTimeFrame("2023-04-01", "2023-05-01")
print("debug breakpoint")