@@ -308,14 +308,15 @@ angular
308308 * <pre>
309309 * {
310310 * id: 'learning_dataset',
311+ * type: 'uploaded_dataset',
311312 * created_at: '2014-12-14T15:09:08.112Z',
312313 * updated_at: '2014-12-14T15:08:57.970Z',
313314 * name: 'Learning dataset',
314315 * header: null,
315316 * separator: null,
316317 * user_id: '541b06dc617070006d060000',
317318 * source_ids: ['54904b136170700007330000'],
318- * parent_dataset_id : null,
319+ * dataset_id : null,
319320 * sampling: 100,
320321 * nb_of_lines: 50002,
321322 * children_dataset_ids: [],
@@ -341,7 +342,8 @@ angular
341342 * {
342343 * ...
343344 * source_ids: [],
344- * parent_dataset_id: 'learning_dataset_with_model',
345+ * type: 'subset',
346+ * dataset_id: 'learning_dataset_with_model',
345347 * sampling: 70,
346348 * nb_of_lines: null,
347349 * preview: null
@@ -354,7 +356,8 @@ angular
354356 * {
355357 * ...
356358 * source_ids: [],
357- * parent_dataset_id: 'learning_dataset_with_model',
359+ * type: 'subset',
360+ * dataset_id: 'learning_dataset_with_model',
358361 * sampling: -70,
359362 * nb_of_lines: null,
360363 * preview: null
@@ -393,6 +396,7 @@ angular
393396 * <pre>
394397 * {
395398 * ...
399+ * type: 'scoreset'
396400 * classifier_id: '5436431070632d15f4260000',
397401 * dataset_id: 'scoring_dataset',
398402 * modalities_set_id: '53fdfa7070632d0fc5030000',
@@ -426,7 +430,8 @@ angular
426430 * source_ids: ['original_source_id'],
427431 * header: true,
428432 * separator: '\t',
429- * data_file: { filename: 'source.csv' }
433+ * data_file: { filename: 'source.csv' },
434+ * type: 'uploaded_dataset'
430435 * }
431436 * </pre>
432437 *
@@ -442,7 +447,8 @@ angular
442447 * main_modality: $main_modality$,
443448 * separator: $separator$,
444449 * header: $header$,
445- * data_file: { filename: $name$ }
450+ * data_file: { filename: $name$ },
451+ * type: 'scoreset'
446452 * }
447453 * </pre>
448454 *
@@ -481,6 +487,7 @@ angular
481487 return Sources . create ( source )
482488 . then ( function ( source ) {
483489 return self . create ( {
490+ type : 'uploaded_dataset' ,
484491 name : fileName ,
485492 source_ids : [ source . id ] ,
486493 data_file : { filename : fileName }
@@ -523,14 +530,16 @@ angular
523530 sampling = sampling || DEFAULT_SAMPLING ;
524531
525532 var learn = {
526- parent_dataset_id : id ,
533+ type : 'subset' ,
534+ dataset_id : id ,
527535 name : 'learned_' + name ,
528536 data_file : { filename : 'learned_' + filename } ,
529537 sampling : sampling
530538 } ;
531539
532540 var test = {
533- parent_dataset_id : id ,
541+ type : 'subset' ,
542+ dataset_id : id ,
534543 name : 'tested_' + name ,
535544 data_file : { filename : 'tested_' + filename } ,
536545 sampling : - sampling
@@ -612,7 +621,7 @@ angular
612621 } )
613622 . then ( function ( childrenCandidates ) {
614623 return childrenCandidates . reduce ( function ( memo , child ) {
615- if ( child . parent_dataset_id === datasetId ) {
624+ if ( child . dataset_id === datasetId ) {
616625 if ( self . isTrainPart ( child , DEFAULT_SAMPLING ) ) {
617626 memo . train = child ;
618627 } else if ( self . isTestPart ( child , - DEFAULT_SAMPLING ) ) {
@@ -716,33 +725,32 @@ angular
716725 * @return {Boolean } <kbd>true</kbd> / <kbd>false</kbd>
717726 */
718727 this . hasChildren = function ( dataset ) {
719- return Boolean ( dataset . children_dataset_ids . length > 0 ) ;
728+ return Boolean ( dataset . children_dataset_ids && dataset . children_dataset_ids . length > 0 ) ;
720729 } ;
721730
722731 /**
723732 * @ngdoc function
724733 * @methodOf predicsis.jsSDK.models.Datasets
725734 * @name isParent
726735 * @description Tells if a dataset is a parent dataset.
727- * <b>Note:</b> A parent may have any children, but its <kbd>parent_dataset_id </kbd> must be null
736+ * <b>Note:</b> A parent may have any children, but its <kbd>dataset_id </kbd> must be null
728737 * @param {Object } dataset Instance of {@link predicsis.jsSDK.models.Datasets dataset}
729738 * @return {Boolean } <kbd>true</kbd> / <kbd>false</kbd>
730739 */
731740 this . isParent = function ( dataset ) {
732- return Boolean ( dataset . parent_dataset_id === null ) ;
741+ return Boolean ( dataset . type === 'uploaded_dataset' ) ;
733742 } ;
734743
735744 /**
736745 * @ngdoc function
737746 * @methodOf predicsis.jsSDK.models.Datasets
738747 * @name isChild
739748 * @description Tells if a dataset is a child dataset
740- * <b>Note:</b> A dataset is considered as a child if it has a parent. There is no orphan among datasets!
741749 * @param {Object } dataset Instance of {@link predicsis.jsSDK.models.Datasets dataset}
742750 * @return {Boolean } <kbd>true</kbd> / <kbd>false</kbd>
743751 */
744752 this . isChild = function ( dataset ) {
745- return Boolean ( dataset . parent_dataset_id !== null ) ;
753+ return Boolean ( dataset . type === 'subset' ) ;
746754 } ;
747755
748756 /**
@@ -810,14 +818,12 @@ angular
810818 * <li><code>dataset.classifier !== null</code></li>
811819 * <li><code>dataset.dataset_id !== null</code></li>
812820 * </ul>
821+ * Since the API implements a type attribute, this check is really simpler
813822 * @param {Object } dataset Instance of {@link predicsis.jsSDK.models.Datasets dataset}
814823 * @return {Boolean } <kbd>true</kbd> / <kbd>false</kbd>
815824 */
816825 this . isScore = function ( dataset ) {
817- return Boolean ( dataset . source_ids . length === 0 )
818- && Boolean ( dataset . main_modality !== null )
819- && Boolean ( dataset . classifier !== null )
820- && Boolean ( dataset . dataset_id !== null ) ;
826+ return Boolean ( dataset . type === 'scoreset' ) ;
821827 } ;
822828 } ) ;
823829
0 commit comments