Skip to content
2 changes: 1 addition & 1 deletion static/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -10431,7 +10431,7 @@ button.tiny {
white-space: pre-wrap; /* Preserves formatting like spaces and line breaks */
box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.2);
z-index: 9;
transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
/* transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease; */
}

.tooltip::before {
Expand Down
11 changes: 6 additions & 5 deletions static/data/fieldLabels.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
{
"people_gend": "People gend",
"people_roles": "People roles",
{
"people" : "Person",
"people_gend": "Person gender",
"people_roles": "Roles or titles of person",
"aut": "Author",
"author_sort": "Author",
"aut_mark": "Author as marked",
"aut_org": "Author is organization",
"agent_org": "Author, recipient etc is organization",
"aut_gend": "Author Gender",
"aut_gend": "Author gender",
"aut_roles": "Roles or titles of author",
"rec": "Recipient",
"rec_roles": "Roles or titles of recipient",
"rec_mark": "Recipient as marked",
"rec_org": "Recipient is organization",
"rec_gend": "Recipient Gender",
"rec_gend": "Recipient gender",
"ment": "Person or organization mentioned",
"ment_gend": "Gender of person mentioned",
"ment_roles": "Roles or titles of person mentioned",
Expand Down
60 changes: 48 additions & 12 deletions static/js/edges.js
Original file line number Diff line number Diff line change
Expand Up @@ -2340,13 +2340,9 @@ emlo.MultiFields = class extends edges.Component {
this.gneratedData["manifestationData"] = {};
}

let relationsArray = await this._fetchRelations(uuid);
// let relationsArray = await this._fetchManifestationData(uuid);

this.gneratedData["manifestationData"][uuid] =
relationsArray.reduce((acc, item) => {
acc[item.uuid] = item;
return acc;
}, {});
this.gneratedData["manifestationData"][uuid] = await this._fetchManifestationData(uuid);
}
}
}
Expand All @@ -2364,6 +2360,27 @@ emlo.MultiFields = class extends edges.Component {
this.hitCount = source.total();
}

async _fetchManifestationData(uuid) {
try {
const response = await fetch(`/manifestation-data/${uuid}`, {
headers: {
"Content-Type": "application/json",
},
});

if (!response.ok) {
console.error(`Error fetching relations: ${response.statusText}`);
return [];
}

const json = await response.json();
return json;
} catch (err) {
console.error("Error while fetching relations", err);
return {};
}
}

async _fetchMoreWorkData(payload) {
try {
const response = await fetch(`/stats-new`, {
Expand Down Expand Up @@ -5830,19 +5847,38 @@ function GetRecordID(type, result) {
}, // Resource query pattern
m: {
field: "dcterms_identifier-edit_",
splitValue: "edit_cofk_union_manifestation-cofk_edit_interface-iwork_id:",
}, // Manifestation query pattern
splitValues: [
":",
"edit_cofk_union_manifestation-",
],
},
// m: {
// field: "dcterms_identifier-edit_",
// splitValue: "edit_cofk_union_manifestation-cofk_edit_interface-iwork_id:",
// }, // Manifestation query pattern
};

console.log("result" , result["id"] , result["dcterms_identifier-edit_"])

const queryConfig = QUERY_MAP[type];
if (queryConfig) {
// Retrieve the value from the result object for the given field
const fieldValue = result[queryConfig.field];
if (fieldValue) {
// Split the value using the delimiter (e.g., "editi_") and get the last part
const splitValue = fieldValue.split(queryConfig.splitValue).pop();
// Return the query by combining the split value and the id
return `${splitValue}`;

if (queryConfig.splitValues) {
for (const splitter of queryConfig.splitValues) {
if (fieldValue.includes(splitter)) {
return fieldValue.split(splitter).pop();
}
}
throw new Error(`No valid splitter found in value: ${fieldValue}`);
} else {
// Split the value using the delimiter (e.g., "editi_") and get the last part
const splitValue = fieldValue.split(queryConfig.splitValue).pop();
// Return the query by combining the split value and the id
return `${splitValue}`;
}
} else {
throw new Error(`Field ${queryConfig.field} not found in result object`);
}
Expand Down
17 changes: 7 additions & 10 deletions static/js/helper/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@ export function getFieldsToDisplayInProfile(objectType, nested = true) {

"ox_isAnnotatedBy-comment",

"dcterms_created", // dummy field to insert date
// get_creation_date_year_fieldname(),
// get_creation_date_month_fieldname(),
// get_creation_date_day_fieldname(),
"dcterms_created-ox_year",
"dcterms_created-ox_month",
"dcterms_created-ox_day",
"ox_dateAnnotate-comment",

"mail_handwroteBy-person",
Expand Down Expand Up @@ -88,14 +87,12 @@ export function getFieldsToDisplayInProfile(objectType, nested = true) {
"ox_postage_costs",
"ox_non_delivery_reason",
"ox_date_of_receipt_as_marked",

// get_fieldname_manifestation_receipt_date_day(),
// get_fieldname_manifestation_receipt_date_month(),
// get_fieldname_manifestation_receipt_date_year(),
"ox_manifestation_receipt_date_day",
"ox_manifestation_receipt_date_month",
"ox_manifestation_receipt_date_year",
"ox_manifestation_receipt_calendar",
"ox_manifestation_receipt_date",
// get_manifestation_receipt_date_gregorian_fn(),

"ox_manifestation_receipt_date_gregorian",
"ox_manifestation_receipt_date_inferred",
"ox_manifestation_receipt_date_uncertain",
"ox_manifestation_receipt_date_approx",
Expand Down
9 changes: 5 additions & 4 deletions static/js/helper/getFieldLabls.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
const labels = {
people_gend: "People gend",
people_roles: "People roles",
people : "Person",
people_gend: "Person gender",
people_roles: "Roles or titles of person",
aut: "Author",
author_sort: "Author",
aut_mark: "Author as marked",
aut_org: "Author is organization",
agent_org: "Author, recipient etc is organization",
aut_gend: "Author Gender",
aut_gend: "Author gender",
aut_roles: "Roles or titles of author",
rec: "Recipient",
rec_roles: "Roles or titles of recipient",
rec_mark: "Recipient as marked",
rec_org: "Recipient is organization",
rec_gend: "Recipient Gender",
rec_gend: "Recipient gender",
ment: "Person or organization mentioned",
ment_gend: "Gender of person mentioned",
ment_roles: "Roles or titles of person mentioned",
Expand Down
6 changes: 5 additions & 1 deletion static/js/helper/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,10 @@ export function detailsOfOneObject(profile, obj, data, nested = false) {
}
}

if(data.hasOwnProperty(relation.uuid) && nested) {
manifestationData = data
}

let frag = ` <div class="display_details_of_one_object ${nested}">`;

const uriFieldName = "dcterms_identifier-uri_";
Expand Down Expand Up @@ -1095,7 +1099,7 @@ export function detailsOfOneObject(profile, obj, data, nested = false) {
if (label) {
frag += `<p><span class="fieldlabel">${label}:</span></p>`;
}
frag += detailsOfOneObject({}, relatedObj, {}, true); // Assumes it returns a string
frag += detailsOfOneObject({}, relatedObj, manifestationData, true); // Assumes it returns a string
} else {
if (displayValue) {
if (label) {
Expand Down
15 changes: 12 additions & 3 deletions static/js/result.edges.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ function _renderMultipleFields(val, res, fieldName) {

let objectType = res.object_type;


if (objectType === "image") return "";

const htmlParts = [];
Expand Down Expand Up @@ -514,6 +515,7 @@ function _renderMultipleFields(val, res, fieldName) {
let inferredType = objectType;
let uuid = "";
const possibleRelation = relationMap[objectType];

let moreData = {};
if (possibleRelation) {
outer: for (const [type, keys] of Object.entries(possibleRelation)) {
Expand Down Expand Up @@ -545,8 +547,13 @@ function _renderMultipleFields(val, res, fieldName) {
const fields = getAddtionalFields(inferredType);
for (const [label, fieldKey] of Object.entries(fields)) {
if (res?.[fieldKey]) {
const value = res[fieldKey];
htmlParts.push(`<div>${label}: ${value}</div>`);
let lines = res[fieldKey];

if(typeof lines == "string") {
lines = lines.replace(/shelf_/g, '');
}

htmlParts.push(`<div>${label}: ${lines}</div>`);
} else {
if (["comment", "resource"].includes(res["object_type"])) {
htmlParts.push(`<p id=${uuid}></p>`);
Expand Down Expand Up @@ -728,8 +735,10 @@ function _getAllMatchingFieldsHTML(val, res, fieldName, edge) {
// Build results
for (const { label, value } of entriesWithLabels) {
const lines = value.join("");

const result = lines.replace(/shelf_/g, '');
results.push(
`<p class="highlighter">Found in <strong>${label}</strong>:<br>${lines}<p>`
`<p class="highlighter">Found in <strong>${label}</strong>:<br>${result}<p>`
);
}

Expand Down
2 changes: 1 addition & 1 deletion static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ function advanceSearch(params) {
{
param: "rec_roles",
queryStringFields: [
{ field: "person-recipient-roles", operator: "AND" },
{ field: "person-addressee-roles", operator: "AND" },
],
},
{
Expand Down
8 changes: 6 additions & 2 deletions views/profile.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
from flask import Blueprint, render_template, abort
from flask import Blueprint, render_template, abort, redirect , url_for
from .solr import check_profile

profile_bp = Blueprint('profile', __name__, url_prefix='/profile')

@profile_bp.route('/<collection>/<id>')
def profile(collection, id):

if collection == "institution":
return redirect(url_for("profile.profile", collection="repository", id=id))

solr_core = (
"people" if collection == "person"
else "institutions" if collection == "repository"
Expand All @@ -15,7 +19,7 @@ def profile(collection, id):

try:
is_valid , is_organisation = check_profile(solr_core , id)

if is_valid:
if is_organisation:
pageTitle = "Organization"
Expand Down
9 changes: 2 additions & 7 deletions views/shortURL.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"i" : lambda id : f"dcterms_identifier-edit_:edit_cofk_union_image-{id}",
"c" : lambda id : f"dcterms_identifier-edit_:edit_cofk_union_comment-{id}",
"re" : lambda id : f"dcterms_identifier-edit_:edit_cofk_union_resource-{id}",
"m": lambda id: f'dcterms_identifier-edit_:\"edit_cofk_union_manifestation-cofk_edit_interface-iwork_id:{id}\"'
"m": lambda id: f'dcterms_identifier-edit_:*{id}'
}

# Function to query Solr based on type and ID
Expand Down Expand Up @@ -61,12 +61,7 @@ def index(type, id):
# Check if the type exists in the core map
if type not in CORE_MAP:
abort(404)

# Special case for type 'm'
if type == 'm' and 2 <= len(id) <= 10:
# Append leading zeros to make id length 10
id = id.zfill(10)


core = CORE_MAP[type] # Get the core name based on type
return redirect_function(type, id, core)

Expand Down
51 changes: 50 additions & 1 deletion views/solr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import requests
import os
from dotenv import load_dotenv
from urllib.parse import urlencode
from urllib.parse import urlparse

load_dotenv()

Expand Down Expand Up @@ -354,6 +354,55 @@ def fetch_institutions():
except requests.RequestException as e:
return jsonify({'error': str(e)}), 500

@solr_bp.route("/manifestation-data/<uuid>", methods=['GET'])
def get_manifestation_data(uuid):
result = {}

# Step 1: Query solr/all for all related objects by uuid
all_data = solr_get("all", f"uuid_related:{uuid}")
docs = all_data.get("response", {}).get("docs", [])

for doc in docs:
doc_uuid = doc.get("uuid")
doc_type = doc.get("object_type")

if not doc_uuid:
continue

# Step 2: If object is a manifestation, check for frbr_Work-work field
if doc_type == "manifestation" and doc.get("frbr_Work-work"):
work_uris = doc.get("frbr_Work-work", [])

for work_uri in work_uris:
work_uuid = uuid_from_uri(work_uri)

# Fetch the work object from the work core
work_data = solr_get("works", f"uuid:{work_uuid}")
work_docs = work_data.get("response", {}).get("docs", [])

if work_docs:
result[work_uuid] = work_docs[0]

# Always add the doc itself to the result
result[doc_uuid] = doc

return jsonify(result)

def uuid_from_uri(uri):
# Extracts UUID from e.g. "http://localhost/work/d1f33b3c-22a5-4d02-a511-1a140e570590"
return urlparse(uri).path.rstrip("/").split("/")[-1]

def solr_get(core, query, rows=9999):
SOLR_URL = getSolrURL()
url = f"{SOLR_URL}{core}/select"
params = {
"q": query,
"wt": "json",
"rows": rows
}
response = requests.get(url, params=params)
response.raise_for_status()
return response.json()

# Function to handle the solr url for each API call.
# Todo: we can store solr URL in global variable instead of making call to multiple times to env file.
Expand Down