Commit 3ed4abd5 authored by Matija Obreza's avatar Matija Obreza
Browse files

Subset#accessionIds renamed to accessionRefs

parent 75fa4f3d
......@@ -10,7 +10,7 @@ import AccessionMapInfo from 'model/AccessionMapInfo';
import {RECEIVE_ACCESSIONS, RECEIVE_ACCESSION, RECEIVE_ACCESSION_OVERVIEW, APPEND_ACCESSIONS, RECEIVE_ACCESSION_MAPINFO} from 'accessions/constants';
import AccessionService from 'service/genesys/AccessionService';
import { AccessionIdentifier } from 'model/dataset.model';
import { AccessionRef } from 'model/dataset.model';
const receiveAccessions = (paged: FilteredPage<Accession>, error = null) => ({
type: RECEIVE_ACCESSIONS,
......@@ -37,7 +37,7 @@ const receiveAccession = (accession: AccessionDetails, error = null) => ({
payload: { accession, error },
});
export const toUUIDPromise = (identifiers: AccessionIdentifier[]) => (dispatch, getState): Promise<Map<string, AccessionIdentifier>> => {
export const toUUIDPromise = (identifiers: AccessionRef[]) => (dispatch, getState): Promise<Map<string, AccessionRef>> => {
return AccessionService.toUUID(identifiers);
};
......
......@@ -9,7 +9,7 @@ import Crop from 'model/Crop';
class Subset {
public accessionCount: number;
public accessionIds: string[];
public accessionRefs: string[];
public active: boolean;
public creators: Creator[];
public createdBy: number;
......
import { EmptyModel } from 'model/common.model';
export class AccessionIdentifier extends EmptyModel {
export class AccessionRef extends EmptyModel {
public doi: string;
public instCode: string;
public acceNumb: string;
......@@ -12,6 +12,6 @@ export class AccessionIdentifier extends EmptyModel {
}
public getClassname(): string {
return 'org.genesys.catalog.model.dataset.AccessionIdentifier';
return 'org.genesys.catalog.model.dataset.AccessionRef';
}
}
export interface IBasicModelFilter {
id?: number[];
_text?: string;
}
export interface IVersionedModelFilter extends IBasicModelFilter {
version?: number[];
}
export interface IDateFilter {
ge?: Date;
gt?: Date;
le?: Date;
lt?: Date;
}
export interface INumberFilter {
eq?: number;
gt?: number;
ge?: number;
lt?: number;
le?: number;
}
export interface IStringFilter {
eq?: string; // equals
contains?: string; // like
sw?: string; // starts with
}
export interface IAuditedVersionedModelFilter extends IVersionedModelFilter {
createdBy?: number[];
lastModifiedBy?: number[];
createdDate?: IDateFilter;
lastModifiedDate?: IDateFilter;
}
......@@ -72,7 +72,7 @@ class DisplayPage extends React.Component<IDisplayPageProps, any> {
{ request.body.requestInfo && <PropertiesItem title="Purpose type">{ t(`request.purposeType.${request.body.requestInfo.purposeType}`) }</PropertiesItem> }
{ request.body.requestInfo && <PropertiesItem title={ t(`request.preacceptSMTA`) }>{ request.body.requestInfo.preacceptSMTA ? 'Yes' : 'No' }</PropertiesItem> }
{ request.body.requestInfo && <PropertiesItem title="Notes">{ request.body.requestInfo.notes }</PropertiesItem> }
<PropertiesItem title="Requested accession ids">{ request.body.accessionIds.reduce((id, acc) => `${acc}, ${id}`) }</PropertiesItem>
<PropertiesItem title="Requested accession ids">{ request.body.accessionRefs.reduce((id, acc) => `${acc}, ${id}`) }</PropertiesItem>
</Properties>
</MainSection>
{ request.body.pid && request.body.pid.type === 'in' &&
......
......@@ -40,7 +40,7 @@ const RequestCard = ({request, classes, index, ...other}: { request: MaterialReq
<b></b>
</span>
}
{ request.body.accessionIds.length } accessions
{ request.body.accessionRefs.length } accessions
</div>
</CardContent>
</Card>
......
......@@ -8,7 +8,7 @@ import AccessionDetails from 'model/AccessionDetails';
import AccessionFilter from 'model/AccessionFilter';
import AccessionMapInfo from 'model/AccessionMapInfo';
import FilteredPage, { IPageRequest } from 'model/FilteredPage';
import {AccessionIdentifier} from 'model/dataset.model';
import {AccessionRef} from 'model/dataset.model';
const URL_GET_BY_DOI = `/api/v1/acn/{doi}`; // UrlTemplate doesn't like the / in DOI
const URL_GET_BY_UUID = UrlTemplate.parse(`/api/v1/acn/{UUID}`);
......@@ -99,7 +99,7 @@ class AccessionService {
}).then(({ data }) => data as AccessionDetails);
}
public static toUUID(identifiers: AccessionIdentifier[]) {
public static toUUID(identifiers: AccessionRef[]) {
const apiUrl = URL_TO_UUID;
const content = { data: identifiers };
......@@ -107,7 +107,7 @@ class AccessionService {
url: apiUrl,
method: 'POST',
...content,
}).then(({ data }) => data as Map<string, AccessionIdentifier>);
}).then(({ data }) => data as Map<string, AccessionRef>);
}
/**
......
......@@ -39,13 +39,13 @@ class SubsetService {
* @param authToken Authorization token
* @param UUID UUID
* @param version version
* @param accessionIds accessionIds
* @param accessionRefs accessionRefs
*/
public static addAccessions(UUID: string, version: number, accessionIds: string[]): Promise<Subset> {
public static addAccessions(UUID: string, version: number, accessionRefs: string[]): Promise<Subset> {
const apiUrl = URL_ADD_ACCESSIONS.expand({UUID, version});
// console.log(`Fetching from ${apiUrl}`);
const content = { data: accessionIds };
const content = { data: accessionRefs };
return axiosBackend.request({
url: apiUrl,
......
......@@ -10,7 +10,7 @@ import {ADD_CREATOR_TO_SUBSET, REMOVE_CREATOR_FROM_SUBSET, UPDATE_SUBSET_CREATOR
import Creator from 'model/Creator';
import Subset from 'model/Subset';
import {PublishState} from 'model/common.model';
import {AccessionIdentifier} from 'model/dataset.model';
import {AccessionRef} from 'model/dataset.model';
// Service
import SubsetService from 'service/genesys/SubsetService';
......@@ -19,10 +19,10 @@ import SubsetService from 'service/genesys/SubsetService';
import steps from 'subsets/ui/dashboard/subset-stepper/steps';
// Accession Identifiers step
export const updateSubsetAccessionIdentifiers = (subset: Subset, accessionIdentifiers: AccessionIdentifier[]) => (dispatch) => {
dispatch(toUUIDPromise(accessionIdentifiers))
.then((accessionIdentifiers) => {
SubsetService.addAccessions(subset.uuid, subset.version, Object.keys(accessionIdentifiers))
export const updateSubsetAccessionRefs = (subset: Subset, AccessionRefs: AccessionRef[]) => (dispatch) => {
dispatch(toUUIDPromise(AccessionRefs))
.then((AccessionRefs) => {
SubsetService.addAccessions(subset.uuid, subset.version, Object.keys(AccessionRefs))
.then((subset) => {
dispatch(receiveSubset(subset));
});
......
......@@ -39,21 +39,21 @@ class DetailInfo extends React.Component<IDetailInfoProps, any> {
subsetAccessions: [],
};
private loadAccessions = (accessionIds) => {
private loadAccessions = (accessionRefs) => {
const {listAccessions} = this.props;
const filter = new AccessionFilter();
filter.uuid = accessionIds.map((id) => id.uuid);
filter.uuid = accessionRefs.map((id) => id.uuid);
listAccessions(filter, {page: 0, size: accessionIds.length, direction: 'ASC'})
listAccessions(filter, {page: 0, size: accessionRefs.length, direction: 'ASC'})
.then((accessionPage) => this.setState({subsetAccessions: accessionPage.content}));
}
public componentWillMount() {
const {subset} = this.props;
if (subset && subset.accessionIds && subset.accessionIds.length > 0) {
this.loadAccessions(subset.accessionIds);
if (subset && subset.accessionRefs && subset.accessionRefs.length > 0) {
this.loadAccessions(subset.accessionRefs);
}
}
......@@ -61,8 +61,8 @@ class DetailInfo extends React.Component<IDetailInfoProps, any> {
const {subset} = nextProps;
const {subsetAccessions} = this.state;
if (subset && subset.accessionIds && subset.accessionIds.length > 0 && (!subsetAccessions || subsetAccessions.length === 0 || subsetAccessions.length !== subset.accessionIds.length)) {
this.loadAccessions(subset.accessionIds);
if (subset && subset.accessionRefs && subset.accessionRefs.length > 0 && (!subsetAccessions || subsetAccessions.length === 0 || subsetAccessions.length !== subset.accessionRefs.length)) {
this.loadAccessions(subset.accessionRefs);
}
}
......
......@@ -9,7 +9,7 @@ import {log} from 'utilities/debug';
import {CSV, ICsvConfiguration} from 'utilities/CSV';
// models
import {AccessionIdentifier} from 'model/dataset.model';
import {AccessionRef} from 'model/dataset.model';
import Accession from 'model/Accession';
import AccessionFilter from 'model/AccessionFilter';
import {IPageRequest} from 'model/FilteredPage';
......@@ -18,13 +18,13 @@ import Subset from 'model/Subset';
// ui
import CSVConfiguration, {CSVConfig} from 'ui/common/csv-configuration/CSVConfiguration';
import AccessionIdentifiersTable from 'ui/catalog/accession/IdentifiersTable';
import AccessionRefsTable from 'ui/catalog/accession/AccessionRefsTable';
interface IListOfAccession extends React.ClassAttributes<any> {
classes: any;
listAccessions: (filter: string | AccessionFilter, page: IPageRequest) => Promise<Page<Accession>>;
subset: Subset;
onAccessionsUpdated: (accessionIdentifiers: AccessionIdentifier[]) => void;
onAccessionsUpdated: (AccessionRefs: AccessionRef[]) => void;
}
const styleSheet = {
......@@ -43,13 +43,13 @@ const styleSheet = {
class ListOfAccession extends React.Component<IListOfAccession, any> {
private loadAccessions = (accessionIds) => {
private loadAccessions = (accessionRefs) => {
const {listAccessions} = this.props;
const filter = new AccessionFilter();
filter.uuid = accessionIds.map((id) => id.uuid);
filter.uuid = accessionRefs.map((id) => id.uuid);
listAccessions(filter, {page: 0, size: accessionIds.length, direction: 'ASC'})
listAccessions(filter, {page: 0, size: accessionRefs.length, direction: 'ASC'})
.then((accessionPage) => this.setState({subsetAccessions: accessionPage.content}));
}
......@@ -57,8 +57,8 @@ class ListOfAccession extends React.Component<IListOfAccession, any> {
const {subset} = this.props;
const {subsetAccessions} = this.state;
if (subset && subset.accessionIds && subset.accessionIds.length > 0 && (!subsetAccessions || subsetAccessions.length === 0)) {
this.loadAccessions(subset.accessionIds);
if (subset && subset.accessionRefs && subset.accessionRefs.length > 0 && (!subsetAccessions || subsetAccessions.length === 0)) {
this.loadAccessions(subset.accessionRefs);
}
}
......@@ -66,8 +66,8 @@ class ListOfAccession extends React.Component<IListOfAccession, any> {
const {subset} = nextProps;
const {subsetAccessions} = this.state;
if (subset && subset.accessionIds && subset.accessionIds.length > 0 && (!subsetAccessions || subsetAccessions.length === 0 || subsetAccessions.length !== subset.accessionIds.length)) {
this.loadAccessions(subset.accessionIds);
if (subset && subset.accessionRefs && subset.accessionRefs.length > 0 && (!subsetAccessions || subsetAccessions.length === 0 || subsetAccessions.length !== subset.accessionRefs.length)) {
this.loadAccessions(subset.accessionRefs);
}
}
......@@ -129,7 +129,7 @@ class ListOfAccession extends React.Component<IListOfAccession, any> {
<h3>Accession list: { subsetAccessions ? subsetAccessions.length : 0 } rows</h3>
{ subsetAccessions &&
<AccessionIdentifiersTable accessionIdentifiers={ subsetAccessions.map((accession) => ({doi: accession.doi, instCode: accession.institute.code, acceNumb: accession.accessionNumber, genus: accession.taxonomy.genus})) }/>
<AccessionRefsTable AccessionRefs={ subsetAccessions.map((accession) => ({doi: accession.doi, instCode: accession.institute.code, acceNumb: accession.accessionNumber, genus: accession.taxonomy.genus})) }/>
}
</div>
);
......@@ -146,11 +146,11 @@ class ListOfAccession extends React.Component<IListOfAccession, any> {
log('CSV config', config);
const newIdentifiers: AccessionIdentifier[] = [];
const newIdentifiers: AccessionRef[] = [];
CSV.parse(csvText, config, {headers: [ 'instCode', 'acceNumb', 'genus', 'species', 'doi']})
.subscribe((jsonObj) => {
const aid: AccessionIdentifier = new AccessionIdentifier(jsonObj);
const aid: AccessionRef = new AccessionRef(jsonObj);
newIdentifiers.push(aid);
log(aid);
}).then(() => {
......
......@@ -2,14 +2,14 @@ import * as React from 'react';
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
// actions
import {updateSubsetAccessionIdentifiers} from 'subsets/actions/editor';
import {updateSubsetAccessionRefs} from 'subsets/actions/editor';
import {listAccessionsPromise} from 'accessions/actions/public'; // TODO maybe move to dashboard or import from service
// models
import Subset from 'model/Subset';
import Page from 'model/Page';
import Accession from 'model/Accession';
import {AccessionIdentifier} from 'model/dataset.model';
import {AccessionRef} from 'model/dataset.model';
import AccessionFilter from 'model/AccessionFilter';
import {IPageRequest} from 'model/FilteredPage';
// ui
......@@ -19,7 +19,7 @@ import Loading from 'ui/common/Loading';
interface IAccessionsListStep extends React.ClassAttributes<any> {
item: Subset;
updateSubsetAccessionIdentifiers: (subset: Subset, accessionIds: AccessionIdentifier[]) => Promise<Subset>;
updateSubsetAccessionRefs: (subset: Subset, accessionRefs: AccessionRef[]) => Promise<Subset>;
listAccessions: (filter: string | AccessionFilter, page: IPageRequest) => Promise<Page<Accession>>;
}
......@@ -31,15 +31,15 @@ class AccessionsListStep extends StepperTemplate<IAccessionsListStep> {
return !item ? <Loading /> : (
<ListOfAccessions
listAccessions={ listAccessions }
onAccessionsUpdated={ this.updateAccessionIds }
onAccessionsUpdated={ this.updateaccessionRefs }
subset={ item }
/>
);
}
protected updateAccessionIds = (accessionIdentifiers: AccessionIdentifier[]) => {
const {item: subset, updateSubsetAccessionIdentifiers} = this.props;
updateSubsetAccessionIdentifiers(subset, accessionIdentifiers);
protected updateaccessionRefs = (AccessionRefs: AccessionRef[]) => {
const {item: subset, updateSubsetAccessionRefs} = this.props;
updateSubsetAccessionRefs(subset, AccessionRefs);
}
}
......@@ -48,7 +48,7 @@ const mapStateToProps = (state, ownProps) => ({
});
const mapDispatchToProps = (dispatch) => bindActionCreators({
updateSubsetAccessionIdentifiers,
updateSubsetAccessionRefs,
listAccessions: listAccessionsPromise,
}, dispatch);
......
import * as React from 'react';
import { withStyles } from '@material-ui/core/styles';
import { AccessionIdentifier } from 'model/dataset.model';
import { AccessionRef } from 'model/dataset.model';
import { Table as VTable, Column as VColumn, AutoSizer } from 'react-virtualized';
import DOI from 'ui/common/DOI';
// import Hidden from '@material-ui/core/Hidden';
......@@ -31,24 +31,24 @@ const styles = (theme) => ({
},
});
interface IAccessionIdentifiersTableProps extends React.ClassAttributes<any> {
interface IAccessionRefsTableProps extends React.ClassAttributes<any> {
classes: any;
accessionIdentifiers: AccessionIdentifier[];
AccessionRefs: AccessionRef[];
}
class AccessionIdentifiersTable extends React.Component<IAccessionIdentifiersTableProps, any> {
class AccessionRefsTable extends React.Component<IAccessionRefsTableProps, any> {
constructor(props, context) {
super(props, context);
}
public render() {
const { accessionIdentifiers, classes } = this.props;
const rowGetter = ({ index }) => accessionIdentifiers[index];
const { AccessionRefs, classes } = this.props;
const rowGetter = ({ index }) => AccessionRefs[index];
const renderDoi = ({ cellData }) => <DOI noPrefix value={ cellData } />;
const rowClassName = ({ index }) => index === -1 ? '' : `${classes.tableCell} ${index % 2 === 0 ? classes.evenRow : classes.oddRow}`;
return accessionIdentifiers && accessionIdentifiers.sort((a, b) => a.acceNumb.localeCompare(b.acceNumb)) && (
return AccessionRefs && AccessionRefs.sort((a, b) => a.acceNumb.localeCompare(b.acceNumb)) && (
<AutoSizer disableHeight>
{ ({ width }) => (
<VTable
......@@ -57,7 +57,7 @@ class AccessionIdentifiersTable extends React.Component<IAccessionIdentifiersTab
height={ 500 }
headerHeight={ 25 }
rowHeight={ 30 }
rowCount={ accessionIdentifiers.length }
rowCount={ AccessionRefs.length }
rowGetter={ rowGetter }
rowClassName={ rowClassName }
headerClassName={ `back-green` }
......@@ -74,4 +74,4 @@ class AccessionIdentifiersTable extends React.Component<IAccessionIdentifiersTab
}
}
export default withStyles(styles)(AccessionIdentifiersTable);
export default withStyles(styles)(AccessionRefsTable);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment