Skip to content
Open
Show file tree
Hide file tree
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
32 changes: 24 additions & 8 deletions dataload/linker/src/main/java/LinkerPass2.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,14 @@ private static void writeEntityArray(JsonReader jsonReader, JsonWriter jsonWrite
jsonWriter.beginObject();
jsonReader.beginObject();

Set<String> stringsInEntity = new HashSet<String>();
Set<String> relatedFromStringsInEntity = new HashSet<String>();
Set<String> allOtherStringsInEntity = new HashSet<String>();
String entityIri = null;

while(jsonReader.peek() != JsonToken.END_OBJECT) {

String name = jsonReader.nextName();
stringsInEntity.add(ExtractIriFromPropertyName.extract(name));
allOtherStringsInEntity.add(ExtractIriFromPropertyName.extract(name));
jsonWriter.name(name);

if(name.equals("iri")) {
Expand All @@ -165,8 +166,10 @@ private static void writeEntityArray(JsonReader jsonReader, JsonWriter jsonWrite
processCurieObject(jsonReader, jsonWriter, pass1Result, entityIri);
} else if (name.equalsIgnoreCase("shortForm")) {
processShortFormObject(jsonReader, jsonWriter, pass1Result, entityIri);
} else if (name.equalsIgnoreCase("relatedFrom")) {
CopyJsonGatheringStrings.copyJsonGatheringStrings(jsonReader, jsonWriter, relatedFromStringsInEntity);
} else {
CopyJsonGatheringStrings.copyJsonGatheringStrings(jsonReader, jsonWriter, stringsInEntity);
CopyJsonGatheringStrings.copyJsonGatheringStrings(jsonReader, jsonWriter, allOtherStringsInEntity);
}
}

Expand Down Expand Up @@ -197,7 +200,24 @@ private static void writeEntityArray(JsonReader jsonReader, JsonWriter jsonWrite
}

jsonWriter.name("linkedEntities");
var linksToIris = writeLinkedEntitiesFromGatheredStrings(jsonWriter, stringsInEntity, ontologyId, entityIri, leveldb, pass1Result);
jsonWriter.beginObject();

/*
* "relatedFrom" is a special field because it contains INCOMING properties
* rather than outgoing. We therefore don't want to include any of the IRIs
* referenced in "relatedFrom" in the "linksTo" array because they are not
* actually linked to (rather the opposite). But we still need them in "linkedEntities"
* so we can display them in the UI.
*/

var linksToIris = writeLinkedEntitiesFromGatheredStrings(jsonWriter, allOtherStringsInEntity, ontologyId, entityIri, leveldb, pass1Result);

relatedFromStringsInEntity.removeAll(allOtherStringsInEntity);
if(relatedFromStringsInEntity.size() > 0) {
writeLinkedEntitiesFromGatheredStrings(jsonWriter, relatedFromStringsInEntity, ontologyId, entityIri, leveldb, pass1Result);
}

jsonWriter.endObject(); // linkedEntities

jsonWriter.name("linksTo");
jsonWriter.beginArray();
Expand Down Expand Up @@ -248,8 +268,6 @@ private static Set<String> writeLinkedEntitiesFromGatheredStrings(JsonWriter jso

Set<String> linksToIris = new HashSet<>();

jsonWriter.beginObject();

for(String str : strings) {

if(str.trim().length() == 0) {
Expand Down Expand Up @@ -371,8 +389,6 @@ private static Set<String> writeLinkedEntitiesFromGatheredStrings(JsonWriter jso

}

jsonWriter.endObject(); // linkedEntities

return linksToIris;
}

Expand Down
6 changes: 3 additions & 3 deletions frontend/.env
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

PUBLIC_URL=/

REACT_APP_APIURL=http://localhost:8080/
#OLS_DEV_BACKEND_PROXY_URL=http://www.ebi.ac.uk/ols4/
OLS_DEV_BACKEND_PROXY_URL=http://localhost:8080/
REACT_APP_APIURL=http://localhost:3000/
OLS_DEV_BACKEND_PROXY_URL=http://www.ebi.ac.uk/ols4/
#OLS_DEV_BACKEND_PROXY_URL=http://localhost:8080/

REACT_APP_EBI_LICENSING=https://www.ebi.ac.uk/licencing
REACT_APP_SPOT_HOME=https://www.ebi.ac.uk/spot
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/model/Entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { LinkedEntity } from "./LinkedEntities";
import Reified from "./Reified";
import Thing from "./Thing";

export default abstract class Entity extends Thing {
abstract getParents(): Reified<any>[];
abstract getSuperEntities(): Reified<any>[];
abstract getEquivalents(): Reified<any>[];
export default class Entity extends Thing {
getParents(): Reified<any>[] { return [] }
getSuperEntities(): Reified<any>[] { return [] }
getEquivalents(): Reified<any>[] { return [] }

isCanonical(): boolean {
return this.properties["isDefiningOntology"] === true;
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/pages/ontologies/entities/EntityPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import addLinksToText from "./entityPageSections/addLinksToText";
import { Helmet } from 'react-helmet'
import { Typography } from "@mui/material";
import SimilarEntitiesSection from "./entityPageSections/SimilarEntitiesSection";
import LinkedFromSection from "./entityPageSections/LinkedFromSection";

export default function EntityPage({
entityType,
Expand Down Expand Up @@ -499,6 +500,10 @@ export default function EntityPage({
classInstances={classInstances}
linkedEntities={linkedEntities}
/>
<LinkedFromSection
entity={entity}
linkedEntities={linkedEntities}
/>
</div>
</details>
<details open className="p-2">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@

import { Fragment, useEffect, useState } from "react";
import { randomString } from "../../../../app/util";
import EntityLink from "../../../../components/EntityLink";
import Class from "../../../../model/Class";
import Entity from "../../../../model/Entity";
import LinkedEntities from "../../../../model/LinkedEntities";
import Property from "../../../../model/Property";
import { Link, useSearchParams } from "react-router-dom";
import { getPaginated, Page } from "../../../../app/api";

export default function LinkedFromSection({entity, linkedEntities}:{entity:Entity, linkedEntities:LinkedEntities}) {

let [linkedfrom, setLinkedFrom] = useState<Page<any>|null>(null);

const [searchParams] = useSearchParams();
let lang = searchParams.get("lang") || "en";

useEffect(() => {
setLinkedFrom(null)
const fetchLinkedFromEntities = async () => {
let page = await getPaginated<any>(`api/v2/entities`, { linksTo: entity.getIri(), size: '5' })
setLinkedFrom(page)
};
fetchLinkedFromEntities();

}, [entity?.getOntologyId(), entity?.getIri()])

if(!entity) {
return <Fragment/>
}

return <div>
<div className="font-bold">Linked from</div>
{ !linkedfrom && <i>Loading...</i> }
{ linkedfrom && linkedfrom.numElements === 0 && <Fragment/> }
{ linkedfrom && linkedfrom.numElements > 0 && <Fragment> <ul className="list-disc list-inside">
{linkedfrom.elements.map(
(elem) => {
return new Entity(elem)
}
).map((otherEntity:Entity) => {
return (
<li key={entity.getId()}>
<Link
className="link-default"
to={`/ontologies/${otherEntity.getOntologyId()}/${
otherEntity.getTypePlural()
}/${encodeURIComponent(encodeURIComponent(otherEntity.getIri()))}?lang=${lang}`}
>
{otherEntity.getName()}
<span
className="link-ontology px-2 py-0.5 rounded-md text-sm text-white uppercase ml-1"
title={otherEntity.getOntologyId().toUpperCase()}
>
{otherEntity.getOntologyId()}
</span>
</Link>
</li>
)
})}
</ul>

{linkedfrom.totalElements > 5 && (
<Link
className="link-default italic"
to={`/search?linksTo=${encodeURIComponent(entity.getIri())}&lang=${lang}`}
>
+ {linkedfrom.totalElements - 5}
</Link>
)}
</Fragment>
}
</div>

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function SimilarEntitiesSection({entity}:{entity:Entity}) {
fetchSimilarEntities();
}

}, [entity?.getIri()])
}, [entity?.getOntologyId(), entity?.getIri()])

if(!entity || (entity.getType() !== 'class' && entity.getType() !== 'property')) {
return <Fragment/>
Expand Down
Loading