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

Added core submission logic #370

Open
wants to merge 28 commits into
base: rc
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e6f9a94
Added core submission logic
jfkonecn Apr 30, 2024
2947a5d
fixed merge conflicts
jfkonecn Jul 9, 2024
ac401d4
Added Save Gene Logic (#385)
jfkonecn Jul 29, 2024
8078a23
Added name changes to review logic (#393)
jfkonecn Jul 31, 2024
3fe71f4
Added gene type submission (#396)
jfkonecn Jul 31, 2024
5177252
Can now delete evidences (#398)
jfkonecn Jul 31, 2024
d870e5c
Fixed merge conflicts
jfkonecn Aug 1, 2024
e07f835
fixed logging in
jfkonecn Aug 1, 2024
d382462
Merge branch 'rc' of https://github.com/oncokb/oncokb-transcript into…
jfkonecn Aug 2, 2024
c178b93
Merge branch 'rc' of https://github.com/oncokb/oncokb-transcript into…
jfkonecn Aug 2, 2024
b81edd3
Merge branch 'rc' of https://github.com/oncokb/oncokb-transcript into…
jfkonecn Aug 12, 2024
1345cff
fixed build errors
jfkonecn Aug 12, 2024
870ecbb
Merge branch 'rc' of https://github.com/oncokb/oncokb-transcript into…
jfkonecn Aug 15, 2024
6f2ac1b
updated drugs mapping
jfkonecn Aug 16, 2024
763d540
updated drugs mapping
jfkonecn Aug 16, 2024
8de84b0
Merge branch 'rc' into feature/submit-to-core
zhx828 Aug 16, 2024
0d1b534
Merge branch 'rc' into feature/submit-to-core
zhx828 Aug 20, 2024
1e23d96
Merge branch 'rc' into feature/submit-to-core
zhx828 Aug 21, 2024
e989bbd
Add releaseGene param when saving gene data to core
zhx828 Aug 19, 2024
78cb4eb
Update to allow save all genes
zhx828 Aug 19, 2024
72feac9
Fix excludedRCTs
zhx828 Aug 21, 2024
ea1900e
Add method to undo gene release
zhx828 Aug 21, 2024
cc4dcdf
Merge pull request #425 from zhx828/submit-to-core-zhx
zhx828 Aug 28, 2024
4204647
Use reviewed content only (#430)
jfkonecn Sep 6, 2024
dafac59
Feature/fix submit to core (#439)
jfkonecn Oct 3, 2024
82dfe1a
Added Vus submissions to core (#456)
jfkonecn Oct 8, 2024
d314a92
Make core API call non-blocking (#454)
jfkonecn Oct 14, 2024
d0e80af
Fixed merge conflicts
jfkonecn Oct 14, 2024
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@
(user_id, authority_name)
VALUES
(@UserId, 'ROLE_ADMIN'),
(@UserId, 'ROLE_DEV'),
(@UserId, 'ROLE_CURATOR'),
(@UserId, 'ROLE_USER');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,14 @@ public String getSentryDsn() {
public void setSentryDsn(String sentryDsn) {
this.sentryDsn = sentryDsn;
}

private Boolean stopReviewIfCoreSubmissionFails;

public Boolean getStopReviewIfCoreSubmissionFails() {
return stopReviewIfCoreSubmissionFails;
}

public void setStopReviewIfCoreSubmissionFails(Boolean stopReviewIfCoreSubmissionFails) {
this.stopReviewIfCoreSubmissionFails = stopReviewIfCoreSubmissionFails;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public final class AuthoritiesConstants {

public static final String ADMIN = "ROLE_ADMIN";

public static final String DEV = "ROLE_DEV";

public static final String USER = "ROLE_USER";

public static final String CURATOR = "ROLE_CURATOR";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
!path.startsWith("/v3/api-docs") &&
!path.startsWith("/login") &&
!path.startsWith("/oauth2") &&
!path.startsWith("/legacy-api") &&
!path.startsWith("/websocket") &&
!path.contains(".") &&
path.matches("/(.*)")
Expand Down
40 changes: 33 additions & 7 deletions src/main/java/org/mskcc/oncokb/curation/web/rest/ApiProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
import java.nio.charset.StandardCharsets;
import org.mskcc.oncokb.curation.service.ApiProxyService;
import org.mskcc.oncokb.curation.web.rest.errors.BadRequestAlertException;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.http.*;
import org.springframework.http.converter.FormHttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;
Expand All @@ -29,8 +29,34 @@ public ApiProxy(ApiProxyService apiProxyService) {
this.apiProxyService = apiProxyService;
}

@RequestMapping("/**")
public ResponseEntity<String> proxy(@RequestBody(required = false) String body, HttpMethod method, HttpServletRequest request)
@RequestMapping(value = "/**", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public ResponseEntity<String> formDataProxy(
@RequestParam MultiValueMap<String, Object> formParams,
HttpMethod method,
HttpServletRequest request
) throws URISyntaxException {
URI uri = apiProxyService.prepareURI(request);

HttpHeaders httpHeaders = apiProxyService.prepareHttpHeaders(request.getContentType());
RestTemplate restTemplate = new RestTemplate();
restTemplate.getMessageConverters().add(0, new FormHttpMessageConverter());

HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(formParams, httpHeaders);
try {
return restTemplate.exchange(uri, method, requestEntity, String.class);
} catch (HttpClientErrorException httpClientErrorException) {
if (
httpClientErrorException.getStatusCode() != null && httpClientErrorException.getStatusCode().equals(HttpStatus.BAD_REQUEST)
) {
throw new BadRequestAlertException(httpClientErrorException.getMessage(), "", "");
} else {
throw new ResponseStatusException(httpClientErrorException.getStatusCode(), httpClientErrorException.getMessage());
}
}
}

@RequestMapping(value = "/**", consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> jsonProxy(@RequestBody(required = false) String body, HttpMethod method, HttpServletRequest request)
throws URISyntaxException {
URI uri = apiProxyService.prepareURI(request);

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/config/liquibase/data/authority.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name
ROLE_ADMIN
ROLE_DEV
ROLE_USER
ROLE_CURATOR
1 change: 1 addition & 0 deletions src/main/webapp/app/appConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
type FrontendProperties = {
firebase?: FirebaseProperties;
sentryDsn?: string;
stopReviewIfCoreSubmissionFails?: boolean;
};

export type FirebaseProperties = {
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/app/components/diff-viewer/DiffViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type DiffViewerProps = {
className?: string;
};

const getMergedDiff = (newContent='', oldContent='') => {
const getMergedDiff = (newContent = '', oldContent = '') => {
const dmp = new DiffMatchPatch();
const diff = dmp.diff_main(oldContent, newContent);
dmp.diff_cleanupSemantic(diff);
Expand Down
89 changes: 74 additions & 15 deletions src/main/webapp/app/components/tabs/CurationToolsTab.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import { componentInject } from 'app/shared/util/typed-inject';
import { IRootStore } from 'app/stores';
import { IRootStore, hasAnyAuthority } from 'app/stores';
import React, { useEffect, useRef, useState } from 'react';
import { Button, Col, Row } from 'reactstrap';
import { FaRegCheckCircle } from 'react-icons/fa';
import { FaRegCircleXmark } from 'react-icons/fa6';
import { notifyError } from 'app/oncokb-commons/components/util/NotificationUtils';
import { FaRegCircleXmark, FaArrowRotateLeft } from 'react-icons/fa6';
import { notifyError, notifySuccess } from 'app/oncokb-commons/components/util/NotificationUtils';
import { IGene } from 'app/shared/model/gene.model';
import _ from 'lodash';
import { IFlag } from 'app/shared/model/flag.model';
import { CURRENT_REVIEWER } from 'app/config/constants/constants';
import { AUTHORITIES, CURRENT_REVIEWER } from 'app/config/constants/constants';
import { GeneType } from 'app/shared/model/firebase/firebase.model';
import { onValue, ref } from 'firebase/database';
import { FB_COLLECTION } from 'app/config/constants/firebase';
import SaveGeneButton from 'app/shared/button/SaveGeneButton';
import { Unsubscribe } from 'firebase/database';
import { geneIsReleased } from 'app/shared/util/entity-utils/gene-entity-utils';
import Tooltip from 'rc-tooltip';

export type ReleaseGeneTestData = {
passed: boolean;
Expand All @@ -22,6 +25,8 @@ export type ReleaseGeneTestData = {

export interface ICurationToolsTabProps extends StoreProps {
genePath: string;
isGermline: boolean;
hugoSymbol: string;
}

export function CurationToolsTab({
Expand All @@ -33,6 +38,11 @@ export function CurationToolsTab({
searchGenes,
updateGene,
searchFlags,
isGermline,
hugoSymbol,
isDev,
firebaseGeneService,
geneLegacyApi,
}: ICurationToolsTabProps) {
const [geneName, setGeneName] = useState<string>();
const [geneSummary, setGeneSummary] = useState<string>();
Expand Down Expand Up @@ -114,7 +124,7 @@ export function CurationToolsTab({

useEffect(() => {
const geneData = geneEntities?.find(entity => entity.hugoSymbol === geneName);
setIsReleased(geneData?.flags?.some(flag => isReleasedFlag(flag)) || false);
setIsReleased(geneData === undefined ? false : geneIsReleased(geneData));
geneToUpdate.current = geneData;
}, [geneEntities, geneName]);

Expand Down Expand Up @@ -146,6 +156,28 @@ export function CurationToolsTab({
}
await updateGene?.(newGene);
await searchGenes?.({ query: geneName, exact: true }); // repopulate gene store entities
await firebaseGeneService?.saveGene(isGermline, hugoSymbol);
} catch (error) {
notifyError(error);
}
}

async function handleUndoReleaseGeneConfirmClick() {
const newGene = _.cloneDeep(geneToUpdate.current);

try {
if (!newGene) {
throw new Error('Error retrieving gene');
}

if (newGene.flags) {
newGene.flags = newGene.flags.filter(flag => !isReleasedFlag(flag));
} else {
newGene.flags = [];
}
await updateGene?.(newGene);
await searchGenes?.({ query: geneName, exact: true }); // repopulate gene store entities
geneLegacyApi!.removeGene(newGene);
} catch (error) {
notifyError(error);
}
Expand All @@ -159,12 +191,26 @@ export function CurationToolsTab({

if (isReleased) {
return (
<Row>
<Col className={'d-flex align-items-center'}>
<FaRegCheckCircle className="text-success me-2" />
<span>Gene is released</span>
</Col>
</Row>
<>
<Row className="mb-3">
<Col className={'d-flex align-items-center'}>
<FaRegCheckCircle className="text-success me-2" />
<span>Gene is released</span>
<Tooltip overlay={'Undo Release'}>
<Button size={'sm'} onClick={handleUndoReleaseGeneConfirmClick} className={'ms-2'} color="danger" outline>
<FaArrowRotateLeft />
</Button>
</Tooltip>
</Col>
</Row>
{!isGermline && isDev && (
<Row className="border-top pt-3">
<Col>
<SaveGeneButton hugoSymbol={hugoSymbol} />
</Col>
</Row>
)}
</>
);
}

Expand Down Expand Up @@ -192,23 +238,36 @@ export function CurationToolsTab({
}

return (
<Button color="primary" onClick={() => setReleaseGeneClicked(clicked => !clicked)}>
Release Gene
</Button>
<div>
<Button color="primary" onClick={() => setReleaseGeneClicked(clicked => !clicked)}>
Release Gene
</Button>
</div>
);
}

return getContent();
}

const mapStoreToProps = ({ firebaseAppStore, firebaseMetaStore, geneStore, flagStore }: IRootStore) => ({
const mapStoreToProps = ({
firebaseAppStore,
firebaseMetaStore,
geneStore,
flagStore,
authStore,
firebaseGeneService,
geneLegacyApi,
}: IRootStore) => ({
firebaseDb: firebaseAppStore.firebaseDb,
metaList: firebaseMetaStore.data,
addMetaListListener: firebaseMetaStore.addListener,
geneEntities: geneStore.entities,
searchGenes: geneStore.searchEntities,
updateGene: geneStore.updateEntity,
searchFlags: flagStore.searchEntities,
isDev: hasAnyAuthority(authStore.account.authorities, [AUTHORITIES.DEV]),
firebaseGeneService,
geneLegacyApi,
});

type StoreProps = Partial<ReturnType<typeof mapStoreToProps>>;
Expand Down
58 changes: 37 additions & 21 deletions src/main/webapp/app/components/tabs/GeneListPageToolsTab.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import { CURATE_NEW_GENE_TEXT, DEFAULT_ICON_SIZE, PAGE_ROUTE } from 'app/config/constants/constants';
import { AUTHORITIES, CURATE_NEW_GENE_TEXT, DEFAULT_ICON_SIZE, PAGE_ROUTE } from 'app/config/constants/constants';
import GeneSelect from 'app/shared/select/GeneSelect';
import { componentInject } from 'app/shared/util/typed-inject';
import { IRootStore } from 'app/stores';
import { IRootStore, hasAnyAuthority } from 'app/stores';
import { observer } from 'mobx-react';
import React, { useRef, useState } from 'react';
import { FaExclamationCircle } from 'react-icons/fa';
import { Button } from 'reactstrap';
import { Button, Col, Row } from 'reactstrap';
import './curation-tools-tab.scss';
import { MetaCollection } from 'app/shared/model/firebase/firebase.model';
import SaveGeneButton from 'app/shared/button/SaveGeneButton';

export interface IGeneListPageToolsTab extends StoreProps {
metaData: MetaCollection | null;
isGermline: boolean;
}

function GeneListPageToolsTab({ metaData, createGene }: IGeneListPageToolsTab) {
function GeneListPageToolsTab({ metaData, isDev, createGene, isGermline }: IGeneListPageToolsTab) {
const selectedGene = useRef<string>();
const [createButtonDisabled, setCreateButtonDisabled] = useState(true);
const [showGeneExistsWarning, setShowGeneExistsWarning] = useState(false);
Expand Down Expand Up @@ -41,28 +43,42 @@ function GeneListPageToolsTab({ metaData, createGene }: IGeneListPageToolsTab) {
}

return (
<div>
<h6 className="mb-2">{CURATE_NEW_GENE_TEXT}</h6>
<div className="mb-2">
<GeneSelect onChange={handleChangeSelectedGene} />
</div>
<div className={`d-flex align-items-center ${showGeneExistsWarning ? 'justify-content-between' : 'justify-content-end'}`}>
{showGeneExistsWarning && (
<div className="error-message me-2">
<FaExclamationCircle className="me-2" size={DEFAULT_ICON_SIZE} color="danger" />
<span>Gene already exists</span>
<>
<Row>
<Col className="mb-3">
<div>
<h6 className="mb-2">{CURATE_NEW_GENE_TEXT}</h6>
<div className="mb-2">
<GeneSelect onChange={handleChangeSelectedGene} />
</div>
<div className={`d-flex align-items-center ${showGeneExistsWarning ? 'justify-content-between' : 'justify-content-end'}`}>
{showGeneExistsWarning && (
<div className="error-message me-2">
<FaExclamationCircle className="me-2" size={DEFAULT_ICON_SIZE} color="danger" />
<span>Gene already exists</span>
</div>
)}
<Button color="primary" disabled={createButtonDisabled} onClick={handleCreateGene}>
Create
</Button>
</div>
</div>
)}
<Button color="primary" disabled={createButtonDisabled} onClick={handleCreateGene}>
Create
</Button>
</div>
</div>
</Col>
</Row>
{!isGermline && isDev && (
<Row className="pt-3 border-top">
<div>
<SaveGeneButton />
</div>
</Row>
)}
</>
);
}

const mapStoreToProps = ({ firebaseGeneService }: IRootStore) => ({
const mapStoreToProps = ({ firebaseGeneService, authStore }: IRootStore) => ({
createGene: firebaseGeneService.createGene,
isDev: hasAnyAuthority(authStore.account.authorities, [AUTHORITIES.DEV]),
});

type StoreProps = Partial<ReturnType<typeof mapStoreToProps>>;
Expand Down
2 changes: 2 additions & 0 deletions src/main/webapp/app/config/constants/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ToastOptions } from 'react-toastify';

export const AUTHORITIES = {
ADMIN: 'ROLE_ADMIN',
DEV: 'ROLE_DEV',
USER: 'ROLE_USER',
CURATOR: 'ROLE_CURATOR',
};
Expand Down Expand Up @@ -336,6 +337,7 @@ export enum SearchOptionType {
export enum USER_AUTHORITY {
ROLE_USER = 'ROLE_USER',
ROLE_ADMIN = 'ROLE_ADMIN',
ROLE_DEV = 'ROLE_DEV',
ROLE_CURATOR = 'ROLE_CURATOR',
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/app/entities/drug/drug-update.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export const DrugUpdate = (props: IDrugUpdateProps) => {
{flags
? flags.map(otherEntity => (
<option value={otherEntity.id} key={otherEntity.id}>
{otherEntity.id}
Type: {otherEntity.type}, Flag: {otherEntity.name}
</option>
))
: null}
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/app/pages/curation/CurationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ export const CurationPage = (props: ICurationPageProps) => {
tabs={[
{
title: 'Tools',
content: <CurationToolsTab genePath={firebaseGenePath} />,
content: <CurationToolsTab genePath={firebaseGenePath} isGermline={isGermline} hugoSymbol={hugoSymbol ?? ''} />,
},
{
title: 'History',
Expand Down
Loading