-1}).length>0,b.deleteRequest=function(c){b.requestToDelete=c.id,a.$broadcast(g.showConfirmDialog,{titleKey:"data-access-request.delete-dialog.title",messageKey:"data-access-request.delete-dialog.message",messageArgs:[c.title,c.applicant]},c.id)},b.userProfile=function(a){b.applicant=a,c.open({scope:b,templateUrl:"access/views/data-access-request-profile-user-modal.html"})};var p=function(a,b){var c=a.filter(function(a){return a.key===b});return c&&c.length>0?c[0].value:null};b.getFullName=function(a){return a?a.attributes?p(a.attributes,"firstName")+" "+p(a.attributes,"lastName"):a.username:null},b.getProfileEmail=function(a){return a&&a.attributes?p(a.attributes,"email"):null},b.getCsvExportHref=function(){return l.getUrl("DataAccessRequestsExportCsvResource").replace(":lang",m.use())},b.$on(g.confirmDialogAccepted,function(a,c){b.requestToDelete===c&&(e["delete"]({id:b.requestToDelete},function(){b.loading=!0,d.query({},n,o)}),delete b.requestToDelete)})}]).controller("DataAccessRequestViewController",["$rootScope","$scope","$location","$uibModal","$routeParams","$filter","$translate","DataAccessRequestResource","DataAccessRequestService","DataAccessRequestStatusResource","DataAccessFormConfigResource","JsonUtils","DataAccessRequestAttachmentsUpdateResource","DataAccessRequestCommentsResource","DataAccessRequestCommentResource","ngObibaMicaUrl","ngObibaMicaAccessTemplateUrl","AlertService","ServerErrorUtils","NOTIFICATION_EVENTS","DataAccessRequestConfig","LocalizedSchemaFormService","SfOptionsService",function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w){function x(){var a=b.dataAccessRequest.statusChangeHistory||[];return a.filter(function(a){return a.to===i.status.SUBMITTED}).pop()}var y=function(a){r.alert({id:"DataAccessRequestViewController",type:"danger",msg:s.buildMessage(a)})};b.sfOptions=w.sfOptions;var z=function(){b.form.comments=n.query({id:e.id})},A=function(a){switch(b.selectedTab=a,a){case"form":break;case"comments":z()}},B=function(a){n.save({id:e.id},a.message,z,y)},C=function(a){o.update({id:e.id,commentId:a.id},a.message,z,y)},D=function(c){b.commentToDelete=c.id,a.$broadcast(t.showConfirmDialog,{titleKey:"comment.delete-dialog.title",messageKey:"comment.delete-dialog.message",messageArgs:[c.createdBy]},c.id)},E=function(a){a&&(b.attachments=angular.copy(b.dataAccessRequest.attachments)||[]),b.showAttachmentsForm=a},F=function(){var a=angular.copy(b.dataAccessRequest);a.attachments=b.attachments,m.save(a,function(){E(!1),b.dataAccessRequest=G()})};b.form={schema:null,definition:null,model:{},comments:null},b.$on(t.confirmDialogAccepted,function(a,c){b.commentToDelete===c&&o["delete"]({id:e.id,commentId:c},{},z,y)}),b.getDownloadHref=function(a){return p.getUrl("DataAccessRequestAttachmentDownloadResource").replace(":id",b.dataAccessRequest.id).replace(":attachmentId",a.id)},b.config=u.getOptions(),b.actions=i.actions,b.nextStatus=i.nextStatus,b.selectTab=A,b.submitComment=B,b.updateComment=C,b.deleteComment=D,b.showAttachmentsForm=!1,b.updateAttachments=F,b.cancelAttachments=function(){E(!1)},b.editAttachments=function(){E(!0)},b.headerTemplateUrl=q.getHeaderUrl("view"),b.footerTemplateUrl=q.getFooterUrl("view"),b.getStatusHistoryInfoId=i.getStatusHistoryInfoId,i.getStatusHistoryInfo(function(a){b.getStatusHistoryInfo=a}),b.validForm=!0;var G=function(){return h.get({id:e.id},function(a){try{b.form.model=a.content?JSON.parse(a.content):{},b.requestDownloadUrl=p.getUrl("DataAccessRequestDownloadPdfResource").replace(":id",b.dataAccessRequest.id)+"?lang="+g.use(),b.attachments=angular.copy(a.attachments)||[]}catch(c){b.validForm=!1,b.form.model={},r.alert({id:"DataAccessRequestViewController",type:"danger",msgKey:"data-access-request.parse-error"})}return k.get(function(a){b.form.definition=v.translate(l.parseJsonSafely(a.definition,[])),b.form.schema=v.translate(l.parseJsonSafely(a.schema,{})),b.form.downloadTemplate="Template"===a.pdfDownloadType,0===b.form.definition.length&&(b.validForm=!1,b.form.definition=[],r.alert({id:"DataAccessRequestViewController",type:"danger",msgKey:"data-access-config.parse-error.definition"})),0===Object.getOwnPropertyNames(b.form.schema).length&&(b.validForm=!1,b.form.schema={readonly:!0},r.alert({id:"DataAccessRequestViewController",type:"danger",msgKey:"data-access-config.parse-error.schema"})),b.form.schema.readonly=!0,b.$broadcast("schemaFormRedraw")},y),a.attachments=a.attachments||[],b.lastSubmittedDate=x(),a})};b.dataAccessRequest=e.id?G():{},b["delete"]=function(){b.requestToDelete=b.dataAccessRequest.id,a.$broadcast(t.showConfirmDialog,{titleKey:"data-access-request.delete-dialog.title",messageKey:"data-access-request.delete-dialog.message",messageArgs:[b.dataAccessRequest.title,b.dataAccessRequest.applicant]},b.requestToDelete)},b.$on(t.confirmDialogAccepted,function(a,d){b.requestToDelete===d&&(h["delete"]({id:b.requestToDelete},function(){c.path("/data-access-requests").replace()}),delete b.requestToDelete)});var H=function(){b.dataAccessRequest=G()},I=function(b,c,d){a.$broadcast(t.showConfirmDialog,{titleKey:"data-access-request.status-change-confirmation.title",messageKey:null!==c?c:"data-access-request.status-change-confirmation.message",messageArgs:null!==d?[f("translate")(d).toLowerCase()]:[]},b)},J=function(a,c){a===c&&j.update({id:b.dataAccessRequest.id,status:a},H,y)},K=function(){setTimeout(function(){window.print()},250)};b.submit=function(){b.$broadcast("schemaFormValidate"),b.forms.requestForm.$valid?j.update({id:b.dataAccessRequest.id,status:i.status.SUBMITTED},function(){H(),d.open({scope:b,templateUrl:"access/views/data-access-request-submitted-modal.html"})},y):r.alert({id:"DataAccessRequestViewController",type:"danger",msgKey:"data-access-request.submit.invalid"})},b.reopen=function(){I(i.status.OPENED,null,"reopen")},b.review=function(){I(i.status.REVIEWED,"data-access-request.status-change-confirmation.message-review",null)},b.approve=function(){I(i.status.APPROVED,null,"approve")},b.reject=function(){I(i.status.REJECTED,null,"reject")},b.conditionallyApprove=function(){I(i.status.CONDITIONALLY_APPROVED,null,"conditionallyApprove")},b.userProfile=function(a){b.applicant=a,d.open({scope:b,templateUrl:"access/views/data-access-request-profile-user-modal.html"})};var L=function(a,b){var c=a.filter(function(a){return a.key===b});return c&&c.length>0?c[0].value:null};b.printForm=K,b.getFullName=function(a){return a?a.attributes?L(a.attributes,"firstName")+" "+L(a.attributes,"lastName"):a.username:null},b.getProfileEmail=function(a){return a&&a.attributes?L(a.attributes,"email"):null},b.$on(t.confirmDialogAccepted,function(a,b){J(i.status.OPENED,b)}),b.$on(t.confirmDialogAccepted,function(a,b){J(i.status.REVIEWED,b)}),b.$on(t.confirmDialogAccepted,function(a,b){J(i.status.CONDITIONALLY_APPROVED,b)}),b.$on(t.confirmDialogAccepted,function(a,b){J(i.status.APPROVED,b)}),b.$on(t.confirmDialogAccepted,function(a,b){J(i.status.REJECTED,b)}),b.forms={}}]).controller("DataAccessRequestEditController",["$log","$scope","$routeParams","$location","$uibModal","LocalizedSchemaFormService","DataAccessRequestsResource","DataAccessRequestResource","DataAccessFormConfigResource","JsonUtils","AlertService","ServerErrorUtils","SessionProxy","DataAccessRequestService","ngObibaMicaAccessTemplateUrl","DataAccessRequestConfig","SfOptionsService",function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q){var r=function(a,b){var c=b().location.split("/");d.path("/data-access-request/"+c[c.length-1]).replace()},s=function(a){k.alert({id:"DataAccessRequestEditController",type:"danger",msg:l.buildMessage(a)})};b.sfOptions=q.sfOptions;var t=function(){b.$broadcast("schemaFormValidate"),e.open({scope:b,templateUrl:"access/views/data-access-request-validation-modal.html"})},u=function(){d.path("/data-access-request"+(c.id?"/"+c.id:"s")).replace()},v=function(){b.dataAccessRequest.content=JSON.stringify(b.form.model),b.newRequest?g.save(b.dataAccessRequest,r,s):h.save(b.dataAccessRequest,function(){d.path("/data-access-request"+(b.dataAccessRequest.id?"/"+b.dataAccessRequest.id:"s")).replace()},s)};i.get(function(a){b.form.definition=f.translate(j.parseJsonSafely(a.definition,[])),b.form.schema=f.translate(j.parseJsonSafely(a.schema,{})),0===b.form.definition.length&&(b.form.definition=[],b.validForm=!1,k.alert({id:"DataAccessRequestEditController",type:"danger",msgKey:"data-access-config.parse-error.definition"})),0===Object.getOwnPropertyNames(b.form.schema).length&&(b.form.schema={},b.validForm=!1,k.alert({id:"DataAccessRequestEditController",type:"danger",msgKey:"data-access-config.parse-error.schema"})),b.validForm&&(b.dataAccessRequest=c.id?h.get({id:c.id},function(a){try{b.form.model=a.content?JSON.parse(a.content):{}}catch(c){b.form.model={},k.alert({id:"DataAccessRequestEditController",type:"danger",msgKey:"data-access-request.parse-error"})}return b.canEdit=n.actions.canEdit(a),b.form.schema.readonly=!b.canEdit,b.$broadcast("schemaFormRedraw"),a.attachments=a.attachments||[],a}):{applicant:m.login(),status:n.status.OPENED,attachments:[]}),b.loaded=!0},s),b.loaded=!1,b.config=p.getOptions(),b.validForm=!0,b.requestId=c.id,b.newRequest=!c.id,b.cancel=u,b.save=v,b.editable=!0,b.validate=t,b.headerTemplateUrl=o.getHeaderUrl("form"),b.footerTemplateUrl=o.getFooterUrl("form"),b.form={schema:null,definition:null,model:{}}}]),angular.module("obiba.mica.access").config(["$routeProvider",function(a){a.when("/data-access-requests",{templateUrl:"access/views/data-access-request-list.html",controller:"DataAccessRequestListController"}).when("/data-access-request/new",{templateUrl:"access/views/data-access-request-form.html",controller:"DataAccessRequestEditController"}).when("/data-access-request/:id/edit",{templateUrl:"access/views/data-access-request-form.html",controller:"DataAccessRequestEditController"}).when("/data-access-request/:id",{templateUrl:"access/views/data-access-request-view.html",controller:"DataAccessRequestViewController"})}]),angular.module("obiba.mica.access").factory("DataAccessFormConfigResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("DataAccessFormConfigResource"),{},{get:{method:"GET",errorHandler:!0}})}]).factory("DataAccessRequestsResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("DataAccessRequestsResource"),{},{save:{method:"POST",errorHandler:!0},get:{method:"GET"}})}]).factory("DataAccessRequestsExportCsvResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("DataAccessRequestsExportCsvResource"),{},{get:{method:"GET"}})}]).factory("DataAccessRequestResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("DataAccessRequestResource"),{},{save:{method:"PUT",params:{id:"@id"},errorHandler:!0},get:{method:"GET"},"delete":{method:"DELETE"}})}]).factory("DataAccessRequestAttachmentsUpdateResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("DataAccessRequestAttachmentsUpdateResource"),{},{save:{method:"PUT",params:{id:"@id"},errorHandler:!0}})}]).factory("DataAccessRequestCommentsResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("DataAccessRequestCommentsResource"),{},{save:{method:"POST",params:{id:"@id"},headers:{"Content-Type":"text/plain"},errorHandler:!0},get:{method:"GET",params:{id:"@id"},errorHandler:!0}})}]).factory("DataAccessRequestCommentResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("DataAccessRequestCommentResource"),{},{"delete":{method:"DELETE",params:{id:"@id",commentId:"@commentId"},errorHandler:!0},update:{method:"PUT",params:{id:"@id",commentId:"@commentId"},headers:{"Content-Type":"text/plain"},errorHandler:!0}})}]).factory("DataAccessRequestStatusResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("DataAccessRequestStatusResource"),{},{update:{method:"PUT",params:{id:"@id",status:"@status"},errorHandler:!0}})}]).service("DataAccessRequestConfig",function(){var a={newRequestButtonCaption:null,documentsSectionTitle:null,documentsSectionHelpText:null,downloadButtonCaption:null,commentsEnabled:!0,userListPageTitle:null,newRequestButtonHelpText:null};this.setOptions=function(b){"object"==typeof b&&Object.keys(b).forEach(function(c){c in a&&(a[c]=b[c])})},this.getOptions=function(){return angular.copy(a)}}).service("DataAccessRequestService",["$translate","SessionProxy","USER_ROLES",function(a,b,c){var d={OPENED:"OPENED",SUBMITTED:"SUBMITTED",REVIEWED:"REVIEWED",CONDITIONALLY_APPROVED:"CONDITIONALLY_APPROVED",APPROVED:"APPROVED",REJECTED:"REJECTED"};this.status=d,this.getStatusFilterData=function(b){b&&a(Object.keys(d)).then(function(a){b(Object.keys(a).map(function(b){return a[b]}))})};var e=function(a,b){return a.actions?-1!==a.actions.indexOf(b):null};this.actions={canViewProfile:function(a){var d=!1,e=b.roles();return angular.forEach(e,function(b){b!==a&&b!==c.admin||(d=!0)}),d},canView:function(a){return e(a,"VIEW")},canEdit:function(a){return e(a,"EDIT")},canEditStatus:function(a){return e(a,"EDIT_STATUS")},canDelete:function(a){return e(a,"DELETE")},canEditAttachments:function(a){return e(a,"EDIT_ATTACHMENTS")}};var f=function(a,b){return a.nextStatus?-1!==a.nextStatus.indexOf(b):null};return this.nextStatus={canSubmit:function(a){return f(a,"SUBMITTED")},canReopen:function(a){return f(a,"OPENED")},canReview:function(a){return f(a,"REVIEWED")},canConditionallyApprove:function(a){return f(a,"CONDITIONALLY_APPROVED")},canApprove:function(a){return f(a,"APPROVED")},canReject:function(a){return f(a,"REJECTED")}},this.getStatusHistoryInfo=function(b){if(b){var c={"data-access-request.histories.opened":"opened","data-access-request.histories.reopened":"reopened","data-access-request.histories.submitted":"submitted","data-access-request.histories.reviewed":"reviewed","data-access-request.histories.conditionallyApproved":"conditionallyApproved","data-access-request.histories.approved":"approved","data-access-request.histories.rejected":"rejected"},d={opened:{id:"opened",icon:"glyphicon glyphicon-saved"},reopened:{id:"reopened",icon:"glyphicon glyphicon-repeat"},submitted:{id:"submitted",icon:"glyphicon glyphicon-export"},reviewed:{id:"reviewed",icon:"glyphicon glyphicon-check"},conditionallyApproved:{id:"conditionallyApproved",icon:"glyphicon glyphicon-unchecked"},approved:{id:"approved",icon:"glyphicon glyphicon-ok"},rejected:{id:"rejected",icon:"glyphicon glyphicon-remove"}};a(Object.keys(c)).then(function(a){Object.keys(a).forEach(function(b){d[c[b]].msg=a[b]}),b(d)})}},this.getStatusHistoryInfoId=function(a){var b="opened";if("OPENED"!==a.from||a.from!==a.to)switch(a.to){case"OPENED":b="reopened";break;case"SUBMITTED":b="submitted";break;case"REVIEWED":b="reviewed";break;case"CONDITIONALLY_APPROVED":b="conditionallyApproved";break;case"APPROVED":b="approved";break;case"REJECTED":b="rejected"}return b},this}]).filter("filterProfileAttributes",function(){return function(a){var b=["email","firstName","lastName","createdDate","lastLogin","username"];return a.filter(function(a){return-1===b.indexOf(a.key)})}}).filter("capitalizeFirstLetter",["StringUtils",function(a){return function(b){return a.capitaliseFirstLetter(b)}}]),angular.module("obiba.mica.access").directive("printFriendlyView",[function(){return{restrict:"EA",replace:!0,scope:!1,templateUrl:"access/views/data-access-request-print-preview.html"}}]);var DISPLAY_TYPES={LIST:"list",COVERAGE:"coverage",GRAPHICS:"graphics"};angular.module("obiba.mica.search",["obiba.alert","ui.bootstrap","pascalprecht.translate","templates-ngObibaMica"]).config(["$provide",function(a){
-a.provider("ngObibaMicaSearchTemplateUrl",(new NgObibaMicaTemplateUrlFactory).create({search:{header:null,footer:null},classifications:{header:null,footer:null}}))}]).config(["$provide","$injector",function(a){a.provider("ngObibaMicaSearch",function(){var a=["LocalizedValues",function(a){return a.getLocal()}],b={targetTabsOrder:[QUERY_TARGETS.VARIABLE,QUERY_TARGETS.DATASET,QUERY_TARGETS.STUDY,QUERY_TARGETS.NETWORK],searchTabsOrder:[DISPLAY_TYPES.LIST,DISPLAY_TYPES.COVERAGE,DISPLAY_TYPES.GRAPHICS],resultTabsOrder:[QUERY_TARGETS.VARIABLE,QUERY_TARGETS.DATASET,QUERY_TARGETS.STUDY,QUERY_TARGETS.NETWORK],showAllFacetedTaxonomies:!0,showSearchBox:!0,showSearchBrowser:!0,variableTaxonomiesOrder:[],studyTaxonomiesOrder:[],datasetTaxonomiesOrder:[],networkTaxonomiesOrder:[],hideNavigate:[],hideSearch:["studyIds","dceIds","datasetId","networkId","studyId"],variables:{showSearchTab:!0,variablesColumn:{showVariablesTypeColumn:!0,showVariablesStudiesColumn:!0,showVariablesDatasetsColumn:!0,showDatasetsStudiesColumn:!0,showDatasetsVariablesColumn:!0}},datasets:{showSearchTab:!0,showDatasetsSearchFilter:!0,datasetsColumn:{showDatasetsAcronymColumn:!0,showDatasetsTypeColumn:!0,showDatasetsNetworkColumn:!0,showDatasetsStudiesColumn:!0,showDatasetsVariablesColumn:!0}},studies:{showSearchTab:!0,showStudiesSearchFilter:!0,studiesColumn:{showStudiesDesignColumn:!0,showStudiesQuestionnaireColumn:!0,showStudiesPmColumn:!0,showStudiesBioColumn:!0,showStudiesOtherColumn:!0,showStudiesParticipantsColumn:!0,showStudiesNetworksColumn:!0,showStudiesStudyDatasetsColumn:!0,showStudiesHarmonizationDatasetsColumn:!0,showStudiesVariablesColumn:!1,showStudiesStudyVariablesColumn:!0,showStudiesDataschemaVariablesColumn:!0}},networks:{showSearchTab:!0,networksColumn:{showNetworksStudiesColumn:!0,showNetworksStudyDatasetColumn:!0,showNetworksHarmonizationDatasetColumn:!0,showNetworksVariablesColumn:!1,showNetworksStudyVariablesColumn:!0,showNetworksDataschemaVariablesColumn:!0}},coverage:{groupBy:{study:!0,dce:!0,dataset:!0,dataschema:!0,network:!0}}};this.setLocaleResolver=function(b){a=b},this.setOptions=function(a){b=angular.merge(b,a),b.targetTabsOrder=a.targetTabsOrder||b.targetTabsOrder,b.searchTabsOrder=a.searchTabsOrder||b.searchTabsOrder,b.resultTabsOrder=a.resultTabsOrder||b.resultTabsOrder,b.variableTaxonomiesOrder=a.variableTaxonomiesOrder||b.variableTaxonomiesOrder,b.studyTaxonomiesOrder=a.studyTaxonomiesOrder||b.studyTaxonomiesOrder,b.datasetTaxonomiesOrder=a.datasetTaxonomiesOrder||b.datasetTaxonomiesOrder,b.networkTaxonomiesOrder=a.networkTaxonomiesOrder||b.networkTaxonomiesOrder,b.hideNavigate=a.hideNavigate||b.hideNavigate,b.hideSearch=a.hideSearch||b.hideSearch},this.$get=["$q","$injector",function(c,d){function e(){var a=Object.keys(b.coverage.groupBy).filter(function(a){return b.coverage.groupBy[a]}).length>0;if(!a){var c=b.searchTabsOrder.indexOf(DISPLAY_TYPES.COVERAGE);c>-1&&b.searchTabsOrder.splice(c,1)}}return e(),{getLocale:function(b,e){return c.when(d.invoke(a),b,e)},getOptions:function(){return b},toggleHideSearchNavigate:function(a){var c=b.hideNavigate.indexOf(a.name);c>-1?b.hideNavigate.splice(c,1):b.hideNavigate.push(a.name)}}}]})}]).run(["GraphicChartsConfigurations",function(a){a.setClientConfig()}]),angular.module("obiba.mica.search").filter("regex",function(){return function(a,b,c,d){var e=[];try{var f=new RegExp(b,"i");e=a.filter(function(a){return c.some(function(b){var c=a[b];return angular.isArray(c)&&d?c.filter(function(a){return a.locale===d}).some(function(a){return f.test(a.text)}):f.test(c)})})}catch(g){}return e}}).filter("orderBySelection",function(){return function(a,b){if(!a)return[];var c=[],d=[];return a.forEach(function(a){b[a.key]?c.push(a):d.push(a)}),c.concat(d)}}).filter("dceDescription",function(){return function(a){return a.split(":").map(function(a){return"
"+a})[2]}});var QUERY_TYPES={NETWORKS:"networks",STUDIES:"studies",DATASETS:"datasets",VARIABLES:"variables"},QUERY_TARGETS={NETWORK:"network",STUDY:"study",DATASET:"dataset",VARIABLE:"variable"},BUCKET_TYPES={NETWORK:"network",STUDY:"study",DCE:"dce",DATASCHEMA:"dataschema",DATASET:"dataset"},RQL_NODE={VARIABLE:"variable",DATASET:"dataset",STUDY:"study",NETWORK:"network",LIMIT:"limit",SORT:"sort",AND:"and",NAND:"nand",OR:"or",NOR:"nor",NOT:"not",FACET:"facet",LOCALE:"locale",AGGREGATE:"aggregate",BUCKET:"bucket",CONTAINS:"contains",IN:"in",OUT:"out",EQ:"eq",GT:"gt",GE:"ge",LT:"lt",LE:"le",BETWEEN:"between",MATCH:"match",EXISTS:"exists",MISSING:"missing"},SORT_FIELDS={ACRONYM:"acronym",NAME:"name"},VOCABULARY_TYPES={STRING:"string",INTEGER:"integer",DECIMAL:"decimal"},CriteriaIdGenerator={generate:function(a,b,c){return a&&b?a.name+"."+b.name+(c?"."+c.name:""):void 0}};CriteriaItem.prototype.isRepeatable=function(){return!1},CriteriaItem.prototype.getTarget=function(){return this.target||null},RepeatableCriteriaItem.prototype=Object.create(CriteriaItem.prototype),RepeatableCriteriaItem.prototype.isRepeatable=function(){return!0},RepeatableCriteriaItem.prototype.addItem=function(a){return this.list.push(a),this},RepeatableCriteriaItem.prototype.items=function(){return this.list},RepeatableCriteriaItem.prototype.first=function(){return this.list[0]},RepeatableCriteriaItem.prototype.getTarget=function(){return this.list.length>0?this.list[0].getTarget():null},CriteriaBuilder.prototype.fieldToVocabulary=function(a){var b={taxonomy:null,vocabulary:null},c=a;a.indexOf(".")<0&&(c="Mica_"+this.target+"."+a);var d=c.split(".",2),e=d[0],f=d[1],g=this.taxonomies.filter(function(a){return e===a.name});if(0===g.length)throw new Error("Could not find taxonomy:",e);b.taxonomy=g[0];var h=b.taxonomy.vocabularies.filter(function(a){return f===a.name});if(0===h.length)throw new Error("Could not find vocabulary:",f);return b.vocabulary=h[0],b},CriteriaBuilder.prototype.visitLeaf=function(a,b){var c=RQL_NODE.MATCH===a.name,d=a.args[c?1:0],e=a.args[c?0:1],f=this.fieldToVocabulary(d),g=this.buildLeafItem(f.taxonomy,f.vocabulary,e instanceof Array?e:[e],a,b),h=this.leafItemMap[g.id];h?h.isRepeatable()?h.addItem(g):(console.error("Non-repeatable criteria items must be unique,",h.id,"will be overwritten."),h=g):h=g.vocabulary.repeatable?(new RepeatableCriteriaItem).addItem(g):g,this.leafItemMap[g.id]=h,b.children.push(g)},CriteriaBuilder.prototype.getRootItem=function(){return this.rootItem},CriteriaBuilder.prototype.getLeafItemMap=function(){return this.leafItemMap},CriteriaBuilder.prototype.visitCondition=function(a,b){var c=this.newCriteriaItemBuilder().parent(b).rqlQuery(a).type(a.name).build();b.children.push(c),this.visit(a.args[0],c),this.visit(a.args[1],c)},CriteriaBuilder.prototype.visitNot=function(a,b){var c=this.newCriteriaItemBuilder().parent(b).rqlQuery(a).type(a.name).build();b.children.push(c),this.visit(a.args[0],c)},CriteriaBuilder.prototype.visit=function(a,b){switch(a.name){case RQL_NODE.NOT:this.visitNot(a,b);break;case RQL_NODE.AND:case RQL_NODE.NAND:case RQL_NODE.OR:case RQL_NODE.NOR:this.visitCondition(a,b);break;case RQL_NODE.CONTAINS:case RQL_NODE.IN:case RQL_NODE.OUT:case RQL_NODE.EQ:case RQL_NODE.LE:case RQL_NODE.LT:case RQL_NODE.GE:case RQL_NODE.GT:case RQL_NODE.BETWEEN:case RQL_NODE.EXISTS:case RQL_NODE.MISSING:case RQL_NODE.MATCH:this.visitLeaf(a,b)}},CriteriaBuilder.prototype.build=function(){var a=this;this.rootRql.args.forEach(function(b){a.visit(b,a.rootItem)})},angular.module("obiba.mica.search").service("RqlQueryUtils",[function(){function a(a){var b=a.args.filter(function(a){switch(a.name){case RQL_NODE.AND:case RQL_NODE.NAND:case RQL_NODE.OR:case RQL_NODE.NOR:case RQL_NODE.NOT:case RQL_NODE.CONTAINS:case RQL_NODE.IN:case RQL_NODE.OUT:case RQL_NODE.EQ:case RQL_NODE.GT:case RQL_NODE.GE:case RQL_NODE.LT:case RQL_NODE.LE:case RQL_NODE.BETWEEN:case RQL_NODE.MATCH:case RQL_NODE.EXISTS:case RQL_NODE.MISSING:return!0}return!1}).pop();return b?a.args.findIndex(function(a){return a.name===b.name}):-1}function b(a,b,c){var d=c;return a.attributes&&a.attributes.some(function(a){return a.key===b?(d=a.value,!0):!1}),d}var c=this;this.vocabularyTermNames=function(a){return a&&a.terms?a.terms.map(function(a){return a.name}):[]},this.hasTargetQuery=function(a,b){return a.args.filter(function(a){switch(a.name){case RQL_NODE.VARIABLE:case RQL_NODE.DATASET:case RQL_NODE.STUDY:case RQL_NODE.NETWORK:return b?b===a.name:!0;default:return!1}}).length>0},this.variableQuery=function(){return new RqlQuery(QUERY_TARGETS.VARIABLE)},this.eqQuery=function(a,b){var c=new RqlQuery(RQL_NODE.EQ);return c.args.push(b),c},this.orQuery=function(a,b){var c=new RqlQuery(RQL_NODE.OR);return c.args=[a,b],c},this.aggregate=function(a){var b=new RqlQuery(RQL_NODE.AGGREGATE);return a.forEach(function(a){b.args.push(a)}),b},this.limit=function(a,b){var c=new RqlQuery(RQL_NODE.LIMIT);return c.args.push(a),c.args.push(b),c},this.fieldQuery=function(a,b,c){var d=new RqlQuery(a);return d.args.push(b),c&&c.length>0&&d.args.push(c),d},this.inQuery=function(a,b){var c=b&&b.length>0,d=c?RQL_NODE.IN:RQL_NODE.EXISTS;return this.fieldQuery(d,a,b)},this.matchQuery=function(a,b){var c=new RqlQuery(RQL_NODE.MATCH);return c.args.push(b||"*"),c.args.push(a),c},this.updateMatchQuery=function(a,b){return a.args[0]=b||"*",a},this.rangeQuery=function(a,b,d){var e=new RqlQuery(RQL_NODE.BETWEEN);return e.args.push(a),c.updateRangeQuery(e,b,d),e},this.updateQueryInternal=function(a,b){var c=b&&b.length>0;return c?a.args[1]=b:a.args.splice(1,1),a},this.mergeInQueryArgValues=function(a,b,c){var d=b&&b.length>0;if(d){var e=a.args[1];if(!e||c)a.args[1]=b;else{e instanceof Array||(e=[e]);var f=b.filter(function(a){return-1===e.indexOf(a)});a.args[1]=e.concat(f)}}else a.args.splice(1,1);return a},this.updateRangeQuery=function(a,b,c,d){d?(a.name=RQL_NODE.MISSING,a.args.splice(1,1)):angular.isDefined(b)&&null!==b&&angular.isDefined(c)&&null!==c?(a.name=RQL_NODE.BETWEEN,a.args[1]=[b,c]):angular.isDefined(b)&&null!==b?(a.name=RQL_NODE.GE,a.args[1]=b):angular.isDefined(c)&&null!==c?(a.name=RQL_NODE.LE,a.args[1]=c):(a.name=RQL_NODE.EXISTS,a.args.splice(1,1))},this.buildRqlQuery=function(a){return this.isNumericVocabulary(a.vocabulary)?this.rangeQuery(this.criteriaId(a.taxonomy,a.vocabulary),null,null):this.isMatchVocabulary(a.vocabulary)?this.matchQuery(this.criteriaId(a.taxonomy,a.vocabulary),null):this.inQuery(this.criteriaId(a.taxonomy,a.vocabulary),a.term?a.term.name:void 0)},this.addQuery=function(b,c,d){if(0===b.args.length)b.args.push(c);else{var e=a(b);if(-1===e)b.args.push(c);else{var f=b.args.splice(e,1).pop();if(!d&&c.args&&c.args.length>0){var g="Mica_"+b.name,h="match"===c.name?c.args[1]:c.args[0];d=h.startsWith(g+".")?RQL_NODE.AND:RQL_NODE.OR}var i=new RqlQuery(d||RQL_NODE.AND);i.args.push(f,c),b.args.push(i)}}return b},this.updateRepeatableQueryArgValues=function(a,b){var c=this;a.items().forEach(function(a){var d=a.rqlQuery;switch(d.name){case RQL_NODE.EXISTS:d.name=RQL_NODE.CONTAINS,c.mergeInQueryArgValues(d,b,!1);break;case RQL_NODE.CONTAINS:c.mergeInQueryArgValues(d,b,!1);break;case RQL_NODE.IN:var e=d.args[1]?[].concat(d.args[1]):[];if(1===e.length){d.name=RQL_NODE.CONTAINS,c.mergeInQueryArgValues(d,b,!1);break}var f,g=d.args[0],h=e.filter(function(a){return b.indexOf(a)<0}).map(function(a){return c.fieldQuery(RQL_NODE.CONTAINS,g,[].concat(a,b))});if(h.length>1){var i=h.splice(0,2);f=c.orQuery(i[0],i[1]),h.forEach(function(a){f=c.orQuery(a,f)}),d.name=f.name,d.args=f.args}else d.name=RQL_NODE.CONTAINS,d.args=h[0].args}})},this.updateQueryArgValues=function(a,b,c){switch(a.name){case RQL_NODE.EXISTS:case RQL_NODE.MISSING:a.name=RQL_NODE.IN,this.mergeInQueryArgValues(a,b,c);break;case RQL_NODE.CONTAINS:case RQL_NODE.IN:this.mergeInQueryArgValues(a,b,c);break;case RQL_NODE.BETWEEN:case RQL_NODE.GE:case RQL_NODE.LE:a.args[1]=b;break;case RQL_NODE.MATCH:a.args[0]=b}},this.updateQuery=function(a,b){switch(a.name){case RQL_NODE.CONTAINS:case RQL_NODE.IN:case RQL_NODE.EXISTS:case RQL_NODE.MISSING:this.updateQueryInternal(a,b)}},this.addLocaleQuery=function(a,b){var c=a.args.filter(function(a){return a.name===RQL_NODE.LOCALE}).pop();if(!c){var d=new RqlQuery("locale");d.args.push(b),a.args.push(d)}},this.addLimit=function(a,b){var c=a.args.filter(function(a){return a.name===RQL_NODE.LIMIT}).pop();c?c.args=b.args:a.args.push(b)},this.addSort=function(a,b){var c=a.args.filter(function(a){return a.name===RQL_NODE.SORT}).pop();if(!c){var d=new RqlQuery("sort");d.args.push(b),a.args.push(d)}},this.criteriaId=function(a,b){return a.name+"."+b.name},this.vocabularyType=function(a){return b(a,"type",VOCABULARY_TYPES.STRING)},this.vocabularyField=function(a){return b(a,"field",a.name)},this.vocabularyAlias=function(a){return b(a,"alias",a.name)},this.isTermsVocabulary=function(a){return c.vocabularyType(a)===VOCABULARY_TYPES.STRING&&a.terms},this.isMatchVocabulary=function(a){return c.vocabularyType(a)===VOCABULARY_TYPES.STRING&&!a.terms},this.isNumericVocabulary=function(a){return!a.terms&&(c.vocabularyType(a)===VOCABULARY_TYPES.INTEGER||c.vocabularyType(a)===VOCABULARY_TYPES.DECIMAL)},this.isRangeVocabulary=function(a){return a.terms&&(c.vocabularyType(a)===VOCABULARY_TYPES.INTEGER||c.vocabularyType(a)===VOCABULARY_TYPES.DECIMAL)}}]).service("RqlQueryService",["$q","TaxonomiesResource","TaxonomyResource","LocalizedValues","RqlQueryUtils",function(a,b,c,d,e){function f(a,b){return b.args.filter(function(b){return b.name===a}).pop()}function g(a){switch(a.type){case RQL_NODE.CONTAINS:case RQL_NODE.IN:case RQL_NODE.OUT:case RQL_NODE.EQ:case RQL_NODE.GT:case RQL_NODE.GE:case RQL_NODE.LT:case RQL_NODE.LE:case RQL_NODE.BETWEEN:case RQL_NODE.MATCH:case RQL_NODE.EXISTS:case RQL_NODE.MISSING:return!0}return!1}function h(a){var b=a.parent,c=a.rqlQuery,d=c.args,e=a.parent.rqlQuery,f=e.args.indexOf(c),g=b.children.indexOf(a);if(-1===f||-1===g)throw new Error("Criteria node not found: "+a);b.children.splice(g,1),a.children.forEach(function(a){a.parent=b}),b.children.splice.apply(b.children,[g,0].concat(a.children)),e.args.splice(f,1),d&&(d instanceof Array?e.args.splice.apply(e.args,[f,0].concat(d)):e.args.splice(f,0,d)),null!==b.parent&&0===e.args.length&&h(b)}function i(a){var b=a.parent,c=a.rqlQuery,d=c.args,e=a.parent.rqlQuery,f=e.args.indexOf(c),g=b.children.indexOf(a);if(-1===f||-1===g)throw new Error("Criteria node not found: "+a);b.children.splice(g,1),a.children.forEach(function(a){a.parent=b}),b.children.splice.apply(b.children,[g,0].concat(a.children)),e.args.splice(f,1),d&&(d instanceof Array?e.args.splice.apply(e.args,[f,0].concat(d)):e.args.splice(f,0,d)),0===e.args.length&&h(b)}function j(a){var b=a.parent;if(!b)throw new Error("Cannot remove criteria when parent is NULL");var c=a.rqlQuery,d=a.parent.rqlQuery,e=d.args.indexOf(c);if(-1===e)throw new Error("Criteria node not found: "+a);d.args.splice(e,1),-1!==[RQL_NODE.OR,RQL_NODE.AND,RQL_NODE.NAND,RQL_NODE.NOR].indexOf(b.type)?i(b):0===d.args.length&&h(b)}var k={variable:null,dataset:null,study:null,network:null};this.removeCriteriaItem=function(a){g(a)?j(a):h(a)},this.createCriteriaItem=function(a,b,e,f,g){function h(b,c,e){return new CriteriaItemBuilder(d,g).target(a).taxonomy(b).vocabulary(c).term(e)}return angular.isString(b)?c.get({target:a,taxonomy:b}).$promise.then(function(a){return e=a.vocabularies.filter(function(a){return a.name===e})[0],f=e.terms.filter(function(a){return a.name===f})[0],h(a,e,f).build()}):h(b,e,f).build()},this.addCriteriaItem=function(a,b,c){var d=a.args.filter(function(a){return b.target===a.name}).pop();d||(d=new RqlQuery(RQL_NODE[b.target.toUpperCase()]),a.args.push(d));var f=b.rqlQuery?b.rqlQuery:e.buildRqlQuery(b);return e.addQuery(d,f,c)},this.updateCriteriaItem=function(a,b,c){var d,f=a.isRepeatable(),g=!f&&a.rqlQuery.name===RQL_NODE.MATCH;c&&b.rqlQuery&&(a.rqlQuery.name=b.rqlQuery.name),b.rqlQuery?d=b.rqlQuery.args[g?0:1]:b.term?d=[b.term.name]:(a=f?a.first():a,a.rqlQuery.name=RQL_NODE.EXISTS,a.rqlQuery.args.splice(1,1)),d&&(f?e.updateRepeatableQueryArgValues(a,d):e.updateQueryArgValues(a.rqlQuery,d,c))},this.builders=function(c,e,f,g){function h(a,b){var e=new CriteriaBuilder(a,b,k[c],d,g);e.initialize(c),e.build(),i.resolve({root:e.getRootItem(),map:e.getLeafItemMap()})}var i=a.defer();return k[c]?h(e,f):b.get({target:c}).$promise.then(function(a){k[c]=a,h(e,f)}),i.promise},this.createCriteria=function(b,c){var d=a.defer(),f=(new CriteriaItemBuilder).type(RQL_NODE.AND).rqlQuery(b).build(),g={};if(!e.hasTargetQuery(b))return d.resolve({root:f,map:g}),d.promise;var h=[],i=this,j=0;return b.args.forEach(function(a){QUERY_TARGETS[a.name.toUpperCase()]&&h.push(a)}),h.forEach(function(a){i.builders(a.name,a,f,c).then(function(a){f.children.push(a.root),g=angular.extend(g,a.map),j++,j===h.length&&d.resolve({root:f,map:g})})}),d.promise},this.prepareCriteriaTermsQuery=function(a,b,c){function d(a,b,c){if(!a||!a.args)return null;if((a.name===RQL_NODE.IN||a.name===RQL_NODE.MISSING||a.name===RQL_NODE.CONTAINS)&&a.args[0]===b)return a;for(var e=a.args.length;e--;){var f=d(a.args[e],b,c);f&&(a.args[e]=c)}}var f=(new RqlParser).parse(a),g=f.args.filter(function(a){return a.name===b.target}).pop();if(g){var h=new RqlQuery(RQL_NODE.EXISTS),i=e.criteriaId(b.taxonomy,b.vocabulary);h.args.push(i),d(g,i,h),g.args.push(e.aggregate([i])),g.args.push(e.limit(0,0))}return f.args.push(new RqlQuery(RQL_NODE.FACET)),c&&e.addLocaleQuery(f,c),f.serializeArgs(f.args)},this.prepareSearchQuery=function(a,b,c,d,g){var h=angular.copy(b),i=typeToTarget(a);e.addLocaleQuery(h,d);var j=f(i,h);j||(j=new RqlQuery(i),h.args.push(j));var k=c[i]||{from:0,size:10};return e.addLimit(j,e.limit(k.from,k.size)),g&&e.addSort(j,g),(new RqlQuery).serializeArgs(h.args)},this.prepareCoverageQuery=function(a,b){var c,d=(new RqlParser).parse(a),e=new RqlQuery("aggregate");switch(b){case BUCKET_TYPES.NETWORK:c="networkId";break;case BUCKET_TYPES.STUDY:c="studyIds";break;case BUCKET_TYPES.DCE:c="dceIds";break;case BUCKET_TYPES.DATASCHEMA:case BUCKET_TYPES.DATASET:c="datasetId"}var f=new RqlQuery("bucket");f.args.push(c),e.args.push(f);var g;if(d.args.forEach(function(a){g||"variable"!==a.name||(g=a)}),g||(g=new RqlQuery("variable"),d.args.push(g)),g.args.length>0&&"limit"!==g.args[0].name){var h=new RqlQuery("in");h.args.push("Mica_variable.variableType"),b===BUCKET_TYPES.NETWORK||b===BUCKET_TYPES.DATASCHEMA?h.args.push("Dataschema"):h.args.push("Study");var i=new RqlQuery("and");i.args.push(h),i.args.push(g.args[0]),g.args[0]=i}return g.args.push(e),d.serializeArgs(d.args)},this.prepareGraphicsQuery=function(a,b,c){var d=(new RqlParser).parse(a),e=new RqlQuery(RQL_NODE.AGGREGATE);if(b.forEach(function(a){e.args.push(a)}),c&&c.length>0){var f=new RqlQuery(RQL_NODE.BUCKET);c.forEach(function(a){f.args.push(a)}),e.args.push(f)}var g,h=!1,i=!1;return d.args.forEach(function(a){if("study"===a.name){i=!0;var b=null;h=a.args.filter(function(a,c){return"limit"===a.name&&(b=c),["limit","sort","aggregate"].indexOf(a.name)<0}).length,null!==b&&a.args.splice(b,1),g=a}}),i||(g=new RqlQuery("study"),d.args.push(g)),h||g.args.push(new RqlQuery(RQL_NODE.MATCH)),g.args.push(e),d.args.push(new RqlQuery("facet")),d.serializeArgs(d.args)},this.getTargetAggregations=function(a,b,c){function f(a,b){var e=b.terms;if(e&&e.length>0){var f=a&&a.map(function(a){return a.key})||[];if(a){var g=[];return e.forEach(function(a){0!==f.length&&-1!==f.indexOf(a.name)||g.push({count:0,"default":0,description:d.forLocale(a.description,c),key:a.name,title:d.forLocale(a.title,c)})}),a.concat(g)}return e.map(function(a){return{count:0,"default":0,description:d.forLocale(a.description,c),key:a.name,title:d.forLocale(a.title,c)}})}return a}function g(a,b){if(a.children){var c=a.children.filter(function(a){return a.hasOwnProperty(b)}).pop();if(c)return c[b]}return null}var h=e.vocabularyAlias(b.vocabulary),i=a[b.target+"ResultDto"];if(i&&i.aggs){var j=b.taxonomy.name.startsWith("Mica_"),k=j?h:b.taxonomy.name,l=i.aggs.filter(function(a){return a.aggregation===k}).pop();if(l){if(j)return e.isNumericVocabulary(b.vocabulary)?l["obiba.mica.StatsAggregationResultDto.stats"]:e.isRangeVocabulary(b.vocabulary)?f(l["obiba.mica.RangeAggregationResultDto.ranges"],b.vocabulary):f(l["obiba.mica.TermsAggregationResultDto.terms"],b.vocabulary);var m=l.children.filter(function(a){return a.aggregation===h}).pop();if(m)return e.isRangeVocabulary(b.vocabulary)?f(g(l,"obiba.mica.RangeAggregationResultDto.ranges"),b.vocabulary):f(g(l,"obiba.mica.TermsAggregationResultDto.terms"),b.vocabulary)}}return f([],b.vocabulary)},this.findCriterion=function(a,b){function c(a,b){var d;if(a.id===b)return a;for(var e=a.children.length;e--;)if(d=c(a.children[e],b))return d}return c(a,b)}}]),angular.module("obiba.mica.search").factory("TaxonomiesSearchResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("TaxonomiesSearchResource"),{},{get:{method:"GET",isArray:!0,errorHandler:!0}})}]).factory("TaxonomiesResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("TaxonomiesResource"),{},{get:{method:"GET",isArray:!0,errorHandler:!0}})}]).factory("TaxonomyResource",["$resource","ngObibaMicaUrl","$cacheFactory",function(a,b,c){return a(b.getUrl("TaxonomyResource"),{},{get:{method:"GET",errorHandler:!0,cache:c("taxonomyResource")}})}]).factory("JoinQuerySearchResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("JoinQuerySearchResource"),{},{variables:{method:"GET",errorHandler:!0,params:{type:"variables"}},studies:{method:"GET",errorHandler:!0,params:{type:"studies"}},networks:{method:"GET",errorHandler:!0,params:{type:"networks"}},datasets:{method:"GET",errorHandler:!0,params:{type:"datasets"}}})}]).factory("JoinQueryCoverageResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("JoinQueryCoverageResource"),{},{get:{method:"GET",errorHandler:!0}})}]).factory("VocabularyResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("VocabularyResource"),{},{get:{method:"GET",errorHandler:!0}})}]).service("SearchContext",function(){var a=null;this.setLocale=function(b){a=b},this.currentLocale=function(){return a}}).service("PageUrlService",["ngObibaMicaUrl","StringUtils",function(a,b){return this.studyPage=function(c){return c?b.replaceAll(a.getUrl("StudyPage"),{":study":c}):""},this.studyPopulationPage=function(c,d){return c?b.replaceAll(a.getUrl("StudyPopulationsPage"),{":study":c,":population":d}):""},this.networkPage=function(c){return c?b.replaceAll(a.getUrl("NetworkPage"),{":network":c}):""},this.datasetPage=function(c,d){var e=("study"===d.toLowerCase()?"study":"harmonization")+"-dataset",f=c?b.replaceAll(a.getUrl("DatasetPage"),{":type":e,":dataset":c}):"";return f},this.variablePage=function(c){return c?b.replaceAll(a.getUrl("VariablePage"),{":variable":c}):""},this.downloadCoverage=function(c){return b.replaceAll(a.getUrl("JoinQueryCoverageDownloadResource"),{":query":c})},this}]).service("ObibaSearchConfig",function(){var a={networks:{showSearchTab:1},studies:{showSearchTab:1},datasets:{showSearchTab:1},variables:{showSearchTab:1}};this.setOptions=function(b){"object"==typeof b&&Object.keys(b).forEach(function(c){c in a&&(a[c]=b[c])})},this.getOptions=function(){return angular.copy(a)}}).service("CoverageGroupByService",["ngObibaMicaSearch",function(a){var b=a.getOptions().coverage.groupBy;return{canShowStudy:function(){return b.study||b.dce},canShowDce:function(a){return(a===BUCKET_TYPES.STUDY||a===BUCKET_TYPES.DCE)&&b.study&&b.dce},canShowDataset:function(){return b.dataset||b.dataschema},canShowDatasetStudyDataschema:function(a){return(a===BUCKET_TYPES.DATASET||a===BUCKET_TYPES.DATASCHEMA)&&b.dataset&&b.dataschema},canShowNetwork:function(){return b.network},studyTitle:function(){return b.study?"search.coverage-buckets.study":b.dce?"search.coverage-buckets.dce":""},studyBucket:function(){return b.study?BUCKET_TYPES.STUDY:BUCKET_TYPES.DCE},datasetTitle:function(){return b.dataset&&b.dataschema?"search.coverage-buckets.datasetNav":b.dataset?"search.coverage-buckets.dataset":b.dataschema?"search.coverage-buckets.dataschema":""},datasetBucket:function(){return b.dataset?BUCKET_TYPES.DATASET:BUCKET_TYPES.DATASCHEMA},canGroupBy:function(a){return b.hasOwnProperty(a)&&b[a]},defaultBucket:function(){return b.study?BUCKET_TYPES.STUDY:b.dce?BUCKET_TYPES.DCE:b.dataset?BUCKET_TYPES.DATASET:b.dataschema?BUCKET_TYPES.DATASCHEMA:b.network?BUCKET_TYPES.NETWORK:""}}}]).factory("CriteriaNodeCompileService",["$templateCache","$compile",function(a,b){return{compile:function(c,d){var e="";e=c.item.type===RQL_NODE.OR||c.item.type===RQL_NODE.AND||c.item.type===RQL_NODE.NAND||c.item.type===RQL_NODE.NOR?angular.element(a.get("search/views/criteria/criteria-node-template.html")):angular.element(' '),b(e)(c,function(a){d.replaceWith(a)})}}}]),angular.module("obiba.mica.search").controller("SearchController",["$scope","$rootScope","$timeout","$routeParams","$location","$translate","$filter","$cookies","TaxonomiesSearchResource","TaxonomiesResource","TaxonomyResource","VocabularyResource","ngObibaMicaSearchTemplateUrl","ngObibaMicaSearch","JoinQuerySearchResource","JoinQueryCoverageResource","AlertService","ServerErrorUtils","LocalizedValues","RqlQueryService","RqlQueryUtils","SearchContext","CoverageGroupByService",function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w){function x(){function b(a){var b=e.search()[a];return b&&b.split(",").filter(function(a){return a}).map(function(a){return a.trim()})}a.taxonomyNav=[];var c=b("targetTabsOrder");a.targetTabsOrder=(c||a.options.targetTabsOrder).filter(function(a){return P[a]});var d=b("searchTabsOrder");a.searchTabsOrder=d||a.options.searchTabsOrder;var f=b("resultTabsOrder");a.resultTabsOrder=(f||a.options.resultTabsOrder).filter(function(a){return P[a]}),e.search().target?a.target=e.search().target:a.target||(a.target=a.targetTabsOrder[0]),a.metaTaxonomy.$promise.then(function(b){a.targetTabsOrder.forEach(function(c){var d=b.vocabularies.filter(function(a){return a.name===c}).pop();d&&d.terms&&d.terms.forEach(function(b){b.target=c;var d=b.title.filter(function(b){return b.locale===a.lang})[0],e=b.description?b.description.filter(function(b){return b.locale===a.lang})[0]:void 0;b.locale={title:d,description:e},b.terms&&b.terms.forEach(function(b){var c=b.title.filter(function(b){return b.locale===a.lang})[0],d=b.description?b.description.filter(function(b){return b.locale===a.lang})[0]:void 0;b.locale={title:c,description:d}}),a.taxonomyNav.push(b)})})})}function y(b){a.search.result={},q.alert({id:"SearchController",type:"danger",msg:r.buildMessage(b),delay:5e3})}function z(a){if(!a||!QUERY_TYPES[a.toUpperCase()])throw new Error("Invalid type: "+a)}function A(a){if(a&&!BUCKET_TYPES[a.toUpperCase()])throw new Error("Invalid bucket: "+a)}function B(a){if(!a||!DISPLAY_TYPES[a.toUpperCase()])throw new Error("Invalid display: "+a)}function C(){return a.taxonomyTypeMap[a.resultTabsOrder[0]]}function D(){return a.searchTabsOrder[0]||DISPLAY_TYPES.LIST}function E(){try{var b=e.search(),c=a.resultTabsOrder.indexOf(O[b.type])>-1?b.type:C(),d=b.bucket&&w.canGroupBy(b.bucket)?b.bucket:w.defaultBucket(),f=a.searchTabsOrder.indexOf(b.display)>-1?b.display:D(),g=b.query||"";return z(c),A(d),B(f),a.search.type=c,a.search.bucket=d,a.search.display=f,a.search.query=g,a.search.rqlQuery=(new RqlParser).parse(g),!0}catch(h){q.alert({id:"SearchController",type:"danger",msg:h.message,delay:5e3})}return!1}function F(a){return a=a.trim(),a.match(/\s+/)?'"'+a.replace(/^"|"$/g,"").replace(/"/,'"')+'"':a}function G(a){a.sort(function(a,b){return"network"===a.target||"variable"===b.target?-1:"variable"===a.target||"network"===b.target?1:a.targetb.target?-1:0})}function H(){if("/search"===e.path()){var b=t.prepareSearchQuery(a.search.type,a.search.rqlQuery,a.search.pagination,a.lang,a.search.type===QUERY_TYPES.VARIABLES?SORT_FIELDS.NAME:SORT_FIELDS.ACRONYM);switch(a.search.display){case DISPLAY_TYPES.LIST:a.search.loading=!0,a.search.executedQuery=b,o[a.search.type]({query:b},function(b){a.search.result.list=b,a.search.loading=!1},y);break;case DISPLAY_TYPES.COVERAGE:var c=Object.keys(a.search.criteriaItemMap).map(function(b){return a.search.criteriaItemMap[b]}).filter(function(a){return QUERY_TARGETS.VARIABLE===a.getTarget()&&"Mica_variable"!==a.taxonomy.name}).length>0;c?(a.search.loading=!0,a.search.executedQuery=t.prepareCoverageQuery(b,a.search.bucket),p.get({query:a.search.executedQuery},function(b){a.search.result.coverage=b,a.search.loading=!1},y)):a.search.result={};break;case DISPLAY_TYPES.GRAPHICS:a.search.loading=!0,a.search.executedQuery=t.prepareGraphicsQuery(b,["Mica_study.populations-selectionCriteria-countriesIso","Mica_study.populations-dataCollectionEvents-bioSamples","Mica_study.numberOfParticipants-participant-number"],["Mica_study.methods-designs"]),o.studies({query:a.search.executedQuery},function(b){a.search.result.graphics=b,a.search.loading=!1},y)}}}function I(){E()&&t.createCriteria(a.search.rqlQuery,a.lang).then(function(b){a.search.criteria=b.root,a.search.criteria&&a.search.criteria.children&&G(a.search.criteria.children),a.search.criteriaItemMap=b.map,a.search.query&&H(),a.$broadcast("ngObibaMicaQueryUpdated",a.search.criteria)})}function J(a){var b=a.parent;if(b.type===RQL_NODE.OR){var c=b.parent,d=c.children.indexOf(b);c.children[d]=a;var e=b.rqlQuery,f=c.rqlQuery,g=f.args.indexOf(e);f.args[g]=a.rqlQuery,c.type!==QUERY_TARGETS.VARIABLE&&J(c)}}function K(b){var c=Object.keys(a.search.criteriaItemMap).filter(function(a){return-1!==b.id.indexOf(a)})[0];return a.search.criteriaItemMap[c]}function L(){n.getLocale(function(b){angular.isArray(b)?(a.tabs=b,a.lang=b[0]):a.lang=b||a.lang,v.setLocale(a.lang),x(),I()})}a.options=n.getOptions();var M="micaHideSearchHelpText",N="micaHideClassificationHelpBox";f(["search.help","search.coverage-help"]).then(function(b){a.options.SearchHelpText||h.get(M)||(a.options.SearchHelpText=b["search.help"]),a.options.ClassificationHelpText||h.get(N)||(a.options.ClassificationHelpText=b["classifications.help"])}),a.closeHelpBox=function(){h.put(M,!0),a.options.SearchHelpText=null},a.closeClassificationHelpBox=function(){h.put(N,!0),a.options.ClassificationHelpText=null},h.get(M)&&(a.options.SearchHelpText=null),h.get(N)&&(a.options.ClassificationHelpText=null),a.taxonomyTypeMap={variable:"variables",study:"studies",network:"networks",dataset:"datasets"},f(["search.classifications-title","search.classifications-link","search.faceted-navigation-help"]).then(function(b){a.hasClassificationsTitle=b["search.classifications-title"],a.hasClassificationsLinkLabel=b["search.classifications-link"],a.hasFacetedNavigationHelp=b["search.faceted-navigation-help"]});var O=Object.keys(a.taxonomyTypeMap).reduce(function(b,c){return b[a.taxonomyTypeMap[c]]=c,b},{});a.targets=[],a.lang=s.getLocal(),a.metaTaxonomy=k.get({target:"taxonomy",taxonomy:"Mica_taxonomy"},function(b){function c(a){function b(a,c){return angular.forEach(c,function(c){return c.terms?void b(a,c.terms):void a.push(c)}),a}return b([],a)}a.targets=b.vocabularies.map(function(a){return a.name}),a.hasFacetedTaxonomies=!1,a.facetedTaxonomies=b.vocabularies.reduce(function(b,d){function e(a){return g.filter(function(b){return b.name===a})[0]}function f(a){return null!==a&&void 0!==a}var g=c(d.terms);return a.options.showAllFacetedTaxonomies?b[d.name]=g.filter(function(a){return a.attributes&&a.attributes.some(function(a){return"showFacetedNavigation"===a.key&&"true"===a.value.toString()})}):b[d.name]=(a.options[d.name+"TaxonomiesOrder"]||[]).map(e).filter(f),a.hasFacetedTaxonomies=a.hasFacetedTaxonomies||b[d.name].length,b},{})});var P={variable:a.options.variables.showSearchTab,dataset:a.options.datasets.showSearchTab,study:a.options.studies.showSearchTab,network:a.options.networks.showSearchTab},Q=function(){var a=e.search();delete a.query,e.search(a)},R=function(){a.search.advanced=!a.search.advanced},S=function(){for(var b=a.search.criteria.children||[],c=b.length;c--;)for(var d=b[c].children||[],e=d.length;e--;)if(d[e].type===RQL_NODE.OR||d[e].type===RQL_NODE.AND)return!0;
-};a.setLocale=function(b){a.lang=b,v.setLocale(a.lang),I()};var T=function(b,c){return a.target===b&&a.taxonomyName===c&&a.taxonomiesShown?void(a.taxonomiesShown=!1):(a.taxonomiesShown=!0,a.target=b,void(a.taxonomyName=c))},U=function(){a.target=null,a.taxonomyName=null},V=function(){var b=(new RqlQuery).serializeArgs(a.search.rqlQuery.args),c=e.search();""===b?delete c.query:c.query=b,e.search(c)},W=function(){a.documents.search.text=null,a.documents.search.active=!1},X=function(b){function c(a){var c=0,d=new RegExp(b,"ig");return a.itemTitle.match(d)?c=10:a.itemDescription&&a.itemDescription.match(d)?c=8:a.itemParentTitle.match(d)?c=6:a.itemParentDescription&&a.itemParentDescription.match(d)&&(c=4),c}function d(a,b){return(b||[]).indexOf(a.name)>-1?!1:0===(a.attributes||[]).filter(function(a){return"showSearch"===a.key}).length}function e(b){var e=[],f=0,g=b.target,h=b.taxonomy;return h.vocabularies&&h.vocabularies.filter(function(b){return d(b,a.options.hideSearch)}).forEach(function(b){if(b.terms)b.terms.filter(function(b){return d(b,a.options.hideSearch)}).forEach(function(d){var i=t.createCriteriaItem(g,h,b,d,a.lang);e.push({score:c(i),item:i}),f++});else{var i=t.createCriteriaItem(g,h,b,null,a.lang);e.push({score:c(i),item:i}),f++}}),{results:e,total:f}}var f=i.get({query:F(b),locale:a.lang,target:a.documents.search.target}).$promise.then(function(a){if(a){var c=[],d=0,f=10;if(a.forEach(function(a){var b=e(a);c.push.apply(c,b.results),d+=b.total}),c.sort(function(a,b){return b.score-a.score}),c=c.splice(0,f),d>c.length){var g={query:b,total:d,size:f,message:"Showing "+f+" / "+d,status:"has-warning"};c.push({score:-1,item:g})}return c.map(function(a){return a.item})}return[]});return f},Y=function(a){t.removeCriteriaItem(a),V()},Z=function(b,c,d,e){if(angular.isUndefined(e)&&(e=!0),b.id){var f,h=CriteriaIdGenerator.generate(b.taxonomy,b.vocabulary),i=a.search.criteriaItemMap[h];i&&-1!==h.indexOf("dceIds")?(Y(i),f="search.criterion.updated",t.addCriteriaItem(a.search.rqlQuery,b,c)):i?(f="search.criterion.updated",t.updateCriteriaItem(i,b,d)):(f="search.criterion.created",t.addCriteriaItem(a.search.rqlQuery,b,c)),e&&q.growl({id:"SearchControllerGrowl",type:"info",msgKey:f,msgArgs:[s.forLocale(b.vocabulary.title,a.lang),g("translate")("taxonomy.target."+b.target)],delay:3e3}),V(),a.selectedCriteria=null}else a.selectedCriteria=b.query},$=function(b){switch(b.keyCode){case 27:a.documents.search.active&&W();break;default:a.documents.search.text&&X(a.documents.search.text)}},_=function(a){if(a){z(a);var b=e.search();b.type=a,e.search(b)}},aa=function(a){if(a){A(a);var b=e.search();b.bucket=a,e.search(b)}},ba=function(b,c,d){a.search.pagination[b]={from:c,size:d},I()},ca=function(a){if(a){B(a);var b=e.search();b.display=a,e.search(b)}},da=function(b,c,d,e,f){if(c&&_(c),e){var g=K(b);g&&J(g)}ca(d&&a.search.display?a.search.display:DISPLAY_TYPES.LIST),Z(b,RQL_NODE.AND,!0,f)},ea=function(b){var c=t.findCriterion(a.search.criteria,b.id);Y(c)},fa=function(b,c,d,e){if(e=e||{},angular.isString(e)&&(e={term:e}),d){var f;if(u.isNumericVocabulary(d))return f=t.createCriteriaItem(b,c,d,null,a.lang),f.rqlQuery=u.buildRqlQuery(f),u.updateRangeQuery(f.rqlQuery,e.from,e.to),void Z(f,null,!0);if(u.isMatchVocabulary(d))return f=t.createCriteriaItem(b,c,d,null,a.lang),f.rqlQuery=u.buildRqlQuery(f),u.updateMatchQuery(f.rqlQuery,e.text),void Z(f,null,!0)}Z(t.createCriteriaItem(b,c,d,e&&e.term,a.lang))},ga=function(b){a.documents.search.target=b},ha={SEARCH:"search",CLASSIFICATION:"classification"};a.goToSearch=function(){a.viewMode=ha.SEARCH,e.search("taxonomy",null),e.search("vocabulary",null),e.search("target",null),e.path("/search")},a.goToClassifications=function(){a.viewMode=ha.CLASSIFICATION,e.path("/classifications"),e.search("target",a.targetTabsOrder[0])},a.navigateToTarget=function(b){e.search("target",b),e.search("taxonomy",null),e.search("vocabulary",null),a.target=b},a.QUERY_TYPES=QUERY_TYPES,a.BUCKET_TYPES=BUCKET_TYPES,a.search={pagination:{},query:null,advanced:!1,rqlQuery:new RqlQuery,executedQuery:null,type:null,bucket:null,result:{list:null,coverage:null,graphics:null},criteria:[],criteriaItemMap:{},loading:!1},a.viewMode=ha.SEARCH,a.documents={search:{text:null,active:!1,target:null}},a.searchHeaderTemplateUrl=m.getHeaderUrl("search"),a.classificationsHeaderTemplateUrl=m.getHeaderUrl("classifications"),a.selectSearchTarget=ga,a.selectDisplay=ca,a.searchCriteria=X,a.selectCriteria=Z,a.searchKeyUp=$,a.showTaxonomy=T,a.clearTaxonomy=U,a.removeCriteriaItem=Y,a.refreshQuery=V,a.clearSearchQuery=Q,a.toggleSearchQuery=R,a.showAdvanced=S,a.onTypeChanged=_,a.onBucketChanged=aa,a.onDisplayChanged=ca,a.onUpdateCriteria=da,a.onRemoveCriteria=ea,a.onSelectTerm=fa,a.QUERY_TARGETS=QUERY_TARGETS,a.onPaginate=ba,a.inSearchMode=function(){return a.viewMode===ha.SEARCH},a.toggleFullscreen=function(){a.isFullscreen=!a.isFullscreen},a.$on("$locationChangeSuccess",function(a,b){x(),a!==b&&I()}),b.$on("ngObibaMicaSearch.fullscreenChange",function(b,c){a.isFullscreen=c}),L()}]).controller("NumericVocabularyPanelController",["$scope",function(a){a.$watch("taxonomies",function(){a.from=null,a.to=null},!0)}]).controller("MatchVocabularyPanelController",["$scope",function(a){a.$watch("taxonomies",function(){a.text=null},!0)}]).controller("NumericVocabularyFacetController",["$scope","JoinQuerySearchResource","RqlQueryService","RqlQueryUtils",function(a,b,c,d){function e(e,f){function g(a,b){var e=angular.copy(a.rqlQuery);return b.rqlQuery=d.buildRqlQuery(b),c.addCriteriaItem(e,b),e}var h=c.findCriterion(e,CriteriaIdGenerator.generate(a.$parent.taxonomy,f));h||(h=c.createCriteriaItem(a.target,a.$parent.taxonomy,a.vocabulary)),h.rqlQuery&&h.rqlQuery.args[1]?angular.isArray(h.rqlQuery.args[1])?(a.from=h.rqlQuery.args[1][0],a.to=h.rqlQuery.args[1][1]):h.rqlQuery.name===RQL_NODE.GE?a.from=h.rqlQuery.args[1]:a.to=h.rqlQuery.args[1]:(a.from=null,a.to=null,a.min=null,a.max=null);var i=d.hasTargetQuery(e.rqlQuery,h.target)?angular.copy(e.rqlQuery):g(e,h),j=c.prepareCriteriaTermsQuery(i,h);b[targetToType(a.target)]({query:j}).$promise.then(function(b){var d=c.getTargetAggregations(b,h,a.lang);d&&d["default"]&&(a.min=d["default"].min,a.max=d["default"].max)})}function f(){a.$parent.selectTerm(a.$parent.target,a.$parent.taxonomy,a.vocabulary,{from:a.from,to:a.to})}a.onKeypress=function(a){13===a.keyCode&&f()},a.$on("ngObibaMicaQueryUpdated",function(b,c){a.vocabulary.isNumeric&&a.vocabulary.isOpen&&e(c,a.vocabulary)}),a.$on("ngObibaMicaLoadVocabulary",function(b,c,d){a.vocabulary.isNumeric&&d.name===a.vocabulary.name&&!d.isOpen&&e(a.criteria,d)})}]).controller("MatchVocabularyFacetController",["$scope","RqlQueryService",function(a,b){function c(c,d){var e=b.findCriterion(c,CriteriaIdGenerator.generate(a.$parent.taxonomy,d));e&&e.rqlQuery&&e.rqlQuery.args[1]?a.text=e.rqlQuery.args[0]:a.text=null}function d(){a.$parent.selectTerm(a.$parent.target,a.$parent.taxonomy,a.vocabulary,{text:a.text||"*"})}a.onKeypress=function(a){13===a.keyCode&&d()},a.$on("ngObibaMicaQueryUpdated",function(b,d){a.vocabulary.isMatch&&a.vocabulary.isOpen&&c(d,a.vocabulary)}),a.$on("ngObibaMicaLoadVocabulary",function(b,d,e){e.name!==a.vocabulary.name||e.isOpen||c(a.criteria,e)})}]).controller("TermsVocabularyFacetController",["$scope","$filter","JoinQuerySearchResource","RqlQueryService","RqlQueryUtils",function(a,b,c,d,e){function f(a,b){return a.selectedTerms&&(a.rqlQuery.name===RQL_NODE.EXISTS||-1!==a.selectedTerms.indexOf(b.key))}function g(b,g){function h(a,b){var c=angular.copy(a.rqlQuery);return b.rqlQuery=e.buildRqlQuery(b),d.addCriteriaItem(c,b),c}var i=null,j=!1,k=d.findCriterion(b,CriteriaIdGenerator.generate(a.$parent.taxonomy,g));k?j=!0:k=d.createCriteriaItem(a.target,a.$parent.taxonomy,a.vocabulary),e.hasTargetQuery(b.rqlQuery,k.target)?(i=angular.copy(b.rqlQuery),j||d.addCriteriaItem(i,k,RQL_NODE.OR)):i=h(b,k);var l=d.prepareCriteriaTermsQuery(i,k,k.lang);c[targetToType(a.target)]({query:l}).$promise.then(function(b){d.getTargetAggregations(b,k,k.lang).forEach(function(b){a.vocabulary.terms.some(function(a){return a.name===b.key?(a.selected=f(k,b),a.count=b.count,!0):void 0})})})}a.selectTerm=function(b,c,f,g){var h=f.terms.filter(function(a){return a.selected}).map(function(a){return a.name}),i=d.findCriterion(a.criteria,CriteriaIdGenerator.generate(c,f));i?(0===h.length?d.removeCriteriaItem(i):(i.rqlQuery.name=RQL_NODE.IN,e.updateQuery(i.rqlQuery,h)),a.onRefresh()):a.onSelectTerm(b,c,f,g)},a.$on("ngObibaMicaQueryUpdated",function(b,c){a.vocabulary.isNumeric||a.vocabulary.isMatch||!a.vocabulary.isOpen||g(c,a.vocabulary)}),a.$on("ngObibaMicaLoadVocabulary",function(b,c,d){d.name!==a.vocabulary.name||a.vocabulary.isNumeric||a.vocabulary.isMatch||d.isOpen||g(a.criteria,d)})}]).controller("TaxonomiesPanelController",["$scope","$location","TaxonomyResource","TaxonomiesResource","ngObibaMicaSearch","RqlQueryUtils",TaxonomiesPanelController]).controller("ClassificationPanelController",["$scope","$location","TaxonomyResource","TaxonomiesResource","ngObibaMicaSearch","RqlQueryUtils",ClassificationPanelController]).controller("TaxonomiesFacetsController",["$scope","$timeout","TaxonomyResource","TaxonomiesResource","LocalizedValues","ngObibaMicaSearch","RqlQueryUtils",function(a,b,c,d,e,f,g){function h(b){a.taxonomies[b]||d.get({target:b},function(c){a.taxonomies[b]=a.facetedTaxonomies[b].map(function(a){return c.filter(function(b){return a.name===b.name})[0]}).filter(function(a){return a}).map(function(a){return a.vocabularies.map(function(a){a.limit=10,a.isMatch=g.isMatchVocabulary(a),a.isNumeric=g.isNumericVocabulary(a)}),a}),1===a.taxonomies[b].length&&(a.taxonomies[b][0].isOpen=1)})}a.options=f.getOptions(),a.taxonomies={},a.targets=[],a.RqlQueryUtils=g,a.$watch("facetedTaxonomies",function(b){b&&(a.targets=a.options.targetTabsOrder.filter(function(a){return b[a].length}),a.target=a.targets[0],h(a.target))}),a.selectTerm=function(b,c,d,e){a.onSelectTerm(b,c,d,e)},a.setTarget=function(c){a.target=c,h(c),a.criteria&&b(function(){a.$broadcast("ngObibaMicaQueryUpdated",a.criteria)})},a.loadVocabulary=function(b,c){a.$broadcast("ngObibaMicaLoadVocabulary",b,c)},a.localize=function(b){return e.forLocale(b,a.lang)},a.$on("ngObibaMicaQueryUpdated",function(b,c){a.criteria=c})}]).controller("SearchResultController",["$scope","ngObibaMicaSearch",function(a,b){function c(b){Object.keys(a.activeTarget).forEach(function(c){a.activeTarget[c].active=b===c})}a.targetTypeMap=a.$parent.taxonomyTypeMap,a.QUERY_TARGETS=QUERY_TARGETS,a.QUERY_TYPES=QUERY_TYPES,a.options=b.getOptions(),a.activeTarget={},a.activeTarget[QUERY_TYPES.VARIABLES]={active:!1,name:QUERY_TARGETS.VARIABLE,totalHits:0},a.activeTarget[QUERY_TYPES.DATASETS]={active:!1,name:QUERY_TARGETS.DATASET,totalHits:0},a.activeTarget[QUERY_TYPES.STUDIES]={active:!1,name:QUERY_TARGETS.STUDY,totalHits:0},a.activeTarget[QUERY_TYPES.NETWORKS]={active:!1,name:QUERY_TARGETS.NETWORK,totalHits:0},a.selectTarget=function(b){c(b),a.type=b,a.$parent.onTypeChanged(b)},a.getTotalHits=function(b){return a.result.list&&a.result.list[b+"ResultDto"]?a.result.list[b+"ResultDto"].totalHits:"..."},a.$watchCollection("result",function(){a.result.list&&(a.activeTarget[QUERY_TYPES.VARIABLES].totalHits=a.result.list.variableResultDto.totalHits,a.activeTarget[QUERY_TYPES.DATASETS].totalHits=a.result.list.datasetResultDto.totalHits,a.activeTarget[QUERY_TYPES.STUDIES].totalHits=a.result.list.studyResultDto.totalHits,a.activeTarget[QUERY_TYPES.NETWORKS].totalHits=a.result.list.networkResultDto.totalHits)}),a.$watch("type",function(a){c(a)}),a.DISPLAY_TYPES=DISPLAY_TYPES}]).controller("CriterionLogicalController",["$scope",function(a){a.updateLogical=function(b){a.item.rqlQuery.name=b,a.$emit(CRITERIA_ITEM_EVENT.refresh)}}]).controller("CriterionDropdownController",["$scope","$filter","LocalizedValues","RqlQueryUtils","StringUtils",function(a,b,c,d,e){var f=function(){if(a.state.open){a.state.onClose();var b=a.state.dirty;a.state.open=!1,a.state.dirty=!1,b&&a.$emit(CRITERIA_ITEM_EVENT.refresh)}},g=function(){return a.state.open?void f():(a.state.open=!0,void a.state.onOpen())},h=function(){a.$emit(CRITERIA_ITEM_EVENT.deleted,a.criterion)},i=function(a){13===a.keyCode&&f()};a.state=new CriterionState,a.timestamp=(new Date).getTime(),a.localize=function(b){return c.forLocale(b,a.criterion.lang)},a.localizeCriterion=function(){var d=a.criterion.rqlQuery;if((d.name===RQL_NODE.IN||d.name===RQL_NODE.CONTAINS)&&a.criterion.selectedTerms&&a.criterion.selectedTerms.length>0){var e=d.name===RQL_NODE.IN?" | ":" + ";return a.criterion.selectedTerms.map(function(b){if(!a.criterion.vocabulary.terms)return b;var d=a.criterion.vocabulary.terms.filter(function(a){return a.name===b}).pop();return d?c.forLocale(d.title,a.criterion.lang):b}).join(e)}var f=d.name;switch(d.name){case RQL_NODE.EXISTS:f=":"+b("translate")("any");break;case RQL_NODE.MISSING:f=":"+b("translate")("none");break;case RQL_NODE.EQ:f="="+d.args[1];break;case RQL_NODE.GE:f=">"+d.args[1];break;case RQL_NODE.LE:f="<"+d.args[1];break;case RQL_NODE.BETWEEN:f=":["+d.args[1]+")";break;case RQL_NODE.IN:case RQL_NODE.CONTAINS:f="";break;case RQL_NODE.MATCH:f=":match("+d.args[0]+")"}return c.forLocale(a.criterion.vocabulary.title,a.criterion.lang)+f},a.vocabularyType=function(a){return d.vocabularyType(a)},a.onKeyup=i,a.truncate=e.truncate,a.remove=h,a.openDropdown=g,a.closeDropdown=f,a.RqlQueryUtils=d}]).controller("MatchCriterionTermsController",["$scope","RqlQueryService","LocalizedValues","JoinQuerySearchResource","RqlQueryUtils","SearchContext",function(a,b,c,d,e,f){a.lang=f.currentLocale();var g=function(){a.state.dirty=!0,e.updateMatchQuery(a.criterion.rqlQuery,a.match)},h=a.criterion.rqlQuery.args[0];a.match="*"===h?"":h,a.update=g,a.localize=function(b){return c.forLocale(b,a.criterion.lang)}}]).controller("NumericCriterionController",["$scope","RqlQueryService","LocalizedValues","JoinQuerySearchResource","RqlQueryUtils","SearchContext",function(a,b,c,d,e,f){a.lang=f.currentLocale();var g=a.criterion.rqlQuery.args[1];angular.isArray(g)?(a.from=a.criterion.rqlQuery.args[1][0],a.to=a.criterion.rqlQuery.args[1][1]):(a.from=a.criterion.rqlQuery.name===RQL_NODE.GE?g:null,a.to=a.criterion.rqlQuery.name===RQL_NODE.LE?g:null);var h=function(){var c=a.criterion.target,e=b.prepareCriteriaTermsQuery(a.query,a.criterion);d[targetToType(c)]({query:e}).$promise.then(function(c){var d=b.getTargetAggregations(c,a.criterion,a.lang);d&&d["default"]&&(a.min=d["default"].min,a.max=d["default"].max)})},i=function(){h()},j=function(){a.updateSelection()};a.updateSelection=function(){e.updateRangeQuery(a.criterion.rqlQuery,a.from,a.to,a.selectMissing),a.state.dirty=!0},a.selectMissing=a.criterion.rqlQuery.name===RQL_NODE.MISSING,a.state.addOnClose(j),a.state.addOnOpen(i),a.localize=function(b){return c.forLocale(b,a.criterion.lang)}}]).controller("StringCriterionTermsController",["$scope","RqlQueryService","LocalizedValues","StringUtils","JoinQuerySearchResource","RqlQueryUtils","SearchContext","$filter",function(a,b,c,d,e,f,g,h){a.lang=g.currentLocale();var i=function(b){return-1!==a.checkboxTerms.indexOf(b)},j=function(){a.state.dirty=!0,a.criterion.rqlQuery.name=a.selectedFilter;var b=[];a.selectedFilter!==RQL_NODE.MISSING&&a.selectedFilter!==RQL_NODE.EXISTS&&Object.keys(a.checkboxTerms).forEach(function(c){a.checkboxTerms[c]&&b.push(c)}),0===b.length&&a.selectedFilter!==RQL_NODE.MISSING&&(a.criterion.rqlQuery.name=RQL_NODE.EXISTS),f.updateQuery(a.criterion.rqlQuery,b)},k=function(){j()},l=function(){return a.selectedFilter===RQL_NODE.IN},m=function(){return a.selectedFilter===RQL_NODE.CONTAINS},n=function(){a.state.loading=!0;var c=a.criterion.target,d=b.prepareCriteriaTermsQuery(a.query,a.criterion,a.lang);e[targetToType(c)]({query:d}).$promise.then(function(c){a.state.loading=!1,a.terms=b.getTargetAggregations(c,a.criterion,a.lang),a.terms&&(a.terms.forEach(function(b){a.checkboxTerms[b.key]=a.isSelectedTerm(b)}),a.terms=h("orderBySelection")(a.terms,a.checkboxTerms))})};a.isSelectedTerm=function(b){return a.criterion.selectedTerms&&-1!==a.criterion.selectedTerms.indexOf(b.key)},a.state.addOnOpen(n),a.checkboxTerms={},a.RQL_NODE=RQL_NODE,a.selectedFilter=a.criterion.type,a.isSelected=i,a.updateFilter=k,a.localize=function(b){return c.forLocale(b,a.criterion.lang)},a.truncate=d.truncate,a.isInFilter=l,a.isContainsFilter=m,a.updateSelection=j}]).controller("CoverageResultTableController",["$scope","$location","$q","PageUrlService","RqlQueryUtils","RqlQueryService","CoverageGroupByService",function(a,b,c,d,e,f,g){function h(a,b){for(var c=0,d=0,e=0;e=a[d].termsCount&&(d++,c=0),c+=b[e].termsCount,b[e].taxonomyName=a[d].entity.name}function i(a,b,c){var d=0;return a.reduce(function(a,e){return a[e.entity.name]=b.slice(d,d+e.termsCount).map(function(a){return e.termsCount>1&&"vocabularyName"===c&&(a.canRemove=!0),a[c]=e.entity.name,a}),d+=e.termsCount,a},{})}function j(a,b){switch(a){case BUCKET_TYPES.STUDY:case BUCKET_TYPES.DCE:return d.studyPage(b);case BUCKET_TYPES.NETWORK:return d.networkPage(b);case BUCKET_TYPES.DATASCHEMA:return d.datasetPage(b,"harmonization");case BUCKET_TYPES.DATASET:return d.datasetPage(b,"study")}return""}function k(b){var d=a.bucket===BUCKET_TYPES.DCE?"dceIds":"id";c.all(b.map(function(b){return f.createCriteriaItem(n[a.bucket],"Mica_"+n[a.bucket],d,b.value)})).then(function(b){if(b.length){var c=b.reduce(function(a,b){return a?(f.updateCriteriaItem(a,b),a):(b.rqlQuery=e.buildRqlQuery(b),b)},null);a.onUpdateCriteria(c,"variables",!0)}})}function l(){function b(a){var b;return i[a]?(b=0,i[a]=i[a]+1):(b=1,i[a]=1),b}function c(a,b,c){k[a]?(bk[a][1]&&(k[a][1]=c)):k[a]=[b,c]}function e(a,b){var c;if(a)if(a.indexOf("-")>0){var d=a.split("-");if(!b){var e=parseInt(d[1]);12>e?d[1]=e+1:(d[0]=parseInt(d[0])+1,d[1]=1)}var f=d[0]+"/"+d[1]+"/01";c=Date.parse(f)}else c=b?Date.parse(a+"/01/01"):Date.parse(a+"/12/31");return c}function f(a,b){var c=e(a,!0),d=b?e(b,!1):n,f=n>d?d:n;return d===c?100:Math.round(a?100*(f-c)/(d-c):0)}var g,h={colSpan:a.bucket===BUCKET_TYPES.DCE?3:1,ids:{}},i={},k={},l=(new Date).getFullYear(),m=(new Date).getMonth()+1,n=e(l+"-"+m,!0),o=!0;return a.result.rows.forEach(function(e){if(h.ids[e.value]=[],a.bucket===BUCKET_TYPES.DCE){var i,k,n=e.value.split(":"),p=e.title.split(":"),q=e.description.split(":");k=n[0],g?k!==g&&(o=!o,g=k):g=k,i=b(k),c(k,e.start,e.end),h.ids[e.value].push({id:k,url:d.studyPage(k),title:p[0],description:q[0],rowSpan:i}),k=n[0]+":"+n[1],i=b(k),h.ids[e.value].push({id:k,url:d.studyPopulationPage(n[0],n[1]),title:p[1],description:q[1],rowSpan:i}),h.ids[e.value].push({id:e.value,title:p[2],description:q[2],start:e.start,current:l+"-"+m,end:e.end,progressClass:o?"info":"warning",url:d.studyPopulationPage(n[0],n[1]),rowSpan:1})}else h.ids[e.value].push({id:e.value,url:j(a.bucket,e.value),title:e.title,description:e.description,min:e.start,start:e.start,current:l,end:e.end,max:e.end,progressStart:0,progress:f(e.start?e.start+"-01":void 0,e.end?e.end+"-12":void 0),progressClass:o?"info":"warning",rowSpan:1}),o=!o}),a.bucket===BUCKET_TYPES.DCE&&a.result.rows.forEach(function(a){h.ids[a.value][0].rowSpan>0&&(h.ids[a.value][0].rowSpan=i[h.ids[a.value][0].id]),h.ids[a.value][1].rowSpan>0&&(h.ids[a.value][1].rowSpan=i[h.ids[a.value][1].id]);var b=a.value.split(":");if(k[b[0]]){var c=k[b[0]][0],d=k[b[0]][1],f=h.ids[a.value][2].start,g=h.ids[a.value][2].end,j=e(d,!1)-e(c,!0);h.ids[a.value][2].min=c,h.ids[a.value][2].max=d,h.ids[a.value][2].progressStart=100*(e(f,!0)-e(c,!0))/j,h.ids[a.value][2].progress=100*(e(g,!1)-e(f,!0))/j}}),h}function m(a){return a.reduce(function(a,b){return a?(f.updateCriteriaItem(a,b),a):(b.rqlQuery=e.buildRqlQuery(b),b)},null)}var n={},o={};n[BUCKET_TYPES.NETWORK]=QUERY_TARGETS.NETWORK,n[BUCKET_TYPES.STUDY]=QUERY_TARGETS.STUDY,n[BUCKET_TYPES.DCE]=QUERY_TARGETS.VARIABLE,n[BUCKET_TYPES.DATASCHEMA]=QUERY_TARGETS.DATASET,n[BUCKET_TYPES.DATASET]=QUERY_TARGETS.DATASET,a.showMissing=!0,a.toggleMissing=function(b){a.showMissing=b},a.groupByOptions=g,a.bucketSelection={dceBucketSelected:a.bucket===BUCKET_TYPES.DCE,datasetBucketSelected:a.bucket!==BUCKET_TYPES.DATASCHEMA},a.$watch("bucketSelection.dceBucketSelected",function(b,c){b!==c&&(b?a.selectBucket(BUCKET_TYPES.DCE):a.bucket===BUCKET_TYPES.DCE&&a.selectBucket(BUCKET_TYPES.STUDY))}),a.$watch("bucketSelection.datasetBucketSelected",function(b,c){b!==c&&(b?a.selectBucket(BUCKET_TYPES.DATASET):a.bucket===BUCKET_TYPES.DATASET&&a.selectBucket(BUCKET_TYPES.DATASCHEMA))}),a.selectBucket=function(b){b===BUCKET_TYPES.STUDY&&a.bucketSelection.dceBucketSelected&&(b=BUCKET_TYPES.DCE),b!==BUCKET_TYPES.DATASET||a.bucketSelection.datasetBucketSelected||(b=BUCKET_TYPES.DATASCHEMA),a.bucket=b,a.$parent.onBucketChanged(b)},a.rowspans={},a.getSpan=function(b,c){var d=0;if(c){var e=b+":"+c;return d=a.result.rows.filter(function(a){return a.title.startsWith(e+":")}).length,a.rowspans[e]=d,d}return d=a.result.rows.filter(function(a){return a.title.startsWith(b+":")}).length,a.rowspans[b]=d,d},a.hasSpan=function(b,c){return c?a.rowspans[b+":"+c]>0:a.rowspans[b]>0},a.hasVariableTarget=function(){var a=b.search().query;return a&&e.hasTargetQuery((new RqlParser).parse(a),RQL_NODE.VARIABLE)},a.hasSelected=function(){return a.table&&a.table.rows&&a.table.rows.filter(function(a){return a.selected}).length},a.selectAll=function(){a.table&&a.table.rows&&a.table.rows.forEach(function(a){a.selected=!0})},a.selectNone=function(){a.table&&a.table.rows&&a.table.rows.forEach(function(a){a.selected=!1})},a.selectFull=function(){a.table&&a.table.rows&&a.table.rows.forEach(function(a){a.hits?a.selected=0===a.hits.filter(function(a){return 0===a}).length:a.selected=!1})},a.BUCKET_TYPES=BUCKET_TYPES,a.downloadUrl=function(){return d.downloadCoverage(a.query)},a.$watch("result",function(){if(a.table={cols:[]},o={},a.result&&a.result.rows){var b=a.result;b.cols=l(),a.table=b,o=i(a.table.vocabularyHeaders,a.table.termHeaders,"vocabularyName"),i(a.table.taxonomyHeaders,a.table.termHeaders,"taxonomyName"),h(a.table.taxonomyHeaders,a.table.vocabularyHeaders)}}),a.updateCriteria=function(b,d,e,g){var h=a.bucket===BUCKET_TYPES.DCE?"dceIds":"id",i={varItem:f.createCriteriaItem(QUERY_TARGETS.VARIABLE,d.taxonomyName,d.vocabularyName,d.entity.name)};b?i.item=f.createCriteriaItem(n[a.bucket],"Mica_"+n[a.bucket],h,b):a.bucket===BUCKET_TYPES.STUDY||a.bucket===BUCKET_TYPES.DATASET?i.item=f.createCriteriaItem(QUERY_TARGETS.DATASET,"Mica_"+QUERY_TARGETS.DATASET,"className","StudyDataset"):a.bucket!==BUCKET_TYPES.NETWORK&&a.bucket!==BUCKET_TYPES.DATASCHEMA||(i.item=f.createCriteriaItem(QUERY_TARGETS.DATASET,"Mica_"+QUERY_TARGETS.DATASET,"className","HarmonizationDataset")),c.all(i).then(function(b){a.onUpdateCriteria(b.varItem,g,!1,!0),b.item&&a.onUpdateCriteria(b.item,g)})},a.isFullCoverageImpossibleOrCoverageAlreadyFull=function(){var b=a.table?a.table.rows||[]:[],c=0;return 0===b.length?!0:(b.forEach(function(a){a.hits&&a.hits.filter(function(a){return 0===a}).length>0&&c++}),0===c?!0:b.length===c)},a.selectFullAndFilter=function(){var b=[];a.table&&a.table.rows&&a.table.rows.forEach(function(a){a.hits&&0===a.hits.filter(function(a){return 0===a}).length&&b.push(a)}),k(b)},a.updateFilterCriteria=function(){k(a.table.rows.filter(function(a){return a.selected}))},a.removeTerm=function(b){var d=o[b.vocabularyName].filter(function(a){return a.entity.name!==b.entity.name}).map(function(a){return f.createCriteriaItem(QUERY_TARGETS.VARIABLE,a.taxonomyName,a.vocabularyName,a.entity.name)});c.all(d).then(function(b){a.onUpdateCriteria(m(b),null,!0,!1,!1)})},a.removeVocabulary=function(b){f.createCriteriaItem(QUERY_TARGETS.VARIABLE,b.taxonomyName,b.entity.name).then(function(b){a.onRemoveCriteria(b)})}}]).controller("GraphicsResultController",["GraphicChartsConfig","GraphicChartsUtils","RqlQueryService","$filter","$scope",function(a,b,c,d,e){var f=function(a,c,d,e,f,g){return b.getArrayByAggregation(a,c).then(function(b){var c=b.map(function(a){return a.participantsNbr&&g?[a.title,a.value,a.participantsNbr]:[a.title,a.value]});return c.length>0?(c.unshift(d),angular.extend(f,{title:e}),{data:c,entries:b,options:f,vocabulary:a}):void 0})},g=a.getOptions().ChartsOptions;e.updateCriteria=function(a,b){c.createCriteriaItem("study","Mica_study",b,a).then(function(a){e.onUpdateCriteria(a,"studies")})},e.$watch("result",function(a){e.chartObjects={},e.noResults=!0,a&&a.studyResultDto.totalHits&&(e.noResults=!1,f("populations-selectionCriteria-countriesIso",a.studyResultDto,[d("translate")(g.geoChartOptions.header[0]),d("translate")(g.geoChartOptions.header[1])],d("translate")(g.geoChartOptions.title)+" (N = "+a.studyResultDto.totalHits+")",g.geoChartOptions.options).then(function(a){if(a){var b={geoChartOptions:{directiveTitle:a.options.title,headerTitle:d("translate")("graphics.geo-charts"),chartObject:{geoTitle:a.options.title,options:a.options,type:"GeoChart",vocabulary:a.vocabulary,data:a.data,entries:a.entries}}};b.geoChartOptions.getTable=function(){return b.geoChartOptions.chartObject},angular.extend(e.chartObjects,b)}}),f("methods-designs",a.studyResultDto,[d("translate")(g.studiesDesigns.header[0]),d("translate")(g.studiesDesigns.header[1])],d("translate")(g.studiesDesigns.title)+" (N = "+a.studyResultDto.totalHits+")",g.studiesDesigns.options).then(function(a){if(a){var b={studiesDesigns:{headerTitle:d("translate")("graphics.study-design"),chartObject:{options:a.options,type:"BarChart",data:a.data,vocabulary:a.vocabulary,entries:a.entries}}};angular.extend(e.chartObjects,b)}}),f("methods-designs",a.studyResultDto,[d("translate")(g.studiesDesigns.header[0]),d("translate")(g.studiesDesigns.header[1]),d("translate")(g.studiesDesigns.header[2])],d("translate")(g.studiesDesigns.title)+" (N = "+a.studyResultDto.totalHits+")",g.studiesDesigns.options,!0).then(function(a){if(a){var b={chartObjectTable:{options:a.options,type:"BarChart",data:a.data,vocabulary:a.vocabulary,entries:a.entries}};b.getTable=function(){return b.chartObjectTable},angular.extend(e.chartObjects.studiesDesigns,b)}}),f("numberOfParticipants-participant-range",a.studyResultDto,[d("translate")(g.numberParticipants.header[0]),d("translate")(g.numberParticipants.header[1])],d("translate")(g.numberParticipants.title)+" (N = "+a.studyResultDto.totalHits+")",g.numberParticipants.options).then(function(a){if(a){var b={numberParticipants:{headerTitle:d("translate")("graphics.number-participants"),chartObject:{options:a.options,type:"PieChart",data:a.data,vocabulary:a.vocabulary,entries:a.entries}}};b.numberParticipants.getTable=function(){return b.numberParticipants.chartObject},angular.extend(e.chartObjects,b)}}),f("populations-dataCollectionEvents-bioSamples",a.studyResultDto,[d("translate")(g.biologicalSamples.header[0]),d("translate")(g.biologicalSamples.header[1])],d("translate")(g.biologicalSamples.title)+" (N = "+a.studyResultDto.totalHits+")",g.biologicalSamples.options).then(function(a){if(a){var b={biologicalSamples:{headerTitle:d("translate")("graphics.bio-samples"),chartObject:{options:a.options,type:"BarChart",data:a.data,vocabulary:a.vocabulary,entries:a.entries}}};b.biologicalSamples.getTable=function(){return b.biologicalSamples.chartObject},angular.extend(e.chartObjects,b)}}))})}]).controller("SearchResultPaginationController",["$scope",function(a){function b(){a.maxSize=Math.min(3,Math.ceil(a.totalHits/a.pagination.selected.value))}function c(){var b=a.pagination.selected.value,c=a.pagination.currentPage;a.pagination.from=b*(c-1)+1,a.pagination.to=Math.min(a.totalHits,b*c)}var d=function(){c(),a.onChange&&a.onChange(a.target,(a.pagination.currentPage-1)*a.pagination.selected.value,a.pagination.selected.value)},e=function(){b(),a.pagination.currentPage=1,d()};a.pageChanged=d,a.pageSizeChanged=e,a.pageSizes=[{label:"10",value:10},{label:"20",value:20},{label:"50",value:50},{label:"100",value:100}],a.pagination={selected:a.pageSizes[0],currentPage:1},a.$watch("totalHits",function(){b(),c()})}]);var CRITERIA_ITEM_EVENT={deleted:"event:delete-criteria-item",refresh:"event:refresh-criteria-item"};angular.module("obiba.mica.search").directive("taxonomyPanel",[function(){return{restrict:"EA",replace:!0,scope:{taxonomy:"=",lang:"=",onNavigate:"="},templateUrl:"search/views/classifications/taxonomy-panel-template.html"}}]).directive("vocabularyPanel",[function(){return{restrict:"EA",replace:!0,scope:{target:"=",taxonomy:"=",vocabulary:"=",lang:"=",onNavigate:"=",onSelect:"=",onHideSearchNavigate:"=",isInHideNavigate:"="},templateUrl:"search/views/classifications/vocabulary-panel-template.html"}}]).directive("termPanel",[function(){return{restrict:"EA",replace:!0,scope:{target:"=",taxonomy:"=",vocabulary:"=",term:"=",lang:"=",onSelect:"="},templateUrl:"search/views/classifications/term-panel-template.html"}}]).directive("networksResultTable",["PageUrlService","ngObibaMicaSearch","RqlQueryService",function(a,b,c){return{restrict:"EA",replace:!0,scope:{summaries:"=",loading:"=",onUpdateCriteria:"="},templateUrl:"search/views/list/networks-search-result-table-template.html",link:function(d){d.options=b.getOptions().networks,d.optionsCols=d.options.networksColumn,d.PageUrlService=a,d.updateCriteria=function(a,b){var e;"HarmonizationDataset"!==b&&"StudyDataset"!==b||(e=b,b="datasets");var f;"DataschemaVariable"!==b&&"StudyVariable"!==b||(f=b.replace("Variable",""),b="variables"),c.createCriteriaItem("network","Mica_network","id",a).then(function(a){e?c.createCriteriaItem("dataset","Mica_dataset","className",e).then(function(c){d.onUpdateCriteria(a,b),d.onUpdateCriteria(c,b)}):f?c.createCriteriaItem("variable","Mica_variable","variableType",f).then(function(c){d.onUpdateCriteria(a,b),d.onUpdateCriteria(c,b)}):d.onUpdateCriteria(a,b)})}}}}]).directive("datasetsResultTable",["PageUrlService","ngObibaMicaSearch","TaxonomyResource","RqlQueryService",function(a,b,c,d){return{restrict:"EA",replace:!0,scope:{summaries:"=",loading:"=",onUpdateCriteria:"="},templateUrl:"search/views/list/datasets-search-result-table-template.html",link:function(e){e.classNames={},c.get({target:"dataset",taxonomy:"Mica_dataset"}).$promise.then(function(a){e.classNames=a.vocabularies.filter(function(a){return"className"===a.name})[0].terms.reduce(function(a,b){return a[b.name]=b.title.map(function(a){return{lang:a.locale,value:a.text}}),a},{})}),e.updateCriteria=function(a,b){d.createCriteriaItem("dataset","Mica_dataset","id",a).then(function(a){e.onUpdateCriteria(a,b)})},e.options=b.getOptions().datasets,e.optionsCols=e.options.datasetsColumn,e.PageUrlService=a}}}]).directive("studiesResultTable",["PageUrlService","ngObibaMicaSearch","TaxonomyResource","RqlQueryService","LocalizedValues",function(a,b,c,d,e){return{restrict:"EA",replace:!0,scope:{lang:"=",summaries:"=",loading:"=",onUpdateCriteria:"="},templateUrl:"search/views/list/studies-search-result-table-template.html",link:function(f){function g(){Object.keys(f.taxonomy)<1||Object.keys(f.datasourceTitles)>0||f.taxonomy.vocabularies.some(function(a){return"populations-dataCollectionEvents-dataSources"===a.name?(a.terms.forEach(function(a){f.datasourceTitles[a.name]={title:e.forLocale(a.title,f.lang)}}),!0):!1})}f.taxonomy={},f.designs={},f.datasourceTitles={},f.$watch("lang",g),c.get({target:"study",taxonomy:"Mica_study"}).$promise.then(function(a){f.taxonomy=a,g(),f.designs=a.vocabularies.filter(function(a){return"methods-designs"===a.name})[0].terms.reduce(function(a,b){return a[b.name]=b.title.map(function(a){return{lang:a.locale,value:a.text}}),a},{})}),f.hasDatasource=function(a,b){return a&&a.indexOf(b)>-1},f.options=b.getOptions().studies,f.optionsCols=f.options.studiesColumn,f.PageUrlService=a,f.updateCriteria=function(a,b){var c;"HarmonizationDataset"!==b&&"StudyDataset"!==b||(c=b,b="datasets");var e;"DataschemaVariable"!==b&&"StudyVariable"!==b||(e=b.replace("Variable",""),b="variables"),d.createCriteriaItem("study","Mica_study","id",a).then(function(a){
-c?d.createCriteriaItem("dataset","Mica_dataset","className",c).then(function(c){f.onUpdateCriteria(a,b),f.onUpdateCriteria(c,b)}):e?d.createCriteriaItem("variable","Mica_variable","variableType",e).then(function(c){f.onUpdateCriteria(a,b),f.onUpdateCriteria(c,b)}):f.onUpdateCriteria(a,b)})}}}}]).directive("variablesResultTable",["PageUrlService","ngObibaMicaSearch",function(a,b){return{restrict:"EA",replace:!0,scope:{summaries:"=",loading:"="},templateUrl:"search/views/list/variables-search-result-table-template.html",link:function(c){c.options=b.getOptions().variables,c.optionsCols=c.options.variablesColumn,c.PageUrlService=a}}}]).directive("coverageResultTable",[function(){return{restrict:"EA",replace:!0,scope:{result:"=",loading:"=",bucket:"=",query:"=",onUpdateCriteria:"=",onRemoveCriteria:"="},controller:"CoverageResultTableController",templateUrl:"search/views/coverage/coverage-search-result-table-template.html"}}]).directive("graphicsResult",[function(){return{restrict:"EA",replace:!0,scope:{result:"=",loading:"=",onUpdateCriteria:"="},controller:"GraphicsResultController",templateUrl:"search/views/graphics/graphics-search-result-template.html"}}]).directive("includeReplace",function(){return{require:"ngInclude",link:function(a,b){b.replaceWith(b.children())}}}).directive("scrollToTop",function(){return{restrict:"A",scope:{trigger:"=scrollToTop"},link:function(a,b){a.$watch("trigger",function(){b[0].scrollTop=0})}}}).directive("resultPanel",[function(){return{restrict:"EA",replace:!0,scope:{type:"=",bucket:"=",query:"=",display:"=",result:"=",lang:"=",loading:"=",searchTabsOrder:"=",resultTabsOrder:"=",onTypeChanged:"=",onBucketChanged:"=",onPaginate:"=",onUpdateCriteria:"=",onRemoveCriteria:"="},controller:"SearchResultController",templateUrl:"search/views/search-result-panel-template.html"}}]).directive("criteriaRoot",[function(){return{restrict:"EA",replace:!0,scope:{item:"=",query:"=",advanced:"=",onRemove:"=",onRefresh:"="},templateUrl:"search/views/criteria/criteria-root-template.html",link:function(a){a.$on(CRITERIA_ITEM_EVENT.deleted,function(b,c){a.onRemove(c)}),a.$on(CRITERIA_ITEM_EVENT.refresh,function(){a.onRefresh()})}}}]).directive("criteriaTarget",[function(){return{restrict:"EA",replace:!0,scope:{item:"=",query:"=",advanced:"="},templateUrl:"search/views/criteria/criteria-target-template.html"}}]).directive("criteriaNode",[function(){return{restrict:"EA",replace:!0,scope:{item:"=",query:"=",advanced:"="},controller:"CriterionLogicalController",templateUrl:"search/views/criteria/criteria-node-template.html"}}]).directive("criteriaLeaf",["CriteriaNodeCompileService",function(a){return{restrict:"EA",replace:!0,scope:{item:"=",query:"=",advanced:"="},controller:"CriterionLogicalController",link:function(b,c){a.compile(b,c)}}}]).directive("numericCriterion",[function(){return{restrict:"EA",replace:!0,scope:{criterion:"=",query:"=",state:"="},controller:"NumericCriterionController",templateUrl:"search/views/criteria/criterion-numeric-template.html"}}]).directive("criterionDropdown",["$document","$timeout",function(a,b){return{restrict:"EA",replace:!0,scope:{criterion:"=",query:"="},controller:"CriterionDropdownController",templateUrl:"search/views/criteria/criterion-dropdown-template.html",link:function(c,d){var e=function(a){var d=document.querySelector("#"+c.criterion.id.replace(".","-")+"-dropdown-"+c.timestamp).contains(a.target);d||b(function(){c.$apply("closeDropdown()")})};a.on("click",e),d.on("$destroy",function(){a.off("click",e)})}}}]).directive("stringCriterionTerms",[function(){return{restrict:"EA",replace:!0,scope:{criterion:"=",query:"=",state:"="},controller:"StringCriterionTermsController",templateUrl:"search/views/criteria/criterion-string-terms-template.html"}}]).directive("matchCriterion",[function(){return{restrict:"EA",replace:!0,scope:{criterion:"=",query:"=",state:"="},controller:"MatchCriterionTermsController",templateUrl:"search/views/criteria/criterion-match-template.html"}}]).directive("searchResultPagination",[function(){return{restrict:"EA",replace:!0,scope:{target:"=",totalHits:"=",onChange:"="},controller:"SearchResultPaginationController",templateUrl:"search/views/list/search-result-pagination-template.html"}}]).directive("taxonomiesFacetsPanel",[function(){return{restrict:"EA",scope:{facetedTaxonomies:"=",onRefresh:"=",onSelectTerm:"=",lang:"=",criteria:"="},controller:"TaxonomiesFacetsController",templateUrl:"search/views/classifications/taxonomies-facets-view.html"}}]).directive("taxonomiesPanel",[function(){return{restrict:"EA",replace:!0,scope:{taxonomyName:"=",target:"=",onClose:"=",onSelectTerm:"=",taxonomiesShown:"=",lang:"="},controller:"TaxonomiesPanelController",templateUrl:"search/views/classifications/taxonomies-view.html",link:function(a,b){a.closeTaxonomies=function(){b.collapse("hide"),a.onClose()},a.showTaxonomies=function(){b.collapse("show")},b.on("show.bs.collapse",function(){a.taxonomiesShown=!0}),b.on("hide.bs.collapse",function(){a.taxonomiesShown=!1}),a.$watch("taxonomiesShown",function(a){a?b.collapse("show"):b.collapse("hide")})}}}]).directive("classificationsPanel",[function(){return{restrict:"EA",replace:!0,scope:{target:"=",onSelectTerm:"=",isHistoryEnabled:"=",lang:"="},controller:"ClassificationPanelController",templateUrl:"search/views/classifications/classifications-view.html"}}]).factory("Fullscreen",["$document","$window","$rootScope",function(a,b,c){var d=a[0],e="undefined"!=typeof b.Element&&"ALLOW_KEYBOARD_INPUT"in b.Element&&b.Element.ALLOW_KEYBOARD_INPUT,f=c.$new(),g={$on:angular.bind(f,f.$on),enable:function(a){a.requestFullScreen?a.requestFullScreen():a.mozRequestFullScreen?a.mozRequestFullScreen():a.webkitRequestFullscreen?/Version\/[\d]{1,2}(\.[\d]{1,2}){1}(\.(\d){1,2}){0,1} Safari/.test(b.navigator.userAgent)?a.webkitRequestFullscreen():a.webkitRequestFullscreen(e):a.msRequestFullscreen&&a.msRequestFullscreen()},cancel:function(){d.cancelFullScreen?d.cancelFullScreen():d.mozCancelFullScreen?d.mozCancelFullScreen():d.webkitExitFullscreen?d.webkitExitFullscreen():d.msExitFullscreen&&d.msExitFullscreen()},isEnabled:function(){var a=d.fullscreenElement||d.mozFullScreenElement||d.webkitFullscreenElement||d.msFullscreenElement;return!!a}};return a.on("fullscreenchange webkitfullscreenchange mozfullscreenchange MSFullscreenChange",function(){f.$emit("ngObibaMicaSearch.fullscreenChange",g.isEnabled())}),g}]).directive("fullscreen",["Fullscreen",function(a){return{link:function(b,c,d){d.fullscreen&&b.$watch(d.fullscreen,function(b){var d=a.isEnabled();b&&!d?(a.enable(c[0]),c.addClass("isInFullScreen")):!b&&d&&(a.cancel(),c.removeClass("isInFullScreen"))})}}}]),angular.module("obiba.mica.search").config(["$routeProvider",function(a){a.when("/search",{templateUrl:"search/views/search.html",controller:"SearchController",reloadOnSearch:!1}).when("/classifications",{templateUrl:"search/views/classifications.html",controller:"SearchController",reloadOnSearch:!1})}]),angular.module("obiba.mica.graphics",["googlechart","obiba.utils","templates-ngObibaMica"]).config(["$provide",function(a){a.provider("GraphicChartsData",GraphicChartsDataProvider)}]).run(["GraphicChartsConfigurations",function(a){a.setClientConfig()}]),angular.module("obiba.mica.graphics").directive("obibaChart",[function(){return{restrict:"EA",replace:!0,scope:{fieldTransformer:"=",chartType:"=",chartAggregationName:"=",chartEntityDto:"=",chartOptionsName:"=",chartOptions:"=",chartHeader:"=",chartTitle:"=",chartTitleGraph:"=",chartSelectGraphic:"="},templateUrl:"graphics/views/charts-directive.html",controller:"GraphicChartsController"}}]).directive("obibaTable",[function(){return{restrict:"EA",replace:!0,scope:{fieldTransformer:"=",chartType:"@",chartAggregationName:"=",chartEntityDto:"=",chartOptionsName:"=",chartOptions:"=",chartHeader:"=",chartTitle:"=",chartTitleGraph:"=",chartSelectGraphic:"=",chartOrdered:"=",chartNotOrdered:"="},templateUrl:"graphics/views/tables-directive.html",controller:"GraphicChartsController"}}]),angular.module("obiba.mica.graphics").controller("GraphicChartsController",["$rootScope","$scope","$filter","$window","GraphicChartsConfig","GraphicChartsUtils","GraphicChartsData","RqlQueryService","ngObibaMicaUrl","googleChartApiPromise",function(a,b,c,d,e,f,g,h,i,j){function k(){b.chartObject={},g.getData(function(a){a&&f.getArrayByAggregation(b.chartAggregationName,a[b.chartEntityDto]).then(function(f){var g=f.map(function(a){return a.participantsNbr?[a.title,a.value,a.participantsNbr]:[a.title,a.value]});b.updateCriteria=function(a,b){h.createCriteriaItem("study","Mica_study",b,a).then(function(a){var b=e.getOptions().entityType,c=e.getOptions().entityIds,f=a.id.split("."),g=i.getUrl("GraphicsSearchRootUrl")+"?type=studies&query="+b+"(in(Mica_"+b+".id,"+c+")),study(in("+f[0]+"."+f[1]+","+f[2].replace(":","%253A")+"))";d.location.href=i.getUrl("BaseUrl")+g})},g&&(null!==/^Table-/.exec(b.chartType)?(b.chartObject.ordered=b.chartOrdered,b.chartObject.notOrdered=b.chartNotOrdered,b.chartHeader.length<3?b.chartObject.header=[c("translate")(b.chartHeader[0]),c("translate")(b.chartHeader[1])]:b.chartObject.header=[c("translate")(b.chartHeader[0]),c("translate")(b.chartHeader[1]),c("translate")(b.chartHeader[2])],b.chartObject.type=b.chartType,b.chartObject.data=g,b.chartObject.vocabulary=b.chartAggregationName,b.chartObject.entries=f,b.chartObject.getTable=function(){return b.chartObject}):(b.chartHeader.length<3?g.unshift([c("translate")(b.chartHeader[0]),c("translate")(b.chartHeader[1])]):(g.map(function(a){return a.pop(),a}),g.unshift([c("translate")(b.chartHeader[0]),c("translate")(b.chartHeader[1])])),b.chartObject.term=!0,b.chartObject.type=b.chartType,b.chartObject.data=g,b.chartObject.options={backgroundColor:{fill:"transparent"}},angular.extend(b.chartObject.options,b.chartOptions),b.chartObject.options.title=c("translate")(b.chartTitleGraph)+" (N="+a.studyResultDto.totalHits+")",b.$parent.directive={title:b.chartObject.options.title}))})})}j.then(function(){b.ready=!0}),b.$watchGroup(["chartType","ready"],function(){b.chartType&&b.ready&&k()})}]),angular.module("obiba.mica.graphics").factory("GraphicChartsDataResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("JoinQuerySearchResource"),{},{studies:{method:"GET",errorHandler:!0,params:{type:"studies"}}})}]).service("GraphicChartsConfig",function(){var a={options:{entityIds:"NaN",entityType:null,ChartsOptions:{geoChartOptions:{header:["graphics.country","graphics.nbr-studies"],title:"graphics.geo-chart-title",options:{backgroundColor:{fill:"transparent"},colors:["#e5edfb","#cfddf5","#b8cbed","#a0b8e2","#88a4d4"]}},studiesDesigns:{header:["graphics.study-design","graphics.nbr-studies","graphics.number-participants"],title:"graphics.study-design-chart-title",options:{bars:"horizontal",series:{0:{axis:"nbrStudies"},1:{axis:"nbrParticipants"}},axes:{x:{nbrStudies:{side:"top",label:"Number of Studies"},nbrParticipants:{label:"Number of Participants"}}},backgroundColor:{fill:"transparent"},colors:["#b8cbed","#e5edfb","#cfddf5","#a0b8e2","#88a4d4"]}},numberParticipants:{header:["graphics.number-participants","graphics.nbr-studies"],title:"graphics.number-participants-chart-title",options:{backgroundColor:{fill:"transparent"},colors:["#b8cbed","#e5edfb","#cfddf5","#a0b8e2","#88a4d4"],pieSliceTextStyle:{color:"#000000"}}},biologicalSamples:{header:["graphics.bio-samples","graphics.nbr-studies"],title:"graphics.bio-samples-chart-title",options:{bars:"horizontal",series:{0:{axis:"nbrStudies"}},axes:{x:{nbrStudies:{side:"top",label:"Number of Studies"}}},backgroundColor:{fill:"transparent"},colors:["#b8cbed","#e5edfb","#cfddf5","#a0b8e2","#88a4d4"]}}}}};return a.setOptions=function(b){"object"==typeof b&&Object.keys(b).forEach(function(c){c in a.options&&(a.options[c]=b[c])})},a.getOptions=function(){return angular.copy(a.options)},a}).service("GraphicChartsUtils",["LocalizedValues","TaxonomyResource","$q",function(a,b,c){var d={};d.getTerms=function(a){function e(){var b=null;d.vocabularies&&angular.forEach(d.vocabularies,function(c){c.name===a&&(b=c.terms)}),f.resolve(b)}var f=c.defer();return d.vocabularies?e():b.get({target:"study",taxonomy:"Mica_study"}).$promise.then(function(a){d.vocabularies=angular.copy(a.vocabularies),e()}),f.promise},this.getArrayByAggregation=function(b,e){var f=c.defer();b&&e||f.resolve([]);var g=[];return d.getTerms(b).then(function(c){var d=c,h=0;angular.forEach(e.aggs,function(c){if(c.aggregation===b)if(c["obiba.mica.RangeAggregationResultDto.ranges"])h=0,angular.forEach(d,function(a){angular.forEach(c["obiba.mica.RangeAggregationResultDto.ranges"],function(b){a.name===b.key&&b.count&&(g[h]={title:b.title,value:b.count,key:b.key},h++)})});else{if("populations-selectionCriteria-countriesIso"===c.aggregation){var e=a.getLocal();d.sort(function(b,c){var d=a.forLocale(b.title,e),f=a.forLocale(c.title,e);return f>d?-1:d>f?1:0})}var f=0;h=0,angular.forEach(d,function(b){angular.forEach(c["obiba.mica.TermsAggregationResultDto.terms"],function(d){b.name===d.key&&d.count&&("methods-designs"===c.aggregation?(angular.forEach(d.aggs,function(b){if("numberOfParticipants-participant-number"===b.aggregation){var c=b["obiba.mica.StatsAggregationResultDto.stats"];f=a.formatNumber(c?c.data.sum:0)}}),g[h]={title:d.title,value:d.count,participantsNbr:f,key:d.key}):g[h]={title:d.title,value:d.count,key:d.key},h++)})})}}),f.resolve(g)}),f.promise}}]).service("GraphicChartsQuery",["RqlQueryService","RqlQueryUtils","LocalizedValues",function(a,b,c){this.queryDtoBuilder=function(d,e){var f;d&&"NaN"!==d||(f="study(exists(Mica_study.id))"),e&&"NaN"!==d&&(f=e+"(in(Mica_"+e+".id,("+d+")))");var g=angular.copy((new RqlParser).parse(f));b.addLocaleQuery(g,c.getLocal());var h=(new RqlQuery).serializeArgs(g.args);return a.prepareGraphicsQuery(h,["Mica_study.populations-selectionCriteria-countriesIso","Mica_study.populations-dataCollectionEvents-bioSamples","Mica_study.numberOfParticipants-participant-number"],["Mica_study.methods-designs"])}}]),angular.module("obiba.mica.localized",["obiba.notification","pascalprecht.translate","templates-ngObibaMica"]),angular.module("obiba.mica.localized").directive("localized",["LocalizedValues",function(a){return{restrict:"AE",scope:{value:"=",lang:"="},templateUrl:"localized/localized-template.html",link:function(b){b.LocalizedValues=a}}}]).directive("localizedNumber",["LocalizedValues",function(a){return{restrict:"E",scope:{number:"=value"},template:"{{LocalizedValues.formatNumber(number)}}",link:function(b){b.LocalizedValues=a}}}]).directive("localizedInput",[function(){return{restrict:"AE",require:"^form",scope:{name:"@",model:"=",label:"@",required:"@",disabled:"=",lang:"=",help:"@",customValidator:"="},templateUrl:"localized/localized-input-template.html",link:function(a,b,c,d){(angular.isUndefined(a.model)||null===a.model)&&(a.model=[{lang:a.lang,value:""}]),a.$watch("model",function(b){(angular.isUndefined(b)||null===b)&&(a.model=[{lang:a.lang,value:""}]);var c=a.model.filter(function(b){return b.lang===a.lang?b:void 0});0===c.length&&a.model.push({lang:a.lang,value:""})},!0),a.fieldName=a.name+"-"+a.lang,a.form=d}}}]).directive("localizedInputGroup",[function(){return{restrict:"AE",require:"^form",scope:{name:"@",model:"=",label:"@",required:"@",disabled:"=",lang:"=",help:"@",remove:"=",customValidator:"="},templateUrl:"localized/localized-input-group-template.html",link:function(a,b,c,d){(angular.isUndefined(a.model)||null===a.model)&&(a.model=[{lang:a.lang,value:""}]),a.$watch("model",function(b){(angular.isUndefined(b)||null===b)&&(a.model=[{lang:a.lang,value:""}]);var c=a.model.filter(function(b){return b.lang===a.lang?b:void 0});0===c.length&&a.model.push({lang:a.lang,value:""})},!0),a.fieldName=a.name+"-"+a.lang,a.form=d}}}]).directive("localizedTextarea",[function(){return{restrict:"AE",require:"^form",scope:{name:"@",model:"=",label:"@",required:"@",disabled:"=",lang:"=",help:"@",rows:"@",customValidator:"="},templateUrl:"localized/localized-textarea-template.html",link:function(a,b,c,d){(angular.isUndefined(a.model)||null===a.model)&&(a.model=[{lang:a.lang,value:""}]),a.$watch("model",function(b){(angular.isUndefined(b)||null===b)&&(a.model=[{lang:a.lang,value:""}]);var c=a.model.filter(function(b){return b.lang===a.lang?b:void 0});0===c.length&&a.model.push({lang:a.lang,value:""})},!0),a.fieldName=a.name+"-"+a.lang,a.form=d}}}]),angular.module("obiba.mica.localized").service("LocalizedValues",function(){var a=this;this["for"]=function(b,c,d,e){if(angular.isArray(b)){var f=b.filter(function(a){return a[d]===c});if(f&&f.length>0)return f[0][e]}else if(angular.isObject(b))return a["for"](Object.keys(b).map(function(a){return{lang:a,value:b[a]}}),c,d,e);return""},this.forLocale=function(a,b){var c=this["for"](a,b,"locale","text");return""===c&&(c=this["for"](a,"und","locale","text")),c},this.forLang=function(a,b){var c=this["for"](a,b,"lang","value");return""===c&&(c=this["for"](a,"und","lang","value")),c},this.getLocal=function(){return"en"},this.formatNumber=function(a){return"undefined"==typeof a&&null===a&&"number"!=typeof a?a:a.toLocaleString(this.getLocal())},this.arrayToObject=function(a){var b={};return a&&a.forEach(function(a){b[a.lang]=a.value}),b},this.objectToArray=function(a,b){var c=[];return b&&a&&a.forEach(function(a){c.push({lang:a,value:b[a]})}),c}}).service("LocalizedSchemaFormService",["$filter",function(a){this.translate=function(a){return a?"string"==typeof a?this.translateString(a):"object"==typeof a?Array.isArray(a)?this.translateArray(a):this.translateObject(a):a:a},this.translateObject=function(a){if(!a)return a;for(var b in a)a.hasOwnProperty(b)&&("string"==typeof a[b]?a[b]=this.translateString(a[b]):"object"==typeof a[b]&&(Array.isArray(a[b])?a[b]=this.translateArray(a[b]):a[b]=this.translateObject(a[b])));return a},this.translateArray=function(a){if(!a)return a;var b=this;return a.map(function(a){return b.translate(a)}),a},this.translateString=function(b){return b?b.replace(/t\(([^\)]+)\)/g,function(b,c){return a("translate")(c)}):b}}]),angular.module("obiba.mica.localized").filter("localizedNumber",["LocalizedValues",function(a){return function(b){return 0===b?0:b?a.formatNumber(b):""}}]),angular.module("obiba.mica.fileBrowser",["pascalprecht.translate","ui.bootstrap","templates-ngObibaMica"]).config(["$provide",function(a){a.provider("ngObibaMicaFileBrowserOptions",new NgObibaMicaFileBrowserOptionsProvider)}]),angular.module("obiba.mica.fileBrowser").directive("fileBrowser",[function(){return{restrict:"EA",replace:!0,controller:"FileBrowserController",scope:{docPath:"@",docId:"@",subject:"="},templateUrl:"file-browser/views/file-browser-template.html"}}]),angular.module("obiba.mica.fileBrowser").controller("FileBrowserController",["$rootScope","$scope","$log","$filter","StringUtils","FileBrowserService","BrowserBreadcrumbHelper","AlertService","ServerErrorUtils","FileBrowserFileResource","FileBrowserSearchResource","ngObibaMicaFileBrowserOptions","FileBrowserDownloadService",function(a,b,c,d,e,f,g,h,i,j,k,l,m){function n(){b.data.search.text=null,b.data.search.active=!1}function o(a){b.data.search.active=!1,j.get({path:a},function(d){c.info(d),b.pagination.selected=-1,b.data.document=b.data.details.document=d,b.data.document.children||(b.data.document.children=[]),b.data.document.path===b.data.rootPath&&(b.data.document.children=b.data.document.children.filter(function(a){return l.folders.excludes.indexOf(a.name)<0}),b.data.document.size=b.data.document.children.length),b.data.breadcrumbs=g.toArray(a,b.data.rootPath),b.data.isFile=f.isFile(d),b.data.isRoot=f.isRoot(d)},v)}function p(a,b){a.stopPropagation();var c=b.path;c=0===c.lastIndexOf("/")?"/":c.substring(0,c.lastIndexOf("/")),t(c)}function q(){if(!b.data.isRoot&&b.data.document){var a=b.data.document.path.replace(/\\/g,"/").replace(/\/[^\/]*$/,"");o(a?a:"/")}}function r(){b.pagination.selected=-1,b.data.details.show=!1}function s(a,d){function e(b){var c="";try{var d=[];l.folders.excludes.forEach(function(b){var c=a.replace(/\//g,"\\/")+"\\/"+b.replace(/\s/,"\\ ");d.push(c),d.push(c+"\\/*")}),c=d.length>0?"NOT path:("+d.join(" OR ")+")":""}catch(e){}return b?b+" AND "+c:c}d.query=e(d.query);var f=angular.extend({},{path:a},d);k.search(f,function(a){c.info("Search result",a);var d=b.data.document?angular.copy(b.data.document):{};d.children=a,b.data.document=d},function(a){c.debug("ERROR:",a)})}var t=function(a){n(),o(a)},u=function(a,b){a.stopPropagation(),b&&t(b.path)},v=function(a){h.alert({id:"FileSystemController",type:"danger",msg:i.buildMessage(a)}),403!==a.status&&b.data.document&&u(b.data.document)},w=function(a){b.data.search.active=!0,r();var c=b.data.search.recursively,d=null,e=null,f=999;switch(b.data.search.query=a,a){case"RECENT":a="",d="desc",e="lastModifiedDate",f=10}var g={query:a,recursively:c,sort:e,order:d,limit:f};s(b.data.document.path,g)},x=function(){b.data.search.recursively=!b.data.search.recursively,b.data.search.text?w(b.data.search.text):b.data.search.query&&w(b.data.search.query)},y=function(){n(),o(b.data.document.path)},z=function(a){switch(a.keyCode){case 13:b.data.search.text?w(b.data.search.text):y();break;case 27:b.data.search.active&&y()}},A=function(a,c){b.pagination.selected=c,b.data.details.document=a,b.data.details.show=!0},B=function(a){return f.isFile(a)&&a.attachment.type?a.attachment.type.split(/,|\s+/):[]},C=function(a){return f.getLocalizedValue(a,l.locale)},D=function(a){return f.hasLocalizedValue(a,l.locale)};b.downloadTarget=l.downloadInline?"_blank":"_self",b.getDownloadUrl=m.getUrl,b.screen=a.screen,b.truncate=e.truncate,b.getDocumentIcon=f.getDocumentIcon,b.navigateToPath=t,b.navigateTo=u,b.navigateBack=q,b.navigateToParent=p,b.clearSearch=y,b.searchDocuments=w,b.toggleRecursively=x,b.searchKeyUp=z,b.isFile=f.isFile,b.isRoot=f.isRoot,b.getLocalizedValue=C,b.hasLocalizedValue=D,b.hideDetails=r,b.showDetails=A,b.getTypeParts=B,b.pagination={selected:-1,currentPage:1,itemsPerPage:20},b.data={details:{document:null,show:!1},docRootIcon:null,rootPath:null,document:null,accesses:[],search:{text:null,active:!1,recursively:!0},breadcrumbs:null,isFile:!1,isRoot:!1,editDescField:!1},b.$watchGroup(["docPath","docId"],function(){b.docPath&&b.docId&&(b.data.docRootIcon=g.rootIcon(b.docPath),b.data.rootPath=b.docPath+("null"!==b.docId?"/"+b.docId:""),o(b.data.rootPath,null))})}]),angular.module("obiba.mica.fileBrowser").factory("FileBrowserFileResource",["$resource","ngObibaMicaUrl",function(a,b){var c=b.getUrl("FileBrowserFileResource");return console.log("PATH>",c),a(c,{path:"@path"},{get:{method:"GET",errorHandler:!0}})}]).factory("FileBrowserSearchResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("FileBrowserSearchResource"),{path:"@path"},{search:{method:"GET",isArray:!0,errorHandler:!0}})}]).service("FileBrowserDownloadService",["ngObibaMicaUrl","ngObibaMicaFileBrowserOptions",function(a,b){return this.getUrl=function(c){return a.getUrl("FileBrowserDownloadUrl").replace(/:path/,c).replace(/:inline/,b.downloadInline)},this}]).service("FileBrowserService",[function(){this.isFile=function(a){return a&&"FILE"===a.type},this.isRoot=function(a){return a&&"/"===a.path},this.getLocalizedValue=function(a,b){if(!a)return null;var c=a.filter(function(a){return a.lang===b});return c&&c.length>0?c[0].value:null},this.hasLocalizedValue=function(a,b){var c=this.getLocalizedValue(a,b);return null!==c&&c.trim().length>0},this.getDocumentIcon=function(a){if(!a)return"";if("FOLDER"===a.type)return"fa-folder";var b=a.path.match(/\.(\w+)$/);if(b&&b.length>1)switch(b[1].toLowerCase()){case"doc":case"docx":case"odm":case"gdoc":return"fa-file-word-o";case"xls":case"xlsx":return"fa-file-excel-o";case"pdf":return"fa-file-pdf-o";case"ppt":case"odt":return"fa-file-powerpoint-o";case"xt":return"fa-file-text-o"}return"fa-file"}}]).service("BrowserBreadcrumbHelper",[function(){this.toArray=function(a,b){if(a){a=a.replace(b,"");var c=a.replace(/\/$/,"").split("/").slice(1),d=[],e=null;return c.forEach(function(a){e=(null===e?b:e)+"/"+a,d.push({name:a,path:e})}),d}return[{name:"",path:""}]},this.rootIcon=function(a){var b=/^\/([^\/]*)/.exec(a);switch(b?b[1]:""){case"study":return"i-obiba-study";case"network":return"i-obiba-network";case"study-dataset":return"i-obiba-study-dataset";case"harmonization-dataset":return"i-obiba-harmo-dataset";default:return"fa fa-hdd-o"}}}]),angular.module("templates-ngObibaMica",["access/views/data-access-request-documents-view.html","access/views/data-access-request-form.html","access/views/data-access-request-history-view.html","access/views/data-access-request-list.html","access/views/data-access-request-print-preview.html","access/views/data-access-request-profile-user-modal.html","access/views/data-access-request-submitted-modal.html","access/views/data-access-request-validation-modal.html","access/views/data-access-request-view.html","attachment/attachment-input-template.html","attachment/attachment-list-template.html","file-browser/views/document-detail-template.html","file-browser/views/documents-table-template.html","file-browser/views/file-browser-template.html","file-browser/views/toolbar-template.html","graphics/views/charts-directive.html","graphics/views/tables-directive.html","localized/localized-input-group-template.html","localized/localized-input-template.html","localized/localized-template.html","localized/localized-textarea-template.html","search/views/classifications.html","search/views/classifications/classifications-view.html","search/views/classifications/taxonomies-facets-view.html","search/views/classifications/taxonomies-view.html","search/views/classifications/taxonomy-accordion-group.html","search/views/classifications/taxonomy-panel-template.html","search/views/classifications/taxonomy-template.html","search/views/classifications/term-panel-template.html","search/views/classifications/vocabulary-accordion-group.html","search/views/classifications/vocabulary-panel-template.html","search/views/coverage/coverage-search-result-table-template.html","search/views/criteria/criteria-node-template.html","search/views/criteria/criteria-root-template.html","search/views/criteria/criteria-target-template.html","search/views/criteria/criterion-dropdown-template.html","search/views/criteria/criterion-header-template.html","search/views/criteria/criterion-match-template.html","search/views/criteria/criterion-numeric-template.html","search/views/criteria/criterion-string-terms-template.html","search/views/criteria/target-template.html","search/views/graphics/graphics-search-result-template.html","search/views/list/datasets-search-result-table-template.html","search/views/list/networks-search-result-table-template.html","search/views/list/pagination-template.html","search/views/list/search-result-pagination-template.html","search/views/list/studies-search-result-table-template.html","search/views/list/variables-search-result-table-template.html","search/views/search-result-coverage-template.html","search/views/search-result-graphics-template.html","search/views/search-result-list-dataset-template.html","search/views/search-result-list-network-template.html","search/views/search-result-list-study-template.html","search/views/search-result-list-template.html","search/views/search-result-list-variable-template.html","search/views/search-result-panel-template.html","search/views/search.html","views/pagination-template.html"]),angular.module("access/views/data-access-request-documents-view.html",[]).run(["$templateCache",function(a){a.put("access/views/data-access-request-documents-view.html",'\n\n')}]),angular.module("access/views/data-access-request-form.html",[]).run(["$templateCache",function(a){a.put("access/views/data-access-request-form.html",'\n\n\n')}]),angular.module("access/views/data-access-request-history-view.html",[]).run(["$templateCache",function(a){a.put("access/views/data-access-request-history-view.html",'\n\n\n \n \n \n status \n changed-by \n changed-on \n \n \n \n \n \n {{info.msg}} \n {{userProfileService.getFullName(status.profile) || status.author}} \n \n \n {{status.changedOn | amCalendar}}\n \n \n \n \n
\n')}]),angular.module("access/views/data-access-request-list.html",[]).run(["$templateCache",function(a){
-a.put("access/views/data-access-request-list.html",'\n\n\n')}]),angular.module("access/views/data-access-request-print-preview.html",[]).run(["$templateCache",function(a){a.put("access/views/data-access-request-print-preview.html",'\n
\n\n
\n\n
\n\n
\n
data-access-request.submissionDate \n
{{lastSubmittedDate | amDateFormat:\'dddd, MMMM Do YYYY\' | capitalizeFirstLetter}}
\n
\n
\n')}]),angular.module("access/views/data-access-request-profile-user-modal.html",[]).run(["$templateCache",function(a){a.put("access/views/data-access-request-profile-user-modal.html",'\n \n
\n\n
\n \n \n {{\'data-access-request.profile.name\' | translate}} \n {{getFullName(applicant)}} \n \n \n {{\'data-access-request.profile.email\' | translate}} \n {{getProfileEmail(applicant)}} \n \n \n {{attribute.key | translate}} \n {{attribute.value}} \n \n \n
\n\n
\n {{\'data-access-request.profile.send-email\' | translate}} \n
\n \n
\n')}]),angular.module("access/views/data-access-request-submitted-modal.html",[]).run(["$templateCache",function(a){a.put("access/views/data-access-request-submitted-modal.html",'\n\n\n\n \n
\n
{{\'data-access-request.submit-confirmation.message\' | translate}}
\n
\n \n
\n')}]),angular.module("access/views/data-access-request-validation-modal.html",[]).run(["$templateCache",function(a){a.put("access/views/data-access-request-validation-modal.html",'\n \n
\n
{{\'data-access-request.validation.success\' | translate}}
\n
{{\'data-access-request.validation.error\' | translate}}
\n
\n \n
\n')}]),angular.module("access/views/data-access-request-view.html",[]).run(["$templateCache",function(a){a.put("access/views/data-access-request-view.html",'\n\n\n
\n
\n
\n\n
\n\n
\n\n
created-by \n \n {{getFullName(dataAccessRequest.profile) || dataAccessRequest.applicant}}\n \n \n {{getFullName(dataAccessRequest.profile) || dataAccessRequest.applicant}} ,\n {{dataAccessRequest.timestamps.created | amCalendar}} \n {{dataAccessRequest.status | translate}}
\n\n
\n\n
\n\n
\n\n
\n \n \n \n \n \n {{config.documentsSectionTitle || \'data-access-request.documents\' | translate}}\n {{dataAccessRequest.attachments.length}} \n \n
\n \n \n \n \n \n \n
\n \n \n
\n
\n\n
\n')}]),angular.module("attachment/attachment-input-template.html",[]).run(["$templateCache",function(a){a.put("attachment/attachment-input-template.html",'file.upload.button\n \n\n\n \n \n \n {{file.fileName}}\n \n {{file.progress}}%\n \n \n \n {{file.timestamps.created | amCalendar }} \n \n \n \n {{file.size | bytes}}\n \n \n \n \n \n \n \n \n \n \n \n \n
\n')}]),angular.module("attachment/attachment-list-template.html",[]).run(["$templateCache",function(a){a.put("attachment/attachment-list-template.html",'\n
{{emptyMessage}} \n
\n \n \n \n {{attachment.fileName}}\n \n \n {{attachment.timestamps.created | amCalendar }} \n \n \n {{attachment.size | bytes}}\n \n \n \n \n
\n\n
\n')}]),angular.module("file-browser/views/document-detail-template.html",[]).run(["$templateCache",function(a){a.put("file-browser/views/document-detail-template.html",'\n\n\n
\n
\n \n {{truncate(data.details.document.name, 30)}}\n \n \n \n
\n
\n
\n
\n {{\'size\' | translate}} \n \n
\n
{{data.details.document.size}} {{data.details.document.size === 1 ? \'item\' : \'items\' | translate}} \n
{{data.details.document.size | bytes}} \n
\n \n \n
\n
\n\n
\n
\n {{\'created-on\' | translate}} \n \n
\n {{data.details.document.timestamps.created | amDateFormat : \'lll\'}} \n
\n
\n
\n
\n {{\'last-modified\' | translate}} \n \n
\n {{data.details.document.timestamps.lastUpdate | amDateFormat : \'lll\'}} \n
\n
\n\n
\n
\n
\n {{\'type\' | translate}} \n \n
\n {{data.details.document.attachment.type}} \n
\n
\n\n
\n
\n {{\'description\' | translate}} \n \n
\n {{getLocalizedValue(data.details.document.attachment.description)}} \n
\n
\n
\n
\n
\n')}]),angular.module("file-browser/views/documents-table-template.html",[]).run(["$templateCache",function(a){a.put("file-browser/views/documents-table-template.html",'\n
\n
\n \n \n
{{\'file.search-results.current-sub\' | translate}} \n
{{\'file.search-results.current\' | translate}} \n ({{data.document.children.length}})\n
\n
\n
")}]),angular.module("file-browser/views/file-browser-template.html",[]).run(["$templateCache",function(a){a.put("file-browser/views/file-browser-template.html",'\n
\n\n
\n
\n\n
\n \n
\n\n
\n
\n
\n
\n {{\'empty-folder\' | translate}} \n
\n
\n \n
\n
\n
\n
\n
\n
\n\n
')}]),angular.module("file-browser/views/toolbar-template.html",[]).run(["$templateCache",function(a){a.put("file-browser/views/toolbar-template.html",'\n')}]),angular.module("graphics/views/charts-directive.html",[]).run(["$templateCache",function(a){a.put("graphics/views/charts-directive.html",'\n')}]),angular.module("graphics/views/tables-directive.html",[]).run(["$templateCache",function(a){a.put("graphics/views/tables-directive.html",'\n
\n \n \n {{header}} \n \n \n \n \n {{row.title}} \n {{row.value}} \n {{row.participantsNbr}} \n \n \n
\n
\n')}]),angular.module("localized/localized-input-group-template.html",[]).run(["$templateCache",function(a){a.put("localized/localized-input-group-template.html",'');
-}]),angular.module("localized/localized-input-template.html",[]).run(["$templateCache",function(a){a.put("localized/localized-input-template.html",'')}]),angular.module("localized/localized-template.html",[]).run(["$templateCache",function(a){a.put("localized/localized-template.html","{{LocalizedValues.forLang(value,lang)}} ")}]),angular.module("localized/localized-textarea-template.html",[]).run(["$templateCache",function(a){a.put("localized/localized-textarea-template.html",'')}]),angular.module("search/views/classifications.html",[]).run(["$templateCache",function(a){a.put("search/views/classifications.html",'')}]),angular.module("search/views/classifications/classifications-view.html",[]).run(["$templateCache",function(a){a.put("search/views/classifications/classifications-view.html",'\n
\n\n
\n\n
\n
\n
\n
{{group.title}} \n
{{group.description}}
\n
\n
\n
\n\n
\n
\n {{label.text}}\n \n\n
\n {{label.text}}\n
\n\n
\n
\n\n
\n
\n {{label.text}}\n \n\n
\n {{label.text}}\n
\n\n
\n
\n\n
\n
\n {{label.text}}\n \n
\n \n \n
\n
\n
\n
\n\n
\n')}]),angular.module("search/views/classifications/taxonomies-facets-view.html",[]).run(["$templateCache",function(a){a.put("search/views/classifications/taxonomies-facets-view.html",'\n\n\n \n \n \n \n {{localize(taxonomy.title)}}\n \n \n \n \n \n \n \n \n {{localize(vocabulary.title)}}\n \n \n {{vocabulary.name}}\n \n \n \n \n
\n
\n
\n
\n
\n search.facet.more \n search.facet.less \n
\n
\n
\n \n \n \n \n')}]),angular.module("search/views/classifications/taxonomies-view.html",[]).run(["$templateCache",function(a){a.put("search/views/classifications/taxonomies-view.html",'\n
\n
\n
\n
\n
\n
\n \n \n {{label.text}} \n \n \n \n
\n
\n
\n \n \n \n
\n
\n
\n
\n\n
\n
\n
\n
{{group.title}} \n
{{group.description}}
\n
\n
\n
\n\n
\n
\n
\n
\n {{label.text}}\n \n
\n {{label.text}}\n
\n
\n
\n
\n
\n
\n {{label.text}}\n \n
\n
\n {{label.text}}\n
\n
\n
\n
\n
\n
search.taxonomy-nav-help
\n
\n
\n
\n
\n {{label.text}}\n \n
\n
\n \n \n
\n
\n
search.vocabulary-nav-help
\n
\n
\n
\n
\n
\n
\n
\n
')}]),angular.module("search/views/classifications/taxonomy-accordion-group.html",[]).run(["$templateCache",function(a){a.put("search/views/classifications/taxonomy-accordion-group.html",'')}]),angular.module("search/views/classifications/taxonomy-panel-template.html",[]).run(["$templateCache",function(a){a.put("search/views/classifications/taxonomy-panel-template.html",'\n
\n
\n
\n
\n {{label.text}}\n
\n
\n
\n
')}]),angular.module("search/views/classifications/taxonomy-template.html",[]).run(["$templateCache",function(a){a.put("search/views/classifications/taxonomy-template.html",'')}]),angular.module("search/views/classifications/term-panel-template.html",[]).run(["$templateCache",function(a){a.put("search/views/classifications/term-panel-template.html",'\n
\n
\n
\n {{label.text}}\n
\n \n \n \n \n
\n
\n
\n
\n \n \n
\n
search.no-description
\n
\n
\n
')}]),angular.module("search/views/classifications/vocabulary-accordion-group.html",[]).run(["$templateCache",function(a){a.put("search/views/classifications/vocabulary-accordion-group.html",'')}]),angular.module("search/views/classifications/vocabulary-panel-template.html",[]).run(["$templateCache",function(a){a.put("search/views/classifications/vocabulary-panel-template.html",'\n
\n
\n
\n
\n {{label.text}}\n
\n
search.no-description
\n
\n
\n
');
-}]),angular.module("search/views/coverage/coverage-search-result-table-template.html",[]).run(["$templateCache",function(a){a.put("search/views/coverage/coverage-search-result-table-template.html",'\n\n
\n
\n\n
\n\n
\n\n
\n \n \n search.coverage-buckets.dce \n \n
\n\n
\n \n \n search.coverage-buckets.dataset \n \n \n \n search.coverage-buckets.dataschema \n \n
\n
\n\n
\n search.no-coverage \n search.no-results \n
\n\n
\n\n
\n
\n \n \n \n \n \n \n {{\'search.coverage-buckets.\' + bucket}}\n \n \n \n {{header.entity.titles[0].value}}\n \n \n \n \n \n \n \n search.coverage-dce-cols.study \n search.coverage-dce-cols.population \n search.coverage-dce-cols.dce \n \n \n {{header.entity.titles[0].value}}\n \n \n \n \n \n \n \n \n \n \n \n \n \n {{col.title}} \n \n
\n \n {{col.start}} {{\'to\' | translate}} {{col.end ? col.end : \'...\'}}\n \n
\n
\n
\n \n \n \n 0 \n \n \n \n \n \n \n all \n \n \n \n \n \n
\n
\n\n \n \n \n
')}]),angular.module("search/views/criteria/criteria-node-template.html",[]).run(["$templateCache",function(a){a.put("search/views/criteria/criteria-node-template.html",'\n \n \n\n \n
\n {{item.type | translate}} \n \n
\n
\n \n\n \n \n \n \n ')}]),angular.module("search/views/criteria/criteria-root-template.html",[]).run(["$templateCache",function(a){a.put("search/views/criteria/criteria-root-template.html",'\n')}]),angular.module("search/views/criteria/criteria-target-template.html",[]).run(["$templateCache",function(a){a.put("search/views/criteria/criteria-target-template.html",'')}]),angular.module("search/views/criteria/criterion-dropdown-template.html",[]).run(["$templateCache",function(a){a.put("search/views/criteria/criterion-dropdown-template.html",'\n\n \n \n \n \n \n {{truncate(localizeCriterion())}}\n \n \n \n \n \n \n\n \n\n \n\n \n\n
\n')}]),angular.module("search/views/criteria/criterion-header-template.html",[]).run(["$templateCache",function(a){a.put("search/views/criteria/criterion-header-template.html",'\n \n {{localize(criterion.vocabulary.title)}}\n \n \n \n \n')}]),angular.module("search/views/criteria/criterion-match-template.html",[]).run(["$templateCache",function(a){a.put("search/views/criteria/criterion-match-template.html",'')}]),angular.module("search/views/criteria/criterion-numeric-template.html",[]).run(["$templateCache",function(a){a.put("search/views/criteria/criterion-numeric-template.html",'')}]),angular.module("search/views/criteria/criterion-string-terms-template.html",[]).run(["$templateCache",function(a){a.put("search/views/criteria/criterion-string-terms-template.html",'')}]),angular.module("search/views/criteria/target-template.html",[]).run(["$templateCache",function(a){a.put("search/views/criteria/target-template.html"," ")}]),angular.module("search/views/graphics/graphics-search-result-template.html",[]).run(["$templateCache",function(a){a.put("search/views/graphics/graphics-search-result-template.html",'\n
\n\n
search.no-results
\n\n
\n
\n {{chart.headerTitle}}\n
\n
\n
\n
\n
\n {{chart.directiveTitle}}\n
\n
\n
\n
\n
\n
\n \n \n {{chart.getTable().data[0][0]}} \n {{chart.getTable().data[0][1]}} \n {{chart.getTable().data[0][2]}} \n \n \n \n \n {{row.title}} \n \n {{row.participantsNbr}} \n \n \n
\n
\n
\n
\n
\n
\n
')}]),angular.module("search/views/list/datasets-search-result-table-template.html",[]).run(["$templateCache",function(a){a.put("search/views/list/datasets-search-result-table-template.html",'\n
\n
\n
search.dataset.noResults
\n
\n
\n \n \n acronym \n name \n type \n networks \n studies \n variables \n \n \n \n \n search.dataset.noResults \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n - \n \n \n \n - \n \n \n \n \n \n \n
\n
\n
\n
')}]),angular.module("search/views/list/networks-search-result-table-template.html",[]).run(["$templateCache",function(a){a.put("search/views/list/networks-search-result-table-template.html",'\n
\n
\n
search.network.noResults
\n
\n
\n \n \n acronym \n name \n studies \n \n datasets\n \n variables \n variables \n \n \n \n search.study.label \n search.harmonization \n search.variable.study \n search.variable.dataschema \n \n \n \n \n search.network.noResults \n \n \n \n \n \n \n \n \n \n \n \n \n - \n \n \n \n - \n \n \n \n - \n \n \n \n \n \n \n - \n \n \n \n - \n \n \n \n
\n
\n
\n
')}]),angular.module("search/views/list/pagination-template.html",[]).run(["$templateCache",function(a){a.put("search/views/list/pagination-template.html",'\n \n \n ')}]),angular.module("search/views/list/search-result-pagination-template.html",[]).run(["$templateCache",function(a){a.put("search/views/list/search-result-pagination-template.html",'\n \n \n \n\n \n \n ')}]),angular.module("search/views/list/studies-search-result-table-template.html",[]).run(["$templateCache",function(a){a.put("search/views/list/studies-search-result-table-template.html",'\n
\n
\n
search.study.noResults
\n
\n
\n \n \n acronym \n name \n search.study.design \n \n search.study.dataSources\n \n search.study.participants \n networks \n datasets\n \n variables \n variables \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n search.study.label \n search.harmonization \n search.variable.study \n search.variable.dataschema \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n - \n \n \n - \n \n \n - \n \n \n - \n \n \n \n \n \n \n numberOfParticipants.no-limit\n \n \n \n \n - \n \n \n \n - \n \n \n \n - \n \n \n \n \n \n \n - \n \n \n \n - \n \n \n \n
\n
\n
\n
\n');
-}]),angular.module("search/views/list/variables-search-result-table-template.html",[]).run(["$templateCache",function(a){a.put("search/views/list/variables-search-result-table-template.html",'\n
\n
\n
search.variable.noResults
\n
\n
\n \n \n name \n search.variable.label \n type \n search.variable.studyNetwork \n search.dataset.label \n \n \n \n \n \n {{summary.name}}\n \n \n \n \n \n \n {{\'search.variable.\' + summary.variableType.toLowerCase() | translate}}\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n
\n
\n
')}]),angular.module("search/views/search-result-coverage-template.html",[]).run(["$templateCache",function(a){a.put("search/views/search-result-coverage-template.html",'\n \n
\n')}]),angular.module("search/views/search-result-graphics-template.html",[]).run(["$templateCache",function(a){a.put("search/views/search-result-graphics-template.html",'\n \n
')}]),angular.module("search/views/search-result-list-dataset-template.html",[]).run(["$templateCache",function(a){a.put("search/views/search-result-list-dataset-template.html",'\n \n
\n')}]),angular.module("search/views/search-result-list-network-template.html",[]).run(["$templateCache",function(a){a.put("search/views/search-result-list-network-template.html",'\n \n
\n')}]),angular.module("search/views/search-result-list-study-template.html",[]).run(["$templateCache",function(a){a.put("search/views/search-result-list-study-template.html",'\n \n
')}]),angular.module("search/views/search-result-list-template.html",[]).run(["$templateCache",function(a){a.put("search/views/search-result-list-template.html",'\n')}]),angular.module("search/views/search-result-list-variable-template.html",[]).run(["$templateCache",function(a){a.put("search/views/search-result-list-variable-template.html",'\n \n
\n')}]),angular.module("search/views/search-result-panel-template.html",[]).run(["$templateCache",function(a){a.put("search/views/search-result-panel-template.html","\n \n
\n")}]),angular.module("search/views/search.html",[]).run(["$templateCache",function(a){a.put("search/views/search.html",'\n
\n \n
\n\n
\n \n
\n\n
\n\n \n
\n\n
\n
\n \n \n
\n
\n\n \n
\n\n
\n
search.faceted-navigation-help
\n
\n\n \n
\n\n \n
\n
\n\n
{{\'search.\' + search.display + \'-help\'}}
\n
\n
\n\n
\n
\n\n
')}]),angular.module("views/pagination-template.html",[]).run(["$templateCache",function(a){a.put("views/pagination-template.html",'\n\n\n\n\n')}]);
\ No newline at end of file
+"use strict";function NgObibaMicaUrlProvider(){function a(a){var b=a;this.getUrl=function(a){return a in b?b[a]:null}}var b={DataAccessClientDetailPath:"",DataAccessClientListPath:"",DataAccessFormConfigResource:"ws/config/data-access-form",DataAccessRequestsResource:"ws/data-access-requests",DataAccessRequestsExportCsvResource:"ws/data-access-requests/csv?lang=:lang",DataAccessRequestResource:"ws/data-access-request/:id",DataAccessRequestAttachmentsUpdateResource:"/ws/data-access-request/:id/_attachments",DataAccessRequestAttachmentDownloadResource:"/ws/data-access-request/:id/attachments/:attachmentId/_download",SchemaFormAttachmentDownloadResource:"/ws/:path/form/attachments/:attachmentName/:attachmentId/_download",DataAccessRequestDownloadPdfResource:"/ws/data-access-request/:id/_pdf",DataAccessRequestCommentsResource:"ws/data-access-request/:id/comments",DataAccessRequestCommentResource:"ws/data-access-request/:id/comment/:commentId",DataAccessRequestStatusResource:"ws/data-access-request/:id/_status?to=:status",TempFileUploadResource:"ws/files/temp",TempFileResource:"ws/files/temp/:id",TaxonomiesSearchResource:"ws/taxonomies/_search",TaxonomiesResource:"ws/taxonomies/_filter",TaxonomyResource:"ws/taxonomy/:taxonomy/_filter",VocabularyResource:"ws/taxonomy/:taxonomy/vocabulary/:vocabulary/_filter",JoinQuerySearchResource:"ws/:type/_rql?query=:query",JoinQueryCoverageResource:"ws/variables/_coverage?query=:query",JoinQueryCoverageDownloadResource:"ws/variables/_coverage_download?query=:query",VariablePage:"",NetworkPage:"#/network/:network",StudyPage:"#/study/:study",StudyPopulationsPage:"#/study/:study",DatasetPage:"#/:type/:dataset",BaseUrl:"/",FileBrowserFileResource:"ws/file/:path/",FileBrowserSearchResource:"ws/files-search/:path",FileBrowserDownloadUrl:"ws/draft/file-dl/:path?inline=:inline",GraphicsSearchRootUrl:"#/search"};this.setUrl=function(a,c){a in b&&(b[a]=c)},this.$get=function(){return new a(b)}}function NgObibaMicaTemplateUrlFactory(){function a(a){var b=a;this.getHeaderUrl=function(a){return a in b?b[a].header:null},this.getFooterUrl=function(a){return a in b?b[a].footer:null}}var b={registry:null};b.setHeaderUrl=function(a,b){a in this.registry&&(this.registry[a].header=b)},b.setFooterUrl=function(a,b){a in this.registry&&(this.registry[a].footer=b)},b.$get=function(){return new a(this.registry)},this.create=function(a){return b.registry=a,b}}function targetToType(a){switch(a.toLocaleString()){case QUERY_TARGETS.NETWORK:return QUERY_TYPES.NETWORKS;case QUERY_TARGETS.STUDY:return QUERY_TYPES.STUDIES;case QUERY_TARGETS.DATASET:return QUERY_TYPES.DATASETS;case QUERY_TARGETS.VARIABLE:return QUERY_TYPES.VARIABLES}throw new Error("Invalid target: "+a)}function typeToTarget(a){switch(a.toLocaleString()){case QUERY_TYPES.NETWORKS:return QUERY_TARGETS.NETWORK;case QUERY_TYPES.STUDIES:return QUERY_TARGETS.STUDY;case QUERY_TYPES.DATASETS:return QUERY_TARGETS.DATASET;case QUERY_TYPES.VARIABLES:return QUERY_TARGETS.VARIABLE}throw new Error("Invalid type: "+a)}function CriteriaItem(a){var b=this;Object.keys(a).forEach(function(c){b[c]=a[c]})}function RepeatableCriteriaItem(){CriteriaItem.call(this,{}),this.list=[]}function CriteriaItemBuilder(a,b){function c(){d.term?(d.itemTitle=a.forLocale(d.term.title,d.lang),d.itemDescription=a.forLocale(d.term.description,d.lang),d.itemParentTitle=a.forLocale(d.vocabulary.title,d.lang),d.itemParentDescription=a.forLocale(d.vocabulary.description,d.lang),d.itemTitle||(d.itemTitle=d.term.name),d.itemParentTitle||(d.itemParentTitle=d.vocabulary.name)):(d.itemTitle=a.forLocale(d.vocabulary.title,d.lang),d.itemDescription=a.forLocale(d.vocabulary.description,d.lang),d.itemParentTitle=a.forLocale(d.taxonomy.title,d.lang),d.itemParentDescription=a.forLocale(d.taxonomy.description,d.lang),d.itemTitle||(d.itemTitle=d.vocabulary.name),d.itemParentTitle||(d.itemParentTitle=d.taxonomy.name)),d.id=CriteriaIdGenerator.generate(d.taxonomy,d.vocabulary,d.term)}var d={type:null,rqlQuery:null,lang:b||"en",parent:null,children:[]};this.type=function(a){if(!RQL_NODE[a.toUpperCase()])throw new Error("Invalid node type:",a);return d.type=a,this},this.target=function(a){return d.target=a,this},this.parent=function(a){return d.parent=a,this},this.taxonomy=function(a){return d.taxonomy=a,this},this.vocabulary=function(a){return d.vocabulary=a,this},this.term=function(a){return d.term=a,this},this.rqlQuery=function(a){return d.rqlQuery=a,this},this.selectedTerm=function(a){return d.selectedTerms||(d.selectedTerms=[]),d.selectedTerms.push("string"==typeof a?a:a.name),this},this.selectedTerms=function(a){return d.selectedTerms=a.filter(function(a){return a}).map(function(a){return"string"==typeof a?a:a.name}),this},this.build=function(){return d.taxonomy&&d.vocabulary&&c(),new CriteriaItem(d)}}function CriteriaBuilder(a,b,c,d,e){this.newCriteriaItemBuilder=function(){return new CriteriaItemBuilder(d,e)},this.initialize=function(f){this.leafItemMap={},this.target=f,this.rootRql=a,this.taxonomies=c,this.LocalizedValues=d,this.lang=e,this.rootItem=this.newCriteriaItemBuilder().parent(b).type(this.target).rqlQuery(this.rootRql).target(this.target).build()},this.buildLeafItem=function(a,b,c,d,e){var f=this,g=new CriteriaItemBuilder(f.LocalizedValues,f.lang).type(d.name).target(f.target).taxonomy(a).vocabulary(b).rqlQuery(d).parent(e);return g.selectedTerms(c).build(),g.build()}}function CriterionState(){var a=[],b=[];this.dirty=!1,this.open=!1,this.loading=!0,this.addOnOpen=function(b){a.push(b)},this.addOnClose=function(a){b.push(a)},this.onOpen=function(){a.forEach(function(a){a()})},this.onClose=function(){b.forEach(function(a){a()})}}function BaseTaxonomiesController(a,b,c,d,e,f){a.options=e.getOptions(),a.RqlQueryUtils=f,a.metaTaxonomy=c.get({target:"taxonomy",taxonomy:"Mica_taxonomy"}),a.taxonomies={all:[],search:{text:null,active:!1},target:a.target||"variable",taxonomy:null,vocabulary:null},a.canNavigate=function(b){return!(a.options.hideNavigate.indexOf(b.name)>-1)&&0===(b.attributes||[]).filter(function(a){return"showNavigate"===a.key}).length},this.navigateTaxonomy=function(c,d,e){if(a.taxonomies.term=e,a.isHistoryEnabled){var f=b.search();f.taxonomy=c?c.name:null,f.vocabulary=d?d.name:null,b.search(f)}else a.taxonomies.taxonomy=c,a.taxonomies.vocabulary=d},this.updateStateFromLocation=function(){var c=b.search(),d=c.taxonomy,e=c.vocabulary,f=null,g=null;a.taxonomies.all&&(a.taxonomies.all.forEach(function(a){a.name===d&&(f=a,a.vocabularies.forEach(function(a){a.name===e&&(g=a)}))}),angular.equals(a.taxonomies.taxonomy,f)&&angular.equals(a.taxonomies.vocabulary,g)||(a.taxonomies.taxonomy=f,a.taxonomies.vocabulary=g))},this.selectTerm=function(b,c,d,e){a.onSelectTerm(b,c,d,e)};var g=this;a.$on("$locationChangeSuccess",function(){a.isHistoryEnabled&&g.updateStateFromLocation()}),a.$watch("taxonomies.vocabulary",function(b){f&&b?(a.taxonomies.isNumericVocabulary=f.isNumericVocabulary(a.taxonomies.vocabulary),a.taxonomies.isMatchVocabulary=f.isMatchVocabulary(a.taxonomies.vocabulary)):(a.taxonomies.isNumericVocabulary=null,a.taxonomies.isMatchVocabulary=null)}),a.navigateTaxonomy=this.navigateTaxonomy,a.selectTerm=this.selectTerm}function TaxonomiesPanelController(a,b,c,d,e,f){BaseTaxonomiesController.call(this,a,b,c,d,e,f),a.$watchGroup(["taxonomyName","target"],function(b){b[0]&&b[1]&&(a.showTaxonomies&&a.showTaxonomies(),a.taxonomies.target=b[1],a.taxonomies.search.active=!0,a.taxonomies.all=null,a.taxonomies.taxonomy=null,a.taxonomies.vocabulary=null,a.taxonomies.term=null,c.get({target:b[1],taxonomy:b[0]},function(b){a.taxonomies.taxonomy=b,a.taxonomies.search.active=!1}))})}function ClassificationPanelController(a,b,c,d,e,f){BaseTaxonomiesController.call(this,a,b,c,d,e,f);var g=function(b,c){var d=b.reduce(function(a,b){return a[b.name]=b,a},{});return a.metaTaxonomy.$promise.then(function(b){var e=b.vocabularies.filter(function(a){return a.name===c})[0];a.taxonomyGroups=e.terms.map(function(b){if(!b.terms){var c=d[b.name];return c?(c.title=b.title,c.description=b.description,{title:null,taxonomies:[c]}):null}var e=b.terms.map(function(a){var b=d[a.name];return b?(b.title=a.title,b.description=a.description,b):null}).filter(function(a){return a}),f=b.title.filter(function(b){return b.locale===a.lang})[0],g=b.description?b.description.filter(function(b){return b.locale===a.lang})[0]:void 0;return{title:f?f.text:null,description:g?g.text:null,taxonomies:e}}).filter(function(a){return a})})},h=this;a.$watch("target",function(b){b&&(a.taxonomies.target=b,a.taxonomies.search.active=!0,a.taxonomies.all=null,a.taxonomies.taxonomy=null,a.taxonomies.vocabulary=null,a.taxonomies.term=null,d.get({target:a.taxonomies.target},function(b){a.taxonomies.all=b,g(b,a.taxonomies.target),a.taxonomies.search.active=!1,h.updateStateFromLocation()}))})}function GraphicChartsDataProvider(){function a(a){var b=a;this.getData=function(a){a&&b.$promise.then(a)}}this.$get=["$log","JoinQuerySearchResource","ServerErrorUtils","AlertService","GraphicChartsConfig","GraphicChartsQuery",function(b,c,d,e,f,g){var h=g.queryDtoBuilder(f.getOptions().entityIds,f.getOptions().entityType);return new a(c.studies({query:h},function(a){return a},function(a){b.error("Server error",a)}))}]}function NgObibaMicaFileBrowserOptionsProvider(){var a={locale:"en",downloadInline:!0,folders:{excludes:["population"]}};this.$get=function(){return a}}angular.module("ngObibaMica",["schemaForm","ngCookies","obiba.mica.utils","obiba.mica.file","obiba.mica.attachment","obiba.mica.access","obiba.mica.search","obiba.mica.graphics","obiba.mica.localized","obiba.mica.fileBrowser","angularUtils.directives.dirPagination"]).constant("USER_ROLES",{all:"*",admin:"mica-administrator",reviewer:"mica-reviewer",editor:"mica-editor",user:"mica-user",dao:"mica-data-access-officer"}).config(["$provide","paginationTemplateProvider",function(a,b){a.provider("ngObibaMicaUrl",NgObibaMicaUrlProvider),b.setPath("views/pagination-template.html")}]),angular.module("obiba.mica.utils",["schemaForm"]).factory("UserProfileService",function(){var a=function(a,b){var c=a.filter(function(a){return a.key===b});return c&&c.length>0?c[0].value:null};return{getAttribute:function(b,c){return a(b,c)},getFullName:function(b){return b?b.attributes?a(b.attributes,"firstName")+" "+a(b.attributes,"lastName"):b.username:null}}}).service("GraphicChartsConfigurations",function(){this.getClientConfig=function(){return!0},this.setClientConfig=function(){return!0}}).directive("fixedHeader",["$timeout","$window",function(a,b){return{restrict:"A",scope:{tableMaxHeight:"@",trigger:"=fixedHeader"},link:function(c,d){function e(a){var c=b.getComputedStyle(a);return"none"!==c.display&&0!==a.offsetWidth}function f(){return e(h.querySelector("tbody"))&&null!==h.querySelector("tbody tr:first-child")}function g(){c.redraw||(angular.element(h.querySelectorAll("thead, tbody, tfoot")).css("display",""),a(function(){c.redraw=!0,console.log("do redrawTable");var a=0;if(angular.forEach(h.querySelectorAll("tr:first-child th"),function(b,c){var d=h.querySelector("tbody tr:first-child td:nth-child("+(c+1)+")"),e=h.querySelector("tfoot tr:first-child td:nth-child("+(c+1)+")"),f=d?d.offsetWidth:b.offsetWidth;d&&(d.style.width=f+"px"),b&&(b.style.width=f+"px"),e&&(e.style.width=f+"px"),a+=f}),angular.element(h.querySelectorAll("thead, tfoot")).css("display","block"),angular.element(h.querySelectorAll("tbody")).css({display:"block","max-height":c.tableMaxHeight||"inherit",overflow:"auto"}),a0){var f=h.querySelector("tbody tr:first-child td:last-child");f.style.width=parseInt(f.style.width.replace("px",""))-e+"px"}c.redraw=!1}))}var h=d[0];c.redraw=!1,c.$watchGroup(["trigger",f],function(a){a[1]===!0&&g()}),c.$watch(function(){return h.offsetWidth},function(){g()})}}}]).directive("routeChecker",["$route",function(a){return{restrict:"A",scope:{routeCheckerHidesParent:"="},link:function(b,c,d){var e=d.ngHref.substr(1,d.ngHref.length-1),f=Object.keys(a.routes).filter(function(b){var c=a.routes[b].regexp;return!!c&&c.test(e)}).pop();f||(b.routeCheckerHidesParent?c.parent().hide():c.hide())}}}]).service("SfOptionsService",["$filter",function(a){this.sfOptions={validationMessage:{default:a("translate")("errors.does-not-validate"),302:a("translate")("required")}}}]).config(["schemaFormProvider",function(a){a.postProcess(function(a){return a.filter(function(a){return a.hasOwnProperty("wordLimit")}).forEach(function(a){a.$validators={wordLimitError:function(b){if(angular.isDefined(b)&&null!==b){var c=(b.match(/\S+/g)||[]).length;if(c>parseInt(a.wordLimit))return!1}return!0}}}),a})}]),angular.module("obiba.mica.file",["ngResource"]),angular.module("obiba.mica.file").filter("bytes",function(){return function(a){return null===a||"undefined"==typeof a?"":filesize(a)}}),angular.module("obiba.mica.file").factory("TempFileResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("TempFileResource"),{},{get:{method:"GET"},delete:{method:"DELETE"}})}]),angular.module("obiba.mica.attachment",["obiba.mica.file","ui","ui.bootstrap","ngFileUpload","templates-ngObibaMica"]),angular.module("obiba.mica.attachment").directive("attachmentList",[function(){return{restrict:"E",scope:{hrefBuilder:"=",files:"=",emptyMessage:"="},templateUrl:"attachment/attachment-list-template.html",link:function(a){a.attachments=[],a.hrefBuilder=a.hrefBuilder||function(a){return a.id},a.hasAttachments=!1,a.$watch("files",function(b){b&&(a.hasAttachments=b.length>0,a.attachments=b.map(function(b){var c=angular.copy(b);return c.href=a.hrefBuilder(b),c}))},!0)}}}]).directive("attachmentInput",[function(){return{restrict:"E",require:"^form",scope:{multiple:"=",accept:"@",files:"=",disabled:"="},templateUrl:"attachment/attachment-input-template.html",controller:"AttachmentCtrl"}}]).controller("AttachmentCtrl",["$scope","$timeout","$log","Upload","TempFileResource","ngObibaMicaUrl",function(a,b,c,d,e,f){var g=function(g){a.files=a.files||[];var h={showProgressBar:!0,lang:"en",progress:0,fileName:g.name,size:g.size};a.multiple?a.files.push(h):(a.files.splice(0,a.files.length),a.files.push(h)),a.upload=d.upload({url:f.getUrl("TempFileUploadResource"),method:"POST",file:g}).progress(function(a){h.progress=parseInt(100*a.loaded/a.total)}).success(function(a,d,f){var g=f().location.split("/"),i=g[g.length-1];e.get({id:i},function(a){c.debug("tempFile",a),h.id=a.id,h.md5=a.md5,h.justUploaded=!0,h.timestamps={created:new Date},b(function(){h.showProgressBar=!1},1e3)})})};a.onFileSelect=function(b){a.uploadedFiles=b,a.uploadedFiles.forEach(function(a){g(a)})},a.deleteTempFile=function(b){e.delete({id:b},function(){for(var c=a.files.length;c--;){var d=a.files[c];d.justUploaded&&d.id===b&&a.files.splice(c,1)}})},a.deleteFile=function(b){for(var c=a.files.length;c--;)a.files[c].id===b&&a.files.splice(c,1)}}]),angular.module("obiba.mica.access",["pascalprecht.translate","obiba.alert","obiba.comments","obiba.mica.attachment","obiba.utils","angularMoment","templates-ngObibaMica"]).config(["$provide",function(a){a.provider("ngObibaMicaAccessTemplateUrl",(new NgObibaMicaTemplateUrlFactory).create({list:{header:null,footer:null},view:{header:null,footer:null},form:{header:null,footer:null}}))}]),angular.module("obiba.mica.access").controller("DataAccessRequestListController",["$rootScope","$scope","$uibModal","DataAccessRequestsResource","DataAccessRequestResource","DataAccessRequestService","NOTIFICATION_EVENTS","SessionProxy","USER_ROLES","ngObibaMicaAccessTemplateUrl","DataAccessRequestConfig","ngObibaMicaUrl","$translate",function(a,b,c,d,e,f,g,h,i,j,k,l,m){var n=function(a){for(var c=0;c-1}).length>0,b.deleteRequest=function(c){b.requestToDelete=c.id,a.$broadcast(g.showConfirmDialog,{titleKey:"data-access-request.delete-dialog.title",messageKey:"data-access-request.delete-dialog.message",messageArgs:[c.title,c.applicant]},c.id)},b.userProfile=function(a){b.applicant=a,c.open({scope:b,templateUrl:"access/views/data-access-request-profile-user-modal.html"})};var p=function(a,b){var c=a.filter(function(a){return a.key===b});return c&&c.length>0?c[0].value:null};b.getFullName=function(a){return a?a.attributes?p(a.attributes,"firstName")+" "+p(a.attributes,"lastName"):a.username:null},b.getProfileEmail=function(a){return a&&a.attributes?p(a.attributes,"email"):null},b.getCsvExportHref=function(){return l.getUrl("DataAccessRequestsExportCsvResource").replace(":lang",m.use())},b.getDataAccessRequestPageUrl=function(){var a=l.getUrl("DataAccessClientDetailPath");return a?l.getUrl("BaseUrl")+l.getUrl("DataAccessClientDetailPath"):null},b.$on(g.confirmDialogAccepted,function(a,c){b.requestToDelete===c&&(e.delete({id:b.requestToDelete},function(){b.loading=!0,d.query({},n,o)}),delete b.requestToDelete)})}]).controller("DataAccessRequestViewController",["$rootScope","$scope","$location","$uibModal","$routeParams","$filter","$translate","DataAccessRequestResource","DataAccessRequestService","DataAccessRequestStatusResource","DataAccessFormConfigResource","JsonUtils","DataAccessRequestAttachmentsUpdateResource","DataAccessRequestCommentsResource","DataAccessRequestCommentResource","ngObibaMicaUrl","ngObibaMicaAccessTemplateUrl","AlertService","ServerErrorUtils","NOTIFICATION_EVENTS","DataAccessRequestConfig","LocalizedSchemaFormService","SfOptionsService",function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w){function x(){var a=b.dataAccessRequest.statusChangeHistory||[];return a.filter(function(a){return a.to===i.status.SUBMITTED}).pop()}var y=function(a){r.alert({id:"DataAccessRequestViewController",type:"danger",msg:s.buildMessage(a)})};b.sfOptions=w.sfOptions;var z=function(){b.form.comments=n.query({id:e.id})},A=function(a){switch(b.selectedTab=a,a){case"form":break;case"comments":z()}},B=function(a){n.save({id:e.id},a.message,z,y)},C=function(a){o.update({id:e.id,commentId:a.id},a.message,z,y)},D=function(c){b.commentToDelete=c.id,a.$broadcast(t.showConfirmDialog,{titleKey:"comment.delete-dialog.title",messageKey:"comment.delete-dialog.message",messageArgs:[c.createdBy]},c.id)},E=function(a){a&&(b.attachments=angular.copy(b.dataAccessRequest.attachments)||[]),b.showAttachmentsForm=a},F=function(){var a=angular.copy(b.dataAccessRequest);a.attachments=b.attachments,m.save(a,function(){E(!1),b.dataAccessRequest=G()})};b.form={schema:null,definition:null,model:{},comments:null},b.$on(t.confirmDialogAccepted,function(a,c){b.commentToDelete===c&&o.delete({id:e.id,commentId:c},{},z,y)}),b.getDownloadHref=function(a){return p.getUrl("DataAccessRequestAttachmentDownloadResource").replace(":id",b.dataAccessRequest.id).replace(":attachmentId",a.id)},b.config=u.getOptions(),b.actions=i.actions,b.nextStatus=i.nextStatus,b.selectTab=A,b.submitComment=B,b.updateComment=C,b.deleteComment=D,b.showAttachmentsForm=!1,b.updateAttachments=F,b.cancelAttachments=function(){E(!1)},b.editAttachments=function(){E(!0)},b.headerTemplateUrl=q.getHeaderUrl("view"),b.footerTemplateUrl=q.getFooterUrl("view"),b.getStatusHistoryInfoId=i.getStatusHistoryInfoId,i.getStatusHistoryInfo(function(a){b.getStatusHistoryInfo=a}),b.validForm=!0;var G=function(){return h.get({id:e.id},function(a){try{b.form.model=a.content?JSON.parse(a.content):{},b.requestDownloadUrl=p.getUrl("DataAccessRequestDownloadPdfResource").replace(":id",b.dataAccessRequest.id)+"?lang="+g.use(),b.attachments=angular.copy(a.attachments)||[]}catch(a){b.validForm=!1,b.form.model={},r.alert({id:"DataAccessRequestViewController",type:"danger",msgKey:"data-access-request.parse-error"})}return k.get(function(a){b.form.definition=v.translate(l.parseJsonSafely(a.definition,[])),b.form.schema=v.translate(l.parseJsonSafely(a.schema,{})),b.form.downloadTemplate="Template"===a.pdfDownloadType,0===b.form.definition.length&&(b.validForm=!1,b.form.definition=[],r.alert({id:"DataAccessRequestViewController",type:"danger",msgKey:"data-access-config.parse-error.definition"})),0===Object.getOwnPropertyNames(b.form.schema).length&&(b.validForm=!1,b.form.schema={readonly:!0},r.alert({id:"DataAccessRequestViewController",type:"danger",msgKey:"data-access-config.parse-error.schema"})),b.form.schema.readonly=!0,b.$broadcast("schemaFormRedraw")},y),a.attachments=a.attachments||[],b.lastSubmittedDate=x(),a})};b.dataAccessRequest=e.id?G():{},b.delete=function(){b.requestToDelete=b.dataAccessRequest.id,a.$broadcast(t.showConfirmDialog,{titleKey:"data-access-request.delete-dialog.title",messageKey:"data-access-request.delete-dialog.message",messageArgs:[b.dataAccessRequest.title,b.dataAccessRequest.applicant]},b.requestToDelete)},b.$on(t.confirmDialogAccepted,function(a,d){b.requestToDelete===d&&(h.delete({id:b.requestToDelete},function(){c.path("/data-access-requests").replace()}),delete b.requestToDelete)});var H=function(){b.dataAccessRequest=G()},I=function(b,c,d){a.$broadcast(t.showConfirmDialog,{titleKey:"data-access-request.status-change-confirmation.title",messageKey:null!==c?c:"data-access-request.status-change-confirmation.message",messageArgs:null!==d?[f("translate")(d).toLowerCase()]:[]},b)},J=function(a,c){a===c&&j.update({id:b.dataAccessRequest.id,status:a},H,y)},K=function(){setTimeout(function(){window.print()},250)};b.submit=function(){b.$broadcast("schemaFormValidate"),b.forms.requestForm.$valid?j.update({id:b.dataAccessRequest.id,status:i.status.SUBMITTED},function(){H(),d.open({scope:b,templateUrl:"access/views/data-access-request-submitted-modal.html"})},y):r.alert({id:"DataAccessRequestViewController",type:"danger",msgKey:"data-access-request.submit.invalid"})},b.reopen=function(){I(i.status.OPENED,null,"reopen")},b.review=function(){I(i.status.REVIEWED,"data-access-request.status-change-confirmation.message-review",null)},b.approve=function(){I(i.status.APPROVED,null,"approve")},b.reject=function(){I(i.status.REJECTED,null,"reject")},b.conditionallyApprove=function(){I(i.status.CONDITIONALLY_APPROVED,null,"conditionallyApprove")},b.userProfile=function(a){b.applicant=a,d.open({scope:b,templateUrl:"access/views/data-access-request-profile-user-modal.html"})},b.getDataAccessListPageUrl=i.getListDataAccessRequestPageUrl();var L=function(a,b){var c=a.filter(function(a){return a.key===b});return c&&c.length>0?c[0].value:null};b.printForm=K,b.getFullName=function(a){return a?a.attributes?L(a.attributes,"firstName")+" "+L(a.attributes,"lastName"):a.username:null},b.getProfileEmail=function(a){return a&&a.attributes?L(a.attributes,"email"):null},b.$on(t.confirmDialogAccepted,function(a,b){J(i.status.OPENED,b)}),b.$on(t.confirmDialogAccepted,function(a,b){J(i.status.REVIEWED,b)}),b.$on(t.confirmDialogAccepted,function(a,b){J(i.status.CONDITIONALLY_APPROVED,b)}),b.$on(t.confirmDialogAccepted,function(a,b){J(i.status.APPROVED,b)}),b.$on(t.confirmDialogAccepted,function(a,b){J(i.status.REJECTED,b)}),b.forms={}}]).controller("DataAccessRequestEditController",["$log","$scope","$routeParams","$location","$uibModal","LocalizedSchemaFormService","DataAccessRequestsResource","DataAccessRequestResource","DataAccessFormConfigResource","JsonUtils","AlertService","ServerErrorUtils","SessionProxy","DataAccessRequestService","ngObibaMicaAccessTemplateUrl","DataAccessRequestConfig","SfOptionsService",function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q){var r=function(a,b){var c=b().location.split("/");d.path("/data-access-request/"+c[c.length-1]).replace()},s=function(a){k.alert({id:"DataAccessRequestEditController",type:"danger",msg:l.buildMessage(a)})};b.sfOptions=q.sfOptions,b.getDataAccessListPageUrl=n.getListDataAccessRequestPageUrl();var t=function(){b.$broadcast("schemaFormValidate"),e.open({scope:b,templateUrl:"access/views/data-access-request-validation-modal.html"})},u=function(){d.path("/data-access-request"+(c.id?"/"+c.id:"s")).replace()},v=function(){b.dataAccessRequest.content=JSON.stringify(b.form.model),b.newRequest?g.save(b.dataAccessRequest,r,s):h.save(b.dataAccessRequest,function(){d.path("/data-access-request"+(b.dataAccessRequest.id?"/"+b.dataAccessRequest.id:"s")).replace()},s)};i.get(function(a){b.form.definition=f.translate(j.parseJsonSafely(a.definition,[])),b.form.schema=f.translate(j.parseJsonSafely(a.schema,{})),0===b.form.definition.length&&(b.form.definition=[],b.validForm=!1,k.alert({id:"DataAccessRequestEditController",type:"danger",msgKey:"data-access-config.parse-error.definition"})),0===Object.getOwnPropertyNames(b.form.schema).length&&(b.form.schema={},b.validForm=!1,k.alert({id:"DataAccessRequestEditController",type:"danger",msgKey:"data-access-config.parse-error.schema"})),b.validForm&&(b.dataAccessRequest=c.id?h.get({id:c.id},function(a){try{b.form.model=a.content?JSON.parse(a.content):{}}catch(a){b.form.model={},k.alert({id:"DataAccessRequestEditController",type:"danger",msgKey:"data-access-request.parse-error"})}return b.canEdit=n.actions.canEdit(a),b.form.schema.readonly=!b.canEdit,b.$broadcast("schemaFormRedraw"),a.attachments=a.attachments||[],a}):{applicant:m.login(),status:n.status.OPENED,attachments:[]}),b.loaded=!0},s),b.loaded=!1,b.config=p.getOptions(),b.validForm=!0,b.requestId=c.id,b.newRequest=!c.id,b.cancel=u,b.save=v,b.editable=!0,b.validate=t,b.headerTemplateUrl=o.getHeaderUrl("form"),b.footerTemplateUrl=o.getFooterUrl("form"),b.form={schema:null,definition:null,model:{}}}]),angular.module("obiba.mica.access").config(["$routeProvider",function(a){a.when("/data-access-requests",{templateUrl:"access/views/data-access-request-list.html",controller:"DataAccessRequestListController"}).when("/data-access-request/new",{templateUrl:"access/views/data-access-request-form.html",controller:"DataAccessRequestEditController"}).when("/data-access-request/:id/edit",{templateUrl:"access/views/data-access-request-form.html",controller:"DataAccessRequestEditController"}).when("/data-access-request/:id",{templateUrl:"access/views/data-access-request-view.html",controller:"DataAccessRequestViewController"})}]),angular.module("obiba.mica.access").factory("DataAccessFormConfigResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("DataAccessFormConfigResource"),{},{get:{method:"GET",errorHandler:!0}})}]).factory("DataAccessRequestsResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("DataAccessRequestsResource"),{},{save:{method:"POST",errorHandler:!0},get:{method:"GET"}})}]).factory("DataAccessRequestsExportCsvResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("DataAccessRequestsExportCsvResource"),{},{get:{method:"GET"}})}]).factory("DataAccessRequestResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("DataAccessRequestResource"),{},{save:{method:"PUT",params:{id:"@id"},errorHandler:!0},get:{method:"GET"},delete:{method:"DELETE"}})}]).factory("DataAccessRequestAttachmentsUpdateResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("DataAccessRequestAttachmentsUpdateResource"),{},{save:{method:"PUT",params:{id:"@id"},errorHandler:!0}})}]).factory("DataAccessRequestCommentsResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("DataAccessRequestCommentsResource"),{},{save:{method:"POST",params:{id:"@id"},headers:{"Content-Type":"text/plain"},errorHandler:!0},get:{method:"GET",params:{id:"@id"},errorHandler:!0}})}]).factory("DataAccessRequestCommentResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("DataAccessRequestCommentResource"),{},{delete:{method:"DELETE",params:{id:"@id",commentId:"@commentId"},errorHandler:!0},update:{method:"PUT",params:{id:"@id",commentId:"@commentId"},headers:{"Content-Type":"text/plain"},errorHandler:!0}})}]).factory("DataAccessRequestStatusResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("DataAccessRequestStatusResource"),{},{update:{method:"PUT",params:{id:"@id",status:"@status"},errorHandler:!0}})}]).service("DataAccessRequestConfig",function(){var a={newRequestButtonCaption:null,documentsSectionTitle:null,documentsSectionHelpText:null,downloadButtonCaption:null,commentsEnabled:!0,userListPageTitle:null,newRequestButtonHelpText:null};this.setOptions=function(b){"object"==typeof b&&Object.keys(b).forEach(function(c){c in a&&(a[c]=b[c])})},this.getOptions=function(){return angular.copy(a)}}).service("DataAccessRequestService",["$translate","SessionProxy","USER_ROLES","ngObibaMicaUrl",function(a,b,c,d){var e={OPENED:"OPENED",SUBMITTED:"SUBMITTED",REVIEWED:"REVIEWED",CONDITIONALLY_APPROVED:"CONDITIONALLY_APPROVED",APPROVED:"APPROVED",REJECTED:"REJECTED"};this.status=e,this.getStatusFilterData=function(b){b&&a(Object.keys(e)).then(function(a){b(Object.keys(a).map(function(b){return a[b]}))})};var f=function(a,b){return a.actions?a.actions.indexOf(b)!==-1:null};this.actions={canViewProfile:function(a){var d=!1,e=b.roles();return angular.forEach(e,function(b){b!==a&&b!==c.admin||(d=!0)}),d},canView:function(a){return f(a,"VIEW")},canEdit:function(a){return f(a,"EDIT")},canEditStatus:function(a){return f(a,"EDIT_STATUS")},canDelete:function(a){return f(a,"DELETE")},canEditAttachments:function(a){return f(a,"EDIT_ATTACHMENTS")}};var g=function(a,b){return a.nextStatus?a.nextStatus.indexOf(b)!==-1:null};return this.nextStatus={canSubmit:function(a){return g(a,"SUBMITTED")},canReopen:function(a){return g(a,"OPENED")},canReview:function(a){return g(a,"REVIEWED")},canConditionallyApprove:function(a){return g(a,"CONDITIONALLY_APPROVED")},canApprove:function(a){return g(a,"APPROVED")},canReject:function(a){return g(a,"REJECTED")}},this.getStatusHistoryInfo=function(b){if(b){var c={"data-access-request.histories.opened":"opened","data-access-request.histories.reopened":"reopened","data-access-request.histories.submitted":"submitted","data-access-request.histories.reviewed":"reviewed","data-access-request.histories.conditionallyApproved":"conditionallyApproved","data-access-request.histories.approved":"approved","data-access-request.histories.rejected":"rejected"},d={opened:{id:"opened",icon:"glyphicon glyphicon-saved"},reopened:{id:"reopened",icon:"glyphicon glyphicon-repeat"},submitted:{id:"submitted",icon:"glyphicon glyphicon-export"},reviewed:{id:"reviewed",icon:"glyphicon glyphicon-check"},conditionallyApproved:{id:"conditionallyApproved",icon:"glyphicon glyphicon-unchecked"},approved:{id:"approved",icon:"glyphicon glyphicon-ok"},rejected:{id:"rejected",icon:"glyphicon glyphicon-remove"}};a(Object.keys(c)).then(function(a){Object.keys(a).forEach(function(b){d[c[b]].msg=a[b]}),b(d)})}},this.getStatusHistoryInfoId=function(a){var b="opened";if("OPENED"!==a.from||a.from!==a.to)switch(a.to){case"OPENED":b="reopened";break;case"SUBMITTED":b="submitted";break;case"REVIEWED":b="reviewed";break;case"CONDITIONALLY_APPROVED":b="conditionallyApproved";break;case"APPROVED":b="approved";break;case"REJECTED":b="rejected"}return b},this.getListDataAccessRequestPageUrl=function(){var a=d.getUrl("DataAccessClientListPath");return a?d.getUrl("BaseUrl")+d.getUrl("DataAccessClientListPath"):null},this}]).filter("filterProfileAttributes",function(){return function(a){var b=["email","firstName","lastName","createdDate","lastLogin","username"];return a.filter(function(a){return b.indexOf(a.key)===-1})}}).filter("capitalizeFirstLetter",["StringUtils",function(a){
+return function(b){return a.capitaliseFirstLetter(b)}}]),angular.module("obiba.mica.access").directive("printFriendlyView",[function(){return{restrict:"EA",replace:!0,scope:!1,templateUrl:"access/views/data-access-request-print-preview.html"}}]);var DISPLAY_TYPES={LIST:"list",COVERAGE:"coverage",GRAPHICS:"graphics"};angular.module("obiba.mica.search",["obiba.alert","ui.bootstrap","pascalprecht.translate","templates-ngObibaMica"]).config(["$provide",function(a){a.provider("ngObibaMicaSearchTemplateUrl",(new NgObibaMicaTemplateUrlFactory).create({search:{header:null,footer:null},classifications:{header:null,footer:null}}))}]).config(["$provide","$injector",function(a){a.provider("ngObibaMicaSearch",function(){var a=["LocalizedValues",function(a){return a.getLocal()}],b={targetTabsOrder:[QUERY_TARGETS.VARIABLE,QUERY_TARGETS.DATASET,QUERY_TARGETS.STUDY,QUERY_TARGETS.NETWORK],searchTabsOrder:[DISPLAY_TYPES.LIST,DISPLAY_TYPES.COVERAGE,DISPLAY_TYPES.GRAPHICS],resultTabsOrder:[QUERY_TARGETS.VARIABLE,QUERY_TARGETS.DATASET,QUERY_TARGETS.STUDY,QUERY_TARGETS.NETWORK],showAllFacetedTaxonomies:!0,showSearchBox:!0,showSearchBrowser:!0,variableTaxonomiesOrder:[],studyTaxonomiesOrder:[],datasetTaxonomiesOrder:[],networkTaxonomiesOrder:[],hideNavigate:[],hideSearch:["studyIds","dceIds","datasetId","networkId","studyId"],variables:{showSearchTab:!0,variablesColumn:{showVariablesTypeColumn:!0,showVariablesStudiesColumn:!0,showVariablesDatasetsColumn:!0,showDatasetsStudiesColumn:!0,showDatasetsVariablesColumn:!0}},datasets:{showSearchTab:!0,showDatasetsSearchFilter:!0,datasetsColumn:{showDatasetsAcronymColumn:!0,showDatasetsTypeColumn:!0,showDatasetsNetworkColumn:!0,showDatasetsStudiesColumn:!0,showDatasetsVariablesColumn:!0}},studies:{showSearchTab:!0,showStudiesSearchFilter:!0,studiesColumn:{showStudiesDesignColumn:!0,showStudiesQuestionnaireColumn:!0,showStudiesPmColumn:!0,showStudiesBioColumn:!0,showStudiesOtherColumn:!0,showStudiesParticipantsColumn:!0,showStudiesNetworksColumn:!0,showStudiesStudyDatasetsColumn:!0,showStudiesHarmonizationDatasetsColumn:!0,showStudiesVariablesColumn:!1,showStudiesStudyVariablesColumn:!0,showStudiesDataschemaVariablesColumn:!0}},networks:{showSearchTab:!0,networksColumn:{showNetworksStudiesColumn:!0,showNetworksStudyDatasetColumn:!0,showNetworksHarmonizationDatasetColumn:!0,showNetworksVariablesColumn:!1,showNetworksStudyVariablesColumn:!0,showNetworksDataschemaVariablesColumn:!0}},coverage:{groupBy:{study:!0,dce:!0,dataset:!0,dataschema:!0,network:!0}}};this.setLocaleResolver=function(b){a=b},this.setOptions=function(a){b=angular.merge(b,a),b.targetTabsOrder=a.targetTabsOrder||b.targetTabsOrder,b.searchTabsOrder=a.searchTabsOrder||b.searchTabsOrder,b.resultTabsOrder=a.resultTabsOrder||b.resultTabsOrder,b.variableTaxonomiesOrder=a.variableTaxonomiesOrder||b.variableTaxonomiesOrder,b.studyTaxonomiesOrder=a.studyTaxonomiesOrder||b.studyTaxonomiesOrder,b.datasetTaxonomiesOrder=a.datasetTaxonomiesOrder||b.datasetTaxonomiesOrder,b.networkTaxonomiesOrder=a.networkTaxonomiesOrder||b.networkTaxonomiesOrder,b.hideNavigate=a.hideNavigate||b.hideNavigate,b.hideSearch=a.hideSearch||b.hideSearch},this.$get=["$q","$injector",function(c,d){function e(){var a=Object.keys(b.coverage.groupBy).filter(function(a){return b.coverage.groupBy[a]}).length>0;if(!a){var c=b.searchTabsOrder.indexOf(DISPLAY_TYPES.COVERAGE);c>-1&&b.searchTabsOrder.splice(c,1)}}return e(),{getLocale:function(b,e){return c.when(d.invoke(a),b,e)},getOptions:function(){return b},toggleHideSearchNavigate:function(a){var c=b.hideNavigate.indexOf(a.name);c>-1?b.hideNavigate.splice(c,1):b.hideNavigate.push(a.name)}}}]})}]).run(["GraphicChartsConfigurations",function(a){a.setClientConfig()}]),angular.module("obiba.mica.search").filter("regex",function(){return function(a,b,c,d){var e=[];try{var f=new RegExp(b,"i");e=a.filter(function(a){return c.some(function(b){var c=a[b];return angular.isArray(c)&&d?c.filter(function(a){return a.locale===d}).some(function(a){return f.test(a.text)}):f.test(c)})})}catch(a){}return e}}).filter("orderBySelection",function(){return function(a,b){if(!a)return[];var c=[],d=[];return a.forEach(function(a){b[a.key]?c.push(a):d.push(a)}),c.concat(d)}}).filter("dceDescription",function(){return function(a){return a.split(":").map(function(a){return"
"+a})[2]}});var QUERY_TYPES={NETWORKS:"networks",STUDIES:"studies",DATASETS:"datasets",VARIABLES:"variables"},QUERY_TARGETS={NETWORK:"network",STUDY:"study",DATASET:"dataset",VARIABLE:"variable"},BUCKET_TYPES={NETWORK:"network",STUDY:"study",DCE:"dce",DATASCHEMA:"dataschema",DATASET:"dataset"},RQL_NODE={VARIABLE:"variable",DATASET:"dataset",STUDY:"study",NETWORK:"network",LIMIT:"limit",SORT:"sort",AND:"and",NAND:"nand",OR:"or",NOR:"nor",NOT:"not",FACET:"facet",LOCALE:"locale",AGGREGATE:"aggregate",BUCKET:"bucket",CONTAINS:"contains",IN:"in",OUT:"out",EQ:"eq",GT:"gt",GE:"ge",LT:"lt",LE:"le",BETWEEN:"between",MATCH:"match",EXISTS:"exists",MISSING:"missing"},SORT_FIELDS={ACRONYM:"acronym",NAME:"name"},VOCABULARY_TYPES={STRING:"string",INTEGER:"integer",DECIMAL:"decimal"},CriteriaIdGenerator={generate:function(a,b,c){return a&&b?a.name+"."+b.name+(c?"."+c.name:""):void 0}};CriteriaItem.prototype.isRepeatable=function(){return!1},CriteriaItem.prototype.getTarget=function(){return this.target||null},RepeatableCriteriaItem.prototype=Object.create(CriteriaItem.prototype),RepeatableCriteriaItem.prototype.isRepeatable=function(){return!0},RepeatableCriteriaItem.prototype.addItem=function(a){return this.list.push(a),this},RepeatableCriteriaItem.prototype.items=function(){return this.list},RepeatableCriteriaItem.prototype.first=function(){return this.list[0]},RepeatableCriteriaItem.prototype.getTarget=function(){return this.list.length>0?this.list[0].getTarget():null},CriteriaBuilder.prototype.fieldToVocabulary=function(a){var b={taxonomy:null,vocabulary:null},c=a;a.indexOf(".")<0&&(c="Mica_"+this.target+"."+a);var d=c.split(".",2),e=d[0],f=d[1],g=this.taxonomies.filter(function(a){return e===a.name});if(0===g.length)throw new Error("Could not find taxonomy:",e);b.taxonomy=g[0];var h=b.taxonomy.vocabularies.filter(function(a){return f===a.name});if(0===h.length)throw new Error("Could not find vocabulary:",f);return b.vocabulary=h[0],b},CriteriaBuilder.prototype.visitLeaf=function(a,b){var c=RQL_NODE.MATCH===a.name,d=a.args[c?1:0],e=a.args[c?0:1],f=this.fieldToVocabulary(d),g=this.buildLeafItem(f.taxonomy,f.vocabulary,e instanceof Array?e:[e],a,b),h=this.leafItemMap[g.id];h?h.isRepeatable()?h.addItem(g):(console.error("Non-repeatable criteria items must be unique,",h.id,"will be overwritten."),h=g):h=g.vocabulary.repeatable?(new RepeatableCriteriaItem).addItem(g):g,this.leafItemMap[g.id]=h,b.children.push(g)},CriteriaBuilder.prototype.getRootItem=function(){return this.rootItem},CriteriaBuilder.prototype.getLeafItemMap=function(){return this.leafItemMap},CriteriaBuilder.prototype.visitCondition=function(a,b){var c=this.newCriteriaItemBuilder().parent(b).rqlQuery(a).type(a.name).build();b.children.push(c),this.visit(a.args[0],c),this.visit(a.args[1],c)},CriteriaBuilder.prototype.visitNot=function(a,b){var c=this.newCriteriaItemBuilder().parent(b).rqlQuery(a).type(a.name).build();b.children.push(c),this.visit(a.args[0],c)},CriteriaBuilder.prototype.visit=function(a,b){switch(a.name){case RQL_NODE.NOT:this.visitNot(a,b);break;case RQL_NODE.AND:case RQL_NODE.NAND:case RQL_NODE.OR:case RQL_NODE.NOR:this.visitCondition(a,b);break;case RQL_NODE.CONTAINS:case RQL_NODE.IN:case RQL_NODE.OUT:case RQL_NODE.EQ:case RQL_NODE.LE:case RQL_NODE.LT:case RQL_NODE.GE:case RQL_NODE.GT:case RQL_NODE.BETWEEN:case RQL_NODE.EXISTS:case RQL_NODE.MISSING:case RQL_NODE.MATCH:this.visitLeaf(a,b)}},CriteriaBuilder.prototype.build=function(){var a=this;this.rootRql.args.forEach(function(b){a.visit(b,a.rootItem)})},angular.module("obiba.mica.search").service("RqlQueryUtils",[function(){function a(a){var b=a.args.filter(function(a){switch(a.name){case RQL_NODE.AND:case RQL_NODE.NAND:case RQL_NODE.OR:case RQL_NODE.NOR:case RQL_NODE.NOT:case RQL_NODE.CONTAINS:case RQL_NODE.IN:case RQL_NODE.OUT:case RQL_NODE.EQ:case RQL_NODE.GT:case RQL_NODE.GE:case RQL_NODE.LT:case RQL_NODE.LE:case RQL_NODE.BETWEEN:case RQL_NODE.MATCH:case RQL_NODE.EXISTS:case RQL_NODE.MISSING:return!0}return!1}).pop();return b?a.args.findIndex(function(a){return a.name===b.name}):-1}function b(a,b,c){var d=c;return a.attributes&&a.attributes.some(function(a){return a.key===b&&(d=a.value,!0)}),d}var c=this;this.vocabularyTermNames=function(a){return a&&a.terms?a.terms.map(function(a){return a.name}):[]},this.hasTargetQuery=function(a,b){return a.args.filter(function(a){switch(a.name){case RQL_NODE.VARIABLE:case RQL_NODE.DATASET:case RQL_NODE.STUDY:case RQL_NODE.NETWORK:return!b||b===a.name;default:return!1}}).length>0},this.variableQuery=function(){return new RqlQuery(QUERY_TARGETS.VARIABLE)},this.eqQuery=function(a,b){var c=new RqlQuery(RQL_NODE.EQ);return c.args.push(b),c},this.orQuery=function(a,b){var c=new RqlQuery(RQL_NODE.OR);return c.args=[a,b],c},this.aggregate=function(a){var b=new RqlQuery(RQL_NODE.AGGREGATE);return a.forEach(function(a){b.args.push(a)}),b},this.limit=function(a,b){var c=new RqlQuery(RQL_NODE.LIMIT);return c.args.push(a),c.args.push(b),c},this.fieldQuery=function(a,b,c){var d=new RqlQuery(a);return d.args.push(b),c&&c.length>0&&d.args.push(c),d},this.inQuery=function(a,b){var c=b&&b.length>0,d=c?RQL_NODE.IN:RQL_NODE.EXISTS;return this.fieldQuery(d,a,b)},this.matchQuery=function(a,b){var c=new RqlQuery(RQL_NODE.MATCH);return c.args.push(b||"*"),c.args.push(a),c},this.updateMatchQuery=function(a,b){return a.args[0]=b||"*",a},this.rangeQuery=function(a,b,d){var e=new RqlQuery(RQL_NODE.BETWEEN);return e.args.push(a),c.updateRangeQuery(e,b,d),e},this.updateQueryInternal=function(a,b){var c=b&&b.length>0;return c?a.args[1]=b:a.args.splice(1,1),a},this.mergeInQueryArgValues=function(a,b,c){var d=b&&b.length>0;if(d){var e=a.args[1];if(!e||c)a.args[1]=b;else{e instanceof Array||(e=[e]);var f=b.filter(function(a){return e.indexOf(a)===-1});a.args[1]=e.concat(f)}}else a.args.splice(1,1);return a},this.updateRangeQuery=function(a,b,c,d){d?(a.name=RQL_NODE.MISSING,a.args.splice(1,1)):angular.isDefined(b)&&null!==b&&angular.isDefined(c)&&null!==c?(a.name=RQL_NODE.BETWEEN,a.args[1]=[b,c]):angular.isDefined(b)&&null!==b?(a.name=RQL_NODE.GE,a.args[1]=b):angular.isDefined(c)&&null!==c?(a.name=RQL_NODE.LE,a.args[1]=c):(a.name=RQL_NODE.EXISTS,a.args.splice(1,1))},this.buildRqlQuery=function(a){return this.isNumericVocabulary(a.vocabulary)?this.rangeQuery(this.criteriaId(a.taxonomy,a.vocabulary),null,null):this.isMatchVocabulary(a.vocabulary)?this.matchQuery(this.criteriaId(a.taxonomy,a.vocabulary),null):this.inQuery(this.criteriaId(a.taxonomy,a.vocabulary),a.term?a.term.name:void 0)},this.addQuery=function(b,c,d){if(0===b.args.length)b.args.push(c);else{var e=a(b);if(e===-1)b.args.push(c);else{var f=b.args.splice(e,1).pop();if(!d&&c.args&&c.args.length>0){var g="Mica_"+b.name,h="match"===c.name?c.args[1]:c.args[0];d=h.startsWith(g+".")?RQL_NODE.AND:RQL_NODE.OR}var i=new RqlQuery(d||RQL_NODE.AND);i.args.push(f,c),b.args.push(i)}}return b},this.updateRepeatableQueryArgValues=function(a,b){var c=this;a.items().forEach(function(a){var d=a.rqlQuery;switch(d.name){case RQL_NODE.EXISTS:d.name=RQL_NODE.CONTAINS,c.mergeInQueryArgValues(d,b,!1);break;case RQL_NODE.CONTAINS:c.mergeInQueryArgValues(d,b,!1);break;case RQL_NODE.IN:var e=d.args[1]?[].concat(d.args[1]):[];if(1===e.length){d.name=RQL_NODE.CONTAINS,c.mergeInQueryArgValues(d,b,!1);break}var f,g=d.args[0],h=e.filter(function(a){return b.indexOf(a)<0}).map(function(a){return c.fieldQuery(RQL_NODE.CONTAINS,g,[].concat(a,b))});if(h.length>1){var i=h.splice(0,2);f=c.orQuery(i[0],i[1]),h.forEach(function(a){f=c.orQuery(a,f)}),d.name=f.name,d.args=f.args}else d.name=RQL_NODE.CONTAINS,d.args=h[0].args}})},this.updateQueryArgValues=function(a,b,c){switch(a.name){case RQL_NODE.EXISTS:case RQL_NODE.MISSING:a.name=RQL_NODE.IN,this.mergeInQueryArgValues(a,b,c);break;case RQL_NODE.CONTAINS:case RQL_NODE.IN:this.mergeInQueryArgValues(a,b,c);break;case RQL_NODE.BETWEEN:case RQL_NODE.GE:case RQL_NODE.LE:a.args[1]=b;break;case RQL_NODE.MATCH:a.args[0]=b}},this.updateQuery=function(a,b){switch(a.name){case RQL_NODE.CONTAINS:case RQL_NODE.IN:case RQL_NODE.EXISTS:case RQL_NODE.MISSING:this.updateQueryInternal(a,b)}},this.addLocaleQuery=function(a,b){var c=a.args.filter(function(a){return a.name===RQL_NODE.LOCALE}).pop();if(!c){var d=new RqlQuery("locale");d.args.push(b),a.args.push(d)}},this.addLimit=function(a,b){var c=a.args.filter(function(a){return a.name===RQL_NODE.LIMIT}).pop();c?c.args=b.args:a.args.push(b)},this.addSort=function(a,b){var c=a.args.filter(function(a){return a.name===RQL_NODE.SORT}).pop();if(!c){var d=new RqlQuery("sort");d.args.push(b),a.args.push(d)}},this.criteriaId=function(a,b){return a.name+"."+b.name},this.vocabularyType=function(a){return b(a,"type",VOCABULARY_TYPES.STRING)},this.vocabularyField=function(a){return b(a,"field",a.name)},this.vocabularyAlias=function(a){return b(a,"alias",a.name)},this.isTermsVocabulary=function(a){return c.vocabularyType(a)===VOCABULARY_TYPES.STRING&&a.terms},this.isMatchVocabulary=function(a){return c.vocabularyType(a)===VOCABULARY_TYPES.STRING&&!a.terms},this.isNumericVocabulary=function(a){return!a.terms&&(c.vocabularyType(a)===VOCABULARY_TYPES.INTEGER||c.vocabularyType(a)===VOCABULARY_TYPES.DECIMAL)},this.isRangeVocabulary=function(a){return a.terms&&(c.vocabularyType(a)===VOCABULARY_TYPES.INTEGER||c.vocabularyType(a)===VOCABULARY_TYPES.DECIMAL)}}]).service("RqlQueryService",["$q","TaxonomiesResource","TaxonomyResource","LocalizedValues","RqlQueryUtils",function(a,b,c,d,e){function f(a,b){return b.args.filter(function(b){return b.name===a}).pop()}function g(a){switch(a.type){case RQL_NODE.CONTAINS:case RQL_NODE.IN:case RQL_NODE.OUT:case RQL_NODE.EQ:case RQL_NODE.GT:case RQL_NODE.GE:case RQL_NODE.LT:case RQL_NODE.LE:case RQL_NODE.BETWEEN:case RQL_NODE.MATCH:case RQL_NODE.EXISTS:case RQL_NODE.MISSING:return!0}return!1}function h(a){var b=a.parent,c=a.rqlQuery,d=c.args,e=a.parent.rqlQuery,f=e.args.indexOf(c),g=b.children.indexOf(a);if(f===-1||g===-1)throw new Error("Criteria node not found: "+a);b.children.splice(g,1),a.children.forEach(function(a){a.parent=b}),b.children.splice.apply(b.children,[g,0].concat(a.children)),e.args.splice(f,1),d&&(d instanceof Array?e.args.splice.apply(e.args,[f,0].concat(d)):e.args.splice(f,0,d)),null!==b.parent&&0===e.args.length&&h(b)}function i(a){var b=a.parent,c=a.rqlQuery,d=c.args,e=a.parent.rqlQuery,f=e.args.indexOf(c),g=b.children.indexOf(a);if(f===-1||g===-1)throw new Error("Criteria node not found: "+a);b.children.splice(g,1),a.children.forEach(function(a){a.parent=b}),b.children.splice.apply(b.children,[g,0].concat(a.children)),e.args.splice(f,1),d&&(d instanceof Array?e.args.splice.apply(e.args,[f,0].concat(d)):e.args.splice(f,0,d)),0===e.args.length&&h(b)}function j(a){var b=a.parent;if(!b)throw new Error("Cannot remove criteria when parent is NULL");var c=a.rqlQuery,d=a.parent.rqlQuery,e=d.args.indexOf(c);if(e===-1)throw new Error("Criteria node not found: "+a);d.args.splice(e,1),[RQL_NODE.OR,RQL_NODE.AND,RQL_NODE.NAND,RQL_NODE.NOR].indexOf(b.type)!==-1?i(b):0===d.args.length&&h(b)}var k={variable:null,dataset:null,study:null,network:null};this.removeCriteriaItem=function(a){g(a)?j(a):h(a)},this.createCriteriaItem=function(a,b,e,f,g){function h(b,c,e){return new CriteriaItemBuilder(d,g).target(a).taxonomy(b).vocabulary(c).term(e)}return angular.isString(b)?c.get({target:a,taxonomy:b}).$promise.then(function(a){return e=a.vocabularies.filter(function(a){return a.name===e})[0],f=e.terms.filter(function(a){return a.name===f})[0],h(a,e,f).build()}):h(b,e,f).build()},this.addCriteriaItem=function(a,b,c){var d=a.args.filter(function(a){return b.target===a.name}).pop();d||(d=new RqlQuery(RQL_NODE[b.target.toUpperCase()]),a.args.push(d));var f=b.rqlQuery?b.rqlQuery:e.buildRqlQuery(b);return e.addQuery(d,f,c)},this.updateCriteriaItem=function(a,b,c){var d,f=a.isRepeatable(),g=!f&&a.rqlQuery.name===RQL_NODE.MATCH;c&&b.rqlQuery&&(a.rqlQuery.name=b.rqlQuery.name),b.rqlQuery?d=b.rqlQuery.args[g?0:1]:b.term?d=[b.term.name]:(a=f?a.first():a,a.rqlQuery.name=RQL_NODE.EXISTS,a.rqlQuery.args.splice(1,1)),d&&(f?e.updateRepeatableQueryArgValues(a,d):e.updateQueryArgValues(a.rqlQuery,d,c))},this.builders=function(c,e,f,g){function h(a,b){var e=new CriteriaBuilder(a,b,k[c],d,g);e.initialize(c),e.build(),i.resolve({root:e.getRootItem(),map:e.getLeafItemMap()})}var i=a.defer();return k[c]?h(e,f):b.get({target:c}).$promise.then(function(a){k[c]=a,h(e,f)}),i.promise},this.createCriteria=function(b,c){var d=a.defer(),f=(new CriteriaItemBuilder).type(RQL_NODE.AND).rqlQuery(b).build(),g={};if(!e.hasTargetQuery(b))return d.resolve({root:f,map:g}),d.promise;var h=[],i=this,j=0;return b.args.forEach(function(a){QUERY_TARGETS[a.name.toUpperCase()]&&h.push(a)}),h.forEach(function(a){i.builders(a.name,a,f,c).then(function(a){f.children.push(a.root),g=angular.extend(g,a.map),j++,j===h.length&&d.resolve({root:f,map:g})})}),d.promise},this.prepareCriteriaTermsQuery=function(a,b,c){function d(a,b,c){if(!a||!a.args)return null;if((a.name===RQL_NODE.IN||a.name===RQL_NODE.MISSING||a.name===RQL_NODE.CONTAINS)&&a.args[0]===b)return a;for(var e=a.args.length;e--;){var f=d(a.args[e],b,c);f&&(a.args[e]=c)}}var f=(new RqlParser).parse(a),g=f.args.filter(function(a){return a.name===b.target}).pop();if(g){var h=new RqlQuery(RQL_NODE.EXISTS),i=e.criteriaId(b.taxonomy,b.vocabulary);h.args.push(i),d(g,i,h),g.args.push(e.aggregate([i])),g.args.push(e.limit(0,0))}return f.args.push(new RqlQuery(RQL_NODE.FACET)),c&&e.addLocaleQuery(f,c),f.serializeArgs(f.args)},this.prepareSearchQuery=function(a,b,c,d,g){var h=angular.copy(b),i=typeToTarget(a);e.addLocaleQuery(h,d);var j=f(i,h);j||(j=new RqlQuery(i),h.args.push(j));var k=c[i]||{from:0,size:10};return e.addLimit(j,e.limit(k.from,k.size)),g&&e.addSort(j,g),(new RqlQuery).serializeArgs(h.args)},this.prepareCoverageQuery=function(a,b){var c,d=(new RqlParser).parse(a),e=new RqlQuery("aggregate");switch(b){case BUCKET_TYPES.NETWORK:c="networkId";break;case BUCKET_TYPES.STUDY:c="studyIds";break;case BUCKET_TYPES.DCE:c="dceIds";break;case BUCKET_TYPES.DATASCHEMA:case BUCKET_TYPES.DATASET:c="datasetId"}var f=new RqlQuery("bucket");f.args.push(c),e.args.push(f);var g;if(d.args.forEach(function(a){g||"variable"!==a.name||(g=a)}),g||(g=new RqlQuery("variable"),d.args.push(g)),g.args.length>0&&"limit"!==g.args[0].name){var h=new RqlQuery("in");h.args.push("Mica_variable.variableType"),b===BUCKET_TYPES.NETWORK||b===BUCKET_TYPES.DATASCHEMA?h.args.push("Dataschema"):h.args.push("Study");var i=new RqlQuery("and");i.args.push(h),i.args.push(g.args[0]),g.args[0]=i}return g.args.push(e),d.serializeArgs(d.args)},this.prepareGraphicsQuery=function(a,b,c){var d=(new RqlParser).parse(a),e=new RqlQuery(RQL_NODE.AGGREGATE);if(b.forEach(function(a){e.args.push(a)}),c&&c.length>0){var f=new RqlQuery(RQL_NODE.BUCKET);c.forEach(function(a){f.args.push(a)}),e.args.push(f)}var g,h=!1,i=!1;return d.args.forEach(function(a){if("study"===a.name){i=!0;var b=null;h=a.args.filter(function(a,c){return"limit"===a.name&&(b=c),["limit","sort","aggregate"].indexOf(a.name)<0}).length,null!==b&&a.args.splice(b,1),g=a}}),i||(g=new RqlQuery("study"),d.args.push(g)),h||g.args.push(new RqlQuery(RQL_NODE.MATCH)),g.args.push(e),d.args.push(new RqlQuery("facet")),d.serializeArgs(d.args)},this.getTargetAggregations=function(a,b,c){function f(a,b){var e=b.terms;if(e&&e.length>0){var f=a&&a.map(function(a){return a.key})||[];if(a){var g=[];return e.forEach(function(a){0!==f.length&&f.indexOf(a.name)!==-1||g.push({count:0,default:0,description:d.forLocale(a.description,c),key:a.name,title:d.forLocale(a.title,c)})}),a.concat(g)}return e.map(function(a){return{count:0,default:0,description:d.forLocale(a.description,c),key:a.name,title:d.forLocale(a.title,c)}})}return a}function g(a,b){if(a.children){var c=a.children.filter(function(a){return a.hasOwnProperty(b)}).pop();if(c)return c[b]}return null}var h=e.vocabularyAlias(b.vocabulary),i=a[b.target+"ResultDto"];if(i&&i.aggs){var j=b.taxonomy.name.startsWith("Mica_"),k=j?h:b.taxonomy.name,l=i.aggs.filter(function(a){return a.aggregation===k}).pop();if(l){if(j)return e.isNumericVocabulary(b.vocabulary)?l["obiba.mica.StatsAggregationResultDto.stats"]:e.isRangeVocabulary(b.vocabulary)?f(l["obiba.mica.RangeAggregationResultDto.ranges"],b.vocabulary):f(l["obiba.mica.TermsAggregationResultDto.terms"],b.vocabulary);var m=l.children.filter(function(a){return a.aggregation===h}).pop();if(m)return e.isRangeVocabulary(b.vocabulary)?f(g(l,"obiba.mica.RangeAggregationResultDto.ranges"),b.vocabulary):f(g(l,"obiba.mica.TermsAggregationResultDto.terms"),b.vocabulary)}}return f([],b.vocabulary)},this.findCriterion=function(a,b){function c(a,b){var d;if(a.id===b)return a;for(var e=a.children.length;e--;)if(d=c(a.children[e],b))return d}return c(a,b)}}]),angular.module("obiba.mica.search").factory("TaxonomiesSearchResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("TaxonomiesSearchResource"),{},{get:{method:"GET",isArray:!0,errorHandler:!0}})}]).factory("TaxonomiesResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("TaxonomiesResource"),{},{get:{method:"GET",isArray:!0,errorHandler:!0}})}]).factory("TaxonomyResource",["$resource","ngObibaMicaUrl","$cacheFactory",function(a,b,c){return a(b.getUrl("TaxonomyResource"),{},{get:{method:"GET",errorHandler:!0,cache:c("taxonomyResource")}})}]).factory("JoinQuerySearchResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("JoinQuerySearchResource"),{},{variables:{method:"GET",errorHandler:!0,params:{type:"variables"}},studies:{method:"GET",errorHandler:!0,params:{type:"studies"}},networks:{method:"GET",errorHandler:!0,params:{type:"networks"}},datasets:{method:"GET",errorHandler:!0,params:{type:"datasets"}}})}]).factory("JoinQueryCoverageResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("JoinQueryCoverageResource"),{},{get:{method:"GET",errorHandler:!0}})}]).factory("VocabularyResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("VocabularyResource"),{},{get:{method:"GET",errorHandler:!0}})}]).service("SearchContext",function(){var a=null;this.setLocale=function(b){a=b},this.currentLocale=function(){return a}}).service("PageUrlService",["ngObibaMicaUrl","StringUtils",function(a,b){return this.studyPage=function(c){return c?b.replaceAll(a.getUrl("StudyPage"),{":study":c}):""},this.studyPopulationPage=function(c,d){return c?b.replaceAll(a.getUrl("StudyPopulationsPage"),{":study":c,":population":d}):""},this.networkPage=function(c){return c?b.replaceAll(a.getUrl("NetworkPage"),{":network":c}):""},this.datasetPage=function(c,d){var e=("study"===d.toLowerCase()?"study":"harmonization")+"-dataset",f=c?b.replaceAll(a.getUrl("DatasetPage"),{":type":e,":dataset":c}):"";return f},this.variablePage=function(c){return c?b.replaceAll(a.getUrl("VariablePage"),{":variable":c}):""},this.downloadCoverage=function(c){return b.replaceAll(a.getUrl("JoinQueryCoverageDownloadResource"),{":query":c})},this}]).service("ObibaSearchConfig",function(){var a={networks:{showSearchTab:1},studies:{showSearchTab:1},datasets:{showSearchTab:1},variables:{showSearchTab:1}};this.setOptions=function(b){"object"==typeof b&&Object.keys(b).forEach(function(c){c in a&&(a[c]=b[c])})},this.getOptions=function(){return angular.copy(a)}}).service("CoverageGroupByService",["ngObibaMicaSearch",function(a){var b=a.getOptions().coverage.groupBy;return{canShowStudy:function(){return b.study||b.dce},canShowDce:function(a){return(a===BUCKET_TYPES.STUDY||a===BUCKET_TYPES.DCE)&&b.study&&b.dce},canShowDataset:function(){return b.dataset||b.dataschema},canShowDatasetStudyDataschema:function(a){return(a===BUCKET_TYPES.DATASET||a===BUCKET_TYPES.DATASCHEMA)&&b.dataset&&b.dataschema},canShowNetwork:function(){return b.network},studyTitle:function(){return b.study?"search.coverage-buckets.study":b.dce?"search.coverage-buckets.dce":""},studyBucket:function(){return b.study?BUCKET_TYPES.STUDY:BUCKET_TYPES.DCE},datasetTitle:function(){return b.dataset&&b.dataschema?"search.coverage-buckets.datasetNav":b.dataset?"search.coverage-buckets.dataset":b.dataschema?"search.coverage-buckets.dataschema":""},datasetBucket:function(){return b.dataset?BUCKET_TYPES.DATASET:BUCKET_TYPES.DATASCHEMA},canGroupBy:function(a){return b.hasOwnProperty(a)&&b[a]},defaultBucket:function(){return b.study?BUCKET_TYPES.STUDY:b.dce?BUCKET_TYPES.DCE:b.dataset?BUCKET_TYPES.DATASET:b.dataschema?BUCKET_TYPES.DATASCHEMA:b.network?BUCKET_TYPES.NETWORK:""}}}]).factory("CriteriaNodeCompileService",["$templateCache","$compile",function(a,b){return{compile:function(c,d){var e="";e=c.item.type===RQL_NODE.OR||c.item.type===RQL_NODE.AND||c.item.type===RQL_NODE.NAND||c.item.type===RQL_NODE.NOR?angular.element(a.get("search/views/criteria/criteria-node-template.html")):angular.element(' '),b(e)(c,function(a){d.replaceWith(a)})}}}]),angular.module("obiba.mica.search").controller("SearchController",["$scope","$rootScope","$timeout","$routeParams","$location","$translate","$filter","$cookies","TaxonomiesSearchResource","TaxonomiesResource","TaxonomyResource","VocabularyResource","ngObibaMicaSearchTemplateUrl","ngObibaMicaSearch","JoinQuerySearchResource","JoinQueryCoverageResource","AlertService","ServerErrorUtils","LocalizedValues","RqlQueryService","RqlQueryUtils","SearchContext","CoverageGroupByService",function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w){function x(){function b(a){var b=e.search()[a];return b&&b.split(",").filter(function(a){return a}).map(function(a){return a.trim()})}a.taxonomyNav=[];var c=b("targetTabsOrder");a.targetTabsOrder=(c||a.options.targetTabsOrder).filter(function(a){return P[a]});var d=b("searchTabsOrder");a.searchTabsOrder=d||a.options.searchTabsOrder;var f=b("resultTabsOrder");a.resultTabsOrder=(f||a.options.resultTabsOrder).filter(function(a){return P[a]}),e.search().target?a.target=e.search().target:a.target||(a.target=a.targetTabsOrder[0]),a.metaTaxonomy.$promise.then(function(b){a.targetTabsOrder.forEach(function(c){var d=b.vocabularies.filter(function(a){return a.name===c}).pop();d&&d.terms&&d.terms.forEach(function(b){b.target=c;var d=b.title.filter(function(b){return b.locale===a.lang})[0],e=b.description?b.description.filter(function(b){return b.locale===a.lang})[0]:void 0;b.locale={title:d,description:e},b.terms&&b.terms.forEach(function(b){var c=b.title.filter(function(b){return b.locale===a.lang})[0],d=b.description?b.description.filter(function(b){return b.locale===a.lang})[0]:void 0;b.locale={title:c,description:d}}),a.taxonomyNav.push(b)})})})}function y(b){a.search.result={},q.alert({id:"SearchController",type:"danger",msg:r.buildMessage(b),delay:5e3})}function z(a){if(!a||!QUERY_TYPES[a.toUpperCase()])throw new Error("Invalid type: "+a)}function A(a){if(a&&!BUCKET_TYPES[a.toUpperCase()])throw new Error("Invalid bucket: "+a)}function B(a){if(!a||!DISPLAY_TYPES[a.toUpperCase()])throw new Error("Invalid display: "+a)}function C(){return a.taxonomyTypeMap[a.resultTabsOrder[0]]}function D(){return a.searchTabsOrder[0]||DISPLAY_TYPES.LIST}function E(){try{var b=e.search(),c=a.resultTabsOrder.indexOf(O[b.type])>-1?b.type:C(),d=b.bucket&&w.canGroupBy(b.bucket)?b.bucket:w.defaultBucket(),f=a.searchTabsOrder.indexOf(b.display)>-1?b.display:D(),g=b.query||"";return z(c),A(d),B(f),a.search.type=c,a.search.bucket=d,a.search.display=f,a.search.query=g,a.search.rqlQuery=(new RqlParser).parse(g),!0}catch(a){q.alert({id:"SearchController",type:"danger",msg:a.message,delay:5e3})}return!1}function F(a){return a=a.trim(),a.match(/\s+/)?'"'+a.replace(/^"|"$/g,"").replace(/"/,'"')+'"':a}function G(a){a.sort(function(a,b){return"network"===a.target||"variable"===b.target?-1:"variable"===a.target||"network"===b.target?1:a.targetb.target?-1:0})}function H(){if("/search"===e.path()){var b=t.prepareSearchQuery(a.search.type,a.search.rqlQuery,a.search.pagination,a.lang,a.search.type===QUERY_TYPES.VARIABLES?SORT_FIELDS.NAME:SORT_FIELDS.ACRONYM);switch(a.search.display){case DISPLAY_TYPES.LIST:a.search.loading=!0,a.search.executedQuery=b,o[a.search.type]({query:b},function(b){a.search.result.list=b,a.search.loading=!1},y);break;case DISPLAY_TYPES.COVERAGE:var c=Object.keys(a.search.criteriaItemMap).map(function(b){return a.search.criteriaItemMap[b]}).filter(function(a){return QUERY_TARGETS.VARIABLE===a.getTarget()&&"Mica_variable"!==a.taxonomy.name}).length>0;c?(a.search.loading=!0,a.search.executedQuery=t.prepareCoverageQuery(b,a.search.bucket),p.get({query:a.search.executedQuery},function(b){a.search.result.coverage=b,a.search.loading=!1},y)):a.search.result={};break;case DISPLAY_TYPES.GRAPHICS:a.search.loading=!0,a.search.executedQuery=t.prepareGraphicsQuery(b,["Mica_study.populations-selectionCriteria-countriesIso","Mica_study.populations-dataCollectionEvents-bioSamples","Mica_study.numberOfParticipants-participant-number"],["Mica_study.methods-designs"]),o.studies({query:a.search.executedQuery},function(b){a.search.result.graphics=b,a.search.loading=!1},y)}}}function I(){E()&&t.createCriteria(a.search.rqlQuery,a.lang).then(function(b){a.search.criteria=b.root,a.search.criteria&&a.search.criteria.children&&G(a.search.criteria.children),a.search.criteriaItemMap=b.map,a.search.query&&H(),a.$broadcast("ngObibaMicaQueryUpdated",a.search.criteria)})}function J(a){var b=a.parent;if(b.type===RQL_NODE.OR){var c=b.parent,d=c.children.indexOf(b);c.children[d]=a;var e=b.rqlQuery,f=c.rqlQuery,g=f.args.indexOf(e);f.args[g]=a.rqlQuery,c.type!==QUERY_TARGETS.VARIABLE&&J(c)}}function K(b){var c=Object.keys(a.search.criteriaItemMap).filter(function(a){return b.id.indexOf(a)!==-1})[0];return a.search.criteriaItemMap[c]}function L(){n.getLocale(function(b){angular.isArray(b)?(a.tabs=b,a.lang=b[0]):a.lang=b||a.lang,v.setLocale(a.lang),x(),I()})}a.options=n.getOptions();var M="micaHideSearchHelpText",N="micaHideClassificationHelpBox";f(["search.help","search.coverage-help"]).then(function(b){a.options.SearchHelpText||h.get(M)||(a.options.SearchHelpText=b["search.help"]),a.options.ClassificationHelpText||h.get(N)||(a.options.ClassificationHelpText=b["classifications.help"])}),a.closeHelpBox=function(){h.put(M,!0),a.options.SearchHelpText=null},a.closeClassificationHelpBox=function(){h.put(N,!0),a.options.ClassificationHelpText=null},h.get(M)&&(a.options.SearchHelpText=null),h.get(N)&&(a.options.ClassificationHelpText=null),a.taxonomyTypeMap={variable:"variables",study:"studies",network:"networks",dataset:"datasets"},f(["search.classifications-title","search.classifications-link","search.faceted-navigation-help"]).then(function(b){a.hasClassificationsTitle=b["search.classifications-title"],a.hasClassificationsLinkLabel=b["search.classifications-link"],a.hasFacetedNavigationHelp=b["search.faceted-navigation-help"]});var O=Object.keys(a.taxonomyTypeMap).reduce(function(b,c){return b[a.taxonomyTypeMap[c]]=c,b},{});a.targets=[],a.lang=s.getLocal(),a.metaTaxonomy=k.get({target:"taxonomy",taxonomy:"Mica_taxonomy"},function(b){function c(a){function b(a,c){return angular.forEach(c,function(c){return c.terms?void b(a,c.terms):void a.push(c)}),a}return b([],a)}a.targets=b.vocabularies.map(function(a){return a.name}),a.hasFacetedTaxonomies=!1,a.facetedTaxonomies=b.vocabularies.reduce(function(b,d){function e(a){return g.filter(function(b){return b.name===a})[0]}function f(a){return null!==a&&void 0!==a}var g=c(d.terms);return a.options.showAllFacetedTaxonomies?b[d.name]=g.filter(function(a){return a.attributes&&a.attributes.some(function(a){return"showFacetedNavigation"===a.key&&"true"===a.value.toString();
+})}):b[d.name]=(a.options[d.name+"TaxonomiesOrder"]||[]).map(e).filter(f),a.hasFacetedTaxonomies=a.hasFacetedTaxonomies||b[d.name].length,b},{})});var P={variable:a.options.variables.showSearchTab,dataset:a.options.datasets.showSearchTab,study:a.options.studies.showSearchTab,network:a.options.networks.showSearchTab},Q=function(){var a=e.search();delete a.query,e.search(a)},R=function(){a.search.advanced=!a.search.advanced},S=function(){for(var b=a.search.criteria.children||[],c=b.length;c--;)for(var d=b[c].children||[],e=d.length;e--;)if(d[e].type===RQL_NODE.OR||d[e].type===RQL_NODE.AND)return!0};a.setLocale=function(b){a.lang=b,v.setLocale(a.lang),I()};var T=function(b,c){return a.target===b&&a.taxonomyName===c&&a.taxonomiesShown?void(a.taxonomiesShown=!1):(a.taxonomiesShown=!0,a.target=b,void(a.taxonomyName=c))},U=function(){a.target=null,a.taxonomyName=null},V=function(){var b=(new RqlQuery).serializeArgs(a.search.rqlQuery.args),c=e.search();""===b?delete c.query:c.query=b,e.search(c)},W=function(){a.documents.search.text=null,a.documents.search.active=!1},X=function(b){function c(a){var c=0,d=new RegExp(b,"ig");return a.itemTitle.match(d)?c=10:a.itemDescription&&a.itemDescription.match(d)?c=8:a.itemParentTitle.match(d)?c=6:a.itemParentDescription&&a.itemParentDescription.match(d)&&(c=4),c}function d(a,b){return!((b||[]).indexOf(a.name)>-1)&&0===(a.attributes||[]).filter(function(a){return"showSearch"===a.key}).length}function e(b){var e=[],f=0,g=b.target,h=b.taxonomy;return h.vocabularies&&h.vocabularies.filter(function(b){return d(b,a.options.hideSearch)}).forEach(function(b){if(b.terms)b.terms.filter(function(b){return d(b,a.options.hideSearch)}).forEach(function(d){var i=t.createCriteriaItem(g,h,b,d,a.lang);e.push({score:c(i),item:i}),f++});else{var i=t.createCriteriaItem(g,h,b,null,a.lang);e.push({score:c(i),item:i}),f++}}),{results:e,total:f}}var f=i.get({query:F(b),locale:a.lang,target:a.documents.search.target}).$promise.then(function(a){if(a){var c=[],d=0,f=10;if(a.forEach(function(a){var b=e(a);c.push.apply(c,b.results),d+=b.total}),c.sort(function(a,b){return b.score-a.score}),c=c.splice(0,f),d>c.length){var g={query:b,total:d,size:f,message:"Showing "+f+" / "+d,status:"has-warning"};c.push({score:-1,item:g})}return c.map(function(a){return a.item})}return[]});return f},Y=function(a){t.removeCriteriaItem(a),V()},Z=function(b,c,d,e){if(angular.isUndefined(e)&&(e=!0),b.id){var f,h=CriteriaIdGenerator.generate(b.taxonomy,b.vocabulary),i=a.search.criteriaItemMap[h];i&&h.indexOf("dceIds")!==-1?(Y(i),f="search.criterion.updated",t.addCriteriaItem(a.search.rqlQuery,b,c)):i?(f="search.criterion.updated",t.updateCriteriaItem(i,b,d)):(f="search.criterion.created",t.addCriteriaItem(a.search.rqlQuery,b,c)),e&&q.growl({id:"SearchControllerGrowl",type:"info",msgKey:f,msgArgs:[s.forLocale(b.vocabulary.title,a.lang),g("translate")("taxonomy.target."+b.target)],delay:3e3}),V(),a.selectedCriteria=null}else a.selectedCriteria=b.query},$=function(b){switch(b.keyCode){case 27:a.documents.search.active&&W();break;default:a.documents.search.text&&X(a.documents.search.text)}},_=function(a){if(a){z(a);var b=e.search();b.type=a,e.search(b)}},aa=function(a){if(a){A(a);var b=e.search();b.bucket=a,e.search(b)}},ba=function(b,c,d){a.search.pagination[b]={from:c,size:d},I()},ca=function(a){if(a){B(a);var b=e.search();b.display=a,e.search(b)}},da=function(b,c,d,e,f){if(c&&_(c),e){var g=K(b);g&&J(g)}ca(d&&a.search.display?a.search.display:DISPLAY_TYPES.LIST),Z(b,RQL_NODE.AND,!0,f)},ea=function(b){var c=t.findCriterion(a.search.criteria,b.id);Y(c)},fa=function(b,c,d,e){if(e=e||{},angular.isString(e)&&(e={term:e}),d){var f;if(u.isNumericVocabulary(d))return f=t.createCriteriaItem(b,c,d,null,a.lang),f.rqlQuery=u.buildRqlQuery(f),u.updateRangeQuery(f.rqlQuery,e.from,e.to),void Z(f,null,!0);if(u.isMatchVocabulary(d))return f=t.createCriteriaItem(b,c,d,null,a.lang),f.rqlQuery=u.buildRqlQuery(f),u.updateMatchQuery(f.rqlQuery,e.text),void Z(f,null,!0)}Z(t.createCriteriaItem(b,c,d,e&&e.term,a.lang))},ga=function(b){a.documents.search.target=b},ha={SEARCH:"search",CLASSIFICATION:"classification"};a.goToSearch=function(){a.viewMode=ha.SEARCH,e.search("taxonomy",null),e.search("vocabulary",null),e.search("target",null),e.path("/search")},a.goToClassifications=function(){a.viewMode=ha.CLASSIFICATION,e.path("/classifications"),e.search("target",a.targetTabsOrder[0])},a.navigateToTarget=function(b){e.search("target",b),e.search("taxonomy",null),e.search("vocabulary",null),a.target=b},a.QUERY_TYPES=QUERY_TYPES,a.BUCKET_TYPES=BUCKET_TYPES,a.search={pagination:{},query:null,advanced:!1,rqlQuery:new RqlQuery,executedQuery:null,type:null,bucket:null,result:{list:null,coverage:null,graphics:null},criteria:[],criteriaItemMap:{},loading:!1},a.viewMode=ha.SEARCH,a.documents={search:{text:null,active:!1,target:null}},a.searchHeaderTemplateUrl=m.getHeaderUrl("search"),a.classificationsHeaderTemplateUrl=m.getHeaderUrl("classifications"),a.selectSearchTarget=ga,a.selectDisplay=ca,a.searchCriteria=X,a.selectCriteria=Z,a.searchKeyUp=$,a.showTaxonomy=T,a.clearTaxonomy=U,a.removeCriteriaItem=Y,a.refreshQuery=V,a.clearSearchQuery=Q,a.toggleSearchQuery=R,a.showAdvanced=S,a.onTypeChanged=_,a.onBucketChanged=aa,a.onDisplayChanged=ca,a.onUpdateCriteria=da,a.onRemoveCriteria=ea,a.onSelectTerm=fa,a.QUERY_TARGETS=QUERY_TARGETS,a.onPaginate=ba,a.inSearchMode=function(){return a.viewMode===ha.SEARCH},a.toggleFullscreen=function(){a.isFullscreen=!a.isFullscreen},a.$on("$locationChangeSuccess",function(a,b){x(),a!==b&&I()}),b.$on("ngObibaMicaSearch.fullscreenChange",function(b,c){a.isFullscreen=c}),L()}]).controller("NumericVocabularyPanelController",["$scope",function(a){a.$watch("taxonomies",function(){a.from=null,a.to=null},!0)}]).controller("MatchVocabularyPanelController",["$scope",function(a){a.$watch("taxonomies",function(){a.text=null},!0)}]).controller("NumericVocabularyFacetController",["$scope","JoinQuerySearchResource","RqlQueryService","RqlQueryUtils",function(a,b,c,d){function e(e,f){function g(a,b){var e=angular.copy(a.rqlQuery);return b.rqlQuery=d.buildRqlQuery(b),c.addCriteriaItem(e,b),e}var h=c.findCriterion(e,CriteriaIdGenerator.generate(a.$parent.taxonomy,f));h||(h=c.createCriteriaItem(a.target,a.$parent.taxonomy,a.vocabulary)),h.rqlQuery&&h.rqlQuery.args[1]?angular.isArray(h.rqlQuery.args[1])?(a.from=h.rqlQuery.args[1][0],a.to=h.rqlQuery.args[1][1]):h.rqlQuery.name===RQL_NODE.GE?a.from=h.rqlQuery.args[1]:a.to=h.rqlQuery.args[1]:(a.from=null,a.to=null,a.min=null,a.max=null);var i=d.hasTargetQuery(e.rqlQuery,h.target)?angular.copy(e.rqlQuery):g(e,h),j=c.prepareCriteriaTermsQuery(i,h);b[targetToType(a.target)]({query:j}).$promise.then(function(b){var d=c.getTargetAggregations(b,h,a.lang);d&&d.default&&(a.min=d.default.min,a.max=d.default.max)})}function f(){a.$parent.selectTerm(a.$parent.target,a.$parent.taxonomy,a.vocabulary,{from:a.from,to:a.to})}a.onKeypress=function(a){13===a.keyCode&&f()},a.$on("ngObibaMicaQueryUpdated",function(b,c){a.vocabulary.isNumeric&&a.vocabulary.isOpen&&e(c,a.vocabulary)}),a.$on("ngObibaMicaLoadVocabulary",function(b,c,d){a.vocabulary.isNumeric&&d.name===a.vocabulary.name&&!d.isOpen&&e(a.criteria,d)})}]).controller("MatchVocabularyFacetController",["$scope","RqlQueryService",function(a,b){function c(c,d){var e=b.findCriterion(c,CriteriaIdGenerator.generate(a.$parent.taxonomy,d));e&&e.rqlQuery&&e.rqlQuery.args[1]?a.text=e.rqlQuery.args[0]:a.text=null}function d(){a.$parent.selectTerm(a.$parent.target,a.$parent.taxonomy,a.vocabulary,{text:a.text||"*"})}a.onKeypress=function(a){13===a.keyCode&&d()},a.$on("ngObibaMicaQueryUpdated",function(b,d){a.vocabulary.isMatch&&a.vocabulary.isOpen&&c(d,a.vocabulary)}),a.$on("ngObibaMicaLoadVocabulary",function(b,d,e){e.name!==a.vocabulary.name||e.isOpen||c(a.criteria,e)})}]).controller("TermsVocabularyFacetController",["$scope","$filter","JoinQuerySearchResource","RqlQueryService","RqlQueryUtils",function(a,b,c,d,e){function f(a,b){return a.selectedTerms&&(a.rqlQuery.name===RQL_NODE.EXISTS||a.selectedTerms.indexOf(b.key)!==-1)}function g(b,g){function h(a,b){var c=angular.copy(a.rqlQuery);return b.rqlQuery=e.buildRqlQuery(b),d.addCriteriaItem(c,b),c}var i=null,j=!1,k=d.findCriterion(b,CriteriaIdGenerator.generate(a.$parent.taxonomy,g));k?j=!0:k=d.createCriteriaItem(a.target,a.$parent.taxonomy,a.vocabulary),e.hasTargetQuery(b.rqlQuery,k.target)?(i=angular.copy(b.rqlQuery),j||d.addCriteriaItem(i,k,RQL_NODE.OR)):i=h(b,k);var l=d.prepareCriteriaTermsQuery(i,k,k.lang);c[targetToType(a.target)]({query:l}).$promise.then(function(b){d.getTargetAggregations(b,k,k.lang).forEach(function(b){a.vocabulary.terms.some(function(a){if(a.name===b.key)return a.selected=f(k,b),a.count=b.count,!0})})})}a.selectTerm=function(b,c,f,g){var h=f.terms.filter(function(a){return a.selected}).map(function(a){return a.name}),i=d.findCriterion(a.criteria,CriteriaIdGenerator.generate(c,f));i?(0===h.length?d.removeCriteriaItem(i):(i.rqlQuery.name=RQL_NODE.IN,e.updateQuery(i.rqlQuery,h)),a.onRefresh()):a.onSelectTerm(b,c,f,g)},a.$on("ngObibaMicaQueryUpdated",function(b,c){a.vocabulary.isNumeric||a.vocabulary.isMatch||!a.vocabulary.isOpen||g(c,a.vocabulary)}),a.$on("ngObibaMicaLoadVocabulary",function(b,c,d){d.name!==a.vocabulary.name||a.vocabulary.isNumeric||a.vocabulary.isMatch||d.isOpen||g(a.criteria,d)})}]).controller("TaxonomiesPanelController",["$scope","$location","TaxonomyResource","TaxonomiesResource","ngObibaMicaSearch","RqlQueryUtils",TaxonomiesPanelController]).controller("ClassificationPanelController",["$scope","$location","TaxonomyResource","TaxonomiesResource","ngObibaMicaSearch","RqlQueryUtils",ClassificationPanelController]).controller("TaxonomiesFacetsController",["$scope","$timeout","TaxonomyResource","TaxonomiesResource","LocalizedValues","ngObibaMicaSearch","RqlQueryUtils",function(a,b,c,d,e,f,g){function h(b){a.taxonomies[b]||d.get({target:b},function(c){a.taxonomies[b]=a.facetedTaxonomies[b].map(function(a){return c.filter(function(b){return a.name===b.name})[0]}).filter(function(a){return a}).map(function(a){return a.vocabularies.map(function(a){a.limit=10,a.isMatch=g.isMatchVocabulary(a),a.isNumeric=g.isNumericVocabulary(a)}),a}),1===a.taxonomies[b].length&&(a.taxonomies[b][0].isOpen=1)})}a.options=f.getOptions(),a.taxonomies={},a.targets=[],a.RqlQueryUtils=g,a.$watch("facetedTaxonomies",function(b){b&&(a.targets=a.options.targetTabsOrder.filter(function(a){return b[a].length}),a.target=a.targets[0],h(a.target))}),a.selectTerm=function(b,c,d,e){a.onSelectTerm(b,c,d,e)},a.setTarget=function(c){a.target=c,h(c),a.criteria&&b(function(){a.$broadcast("ngObibaMicaQueryUpdated",a.criteria)})},a.loadVocabulary=function(b,c){a.$broadcast("ngObibaMicaLoadVocabulary",b,c)},a.localize=function(b){return e.forLocale(b,a.lang)},a.$on("ngObibaMicaQueryUpdated",function(b,c){a.criteria=c})}]).controller("SearchResultController",["$scope","ngObibaMicaSearch",function(a,b){function c(b){Object.keys(a.activeTarget).forEach(function(c){a.activeTarget[c].active=b===c})}a.targetTypeMap=a.$parent.taxonomyTypeMap,a.QUERY_TARGETS=QUERY_TARGETS,a.QUERY_TYPES=QUERY_TYPES,a.options=b.getOptions(),a.activeTarget={},a.activeTarget[QUERY_TYPES.VARIABLES]={active:!1,name:QUERY_TARGETS.VARIABLE,totalHits:0},a.activeTarget[QUERY_TYPES.DATASETS]={active:!1,name:QUERY_TARGETS.DATASET,totalHits:0},a.activeTarget[QUERY_TYPES.STUDIES]={active:!1,name:QUERY_TARGETS.STUDY,totalHits:0},a.activeTarget[QUERY_TYPES.NETWORKS]={active:!1,name:QUERY_TARGETS.NETWORK,totalHits:0},a.selectTarget=function(b){c(b),a.type=b,a.$parent.onTypeChanged(b)},a.getTotalHits=function(b){return a.result.list&&a.result.list[b+"ResultDto"]?a.result.list[b+"ResultDto"].totalHits:"..."},a.$watchCollection("result",function(){a.result.list&&(a.activeTarget[QUERY_TYPES.VARIABLES].totalHits=a.result.list.variableResultDto.totalHits,a.activeTarget[QUERY_TYPES.DATASETS].totalHits=a.result.list.datasetResultDto.totalHits,a.activeTarget[QUERY_TYPES.STUDIES].totalHits=a.result.list.studyResultDto.totalHits,a.activeTarget[QUERY_TYPES.NETWORKS].totalHits=a.result.list.networkResultDto.totalHits)}),a.$watch("type",function(a){c(a)}),a.DISPLAY_TYPES=DISPLAY_TYPES}]).controller("CriterionLogicalController",["$scope",function(a){a.updateLogical=function(b){a.item.rqlQuery.name=b,a.$emit(CRITERIA_ITEM_EVENT.refresh)}}]).controller("CriterionDropdownController",["$scope","$filter","LocalizedValues","RqlQueryUtils","StringUtils",function(a,b,c,d,e){var f=function(){if(a.state.open){a.state.onClose();var b=a.state.dirty;a.state.open=!1,a.state.dirty=!1,b&&a.$emit(CRITERIA_ITEM_EVENT.refresh)}},g=function(){return a.state.open?void f():(a.state.open=!0,void a.state.onOpen())},h=function(){a.$emit(CRITERIA_ITEM_EVENT.deleted,a.criterion)},i=function(a){13===a.keyCode&&f()};a.state=new CriterionState,a.timestamp=(new Date).getTime(),a.localize=function(b){return c.forLocale(b,a.criterion.lang)},a.localizeCriterion=function(){var d=a.criterion.rqlQuery;if((d.name===RQL_NODE.IN||d.name===RQL_NODE.CONTAINS)&&a.criterion.selectedTerms&&a.criterion.selectedTerms.length>0){var e=d.name===RQL_NODE.IN?" | ":" + ";return a.criterion.selectedTerms.map(function(b){if(!a.criterion.vocabulary.terms)return b;var d=a.criterion.vocabulary.terms.filter(function(a){return a.name===b}).pop();return d?c.forLocale(d.title,a.criterion.lang):b}).join(e)}var f=d.name;switch(d.name){case RQL_NODE.EXISTS:f=":"+b("translate")("any");break;case RQL_NODE.MISSING:f=":"+b("translate")("none");break;case RQL_NODE.EQ:f="="+d.args[1];break;case RQL_NODE.GE:f=">"+d.args[1];break;case RQL_NODE.LE:f="<"+d.args[1];break;case RQL_NODE.BETWEEN:f=":["+d.args[1]+")";break;case RQL_NODE.IN:case RQL_NODE.CONTAINS:f="";break;case RQL_NODE.MATCH:f=":match("+d.args[0]+")"}return c.forLocale(a.criterion.vocabulary.title,a.criterion.lang)+f},a.vocabularyType=function(a){return d.vocabularyType(a)},a.onKeyup=i,a.truncate=e.truncate,a.remove=h,a.openDropdown=g,a.closeDropdown=f,a.RqlQueryUtils=d}]).controller("MatchCriterionTermsController",["$scope","RqlQueryService","LocalizedValues","JoinQuerySearchResource","RqlQueryUtils","SearchContext",function(a,b,c,d,e,f){a.lang=f.currentLocale();var g=function(){a.state.dirty=!0,e.updateMatchQuery(a.criterion.rqlQuery,a.match)},h=a.criterion.rqlQuery.args[0];a.match="*"===h?"":h,a.update=g,a.localize=function(b){return c.forLocale(b,a.criterion.lang)}}]).controller("NumericCriterionController",["$scope","RqlQueryService","LocalizedValues","JoinQuerySearchResource","RqlQueryUtils","SearchContext",function(a,b,c,d,e,f){a.lang=f.currentLocale();var g=a.criterion.rqlQuery.args[1];angular.isArray(g)?(a.from=a.criterion.rqlQuery.args[1][0],a.to=a.criterion.rqlQuery.args[1][1]):(a.from=a.criterion.rqlQuery.name===RQL_NODE.GE?g:null,a.to=a.criterion.rqlQuery.name===RQL_NODE.LE?g:null);var h=function(){var c=a.criterion.target,e=b.prepareCriteriaTermsQuery(a.query,a.criterion);d[targetToType(c)]({query:e}).$promise.then(function(c){var d=b.getTargetAggregations(c,a.criterion,a.lang);d&&d.default&&(a.min=d.default.min,a.max=d.default.max)})},i=function(){h()},j=function(){a.updateSelection()};a.updateSelection=function(){e.updateRangeQuery(a.criterion.rqlQuery,a.from,a.to,a.selectMissing),a.state.dirty=!0},a.selectMissing=a.criterion.rqlQuery.name===RQL_NODE.MISSING,a.state.addOnClose(j),a.state.addOnOpen(i),a.localize=function(b){return c.forLocale(b,a.criterion.lang)}}]).controller("StringCriterionTermsController",["$scope","RqlQueryService","LocalizedValues","StringUtils","JoinQuerySearchResource","RqlQueryUtils","SearchContext","$filter",function(a,b,c,d,e,f,g,h){a.lang=g.currentLocale();var i=function(b){return a.checkboxTerms.indexOf(b)!==-1},j=function(){a.state.dirty=!0,a.criterion.rqlQuery.name=a.selectedFilter;var b=[];a.selectedFilter!==RQL_NODE.MISSING&&a.selectedFilter!==RQL_NODE.EXISTS&&Object.keys(a.checkboxTerms).forEach(function(c){a.checkboxTerms[c]&&b.push(c)}),0===b.length&&a.selectedFilter!==RQL_NODE.MISSING&&(a.criterion.rqlQuery.name=RQL_NODE.EXISTS),f.updateQuery(a.criterion.rqlQuery,b)},k=function(){j()},l=function(){return a.selectedFilter===RQL_NODE.IN},m=function(){return a.selectedFilter===RQL_NODE.CONTAINS},n=function(){a.state.loading=!0;var c=a.criterion.target,d=b.prepareCriteriaTermsQuery(a.query,a.criterion,a.lang);e[targetToType(c)]({query:d}).$promise.then(function(c){a.state.loading=!1,a.terms=b.getTargetAggregations(c,a.criterion,a.lang),a.terms&&(a.terms.forEach(function(b){a.checkboxTerms[b.key]=a.isSelectedTerm(b)}),a.terms=h("orderBySelection")(a.terms,a.checkboxTerms))})};a.isSelectedTerm=function(b){return a.criterion.selectedTerms&&a.criterion.selectedTerms.indexOf(b.key)!==-1},a.state.addOnOpen(n),a.checkboxTerms={},a.RQL_NODE=RQL_NODE,a.selectedFilter=a.criterion.type,a.isSelected=i,a.updateFilter=k,a.localize=function(b){return c.forLocale(b,a.criterion.lang)},a.truncate=d.truncate,a.isInFilter=l,a.isContainsFilter=m,a.updateSelection=j}]).controller("CoverageResultTableController",["$scope","$location","$q","PageUrlService","RqlQueryUtils","RqlQueryService","CoverageGroupByService",function(a,b,c,d,e,f,g){function h(a,b){for(var c=0,d=0,e=0;e=a[d].termsCount&&(d++,c=0),c+=b[e].termsCount,b[e].taxonomyName=a[d].entity.name}function i(a,b,c){var d=0;return a.reduce(function(a,e){return a[e.entity.name]=b.slice(d,d+e.termsCount).map(function(a){return e.termsCount>1&&"vocabularyName"===c&&(a.canRemove=!0),a[c]=e.entity.name,a}),d+=e.termsCount,a},{})}function j(a,b){switch(a){case BUCKET_TYPES.STUDY:case BUCKET_TYPES.DCE:return d.studyPage(b);case BUCKET_TYPES.NETWORK:return d.networkPage(b);case BUCKET_TYPES.DATASCHEMA:return d.datasetPage(b,"harmonization");case BUCKET_TYPES.DATASET:return d.datasetPage(b,"study")}return""}function k(b){var d=a.bucket===BUCKET_TYPES.DCE?"dceIds":"id";c.all(b.map(function(b){return f.createCriteriaItem(n[a.bucket],"Mica_"+n[a.bucket],d,b.value)})).then(function(b){if(b.length){var c=b.reduce(function(a,b){return a?(f.updateCriteriaItem(a,b),a):(b.rqlQuery=e.buildRqlQuery(b),b)},null);a.onUpdateCriteria(c,"variables",!0)}})}function l(){function b(a){var b;return i[a]?(b=0,i[a]=i[a]+1):(b=1,i[a]=1),b}function c(a,b,c){k[a]?(bk[a][1]&&(k[a][1]=c)):k[a]=[b,c]}function e(a,b){var c;if(a)if(a.indexOf("-")>0){var d=a.split("-");if(!b){var e=parseInt(d[1]);e<12?d[1]=e+1:(d[0]=parseInt(d[0])+1,d[1]=1)}var f=d[0]+"/"+d[1]+"/01";c=Date.parse(f)}else c=b?Date.parse(a+"/01/01"):Date.parse(a+"/12/31");return c}function f(a,b){var c=e(a,!0),d=b?e(b,!1):n,f=d0&&(h.ids[a.value][0].rowSpan=i[h.ids[a.value][0].id]),h.ids[a.value][1].rowSpan>0&&(h.ids[a.value][1].rowSpan=i[h.ids[a.value][1].id]);var b=a.value.split(":");if(k[b[0]]){var c=k[b[0]][0],d=k[b[0]][1],f=h.ids[a.value][2].start,g=h.ids[a.value][2].end,j=e(d,!1)-e(c,!0);h.ids[a.value][2].min=c,h.ids[a.value][2].max=d,h.ids[a.value][2].progressStart=100*(e(f,!0)-e(c,!0))/j,h.ids[a.value][2].progress=100*(e(g,!1)-e(f,!0))/j}}),h}function m(a){return a.reduce(function(a,b){return a?(f.updateCriteriaItem(a,b),a):(b.rqlQuery=e.buildRqlQuery(b),b)},null)}var n={},o={};n[BUCKET_TYPES.NETWORK]=QUERY_TARGETS.NETWORK,n[BUCKET_TYPES.STUDY]=QUERY_TARGETS.STUDY,n[BUCKET_TYPES.DCE]=QUERY_TARGETS.VARIABLE,n[BUCKET_TYPES.DATASCHEMA]=QUERY_TARGETS.DATASET,n[BUCKET_TYPES.DATASET]=QUERY_TARGETS.DATASET,a.showMissing=!0,a.toggleMissing=function(b){a.showMissing=b},a.groupByOptions=g,a.bucketSelection={dceBucketSelected:a.bucket===BUCKET_TYPES.DCE,datasetBucketSelected:a.bucket!==BUCKET_TYPES.DATASCHEMA},a.$watch("bucketSelection.dceBucketSelected",function(b,c){b!==c&&(b?a.selectBucket(BUCKET_TYPES.DCE):a.bucket===BUCKET_TYPES.DCE&&a.selectBucket(BUCKET_TYPES.STUDY))}),a.$watch("bucketSelection.datasetBucketSelected",function(b,c){b!==c&&(b?a.selectBucket(BUCKET_TYPES.DATASET):a.bucket===BUCKET_TYPES.DATASET&&a.selectBucket(BUCKET_TYPES.DATASCHEMA))}),a.selectBucket=function(b){b===BUCKET_TYPES.STUDY&&a.bucketSelection.dceBucketSelected&&(b=BUCKET_TYPES.DCE),b!==BUCKET_TYPES.DATASET||a.bucketSelection.datasetBucketSelected||(b=BUCKET_TYPES.DATASCHEMA),a.bucket=b,a.$parent.onBucketChanged(b)},a.rowspans={},a.getSpan=function(b,c){var d=0;if(c){var e=b+":"+c;return d=a.result.rows.filter(function(a){return a.title.startsWith(e+":")}).length,a.rowspans[e]=d,d}return d=a.result.rows.filter(function(a){return a.title.startsWith(b+":")}).length,a.rowspans[b]=d,d},a.hasSpan=function(b,c){return c?a.rowspans[b+":"+c]>0:a.rowspans[b]>0},a.hasVariableTarget=function(){var a=b.search().query;return a&&e.hasTargetQuery((new RqlParser).parse(a),RQL_NODE.VARIABLE)},a.hasSelected=function(){return a.table&&a.table.rows&&a.table.rows.filter(function(a){return a.selected}).length},a.selectAll=function(){a.table&&a.table.rows&&a.table.rows.forEach(function(a){a.selected=!0})},a.selectNone=function(){a.table&&a.table.rows&&a.table.rows.forEach(function(a){a.selected=!1})},a.selectFull=function(){a.table&&a.table.rows&&a.table.rows.forEach(function(a){a.hits?a.selected=0===a.hits.filter(function(a){return 0===a}).length:a.selected=!1})},a.BUCKET_TYPES=BUCKET_TYPES,a.downloadUrl=function(){return d.downloadCoverage(a.query)},a.$watch("result",function(){if(a.table={cols:[]},o={},a.result&&a.result.rows){var b=a.result;b.cols=l(),a.table=b,o=i(a.table.vocabularyHeaders,a.table.termHeaders,"vocabularyName"),i(a.table.taxonomyHeaders,a.table.termHeaders,"taxonomyName"),h(a.table.taxonomyHeaders,a.table.vocabularyHeaders)}}),a.updateCriteria=function(b,d,e,g){var h=a.bucket===BUCKET_TYPES.DCE?"dceIds":"id",i={varItem:f.createCriteriaItem(QUERY_TARGETS.VARIABLE,d.taxonomyName,d.vocabularyName,d.entity.name)};b?i.item=f.createCriteriaItem(n[a.bucket],"Mica_"+n[a.bucket],h,b):a.bucket===BUCKET_TYPES.STUDY||a.bucket===BUCKET_TYPES.DATASET?i.item=f.createCriteriaItem(QUERY_TARGETS.DATASET,"Mica_"+QUERY_TARGETS.DATASET,"className","StudyDataset"):a.bucket!==BUCKET_TYPES.NETWORK&&a.bucket!==BUCKET_TYPES.DATASCHEMA||(i.item=f.createCriteriaItem(QUERY_TARGETS.DATASET,"Mica_"+QUERY_TARGETS.DATASET,"className","HarmonizationDataset")),c.all(i).then(function(b){a.onUpdateCriteria(b.varItem,g,!1,!0),b.item&&a.onUpdateCriteria(b.item,g)})},a.isFullCoverageImpossibleOrCoverageAlreadyFull=function(){var b=a.table?a.table.rows||[]:[],c=0;return 0===b.length||(b.forEach(function(a){a.hits&&a.hits.filter(function(a){return 0===a}).length>0&&c++}),0===c||b.length===c)},a.selectFullAndFilter=function(){var b=[];a.table&&a.table.rows&&a.table.rows.forEach(function(a){a.hits&&0===a.hits.filter(function(a){return 0===a}).length&&b.push(a)}),k(b)},a.updateFilterCriteria=function(){k(a.table.rows.filter(function(a){return a.selected}))},a.removeTerm=function(b){var d=o[b.vocabularyName].filter(function(a){return a.entity.name!==b.entity.name}).map(function(a){return f.createCriteriaItem(QUERY_TARGETS.VARIABLE,a.taxonomyName,a.vocabularyName,a.entity.name)});c.all(d).then(function(b){a.onUpdateCriteria(m(b),null,!0,!1,!1)})},a.removeVocabulary=function(b){f.createCriteriaItem(QUERY_TARGETS.VARIABLE,b.taxonomyName,b.entity.name).then(function(b){a.onRemoveCriteria(b)})}}]).controller("GraphicsResultController",["GraphicChartsConfig","GraphicChartsUtils","RqlQueryService","$filter","$scope",function(a,b,c,d,e){var f=function(a,c,d,e,f,g){return b.getArrayByAggregation(a,c).then(function(b){var c=b.map(function(a){return a.participantsNbr&&g?[a.title,a.value,a.participantsNbr]:[a.title,a.value]});if(c.length>0)return c.unshift(d),angular.extend(f,{title:e}),{data:c,entries:b,options:f,vocabulary:a}})},g=a.getOptions().ChartsOptions;e.updateCriteria=function(a,b){c.createCriteriaItem("study","Mica_study",b,a).then(function(a){e.onUpdateCriteria(a,"studies")})},e.$watch("result",function(a){e.chartObjects={},e.noResults=!0,a&&a.studyResultDto.totalHits&&(e.noResults=!1,f("populations-selectionCriteria-countriesIso",a.studyResultDto,[d("translate")(g.geoChartOptions.header[0]),d("translate")(g.geoChartOptions.header[1])],d("translate")(g.geoChartOptions.title)+" (N = "+a.studyResultDto.totalHits+")",g.geoChartOptions.options).then(function(a){if(a){var b={geoChartOptions:{directiveTitle:a.options.title,headerTitle:d("translate")("graphics.geo-charts"),chartObject:{geoTitle:a.options.title,options:a.options,type:"GeoChart",vocabulary:a.vocabulary,data:a.data,entries:a.entries}}};b.geoChartOptions.getTable=function(){return b.geoChartOptions.chartObject},angular.extend(e.chartObjects,b)}}),f("methods-designs",a.studyResultDto,[d("translate")(g.studiesDesigns.header[0]),d("translate")(g.studiesDesigns.header[1])],d("translate")(g.studiesDesigns.title)+" (N = "+a.studyResultDto.totalHits+")",g.studiesDesigns.options).then(function(a){if(a){var b={studiesDesigns:{headerTitle:d("translate")("graphics.study-design"),chartObject:{options:a.options,type:"BarChart",data:a.data,vocabulary:a.vocabulary,entries:a.entries}}};angular.extend(e.chartObjects,b)}}),f("methods-designs",a.studyResultDto,[d("translate")(g.studiesDesigns.header[0]),d("translate")(g.studiesDesigns.header[1]),d("translate")(g.studiesDesigns.header[2])],d("translate")(g.studiesDesigns.title)+" (N = "+a.studyResultDto.totalHits+")",g.studiesDesigns.options,!0).then(function(a){if(a){var b={chartObjectTable:{options:a.options,type:"BarChart",data:a.data,vocabulary:a.vocabulary,entries:a.entries}};b.getTable=function(){return b.chartObjectTable},angular.extend(e.chartObjects.studiesDesigns,b)}}),f("numberOfParticipants-participant-range",a.studyResultDto,[d("translate")(g.numberParticipants.header[0]),d("translate")(g.numberParticipants.header[1])],d("translate")(g.numberParticipants.title)+" (N = "+a.studyResultDto.totalHits+")",g.numberParticipants.options).then(function(a){if(a){var b={numberParticipants:{headerTitle:d("translate")("graphics.number-participants"),chartObject:{options:a.options,type:"PieChart",data:a.data,vocabulary:a.vocabulary,entries:a.entries}}};b.numberParticipants.getTable=function(){return b.numberParticipants.chartObject},angular.extend(e.chartObjects,b)}}),f("populations-dataCollectionEvents-bioSamples",a.studyResultDto,[d("translate")(g.biologicalSamples.header[0]),d("translate")(g.biologicalSamples.header[1])],d("translate")(g.biologicalSamples.title)+" (N = "+a.studyResultDto.totalHits+")",g.biologicalSamples.options).then(function(a){if(a){var b={biologicalSamples:{headerTitle:d("translate")("graphics.bio-samples"),chartObject:{options:a.options,type:"BarChart",data:a.data,vocabulary:a.vocabulary,entries:a.entries}}};b.biologicalSamples.getTable=function(){return b.biologicalSamples.chartObject},angular.extend(e.chartObjects,b)}}))})}]).controller("SearchResultPaginationController",["$scope",function(a){function b(){a.maxSize=Math.min(3,Math.ceil(a.totalHits/a.pagination.selected.value))}function c(){var b=a.pagination.selected.value,c=a.pagination.currentPage;a.pagination.from=b*(c-1)+1,a.pagination.to=Math.min(a.totalHits,b*c)}var d=function(){c(),a.onChange&&a.onChange(a.target,(a.pagination.currentPage-1)*a.pagination.selected.value,a.pagination.selected.value)},e=function(){b(),a.pagination.currentPage=1,d()};a.pageChanged=d,a.pageSizeChanged=e,a.pageSizes=[{label:"10",value:10},{label:"20",value:20},{label:"50",value:50},{label:"100",value:100}],a.pagination={selected:a.pageSizes[0],currentPage:1},a.$watch("totalHits",function(){b(),c()})}]);var CRITERIA_ITEM_EVENT={deleted:"event:delete-criteria-item",refresh:"event:refresh-criteria-item"};angular.module("obiba.mica.search").directive("taxonomyPanel",[function(){return{restrict:"EA",replace:!0,scope:{taxonomy:"=",lang:"=",onNavigate:"="},templateUrl:"search/views/classifications/taxonomy-panel-template.html"}}]).directive("vocabularyPanel",[function(){return{restrict:"EA",replace:!0,scope:{target:"=",taxonomy:"=",vocabulary:"=",lang:"=",onNavigate:"=",onSelect:"=",onHideSearchNavigate:"=",isInHideNavigate:"="},templateUrl:"search/views/classifications/vocabulary-panel-template.html"}}]).directive("termPanel",[function(){return{restrict:"EA",replace:!0,scope:{target:"=",taxonomy:"=",vocabulary:"=",term:"=",lang:"=",onSelect:"="},templateUrl:"search/views/classifications/term-panel-template.html"}}]).directive("networksResultTable",["PageUrlService","ngObibaMicaSearch","RqlQueryService",function(a,b,c){return{restrict:"EA",replace:!0,scope:{summaries:"=",loading:"=",onUpdateCriteria:"="},templateUrl:"search/views/list/networks-search-result-table-template.html",link:function(d){d.options=b.getOptions().networks,d.optionsCols=d.options.networksColumn,d.PageUrlService=a,d.updateCriteria=function(a,b){var e;"HarmonizationDataset"!==b&&"StudyDataset"!==b||(e=b,b="datasets");var f;"DataschemaVariable"!==b&&"StudyVariable"!==b||(f=b.replace("Variable",""),b="variables"),c.createCriteriaItem("network","Mica_network","id",a).then(function(a){e?c.createCriteriaItem("dataset","Mica_dataset","className",e).then(function(c){d.onUpdateCriteria(a,b),d.onUpdateCriteria(c,b)}):f?c.createCriteriaItem("variable","Mica_variable","variableType",f).then(function(c){d.onUpdateCriteria(a,b),d.onUpdateCriteria(c,b)}):d.onUpdateCriteria(a,b)})}}}}]).directive("datasetsResultTable",["PageUrlService","ngObibaMicaSearch","TaxonomyResource","RqlQueryService",function(a,b,c,d){return{restrict:"EA",replace:!0,scope:{summaries:"=",loading:"=",onUpdateCriteria:"="},templateUrl:"search/views/list/datasets-search-result-table-template.html",link:function(e){e.classNames={},c.get({target:"dataset",taxonomy:"Mica_dataset"}).$promise.then(function(a){e.classNames=a.vocabularies.filter(function(a){return"className"===a.name})[0].terms.reduce(function(a,b){return a[b.name]=b.title.map(function(a){return{lang:a.locale,value:a.text}}),a},{})}),e.updateCriteria=function(a,b){d.createCriteriaItem("dataset","Mica_dataset","id",a).then(function(a){e.onUpdateCriteria(a,b)})},e.options=b.getOptions().datasets,e.optionsCols=e.options.datasetsColumn,e.PageUrlService=a}}}]).directive("studiesResultTable",["PageUrlService","ngObibaMicaSearch","TaxonomyResource","RqlQueryService","LocalizedValues",function(a,b,c,d,e){return{restrict:"EA",replace:!0,scope:{lang:"=",summaries:"=",loading:"=",onUpdateCriteria:"="},templateUrl:"search/views/list/studies-search-result-table-template.html",link:function(f){function g(){Object.keys(f.taxonomy)<1||Object.keys(f.datasourceTitles)>0||f.taxonomy.vocabularies.some(function(a){return"populations-dataCollectionEvents-dataSources"===a.name&&(a.terms.forEach(function(a){f.datasourceTitles[a.name]={title:e.forLocale(a.title,f.lang)}}),!0)})}f.taxonomy={},f.designs={},f.datasourceTitles={},f.$watch("lang",g),c.get({target:"study",taxonomy:"Mica_study"}).$promise.then(function(a){f.taxonomy=a,g(),
+f.designs=a.vocabularies.filter(function(a){return"methods-designs"===a.name})[0].terms.reduce(function(a,b){return a[b.name]=b.title.map(function(a){return{lang:a.locale,value:a.text}}),a},{})}),f.hasDatasource=function(a,b){return a&&a.indexOf(b)>-1},f.options=b.getOptions().studies,f.optionsCols=f.options.studiesColumn,f.PageUrlService=a,f.updateCriteria=function(a,b){var c;"HarmonizationDataset"!==b&&"StudyDataset"!==b||(c=b,b="datasets");var e;"DataschemaVariable"!==b&&"StudyVariable"!==b||(e=b.replace("Variable",""),b="variables"),d.createCriteriaItem("study","Mica_study","id",a).then(function(a){c?d.createCriteriaItem("dataset","Mica_dataset","className",c).then(function(c){f.onUpdateCriteria(a,b),f.onUpdateCriteria(c,b)}):e?d.createCriteriaItem("variable","Mica_variable","variableType",e).then(function(c){f.onUpdateCriteria(a,b),f.onUpdateCriteria(c,b)}):f.onUpdateCriteria(a,b)})}}}}]).directive("variablesResultTable",["PageUrlService","ngObibaMicaSearch",function(a,b){return{restrict:"EA",replace:!0,scope:{summaries:"=",loading:"="},templateUrl:"search/views/list/variables-search-result-table-template.html",link:function(c){c.options=b.getOptions().variables,c.optionsCols=c.options.variablesColumn,c.PageUrlService=a}}}]).directive("coverageResultTable",[function(){return{restrict:"EA",replace:!0,scope:{result:"=",loading:"=",bucket:"=",query:"=",onUpdateCriteria:"=",onRemoveCriteria:"="},controller:"CoverageResultTableController",templateUrl:"search/views/coverage/coverage-search-result-table-template.html"}}]).directive("graphicsResult",[function(){return{restrict:"EA",replace:!0,scope:{result:"=",loading:"=",onUpdateCriteria:"="},controller:"GraphicsResultController",templateUrl:"search/views/graphics/graphics-search-result-template.html"}}]).directive("includeReplace",function(){return{require:"ngInclude",link:function(a,b){b.replaceWith(b.children())}}}).directive("scrollToTop",function(){return{restrict:"A",scope:{trigger:"=scrollToTop"},link:function(a,b){a.$watch("trigger",function(){b[0].scrollTop=0})}}}).directive("resultPanel",[function(){return{restrict:"EA",replace:!0,scope:{type:"=",bucket:"=",query:"=",display:"=",result:"=",lang:"=",loading:"=",searchTabsOrder:"=",resultTabsOrder:"=",onTypeChanged:"=",onBucketChanged:"=",onPaginate:"=",onUpdateCriteria:"=",onRemoveCriteria:"="},controller:"SearchResultController",templateUrl:"search/views/search-result-panel-template.html"}}]).directive("criteriaRoot",[function(){return{restrict:"EA",replace:!0,scope:{item:"=",query:"=",advanced:"=",onRemove:"=",onRefresh:"="},templateUrl:"search/views/criteria/criteria-root-template.html",link:function(a){a.$on(CRITERIA_ITEM_EVENT.deleted,function(b,c){a.onRemove(c)}),a.$on(CRITERIA_ITEM_EVENT.refresh,function(){a.onRefresh()})}}}]).directive("criteriaTarget",[function(){return{restrict:"EA",replace:!0,scope:{item:"=",query:"=",advanced:"="},templateUrl:"search/views/criteria/criteria-target-template.html"}}]).directive("criteriaNode",[function(){return{restrict:"EA",replace:!0,scope:{item:"=",query:"=",advanced:"="},controller:"CriterionLogicalController",templateUrl:"search/views/criteria/criteria-node-template.html"}}]).directive("criteriaLeaf",["CriteriaNodeCompileService",function(a){return{restrict:"EA",replace:!0,scope:{item:"=",query:"=",advanced:"="},controller:"CriterionLogicalController",link:function(b,c){a.compile(b,c)}}}]).directive("numericCriterion",[function(){return{restrict:"EA",replace:!0,scope:{criterion:"=",query:"=",state:"="},controller:"NumericCriterionController",templateUrl:"search/views/criteria/criterion-numeric-template.html"}}]).directive("criterionDropdown",["$document","$timeout",function(a,b){return{restrict:"EA",replace:!0,scope:{criterion:"=",query:"="},controller:"CriterionDropdownController",templateUrl:"search/views/criteria/criterion-dropdown-template.html",link:function(c,d){var e=function(a){var d=document.querySelector("#"+c.criterion.id.replace(".","-")+"-dropdown-"+c.timestamp).contains(a.target);d||b(function(){c.$apply("closeDropdown()")})};a.on("click",e),d.on("$destroy",function(){a.off("click",e)})}}}]).directive("stringCriterionTerms",[function(){return{restrict:"EA",replace:!0,scope:{criterion:"=",query:"=",state:"="},controller:"StringCriterionTermsController",templateUrl:"search/views/criteria/criterion-string-terms-template.html"}}]).directive("matchCriterion",[function(){return{restrict:"EA",replace:!0,scope:{criterion:"=",query:"=",state:"="},controller:"MatchCriterionTermsController",templateUrl:"search/views/criteria/criterion-match-template.html"}}]).directive("searchResultPagination",[function(){return{restrict:"EA",replace:!0,scope:{target:"=",totalHits:"=",onChange:"="},controller:"SearchResultPaginationController",templateUrl:"search/views/list/search-result-pagination-template.html"}}]).directive("taxonomiesFacetsPanel",[function(){return{restrict:"EA",scope:{facetedTaxonomies:"=",onRefresh:"=",onSelectTerm:"=",lang:"=",criteria:"="},controller:"TaxonomiesFacetsController",templateUrl:"search/views/classifications/taxonomies-facets-view.html"}}]).directive("taxonomiesPanel",[function(){return{restrict:"EA",replace:!0,scope:{taxonomyName:"=",target:"=",onClose:"=",onSelectTerm:"=",taxonomiesShown:"=",lang:"="},controller:"TaxonomiesPanelController",templateUrl:"search/views/classifications/taxonomies-view.html",link:function(a,b){a.closeTaxonomies=function(){b.collapse("hide"),a.onClose()},a.showTaxonomies=function(){b.collapse("show")},b.on("show.bs.collapse",function(){a.taxonomiesShown=!0}),b.on("hide.bs.collapse",function(){a.taxonomiesShown=!1}),a.$watch("taxonomiesShown",function(a){a?b.collapse("show"):b.collapse("hide")})}}}]).directive("classificationsPanel",[function(){return{restrict:"EA",replace:!0,scope:{target:"=",onSelectTerm:"=",isHistoryEnabled:"=",lang:"="},controller:"ClassificationPanelController",templateUrl:"search/views/classifications/classifications-view.html"}}]).factory("Fullscreen",["$document","$window","$rootScope",function(a,b,c){var d=a[0],e="undefined"!=typeof b.Element&&"ALLOW_KEYBOARD_INPUT"in b.Element&&b.Element.ALLOW_KEYBOARD_INPUT,f=c.$new(),g={$on:angular.bind(f,f.$on),enable:function(a){a.requestFullScreen?a.requestFullScreen():a.mozRequestFullScreen?a.mozRequestFullScreen():a.webkitRequestFullscreen?/Version\/[\d]{1,2}(\.[\d]{1,2}){1}(\.(\d){1,2}){0,1} Safari/.test(b.navigator.userAgent)?a.webkitRequestFullscreen():a.webkitRequestFullscreen(e):a.msRequestFullscreen&&a.msRequestFullscreen()},cancel:function(){d.cancelFullScreen?d.cancelFullScreen():d.mozCancelFullScreen?d.mozCancelFullScreen():d.webkitExitFullscreen?d.webkitExitFullscreen():d.msExitFullscreen&&d.msExitFullscreen()},isEnabled:function(){var a=d.fullscreenElement||d.mozFullScreenElement||d.webkitFullscreenElement||d.msFullscreenElement;return!!a}};return a.on("fullscreenchange webkitfullscreenchange mozfullscreenchange MSFullscreenChange",function(){f.$emit("ngObibaMicaSearch.fullscreenChange",g.isEnabled())}),g}]).directive("fullscreen",["Fullscreen",function(a){return{link:function(b,c,d){d.fullscreen&&b.$watch(d.fullscreen,function(b){var d=a.isEnabled();b&&!d?(a.enable(c[0]),c.addClass("isInFullScreen")):!b&&d&&(a.cancel(),c.removeClass("isInFullScreen"))})}}}]),angular.module("obiba.mica.search").config(["$routeProvider",function(a){a.when("/search",{templateUrl:"search/views/search.html",controller:"SearchController",reloadOnSearch:!1}).when("/classifications",{templateUrl:"search/views/classifications.html",controller:"SearchController",reloadOnSearch:!1})}]),angular.module("obiba.mica.graphics",["googlechart","obiba.utils","templates-ngObibaMica"]).config(["$provide",function(a){a.provider("GraphicChartsData",GraphicChartsDataProvider)}]).run(["GraphicChartsConfigurations",function(a){a.setClientConfig()}]),angular.module("obiba.mica.graphics").directive("obibaChart",[function(){return{restrict:"EA",replace:!0,scope:{fieldTransformer:"=",chartType:"=",chartAggregationName:"=",chartEntityDto:"=",chartOptionsName:"=",chartOptions:"=",chartHeader:"=",chartTitle:"=",chartTitleGraph:"=",chartSelectGraphic:"="},templateUrl:"graphics/views/charts-directive.html",controller:"GraphicChartsController"}}]).directive("obibaTable",[function(){return{restrict:"EA",replace:!0,scope:{fieldTransformer:"=",chartType:"@",chartAggregationName:"=",chartEntityDto:"=",chartOptionsName:"=",chartOptions:"=",chartHeader:"=",chartTitle:"=",chartTitleGraph:"=",chartSelectGraphic:"=",chartOrdered:"=",chartNotOrdered:"="},templateUrl:"graphics/views/tables-directive.html",controller:"GraphicChartsController"}}]),angular.module("obiba.mica.graphics").controller("GraphicChartsController",["$rootScope","$scope","$filter","$window","GraphicChartsConfig","GraphicChartsUtils","GraphicChartsData","RqlQueryService","ngObibaMicaUrl","googleChartApiPromise",function(a,b,c,d,e,f,g,h,i,j){function k(){b.chartObject={},g.getData(function(a){a&&f.getArrayByAggregation(b.chartAggregationName,a[b.chartEntityDto]).then(function(f){var g=f.map(function(a){return a.participantsNbr?[a.title,a.value,a.participantsNbr]:[a.title,a.value]});b.updateCriteria=function(a,b){h.createCriteriaItem("study","Mica_study",b,a).then(function(a){var b=e.getOptions().entityType,c=e.getOptions().entityIds,f=a.id.split("."),g=i.getUrl("GraphicsSearchRootUrl")+"?type=studies&query="+b+"(in(Mica_"+b+".id,"+c+")),study(in("+f[0]+"."+f[1]+","+f[2].replace(":","%253A")+"))";d.location.href=i.getUrl("BaseUrl")+g})},g&&(null!==/^Table-/.exec(b.chartType)?(b.chartObject.ordered=b.chartOrdered,b.chartObject.notOrdered=b.chartNotOrdered,b.chartHeader.length<3?b.chartObject.header=[c("translate")(b.chartHeader[0]),c("translate")(b.chartHeader[1])]:b.chartObject.header=[c("translate")(b.chartHeader[0]),c("translate")(b.chartHeader[1]),c("translate")(b.chartHeader[2])],b.chartObject.type=b.chartType,b.chartObject.data=g,b.chartObject.vocabulary=b.chartAggregationName,b.chartObject.entries=f,b.chartObject.getTable=function(){return b.chartObject}):(b.chartHeader.length<3?g.unshift([c("translate")(b.chartHeader[0]),c("translate")(b.chartHeader[1])]):(g.map(function(a){return a.pop(),a}),g.unshift([c("translate")(b.chartHeader[0]),c("translate")(b.chartHeader[1])])),b.chartObject.term=!0,b.chartObject.type=b.chartType,b.chartObject.data=g,b.chartObject.options={backgroundColor:{fill:"transparent"}},angular.extend(b.chartObject.options,b.chartOptions),b.chartObject.options.title=c("translate")(b.chartTitleGraph)+" (N="+a.studyResultDto.totalHits+")",b.$parent.directive={title:b.chartObject.options.title}))})})}j.then(function(){b.ready=!0}),b.$watchGroup(["chartType","ready"],function(){b.chartType&&b.ready&&k()})}]),angular.module("obiba.mica.graphics").factory("GraphicChartsDataResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("JoinQuerySearchResource"),{},{studies:{method:"GET",errorHandler:!0,params:{type:"studies"}}})}]).service("GraphicChartsConfig",function(){var a={options:{entityIds:"NaN",entityType:null,ChartsOptions:{geoChartOptions:{header:["graphics.country","graphics.nbr-studies"],title:"graphics.geo-chart-title",options:{backgroundColor:{fill:"transparent"},colors:["#e5edfb","#cfddf5","#b8cbed","#a0b8e2","#88a4d4"]}},studiesDesigns:{header:["graphics.study-design","graphics.nbr-studies","graphics.number-participants"],title:"graphics.study-design-chart-title",options:{bars:"horizontal",series:{0:{axis:"nbrStudies"},1:{axis:"nbrParticipants"}},axes:{x:{nbrStudies:{side:"top",label:"Number of Studies"},nbrParticipants:{label:"Number of Participants"}}},backgroundColor:{fill:"transparent"},colors:["#b8cbed","#e5edfb","#cfddf5","#a0b8e2","#88a4d4"]}},numberParticipants:{header:["graphics.number-participants","graphics.nbr-studies"],title:"graphics.number-participants-chart-title",options:{backgroundColor:{fill:"transparent"},colors:["#b8cbed","#e5edfb","#cfddf5","#a0b8e2","#88a4d4"],pieSliceTextStyle:{color:"#000000"}}},biologicalSamples:{header:["graphics.bio-samples","graphics.nbr-studies"],title:"graphics.bio-samples-chart-title",options:{bars:"horizontal",series:{0:{axis:"nbrStudies"}},axes:{x:{nbrStudies:{side:"top",label:"Number of Studies"}}},backgroundColor:{fill:"transparent"},colors:["#b8cbed","#e5edfb","#cfddf5","#a0b8e2","#88a4d4"]}}}}};return a.setOptions=function(b){"object"==typeof b&&Object.keys(b).forEach(function(c){c in a.options&&(a.options[c]=b[c])})},a.getOptions=function(){return angular.copy(a.options)},a}).service("GraphicChartsUtils",["LocalizedValues","TaxonomyResource","$q",function(a,b,c){var d={};d.getTerms=function(a){function e(){var b=null;d.vocabularies&&angular.forEach(d.vocabularies,function(c){c.name===a&&(b=c.terms)}),f.resolve(b)}var f=c.defer();return d.vocabularies?e():b.get({target:"study",taxonomy:"Mica_study"}).$promise.then(function(a){d.vocabularies=angular.copy(a.vocabularies),e()}),f.promise},this.getArrayByAggregation=function(b,e){var f=c.defer();b&&e||f.resolve([]);var g=[];return d.getTerms(b).then(function(c){var d=c,h=0;angular.forEach(e.aggs,function(c){if(c.aggregation===b)if(c["obiba.mica.RangeAggregationResultDto.ranges"])h=0,angular.forEach(d,function(a){angular.forEach(c["obiba.mica.RangeAggregationResultDto.ranges"],function(b){a.name===b.key&&b.count&&(g[h]={title:b.title,value:b.count,key:b.key},h++)})});else{if("populations-selectionCriteria-countriesIso"===c.aggregation){var e=a.getLocal();d.sort(function(b,c){var d=a.forLocale(b.title,e),f=a.forLocale(c.title,e);return df?1:0})}var f=0;h=0,angular.forEach(d,function(b){angular.forEach(c["obiba.mica.TermsAggregationResultDto.terms"],function(d){b.name===d.key&&d.count&&("methods-designs"===c.aggregation?(angular.forEach(d.aggs,function(b){if("numberOfParticipants-participant-number"===b.aggregation){var c=b["obiba.mica.StatsAggregationResultDto.stats"];f=a.formatNumber(c?c.data.sum:0)}}),g[h]={title:d.title,value:d.count,participantsNbr:f,key:d.key}):g[h]={title:d.title,value:d.count,key:d.key},h++)})})}}),f.resolve(g)}),f.promise}}]).service("GraphicChartsQuery",["RqlQueryService","RqlQueryUtils","LocalizedValues",function(a,b,c){this.queryDtoBuilder=function(d,e){var f;d&&"NaN"!==d||(f="study(exists(Mica_study.id))"),e&&"NaN"!==d&&(f=e+"(in(Mica_"+e+".id,("+d+")))");var g=angular.copy((new RqlParser).parse(f));b.addLocaleQuery(g,c.getLocal());var h=(new RqlQuery).serializeArgs(g.args);return a.prepareGraphicsQuery(h,["Mica_study.populations-selectionCriteria-countriesIso","Mica_study.populations-dataCollectionEvents-bioSamples","Mica_study.numberOfParticipants-participant-number"],["Mica_study.methods-designs"])}}]),angular.module("obiba.mica.localized",["obiba.notification","pascalprecht.translate","templates-ngObibaMica"]),angular.module("obiba.mica.localized").directive("localized",["LocalizedValues",function(a){return{restrict:"AE",scope:{value:"=",lang:"="},templateUrl:"localized/localized-template.html",link:function(b){b.LocalizedValues=a}}}]).directive("localizedNumber",["LocalizedValues",function(a){return{restrict:"E",scope:{number:"=value"},template:"{{LocalizedValues.formatNumber(number)}}",link:function(b){b.LocalizedValues=a}}}]).directive("localizedInput",[function(){return{restrict:"AE",require:"^form",scope:{name:"@",model:"=",label:"@",required:"@",disabled:"=",lang:"=",help:"@",customValidator:"="},templateUrl:"localized/localized-input-template.html",link:function(a,b,c,d){(angular.isUndefined(a.model)||null===a.model)&&(a.model=[{lang:a.lang,value:""}]),a.$watch("model",function(b){(angular.isUndefined(b)||null===b)&&(a.model=[{lang:a.lang,value:""}]);var c=a.model.filter(function(b){if(b.lang===a.lang)return b});0===c.length&&a.model.push({lang:a.lang,value:""})},!0),a.fieldName=a.name+"-"+a.lang,a.form=d}}}]).directive("localizedInputGroup",[function(){return{restrict:"AE",require:"^form",scope:{name:"@",model:"=",label:"@",required:"@",disabled:"=",lang:"=",help:"@",remove:"=",customValidator:"="},templateUrl:"localized/localized-input-group-template.html",link:function(a,b,c,d){(angular.isUndefined(a.model)||null===a.model)&&(a.model=[{lang:a.lang,value:""}]),a.$watch("model",function(b){(angular.isUndefined(b)||null===b)&&(a.model=[{lang:a.lang,value:""}]);var c=a.model.filter(function(b){if(b.lang===a.lang)return b});0===c.length&&a.model.push({lang:a.lang,value:""})},!0),a.fieldName=a.name+"-"+a.lang,a.form=d}}}]).directive("localizedTextarea",[function(){return{restrict:"AE",require:"^form",scope:{name:"@",model:"=",label:"@",required:"@",disabled:"=",lang:"=",help:"@",rows:"@",customValidator:"="},templateUrl:"localized/localized-textarea-template.html",link:function(a,b,c,d){(angular.isUndefined(a.model)||null===a.model)&&(a.model=[{lang:a.lang,value:""}]),a.$watch("model",function(b){(angular.isUndefined(b)||null===b)&&(a.model=[{lang:a.lang,value:""}]);var c=a.model.filter(function(b){if(b.lang===a.lang)return b});0===c.length&&a.model.push({lang:a.lang,value:""})},!0),a.fieldName=a.name+"-"+a.lang,a.form=d}}}]),angular.module("obiba.mica.localized").service("LocalizedValues",function(){var a=this;this.for=function(b,c,d,e){if(angular.isArray(b)){var f=b.filter(function(a){return a[d]===c});if(f&&f.length>0)return f[0][e]}else if(angular.isObject(b))return a.for(Object.keys(b).map(function(a){return{lang:a,value:b[a]}}),c,d,e);return""},this.forLocale=function(a,b){var c=this.for(a,b,"locale","text");return""===c&&(c=this.for(a,"und","locale","text")),c},this.forLang=function(a,b){var c=this.for(a,b,"lang","value");return""===c&&(c=this.for(a,"und","lang","value")),c},this.getLocal=function(){return"en"},this.formatNumber=function(a){return"undefined"==typeof a&&null===a&&"number"!=typeof a?a:a.toLocaleString(this.getLocal())},this.arrayToObject=function(a){var b={};return a&&a.forEach(function(a){b[a.lang]=a.value}),b},this.objectToArray=function(a,b){var c=[];return b&&a&&a.forEach(function(a){c.push({lang:a,value:b[a]})}),c}}).service("LocalizedSchemaFormService",["$filter",function(a){this.translate=function(a){return a?"string"==typeof a?this.translateString(a):"object"==typeof a?Array.isArray(a)?this.translateArray(a):this.translateObject(a):a:a},this.translateObject=function(a){if(!a)return a;for(var b in a)a.hasOwnProperty(b)&&("string"==typeof a[b]?a[b]=this.translateString(a[b]):"object"==typeof a[b]&&(Array.isArray(a[b])?a[b]=this.translateArray(a[b]):a[b]=this.translateObject(a[b])));return a},this.translateArray=function(a){if(!a)return a;var b=this;return a.map(function(a){return b.translate(a)}),a},this.translateString=function(b){return b?b.replace(/t\(([^\)]+)\)/g,function(b,c){return a("translate")(c)}):b}}]),angular.module("obiba.mica.localized").filter("localizedNumber",["LocalizedValues",function(a){return function(b){return 0===b?0:b?a.formatNumber(b):""}}]),angular.module("obiba.mica.fileBrowser",["pascalprecht.translate","ui.bootstrap","templates-ngObibaMica"]).config(["$provide",function(a){a.provider("ngObibaMicaFileBrowserOptions",new NgObibaMicaFileBrowserOptionsProvider)}]),angular.module("obiba.mica.fileBrowser").directive("fileBrowser",[function(){return{restrict:"EA",replace:!0,controller:"FileBrowserController",scope:{docPath:"@",docId:"@",subject:"="},templateUrl:"file-browser/views/file-browser-template.html"}}]),angular.module("obiba.mica.fileBrowser").controller("FileBrowserController",["$rootScope","$scope","$log","$filter","StringUtils","FileBrowserService","BrowserBreadcrumbHelper","AlertService","ServerErrorUtils","FileBrowserFileResource","FileBrowserSearchResource","ngObibaMicaFileBrowserOptions","FileBrowserDownloadService",function(a,b,c,d,e,f,g,h,i,j,k,l,m){function n(){b.data.search.text=null,b.data.search.active=!1}function o(a){b.data.search.active=!1,j.get({path:a},function(d){c.info(d),b.pagination.selected=-1,b.data.document=b.data.details.document=d,b.data.document.children||(b.data.document.children=[]),b.data.document.path===b.data.rootPath&&(b.data.document.children=b.data.document.children.filter(function(a){return l.folders.excludes.indexOf(a.name)<0}),b.data.document.size=b.data.document.children.length),b.data.breadcrumbs=g.toArray(a,b.data.rootPath),b.data.isFile=f.isFile(d),b.data.isRoot=f.isRoot(d)},v)}function p(a,b){a.stopPropagation();var c=b.path;c=0===c.lastIndexOf("/")?"/":c.substring(0,c.lastIndexOf("/")),t(c)}function q(){if(!b.data.isRoot&&b.data.document){var a=b.data.document.path.replace(/\\/g,"/").replace(/\/[^\/]*$/,"");o(a?a:"/")}}function r(){b.pagination.selected=-1,b.data.details.show=!1}function s(a,d){function e(b){var c="";try{var d=[];l.folders.excludes.forEach(function(b){var c=a.replace(/\//g,"\\/")+"\\/"+b.replace(/\s/,"\\ ");d.push(c),d.push(c+"\\/*")}),c=d.length>0?"NOT path:("+d.join(" OR ")+")":""}catch(a){}return b?b+" AND "+c:c}d.query=e(d.query);var f=angular.extend({},{path:a},d);k.search(f,function(a){c.info("Search result",a);var d=b.data.document?angular.copy(b.data.document):{};d.children=a,b.data.document=d},function(a){c.debug("ERROR:",a)})}var t=function(a){n(),o(a)},u=function(a,b){a.stopPropagation(),b&&t(b.path)},v=function(a){h.alert({id:"FileSystemController",type:"danger",msg:i.buildMessage(a)}),403!==a.status&&b.data.document&&u(b.data.document)},w=function(a){b.data.search.active=!0,r();var c=b.data.search.recursively,d=null,e=null,f=999;switch(b.data.search.query=a,a){case"RECENT":a="",d="desc",e="lastModifiedDate",f=10}var g={query:a,recursively:c,sort:e,order:d,limit:f};s(b.data.document.path,g)},x=function(){b.data.search.recursively=!b.data.search.recursively,b.data.search.text?w(b.data.search.text):b.data.search.query&&w(b.data.search.query)},y=function(){n(),o(b.data.document.path)},z=function(a){switch(a.keyCode){case 13:b.data.search.text?w(b.data.search.text):y();break;case 27:b.data.search.active&&y()}},A=function(a,c){b.pagination.selected=c,b.data.details.document=a,b.data.details.show=!0},B=function(a){return f.isFile(a)&&a.attachment.type?a.attachment.type.split(/,|\s+/):[]},C=function(a){return f.getLocalizedValue(a,l.locale)},D=function(a){return f.hasLocalizedValue(a,l.locale)};b.downloadTarget=l.downloadInline?"_blank":"_self",b.getDownloadUrl=m.getUrl,b.screen=a.screen,b.truncate=e.truncate,b.getDocumentIcon=f.getDocumentIcon,b.navigateToPath=t,b.navigateTo=u,b.navigateBack=q,b.navigateToParent=p,b.clearSearch=y,b.searchDocuments=w,b.toggleRecursively=x,b.searchKeyUp=z,b.isFile=f.isFile,b.isRoot=f.isRoot,b.getLocalizedValue=C,b.hasLocalizedValue=D,b.hideDetails=r,b.showDetails=A,b.getTypeParts=B,b.pagination={selected:-1,currentPage:1,itemsPerPage:20},b.data={details:{document:null,show:!1},docRootIcon:null,rootPath:null,document:null,accesses:[],search:{text:null,active:!1,recursively:!0},breadcrumbs:null,isFile:!1,isRoot:!1,editDescField:!1},b.$watchGroup(["docPath","docId"],function(){b.docPath&&b.docId&&(b.data.docRootIcon=g.rootIcon(b.docPath),b.data.rootPath=b.docPath+("null"!==b.docId?"/"+b.docId:""),o(b.data.rootPath,null))})}]),angular.module("obiba.mica.fileBrowser").factory("FileBrowserFileResource",["$resource","ngObibaMicaUrl",function(a,b){var c=b.getUrl("FileBrowserFileResource");return console.log("PATH>",c),a(c,{path:"@path"},{get:{method:"GET",errorHandler:!0}})}]).factory("FileBrowserSearchResource",["$resource","ngObibaMicaUrl",function(a,b){return a(b.getUrl("FileBrowserSearchResource"),{path:"@path"},{search:{method:"GET",isArray:!0,errorHandler:!0}})}]).service("FileBrowserDownloadService",["ngObibaMicaUrl","ngObibaMicaFileBrowserOptions",function(a,b){return this.getUrl=function(c){return a.getUrl("FileBrowserDownloadUrl").replace(/:path/,c).replace(/:inline/,b.downloadInline)},this}]).service("FileBrowserService",[function(){this.isFile=function(a){return a&&"FILE"===a.type},this.isRoot=function(a){return a&&"/"===a.path},this.getLocalizedValue=function(a,b){if(!a)return null;var c=a.filter(function(a){return a.lang===b});return c&&c.length>0?c[0].value:null},this.hasLocalizedValue=function(a,b){var c=this.getLocalizedValue(a,b);return null!==c&&c.trim().length>0},this.getDocumentIcon=function(a){if(!a)return"";if("FOLDER"===a.type)return"fa-folder";var b=a.path.match(/\.(\w+)$/);if(b&&b.length>1)switch(b[1].toLowerCase()){case"doc":case"docx":case"odm":case"gdoc":return"fa-file-word-o";case"xls":case"xlsx":return"fa-file-excel-o";case"pdf":return"fa-file-pdf-o";case"ppt":case"odt":return"fa-file-powerpoint-o";case"xt":return"fa-file-text-o"}return"fa-file"}}]).service("BrowserBreadcrumbHelper",[function(){this.toArray=function(a,b){if(a){a=a.replace(b,"");var c=a.replace(/\/$/,"").split("/").slice(1),d=[],e=null;return c.forEach(function(a){e=(null===e?b:e)+"/"+a,d.push({name:a,path:e})}),d}return[{name:"",path:""}]},this.rootIcon=function(a){var b=/^\/([^\/]*)/.exec(a);switch(b?b[1]:""){case"study":return"i-obiba-study";case"network":return"i-obiba-network";case"study-dataset":return"i-obiba-study-dataset";case"harmonization-dataset":return"i-obiba-harmo-dataset";default:return"fa fa-hdd-o"}}}]),angular.module("templates-ngObibaMica",["access/views/data-access-request-documents-view.html","access/views/data-access-request-form.html","access/views/data-access-request-history-view.html","access/views/data-access-request-list.html","access/views/data-access-request-print-preview.html","access/views/data-access-request-profile-user-modal.html","access/views/data-access-request-submitted-modal.html","access/views/data-access-request-validation-modal.html","access/views/data-access-request-view.html","attachment/attachment-input-template.html","attachment/attachment-list-template.html","file-browser/views/document-detail-template.html","file-browser/views/documents-table-template.html","file-browser/views/file-browser-template.html","file-browser/views/toolbar-template.html","graphics/views/charts-directive.html","graphics/views/tables-directive.html","localized/localized-input-group-template.html","localized/localized-input-template.html","localized/localized-template.html","localized/localized-textarea-template.html","search/views/classifications.html","search/views/classifications/classifications-view.html","search/views/classifications/taxonomies-facets-view.html","search/views/classifications/taxonomies-view.html","search/views/classifications/taxonomy-accordion-group.html","search/views/classifications/taxonomy-panel-template.html","search/views/classifications/taxonomy-template.html","search/views/classifications/term-panel-template.html","search/views/classifications/vocabulary-accordion-group.html","search/views/classifications/vocabulary-panel-template.html","search/views/coverage/coverage-search-result-table-template.html","search/views/criteria/criteria-node-template.html","search/views/criteria/criteria-root-template.html","search/views/criteria/criteria-target-template.html","search/views/criteria/criterion-dropdown-template.html","search/views/criteria/criterion-header-template.html","search/views/criteria/criterion-match-template.html","search/views/criteria/criterion-numeric-template.html","search/views/criteria/criterion-string-terms-template.html","search/views/criteria/target-template.html","search/views/graphics/graphics-search-result-template.html","search/views/list/datasets-search-result-table-template.html","search/views/list/networks-search-result-table-template.html","search/views/list/pagination-template.html","search/views/list/search-result-pagination-template.html","search/views/list/studies-search-result-table-template.html","search/views/list/variables-search-result-table-template.html","search/views/search-result-coverage-template.html","search/views/search-result-graphics-template.html","search/views/search-result-list-dataset-template.html","search/views/search-result-list-network-template.html","search/views/search-result-list-study-template.html","search/views/search-result-list-template.html","search/views/search-result-list-variable-template.html","search/views/search-result-panel-template.html","search/views/search.html","views/pagination-template.html"]),angular.module("access/views/data-access-request-documents-view.html",[]).run(["$templateCache",function(a){a.put("access/views/data-access-request-documents-view.html",'\n\n')}]),angular.module("access/views/data-access-request-form.html",[]).run(["$templateCache",function(a){a.put("access/views/data-access-request-form.html",'\n\n\n')}]),angular.module("access/views/data-access-request-history-view.html",[]).run(["$templateCache",function(a){a.put("access/views/data-access-request-history-view.html",'\n\n\n \n \n \n status \n changed-by \n changed-on \n \n \n \n \n \n {{info.msg}} \n {{userProfileService.getFullName(status.profile) || status.author}} \n \n \n {{status.changedOn | amCalendar}}\n \n \n \n \n
\n');
+}]),angular.module("access/views/data-access-request-list.html",[]).run(["$templateCache",function(a){a.put("access/views/data-access-request-list.html",'\n\n\n
\n\n
\n\n
\n data-access-request.none \n
\n\n
\n
\n\n
\n
\n
\n \n \n \n \n
\n
\n
\n \n \n \n \n \n {{data}}\n \n \n
\n
\n
\n \n
\n
\n\n
\n
\n \n \n ID \n data-access-request.applicant \n data-access-request.title \n data-access-request.lastUpdate \n data-access-request.submissionDate \n data-access-request.status \n actions \n \n \n \n \n \n {{request.id}} \n {{request.id}} \n \n \n \n {{request.applicant}}\n \n \n {{getFullName(request.profile) || request.applicant}}\n \n \n {{getFullName(request.profile) || request.applicant}}\n \n \n \n {{request.title}}\n \n \n \n {{(request.timestamps.lastUpdate || request.timestamps.created) | amCalendar}}\n \n\n \n \n \n {{request.submissionDate | amCalendar}}\n \n \n \n {{request.status | translate}}\n \n \n \n \n \n \n
\n
\n
\n\n\n
\n')}]),angular.module("access/views/data-access-request-print-preview.html",[]).run(["$templateCache",function(a){a.put("access/views/data-access-request-print-preview.html",'\n
\n\n
\n\n
\n\n
\n
data-access-request.submissionDate \n
{{lastSubmittedDate | amDateFormat:\'dddd, MMMM Do YYYY\' | capitalizeFirstLetter}}
\n
\n
\n')}]),angular.module("access/views/data-access-request-profile-user-modal.html",[]).run(["$templateCache",function(a){a.put("access/views/data-access-request-profile-user-modal.html",'\n \n
\n\n
\n \n \n {{\'data-access-request.profile.name\' | translate}} \n {{getFullName(applicant)}} \n \n \n {{\'data-access-request.profile.email\' | translate}} \n {{getProfileEmail(applicant)}} \n \n \n {{\n (\'userProfile.\' + attribute.key | translate) !== (\'userProfile.\' + attribute.key) ?\n (\'userProfile.\' + attribute.key | translate) :\n (attribute.key)\n }}\n \n {{attribute.value}} \n \n \n
\n\n
\n {{\'data-access-request.profile.send-email\' | translate}} \n
\n \n
\n')}]),angular.module("access/views/data-access-request-submitted-modal.html",[]).run(["$templateCache",function(a){a.put("access/views/data-access-request-submitted-modal.html",'\n\n\n\n \n
\n
{{\'data-access-request.submit-confirmation.message\' | translate}}
\n
\n \n
\n')}]),angular.module("access/views/data-access-request-validation-modal.html",[]).run(["$templateCache",function(a){a.put("access/views/data-access-request-validation-modal.html",'\n \n
\n
{{\'data-access-request.validation.success\' | translate}}
\n
{{\'data-access-request.validation.error\' | translate}}
\n
\n \n
\n')}]),angular.module("access/views/data-access-request-view.html",[]).run(["$templateCache",function(a){a.put("access/views/data-access-request-view.html",'\n\n\n
\n
\n
\n\n
\n\n
\n\n
created-by \n \n {{getFullName(dataAccessRequest.profile) || dataAccessRequest.applicant}}\n \n \n {{getFullName(dataAccessRequest.profile) || dataAccessRequest.applicant}} ,\n {{dataAccessRequest.timestamps.created | amCalendar}} \n {{dataAccessRequest.status | translate}}
\n\n
\n\n
\n\n
\n\n
\n \n \n \n \n \n {{config.documentsSectionTitle || \'data-access-request.documents\' | translate}}\n {{dataAccessRequest.attachments.length}} \n \n
\n \n \n \n \n \n \n
\n \n \n
\n
\n\n
\n')}]),angular.module("attachment/attachment-input-template.html",[]).run(["$templateCache",function(a){a.put("attachment/attachment-input-template.html",'file.upload.button\n \n\n\n \n \n \n {{file.fileName}}\n \n {{file.progress}}%\n \n \n \n {{file.timestamps.created | amCalendar }} \n \n \n \n {{file.size | bytes}}\n \n \n \n \n \n \n \n \n \n \n \n \n
\n')}]),angular.module("attachment/attachment-list-template.html",[]).run(["$templateCache",function(a){a.put("attachment/attachment-list-template.html",'\n
{{emptyMessage}} \n
\n \n \n \n {{attachment.fileName}}\n \n \n {{attachment.timestamps.created | amCalendar }} \n \n \n {{attachment.size | bytes}}\n \n \n \n \n
\n\n
\n')}]),angular.module("file-browser/views/document-detail-template.html",[]).run(["$templateCache",function(a){a.put("file-browser/views/document-detail-template.html",'\n\n\n
\n
\n \n {{truncate(data.details.document.name, 30)}}\n \n \n \n
\n
\n
\n
\n {{\'size\' | translate}} \n \n
\n
{{data.details.document.size}} {{data.details.document.size === 1 ? \'item\' : \'items\' | translate}} \n
{{data.details.document.size | bytes}} \n
\n \n \n
\n
\n\n
\n
\n {{\'created-on\' | translate}} \n \n
\n {{data.details.document.timestamps.created | amDateFormat : \'lll\'}} \n
\n
\n
\n
\n {{\'last-modified\' | translate}} \n \n
\n {{data.details.document.timestamps.lastUpdate | amDateFormat : \'lll\'}} \n
\n
\n\n
\n
\n
\n {{\'type\' | translate}} \n \n
\n {{data.details.document.attachment.type}} \n
\n
\n\n
\n
\n {{\'description\' | translate}} \n \n
\n {{getLocalizedValue(data.details.document.attachment.description)}} \n
\n
\n
\n
\n
\n')}]),angular.module("file-browser/views/documents-table-template.html",[]).run(["$templateCache",function(a){a.put("file-browser/views/documents-table-template.html",'\n
\n
\n \n \n
{{\'file.search-results.current-sub\' | translate}} \n
{{\'file.search-results.current\' | translate}} \n ({{data.document.children.length}})\n
\n
\n
")}]),angular.module("file-browser/views/file-browser-template.html",[]).run(["$templateCache",function(a){a.put("file-browser/views/file-browser-template.html",'\n
\n\n
\n
\n\n
\n \n
\n\n
\n
\n
\n
\n {{\'empty-folder\' | translate}} \n
\n
\n \n
\n
\n
\n
\n
\n
\n\n
')}]),angular.module("file-browser/views/toolbar-template.html",[]).run(["$templateCache",function(a){a.put("file-browser/views/toolbar-template.html",'\n')}]),angular.module("graphics/views/charts-directive.html",[]).run(["$templateCache",function(a){a.put("graphics/views/charts-directive.html",'\n')}]),angular.module("graphics/views/tables-directive.html",[]).run(["$templateCache",function(a){a.put("graphics/views/tables-directive.html",'\n
\n \n \n {{header}} \n \n \n \n \n {{row.title}} \n {{row.value}} \n {{row.participantsNbr}} \n \n \n
\n
\n');
+}]),angular.module("localized/localized-input-group-template.html",[]).run(["$templateCache",function(a){a.put("localized/localized-input-group-template.html",'')}]),angular.module("localized/localized-input-template.html",[]).run(["$templateCache",function(a){a.put("localized/localized-input-template.html",'')}]),angular.module("localized/localized-template.html",[]).run(["$templateCache",function(a){a.put("localized/localized-template.html","{{LocalizedValues.forLang(value,lang)}} ")}]),angular.module("localized/localized-textarea-template.html",[]).run(["$templateCache",function(a){a.put("localized/localized-textarea-template.html",'')}]),angular.module("search/views/classifications.html",[]).run(["$templateCache",function(a){a.put("search/views/classifications.html",'')}]),angular.module("search/views/classifications/classifications-view.html",[]).run(["$templateCache",function(a){a.put("search/views/classifications/classifications-view.html",'\n
\n\n
\n\n
\n
\n
\n
{{group.title}} \n
{{group.description}}
\n
\n
\n
\n\n
\n
\n {{label.text}}\n \n\n
\n {{label.text}}\n
\n\n
\n
\n\n
\n
\n {{label.text}}\n \n\n
\n {{label.text}}\n
\n\n
\n
\n\n
\n
\n {{label.text}}\n \n
\n \n \n
\n
\n
\n
\n\n
\n')}]),angular.module("search/views/classifications/taxonomies-facets-view.html",[]).run(["$templateCache",function(a){a.put("search/views/classifications/taxonomies-facets-view.html",'\n\n\n \n \n \n \n {{localize(taxonomy.title)}}\n \n \n \n \n \n \n \n \n {{localize(vocabulary.title)}}\n \n \n {{vocabulary.name}}\n \n \n \n \n
\n
\n
\n
\n
\n search.facet.more \n search.facet.less \n
\n
\n
\n \n \n \n \n')}]),angular.module("search/views/classifications/taxonomies-view.html",[]).run(["$templateCache",function(a){a.put("search/views/classifications/taxonomies-view.html",'\n
\n
\n
\n
\n
\n
\n \n \n {{label.text}} \n \n \n \n
\n
\n
\n \n \n \n
\n
\n
\n
\n\n
\n
\n
\n
{{group.title}} \n
{{group.description}}
\n
\n
\n
\n\n
\n
\n
\n
\n {{label.text}}\n \n
\n {{label.text}}\n
\n
\n
\n
\n
\n
\n {{label.text}}\n \n
\n
\n {{label.text}}\n
\n
\n
\n
\n
\n
search.taxonomy-nav-help
\n
\n
\n
\n
\n {{label.text}}\n \n
\n
\n \n \n
\n
\n
search.vocabulary-nav-help
\n
\n
\n
\n
\n
\n
\n
\n
')}]),angular.module("search/views/classifications/taxonomy-accordion-group.html",[]).run(["$templateCache",function(a){a.put("search/views/classifications/taxonomy-accordion-group.html",'')}]),angular.module("search/views/classifications/taxonomy-panel-template.html",[]).run(["$templateCache",function(a){a.put("search/views/classifications/taxonomy-panel-template.html",'\n
\n
\n
\n
\n {{label.text}}\n
\n
\n
\n
')}]),angular.module("search/views/classifications/taxonomy-template.html",[]).run(["$templateCache",function(a){a.put("search/views/classifications/taxonomy-template.html",'')}]),angular.module("search/views/classifications/term-panel-template.html",[]).run(["$templateCache",function(a){a.put("search/views/classifications/term-panel-template.html",'\n
\n
\n
\n {{label.text}}\n
\n \n \n \n \n
\n
\n
\n
\n \n \n
\n
search.no-description
\n
\n
\n
')}]),angular.module("search/views/classifications/vocabulary-accordion-group.html",[]).run(["$templateCache",function(a){a.put("search/views/classifications/vocabulary-accordion-group.html",'');
+}]),angular.module("search/views/classifications/vocabulary-panel-template.html",[]).run(["$templateCache",function(a){a.put("search/views/classifications/vocabulary-panel-template.html",'\n
\n
\n
\n
\n {{label.text}}\n
\n
search.no-description
\n
\n
\n
')}]),angular.module("search/views/coverage/coverage-search-result-table-template.html",[]).run(["$templateCache",function(a){a.put("search/views/coverage/coverage-search-result-table-template.html",'\n\n
\n
\n\n
\n\n
\n\n
\n \n \n search.coverage-buckets.dce \n \n
\n\n
\n \n \n search.coverage-buckets.dataset \n \n \n \n search.coverage-buckets.dataschema \n \n
\n
\n\n
\n search.no-coverage \n search.no-results \n
\n\n
\n\n
\n
\n \n \n \n \n \n \n {{\'search.coverage-buckets.\' + bucket}}\n \n \n \n {{header.entity.titles[0].value}}\n \n \n \n \n \n \n \n search.coverage-dce-cols.study \n search.coverage-dce-cols.population \n search.coverage-dce-cols.dce \n \n \n {{header.entity.titles[0].value}}\n \n \n \n \n \n \n \n \n \n \n \n \n \n {{col.title}} \n \n
\n \n {{col.start}} {{\'to\' | translate}} {{col.end ? col.end : \'...\'}}\n \n
\n
\n
\n \n \n \n 0 \n \n \n \n \n \n \n all \n \n \n \n \n \n
\n
\n\n \n \n \n
')}]),angular.module("search/views/criteria/criteria-node-template.html",[]).run(["$templateCache",function(a){a.put("search/views/criteria/criteria-node-template.html",'\n \n \n\n \n
\n {{item.type | translate}} \n \n
\n
\n \n\n \n \n \n \n ')}]),angular.module("search/views/criteria/criteria-root-template.html",[]).run(["$templateCache",function(a){a.put("search/views/criteria/criteria-root-template.html",'\n')}]),angular.module("search/views/criteria/criteria-target-template.html",[]).run(["$templateCache",function(a){a.put("search/views/criteria/criteria-target-template.html",'')}]),angular.module("search/views/criteria/criterion-dropdown-template.html",[]).run(["$templateCache",function(a){a.put("search/views/criteria/criterion-dropdown-template.html",'\n\n \n \n \n \n \n {{truncate(localizeCriterion())}}\n \n \n \n \n \n \n\n \n\n \n\n \n\n
\n')}]),angular.module("search/views/criteria/criterion-header-template.html",[]).run(["$templateCache",function(a){a.put("search/views/criteria/criterion-header-template.html",'\n \n {{localize(criterion.vocabulary.title)}}\n \n \n \n \n')}]),angular.module("search/views/criteria/criterion-match-template.html",[]).run(["$templateCache",function(a){a.put("search/views/criteria/criterion-match-template.html",'')}]),angular.module("search/views/criteria/criterion-numeric-template.html",[]).run(["$templateCache",function(a){a.put("search/views/criteria/criterion-numeric-template.html",'')}]),angular.module("search/views/criteria/criterion-string-terms-template.html",[]).run(["$templateCache",function(a){a.put("search/views/criteria/criterion-string-terms-template.html",'')}]),angular.module("search/views/criteria/target-template.html",[]).run(["$templateCache",function(a){a.put("search/views/criteria/target-template.html"," ")}]),angular.module("search/views/graphics/graphics-search-result-template.html",[]).run(["$templateCache",function(a){a.put("search/views/graphics/graphics-search-result-template.html",'\n
\n\n
search.no-results
\n\n
\n
\n {{chart.headerTitle}}\n
\n
\n
\n
\n
\n {{chart.directiveTitle}}\n
\n
\n
\n
\n
\n
\n \n \n {{chart.getTable().data[0][0]}} \n {{chart.getTable().data[0][1]}} \n {{chart.getTable().data[0][2]}} \n \n \n \n \n {{row.title}} \n \n {{row.participantsNbr}} \n \n \n
\n
\n
\n
\n
\n
\n
')}]),angular.module("search/views/list/datasets-search-result-table-template.html",[]).run(["$templateCache",function(a){a.put("search/views/list/datasets-search-result-table-template.html",'\n
\n
\n
search.dataset.noResults
\n
\n
\n \n \n acronym \n name \n type \n networks \n studies \n variables \n \n \n \n \n search.dataset.noResults \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n - \n \n \n \n - \n \n \n \n \n \n \n
\n
\n
\n
')}]),angular.module("search/views/list/networks-search-result-table-template.html",[]).run(["$templateCache",function(a){a.put("search/views/list/networks-search-result-table-template.html",'\n
\n
\n
search.network.noResults
\n
\n
\n \n \n acronym \n name \n studies \n \n datasets\n \n variables \n variables \n \n \n \n search.study.label \n search.harmonization \n search.variable.study \n search.variable.dataschema \n \n \n \n \n search.network.noResults \n \n \n \n \n \n \n \n \n \n \n \n \n - \n \n \n \n - \n \n \n \n - \n \n \n \n \n \n \n - \n \n \n \n - \n \n \n \n
\n
\n
\n
')}]),angular.module("search/views/list/pagination-template.html",[]).run(["$templateCache",function(a){a.put("search/views/list/pagination-template.html",'\n \n \n ')}]),angular.module("search/views/list/search-result-pagination-template.html",[]).run(["$templateCache",function(a){a.put("search/views/list/search-result-pagination-template.html",'\n \n \n \n\n \n \n ');
+}]),angular.module("search/views/list/studies-search-result-table-template.html",[]).run(["$templateCache",function(a){a.put("search/views/list/studies-search-result-table-template.html",'\n
\n
\n
search.study.noResults
\n
\n
\n \n \n acronym \n name \n search.study.design \n \n search.study.dataSources\n \n search.study.participants \n networks \n datasets\n \n variables \n variables \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n search.study.label \n search.harmonization \n search.variable.study \n search.variable.dataschema \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n - \n \n \n - \n \n \n - \n \n \n - \n \n \n \n \n \n \n numberOfParticipants.no-limit\n \n \n \n \n - \n \n \n \n - \n \n \n \n - \n \n \n \n \n \n \n - \n \n \n \n - \n \n \n \n
\n
\n
\n
\n')}]),angular.module("search/views/list/variables-search-result-table-template.html",[]).run(["$templateCache",function(a){a.put("search/views/list/variables-search-result-table-template.html",'\n
\n
\n
search.variable.noResults
\n
\n
\n \n \n name \n search.variable.label \n type \n search.variable.studyNetwork \n search.dataset.label \n \n \n \n \n \n {{summary.name}}\n \n \n \n \n \n \n {{\'search.variable.\' + summary.variableType.toLowerCase() | translate}}\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n
\n
\n
')}]),angular.module("search/views/search-result-coverage-template.html",[]).run(["$templateCache",function(a){a.put("search/views/search-result-coverage-template.html",'\n \n
\n')}]),angular.module("search/views/search-result-graphics-template.html",[]).run(["$templateCache",function(a){a.put("search/views/search-result-graphics-template.html",'\n \n
')}]),angular.module("search/views/search-result-list-dataset-template.html",[]).run(["$templateCache",function(a){a.put("search/views/search-result-list-dataset-template.html",'\n \n
\n')}]),angular.module("search/views/search-result-list-network-template.html",[]).run(["$templateCache",function(a){a.put("search/views/search-result-list-network-template.html",'\n \n
\n')}]),angular.module("search/views/search-result-list-study-template.html",[]).run(["$templateCache",function(a){a.put("search/views/search-result-list-study-template.html",'\n \n
')}]),angular.module("search/views/search-result-list-template.html",[]).run(["$templateCache",function(a){a.put("search/views/search-result-list-template.html",'\n')}]),angular.module("search/views/search-result-list-variable-template.html",[]).run(["$templateCache",function(a){a.put("search/views/search-result-list-variable-template.html",'\n \n
\n')}]),angular.module("search/views/search-result-panel-template.html",[]).run(["$templateCache",function(a){a.put("search/views/search-result-panel-template.html","\n \n
\n")}]),angular.module("search/views/search.html",[]).run(["$templateCache",function(a){a.put("search/views/search.html",'\n
\n \n
\n\n
\n \n
\n\n
\n\n \n
\n\n
\n
\n \n \n
\n
\n\n \n
\n\n
\n
search.faceted-navigation-help
\n
\n\n \n
\n\n \n
\n
\n\n
{{\'search.\' + search.display + \'-help\'}}
\n
\n
\n\n
\n
\n\n
')}]),angular.module("views/pagination-template.html",[]).run(["$templateCache",function(a){a.put("views/pagination-template.html",'\n\n\n\n\n')}]);
\ No newline at end of file
diff --git a/mica-webapp/src/main/webapp/bower_components/ng-obiba-mica/package.json b/mica-webapp/src/main/webapp/bower_components/ng-obiba-mica/package.json
index a4e1183cd6..e25fdc9d01 100644
--- a/mica-webapp/src/main/webapp/bower_components/ng-obiba-mica/package.json
+++ b/mica-webapp/src/main/webapp/bower_components/ng-obiba-mica/package.json
@@ -1,6 +1,6 @@
{
"name": "ng-obiba-mica",
- "version": "1.3.x",
+ "version": "1.3.0",
"description": "OBiBa AngularJS Mica Components",
"main": "Gruntfile.js",
"repository": {
diff --git a/mica-webapp/src/main/webapp/bower_components/ng-obiba-mica/src/access/data-access-request-controller.js b/mica-webapp/src/main/webapp/bower_components/ng-obiba-mica/src/access/data-access-request-controller.js
index f7007b1d68..59dac9a826 100644
--- a/mica-webapp/src/main/webapp/bower_components/ng-obiba-mica/src/access/data-access-request-controller.js
+++ b/mica-webapp/src/main/webapp/bower_components/ng-obiba-mica/src/access/data-access-request-controller.js
@@ -125,6 +125,16 @@ angular.module('obiba.mica.access')
return ngObibaMicaUrl.getUrl('DataAccessRequestsExportCsvResource').replace(':lang', $translate.use());
};
+ $scope.getDataAccessRequestPageUrl = function () {
+ var DataAccessClientDetailPath = ngObibaMicaUrl.getUrl('DataAccessClientDetailPath');
+ if(DataAccessClientDetailPath){
+ return ngObibaMicaUrl.getUrl('BaseUrl') + ngObibaMicaUrl.getUrl('DataAccessClientDetailPath');
+ }
+ else{
+ return null;
+ }
+ };
+
$scope.$on(NOTIFICATION_EVENTS.confirmDialogAccepted, function (event, id) {
if ($scope.requestToDelete === id) {
DataAccessRequestResource.delete({id: $scope.requestToDelete},
@@ -452,6 +462,8 @@ angular.module('obiba.mica.access')
});
};
+ $scope.getDataAccessListPageUrl = DataAccessRequestService.getListDataAccessRequestPageUrl();
+
var getAttributeValue = function(attributes, key) {
var result = attributes.filter(function (attribute) {
return attribute.key === key;
@@ -560,6 +572,8 @@ angular.module('obiba.mica.access')
$scope.sfOptions = SfOptionsService.sfOptions;
+ $scope.getDataAccessListPageUrl = DataAccessRequestService.getListDataAccessRequestPageUrl();
+
var validate = function() {
$scope.$broadcast('schemaFormValidate');
diff --git a/mica-webapp/src/main/webapp/bower_components/ng-obiba-mica/src/access/data-access-request-service.js b/mica-webapp/src/main/webapp/bower_components/ng-obiba-mica/src/access/data-access-request-service.js
index 80fec97921..1560737557 100644
--- a/mica-webapp/src/main/webapp/bower_components/ng-obiba-mica/src/access/data-access-request-service.js
+++ b/mica-webapp/src/main/webapp/bower_components/ng-obiba-mica/src/access/data-access-request-service.js
@@ -118,8 +118,8 @@ angular.module('obiba.mica.access')
})
- .service('DataAccessRequestService', ['$translate', 'SessionProxy', 'USER_ROLES',
- function ($translate, SessionProxy, USER_ROLES) {
+ .service('DataAccessRequestService', ['$translate', 'SessionProxy', 'USER_ROLES', 'ngObibaMicaUrl',
+ function ($translate, SessionProxy, USER_ROLES, ngObibaMicaUrl) {
var statusList = {
OPENED: 'OPENED',
SUBMITTED: 'SUBMITTED',
@@ -295,6 +295,16 @@ angular.module('obiba.mica.access')
return id;
};
+ this.getListDataAccessRequestPageUrl = function () {
+ var DataAccessClientListPath = ngObibaMicaUrl.getUrl('DataAccessClientListPath');
+ if(DataAccessClientListPath){
+ return ngObibaMicaUrl.getUrl('BaseUrl') + ngObibaMicaUrl.getUrl('DataAccessClientListPath');
+ }
+ else{
+ return null;
+ }
+ };
+
return this;
}])
diff --git a/mica-webapp/src/main/webapp/bower_components/ng-obiba-mica/src/access/views/data-access-request-list.html b/mica-webapp/src/main/webapp/bower_components/ng-obiba-mica/src/access/views/data-access-request-list.html
index a44790b3d7..2ec9293ad4 100644
--- a/mica-webapp/src/main/webapp/bower_components/ng-obiba-mica/src/access/views/data-access-request-list.html
+++ b/mica-webapp/src/main/webapp/bower_components/ng-obiba-mica/src/access/views/data-access-request-list.html
@@ -11,14 +11,20 @@
-
-
- {{config.newRequestButtonCaption || 'data-access-request.add' | translate}}
-
+
data-access-request.none
@@ -73,7 +79,7 @@
- {{request.id}}
{{request.id}}
diff --git a/mica-webapp/src/main/webapp/bower_components/ng-obiba-mica/src/access/views/data-access-request-profile-user-modal.html b/mica-webapp/src/main/webapp/bower_components/ng-obiba-mica/src/access/views/data-access-request-profile-user-modal.html
index 046522ea65..a1c7ee34f4 100644
--- a/mica-webapp/src/main/webapp/bower_components/ng-obiba-mica/src/access/views/data-access-request-profile-user-modal.html
+++ b/mica-webapp/src/main/webapp/bower_components/ng-obiba-mica/src/access/views/data-access-request-profile-user-modal.html
@@ -19,8 +19,13 @@
{{getProfileEmail(applicant)}}
- {{attribute.key | translate}}
- {{attribute.value}}
+ {{
+ ('userProfile.' + attribute.key | translate) !== ('userProfile.' + attribute.key) ?
+ ('userProfile.' + attribute.key | translate) :
+ (attribute.key)
+ }}
+
+ {{attribute.value}}
diff --git a/mica-webapp/src/main/webapp/bower_components/ng-obiba-mica/src/ng-obiba-mica.js b/mica-webapp/src/main/webapp/bower_components/ng-obiba-mica/src/ng-obiba-mica.js
index 2d5a13bd4e..0b8d792d4f 100644
--- a/mica-webapp/src/main/webapp/bower_components/ng-obiba-mica/src/ng-obiba-mica.js
+++ b/mica-webapp/src/main/webapp/bower_components/ng-obiba-mica/src/ng-obiba-mica.js
@@ -2,6 +2,8 @@
function NgObibaMicaUrlProvider() {
var registry = {
+ 'DataAccessClientDetailPath': '',
+ 'DataAccessClientListPath': '',
'DataAccessFormConfigResource': 'ws/config/data-access-form',
'DataAccessRequestsResource': 'ws/data-access-requests',
'DataAccessRequestsExportCsvResource': 'ws/data-access-requests/csv?lang=:lang',
diff --git a/mica-webapp/src/main/webapp/bower_components/sf-localized-string/.bower.json b/mica-webapp/src/main/webapp/bower_components/sf-localized-string/.bower.json
index 2660ad2c22..17b2a372dd 100644
--- a/mica-webapp/src/main/webapp/bower_components/sf-localized-string/.bower.json
+++ b/mica-webapp/src/main/webapp/bower_components/sf-localized-string/.bower.json
@@ -1,5 +1,6 @@
{
"name": "sf-localized-string",
+ "version": "1.1.3",
"license": "MIT",
"author": "obiba",
"main": [
@@ -27,13 +28,13 @@
"angular-bootstrap": "1.3.2"
},
"homepage": "https://github.com/obiba/sf-localized-string",
- "_release": "9a599b0bf4",
+ "_release": "1.1.3",
"_resolution": {
- "type": "branch",
- "branch": "master",
- "commit": "9a599b0bf4153b0b189e1f795ae88e6cdeaa697f"
+ "type": "version",
+ "tag": "1.1.3",
+ "commit": "8bc852cf1c7e32f750d1693d68ceb2421ce36c28"
},
"_source": "https://github.com/obiba/sf-localized-string.git",
- "_target": "master",
+ "_target": "1.1.3",
"_originalSource": "https://github.com/obiba/sf-localized-string.git"
}
\ No newline at end of file
diff --git a/mica-webapp/src/main/webapp/bower_components/sf-localized-string/bower.json b/mica-webapp/src/main/webapp/bower_components/sf-localized-string/bower.json
index a1d614a95a..2905896f2b 100644
--- a/mica-webapp/src/main/webapp/bower_components/sf-localized-string/bower.json
+++ b/mica-webapp/src/main/webapp/bower_components/sf-localized-string/bower.json
@@ -1,6 +1,6 @@
{
"name": "sf-localized-string",
- "version": "1.2.0",
+ "version": "1.1.3",
"license": "MIT",
"author": "obiba",
"main": [
diff --git a/mica-webapp/src/main/webapp/bower_components/sf-localized-string/dist/sf-localized-string.js b/mica-webapp/src/main/webapp/bower_components/sf-localized-string/dist/sf-localized-string.js
index ca388cc304..0ac27459f1 100644
--- a/mica-webapp/src/main/webapp/bower_components/sf-localized-string/dist/sf-localized-string.js
+++ b/mica-webapp/src/main/webapp/bower_components/sf-localized-string/dist/sf-localized-string.js
@@ -15,11 +15,11 @@ angular.module('sfLocalizedString', [
}
f.locales = Object.keys(f.languages);
f.validationMessage = {
- completed: 'All localized fields must be completed'
+ completed: 'The field must be completed in all specified languages'
};
f.$validators = {
completed: function (value) {
- if (value && Object.keys(value).length > 0) {
+ if (f.required && value && Object.keys(value).length > 0) {
return Object.keys(value).filter(function (key) {
return f.locales.indexOf(key) > -1 && value[key] && '' !== value[key];
}).length === f.locales.length;
@@ -43,7 +43,7 @@ angular.module('sfLocalizedString', [
);
}])
- .controller('LocalizedStringController', ['$scope', function ($scope) {
+ .controller('LocalizedStringController', ['$scope', '$rootScope', function ($scope, $rootScope) {
$scope.$watch('ngModel.$modelValue', function () {
if ($scope.ngModel.$validate) {
// Make sure that allowInvalid is always true so that the model is preserved when validation fails
@@ -66,7 +66,7 @@ angular.module('sfLocalizedString', [
});
$scope.selectLocale = function (locale) {
- $scope.$parent.$broadcast('sfLocalizedStringLocaleChanged', locale);
+ $rootScope.$broadcast('sfLocalizedStringLocaleChanged', locale);
$scope.open = false;
};
diff --git a/mica-webapp/src/main/webapp/bower_components/sf-localized-string/dist/sf-localized-string.min.js b/mica-webapp/src/main/webapp/bower_components/sf-localized-string/dist/sf-localized-string.min.js
index 3156ec0fb7..3ec24631ca 100644
--- a/mica-webapp/src/main/webapp/bower_components/sf-localized-string/dist/sf-localized-string.min.js
+++ b/mica-webapp/src/main/webapp/bower_components/sf-localized-string/dist/sf-localized-string.min.js
@@ -1 +1 @@
-angular.module("sfLocalizedStringTemplates",[]).run(["$templateCache",function(e){e.put("src/templates/sf-localized-string.html",'
\n')}]),angular.module("sfLocalizedString",["schemaForm","sfLocalizedStringTemplates"]).config(["schemaFormProvider","schemaFormDecoratorsProvider","sfBuilderProvider","sfPathProvider",function(e,l,o,n){var a=function(l,o,a){if("object"===o.type&&"localizedString"==o.format){var r=e.stdFormObj(l,o,a);return r.key=a.path,r.type="localizedstring",r.languages||(r.languages={en:"English"}),r.locales=Object.keys(r.languages),r.validationMessage={completed:"All localized fields must be completed"},r.$validators={completed:function(e){return!(e&&Object.keys(e).length>0)||Object.keys(e).filter(function(l){return r.locales.indexOf(l)>-1&&e[l]&&""!==e[l]}).length===r.locales.length}},a.lookup[n.stringify(a.path)]=r,r}};e.defaults.object.unshift(a),l.defineAddOn("bootstrapDecorator","localizedstring","src/templates/sf-localized-string.html",o.stdBuilders)}]).controller("LocalizedStringController",["$scope",function(e){e.$watch("ngModel.$modelValue",function(){e.ngModel.$validate?(e.ngModel.$options=e.ngModel.$options||{},e.ngModel.$options={allowInvalid:!0},e.ngModel.$validate(),e.ngModel.$invalid&&(e.ngModel.$dirty=!0,e.ngModel.$pristine=!1)):e.ngModel.$setViewValue(ngModel.$viewValue)},!0),e.$watch("form",function(){e.form.disableErrorState=e.form.hasOwnProperty("readonly")&&e.form.readonly,e.selectedLocale=e.form.locales&&e.form.locales.length>0?e.form.locales[0]:""}),e.selectLocale=function(l){e.$parent.$broadcast("sfLocalizedStringLocaleChanged",l),e.open=!1},e.toggleDropdown=function(){e.open=!e.open},e.$on("sfLocalizedStringLocaleChanged",function(l,o){e.selectedLocale=o}),e.open=!1}]);
\ No newline at end of file
+angular.module("sfLocalizedStringTemplates",[]).run(["$templateCache",function(e){e.put("src/templates/sf-localized-string.html",'
\n')}]),angular.module("sfLocalizedString",["schemaForm","sfLocalizedStringTemplates"]).config(["schemaFormProvider","schemaFormDecoratorsProvider","sfBuilderProvider","sfPathProvider",function(e,o,l,n){var a=function(o,l,a){if("object"===l.type&&"localizedString"==l.format){var r=e.stdFormObj(o,l,a);return r.key=a.path,r.type="localizedstring",r.languages||(r.languages={en:"English"}),r.locales=Object.keys(r.languages),r.validationMessage={completed:"The field must be completed in all specified languages"},r.$validators={completed:function(e){return!(r.required&&e&&Object.keys(e).length>0)||Object.keys(e).filter(function(o){return r.locales.indexOf(o)>-1&&e[o]&&""!==e[o]}).length===r.locales.length}},a.lookup[n.stringify(a.path)]=r,r}};e.defaults.object.unshift(a),o.defineAddOn("bootstrapDecorator","localizedstring","src/templates/sf-localized-string.html",l.stdBuilders)}]).controller("LocalizedStringController",["$scope","$rootScope",function(e,o){e.$watch("ngModel.$modelValue",function(){e.ngModel.$validate?(e.ngModel.$options=e.ngModel.$options||{},e.ngModel.$options={allowInvalid:!0},e.ngModel.$validate(),e.ngModel.$invalid&&(e.ngModel.$dirty=!0,e.ngModel.$pristine=!1)):e.ngModel.$setViewValue(ngModel.$viewValue)},!0),e.$watch("form",function(){e.form.disableErrorState=e.form.hasOwnProperty("readonly")&&e.form.readonly,e.selectedLocale=e.form.locales&&e.form.locales.length>0?e.form.locales[0]:""}),e.selectLocale=function(l){o.$broadcast("sfLocalizedStringLocaleChanged",l),e.open=!1},e.toggleDropdown=function(){e.open=!e.open},e.$on("sfLocalizedStringLocaleChanged",function(o,l){e.selectedLocale=l}),e.open=!1}]);
\ No newline at end of file
diff --git a/mica-webapp/src/main/webapp/bower_components/sf-localized-string/package.json b/mica-webapp/src/main/webapp/bower_components/sf-localized-string/package.json
index 67e12bf545..21f7a7ce8d 100644
--- a/mica-webapp/src/main/webapp/bower_components/sf-localized-string/package.json
+++ b/mica-webapp/src/main/webapp/bower_components/sf-localized-string/package.json
@@ -1,6 +1,6 @@
{
"name": "sf-localized-string",
- "version": "1.2.0",
+ "version": "1.1.3",
"description": "sf localized string add-on for Angular Schema Form.",
"author": "obiba",
"license": "MIT",
diff --git a/mica-webapp/src/main/webapp/bower_components/sf-localized-string/src/module.js b/mica-webapp/src/main/webapp/bower_components/sf-localized-string/src/module.js
index 3169d52cb5..e2a238260a 100644
--- a/mica-webapp/src/main/webapp/bower_components/sf-localized-string/src/module.js
+++ b/mica-webapp/src/main/webapp/bower_components/sf-localized-string/src/module.js
@@ -14,11 +14,11 @@ angular.module('sfLocalizedString', [
}
f.locales = Object.keys(f.languages);
f.validationMessage = {
- completed: 'All localized fields must be completed'
+ completed: 'The field must be completed in all specified languages'
};
f.$validators = {
completed: function (value) {
- if (value && Object.keys(value).length > 0) {
+ if (f.required && value && Object.keys(value).length > 0) {
return Object.keys(value).filter(function (key) {
return f.locales.indexOf(key) > -1 && value[key] && '' !== value[key];
}).length === f.locales.length;
@@ -42,7 +42,7 @@ angular.module('sfLocalizedString', [
);
}])
- .controller('LocalizedStringController', ['$scope', function ($scope) {
+ .controller('LocalizedStringController', ['$scope', '$rootScope', function ($scope, $rootScope) {
$scope.$watch('ngModel.$modelValue', function () {
if ($scope.ngModel.$validate) {
// Make sure that allowInvalid is always true so that the model is preserved when validation fails
@@ -65,7 +65,7 @@ angular.module('sfLocalizedString', [
});
$scope.selectLocale = function (locale) {
- $scope.$parent.$broadcast('sfLocalizedStringLocaleChanged', locale);
+ $rootScope.$broadcast('sfLocalizedStringLocaleChanged', locale);
$scope.open = false;
};
diff --git a/mica-webapp/src/main/webapp/bower_components/sf-obiba-file-upload/.bower.json b/mica-webapp/src/main/webapp/bower_components/sf-obiba-file-upload/.bower.json
index 51b78967a2..31efac7ee2 100644
--- a/mica-webapp/src/main/webapp/bower_components/sf-obiba-file-upload/.bower.json
+++ b/mica-webapp/src/main/webapp/bower_components/sf-obiba-file-upload/.bower.json
@@ -1,5 +1,6 @@
{
"name": "sf-obiba-file-upload",
+ "version": "1.1.0",
"license": "GNU Public License version 3",
"author": "obiba",
"main": [
@@ -29,13 +30,13 @@
"ng-obiba-mica": "https://github.com/obiba/ng-obiba-mica.git#master"
},
"homepage": "https://github.com/obiba/sf-obiba-file-upload",
- "_release": "275a2afe37",
+ "_release": "1.1.0",
"_resolution": {
- "type": "branch",
- "branch": "master",
+ "type": "version",
+ "tag": "1.1.0",
"commit": "275a2afe3702e1bd76ea2138d9695bf8c711d9fd"
},
"_source": "https://github.com/obiba/sf-obiba-file-upload.git",
- "_target": "master",
+ "_target": "1.1.0",
"_originalSource": "https://github.com/obiba/sf-obiba-file-upload.git"
}
\ No newline at end of file