Skip to content

Commit

Permalink
Merge pull request #21 from alliance-genome/fix_annotation_search
Browse files Browse the repository at this point in the history
Fixed annotation search
  • Loading branch information
oblodgett authored Aug 26, 2021
2 parents a2d9937 + 5281111 commit 2ef9dc0
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 22 deletions.
20 changes: 10 additions & 10 deletions src/main/cliapp/src/components/DiseaseAnnotationsComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ export const DiseaseAnnotationsComponent = () => {
setDiseaseAnnotations(data.results);
setTotalRecords(data.totalResults);
},
onError: (error) => {
errorMessage.current.show([
{ severity: 'error', summary: 'Error', detail: error.message, sticky: true }
])
},
onError: (error) => {
errorMessage.current.show([
{ severity: 'error', summary: 'Error', detail: error.message, sticky: true }
])
},
keepPreviousData: true

})
Expand Down Expand Up @@ -72,7 +72,7 @@ export const DiseaseAnnotationsComponent = () => {

const publicationTemplate = (rowData) => {
if (rowData) {
return <div>{rowData.referenceList[0].curie}</div>
return <div>{rowData.referenceList.map(a => a.curie)}</div>
}
};

Expand All @@ -82,8 +82,8 @@ export const DiseaseAnnotationsComponent = () => {
return (
<div>
<div className="card">
<h3>Disease Annotations Table</h3>
<Messages ref={errorMessage}/>
<h3>Disease Annotations Table</h3>
<Messages ref={errorMessage}/>
<DataTable value={diseaseAnnotations} className="p-datatable-md"
sortMode="multiple" removableSort onSort={onSort} multiSortMeta={multiSortMeta}
first={first} onFilter={onFilter} filters={filters}
Expand All @@ -92,10 +92,10 @@ export const DiseaseAnnotationsComponent = () => {
paginatorTemplate="CurrentPageReport FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown"
currentPageReportTemplate="Showing {first} to {last} of {totalRecords}" rows={rows} rowsPerPageOptions={[10, 20, 50, 100, 250, 1000]}
paginatorLeft={paginatorLeft} paginatorRight={paginatorRight}>
<Column field="id" header="Id" sortable filter ></Column>
<Column field="id" header="Id" sortable ></Column>
<Column field="subject.curie" header="Subject" sortable filter ></Column>
<Column field="object.curie" header="Disease" sortable filter ></Column>
<Column field="referenceList" header="Reference" body={publicationTemplate} sortable filter ></Column>
<Column field="referenceList.curie" header="Reference" body={publicationTemplate} sortable filter ></Column>
</DataTable>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/main/cliapp/src/components/FMSComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export const FMSComponent = () => {
fmsService.getReleases().then(results => {
console.log(results);
setReleases(results.reverse());
//selectedRelease = results[0].releaseVersion;
//selectedRelease = results[0].releaseVersio;
//setSelectedRelease(results[0].releaseVersion);
//setDataFiles(results.dataFiles);
});

Expand Down
18 changes: 10 additions & 8 deletions src/main/cliapp/src/service/DiseaseService.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,27 @@ import axios from 'axios';

export class DiseaseService {
getDiseases(limit, page, sorts, filters) {

var sortOptions = {};

var sortArray = {};
sorts.forEach((o) => {
if(sorts) {
sorts.forEach((o) => {
sortArray[o.field] = o.order;
});
});
}

var filterArray = {};

Object.keys(filters).forEach((key) => {
if(filters) {
Object.keys(filters).forEach((key) => {
filterArray[key] = filters[key]["value"];
});
});
}

if(Object.keys(filterArray).length > 0) {
sortOptions["searchFilters"] = filterArray;
sortOptions["searchFilters"] = filterArray;
}
if(Object.keys(sortArray).length > 0) {
sortOptions["sortOrders"] = sortArray;
sortOptions["sortOrders"] = sortArray;
}

return axios.post('/api/doterm/search?limit=' + limit + '&page=' + page, sortOptions).then(res => res.data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import org.alliancegenome.curation_api.view.View;
import org.hibernate.annotations.*;
import org.hibernate.search.engine.backend.types.*;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.*;

import com.fasterxml.jackson.annotation.JsonView;
Expand All @@ -15,8 +16,8 @@
@Data @EqualsAndHashCode(callSuper = false)
@MappedSuperclass
public class BaseGeneratedEntity extends BaseEntity {
@Id

@Id @DocumentId
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@JsonView({View.FieldsOnly.class})
private Long id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ public SearchResults<E> searchByParams(Pagination pagination, Map<String, Object
})
.toQuery();

SearchResult<E> result = query.fetch(pagination.getPage() * pagination.getLimit(), pagination.getLimit());
log.debug(query);
SearchResult<E> result = query.fetch(pagination.getPage() * pagination.getLimit(), pagination.getLimit());


SearchResults<E> results = new SearchResults<E>();
results.setResults(result.hits());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import org.alliancegenome.curation_api.view.View;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import org.hibernate.envers.Audited;
import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.*;
import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.*;

import com.fasterxml.jackson.annotation.JsonView;

Expand All @@ -22,13 +26,20 @@
@Schema(name = "association", description = "Annotation class representing a disease annotation")
public class Association extends BaseGeneratedEntity {

@IndexedEmbedded(includeDepth = 1)
@IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW)
@ManyToOne
@JsonView({View.FieldsOnly.class})
private BiologicalEntity subject;

@IndexedEmbedded(includeDepth = 1)
@IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW)
@ManyToOne
@JsonView({View.FieldsOnly.class})
private DOTerm object;

@IndexedEmbedded(includeDepth = 1)
@IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW)
@ManyToMany
@JsonView({View.FieldsOnly.class})
private List<Reference> referenceList;
Expand Down

0 comments on commit 2ef9dc0

Please sign in to comment.