@@ -336,10 +336,7 @@ public Response some(Annotation annotation) {
336
336
// create a new one
337
337
@ Override
338
338
public Response none () {
339
- Resource resource = eas .createResource (Option .none ());
340
- final Annotation a = eas .createAnnotation (
341
- new AnnotationImpl (id , trackId , start , option (duration ), content , createdFromQuestionnaire , trimToNone (settings ), resource ));
342
- return Response .created (annotationLocationUri (videoId , a )).entity (AnnotationDto .toJson .apply (eas , a ).toString ()).build ();
339
+ return NOT_FOUND ;
343
340
}
344
341
});
345
342
} else {
@@ -430,33 +427,16 @@ public Response apply() {
430
427
@ POST
431
428
@ Produces (MediaType .APPLICATION_JSON )
432
429
@ Path ("scales" )
433
- public Response postScale (@ FormParam ("name" ) final String name , @ FormParam ("description" ) final String description ,
434
- @ FormParam ("scale_id" ) final Long scaleId , @ FormParam ("access" ) final Integer access ) {
435
- if (scaleId == null ) {
436
- return run (array (name ), new Function0 <>() {
437
- @ Override
438
- public Response apply () {
439
- if (eas .getVideo (videoId ).isNone ()) {
440
- return BAD_REQUEST ;
441
- }
442
-
443
- Resource resource = eas .createResource (option (access ), none ());
444
- final Scale scale = eas .createScale (videoId , name , trimToNone (description ), resource );
445
- return Response .created (scaleLocationUri (scale )).entity (ScaleDto .toJson .apply (eas , scale ).toString ()).build ();
446
- }
447
- });
448
- }
449
-
450
- // TODO Why does this not use `createScale`?
451
- return run (array (scaleId ), new Function0 <>() {
430
+ public Response postScale (@ FormParam ("name" ) final String name , @ FormParam ("description" ) final String description , @ FormParam ("access" ) final Integer access ) {
431
+ return run (array (name ), new Function0 <>() {
452
432
@ Override
453
433
public Response apply () {
454
- if (eas .getScale ( scaleId , false ). isNone () || videoOpt .isNone ()) {
434
+ if (eas .getVideo ( videoId ) .isNone ()) {
455
435
return BAD_REQUEST ;
456
436
}
457
437
458
438
Resource resource = eas .createResource (option (access ), none ());
459
- final Scale scale = eas .createScaleFromTemplate (videoId , scaleId , resource );
439
+ final Scale scale = eas .createScale (videoId , name , trimToNone ( description ) , resource );
460
440
return Response .created (scaleLocationUri (scale )).entity (ScaleDto .toJson .apply (eas , scale ).toString ()).build ();
461
441
}
462
442
});
@@ -491,10 +471,7 @@ public Response some(Scale scale) {
491
471
492
472
@ Override
493
473
public Response none () {
494
- Resource resource = eas .createResource ();
495
- final Scale scale = eas .createScale (videoId , name , trimToNone (description ), resource );
496
-
497
- return Response .created (scaleLocationUri (scale )).entity (ScaleDto .toJson .apply (eas , scale ).toString ()).build ();
474
+ return NOT_FOUND ;
498
475
}
499
476
});
500
477
}
@@ -626,10 +603,7 @@ public Response some(ScaleValue s) {
626
603
627
604
@ Override
628
605
public Response none () {
629
- Resource resource = eas .createResource (option (access ), Option .none ());
630
- final ScaleValue scaleValue = eas .createScaleValue (scaleId , name , value , order , resource );
631
-
632
- return Response .created (scaleValueLocationUri (scaleValue , videoId )).entity (ScaleValueDto .toJson .apply (eas , scaleValue ).toString ()).build ();
606
+ return NOT_FOUND ;
633
607
}
634
608
});
635
609
}
@@ -712,50 +686,22 @@ public Response none() {
712
686
@ POST
713
687
@ Produces (MediaType .APPLICATION_JSON )
714
688
@ Path ("categories" )
715
- public Response postCategory (@ FormParam ("category_id" ) final Long id ,
716
- @ FormParam ("series_extid" ) final String seriesExtId ,
689
+ public Response postCategory (@ FormParam ("series_extid" ) final String seriesExtId ,
717
690
@ FormParam ("series_category_id" ) final Long seriesCategoryId , @ FormParam ("name" ) final String name ,
718
691
@ FormParam ("description" ) final String description , @ FormParam ("scale_id" ) final Long scaleId ,
719
692
@ FormParam ("settings" ) final String settings , @ FormParam ("access" ) final Integer access ) {
720
- if (id == null ) {
721
- return run (array (name ), new Function0 <>() {
722
- @ Override
723
- public Response apply () {
724
- if (eas .getVideo (videoId ).isNone ()) {
725
- return BAD_REQUEST ;
726
- }
727
-
728
- Resource resource = eas .createResource (option (access ), none ());
729
- final Category category = eas .createCategory (trimToNone (seriesExtId ), option (seriesCategoryId ), videoId ,
730
- option (scaleId ), name , trimToNone (description ), trimToNone (settings ), resource );
731
-
732
- return Response .created (categoryLocationUri (category )).entity (CategoryDto .toJson .apply (eas , category ).toString ()).build ();
733
- }
734
- });
735
- }
736
- return run (array (id ), new Function0 <>() {
693
+ return run (array (name ), new Function0 <>() {
737
694
@ Override
738
695
public Response apply () {
739
- if (videoOpt .isNone ()) {
696
+ if (eas . getVideo ( videoId ) .isNone ()) {
740
697
return BAD_REQUEST ;
741
698
}
742
699
743
- Resource resource = eas .createResource ();
744
- Option <Category > categoryFromTemplate = eas .createCategoryFromTemplate (id , seriesExtId , seriesCategoryId ,
745
- videoId , resource );
746
- return categoryFromTemplate .fold (new Option .Match <>() {
747
-
748
- @ Override
749
- public Response some (Category c ) {
750
- return Response .created (categoryLocationUri (c )).entity (CategoryDto .toJson .apply (eas , c ).toString ()).build ();
751
- }
752
-
753
- @ Override
754
- public Response none () {
755
- return BAD_REQUEST ;
756
- }
700
+ Resource resource = eas .createResource (option (access ), none ());
701
+ final Category category = eas .createCategory (trimToNone (seriesExtId ), option (seriesCategoryId ), videoId ,
702
+ option (scaleId ), name , trimToNone (description ), trimToNone (settings ), resource );
757
703
758
- } );
704
+ return Response . created ( categoryLocationUri ( category )). entity ( CategoryDto . toJson . apply ( eas , category ). toString ()). build ( );
759
705
}
760
706
});
761
707
}
@@ -820,13 +766,7 @@ name, trimToNone(description), trimToNone(settings),
820
766
821
767
@ Override
822
768
public Response none () {
823
- Resource resource = eas .createResource ();
824
- final Category category = eas .createCategory (seriesExtIdOpt , seriesCategoryIdOpt , videoId , option (scaleId ), name ,
825
- trimToNone (description ), trimToNone (settings ),
826
- new ResourceImpl (option (access ), resource .getCreatedBy (), resource .getUpdatedBy (), resource .getDeletedBy (),
827
- resource .getCreatedAt (), resource .getUpdatedAt (), resource .getDeletedAt (), resource .getTags ()));
828
-
829
- return Response .created (categoryLocationUri (category )).entity (CategoryDto .toJson .apply (eas , category ).toString ()).build ();
769
+ return NOT_FOUND ;
830
770
}
831
771
});
832
772
}
@@ -961,10 +901,7 @@ public Response some(Label l) {
961
901
962
902
@ Override
963
903
public Response none () {
964
- Resource resource = eas .createResource (option (access ), Option .none ());
965
- final Label label = eas .createLabel (categoryId , value , abbreviation , trimToNone (description ), trimToNone (settings ), resource );
966
-
967
- return Response .created (labelLocationUri (label )).entity (LabelDto .toJson .apply (eas , label ).toString ()).build ();
904
+ return NOT_FOUND ;
968
905
}
969
906
});
970
907
}
@@ -1115,50 +1052,22 @@ public Response apply() {
1115
1052
@ Produces (MediaType .APPLICATION_JSON )
1116
1053
@ Path ("questionnaires" )
1117
1054
public Response postQuestionnaire (
1118
- @ FormParam ("questionnaireId" ) final Long id ,
1119
1055
@ FormParam ("title" ) final String title ,
1120
1056
@ FormParam ("content" ) @ DefaultValue ("[]" ) final String content ,
1121
1057
@ FormParam ("settings" ) final String settings ,
1122
1058
@ FormParam ("access" ) final Integer access ) {
1123
- if (id == null ) {
1124
- return run (array (title , content ), new Function0 <>() {
1125
- @ Override
1126
- public Response apply () {
1127
- if (eas .getVideo (videoId ).isNone ()) {
1128
- return BAD_REQUEST ;
1129
- }
1130
-
1131
- Resource resource = eas .createResource (option (access ), none ());
1132
- final Questionnaire questionnaire = eas .createQuestionnaire (videoId , title , content , trimToNone (settings ),
1133
- resource );
1134
-
1135
- return Response .created (questionnaireLocationUri (questionnaire )).entity (QuestionnaireDto .toJson .apply (eas , questionnaire ).toString ()).build ();
1136
- }
1137
- });
1138
- }
1139
-
1140
- return run (array (id ), new Function0 <>() {
1059
+ return run (array (title , content ), new Function0 <>() {
1141
1060
@ Override
1142
1061
public Response apply () {
1143
- if (videoOpt .isNone ()) {
1062
+ if (eas . getVideo ( videoId ) .isNone ()) {
1144
1063
return BAD_REQUEST ;
1145
1064
}
1146
1065
1147
- Resource resource = eas .createResource ();
1148
- Option <Questionnaire > questionnaireFromTemplate = eas .createQuestionnaireFromTemplate (id , videoId , resource );
1149
-
1150
- return questionnaireFromTemplate .fold (new Option .Match <>() {
1151
- @ Override
1152
- public Response some (Questionnaire q ) {
1153
- return Response .created (questionnaireLocationUri (q ))
1154
- .entity (QuestionnaireDto .toJson .apply (eas , q ).toString ()).build ();
1155
- }
1066
+ Resource resource = eas .createResource (option (access ), none ());
1067
+ final Questionnaire questionnaire = eas .createQuestionnaire (videoId , title , content , trimToNone (settings ),
1068
+ resource );
1156
1069
1157
- @ Override
1158
- public Response none () {
1159
- return BAD_REQUEST ;
1160
- }
1161
- });
1070
+ return Response .created (questionnaireLocationUri (questionnaire )).entity (QuestionnaireDto .toJson .apply (eas , questionnaire ).toString ()).build ();
1162
1071
}
1163
1072
});
1164
1073
}
@@ -1250,10 +1159,7 @@ public Response some(Comment c) {
1250
1159
1251
1160
@ Override
1252
1161
public Response none () {
1253
- Resource resource = eas .createResource ();
1254
- final Comment comment = eas .createComment (annotationId , Option .none (), text , resource );
1255
-
1256
- return Response .created (commentLocationUri (comment , videoId , trackId )).entity (CommentDto .toJson .apply (eas , comment ).toString ()).build ();
1162
+ return NOT_FOUND ;
1257
1163
}
1258
1164
});
1259
1165
}
0 commit comments