Skip to content

Commit

Permalink
added two new filter fields: dataDomain and copyright
Browse files Browse the repository at this point in the history
  • Loading branch information
theorm committed Jan 16, 2025
1 parent fef6848 commit 8f2de60
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 9 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"graphology-pagerank": "^1.1.0",
"helmet": "^3.21.1",
"http-proxy-middleware": "^2.0.1",
"impresso-jscommons": "https://github.com/impresso/impresso-jscommons/tarball/v1.4.3",
"impresso-jscommons": "https://github.com/impresso/impresso-jscommons/tarball/v1.5.0",
"json-bigint": "^1.0.0",
"json2csv": "^4.3.3",
"jsonpath-plus": "^10.0.1",
Expand Down
26 changes: 26 additions & 0 deletions src/data/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ export const SolrMappings: Record<string, ISolrMappings> = Object.freeze({
offset: 0,
numBuckets: true,
},
/**
* @deprecated removed in Impresso 2.0. New field: rights_data_domain_s
* https://github.com/impresso/impresso-middle-layer/issues/462
*/
accessRight: {
type: 'terms',
field: 'access_right_s',
Expand All @@ -174,6 +178,28 @@ export const SolrMappings: Record<string, ISolrMappings> = Object.freeze({
offset: 0,
numBuckets: true,
},
/**
* Available in Impresso 2.0 only.
*/
dataDomain: {
type: 'terms',
field: 'rights_data_domain_s',
mincount: 0,
limit: 10,
offset: 0,
numBuckets: true,
},
/**
* Available in Impresso 2.0 only.
*/
copyright: {
type: 'terms',
field: 'rights_copyright_s',
mincount: 0,
limit: 10,
offset: 0,
numBuckets: true,
},
},
orderBy: {
date: 'meta_date_dt',
Expand Down
19 changes: 18 additions & 1 deletion src/models/articles.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,23 @@ export const ARTICLE_SOLR_FL_LIST_ITEM = [
'rc_plains',
// snippet
'snippet_plain',
'access_right_s',
'meta_partnerid_s',
// layout & quality
'olr_b',
// access & download
/**
* @deprecated removed in Impresso 2.0. New field: rights_data_domain_s
* https://github.com/impresso/impresso-middle-layer/issues/462
*/
'access_right_s',
'exportable_plain',
// permissions bitmaps
// see https://github.com/search?q=org%3Aimpresso%20rights_bm_explore_l&type=code
'rights_bm_explore_l',
'rights_bm_get_tr_l',
'rights_bm_get_img_l',
'rights_data_domain_s',
'rights_copyright_s',
]

export const ARTICLE_SOLR_FL_LITE = [
Expand Down Expand Up @@ -316,6 +321,8 @@ class Article extends BaseArticle {
bitmapExplore = undefined,
bitmapGetTranscript = undefined,
bitmapGetImages = undefined,
dataDomain = undefined,
copyright = undefined,
} = {}) {
super({
uid,
Expand Down Expand Up @@ -400,6 +407,9 @@ class Article extends BaseArticle {
this.bitmapExplore = bitmapExplore
this.bitmapGetTranscript = bitmapGetTranscript
this.bitmapGetImages = bitmapGetImages

this.dataDomain = dataDomain
this.copyright = copyright
}

enrich(rc, lb, rb) {
Expand Down Expand Up @@ -718,6 +728,10 @@ class Article extends BaseArticle {

rc,
// accessRight
/**
* @deprecated removed in Impresso 2.0. New field: rights_data_domain_s
* https://github.com/impresso/impresso-middle-layer/issues/462
*/
accessRight: doc.access_right_s || ACCESS_RIGHT_NOT_SPECIFIED,
mentions: typeof doc.nem_offset_plain === 'string' ? JSON.parse(doc.nem_offset_plain) : doc.nem_offset_plain,
topics: ArticleTopic.solrDPFsFactory(doc.topics_dpfs),
Expand All @@ -730,6 +744,9 @@ class Article extends BaseArticle {
bitmapExplore: BigInt(doc.rights_bm_explore_l ?? OpenPermissions),
bitmapGetTranscript: BigInt(doc.rights_bm_get_tr_l ?? OpenPermissions),
bitmapGetImages: BigInt(doc.rights_bm_get_img_l ?? OpenPermissions),

dataDomain: doc.rights_data_domain_s,
copyright: doc.rights_copyright_s,
})

if (!doc.pp_plain) {
Expand Down
13 changes: 12 additions & 1 deletion src/models/generated/schemas.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,18 @@ export interface ContentItem {
* TODO
*/
labels: "article"[];
accessRight: "na" | "OpenPrivate" | "Closed" | "OpenPublic";
/**
* The access rights of the content item. Available in Impresso 1.0 only
*/
accessRight?: "na" | "OpenPrivate" | "Closed" | "OpenPublic";
/**
* The data domain of the content item ('pbl' for Public Domain, 'prt' for Protected Domain). Available in Impresso 2.0 only
*/
dataDomain?: "pbl" | "prt";
/**
* Copyright of the content item. Available in Impresso 2.0 only. pbl: 'Public Domain', und: 'Protected Domain: Copyright undetermined', nkn: 'Protected Domain: No Known Copyright', euo: 'Protected Domain: In copyright - EU Orphan Work', unk: 'Protected Domain: In copyright - Unknown rightsholders', in_cpy: 'Protected Domain: In copyright'.
*/
copyright?: "pbl" | "und" | "nkn" | "euo" | "unk" | "in_cpy";
/**
* TODO
*/
Expand Down
15 changes: 13 additions & 2 deletions src/schema/schemas/ContentItem.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,18 @@
},
"accessRight": {
"type": "string",
"enum": ["na", "OpenPrivate", "Closed", "OpenPublic"]
"enum": ["na", "OpenPrivate", "Closed", "OpenPublic"],
"description": "The access rights of the content item. Available in Impresso 1.0 only"
},
"dataDomain": {
"type": "string",
"enum": ["pbl", "prt"],
"description": "The data domain of the content item ('pbl' for Public Domain, 'prt' for Protected Domain). Available in Impresso 2.0 only"
},
"copyright": {
"type": "string",
"enum": ["pbl", "und", "nkn", "euo", "unk", "in_cpy"],
"description": "Copyright of the content item. Available in Impresso 2.0 only. pbl: 'Public Domain', und: 'Protected Domain: Copyright undetermined', nkn: 'Protected Domain: No Known Copyright', euo: 'Protected Domain: In copyright - EU Orphan Work', unk: 'Protected Domain: In copyright - Unknown rightsholders', in_cpy: 'Protected Domain: In copyright'."
},
"isFront": {
"type": "boolean",
Expand Down Expand Up @@ -173,5 +184,5 @@
"description": "Access rights bitmap for getting images"
}
},
"required": ["uid", "type", "title", "size", "nbPages", "pages", "isCC", "excerpt", "labels", "accessRight", "year"]
"required": ["uid", "type", "title", "size", "nbPages", "pages", "isCC", "excerpt", "labels", "year"]
}
2 changes: 2 additions & 0 deletions src/transformers/searchFacet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ const transformBucket = (
case 'type':
case 'language':
case 'accessRight':
case 'dataDomain':
case 'copyright':
return {
count: input.count,
value: String(input.val),
Expand Down
10 changes: 10 additions & 0 deletions src/util/solr/solrFilters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,19 @@ indexes:
uid:
field: id
rule: value
# @deprecated removed in Impresso 2.0. New field: rights_data_domain_s
# https://github.com/impresso/impresso-middle-layer/issues/462
accessRight:
field: access_right_s
rule: value
# Impresso 2.0 only
dataDomain:
field: rights_data_domain_s
rule: value
# Impresso 2.0 only
copyright:
field: rights_copyright_s
rule: value
partner:
field: meta_partnerid_s
rule: value
Expand Down

0 comments on commit 8f2de60

Please sign in to comment.