Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 43 additions & 10 deletions scripts/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
?obj <info:fedora/fedora-system:def/model#hasModel> ?model;
}
GROUP BY ?model
ORDER BY DESC(?count)
""",

"object_count": """
Expand All @@ -24,17 +25,20 @@
{
SELECT ?activeObj
WHERE {
?activeObj <info:fedora/fedora-system:def/model#state> <info:fedora/fedora-system:def/model#Active> .
?activeObj <info:fedora/fedora-system:def/model#hasModel> <info:fedora/fedora-system:FedoraObject-3.0> ;
<info:fedora/fedora-system:def/model#state> <info:fedora/fedora-system:def/model#Active> .
}
} UNION {
SELECT ?deletedObj
WHERE {
?deletedObj <info:fedora/fedora-system:def/model#state> <info:fedora/fedora-system:def/model#Deleted> .
?deletedObj <info:fedora/fedora-system:def/model#hasModel> <info:fedora/fedora-system:FedoraObject-3.0> ;
<info:fedora/fedora-system:def/model#state> <info:fedora/fedora-system:def/model#Deleted> .
}
} UNION {
SELECT ?inactiveObj
WHERE {
?inactiveObj <info:fedora/fedora-system:def/model#state> <info:fedora/fedora-system:def/model#Inactive> .
?inactiveObj <info:fedora/fedora-system:def/model#hasModel> <info:fedora/fedora-system:FedoraObject-3.0> ;
<info:fedora/fedora-system:def/model#state> <info:fedora/fedora-system:def/model#Inactive> .
}
}
}
Expand All @@ -44,15 +48,17 @@
SELECT ?obj
FROM <#ri>
WHERE {
?obj <info:fedora/fedora-system:def/model#state> <info:fedora/fedora-system:def/model#Deleted>
?obj <info:fedora/fedora-system:def/model#hasModel> <info:fedora/fedora-system:FedoraObject-3.0> ;
<info:fedora/fedora-system:def/model#state> <info:fedora/fedora-system:def/model#Deleted>
}
""",

"inactive_objects": """
SELECT ?obj
FROM <#ri>
WHERE {
?obj <info:fedora/fedora-system:def/model#state> <info:fedora/fedora-system:def/model#Inactive>
?obj <info:fedora/fedora-system:def/model#hasModel> <info:fedora/fedora-system:FedoraObject-3.0> ;
<info:fedora/fedora-system:def/model#state> <info:fedora/fedora-system:def/model#Inactive>
}
""",

Expand All @@ -67,6 +73,7 @@
}
}
GROUP BY ?datastream
ORDER BY DESC(?count)
""",

"owner_distribution": """
Expand All @@ -76,6 +83,7 @@
?obj <info:fedora/fedora-system:def/model#ownerId> ?owner;
}
GROUP BY ?owner
ORDER BY DESC(?count)
""",

"collection_distribution": """
Expand All @@ -86,6 +94,7 @@
?collection <info:fedora/fedora-system:def/model#hasModel> <info:fedora/fedora-system:FedoraObject-3.0>
}
GROUP BY ?collection
ORDER BY DESC(?count)
""",

"relationships": """
Expand All @@ -98,17 +107,27 @@
""",

"orphaned_objects": """
SELECT DISTINCT ?orphan
SELECT DISTINCT ?object ?title
FROM <#ri>
WHERE {
?orphan <info:fedora/fedora-system:def/model#hasModel> <info:fedora/fedora-system:FedoraObject-3.0>
FILTER NOT EXISTS {
?orphan <info:fedora/fedora-system:def/relations-external#isMemberOf> ?subject .
# Get all objects with parent-like relationships
?object <fedora-model:hasModel> <info:fedora/fedora-system:FedoraObject-3.0> ;
<fedora-model:label> ?title .
VALUES ?p {
<fedora-rels-ext:isMemberOfCollection>
<fedora-rels-ext:isMemberOf>
<fedora-rels-ext:isConstituentOf>
}
?object ?p ?otherobject .
# Exclude if the other object actually exists (i.e., has a model)
FILTER NOT EXISTS {
?orphan <info:fedora/fedora-system:def/relations-external#isMemberOfCollection> ?subject .
?otherobject <fedora-model:hasModel> ?anyModel .
}
}
ORDER BY ?object
""",

"mimetype_distribution": """
Expand All @@ -118,5 +137,19 @@
?o <info:fedora/fedora-system:def/view#mimeType> ?mimetype
}
GROUP BY ?mimetype
ORDER BY DESC(?count)
""",

"namespace_distribution": """
SELECT ?namespace (COUNT(?namespace) as ?count)
FROM <#ri>
WHERE {
?obj <info:fedora/fedora-system:def/model#hasModel> <info:fedora/fedora-system:FedoraObject-3.0> .
FILTER STRSTARTS(STR(?obj), "info:fedora/")
BIND(STRAFTER(STR(?obj), "info:fedora/") AS ?after)
BIND(STRBEFORE(?after, ":") AS ?namespace)
}
GROUP BY ?namespace
ORDER BY DESC(?count)
"""
}