a UCg@s&dZddlZddlZGdddZdS)zN Functionality for reconstructing data structure - reconstruct_data_structure Nc@sbeZdZdZddZddZddZdd Zd d Zd d Z dddZ ddZ ddZ ddZ dS)PaginationFormatterz0 fe -> filter editor object is required cCs||_dS)N) cache_loader"_PaginationFormatter__filter_cache)selffer\/home/cmiss/Jenkins/workspace/12-Labours-API/app/function/pagination/pagination_formatter.py__init__szPaginationFormatter.__init__cCs4g}|gkr|S|D]}|ddur||q|S)z0 Handler for updating thumbnail additional_typesNappend)rdataresult_rrr_handle_thumbnails  z%PaginationFormatter._handle_thumbnailcCsd}gdgid}ttdd|}|D]T}|d}|dd|d<d|}|d||dd|ddq*|S) z9 Handler for updating multiple cite path pathrrelative'"/r)jsonloadsresubsplitjoinr )rfilenamecite full_pathrr rfull_path_listrrr_handle_multiple_cite_paths  z.PaginationFormatter._handle_multiple_cite_pathcCs||}d}gdgid}|dkrlt|ddkrF|||}|S|d}|dd|d<d|}|d||dd|dd|S) z0 Handler for updating cite path rrr,rrr) _handle_emptylenrr#rr )rrr Z cite_pathr!rr"rrr_handle_cite_path-s    z%PaginationFormatter._handle_cite_pathcCs|dus|dkrdS|S)z2 Handler for updating empty value NNArr)rr rrrr&?sz!PaginationFormatter._handle_emptycCsR|}|rJ|dkr@|d}|dd|d<d|}||7}qN||7}ndS|S)z4 Handler for updating the image url rrr)rr)r preview_linkr is_source_of has_imager path_listfilepathrrr_handle_image_linkGs    z&PaginationFormatter._handle_image_linkFc Csg}|D]}|d}|||||d|d||di|||d|||d|||dd||did ||d d||d i|d |d dd}||q|S)zc Handler for updating the data format which be queried based on manifest structure rr+namer Zis_derived_fromZis_described_by descriptionsupplemental_json_metadata)Z isDerivedFromZ isDescribedByZ isSourceOfr2) identifierr file_typeidrr)Z image_urlZadditional_mimetypeZdatacitedatasetr4r3r0)r/r&r(rr ) ruuidr*r r,rrritemrrr_handle_manifestXsB  " z$PaginationFormatter._handle_manifestcCsg}|gkr|S|D]p}|ddkr|jdd}|}|d|vrjt||d}t||}n|d}||vr||q|S)z9 Handler for updating the species format speciesr)ZMAPPED_SPECIESfacets)rvalueslistindexkeysr )rr rrZspecies_filterr;r>r:rrr_handle_speciess   z#PaginationFormatter._handle_speciescCs0g}|gkr|S|D]}d|i}||q|S)z= Handler for updating the contributor format r0r )rr rrZ contributorrrr_handle_contributors z'PaginationFormatter._handle_contributorc Csg}|D]}|dd}|d}|d}d|d}d|dd |d||d |d t|d dt|d d|dd||d||d||||d||||dd||||d|||||dd||||d||||ddd}||q|S)zI Reconstructing the structure to support portal services dataset_descriptionsr submitter_idr5z/data/preview/rz/data/browser/dataset/z?datasetTab=abstractz/data/download/Zcontributor_namekeywordsZnumber_of_samplesZnumber_of_subjectstitlestudy_organ_systemcasesplots scaffoldViewsT scaffolds thumbnailsmris dicomImages)Zdata_url_suffixZsource_url_middle contributorsrD numberSamplesnumberSubjectsr0 datasetIdorgansr:rHrIrJrKrLrM detailsReady)rAintr@r9rr ) rr rrZdataset_descriptionrCr7r*Zdataset_formatrrrreconstruct_data_structuresJ           z.PaginationFormatter.reconstruct_data_structureN)F)__name__ __module__ __qualname____doc__r rr#r(r&r/r9r@rArUrrrrr s  , r)rYrrrrrrrs