8181 * <pre>
8282 * {
8383 * id: 'learning_dataset',
84+ * type: 'upload_dataset',
8485 * created_at: '2014-12-14T15:09:08.112Z',
8586 * updated_at: '2014-12-14T15:08:57.970Z',
8687 * name: 'Learning dataset',
114115 * {
115116 * ...
116117 * source_ids: [],
118+ * type: 'subset',
117119 * parent_dataset_id: 'learning_dataset_with_model',
118120 * sampling: 70,
119121 * nb_of_lines: null,
127129 * {
128130 * ...
129131 * source_ids: [],
132+ * type: 'subset',
130133 * parent_dataset_id: 'learning_dataset_with_model',
131134 * sampling: -70,
132135 * nb_of_lines: null,
166169 * <pre>
167170 * {
168171 * ...
172+ * type: 'scoreset'
169173 * classifier_id: '5436431070632d15f4260000',
170174 * dataset_id: 'scoring_dataset',
171175 * modalities_set_id: '53fdfa7070632d0fc5030000',
@@ -199,7 +203,8 @@ angular
199203 * source_ids: ['original_source_id'],
200204 * header: true,
201205 * separator: '\t',
202- * data_file: { filename: 'source.csv' }
206+ * data_file: { filename: 'source.csv' },
207+ * type: 'upload_dataset'
203208 * }
204209 * </pre>
205210 *
@@ -215,7 +220,8 @@ angular
215220 * main_modality: $main_modality$,
216221 * separator: $separator$,
217222 * header: $header$,
218- * data_file: { filename: $name$ }
223+ * data_file: { filename: $name$ },
224+ * type: 'scoreset'
219225 * }
220226 * </pre>
221227 *
@@ -254,6 +260,7 @@ angular
254260 return Sources . create ( source )
255261 . then ( function ( source ) {
256262 return self . create ( {
263+ type : 'upload_dataset' ,
257264 name : fileName ,
258265 source_ids : [ source . id ] ,
259266 data_file : { filename : fileName }
@@ -296,13 +303,15 @@ angular
296303 sampling = sampling || DEFAULT_SAMPLING ;
297304
298305 var learn = {
306+ type : 'subset' ,
299307 parent_dataset_id : id ,
300308 name : 'learned_' + name ,
301309 data_file : { filename : 'learned_' + filename } ,
302310 sampling : sampling
303311 } ;
304312
305313 var test = {
314+ type : 'subset' ,
306315 parent_dataset_id : id ,
307316 name : 'tested_' + name ,
308317 data_file : { filename : 'tested_' + filename } ,
@@ -385,7 +394,7 @@ angular
385394 } )
386395 . then ( function ( childrenCandidates ) {
387396 return childrenCandidates . reduce ( function ( memo , child ) {
388- if ( child . parent_dataset_id === datasetId ) {
397+ if ( child . dataset_id === datasetId ) {
389398 if ( self . isTrainPart ( child , DEFAULT_SAMPLING ) ) {
390399 memo . train = child ;
391400 } else if ( self . isTestPart ( child , - DEFAULT_SAMPLING ) ) {
@@ -489,7 +498,7 @@ angular
489498 * @return {Boolean } <kbd>true</kbd> / <kbd>false</kbd>
490499 */
491500 this . hasChildren = function ( dataset ) {
492- return Boolean ( dataset . children_dataset_ids . length > 0 ) ;
501+ return Boolean ( dataset . children_dataset_ids && dataset . children_dataset_ids . length > 0 ) ;
493502 } ;
494503
495504 /**
@@ -502,20 +511,19 @@ angular
502511 * @return {Boolean } <kbd>true</kbd> / <kbd>false</kbd>
503512 */
504513 this . isParent = function ( dataset ) {
505- return Boolean ( dataset . parent_dataset_id === null ) ;
514+ return Boolean ( dataset . type === 'upload_dataset' ) ;
506515 } ;
507516
508517 /**
509518 * @ngdoc function
510519 * @methodOf predicsis.jsSDK.models.Datasets
511520 * @name isChild
512521 * @description Tells if a dataset is a child dataset
513- * <b>Note:</b> A dataset is considered as a child if it has a parent. There is no orphan among datasets!
514522 * @param {Object } dataset Instance of {@link predicsis.jsSDK.models.Datasets dataset}
515523 * @return {Boolean } <kbd>true</kbd> / <kbd>false</kbd>
516524 */
517525 this . isChild = function ( dataset ) {
518- return Boolean ( dataset . parent_dataset_id !== null ) ;
526+ return Boolean ( dataset . type === 'subset' ) ;
519527 } ;
520528
521529 /**
@@ -583,13 +591,11 @@ angular
583591 * <li><code>dataset.classifier !== null</code></li>
584592 * <li><code>dataset.dataset_id !== null</code></li>
585593 * </ul>
594+ * Since the API implements a type attribute, this check is really simpler
586595 * @param {Object } dataset Instance of {@link predicsis.jsSDK.models.Datasets dataset}
587596 * @return {Boolean } <kbd>true</kbd> / <kbd>false</kbd>
588597 */
589598 this . isScore = function ( dataset ) {
590- return Boolean ( dataset . source_ids . length === 0 )
591- && Boolean ( dataset . main_modality !== null )
592- && Boolean ( dataset . classifier !== null )
593- && Boolean ( dataset . dataset_id !== null ) ;
599+ return Boolean ( dataset . type === 'scoreset' ) ;
594600 } ;
595601 } ) ;
0 commit comments