2023-11-27 16:33:24 +01:00
package eu.eudat.controllers.publicapi ;
import eu.eudat.controllers.BaseController ;
2023-11-28 11:54:08 +01:00
import eu.eudat.model.publicapi.listingmodels.DatasetPublicListingModel ;
2023-11-27 16:33:24 +01:00
import eu.eudat.controllers.publicapi.response.DataTableData ;
import eu.eudat.logic.services.ApiContext ;
import eu.eudat.models.data.helpers.responses.ResponseItem ;
2023-11-28 11:54:08 +01:00
import eu.eudat.model.publicapi.overviewmodels.DatasetPublicModel ;
2023-11-27 16:33:24 +01:00
import eu.eudat.controllers.publicapi.request.dataset.DatasetPublicTableRequest ;
import eu.eudat.types.ApiMessageCode ;
import io.swagger.v3.oas.annotations.Operation ;
import io.swagger.v3.oas.annotations.Parameter ;
import io.swagger.v3.oas.annotations.media.Content ;
import io.swagger.v3.oas.annotations.media.ExampleObject ;
import io.swagger.v3.oas.annotations.responses.ApiResponse ;
import io.swagger.v3.oas.annotations.tags.Tag ;
import jakarta.validation.Valid ;
import org.slf4j.Logger ;
import org.slf4j.LoggerFactory ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.http.HttpStatus ;
import org.springframework.http.ResponseEntity ;
import org.springframework.web.bind.annotation.* ;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE ;
@Tag ( name = " Datasets Description " , description = " Provides Dataset description public API's. " )
@RestController
@CrossOrigin
@RequestMapping ( value = { " /api/public/datasets/ " } )
public class PublicDatasetsDescriptionDocumentation extends BaseController {
private static final Logger logger = LoggerFactory . getLogger ( PublicDatasetsDescriptionDocumentation . class ) ;
@Autowired
2023-11-28 11:54:08 +01:00
public PublicDatasetsDescriptionDocumentation ( ApiContext apiContext ) {
2023-11-27 16:33:24 +01:00
super ( apiContext ) ;
}
@Operation ( summary = " This method is used to get a listing of public datasets. " , description = PublicApiStaticHelpers . Description . getPagedNotes )
@io.swagger.v3.oas.annotations.responses.ApiResponses ( value = { @io.swagger.v3.oas.annotations.responses.ApiResponse (
responseCode = " 200 " ,
description = " The following example is generated using body: *{ \" criteria \" : {}, \" length \" : 2, \" offset \" : 0, \" orderings \" : { \" fields \" : []} }* " ,
content = @Content ( mediaType = APPLICATION_JSON_VALUE , examples = { @ExampleObject (
value = PublicApiStaticHelpers . Description . getPagedResponseExample
) } )
) } )
@RequestMapping ( method = RequestMethod . POST , consumes = " application/json " , produces = " application/json " )
2023-11-28 11:54:08 +01:00
public @ResponseBody ResponseEntity < ResponseItem < DataTableData < DatasetPublicListingModel > > > getPaged (
@Valid @RequestBody @io.swagger.v3.oas.annotations.parameters.RequestBody ( description = PublicApiStaticHelpers . Description . getPagedRequestBodyDescription ) DatasetPublicTableRequest datasetTableRequest
) throws Exception {
// DataTableData<DatasetPublicListingModel> dataTable = this.datasetManager.getPublicPaged(datasetTableRequest); TODO
return ResponseEntity . status ( HttpStatus . OK ) . body ( new ResponseItem < DataTableData < DatasetPublicListingModel > > ( ) . status ( ApiMessageCode . NO_MESSAGE ) . payload ( null ) ) ;
2023-11-27 16:33:24 +01:00
}
@Operation ( summary = " This method is used to get the overview of a public dataset. " , description = PublicApiStaticHelpers . Description . getOverviewSinglePublicNotes )
@io.swagger.v3.oas.annotations.responses.ApiResponses ( value = { @ApiResponse (
responseCode = " 200 " ,
description = " The following example is generated using id: *ef7dfbdc-c5c1-46a7-a37b-c8d8692f1c0e* " ,
content = @Content ( mediaType = APPLICATION_JSON_VALUE , examples = { @ExampleObject (
value = PublicApiStaticHelpers . Description . getOverviewSinglePublicResponseExample
) } )
) } )
@RequestMapping ( method = RequestMethod . GET , value = { " /{id} " } , produces = " application/json " )
2023-11-28 11:54:08 +01:00
public @ResponseBody ResponseEntity < ResponseItem < DatasetPublicModel > > getOverviewSinglePublic (
@PathVariable @Parameter ( description = " fetch the dataset with the given id " , example = " xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx " ) String id
) {
// DatasetPublicModel dataset = this.datasetManager.getOverviewSinglePublic(id); TODO
return ResponseEntity . status ( HttpStatus . OK ) . body ( new ResponseItem < DatasetPublicModel > ( ) . status ( ApiMessageCode . NO_MESSAGE ) . payload ( null ) ) ;
2023-11-27 16:33:24 +01:00
}
}