From 98dbaf0f7a4ea46aa3330d79c90f802fc0671f41 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 12 Sep 2011 21:16:53 +0200 Subject: [PATCH] ICU per metadata element (icu_chain attribute) --- src/pazpar2_config.c | 15 +++++++++++---- src/pazpar2_config.h | 1 + src/session.c | 8 ++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/pazpar2_config.c b/src/pazpar2_config.c index b9fd4b1..f42cfae 100644 --- a/src/pazpar2_config.c +++ b/src/pazpar2_config.c @@ -70,7 +70,8 @@ static void conf_metadata_assign(NMEM nmem, int termlist, int rank, int sortkey_offset, - enum conf_metadata_mergekey mt) + enum conf_metadata_mergekey mt, + const char *icu_chain) { assert(nmem && metadata && name); @@ -90,6 +91,7 @@ static void conf_metadata_assign(NMEM nmem, metadata->rank = rank; metadata->sortkey_offset = sortkey_offset; metadata->mergekey = mt; + metadata->icu_chain = nmem_strdup_null(nmem, icu_chain); } @@ -157,7 +159,8 @@ static struct conf_metadata* conf_service_add_metadata( int termlist, int rank, int sortkey_offset, - enum conf_metadata_mergekey mt) + enum conf_metadata_mergekey mt, + const char *icu_chain) { struct conf_metadata * md = 0; @@ -168,7 +171,7 @@ static struct conf_metadata* conf_service_add_metadata( md = service->metadata + field_id; conf_metadata_assign(service->nmem, md, name, type, merge, setting, brief, termlist, rank, sortkey_offset, - mt); + mt, icu_chain); return md; } @@ -281,6 +284,7 @@ static int parse_metadata(struct conf_service *service, xmlNode *n, xmlChar *xml_rank = 0; xmlChar *xml_setting = 0; xmlChar *xml_mergekey = 0; + xmlChar *xml_icu_chain = 0; struct _xmlAttr *attr; for (attr = n->properties; attr; attr = attr->next) { @@ -311,6 +315,9 @@ static int parse_metadata(struct conf_service *service, xmlNode *n, else if (!xmlStrcmp(attr->name, BAD_CAST "mergekey") && attr->children && attr->children->type == XML_TEXT_NODE) xml_mergekey = attr->children->content; + else if (!xmlStrcmp(attr->name, BAD_CAST "icu_chain") && + attr->children && attr->children->type == XML_TEXT_NODE) + xml_icu_chain = attr->children->content; else { yaz_log(YLOG_FATAL, "Unknown metadata attribute '%s'", attr->name); @@ -450,7 +457,7 @@ static int parse_metadata(struct conf_service *service, xmlNode *n, (const char *) xml_name, type, merge, setting, brief, termlist, rank, sortkey_offset, - mergekey_type); + mergekey_type, (const char *) xml_icu_chain); (*md_node)++; return 0; } diff --git a/src/pazpar2_config.h b/src/pazpar2_config.h index dd199c5..f6cf6d0 100644 --- a/src/pazpar2_config.h +++ b/src/pazpar2_config.h @@ -81,6 +81,7 @@ struct conf_metadata enum conf_metadata_merge merge; enum conf_setting_type setting; // Value is to be taken from session/db settings? enum conf_metadata_mergekey mergekey; + char *icu_chain; }; diff --git a/src/session.c b/src/session.c index ee39c7b..9b69b38 100644 --- a/src/session.c +++ b/src/session.c @@ -192,6 +192,14 @@ void add_facet(struct session *s, const char *type, const char *value, int count const char *facet_component; WRBUF facet_wrbuf = wrbuf_alloc(); WRBUF display_wrbuf = wrbuf_alloc(); + int i; + const char *icu_chain_id = 0; + + for (i = 0; i < service->num_metadata; i++) + if (!strcmp((service->metadata + i)->name, type)) + icu_chain_id = (service->metadata + i)->icu_chain; + yaz_log(YLOG_LOG, "icu_chain id=%s", icu_chain_id ? icu_chain_id : "null"); + prt = pp2_relevance_tokenize(service->facet_pct); pp2_relevance_first(prt, value, 0); -- 1.7.10.4