-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
17017ee
commit febfef3
Showing
5 changed files
with
145 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
backend/src/main/java/uk/ac/ebi/spot/ols/controller/api/v2/V2DefinedFieldsController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package uk.ac.ebi.spot.ols.controller.api.v2; | ||
|
||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import uk.ac.ebi.ols.shared.DefinedFields; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
@RestController | ||
public class V2DefinedFieldsController { | ||
|
||
@GetMapping("/api/v2/defined-fields") | ||
public List<DefinedFieldDto> getDefinedFields() { | ||
return Stream.of(DefinedFields.values()) | ||
.map(field -> new DefinedFieldDto( | ||
field.getText(), | ||
field.getOls3Text(), | ||
field.getDescription(), | ||
field.getType() | ||
)) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
// DTO class for serialization | ||
static class DefinedFieldDto { | ||
private String ols4FieldName; | ||
private String ols3FieldName; | ||
private String description; | ||
private String dataType; | ||
|
||
public DefinedFieldDto(String ols4FieldName, String ols3FieldName, String description, String dataType) { | ||
this.ols4FieldName = ols4FieldName; | ||
this.ols3FieldName = ols3FieldName; | ||
this.description = description; | ||
this.dataType = dataType; | ||
} | ||
|
||
public String getOls4FieldName() { | ||
return ols4FieldName; | ||
} | ||
|
||
public String getOls3FieldName() { | ||
return ols3FieldName; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public String getDataType() { | ||
return dataType; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { Fragment, useEffect, useState } from "react"; | ||
import Header from "../components/Header"; | ||
|
||
interface DefinedField { | ||
ols4FieldName: string; | ||
ols3FieldName: string; | ||
description: string; | ||
dataType: string; | ||
} | ||
|
||
export default function StaticDocs() { | ||
document.title = "OLS Documentation"; | ||
|
||
const [fields, setFields] = useState<DefinedField[]>([]); | ||
|
||
useEffect(() => { | ||
fetch('/api/v2/defined-fields') | ||
.then((response) => response.json()) | ||
.then((data) => setFields(data)) | ||
.catch((error) => console.error('Error fetching defined fields:', error)); | ||
}, []); | ||
|
||
return ( | ||
<Fragment> | ||
<Header section="static-docs" /> | ||
<main className="container mx-auto px-4 my-8"> | ||
<div className="text-2xl font-bold my-6">Defined Response Fields in OLS</div> | ||
<table className="table-auto w-full border-collapse border border-gray-300"> | ||
<thead> | ||
<tr className="bg-gray-100"> | ||
<th className="border border-gray-300 px-4 py-2">OLS4 Field Name</th> | ||
<th className="border border-gray-300 px-4 py-2">OLS3 Field Name</th> | ||
<th className="border border-gray-300 px-4 py-2">Description</th> | ||
<th className="border border-gray-300 px-4 py-2">Data Type</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{fields.map((field, index) => ( | ||
<tr key={index}> | ||
<td className="border border-gray-300 px-4 py-2">{field.ols4FieldName}</td> | ||
<td className="border border-gray-300 px-4 py-2">{field.ols3FieldName}</td> | ||
<td className="border border-gray-300 px-4 py-2">{field.description}</td> | ||
<td className="border border-gray-300 px-4 py-2">{field.dataType}</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
</main> | ||
</Fragment> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters