js/model/vismodel.js
/**
 * generate a textual representation of a domain
 */
generate a textual representation of a domain
generate a textual representation of a domain
function tabDomain(domain, m) {
    var res = '';
    var modelCache = {};
    var cats = mgnlq_model_1.Model.getCategoriesForDomain(m, domain);
    cats = mgnlq_model_1.Model.sortCategoriesByImportance(m.full.domain[domain].categories || {}, cats);
    return Describe.getCategoryStatsInDomain(cats[0], domain, m).then((catResult0) => {
        return calcCategoryRecord(m, cats[0], domain, modelCache).then((catResult1) => {
            var domainDescr = m.full.domain[domain].description || "";
            domainDescr = replaceBr(domainDescr);
            res = `
// preset form values if we receive a userdata object //
- user = user
extends ../layout_p
block content
	nav.navbar.navbar-default.navbar-fixed-top
		.container
			.navbar-header
				.navbar-brand(style='bgcolor:orange;color:darkblue;font-family:Arial Black;font-size:15.118px') wosap domain ${domain}
			ul.nav.navbar-nav.navbar-right #{uid}
				li
					.navbar-btn#btn-logout.btn.btn-default(onclick="location.href='/home'")
						| back to home
	p  &nbsp;
	p &nbsp;
	p
	div.well
		h3 domain "${domain}"
			span.pull-right ${catResult1.nrTotalRecordsInDomain} records
		p
		span ${domainDescr}
		table.table.table-condensed.table-striped
			thead
				tr
					th category
					th(style="width:10%") count
					th
						table
							tr
								td synonyms
							tr
								td description
							tr
								td example values
			tbody
`;
            var categoryResults = {};
            var otherdomains = [];
            var categoryMap = m.full.domain[domain].categories || {};
            var pTail = Promise.resolve();
            cats.forEach(function (cat) {
                pTail = pTail.then(() => {
                    return Describe.getCategoryStatsInDomain(cat, domain, m).then(catdesc => {
                        return calcCategoryRecord(m, cat, domain, modelCache).then((catResult2) => {
                            categoryResults[cat] = catResult2;
                            otherdomains = _.union(otherdomains, categoryResults[cat].otherDomains);
                            if (m.full.domain[domain].categories[cat]) {
                                var synonymsString = Util.listToCommaAnd(catdesc.categoryDesc && catdesc.categoryDesc.category_synonyms && catdesc.categoryDesc.category_synonyms || []) || "&nbsp;";
                                res += `
			tr
					td.cat_count ${cat}
\t\t\t\t\ttd ${catdesc.presentRecords} distinct values in ${catdesc.percPresent}% of records
\t\t\t\t\ttd
\t\t\t\t\t\ttable
\t\t\t\t\t\t\ttr.cat_synonyms
\t\t\t\t\t\t\t\ttd ${synonymsString}
\t\t\t\t\t\t\ttr.cat_description
\t\t\t\t\t\t\t\ttd ${replaceBr(catdesc.categoryDesc && catdesc.categoryDesc.category_description || "")}
\t\t\t\t\t\t\ttr.cat_samplevalues
\t\t\t\t\t\t\t\ttd ${replaceBr(catdesc.sampleValues)}
      `;
                            }
                        });
                    });
                });
            });
            return pTail.then(() => {
                var othercats = cats.length - Object.keys(m.full.domain[domain].categories).length;
                var remainingCategories = _.difference(cats, Object.keys(m.full.domain[domain].categories));
                if ((othercats) > 0) {
                    res += `
\t\tp   and ${othercats} other categories
\t\t| ${Util.listToCommaAnd(remainingCategories)}
       `;
                }
                res += `
		h3 Version
			a.small(href="/whatsnew")
block scripts
	script(src='/vendor/jquery-2.2.3.min.js')
	script(src='/vendor/bootstrap.min.js')
	script(src='/js/views/settings.js')
`;
                return res;
            });
        });
    }).then(() => {
        return res;
    });
}
function tabDomain ( domain , m ) { var res = '' ; var modelCache = { } ; var cats = mgnlq_model_1 . Model . getCategoriesForDomain ( m , domain ) ; cats = mgnlq_model_1 . Model . sortCategoriesByImportance ( m . full . domain [ domain ] . categories || { } , cats ) ; return Describe . getCategoryStatsInDomain ( cats [ 0 ] , domain , m ) . then ( ( catResult0 ) => { return calcCategoryRecord ( m , cats [ 0 ] , domain , modelCache ) . then ( ( catResult1 ) => { var domainDescr = m . full . domain [ domain ] . description || "" ; domainDescr = replaceBr ( domainDescr ) ; res = ` ${ domain } ${ domain } ${ catResult1 . nrTotalRecordsInDomain } ${ domainDescr } ` ; var categoryResults = { } ; var otherdomains = [ ] ; var categoryMap = m . full . domain [ domain ] . categories || { } ; var pTail = Promise . resolve ( ) ; cats . forEach ( function ( cat ) { pTail = pTail . then ( ( ) => { return Describe . getCategoryStatsInDomain ( cat , domain , m ) . then ( catdesc => { return calcCategoryRecord ( m , cat , domain , modelCache ) . then ( ( catResult2 ) => { categoryResults [ cat ] = catResult2 ; otherdomains = _ . union ( otherdomains , categoryResults [ cat ] . otherDomains ) ; if ( m . full . domain [ domain ] . categories [ cat ] ) { var synonymsString = Util . listToCommaAnd ( catdesc . categoryDesc && catdesc . categoryDesc . category_synonyms && catdesc . categoryDesc . category_synonyms || [ ] ) || "&nbsp;" ; res += ` ${ cat } \t \t \t \t \t ${ catdesc . presentRecords } ${ catdesc . percPresent } \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t ${ synonymsString } \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t ${ replaceBr ( catdesc . categoryDesc && catdesc . categoryDesc . category_description || "" ) } \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t ${ replaceBr ( catdesc . sampleValues ) } ` ; } } ) ; } ) ; } ) ; } ) ; return pTail . then ( ( ) => { var othercats = cats . length - Object . keys ( m . full . domain [ domain ] . categories ) . length ; var remainingCategories = _ . difference ( cats , Object . keys ( m . full . domain [ domain ] . categories ) ) ; if ( ( othercats ) > 0 ) { res += ` \t \t ${ othercats } \t \t ${ Util . listToCommaAnd ( remainingCategories ) } ` ; } res += ` ` ; return res ; } ) ; } ) ; } ) . then ( ( ) => { return res ; } ) ; }
generate a textual representation of a domain
generate a textual representation of a domain
// draw a model domains //console.log(cats.join("\n")); /*
                                res += `"${cat}" [label="{ ${cat} | ${catResult.nrDistinctValuesInDomain} Values in ${catResult.nrRecordsInDomain} `;
                                if(catResult.nrRecordsInDomain !== catResult.nrRecords) {
                                  res +=  `|  ${catResult.nrDistinctValues - catResult.nrDistinctValuesInDomain} other values in ${catResult.nrRecords - catResult.nrRecordsInDomain} other records`;
                                } else {
                                  res += ` `;
                                }
                                res += `}"]\n`;
                            */ //console.log(JSON.stringify(m.full.domain[domain])); //console.log(JSON.stringify(catdesc)); /*
                  // calculate other domains.
                  // draw "other categories"
                  res += `node [color=purple, style=filled]; \n`
                  otherdomains.forEach(function(otherdomain) {
                    res += `"${otherdomain}" \n`;
                  });
                  // count records in domain :
                  var nrRecords = m.records.reduce(function(prev,entry) {
                  return prev + ((entry._domain === domain) ? 1 : 0);
                  },0);
                  res += `node [shape=record]; \n`
                  res += ` "record" [label="{<f0> ${domain} | ${nrRecords}}"] \n`;
        
                  res += ` "r_other" [label="{<f0> other | ${nrRecords}}"] \n `;
        
                  res += `# relation from categories to domain\n`;
                  cats.forEach(function(cat) {
                    res += ` "${cat}" -> "${domain}" \n`;
                  })
        
        
                  res += `# relation from categories to records\n`;
                  cats.forEach(function(cat) {
                    var rec = categoryResults[cat];
                    res += ` "${cat}" -> "record" \n`;
                  })
        
        
                  //other domains to this
                  cats.forEach(function(cat) {
        
        
                  })
                */ /*
                cats fo
                  digraph sdsu {
                size="36,36";
                node [color=yellow, style=filled];
                FLPD FLP "BOM Editor", "WIKIURL" "UI5 Documentation", "UI5 Example", "STARTTA"
                BCP
                node [color=grey, style=filled];
                node [fontname="Verdana", size="30,30"];
                node [color=grey, style=filled];
                graph [ fontname = "Arial",
                */