Commit 0f4f5f1b903068857d9906d85efe778e5f9e95e2

Authored by Renato De Donato
1 parent 55f1f6d9

new datalets multiserie2

bower_components/JSDataChecker/.bower.json
1 1 {
2 2 "name": "JSDataChecker",
3   - "version": "0.0.7",
  3 + "version": "0.0.8",
4 4 "homepage": "https://github.com/donpir/JSDataChecker",
5 5 "authors": [
6 6 "'Donato Pirozzi <'donatopirozzi@gmail.com'>"
... ... @@ -22,11 +22,11 @@
22 22 "polywc": "https://github.com/donpir/polywc.git#master"
23 23 },
24 24 "private": false,
25   - "_release": "0.0.7",
  25 + "_release": "0.0.8",
26 26 "_resolution": {
27 27 "type": "version",
28   - "tag": "v0.0.7",
29   - "commit": "f6d2d47543510eeefc2e0a9bda86dec09ac4b092"
  28 + "tag": "v0.0.8",
  29 + "commit": "862e4d5fe56d629ae7ef8aadb728b1add3af01d9"
30 30 },
31 31 "_source": "https://github.com/donpir/JSDataChecker.git",
32 32 "_target": "~0.0.6",
... ...
bower_components/JSDataChecker/bower.json
1 1 {
2 2 "name": "JSDataChecker",
3   - "version": "v0.0.7",
  3 + "version": "v0.0.8",
4 4 "homepage": "https://github.com/donpir/JSDataChecker",
5 5 "authors": [
6 6 "'Donato Pirozzi <'donatopirozzi@gmail.com'>"
... ...
bower_components/JSDataChecker/build.cmd
1 1 del jsdatachecker.min.js
2   -uglifyjs src\ArrayUtils.js src\DataTypeConverter.js src\DataTypesUtils.js --compress -o jsdatachecker.min.js
3 2 \ No newline at end of file
  3 +uglifyjs src\ArrayUtils.js src\DataTypeConverter.js src\DataTypesUtils.js src\DataTypeHierarchy.js --compress -o jsdatachecker.min.js
4 4 \ No newline at end of file
... ...
bower_components/JSDataChecker/jsdatachecker.min.js
1   -function ArrayUtils(){}function DataTypeConverter(){this._fields=[],this._numOfRows=0}function DataTypesUtils(){}ArrayUtils.TestAndSet=function(arr,key,object){return"undefined"==typeof arr?null:0==Array.isArray(arr)?null:("undefined"==typeof arr[key]&&(arr[key]=object),arr[key])},ArrayUtils.TestAndInitializeKey=function(obj,key,value){return"undefined"==typeof obj?null:("undefined"==typeof obj[key]&&(obj[key]=value),obj[key])},ArrayUtils.TestAndIncrement=function(arr,key){var exists=arr[key];return"undefined"==typeof exists&&(arr[key]=0),arr[key]++,arr},ArrayUtils.toFieldsArray=function(obj){var fields=[];return ArrayUtils.IteratorOverKeys(obj,function(field,key){field.key=key,fields.push(field)}),fields},ArrayUtils.IteratorOverKeys=function(arr,callback){for(var property in arr)if(arr.hasOwnProperty(property)){var item=arr[property];callback(item,property)}},ArrayUtils.FindMinMax=function(arr,fncompare){var max1=null,max2=null;for(var key in arr)null==max1||fncompare(arr[key],max1.value)?(max2=max1,max1={index:-1,key:key,value:arr[key]}):(null==max2||fncompare(arr[key],max2.value))&&(max2={index:-1,key:key,value:arr[key]});return{first:max1,second:max2}},ArrayUtils.isArray=function(arr){return Array.isArray(arr)?arr.length>0:!1},DataTypeConverter.TYPES={TEXT:{value:0,name:"TEXT"},CODE:{value:1,name:"CODE"},NUMBER:{value:2,name:"NUMBER"},OBJECT:{value:3,name:"OBJECT"},BOOL:{value:5,name:"BOOL"},CONST:{value:6,name:"CONST"},CATEGORY:{value:7,name:"CATEGORY"},DATETIME:{value:8,name:"DATETIME"},EMPTY:{value:101,name:"NULL"}},DataTypeConverter.SUBTYPES={PERCENTAGE:{value:1e3,name:"PERCENTAGE"},LATITUDE:{value:1001,name:"LATITUDE"},LONGITUDE:{value:1002,name:"LONGITUDE"}},DataTypeConverter.prototype=function(){var _analyseDataTypes=function(fields){ArrayUtils.IteratorOverKeys(fields,function(field){if(field._inferredTypes[DataTypeConverter.TYPES.CODE.name]){var confidence=field._inferredTypes[DataTypeConverter.TYPES.CODE.name]/field.numOfItems,_numericalInferredType=field._inferredTypes[DataTypeConverter.TYPES.NUMBER.name];return"undefined"!=typeof _numericalInferredType&&(confidence+=_numericalInferredType/field.numOfItems),field.type=DataTypeConverter.TYPES.CODE.name,void(field.typeConfidence=confidence)}var max=ArrayUtils.FindMinMax(field._inferredTypes,function(curval,lastval){return curval>lastval}),tkey=max.first.key;tkey===DataTypeConverter.TYPES.EMPTY.name&&null!=max.second&&"undefined"!=typeof max.second&&(tkey=max.second.key),field.type=tkey,field.typeConfidence=field._inferredTypes[max.first.key]/field.numOfItems})},_processInferType=function(value){if(null===value||"undefined"==typeof value)return DataTypeConverter.TYPES.EMPTY;if("object"==typeof value)return DataTypeConverter.TYPES.OBJECT;if(/^0[0-9]+$/.test(value))return DataTypeConverter.TYPES.CODE;var isnumber=DataTypesUtils.FilterFloat(value);if(isNaN(isnumber)!==!0)return DataTypeConverter.TYPES.NUMBER;var _date=DataTypesUtils.FilterDateTime(value);return 0==isNaN(_date)&&null!=_date?DataTypeConverter.TYPES.DATETIME:DataTypeConverter.TYPES.TEXT},jsonTraverse=function(json,fieldKeys,callback){var stack=[],numOfRows=0;for(stack.push({item:json,fieldKeyIndex:0});stack.length>0;){var stackTask=stack.pop(),item=stackTask.item,fieldKeyIndex=stackTask.fieldKeyIndex,fieldKey=fieldKeys[fieldKeyIndex];if("*"!=fieldKey||0!=ArrayUtils.isArray(item))if("*"!=fieldKey||1!=ArrayUtils.isArray(item)){var jsonSubtree=item[fieldKey];if(Array.isArray(jsonSubtree))for(var j=0;j<jsonSubtree.length;j++){var jsonItem=jsonSubtree[j];stack.push({item:jsonItem,fieldKeyIndex:fieldKeyIndex+1})}else stack.push({item:jsonSubtree,fieldKeyIndex:fieldKeyIndex+1})}else for(var cell,j=0;j<item.length&&(cell=item[j]);j++)stack.push({item:cell,fieldKeyIndex:fieldKeyIndex}),numOfRows++;else{var sProcessedKeys=fieldKeys.slice(0,fieldKeyIndex).toString();ArrayUtils.IteratorOverKeys(item,function(value,key){var curKey=sProcessedKeys+(sProcessedKeys.length>0?",":"")+key,_value=callback(value,key,curKey,numOfRows);item[key]=_value}),numOfRows++}}};return{constructor:DataTypeConverter,cast:function(metadata,options){return"undefined"!=typeof options&&null!=options||(options={castThresholdConfidence:1,castIfNull:!1}),this.convert(metadata,options)},convert:function(metadata,options){var lastRowIndex=0,numOfRows=0,numOfValues=0,datasetErrors=0,datasetMissingValues=0;return"undefined"!=typeof options&&null!=options||(options={castThresholdConfidence:1,castIfNull:!1}),jsonTraverse(metadata.dataset,metadata.fieldKeys,function(value,key,traversedKeys,rowIndex){var inferredType=metadata.types[traversedKeys];numOfValues++,lastRowIndex!=rowIndex&&(lastRowIndex=rowIndex,numOfRows++),null==value||"undefined"==typeof value||0==(value+"").length;var isCast=inferredType.typeConfidence>=options.castThresholdConfidence;if(inferredType.type==DataTypeConverter.TYPES.NUMBER.name&&isCast){var number=parseFloat(value);return isNaN(number)?(datasetErrors++,value):number}return value}),metadata.qualityIndex.notNullValues=(numOfValues-datasetMissingValues)/numOfValues,metadata.qualityIndex.errors=(numOfValues-datasetErrors)/numOfValues,metadata},inferJsonDataType:function(json,fieldKeys){var stack=[],fieldsType={},numOfRows=0;if("undefined"==typeof fieldKeys)throw"IllegalArgumentException: undefined json path to analyse.";for(stack.push({item:json,fieldKeyIndex:0});stack.length>0;){var stackTask=stack.pop(),item=stackTask.item,fieldKeyIndex=stackTask.fieldKeyIndex,fieldKey=fieldKeys[fieldKeyIndex];if("*"!=fieldKey||0!=ArrayUtils.isArray(item))if("*"==fieldKey&&ArrayUtils.isArray(item))for(var cell,j=0;j<item.length&&(cell=item[j]);j++)stack.push({item:cell,fieldKeyIndex:fieldKeyIndex}),numOfRows++;else{var jsonSubtree=item[fieldKey];if(Array.isArray(jsonSubtree))for(var j=0;j<jsonSubtree.length;j++){var jsonItem=jsonSubtree[j];stack.push({item:jsonItem,fieldKeyIndex:fieldKeyIndex+1})}else stack.push({item:jsonSubtree,fieldKeyIndex:fieldKeyIndex+1})}else{var sProcessedKeys=fieldKeys.slice(0,fieldKeyIndex).toString();ArrayUtils.IteratorOverKeys(item,function(item,key){var inferredType=_processInferType(item),curKey=sProcessedKeys+(0==sProcessedKeys.length?"":",")+key,fieldType=ArrayUtils.TestAndInitializeKey(fieldsType,curKey,{name:curKey,_inferredTypes:[],_inferredValues:[],numOfItems:0});fieldType.numOfItems++,ArrayUtils.TestAndIncrement(fieldType._inferredTypes,inferredType.name),inferredType===DataTypeConverter.TYPES.TEXT&&ArrayUtils.TestAndIncrement(fieldType._inferredValues,item)}),numOfRows++}}_analyseDataTypes(fieldsType);var quality={homogeneity:1,completeness:1,totalNullValues:0,totalValues:0};ArrayUtils.IteratorOverKeys(fieldsType,function(fieldType){quality.totalValues+=fieldType.numOfItems,quality.homogeneity*=fieldType.typeConfidence,fieldType.totalNullValues=0,fieldType._inferredTypes.hasOwnProperty(DataTypeConverter.TYPES.EMPTY.name)&&(fieldType.totalNullValues=fieldType._inferredTypes[DataTypeConverter.TYPES.EMPTY.name],quality.totalNullValues+=fieldType.totalNullValues)}),quality.homogeneity=Math.round(100*quality.homogeneity)/100;var totFullValues=quality.totalValues-quality.totalNullValues;quality.completeness=Math.round(totFullValues/quality.totalValues*100)/100;var warningsTextual="";return ArrayUtils.IteratorOverKeys(fieldsType,function(fieldType){fieldType.errorsDescription="";var description="";if(fieldType.typeConfidence<1){var incorrect=fieldType.numOfItems-fieldType.totalNullValues-fieldType._inferredTypes[fieldType.type];if(incorrect>0){description+="The column <"+fieldType.name+"> has the type <"+fieldType.type+">";var verb=1==incorrect?" value is":" values are";description+=", but "+incorrect+verb+" not a "+fieldType.type}}fieldType.totalNullValues>0&&(description+="The column <"+fieldType.name+"> has "+fieldType.totalNullValues+" EMPTY value",fieldType.totalNullValues>1&&(description+="s")),description.length>0&&(description+="."),fieldType.errorsDescription=description,warningsTextual+=description}),{dataset:json,fieldKeys:fieldKeys,types:fieldsType,qualityIndex:quality,warningsTextual:warningsTextual}},inferDataTypeOfValue:function(value){return _processInferType(value)}}}(),DataTypesUtils.FilterTime=function(value){var expTime=/^[0-9]{2}:[0-9]{2}(:[0-9]{2})?(\+[0-9]{2}:[0-9]{2})?$/;if(0==expTime.test(value))return null;var splitted=value.split(/[:|\+]/),expNumber=/^[0-9]{2}$/,HH=expNumber.test(splitted[0])?parseInt(splitted[0]):0,MM=expNumber.test(splitted[1])?parseInt(splitted[1]):0,SS=splitted.length>=3&&expNumber.test(splitted[2])?parseInt(splitted[2]):0,dt=new Date;return dt.setHours(HH),dt.setMinutes(MM),dt.setSeconds(SS),dt},DataTypesUtils.FilterDateTime=function(value){var _dtSplitted=value.split(/[T|\s]/);if(2==_dtSplitted.length){var dtTime=DataTypesUtils.FilterTime(_dtSplitted[1]);if(null==dtTime)return null;var dtDateTime=DataTypesUtils.FilterDate(_dtSplitted[0],dtTime);return dtDateTime}var dtDate=DataTypesUtils.FilterDate(value);if(null!=dtDate)return dtDate;var dtTime=DataTypesUtils.FilterTime(value);return dtTime},DataTypesUtils.FilterDate=function(value,dtDate){if(null==dtDate&&(dtDate=new Date),/^[0-9][0-9][0-9][0-9]\-[0-9][0-9]$/.test(value)){var year=parseInt(value.substring(0,4)),month=parseInt(value.substring(5));return dtDate.setYear(year),dtDate.setMonth(month),dtDate}var expDate=/^[0-9]{4}(\-|\/)[0-9]{2}((\-|\/)[0-9]{2})?$/;if(expDate.test(value)){var splitted=value.split(/[\-|\/]/),year=parseInt(splitted[0]),month=parseInt(splitted[1]),day=3==splitted.length?parseInt(splitted[2]):0;return dtDate.setYear(year),dtDate.setMonth(month),dtDate.setDate(day),dtDate}if(expDate=/^[0-9]{2}(\-|\/)[0-9]{2}(\-|\/)[0-9]{4}$/,expDate.test(value)){var splitted=value.split(/[\-|\/]/),year=parseInt(splitted[2]),month=parseInt(splitted[1]),day=parseInt(splitted[0]);return dtDate.setYear(year),dtDate.setMonth(month),dtDate.setDate(day),dtDate}return null},DataTypesUtils.FilterFloat=function(value){return/^(\-|\+)?((0|([1-9][0-9]*))(\.[0-9]+)?|Infinity)$/.test(value)?Number(value):NaN},DataTypesUtils.DecimalPlaces=function(num){var match=(""+num).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return match?Math.max(0,(match[1]?match[1].length:0)-(match[2]?+match[2]:0)):0};
2 1 \ No newline at end of file
  2 +function ArrayUtils(){}function DataTypeConverter(){this._fields=[],this._numOfRows=0}function DataTypesUtils(){}function DataTypeHierarchy(){}ArrayUtils.TestAndSet=function(arr,key,object){return"undefined"==typeof arr?null:0==Array.isArray(arr)?null:("undefined"==typeof arr[key]&&(arr[key]=object),arr[key])},ArrayUtils.TestAndInitializeKey=function(obj,key,value){return"undefined"==typeof obj?null:("undefined"==typeof obj[key]&&(obj[key]=value),obj[key])},ArrayUtils.TestAndIncrement=function(arr,key){var exists=arr[key];return"undefined"==typeof exists&&(arr[key]=0),arr[key]++,arr},ArrayUtils.toFieldsArray=function(obj){var fields=[];return ArrayUtils.IteratorOverKeys(obj,function(field,key){field.key=key,fields.push(field)}),fields},ArrayUtils.IteratorOverKeys=function(arr,callback){for(var property in arr)if(arr.hasOwnProperty(property)){var item=arr[property];callback(item,property)}},ArrayUtils.FindMinMax=function(arr,fncompare){var max1=null,max2=null;for(var key in arr)null==max1||fncompare(arr[key],max1.value)?(max2=max1,max1={index:-1,key:key,value:arr[key]}):(null==max2||fncompare(arr[key],max2.value))&&(max2={index:-1,key:key,value:arr[key]});return{first:max1,second:max2}},ArrayUtils.isArray=function(arr){return Array.isArray(arr)?arr.length>0:!1},DataTypeConverter.TYPES={TEXT:{value:0,name:"TEXT"},CODE:{value:1,name:"CODE"},NUMBER:{value:2,name:"NUMBER"},OBJECT:{value:3,name:"OBJECT"},BOOL:{value:5,name:"BOOL"},CONST:{value:6,name:"CONST"},CATEGORY:{value:7,name:"CATEGORY"},DATETIME:{value:8,name:"DATETIME"},EMPTY:{value:101,name:"NULL"}},DataTypeConverter.SUBTYPES={PERCENTAGE:{value:1e3,name:"PERCENTAGE"},LATITUDE:{value:1001,name:"LATITUDE"},LONGITUDE:{value:1002,name:"LONGITUDE"}},DataTypeConverter.prototype=function(){var _analyseDataTypes=function(fields){ArrayUtils.IteratorOverKeys(fields,function(field){if(field._inferredTypes[DataTypeConverter.TYPES.CODE.name]){var confidence=field._inferredTypes[DataTypeConverter.TYPES.CODE.name]/field.numOfItems,_numericalInferredType=field._inferredTypes[DataTypeConverter.TYPES.NUMBER.name];return"undefined"!=typeof _numericalInferredType&&(confidence+=_numericalInferredType/field.numOfItems),field.type=DataTypeConverter.TYPES.CODE.name,void(field.typeConfidence=confidence)}var max=ArrayUtils.FindMinMax(field._inferredTypes,function(curval,lastval){return curval>lastval}),tkey=max.first.key;tkey===DataTypeConverter.TYPES.EMPTY.name&&null!=max.second&&"undefined"!=typeof max.second&&(tkey=max.second.key),field.type=tkey,field.typeConfidence=field._inferredTypes[max.first.key]/field.numOfItems})},_processInferType=function(value){if(null===value||"undefined"==typeof value)return DataTypeConverter.TYPES.EMPTY;if("object"==typeof value)return DataTypeConverter.TYPES.OBJECT;if(/^0[0-9]+$/.test(value))return DataTypeConverter.TYPES.CODE;var isnumber=DataTypesUtils.FilterFloat(value);if(isNaN(isnumber)!==!0)return DataTypeConverter.TYPES.NUMBER;var _date=DataTypesUtils.FilterDateTime(value);return 0==isNaN(_date)&&null!=_date?DataTypeConverter.TYPES.DATETIME:DataTypeConverter.TYPES.TEXT},jsonTraverse=function(json,fieldKeys,callback){var stack=[],numOfRows=0;for(stack.push({item:json,fieldKeyIndex:0});stack.length>0;){var stackTask=stack.pop(),item=stackTask.item,fieldKeyIndex=stackTask.fieldKeyIndex,fieldKey=fieldKeys[fieldKeyIndex];if("*"!=fieldKey||0!=ArrayUtils.isArray(item))if("*"!=fieldKey||1!=ArrayUtils.isArray(item)){var jsonSubtree=item[fieldKey];if(Array.isArray(jsonSubtree))for(var j=0;j<jsonSubtree.length;j++){var jsonItem=jsonSubtree[j];stack.push({item:jsonItem,fieldKeyIndex:fieldKeyIndex+1})}else stack.push({item:jsonSubtree,fieldKeyIndex:fieldKeyIndex+1})}else for(var cell,j=0;j<item.length&&(cell=item[j]);j++)stack.push({item:cell,fieldKeyIndex:fieldKeyIndex}),numOfRows++;else{var sProcessedKeys=fieldKeys.slice(0,fieldKeyIndex).toString();ArrayUtils.IteratorOverKeys(item,function(value,key){var curKey=sProcessedKeys+(sProcessedKeys.length>0?",":"")+key,_value=callback(value,key,curKey,numOfRows);item[key]=_value}),numOfRows++}}};return{constructor:DataTypeConverter,cast:function(metadata,options){return"undefined"!=typeof options&&null!=options||(options={castThresholdConfidence:1,castIfNull:!1}),this.convert(metadata,options)},convert:function(metadata,options){var lastRowIndex=0,numOfRows=0,numOfValues=0,datasetErrors=0,datasetMissingValues=0;return"undefined"!=typeof options&&null!=options||(options={castThresholdConfidence:1,castIfNull:!1}),jsonTraverse(metadata.dataset,metadata.fieldKeys,function(value,key,traversedKeys,rowIndex){var inferredType=metadata.types[traversedKeys];numOfValues++,lastRowIndex!=rowIndex&&(lastRowIndex=rowIndex,numOfRows++),null==value||"undefined"==typeof value||0==(value+"").length;var isCast=inferredType.typeConfidence>=options.castThresholdConfidence;if(inferredType.type==DataTypeConverter.TYPES.NUMBER.name&&isCast){var number=parseFloat(value);return isNaN(number)?(datasetErrors++,value):number}return value}),metadata.qualityIndex.notNullValues=(numOfValues-datasetMissingValues)/numOfValues,metadata.qualityIndex.errors=(numOfValues-datasetErrors)/numOfValues,metadata},inferJsonDataType:function(json,fieldKeys){var stack=[],fieldsType={},numOfRows=0;if("undefined"==typeof fieldKeys)throw"IllegalArgumentException: undefined json path to analyse.";for(stack.push({item:json,fieldKeyIndex:0});stack.length>0;){var stackTask=stack.pop(),item=stackTask.item,fieldKeyIndex=stackTask.fieldKeyIndex,fieldKey=fieldKeys[fieldKeyIndex];if("*"!=fieldKey||0!=ArrayUtils.isArray(item))if("*"==fieldKey&&ArrayUtils.isArray(item))for(var cell,j=0;j<item.length&&(cell=item[j]);j++)stack.push({item:cell,fieldKeyIndex:fieldKeyIndex}),numOfRows++;else{var jsonSubtree=item[fieldKey];if(Array.isArray(jsonSubtree))for(var j=0;j<jsonSubtree.length;j++){var jsonItem=jsonSubtree[j];stack.push({item:jsonItem,fieldKeyIndex:fieldKeyIndex+1})}else stack.push({item:jsonSubtree,fieldKeyIndex:fieldKeyIndex+1})}else{var sProcessedKeys=fieldKeys.slice(0,fieldKeyIndex).toString();ArrayUtils.IteratorOverKeys(item,function(item,key){var inferredType=_processInferType(item),curKey=sProcessedKeys+(0==sProcessedKeys.length?"":",")+key,fieldType=ArrayUtils.TestAndInitializeKey(fieldsType,curKey,{name:curKey,_inferredTypes:[],_inferredValues:[],numOfItems:0});fieldType.numOfItems++,ArrayUtils.TestAndIncrement(fieldType._inferredTypes,inferredType.name),inferredType===DataTypeConverter.TYPES.TEXT&&ArrayUtils.TestAndIncrement(fieldType._inferredValues,item)}),numOfRows++}}_analyseDataTypes(fieldsType);var quality={homogeneity:1,completeness:1,totalNullValues:0,totalValues:0};ArrayUtils.IteratorOverKeys(fieldsType,function(fieldType){quality.totalValues+=fieldType.numOfItems,quality.homogeneity*=fieldType.typeConfidence,fieldType.totalNullValues=0,fieldType._inferredTypes.hasOwnProperty(DataTypeConverter.TYPES.EMPTY.name)&&(fieldType.totalNullValues=fieldType._inferredTypes[DataTypeConverter.TYPES.EMPTY.name],quality.totalNullValues+=fieldType.totalNullValues)}),quality.homogeneity=Math.round(100*quality.homogeneity)/100;var totFullValues=quality.totalValues-quality.totalNullValues;quality.completeness=Math.round(totFullValues/quality.totalValues*100)/100;var warningsTextual="";return ArrayUtils.IteratorOverKeys(fieldsType,function(fieldType){fieldType.errorsDescription="";var description="";if(fieldType.typeConfidence<1){var incorrect=fieldType.numOfItems-fieldType.totalNullValues-fieldType._inferredTypes[fieldType.type];if(incorrect>0){description+="The column <"+fieldType.name+"> has the type <"+fieldType.type+">";var verb=1==incorrect?" value is":" values are";description+=", but "+incorrect+verb+" not a "+fieldType.type}}fieldType.totalNullValues>0&&(description+="The column <"+fieldType.name+"> has "+fieldType.totalNullValues+" EMPTY value",fieldType.totalNullValues>1&&(description+="s")),description.length>0&&(description+="."),fieldType.errorsDescription=description,warningsTextual+=description}),{dataset:json,fieldKeys:fieldKeys,types:fieldsType,qualityIndex:quality,warningsTextual:warningsTextual}},inferDataTypeOfValue:function(value){return _processInferType(value)}}}(),DataTypesUtils.FilterTime=function(value){var expTime=/^[0-9]{2}:[0-9]{2}(:[0-9]{2})?(\+[0-9]{2}:[0-9]{2})?$/;if(0==expTime.test(value))return null;var splitted=value.split(/[:|\+]/),expNumber=/^[0-9]{2}$/,HH=expNumber.test(splitted[0])?parseInt(splitted[0]):0,MM=expNumber.test(splitted[1])?parseInt(splitted[1]):0,SS=splitted.length>=3&&expNumber.test(splitted[2])?parseInt(splitted[2]):0,dt=new Date;return dt.setHours(HH),dt.setMinutes(MM),dt.setSeconds(SS),dt},DataTypesUtils.FilterDateTime=function(value){var _dtSplitted=value.split(/[T|\s]/);if(2==_dtSplitted.length){var dtTime=DataTypesUtils.FilterTime(_dtSplitted[1]);if(null==dtTime)return null;var dtDateTime=DataTypesUtils.FilterDate(_dtSplitted[0],dtTime);return dtDateTime}var dtDate=DataTypesUtils.FilterDate(value);if(null!=dtDate)return dtDate;var dtTime=DataTypesUtils.FilterTime(value);return dtTime},DataTypesUtils.FilterDate=function(value,dtDate){if(null==dtDate&&(dtDate=new Date),/^[0-9][0-9][0-9][0-9]\-[0-9][0-9]$/.test(value)){var year=parseInt(value.substring(0,4)),month=parseInt(value.substring(5));return dtDate.setYear(year),dtDate.setMonth(month),dtDate}var expDate=/^[0-9]{4}(\-|\/)[0-9]{2}((\-|\/)[0-9]{2})?$/;if(expDate.test(value)){var splitted=value.split(/[\-|\/]/),year=parseInt(splitted[0]),month=parseInt(splitted[1]),day=3==splitted.length?parseInt(splitted[2]):0;return dtDate.setYear(year),dtDate.setMonth(month),dtDate.setDate(day),dtDate}if(expDate=/^[0-9]{2}(\-|\/)[0-9]{2}(\-|\/)[0-9]{4}$/,expDate.test(value)){var splitted=value.split(/[\-|\/]/),year=parseInt(splitted[2]),month=parseInt(splitted[1]),day=parseInt(splitted[0]);return dtDate.setYear(year),dtDate.setMonth(month),dtDate.setDate(day),dtDate}return null},DataTypesUtils.FilterFloat=function(value){return/^(\-|\+)?((0|([1-9][0-9]*))(\.[0-9]+)?|Infinity)$/.test(value)?Number(value):NaN},DataTypesUtils.DecimalPlaces=function(num){var match=(""+num).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return match?Math.max(0,(match[1]?match[1].length:0)-(match[2]?+match[2]:0)):0},DataTypeHierarchy.HIERARCHY=[],DataTypeHierarchy.HIERARCHY[DataTypeConverter.TYPES.TEXT.name]=[DataTypeConverter.TYPES.TEXT.name],DataTypeHierarchy.HIERARCHY[DataTypeConverter.TYPES.NUMBER.name]=[DataTypeConverter.TYPES.NUMBER.name,DataTypeConverter.TYPES.TEXT.name],DataTypeHierarchy.HIERARCHY[DataTypeConverter.TYPES.DATETIME.name]=[DataTypeConverter.TYPES.DATETIME.name,DataTypeConverter.TYPES.TEXT.name],DataTypeHierarchy.HIERARCHY[DataTypeConverter.SUBTYPES.LATITUDE.name]=[DataTypeConverter.SUBTYPES.LATITUDE.name,DataTypeConverter.TYPES.NUMBER.name,DataTypeConverter.TYPES.TEXT.name],DataTypeHierarchy.HIERARCHY[DataTypeConverter.SUBTYPES.LONGITUDE.name]=[DataTypeConverter.SUBTYPES.LONGITUDE.name,DataTypeConverter.TYPES.NUMBER.name,DataTypeConverter.TYPES.TEXT.name],DataTypeHierarchy.canConvert=function(fromType,toType){var arrConvertableTypes=DataTypeHierarchy.HIERARCHY[fromType],idx=arrConvertableTypes.indexOf(toType);return idx>=0};
3 3 \ No newline at end of file
... ...
bower_components/JSDataChecker/src/DataTypeConverter.js
... ... @@ -38,8 +38,6 @@ DataTypeConverter.TYPES = {
38 38  
39 39 DATETIME : { value: 8, name: "DATETIME" },
40 40  
41   -
42   -
43 41 EMPTY : { value: 101, name: "NULL" }
44 42 };
45 43  
... ... @@ -138,14 +136,14 @@ DataTypeConverter.prototype = (function () {
138 136 field.typeConfidence = field._inferredTypes[max.first.key] / field.numOfItems;
139 137  
140 138  
141   - /*//TODO: improve this piece of code.
  139 + //TODO: improve this piece of code.
142 140 //LAT/LNG.
143   - var fieldName = field.name.toLowerCase();
  141 + /*var fieldName = field.name.toLowerCase();
144 142 var isLatType = (field.type === DataTypeConverter.TYPES.LATITUDE.name);
145 143 var fieldNameContainsLat = fieldName.indexOf('lat') >= 0;
146 144 var fieldNameContainsLon = fieldName.indexOf('ng') >= 0; //It could be 'lng'.
147 145 if (isLatType == true && fieldNameContainsLat == false && fieldNameContainsLon == true) {
148   - field.type = DataTypeConverter.TYPES.LONGITUDE.name;
  146 + field.type = DataTypeConverter.TYPES.LONGITUDE.name;
149 147 }*/
150 148  
151 149 //BOOLEAN.
... ...
bower_components/JSDataChecker/src/DataTypeHierarchy.js 0 โ†’ 100644
  1 +/*
  2 + ** This file is part of JSDataChecker.
  3 + **
  4 + ** JSDataChecker is free software: you can redistribute it and/or modify
  5 + ** it under the terms of the GNU General Public License as published by
  6 + ** the Free Software Foundation, either version 3 of the License, or
  7 + ** (at your option) any later version.
  8 + **
  9 + ** JSDataChecker is distributed in the hope that it will be useful,
  10 + ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  11 + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12 + ** GNU General Public License for more details.
  13 + **
  14 + ** You should have received a copy of the GNU General Public License
  15 + ** along with JSDataChecker. If not, see <http://www.gnu.org/licenses/>.
  16 + **
  17 + ** Copyright (C) 2016 JSDataChecker - Donato Pirozzi (donatopirozzi@gmail.com)
  18 + ** Distributed under the GNU GPL v3. For full terms see the file LICENSE.
  19 + ** License: http://www.gnu.org/licenses/gpl.html GPL version 3 or higher
  20 + **/
  21 +
  22 +function DataTypeHierarchy() {
  23 +
  24 +};//EndConstructor.
  25 +
  26 +DataTypeHierarchy.HIERARCHY = [ ];
  27 +
  28 +DataTypeHierarchy.HIERARCHY[DataTypeConverter.TYPES.TEXT.name] = [ DataTypeConverter.TYPES.TEXT.name ];
  29 +DataTypeHierarchy.HIERARCHY[DataTypeConverter.TYPES.NUMBER.name] = [ DataTypeConverter.TYPES.NUMBER.name, DataTypeConverter.TYPES.TEXT.name];
  30 +DataTypeHierarchy.HIERARCHY[DataTypeConverter.TYPES.DATETIME.name] = [ DataTypeConverter.TYPES.DATETIME.name, DataTypeConverter.TYPES.TEXT.name ];
  31 +
  32 +DataTypeHierarchy.HIERARCHY[DataTypeConverter.SUBTYPES.LATITUDE.name] = [ DataTypeConverter.SUBTYPES.LATITUDE.name,
  33 + DataTypeConverter.TYPES.NUMBER.name, DataTypeConverter.TYPES.TEXT.name];
  34 +DataTypeHierarchy.HIERARCHY[DataTypeConverter.SUBTYPES.LONGITUDE.name] = [ DataTypeConverter.SUBTYPES.LONGITUDE.name,
  35 + DataTypeConverter.TYPES.NUMBER.name, DataTypeConverter.TYPES.TEXT.name];
  36 +
  37 +DataTypeHierarchy.canConvert = function (fromType, toType) {
  38 + var arrConvertableTypes = DataTypeHierarchy.HIERARCHY[fromType];
  39 + var idx = arrConvertableTypes.indexOf(toType);
  40 + return (idx >= 0);
  41 +};//EndFunction.
... ...
controllets/data-table-controllet/data-table-controllet.html
... ... @@ -216,6 +216,9 @@
216 216 <paper-tooltip for="{{_fieldId(index)}}" offset="8">
217 217 <p>
218 218 <span class="type">{{_type()}}:</span> {{item.type}}
  219 + <!--<template is="dom-if" if={{item.errorsDescription}}>-->
  220 + <!--({{item.subType}})-->
  221 + <!--</template>-->
219 222 <template is="dom-if" if={{item.errorsDescription.length}}>
220 223 <br/>
221 224 <span class="warning">{{_warning()}}:</span> {{item.errorsDescription}}
... ... @@ -301,6 +304,7 @@
301 304 var result = converter.inferJsonDataType(data, ["*"]);
302 305 result = converter.cast(result);
303 306 this.fields = ArrayUtils.toFieldsArray(result.types);
  307 +// console.log(this.fields);
304 308 this.data = result.dataset;
305 309  
306 310 this.filter = "";
... ...
controllets/providers-utility-controllet/providers-utility-controllet.html
... ... @@ -16,6 +16,8 @@
16 16 }
17 17 };
18 18  
  19 + //utility non legato al provider, aggiungere copy e creare un altro js!!!
  20 +
19 21 //jsdatachecker
20 22 utility_getFields = function(types) {
21 23 return Object.keys(types).map(function(key) { return key; });
... ... @@ -36,26 +38,7 @@
36 38 return selectedIndices;
37 39 };
38 40  
39   - // utility_getResourceUrl = function(url) {
40   - // //CKAN
41   - // var strDatasetPos = url.indexOf('/dataset/');
42   - // var strResourcePos = url.indexOf('/resource/');
43   - // if (strDatasetPos >= 0 && strResourcePos > strDatasetPos) {
44   - // var urlSegment1 = url.substring(0, strDatasetPos);
45   - // var urlResourceEnd = url.indexOf('/', strResourcePos + 10);
46   - // var resourceId = url.substring(strResourcePos + 10, urlResourceEnd);
47   - // return urlSegment1 + "/api/action/datastore_search?resource_id=" + resourceId;
48   - // }
49   - // //OPENDATASOFT
50   - // var strExploreDatasetPos = url.indexOf('/explore/dataset/');
51   - // if (strExploreDatasetPos >= 0) {
52   - // var urlSegment1 = url.substring(0, strExploreDatasetPos);
53   - // var datasetEnd = url.indexOf(strExploreDatasetPos + 17, '/');
54   - // var datasetId = url.substring(strExploreDatasetPos + 17, datasetEnd >= 0 ? datasetEnd : url.length);
55   - // return urlSegment1 + '/api/records/1.0/search?dataset=' + datasetId;
56   - // }
57   - // return "";
58   - // };
  41 +
59 42 </script>
60 43  
61 44 <dom-module id="providers-utility-controllet">
... ...
controllets/select-data-controllet/select-data-controllet.html
... ... @@ -130,7 +130,15 @@
130 130 },
131 131  
132 132 getData : function() {
133   - return this.data;
  133 + //return datatable.getData
  134 + //this.fields = "*"
  135 + var data = alasql_selectData(this.data, this.fields, this.filters);
  136 + var converter = new DataTypeConverter();
  137 + var result = converter.inferJsonDataType(data, ["*"]);
  138 + result = converter.cast(result);
  139 + data = result.dataset;
  140 +
  141 + return data;
134 142 },
135 143  
136 144 setSelectedFields : function(selectedFields) {
... ...
controllets/select-dataset-controllet/select-dataset-controllet.html
... ... @@ -485,11 +485,11 @@
485 485 // this.datasets = that.datasets["result"]["datasets"];
486 486  
487 487 $.ajax({
488   - url: "/cocreation/ajax/get-all-dataset",
  488 + url: "http://172.16.15.77/cocreation/ajax/get-all-dataset",
489 489 dataType: "json",
490 490 success: function(spodDatasets){
491 491  
492   - that.providers = $.extend(that.datasets["result"]["providers"], {99: {api_url: "/cocreation/ajax/get-all-dataset", id: "99", image_hash: "SPOD", title: "SPOD"}});
  492 + that.providers = $.extend(that.datasets["result"]["providers"], {99: {api_url: "http://172.16.15.77/cocreation/ajax/get-all-dataset", id: "99", image_hash: "SPOD", title: "SPOD"}});
493 493 that.datasets = $.merge(spodDatasets, that.datasets["result"]["datasets"]);
494 494  
495 495 if(that.suggestedDatasets) {
... ...
controllets/select-visualization-controllet/demo/index.html
... ... @@ -9,6 +9,10 @@
9 9 <link rel="stylesheet" href="../../shared_js/perfect-scrollbar/css/perfect-scrollbar.min.css">
10 10  
11 11 <script src="../../../locales/controllet_ln.js"></script>
  12 +
  13 + <script type="text/javascript" src="../../../alasql-utility/alasql.min.js"></script>
  14 + <script type="text/javascript" src="../../../alasql-utility/alasql-utility.js"></script>
  15 +
12 16 <script>
13 17 ln["localization"] = "en";
14 18 </script>
... ...
controllets/select-visualization-controllet/select-datalet-inputs.html
... ... @@ -303,9 +303,21 @@
303 303 // temp.push({name: name + " " + (i-4), description: description, selection: selection});
304 304 // }
305 305  
  306 + else if (inputs.length == 2 && inputs[1].selection == "*") {//
  307 + name = inputs[1].name;
  308 + description = inputs[1].description;
  309 + selection = inputs[1].selection;
  310 + temp = [inputs[0]];
  311 + temp.push({name: name + " 1", description: description, selection: selection});
  312 + for (var i = 3; i < this.fields.length; i++)
  313 + temp.push({name: name + " " +(i-1), description: description, selection: selection});
  314 + }
  315 +
306 316 this.inputs = this._copy(temp);
307 317  
308 318 this.selectedFields = new Array(temp.length);
  319 +
  320 + this.selectedFields2 = new Array(temp.length);
309 321 },
310 322  
311 323 fireReady : function() {
... ... @@ -381,15 +393,23 @@
381 393 this.expert = !this.expert;
382 394 },
383 395  
  396 + getFields : function () {
  397 + return this.selectedFields2;
  398 + },
  399 +
384 400 _addInput : function(e){
385 401 var selectedFields = this._copy(this.selectedFields);
386 402  
387 403 var ddl_index = $(e.target).parents("paper-dropdown-menu")[0].id;
  404 +
388 405 var index = e.target.id;
389 406 selectedFields[ddl_index] = this.fields[index];
390 407  
391 408 this.selectedFields = this._copy(selectedFields);
392 409  
  410 +// console.log(this.inputs[ddl_index].name);
  411 + this.selectedFields2[ddl_index] = {field: this.fields[index], input: this.inputs[ddl_index].name};
  412 +
393 413 if(!this._isReady()) {
394 414 this.$.group_by.setAttribute("disabled", "");
395 415  
... ... @@ -518,6 +538,9 @@
518 538 // if(key.indexOf("BubbleContent") > -1) {
519 539 // return ln["BubbleContent" + "_" +ln["localization"]] + key.slice(-2);
520 540 // }
  541 + if(key.indexOf("NumericYAxis") > -1) {
  542 + return ln["NumericYAxis" + "_" +ln["localization"]] + key.slice(-2);
  543 + }
521 544  
522 545 return ln[key + "_" +ln["localization"]];
523 546 },
... ...
controllets/select-visualization-controllet/select-datalet-inputs_series.html
... ... @@ -302,6 +302,10 @@
302 302 }
303 303 },
304 304  
  305 + getFields : function () {
  306 + return null;
  307 + },
  308 +
305 309 setInputs : function(inputs) {
306 310 this.inputs = this._copy(inputs);
307 311 },
... ...
controllets/select-visualization-controllet/select-datalet-options.html
... ... @@ -137,11 +137,11 @@
137 137  
138 138 <template is="dom-repeat" items={{options}} index-as="index">
139 139 <div class="inputs">
140   - <template is="dom-if" if="{{_checkType(item.type, 'text')}}">
  140 + <template is="dom-if" if="{{_checkType(item.type, 'TEXT')}}">
141 141 <paper-input label={{_getLabelName(item.name)}} on-change="_updateParams"></paper-input>
142 142 </template>
143 143  
144   - <template is="dom-if" if="{{_checkType(item.type, 'list')}}">
  144 + <template is="dom-if" if="{{_checkType(item.type, 'LIST')}}">
145 145 <paper-dropdown-menu label={{_getLabelName(item.name)}}>
146 146 <paper-menu class="dropdown-content" selected = 0>
147 147 <!--<paper-item on-tap="_updateParams"></paper-item>-->
... ...
controllets/select-visualization-controllet/select-visualization-controllet.html
... ... @@ -342,9 +342,13 @@
342 342  
343 343 this.selectedFields = inputs.getSelectedFields();
344 344  
  345 +// console.log(inputs.getFields());
  346 +
345 347 this.params = {'data-url' : this.dataUrl};//??????????????????
346 348 // this.params = {};
347 349  
  350 + this.params["selectedFields"] = JSON.stringify(inputs.getFields());
  351 +
348 352 this.params["filters"] = JSON.stringify(this.filters);
349 353 this.params["aggregators"] = JSON.stringify(inputs.getAggregators());
350 354 this.params["orders"] = JSON.stringify(inputs.getOrders());
... ... @@ -356,7 +360,9 @@
356 360  
357 361 var data = alasql_complexSelectData(this.data, this.selectedFields, this.filters, inputs.getAggregators(), inputs.getOrders());
358 362 data = transformData(data, this.selectedFields, true);
359   - this.params["data"] = JSON.stringify(data).replace(/'/g, "&#39;");
  363 +
  364 + //use cache
  365 +// this.params["data"] = JSON.stringify(data).replace(/'/g, "&#39;");
360 366  
361 367 var dataletParams ={
362 368 component: this.selectedDatalet+"-datalet",
... ...
datalets/base-ajax-json-alasql-datalet/static/js/AjaxJsonAlasqlBehavior.js
... ... @@ -85,11 +85,13 @@ var AjaxJsonAlasqlBehavior = {
85 85 selectData : function() {
86 86 var fields = this._component.fields = JSON.parse(this._component.fields);
87 87  
  88 + //var selectedFields = JSON.parse(this._component.getAttribute("selectedFields"));
  89 +
88 90 var filters = JSON.parse(this._component.getAttribute("filters"));
89 91 var aggregators = JSON.parse(this._component.getAttribute("aggregators"));
90 92 var orders = JSON.parse(this._component.getAttribute("orders"));
91 93  
92   - //preview my space
  94 + //preview my space ?
93 95 if(filters && filters[0] && filters[0].constructor == Array){
94 96 filters = filters[0];
95 97 aggregators = aggregators[0];
... ... @@ -100,12 +102,28 @@ var AjaxJsonAlasqlBehavior = {
100 102 var provider = f.getProvider(this._component.dataUrl);
101 103 var data = provider.selectData(this.properties.json_results.value);
102 104  
  105 + //if(selectedFields) {
  106 + // fields = [];
  107 + // var inputs = [];
  108 + // for (var i=0; i < selectedFields.length; i++) {
  109 + // if (selectedFields[i]) {
  110 + // fields.push(selectedFields[i].field);
  111 + // inputs.push(selectedFields[i].input);
  112 + // }
  113 + // }
  114 + //}
  115 +
103 116 var converter = new DataTypeConverter();
104 117 var result = converter.inferJsonDataType(data, ["*"]);
105 118 result = converter.cast(result);
106 119 data = result.dataset;
107 120  
108   - //data = alasql_selectData(data, fields, filters);
  121 + data = alasql_selectData(data, fields, filters);//funziona senza?
  122 +
  123 + result = converter.inferJsonDataType(data, ["*"]);
  124 + result = converter.cast(result);
  125 + data = result.dataset;
  126 +
109 127 data = alasql_complexSelectData(data, fields, filters, aggregators, orders);
110 128  
111 129 this.data = transformData(data, fields, true);
... ...
datalets/highcharts-datalet/highcharts-datalet.html
... ... @@ -140,15 +140,20 @@ Example :
140 140 // },
141 141  
142 142 transformData: function () {
  143 + var selectedFields = JSON.parse(this._component.getAttribute("selectedFields"));
  144 +
143 145 if(this.data.length == 0)
144 146 return;
145 147  
146   - if(this.data.length == 2){
147   - this.properties.categories.value = this.data[0].data;
148   - this.properties.series.value = [this.data[1]];
149   - }
  148 + categories = this.data[0].data;
  149 + series = [];
  150 + for(var i = 1; i < this.data.length; i++)
  151 + series.push(this.data[i]);
  152 +
  153 + this.properties.categories.value = categories;
  154 + this.properties.series.value = series;
150 155  
151   - if(this.data.length == 3){//multi series
  156 + if(this.data.length == 3 && !selectedFields){//split cat
152 157 var x = this.data[0]["data"];
153 158 var gb = this.data[1]["data"];
154 159 var y = this.data[2]["data"];
... ... @@ -166,19 +171,21 @@ Example :
166 171 series.push({name: s[i], data: new Array(categories.length+1).join('0').split('').map(parseFloat)});
167 172 }
168 173  
169   - for (var i = 0; i < y.length; i++){
  174 + for(var i = 0; i < y.length; i++){
170 175 var index = categories.indexOf(x[i]);
171 176 var s = series.filter(function( obj ) {
172 177 return obj.name == gb[i];
173 178 });
174   - s[0]["data"][index] = y[i];
  179 + s[0]["data"][index] = y[i];
175 180 }
176 181  
177 182 this.properties.categories.value = categories;
178 183 this.properties.series.value = series;
179 184 }
  185 +
180 186 },
181 187  
  188 +
182 189 // setParameters: function(params)
183 190 // {
184 191 // this._component.title = params['title'];
... ...