Skip to content

Commit d4b294b

Browse files
Merge pull request #477 from diggsweden/DIGG-384
Digg 384
2 parents 28d76b4 + 9e2674b commit d4b294b

File tree

2 files changed

+30
-14
lines changed

2 files changed

+30
-14
lines changed

pages/terminology/[terminology]/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default function Concept() {
1515
if (env.ENTRYSCAPE_TERMS_PATH.includes("sandbox"))
1616
entryUri = `https://www-sandbox.dataportal.se/concepts/${curi}`;
1717
else entryUri = `https://dataportal.se/concepts/${curi}`;
18-
18+
const hasResourceUri = `https://www.dataportal.se/terminology/${curi}`;
1919
const postscribeStatus = useScript(
2020
"/postscribe.min.js",
2121
"sha384-1nPAWyZS0cvGLWSoWOrkTZAy8Xq8g6llEe985qo5NRPAeDi+F9h9U+0R8v56XWCM",
@@ -28,6 +28,7 @@ export default function Concept() {
2828
entryUri={entryUri}
2929
entrystoreUrl={env.ENTRYSCAPE_TERMS_PATH}
3030
fetchMore={false}
31+
hasResourceUri={hasResourceUri}
3132
>
3233
<ConceptPage curi={curi as string} />
3334
</EntrystoreProvider>

providers/EntrystoreProvider/index.tsx

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export interface EntrystoreProviderProps {
2222
entrystoreUrl: string | "admin.dataportal.se";
2323
fetchMore: boolean;
2424
isConcept?: boolean;
25+
hasResourceUri?: string;
2526
}
2627

2728
export interface ESEntry {
@@ -74,6 +75,7 @@ export const EntrystoreProvider: React.FC<EntrystoreProviderProps> = ({
7475
entrystoreUrl,
7576
fetchMore,
7677
isConcept,
78+
hasResourceUri,
7779
}) => {
7880
const [state, setState] = useState(defaultESEntry);
7981
const { lang: nextLang } = useTranslation("common");
@@ -138,8 +140,11 @@ export const EntrystoreProvider: React.FC<EntrystoreProviderProps> = ({
138140

139141
const hasResource = await es
140142
.newSolrQuery()
143+
.uriProperty(
144+
"http://www.w3.org/ns/dx/prof/hasResource",
145+
hasResourceUri || entryUri,
146+
)
141147
.rdfType(["dcterms:Standard", "prof:Profile"])
142-
.uriProperty("prof:hasResource", resourceURI)
143148
.getEntries();
144149

145150
const datasetArr = await Promise.all(
@@ -278,29 +283,39 @@ export const EntrystoreProvider: React.FC<EntrystoreProviderProps> = ({
278283
const resourceURI = entry.getResourceURI();
279284
const valuePromises: Promise<string>[] = [];
280285

281-
const maybeSpecs = graph
282-
.find(null, "dcterms:conformsTo")
286+
const conformsToURIs = graph
287+
.find(resourceURI, "dcterms:conformsTo")
283288
.map((stmt: any) => stmt.getValue());
289+
const util = new ESJS.EntryStoreUtil(
290+
new ESJS.EntryStore(`https://editera.dataportal.se/store`),
291+
);
284292

285-
const findSpec =
286-
maybeSpecs.length > 0
287-
? await es
288-
.newSolrQuery()
289-
.resource(maybeSpecs, null)
290-
.rdfType(["dcterms:Standard", "prof:Profile"])
291-
.getEntries()
292-
: [];
293+
const conformsToEntries = await util.loadEntriesByResourceURIs(
294+
conformsToURIs,
295+
undefined,
296+
true,
297+
);
298+
const specfications = conformsToEntries.filter((s: any) => s);
299+
const extractHREF = (s: any) => {
300+
if (s.getResourceURI().startsWith("https://dataportal.se"))
301+
return s.getResourceURI();
302+
return `https://dataportal.se/externalspecification/${s.getResourceURI()}`;
303+
};
304+
305+
const specificationHREF = specfications.map((s: any) =>
306+
extractHREF(s),
307+
);
293308

294309
const specArr = await Promise.all(
295-
findSpec.map(async (spec: any) => {
310+
conformsToEntries.map(async (spec: any) => {
296311
return {
297312
title: await getLocalizedValue(
298313
spec.getAllMetadata(),
299314
"dcterms:title",
300315
nextLang,
301316
es,
302317
),
303-
url: spec.getResourceURI(),
318+
url: specificationHREF[0],
304319
};
305320
}),
306321
);

0 commit comments

Comments
 (0)