Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Dev into Main #23

Merged
merged 5 commits into from
Jun 19, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -76,26 +76,13 @@ const NeighborhoodExplorerComponent: React.FC<GraphExplorerProps> = ({graphServi


const init = async () => {
// let graph = await graphService.getInitial(messageService!);
// const newElements = [...graph.nodes.map((x:any)=>{ return {data: x}}), ...graph.links?.map((x:any)=>{ return {data: x}})];
// setElements([...newElements]);

setQueryHistory(await graphVisualizationHistoryService.getAllAsOptions(messageService!));

// const nodes = neighborhoodExplorerStore.getIds();
// if (nodes.length > 0){
// const graph = {nodes: nodes.map(x => {return {data: x}}), edges: []};
// myComponentRef.current!.setElements(JSON.stringify(graph));
// } else {
// const viz = await graphVisualizationHistoryService.get("0", messageService!);
// myComponentRef.current!.setElements(viz.visualization);
// }

// console.log(neighborhoodExplorerStore.elements);
// if (neighborhoodExplorerStore.elements?.nodes){
// console.log("here");
// console.log(neighborhoodExplorerStore.elements.nodes);
// myComponentRef.current!.setElements(JSON.stringify(neighborhoodExplorerStore.elements))
// }
if (!neighborhoodExplorerStore.nodes || neighborhoodExplorerStore.nodes.length <= 0){
const viz = await graphVisualizationHistoryService.get("0", messageService!);
myComponentRef.current!.setElements(viz.visualization);
}

const entityTypes = await entityTypeService.getAll(messageService!);
setTypes(entityTypes.map(x => {return {name: x.name, id: x.id, color: x.color}}));
Expand Down Expand Up @@ -199,6 +186,25 @@ const NeighborhoodExplorerComponent: React.FC<GraphExplorerProps> = ({graphServi
];
};

const nodeSynonymsTemplate = (items: any[]) : ReactNode[] | undefined => {
if (!items || items.length === 0) return undefined;

let list = items.sort().map((query, index) => {
return (<div style={{padding: 5, backgroundColor: "#F8F9FA", marginBottom: 5, borderRadius: 10, border: '1px solid #DEE2E6', overflowX: 'scroll'} }>

<span style={{marginLeft: 5}}>{query}</span>

</div>)
});

return [
<>
<b style={{paddingLeft: "3px"}}>Synonyms:</b>
{list}
</>
];
};

const nodeReferencesTemplate = (items: any[]) : ReactNode[] | undefined => {
if (!items || items.length === 0) return undefined;

Expand Down Expand Up @@ -591,6 +597,7 @@ const NeighborhoodExplorerComponent: React.FC<GraphExplorerProps> = ({graphServi
<MolecularDrawComponent element={element}></MolecularDrawComponent>
<canvas id="mol_structure" width="500" height="500" style={{display: 'none'}}></canvas>
<DataView value={element.properties} listTemplate={nodePropertiesTemplate} />
<DataView value={element.synonyms} listTemplate={nodeSynonymsTemplate}/>
<DataView value={element.references} listTemplate={nodeReferencesTemplate} />
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,25 +259,17 @@ class CytoscapeInteractiveChartComponent extends Component<CytoscapeInteractiveC

configureCytoscape (cytoscapeCore: any) {
const contextMenu = this.props.contextMenu;
const store = this.props.store;

const x = () => {
this.rendered = true;
}



if (cytoscapeCore){


cytoscapeCore.ready(function() {
cytoscapeCore.ready(() => {
console.log('Cytoscape canvas has been rendered');
// Your code to run after the graph has been rendered
// if (store.elements?.nodes){
// cytoscapeCore.add(store.elements);
// };

x();
cytoscapeCore.fit();
});

cytoscapeCore.on('layoutstop',() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class EntityDTO {
private List<String> labels;
private List<PropertyValueDTO> properties;
private List<ReferenceDTO> references;
private List<String> synonyms;
private String color;

public EntityDTO() {
Expand Down Expand Up @@ -79,4 +80,12 @@ public List<ReferenceDTO> getReferences() {
public void setReferences(List<ReferenceDTO> references) {
this.references = references;
}

public List<String> getSynonyms() {
return synonyms;
}

public void setSynonyms(List<String> synonyms) {
this.synonyms = synonyms;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package ipbhalle.de.ontologymanagerserver.data.dtos;

public class SynonymDTO
{
private String name;

public SynonymDTO() {}
public SynonymDTO(String name) {
this.name = name;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ public EntityDTO GetNode(String nodeId) {

var entity = neo4jTemplate.findOne(getNodeQuery, new HashMap<>(), N4JEntity.class);

if (entity.isEmpty())
return null;

Node sourceNode = Cypher.node("Source").named("s");
Relationship fromSourceRelationship = entityNode.relationshipTo(sourceNode, "FROM_SOURCE").named("r");

Expand All @@ -218,8 +221,17 @@ public EntityDTO GetNode(String nodeId) {

var references = neo4jTemplate.findAll(getReferencesQuery, ReferenceDTO.class);

if (entity.isEmpty())
return null;

Node synonymNode = Cypher.node("Synonym").named("s");
Relationship hasSynonymRelationship = entityNode.relationshipTo(synonymNode, "HAS_SYNONYM").named("r");
Statement getSynonymsQuery = Cypher
.match(hasSynonymRelationship)
.where(entityNode.property("OHUUID").isEqualTo(nodeIdParam))
.returning(
synonymNode.property("name").as("name")
).build();

var synonyms = neo4jTemplate.findAll(getSynonymsQuery, SynonymDTO.class);

var entityValue = entity.get();

Expand Down Expand Up @@ -257,6 +269,7 @@ public EntityDTO GetNode(String nodeId) {

entityDto.setProperties(propertyValues);
entityDto.setReferences(references);
entityDto.setSynonyms(synonyms.stream().map(SynonymDTO::getName).toList());

return entityDto;

Expand Down
Loading