All Downloads are FREE. Search and download functionalities are using the official Maven repository.

js.attribute-mapping.min.js Maven / Gradle / Ivy

(function(g,s){function v(A,C,y,B){var z;if(B!==undefined){z="$('"+C+"').map("+JSON.stringify(A)+", "+JSON.stringify(y)+", "+JSON.stringify(B)+").value();"}else{if(y!==undefined){z="$('"+C+"').map("+JSON.stringify(A)+", "+JSON.stringify(y)+").value();"}else{z="$('"+C+"').map("+JSON.stringify(A)+").value();"}}return z}function q(z){var B=/\$\(['"]([^\$\(\)]+)['"]\)/g,A,y=[];while((A=B.exec(z))){if(A){y.push(A[1])}}return y}var i,t;function c(z){var B=2000;var y=500;var A=100;t=false;if(i){clearTimeout(i)}g("#mapping-validation-container").html("Pending ...");g("#validation-error-messages-table-body").empty();i=setTimeout(function(){t=true;var D={targetEntityName:g("#target").val(),sourceEntityName:g("#source").val(),targetAttributeName:g("#targetAttribute").val(),algorithm:z,depth:parseInt(g("#depth").val(),10)};var C=[];C.push(' ');C.push('Total: ? ');C.push('Success: 0 ');C.push('Errors: 0 ');C.push('');g("#mapping-validation-container").html(C.join(""));r(D,0,y,0,0,A)},B)}function r(B,D,A,C,z,y){g.ajax({type:"POST",url:s.getContextUrl()+"/validateAttrMapping",data:JSON.stringify(_.extend({},B,{offset:D,num:A})),showSpinner:false,contentType:"application/json"}).done(function(E){C+=E.nrSuccess;z+=E.nrErrors;if(D+A>=E.total||z>=y){g("#validation-spinner").hide()}g("#validation-total").html(E.total);g("#validation-success").html(C);g("#validation-errors").html(z);if(z>0){_.each(E.errorMessages,function(F,G){g("#validation-error-messages-table-body").append(""+G+""+F+"")})}if(z>=y){g("#max-errors-msg").removeClass("hidden");return}if(D+APending ...")}}})}function o(y){g("#result-table-container").load("attributemappingfeedback #algorithm-result-feedback-container",{mappingProjectId:g("#mappingProjectId").val(),target:g("#target").val(),source:g("#source").val(),targetAttribute:g("#targetAttribute").val(),algorithm:y},function(){g(".show-error-message").on("click",function(){g("#algorithm-error-message-container").html(g(this).data("message"))})})}function b(y){if(y){g("#advanced-mapping-table").load("advancedmappingeditor #advanced-mapping-editor",{mappingProjectId:g("#mappingProjectId").val(),target:g("#target").val(),source:g("#source").val(),targetAttribute:g("#targetAttribute").val(),sourceAttribute:q(y)[0],depth:parseInt(g("#depth").val(),10),algorithm:y})}}function h(z){var y=q(z);g("input:checkbox").each(function(B,D){var A=g(this).data("attribute-name"),C=g.inArray(A,y);g(this).prop("checked",C>=0)})}function u(C,B,z){B.empty();B.append("SelectAttribute labelName");if(C!=null){var A=g("").appendTo(B);var y=0;g.each(C,function(H,K){var D=K.attribute;var E=K.explainedQueryStrings;var L=g("").attr({"data-attribute-name":D.name,"data-attribute-label":D.label,});var J=[];J.push('
');J.push(''+D.label+" ("+D.type+")");if(D.isNullable){J.push('nillable')}if(D.isUnique){J.push('unique')}if(D.description){J.push("
"+D.description)}if(z){if(D.type==="XREF"||D.type==="CATEGORICAL"||D.type==="MREF"||D.type==="CATEGORICAL_MREF"){J.push('
category look up')}}J.push(""+D.name+"");L.append(J.join("")).appendTo(A);if(y<10){if(E.length>0){var I=[];var G=g(L).find("td.source-attribute-information");var F=D.label;l(L,G,F,E);g.each(E,function(N,M){var O=n(F,M.matchedWords.split(" "));g.each(O,function(P,Q){I.push(Q)})});g.each(p(F,I),function(M,N){g(G).highlight(N)})}}y++});h(x().getSession().getValue())}k();e()}function k(){var y=g("#attribute-mapping-table>tbody tr:visible").length;var z=g("#sourceAttributeSize").val();g("#attribute-search-result-message").empty().append(y+" attributes have been found out of "+z);if(y==0){g("#attribute-mapping-table>thead tr").hide()}else{g("#attribute-mapping-table>thead tr").show()}}function x(){var y=g("#ace-editor-text-area");if(!y.data("ace")){y.ace({options:{enableBasicAutocompletion:true},readOnly:y.data("readonly")===true,theme:"eclipse",mode:"javascript",showGutter:true,highlightActiveLine:true})}return y.data("ace").editor}function e(){var y=x();h(y.getSession().getValue());g("#attribute-mapping-table :checkbox").on("change",function(){var A=[];g("#attribute-mapping-table :checkbox:checked").each(function(){A.push(g(this).data("attribute-name"))});var z=y.getSession().getValue();var B={targetEntityTypeId:g('[name="target"]').val(),sourceEntityTypeId:g('[name="source"]').val(),targetAttributeName:g('[name="targetAttribute"]').val(),sourceAttributes:A};g.ajax({type:"POST",url:s.getContextUrl()+"/attributemapping/algorithm",data:JSON.stringify(B),contentType:"application/json",success:function(C){if(A.length===0){g("#result-container").css("display","none");g(".nav-tabs a[href=\\#script]").tab("show");g("#map-tab").hide()}else{g("#result-container").css("display","inline")}y.getSession().setValue(C);o(C);var D=g('input[name="targetAttributeType"]').val();if(D==="xref"||D==="categorical"){b(C);g("#map-tab").show()}}})})}function l(F,C,B,z){if(z.length>0){var G="",E,y,A;g.each(z,function(I,H){E=n(B,H.matchedWords.split(" "));y=H.queryString;A=H.score;G+="The query "+y+" derived from "+H.tagName;G+=" is matched to the label on words "+E.join(" ").toLowerCase()+" with "+A+"%

"});var D={title:"Explanation",content:G,html:true,placement:"top",container:F,trigger:"hover"};g(C).popover(D)}}function p(z,C){var D=[],A,E,y;if(z&&C&&C.length>0){z=z.toUpperCase();y=j(z,C);if(y.length>0){A=y[0];for(var B=1;B0){D.push(A)}}}return D}function j(z,A){var C={},y=[],B=[];g.each(A,function(E,D){var E=z.indexOf(D);C[E]=D;B.push(E)});B.sort(function(E,D){return E-D});g.each(B,function(E,D){if(C[D]){y.push(C[D])}});return y}function n(y,A){var z=[];if(y&&A&&A.length>0){g.each(A,function(B,D){if(D.length>2){y=y.toUpperCase();D=D.toUpperCase();var E=y.indexOf(D);while(E==-1&&D.length>0){D=D.substring(0,D.length-1);E=y.indexOf(D)}if(E!=-1){var C=E+D.length;while(y.length>C&&y.charAt(C).match(/[A-Z0-9]/i)){C++}z.push(y.substring(E,C))}else{z.push(D)}}})}return z}function m(B,y,A){showSpinner();var z="";if(A){g.each(A,function(C,D){z+=''})}g('
'+z+"
").appendTo("body").submit()}function w(z,y){g.post(s.getContextUrl()+"/saveattributemapping",{mappingProjectId:g("#mappingProjectId").val(),target:g("#target").val(),source:g("#source").val(),targetAttribute:g("#targetAttribute").val(),algorithm:z,algorithmState:y},function(A){g("#algorithmState").empty().html(y);s.createAlert([{message:"This attribute mapping is saved with the state "+y}],"success");f()}).fail(function(){g(".alerts").empty();s.createAlert([{message:"Error trying to save the attribuet mapping"}],"error")})}function f(){g.post(s.getContextUrl()+"/firstattributemapping",{mappingProjectId:g("#mappingProjectId").val(),target:g("#target").val(),skipAlgorithmStates:["DISCUSS","CURATED"]},function(y){g("#find-first-to-curate-attribute-btn").remove();if(y.length!==0&&(g("#targetAttribute").val()!==y.targetAttribute||g("#source").val()!==y.source)){g("#attribute-mapping-toolbar").append(g(''));g("#find-first-to-curate-attribute-btn").on("click",function(){m("get",s.getContextUrl()+"/attributeMapping",y)})}})}function d(y){if(null!=y&&y.length>0){g("#save-mapping-btn").prop("disabled",false);g("#save-discuss-mapping-btn").prop("disabled",false)}else{g("#save-mapping-btn").prop("disabled",true);g("#save-discuss-mapping-btn").prop("disabled",true)}}function a(A,z,y){A.searchTerms=g("#attribute-search-field").val();g.ajax({type:"POST",url:s.getContextUrl()+"/attributeMapping/semanticsearch",data:JSON.stringify(A),contentType:"application/json",success:function(B){u(B,z,y)}})}g(function(){var C,z,B={mappingProjectId:g('[name="mappingProjectId"]').val(),target:g('[name="target"]').val(),source:g('[name="source"]').val(),targetAttribute:g('[name="targetAttribute"]').val(),searchTerms:""},A,y=[];g("#validate-algorithm-btn").on("click",function(){var D=g("#ace-editor-text-area").data("ace").editor.getSession().getValue();h(D);d(D);c(D);o(D);g("#result-container").css("display","inline")});g("[rel=tooltip]").tooltip({placement:"right"});g(".ontologytag-tooltip").css({cursor:"pointer"}).popover({html:true,placement:"right",trigger:"hover"});a(B,g("#attribute-mapping-table"),g("#dataExplorerUri").val());C=x();z=C.getSession().getValue();if(z.trim()){o(z)}else{g("#result-container").css("display","none")}g("#save-mapping-btn").on("click",function(){w(C.getSession().getValue(),"CURATED")});g("#save-discuss-mapping-btn").on("click",function(){w(C.getSession().getValue(),"DISCUSS")});d(z);f();g("#js-function-modal-btn").on("click",function(){g("#js-function-modal").modal("show")});g("#attribute-search-field-button").on("click",function(D){a(B,g("#attribute-mapping-table"),g("#dataExplorerUri").val())});g("#attribute-search-field").keydown(function(D){if(D.keyCode===13){D.preventDefault();g("#attribute-search-field-button").trigger("click");return false}}).keyup(function(){if(g(this).val()===""){g("#attribute-search-field-button").trigger("click")}});g("a[href=\\#map]").on("shown.bs.tab",function(){b(C.getSession().getValue())});g("a[href=\\#script]").on("shown.bs.tab",function(){C.scrollPageDown()});g("#advanced-mapping-table").on("change",function(){var E={},D=undefined,H=undefined,F,I;g("#advanced-mapping-table > tbody > tr").each(function(){F=g(this).attr("id");I=g(this).find("option:selected").val();if(F==="nullValue"){if(I!=="use-default-option"){if(I==="use-null-value"){H=null}else{H=I}}}else{if(I!=="use-default-option"){if(I==="use-null-value"){E[g(this).attr("id")]=null}else{E[g(this).attr("id")]=I}}}});if(H!==undefined){D=null}if(g("#default-value").is(":visible")){D=g("#default-value").find("option:selected").val();if(D==="use-null-value"){D=null}}var G=v(E,g('input[name="sourceAttribute"]').val(),D,H);x().setValue(G);o(G)})})}($,window.top.molgenis=window.top.molgenis||{}));




© 2015 - 2024 Weber Informatics LLC | Privacy Policy