This commit is contained in:
Jeff Bernhardt 2018-06-25 18:56:14 -07:00
Родитель 4fb619b0c1
Коммит 5444442918
2 изменённых файлов: 223 добавлений и 173 удалений

Просмотреть файл

@ -113,6 +113,18 @@ class profile {
} }
} }
let p = new profile(); let p = new profile();
let visits;
function trackVisits(path) {
if (!visits)
visits = new Map();
let cnt = 0;
if (visits.has(path)) {
cnt = visits.get(path) + 1;
}
visits.set(path, cnt);
if (path == "Case/hasAttributes/attributesAddedAtThisScope/members/(unspecified)")
return true;
}
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
// //
@ -191,12 +203,39 @@ class ParameterValue {
get valueString() { get valueString() {
//let bodyCode = () => //let bodyCode = () =>
{ {
if (this.value) { let value = this.value;
if (this.value.objectType == cdmObjectType.stringConstant) if (value) {
return this.value.getConstant(); // if a string constant, call get value to turn into itself or a reference if that is what is held there
return "cdmObject()"; if (value.getObjectType() == cdmObjectType.stringConstant)
value = value.getValue();
// if still a string, it is just a string
if (value.getObjectType() == cdmObjectType.stringConstant)
return value.getConstant();
// if this is a constant table, then expand into an html table
if (value.getObjectType() == cdmObjectType.entityRef && value.getObjectDef().getObjectType() == cdmObjectType.constantEntityDef) {
var entShape = value.getObjectDef().getEntityShape();
var entValues = value.getObjectDef().getConstantValues();
if (!entValues && entValues.length == 0)
return "";
let rows = new Array();
var shapeAtts = entShape.getResolvedAttributes();
let l = shapeAtts.set.length;
for (var r = 0; r < entValues.length; r++) {
var rowData = entValues[r];
if (rowData && rowData.length) {
let row = {};
for (var c = 0; c < rowData.length; c++) {
var tvalue = rowData[c];
row[shapeAtts.set[c].resolvedName] = tvalue;
} }
return "undefined"; rows.push(row);
}
}
return JSON.stringify(rows);
}
return value.getObjectDef().getName();
}
return "";
} }
//return p.measure(bodyCode); //return p.measure(bodyCode);
} }
@ -312,6 +351,13 @@ class ParameterValueSet {
} }
//return p.measure(bodyCode); //return p.measure(bodyCode);
} }
getValueString(i) {
//let bodyCode = () =>
{
return new ParameterValue(this.pc.sequence[i], this.values[i]).valueString;
}
//return p.measure(bodyCode);
}
getParameterValue(pName) { getParameterValue(pName) {
//let bodyCode = () => //let bodyCode = () =>
{ {
@ -1887,13 +1933,16 @@ class cdmObject {
{ {
let result = false; let result = false;
if (items) { if (items) {
items.some(element => { let lItem = items.length;
if (element) for (let iItem = 0; iItem < lItem; iItem++) {
let element = items[iItem];
if (element) {
if (element.visit(userData, pathRoot, preChildren, postChildren, statusRpt)) { if (element.visit(userData, pathRoot, preChildren, postChildren, statusRpt)) {
result = true; result = true;
return true; break;
}
}
} }
});
} }
return result; return result;
} }
@ -2129,20 +2178,18 @@ class StringConstant extends cdmObject {
} }
//return p.measure(bodyCode); //return p.measure(bodyCode);
} }
getPathBranch() {
//let bodyCode = () =>
{
if (!this.constantValue)
return "XXXXX";
return this.constantValue;
}
//return p.measure(bodyCode);
}
visit(userData, pathRoot, preChildren, postChildren, statusRpt) { visit(userData, pathRoot, preChildren, postChildren, statusRpt) {
//let bodyCode = () => //let bodyCode = () =>
{ {
//let path = pathRoot + this.getPathBranch(); let path = this.declaredPath;
let path = pathRoot + this.constantValue; if (!path) {
if (!this.constantValue)
path = pathRoot + "XXXXX";
else
path = pathRoot + this.constantValue;
this.declaredPath = path;
}
//trackVisits(path);
// not much to do // not much to do
if (preChildren && preChildren(userData, this, path, statusRpt)) if (preChildren && preChildren(userData, this, path, statusRpt))
return false; return false;
@ -2276,13 +2323,6 @@ class ImportImpl extends cdmObject {
} }
//return p.measure(bodyCode); //return p.measure(bodyCode);
} }
getPathBranch() {
//let bodyCode = () =>
{
return this.uri;
}
//return p.measure(bodyCode);
}
visit(userData, pathRoot, preChildren, postChildren, statusRpt) { visit(userData, pathRoot, preChildren, postChildren, statusRpt) {
//let bodyCode = () => //let bodyCode = () =>
{ {
@ -2454,19 +2494,15 @@ class ArgumentImpl extends cdmObject {
} }
//return p.measure(bodyCode); //return p.measure(bodyCode);
} }
getPathBranch() {
//let bodyCode = () =>
{
if (this.value)
return "value/";
return "";
}
//return p.measure(bodyCode);
}
visit(userData, pathRoot, preChildren, postChildren, statusRpt) { visit(userData, pathRoot, preChildren, postChildren, statusRpt) {
//let bodyCode = () => //let bodyCode = () =>
{ {
let path = pathRoot + this.getPathBranch(); let path = this.declaredPath;
if (!path) {
path = pathRoot + (this.value ? "value/" : "");
this.declaredPath = path;
}
//trackVisits(path);
if (preChildren && preChildren(userData, this, path, statusRpt)) if (preChildren && preChildren(userData, this, path, statusRpt))
return false; return false;
if (this.value) if (this.value)
@ -2637,17 +2673,15 @@ class ParameterImpl extends cdmObject {
} }
//return p.measure(bodyCode); //return p.measure(bodyCode);
} }
getPathBranch() {
//let bodyCode = () =>
{
return this.name;
}
//return p.measure(bodyCode);
}
visit(userData, pathRoot, preChildren, postChildren, statusRpt) { visit(userData, pathRoot, preChildren, postChildren, statusRpt) {
//let bodyCode = () => //let bodyCode = () =>
{ {
let path = pathRoot + this.getPathBranch(); let path = this.declaredPath;
if (!path) {
path = pathRoot + this.name;
this.declaredPath = path;
}
//trackVisits(path);
if (preChildren && preChildren(userData, this, path, statusRpt)) if (preChildren && preChildren(userData, this, path, statusRpt))
return false; return false;
if (this.defaultValue) if (this.defaultValue)
@ -3083,19 +3117,19 @@ class TraitReferenceImpl extends cdmObjectRef {
} }
//return p.measure(bodyCode); //return p.measure(bodyCode);
} }
getPathBranch() {
//let bodyCode = () =>
{
if (this.trait.objectType != cdmObjectType.stringConstant)
return "";
return this.trait.getPathBranch();
}
//return p.measure(bodyCode);
}
visit(userData, pathRoot, preChildren, postChildren, statusRpt) { visit(userData, pathRoot, preChildren, postChildren, statusRpt) {
//let bodyCode = () => //let bodyCode = () =>
{ {
let path = pathRoot + this.getPathBranch(); let path = this.declaredPath;
if (!path) {
path = pathRoot;
if (this.trait.objectType === cdmObjectType.stringConstant)
path = pathRoot + this.trait.constantValue;
else
path = pathRoot;
this.declaredPath = path;
}
//trackVisits(path);
if (preChildren && preChildren(userData, this, path, statusRpt)) if (preChildren && preChildren(userData, this, path, statusRpt))
return false; return false;
if (this.trait) if (this.trait)
@ -3319,17 +3353,15 @@ class TraitImpl extends cdmObjectDef {
} }
//return p.measure(bodyCode); //return p.measure(bodyCode);
} }
getPathBranch() {
//let bodyCode = () =>
{
return this.traitName;
}
//return p.measure(bodyCode);
}
visit(userData, pathRoot, preChildren, postChildren, statusRpt) { visit(userData, pathRoot, preChildren, postChildren, statusRpt) {
//let bodyCode = () => //let bodyCode = () =>
{ {
let path = pathRoot + this.getPathBranch(); let path = this.declaredPath;
if (!path) {
path = pathRoot + this.traitName;
this.declaredPath = path;
}
//trackVisits(path);
if (preChildren && preChildren(userData, this, path, statusRpt)) if (preChildren && preChildren(userData, this, path, statusRpt))
return false; return false;
if (this.extendsTrait) if (this.extendsTrait)
@ -3533,19 +3565,18 @@ class RelationshipReferenceImpl extends cdmObjectRef {
} }
//return p.measure(bodyCode); //return p.measure(bodyCode);
} }
getPathBranch() {
//let bodyCode = () =>
{
if (this.relationship.objectType != cdmObjectType.stringConstant)
return "";
return this.relationship.getPathBranch();
}
//return p.measure(bodyCode);
}
visit(userData, pathRoot, preChildren, postChildren, statusRpt) { visit(userData, pathRoot, preChildren, postChildren, statusRpt) {
//let bodyCode = () => //let bodyCode = () =>
{ {
let path = pathRoot + this.getPathBranch(); let path = this.declaredPath;
if (!path) {
if (this.relationship.objectType === cdmObjectType.stringConstant)
path = pathRoot + this.relationship.constantValue;
else
path = pathRoot;
this.declaredPath = path;
}
//trackVisits(path);
if (preChildren && preChildren(userData, this, path, statusRpt)) if (preChildren && preChildren(userData, this, path, statusRpt))
return false; return false;
if (this.relationship) if (this.relationship)
@ -3659,17 +3690,15 @@ class RelationshipImpl extends cdmObjectDef {
} }
//return p.measure(bodyCode); //return p.measure(bodyCode);
} }
getPathBranch() {
//let bodyCode = () =>
{
return this.relationshipName;
}
//return p.measure(bodyCode);
}
visit(userData, pathRoot, preChildren, postChildren, statusRpt) { visit(userData, pathRoot, preChildren, postChildren, statusRpt) {
//let bodyCode = () => //let bodyCode = () =>
{ {
let path = pathRoot + this.getPathBranch(); let path = this.declaredPath;
if (!path) {
path = pathRoot + this.relationshipName;
this.declaredPath = path;
}
//trackVisits(path);
if (preChildren && preChildren(userData, this, path, statusRpt)) if (preChildren && preChildren(userData, this, path, statusRpt))
return false; return false;
if (this.extendsRelationship) if (this.extendsRelationship)
@ -3805,19 +3834,19 @@ class DataTypeReferenceImpl extends cdmObjectRef {
} }
//return p.measure(bodyCode); //return p.measure(bodyCode);
} }
getPathBranch() {
//let bodyCode = () =>
{
if (this.dataType.objectType != cdmObjectType.stringConstant)
return "";
return this.dataType.getPathBranch();
}
//return p.measure(bodyCode);
}
visit(userData, pathRoot, preChildren, postChildren, statusRpt) { visit(userData, pathRoot, preChildren, postChildren, statusRpt) {
//let bodyCode = () => //let bodyCode = () =>
{ {
let path = pathRoot + this.getPathBranch(); let path = this.declaredPath;
if (!path) {
path = pathRoot;
if (this.dataType.objectType === cdmObjectType.stringConstant)
path = pathRoot + this.dataType.constantValue;
else
path = pathRoot;
this.declaredPath = path;
}
//trackVisits(path);
if (preChildren && preChildren(userData, this, path, statusRpt)) if (preChildren && preChildren(userData, this, path, statusRpt))
return false; return false;
if (this.dataType) if (this.dataType)
@ -3934,17 +3963,15 @@ class DataTypeImpl extends cdmObjectDef {
} }
//return p.measure(bodyCode); //return p.measure(bodyCode);
} }
getPathBranch() {
//let bodyCode = () =>
{
return this.dataTypeName;
}
//return p.measure(bodyCode);
}
visit(userData, pathRoot, preChildren, postChildren, statusRpt) { visit(userData, pathRoot, preChildren, postChildren, statusRpt) {
//let bodyCode = () => //let bodyCode = () =>
{ {
let path = pathRoot + this.getPathBranch(); let path = this.declaredPath;
if (!path) {
path = pathRoot + this.dataTypeName;
this.declaredPath = path;
}
//trackVisits(path);
if (preChildren && preChildren(userData, this, path, statusRpt)) if (preChildren && preChildren(userData, this, path, statusRpt))
return false; return false;
if (this.extendsDataType) if (this.extendsDataType)
@ -4226,17 +4253,15 @@ class TypeAttributeImpl extends AttributeImpl {
} }
//return p.measure(bodyCode); //return p.measure(bodyCode);
} }
getPathBranch() {
//let bodyCode = () =>
{
return this.name;
}
//return p.measure(bodyCode);
}
visit(userData, pathRoot, preChildren, postChildren, statusRpt) { visit(userData, pathRoot, preChildren, postChildren, statusRpt) {
//let bodyCode = () => //let bodyCode = () =>
{ {
let path = pathRoot + this.getPathBranch(); let path = this.declaredPath;
if (!path) {
path = pathRoot + this.name;
this.declaredPath = path;
}
//trackVisits(path);
if (preChildren && preChildren(userData, this, path, statusRpt)) if (preChildren && preChildren(userData, this, path, statusRpt))
return false; return false;
if (this.dataType) if (this.dataType)
@ -4460,13 +4485,15 @@ class EntityAttributeImpl extends AttributeImpl {
} }
//return p.measure(bodyCode); //return p.measure(bodyCode);
} }
getPathBranch() {
return "(unspecified)";
}
visit(userData, pathRoot, preChildren, postChildren, statusRpt) { visit(userData, pathRoot, preChildren, postChildren, statusRpt) {
//let bodyCode = () => //let bodyCode = () =>
{ {
let path = pathRoot + this.getPathBranch(); let path = this.declaredPath;
if (!path) {
path = pathRoot + "(unspecified)";
this.declaredPath = path;
}
//trackVisits(path);
if (preChildren && preChildren(userData, this, path, statusRpt)) if (preChildren && preChildren(userData, this, path, statusRpt))
return false; return false;
if (this.entity instanceof Array) { if (this.entity instanceof Array) {
@ -4700,19 +4727,18 @@ class AttributeGroupReferenceImpl extends cdmObjectRef {
} }
//return p.measure(bodyCode); //return p.measure(bodyCode);
} }
getPathBranch() {
//let bodyCode = () =>
{
if (this.attributeGroup.objectType != cdmObjectType.stringConstant)
return "";
return this.attributeGroup.getPathBranch();
}
//return p.measure(bodyCode);
}
visit(userData, pathRoot, preChildren, postChildren, statusRpt) { visit(userData, pathRoot, preChildren, postChildren, statusRpt) {
//let bodyCode = () => //let bodyCode = () =>
{ {
let path = pathRoot + this.getPathBranch(); let path = this.declaredPath;
if (!path) {
if (this.attributeGroup.objectType === cdmObjectType.stringConstant)
path = pathRoot + this.attributeGroup.constantValue;
else
path = pathRoot;
this.declaredPath = path;
}
//trackVisits(path);
if (preChildren && preChildren(userData, this, path, statusRpt)) if (preChildren && preChildren(userData, this, path, statusRpt))
return false; return false;
if (this.attributeGroup) if (this.attributeGroup)
@ -4858,18 +4884,15 @@ class AttributeGroupImpl extends cdmObjectDef {
} }
//return p.measure(bodyCode); //return p.measure(bodyCode);
} }
getPathBranch() {
//let bodyCode = () =>
{
return this.attributeGroupName;
;
}
//return p.measure(bodyCode);
}
visit(userData, pathRoot, preChildren, postChildren, statusRpt) { visit(userData, pathRoot, preChildren, postChildren, statusRpt) {
//let bodyCode = () => //let bodyCode = () =>
{ {
let path = pathRoot + this.getPathBranch(); let path = this.declaredPath;
if (!path) {
path = pathRoot + this.attributeGroupName;
this.declaredPath = path;
}
//trackVisits(path);
if (preChildren && preChildren(userData, this, path, statusRpt)) if (preChildren && preChildren(userData, this, path, statusRpt))
return false; return false;
if (this.members) if (this.members)
@ -5095,20 +5118,15 @@ class ConstantEntityImpl extends cdmObjectDef {
} }
//return p.measure(bodyCode); //return p.measure(bodyCode);
} }
getPathBranch() {
//let bodyCode = () =>
{
if (this.constantEntityName)
return this.constantEntityName;
else
return "(unspecified)";
}
//return p.measure(bodyCode);
}
visit(userData, pathRoot, preChildren, postChildren, statusRpt) { visit(userData, pathRoot, preChildren, postChildren, statusRpt) {
//let bodyCode = () => //let bodyCode = () =>
{ {
let path = pathRoot + this.getPathBranch(); let path = this.declaredPath;
if (!path) {
path = pathRoot + (this.constantEntityName ? this.constantEntityName : "(unspecified)");
this.declaredPath = path;
}
//trackVisits(path);
if (preChildren && preChildren(userData, this, path, statusRpt)) if (preChildren && preChildren(userData, this, path, statusRpt))
return false; return false;
if (this.entityShape) if (this.entityShape)
@ -5275,19 +5293,20 @@ class EntityReferenceImpl extends cdmObjectRef {
} }
//return p.measure(bodyCode); //return p.measure(bodyCode);
} }
getPathBranch() {
//let bodyCode = () =>
{
if (this.entity.objectType != cdmObjectType.stringConstant)
return "";
return this.entity.getPathBranch();
}
//return p.measure(bodyCode);
}
visit(userData, pathRoot, preChildren, postChildren, statusRpt) { visit(userData, pathRoot, preChildren, postChildren, statusRpt) {
//let bodyCode = () => //let bodyCode = () =>
{ {
let path = pathRoot + this.getPathBranch(); let path = this.declaredPath;
if (!path) {
if (this.entity.objectType == cdmObjectType.stringConstant)
path = pathRoot + this.entity.constantValue;
else if (this.entity.objectType == cdmObjectType.constantEntityDef)
path = pathRoot + "(constantEntity)";
else
path = pathRoot;
this.declaredPath = path;
}
//trackVisits(path);
if (preChildren && preChildren(userData, this, path, statusRpt)) if (preChildren && preChildren(userData, this, path, statusRpt))
return false; return false;
if (this.entity) if (this.entity)
@ -5451,17 +5470,15 @@ class EntityImpl extends cdmObjectDef {
} }
//return p.measure(bodyCode); //return p.measure(bodyCode);
} }
getPathBranch() {
//let bodyCode = () =>
{
return this.entityName;
}
//return p.measure(bodyCode);
}
visit(userData, pathRoot, preChildren, postChildren, statusRpt) { visit(userData, pathRoot, preChildren, postChildren, statusRpt) {
//let bodyCode = () => //let bodyCode = () =>
{ {
let path = pathRoot + this.getPathBranch(); let path = this.declaredPath;
if (!path) {
path = pathRoot + this.entityName;
this.declaredPath = path;
}
//trackVisits(path);
if (preChildren && preChildren(userData, this, path, statusRpt)) if (preChildren && preChildren(userData, this, path, statusRpt))
return false; return false;
if (this.extendsEntity) if (this.extendsEntity)
@ -5808,13 +5825,6 @@ class Document extends cdmObject {
} }
//return p.measure(bodyCode); //return p.measure(bodyCode);
} }
getPathBranch() {
//let bodyCode = () =>
{
return "";
}
//return p.measure(bodyCode);
}
visit(userData, pathRoot, preChildren, postChildren, statusRpt) { visit(userData, pathRoot, preChildren, postChildren, statusRpt) {
//let bodyCode = () => //let bodyCode = () =>
{ {
@ -6189,13 +6199,6 @@ class Folder {
} }
//return p.measure(bodyCode); //return p.measure(bodyCode);
} }
getPathBranch() {
//let bodyCode = () =>
{
return "only makes sense inside a document";
}
//return p.measure(bodyCode);
}
getObjectDef() { getObjectDef() {
//let bodyCode = () => //let bodyCode = () =>
{ {
@ -7057,6 +7060,17 @@ class Corpus extends Folder {
} }
; ;
p.report(); p.report();
if (visits) {
let max = 0;
let maxVisit = "";
visits.forEach((v, k) => {
if (v > 250) {
max = v;
maxVisit = k;
}
});
console.log(`${maxVisit}, ${max}`);
}
if (errors > 0) if (errors > 0)
resolve(cdmValidationStep.error); resolve(cdmValidationStep.error);
else else

Просмотреть файл

@ -56,6 +56,10 @@ class DPAttributeImpl {
//isHidden: boolean; //isHidden: boolean;
constructor() { constructor() {
} }
cleanUp() {
if (this.annotations.length == 0)
this.annotations = undefined;
}
} }
class DPAnnotationImpl { class DPAnnotationImpl {
constructor(name, value) { constructor(name, value) {
@ -136,6 +140,8 @@ class Converter {
if (localizedTableRef) if (localizedTableRef)
dpEnt.description = localizedTableRef.getObjectDef().lookupWhere("displayText", "languageTag", "en"); dpEnt.description = localizedTableRef.getObjectDef().lookupWhere("displayText", "languageTag", "en");
} }
// turn each trait into an annotation too
//this.traitToAnnotation(rt, dpEnt.annotations);
}); });
// if (isPII) // if (isPII)
// dpEnt.pii = "CustomerContent"; // dpEnt.pii = "CustomerContent";
@ -161,6 +167,13 @@ class Converter {
dpAtt.sourceColumnName = mapTrait.parameterValues.getParameterValue("name").valueString; dpAtt.sourceColumnName = mapTrait.parameterValues.getParameterValue("name").valueString;
dpAtt.dataType = this.traits2DataType(ra.resolvedTraits); dpAtt.dataType = this.traits2DataType(ra.resolvedTraits);
dpAtt.dataCategory = this.traits2DataCategory(ra.resolvedTraits); dpAtt.dataCategory = this.traits2DataCategory(ra.resolvedTraits);
// turn each trait into an annotation too
dpAtt.annotations = new Array();
let rtsAtt = ra.resolvedTraits;
rtsAtt.set.forEach(rt => {
//this.traitToAnnotation(rt, dpAtt.annotations);
});
dpAtt.cleanUp();
dpEnt.attributes.push(dpAtt); dpEnt.attributes.push(dpAtt);
}); });
dpEnt.cleanUp(); dpEnt.cleanUp();
@ -447,6 +460,29 @@ class Converter {
} }
return baseType; return baseType;
} }
traitToAnnotation(rt, annotations) {
// skip the ugly traits
if (!rt.trait.ugly) {
let annotationName = "trait." + rt.traitName;
let annotation;
// if there are non-null parameters for the trait, they each turn into annotations
let pv = rt.parameterValues;
if (pv && pv.length) {
for (let i = 0; i < pv.length; i++) {
let paramName = pv.getParameter(i).getName();
let paramValue = pv.getValueString(i);
if (paramValue) {
annotation = new DPAnnotationImpl(annotationName + "." + paramName, paramValue);
annotations.push(annotation);
}
}
}
if (!annotation) {
annotation = new DPAnnotationImpl(annotationName, "true");
annotations.push(annotation);
}
}
}
} }
exports.Converter = Converter; exports.Converter = Converter;