77
88// App dependencies
99import { FetchMatrixFileFormatsSuccessAction } from "./fetch-matrix-file-formats-success.action" ;
10+ import { FetchMatrixUrlSpeciesSuccessAction } from "./fetch-matrix-url-species-success.action" ;
1011import { FetchFileManifestUrlSuccessAction } from "../file-manifest/fetch-file-manifest-url-success.action" ;
1112import { FileManifestState } from "../file-manifest/file-manifest.state" ;
1213import { FetchMatrixUrlSuccessAction } from "./fetch-matrix-url-success.action" ;
1314import { FetchMatrixPartialQueryMatchSuccessAction } from "./fetch-matrix-partial-query-match-success.action" ;
1415import { FetchProjectMatrixUrlsSuccessAction } from "./fetch-project-matrix-urls-success.action" ;
1516import { Matrix } from "./matrix.model" ;
16- import { MatrixResponse } from "../../shared/matrix-response.model" ;
17- import { MatrixStatus } from "../../shared/matrix-status.model" ;
17+ import { MatrixUrlRequest } from "../../shared/matrix-url-request.model" ;
1818import { ProjectMatrixUrls } from "../../shared/project-matrix-urls.model" ;
1919
2020const DEFAULT_MATRIX = {
2121 fileFormats : [ ] ,
2222 partialQueryMatch : null ,
23- matrixResponse : {
24- status : MatrixStatus . NOT_STARTED
25- } as MatrixResponse ,
23+ matrixUrlRequestsBySpecies : new Map < string , MatrixUrlRequest > ( ) ,
2624 matrixUrlsByProjectId : new Map < string , ProjectMatrixUrls > ( )
2725} ;
2826
2927export class MatrixState implements Matrix {
3028
3129 fileFormats : string [ ] ;
3230 partialQueryMatch : boolean ;
33- matrixResponse : MatrixResponse ;
31+ matrixUrlRequestsBySpecies : Map < string , MatrixUrlRequest > ;
3432 matrixUrlsByProjectId : Map < string , ProjectMatrixUrls > ;
3533
3634 /**
@@ -50,9 +48,7 @@ export class MatrixState implements Matrix {
5048 return new MatrixState ( {
5149 fileFormats : this . fileFormats ,
5250 partialQueryMatch : this . partialQueryMatch ,
53- matrixResponse : {
54- status : MatrixStatus . NOT_STARTED
55- } as MatrixResponse ,
51+ matrixUrlRequestsBySpecies : new Map ( ) ,
5652 matrixUrlsByProjectId : this . matrixUrlsByProjectId
5753 } ) ;
5854 }
@@ -67,7 +63,7 @@ export class MatrixState implements Matrix {
6763 return new MatrixState ( {
6864 fileFormats : this . fileFormats ,
6965 partialQueryMatch : null ,
70- matrixResponse : this . matrixResponse ,
66+ matrixUrlRequestsBySpecies : this . matrixUrlRequestsBySpecies ,
7167 matrixUrlsByProjectId : this . matrixUrlsByProjectId
7268 } ) ;
7369 }
@@ -84,11 +80,12 @@ export class MatrixState implements Matrix {
8480 * @returns {MatrixState }
8581 */
8682 public fetchMatrixFileFormatsSuccess ( action : FetchMatrixFileFormatsSuccessAction ) {
83+
8784 const fileFormats = action . fileFormats ;
8885 return new MatrixState ( {
8986 fileFormats,
9087 partialQueryMatch : this . partialQueryMatch ,
91- matrixResponse : this . matrixResponse ,
88+ matrixUrlRequestsBySpecies : this . matrixUrlRequestsBySpecies ,
9289 matrixUrlsByProjectId : this . matrixUrlsByProjectId
9390 } ) ;
9491 }
@@ -104,7 +101,7 @@ export class MatrixState implements Matrix {
104101 return new MatrixState ( {
105102 fileFormats : this . fileFormats ,
106103 partialQueryMatch : action . partialQueryMatch ,
107- matrixResponse : this . matrixResponse ,
104+ matrixUrlRequestsBySpecies : this . matrixUrlRequestsBySpecies ,
108105 matrixUrlsByProjectId : this . matrixUrlsByProjectId
109106 } ) ;
110107 }
@@ -124,7 +121,7 @@ export class MatrixState implements Matrix {
124121 return new MatrixState ( {
125122 fileFormats : this . fileFormats ,
126123 partialQueryMatch : this . partialQueryMatch ,
127- matrixResponse : this . matrixResponse ,
124+ matrixUrlRequestsBySpecies : this . matrixUrlRequestsBySpecies ,
128125 matrixUrlsByProjectId : updatedMatrixUrlsByProjectId
129126 } ) ;
130127 }
@@ -137,11 +134,32 @@ export class MatrixState implements Matrix {
137134 * @param {FetchFileManifestUrlSuccessAction } action
138135 * @returns {FileManifestState }
139136 */
140- public fetchMatrixUrlSuccess ( action : FetchMatrixUrlSuccessAction ) {
137+ public fetchMatrixUrlRequestSuccess ( action : FetchMatrixUrlSuccessAction ) {
138+
139+ const requestsBySpecies = new Map ( this . matrixUrlRequestsBySpecies ) ;
140+ requestsBySpecies . set ( action . response . species , action . response ) ;
141+
142+ return new MatrixState ( {
143+ fileFormats : this . fileFormats ,
144+ partialQueryMatch : this . partialQueryMatch ,
145+ matrixUrlRequestsBySpecies : requestsBySpecies ,
146+ matrixUrlsByProjectId : this . matrixUrlsByProjectId
147+ } ) ;
148+ }
149+
150+ /**
151+ * Manifest URL request response has been received from server and we have determined the set of species for the
152+ * request.
153+ *
154+ * @param {FetchFileManifestUrlSuccessAction } action
155+ * @returns {FileManifestState }
156+ */
157+ public fetchMatrixUrlRequestSpeciesSuccess ( action : FetchMatrixUrlSpeciesSuccessAction ) {
158+
141159 return new MatrixState ( {
142160 fileFormats : this . fileFormats ,
143161 partialQueryMatch : this . partialQueryMatch ,
144- matrixResponse : action . response ,
162+ matrixUrlRequestsBySpecies : action . response . matrixUrlRequestsBySpecies ,
145163 matrixUrlsByProjectId : this . matrixUrlsByProjectId
146164 } ) ;
147165 }
0 commit comments