diff --git a/bower_components/JSDataChecker/.bower.json b/bower_components/JSDataChecker/.bower.json index 2a83267..535202d 100644 --- a/bower_components/JSDataChecker/.bower.json +++ b/bower_components/JSDataChecker/.bower.json @@ -1,6 +1,6 @@ { "name": "JSDataChecker", - "version": "0.0.7", + "version": "0.0.8", "homepage": "https://github.com/donpir/JSDataChecker", "authors": [ "'Donato Pirozzi <'donatopirozzi@gmail.com'>" @@ -22,11 +22,11 @@ "polywc": "https://github.com/donpir/polywc.git#master" }, "private": false, - "_release": "0.0.7", + "_release": "0.0.8", "_resolution": { "type": "version", - "tag": "v0.0.7", - "commit": "f6d2d47543510eeefc2e0a9bda86dec09ac4b092" + "tag": "v0.0.8", + "commit": "862e4d5fe56d629ae7ef8aadb728b1add3af01d9" }, "_source": "https://github.com/donpir/JSDataChecker.git", "_target": "~0.0.6", diff --git a/bower_components/JSDataChecker/bower.json b/bower_components/JSDataChecker/bower.json index 049673a..ccc6ddd 100644 --- a/bower_components/JSDataChecker/bower.json +++ b/bower_components/JSDataChecker/bower.json @@ -1,6 +1,6 @@ { "name": "JSDataChecker", - "version": "v0.0.7", + "version": "v0.0.8", "homepage": "https://github.com/donpir/JSDataChecker", "authors": [ "'Donato Pirozzi <'donatopirozzi@gmail.com'>" diff --git a/bower_components/JSDataChecker/build.cmd b/bower_components/JSDataChecker/build.cmd index adabe1a..96692db 100644 --- a/bower_components/JSDataChecker/build.cmd +++ b/bower_components/JSDataChecker/build.cmd @@ -1,2 +1,2 @@ del jsdatachecker.min.js -uglifyjs src\ArrayUtils.js src\DataTypeConverter.js src\DataTypesUtils.js --compress -o jsdatachecker.min.js \ No newline at end of file +uglifyjs src\ArrayUtils.js src\DataTypeConverter.js src\DataTypesUtils.js src\DataTypeHierarchy.js --compress -o jsdatachecker.min.js \ No newline at end of file diff --git a/bower_components/JSDataChecker/jsdatachecker.min.js b/bower_components/JSDataChecker/jsdatachecker.min.js index b76a9ec..2618cbe 100644 --- a/bower_components/JSDataChecker/jsdatachecker.min.js +++ b/bower_components/JSDataChecker/jsdatachecker.min.js @@ -1 +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}; \ No newline at end of file +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}; \ No newline at end of file diff --git a/bower_components/JSDataChecker/src/DataTypeConverter.js b/bower_components/JSDataChecker/src/DataTypeConverter.js index 408b395..cc424bc 100644 --- a/bower_components/JSDataChecker/src/DataTypeConverter.js +++ b/bower_components/JSDataChecker/src/DataTypeConverter.js @@ -38,8 +38,6 @@ DataTypeConverter.TYPES = { DATETIME : { value: 8, name: "DATETIME" }, - - EMPTY : { value: 101, name: "NULL" } }; @@ -138,14 +136,14 @@ DataTypeConverter.prototype = (function () { field.typeConfidence = field._inferredTypes[max.first.key] / field.numOfItems; - /*//TODO: improve this piece of code. + //TODO: improve this piece of code. //LAT/LNG. - var fieldName = field.name.toLowerCase(); + /*var fieldName = field.name.toLowerCase(); var isLatType = (field.type === DataTypeConverter.TYPES.LATITUDE.name); var fieldNameContainsLat = fieldName.indexOf('lat') >= 0; var fieldNameContainsLon = fieldName.indexOf('ng') >= 0; //It could be 'lng'. if (isLatType == true && fieldNameContainsLat == false && fieldNameContainsLon == true) { - field.type = DataTypeConverter.TYPES.LONGITUDE.name; + field.type = DataTypeConverter.TYPES.LONGITUDE.name; }*/ //BOOLEAN. diff --git a/bower_components/JSDataChecker/src/DataTypeHierarchy.js b/bower_components/JSDataChecker/src/DataTypeHierarchy.js new file mode 100644 index 0000000..d65eff4 --- /dev/null +++ b/bower_components/JSDataChecker/src/DataTypeHierarchy.js @@ -0,0 +1,41 @@ +/* + ** This file is part of JSDataChecker. + ** + ** JSDataChecker is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** JSDataChecker is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with JSDataChecker. If not, see <http://www.gnu.org/licenses/>. + ** + ** Copyright (C) 2016 JSDataChecker - Donato Pirozzi (donatopirozzi@gmail.com) + ** Distributed under the GNU GPL v3. For full terms see the file LICENSE. + ** License: http://www.gnu.org/licenses/gpl.html GPL version 3 or higher + **/ + +function DataTypeHierarchy() { + +};//EndConstructor. + +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]; + var idx = arrConvertableTypes.indexOf(toType); + return (idx >= 0); +};//EndFunction. diff --git a/controllets/data-sevc-controllet/demo/index.html b/controllets/data-sevc-controllet/demo/index.html index 7a3623b..ac38ffb 100755 --- a/controllets/data-sevc-controllet/demo/index.html +++ b/controllets/data-sevc-controllet/demo/index.html @@ -15,15 +15,16 @@ <body> - <!--<data-sevc-controllet deep-url="http://172.16.15.38/DEEalerProvider/DEEP/"--> - <!--datalets-list-url="http://172.16.15.38/DEEalerProvider/DEEP/datalets-list"--> + <data-sevc-controllet deep-url="http://172.16.15.38/DEEalerProvider/DEEP/" + datalets-list-url="http://172.16.15.38/DEEalerProvider/DEEP/datalets-list" + datasets='{"result":{"providers":{"1":{"title":"CKAN","api_url":"http:\/\/ckan.routetopa.eu","image_hash":"11","id":"1"}},"datasets":[{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 2","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b056c5e6-76af-4526-a35d-7dee664fb6ee\/download\/isislab.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"ROUTE-TO-PA","package_name":"Year 1 Dissemination of the ROUTE-TO-PA project (2015)","resource_name":"First year (2015) ROUTE-TO-PA Dissemination","url":"http:\/\/ckan.routetopa.eu\/dataset\/d81d451d-8b3d-47f4-b57f-e295e8f51da0\/resource\/818c2edb-0cb7-4288-b340-e4dd1933d817\/download\/ROUTE-TO-PA-Individual-Dissemination-Activity-Report-Form-Responses-New---Link-Upd.csv","metas":"{\"organization\":\"ROUTE-TO-PA\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"ROUTE-TO-PA","package_name":"Year 1 Dissemination of the ROUTE-TO-PA project (2015)","resource_name":"First year (2015) ROUTE-TO-PA Dissemination - dl","url":"http:\/\/ckan.routetopa.eu\/dataset\/d81d451d-8b3d-47f4-b57f-e295e8f51da0\/resource\/fd8c4d6f-315d-4aa0-b7bd-4fdde7bf641b\/download\/ROUTE-TO-PA-Individual-Dissemination-Activity-Report-Form-Responses-New---Link-Upd.csv","metas":"{\"organization\":\"ROUTE-TO-PA\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"ROUTE-TO-PA","package_name":"Year 1 Dissemination of the ROUTE-TO-PA project (2015)","resource_name":"First year (2015) dissemination of ROUTE-TO-PA project","url":"http:\/\/ckan.routetopa.eu\/dataset\/d81d451d-8b3d-47f4-b57f-e295e8f51da0\/resource\/b0ef6017-8c64-4e11-8046-7e51a8561856\/download\/ROUTE-TO-PA-Individual-Dissemination-Activity-Report-Form-Responses-New---Link-Upd.csv","metas":"{\"organization\":\"ROUTE-TO-PA\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"ROUTE-TO-PA","package_name":"test dissemination with link","resource_name":"Year 1 Dissemination of the ROUTE-TO-PA project (2015)","url":"http:\/\/ckan.routetopa.eu\/dataset\/ba5054af-7561-4f99-9504-76ea004a1e85\/resource\/4cc2349d-bf7b-4bbe-a7ca-db5312bb6c94\/download\/ROUTE-TO-PA-Individual-Dissemination-Activity-Report-Form-Responses-New---Link.csv","metas":"{\"organization\":\"ROUTE-TO-PA\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"ROUTE-TO-PA","package_name":"Dissemination activity of the first year","resource_name":"Dissemination activity of the first year (2015)","url":"http:\/\/ckan.routetopa.eu\/dataset\/61f07087-210a-4c35-9606-2aafe183633b\/resource\/5f9d8d8b-1c41-45f7-9dbb-61b9a7bcd076\/download\/ROUTE-TO-PA-Individual-Dissemination-Activity-Report-Form-Responses-New.csv","metas":"{\"organization\":\"ROUTE-TO-PA\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"City of the Hague Municipality","package_name":"Test 3- Buurten","resource_name":"Test Buurten - 3","url":"http:\/\/ckan.routetopa.eu\/dataset\/1248d447-2901-4beb-91ae-c2f249fd8a99\/resource\/1fdbc765-8945-4271-8dce-9c7eba45a67d\/download\/Test-3-Compare.csv","metas":"{\"organization\":\"City of the Hague Municipality\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"}]}}' <!--datasets='{"result":{"providers":{"1":{"title":"CKAN","api_url":"http:\/\/ckan.routetopa.eu","image_hash":"11","id":"1"}},"datasets":[{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 2","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b056c5e6-76af-4526-a35d-7dee664fb6ee\/download\/isislab.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"ROUTE-TO-PA","package_name":"Year 1 Dissemination of the ROUTE-TO-PA project (2015)","resource_name":"First year (2015) ROUTE-TO-PA Dissemination","url":"http:\/\/ckan.routetopa.eu\/dataset\/d81d451d-8b3d-47f4-b57f-e295e8f51da0\/resource\/818c2edb-0cb7-4288-b340-e4dd1933d817\/download\/ROUTE-TO-PA-Individual-Dissemination-Activity-Report-Form-Responses-New---Link-Upd.csv","metas":"{\"organization\":\"ROUTE-TO-PA\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"ROUTE-TO-PA","package_name":"Year 1 Dissemination of the ROUTE-TO-PA project (2015)","resource_name":"First year (2015) ROUTE-TO-PA Dissemination - dl","url":"http:\/\/ckan.routetopa.eu\/dataset\/d81d451d-8b3d-47f4-b57f-e295e8f51da0\/resource\/fd8c4d6f-315d-4aa0-b7bd-4fdde7bf641b\/download\/ROUTE-TO-PA-Individual-Dissemination-Activity-Report-Form-Responses-New---Link-Upd.csv","metas":"{\"organization\":\"ROUTE-TO-PA\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"ROUTE-TO-PA","package_name":"Year 1 Dissemination of the ROUTE-TO-PA project (2015)","resource_name":"First year (2015) dissemination of ROUTE-TO-PA project","url":"http:\/\/ckan.routetopa.eu\/dataset\/d81d451d-8b3d-47f4-b57f-e295e8f51da0\/resource\/b0ef6017-8c64-4e11-8046-7e51a8561856\/download\/ROUTE-TO-PA-Individual-Dissemination-Activity-Report-Form-Responses-New---Link-Upd.csv","metas":"{\"organization\":\"ROUTE-TO-PA\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"ROUTE-TO-PA","package_name":"test dissemination with link","resource_name":"Year 1 Dissemination of the ROUTE-TO-PA project (2015)","url":"http:\/\/ckan.routetopa.eu\/dataset\/ba5054af-7561-4f99-9504-76ea004a1e85\/resource\/4cc2349d-bf7b-4bbe-a7ca-db5312bb6c94\/download\/ROUTE-TO-PA-Individual-Dissemination-Activity-Report-Form-Responses-New---Link.csv","metas":"{\"organization\":\"ROUTE-TO-PA\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"ROUTE-TO-PA","package_name":"Dissemination activity of the first year","resource_name":"Dissemination activity of the first year (2015)","url":"http:\/\/ckan.routetopa.eu\/dataset\/61f07087-210a-4c35-9606-2aafe183633b\/resource\/5f9d8d8b-1c41-45f7-9dbb-61b9a7bcd076\/download\/ROUTE-TO-PA-Individual-Dissemination-Activity-Report-Form-Responses-New.csv","metas":"{\"organization\":\"ROUTE-TO-PA\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"City of the Hague Municipality","package_name":"Test 3- Buurten","resource_name":"Test Buurten - 3","url":"http:\/\/ckan.routetopa.eu\/dataset\/1248d447-2901-4beb-91ae-c2f249fd8a99\/resource\/1fdbc765-8945-4271-8dce-9c7eba45a67d\/download\/Test-3-Compare.csv","metas":"{\"organization\":\"City of the Hague Municipality\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"}]}}'--> <!--suggested-datasets='[{"resource_name":"SUGGESTED 1","url":"noUrl.csv","metas":"{\"description\":\"noDescriione\"}"},{"resource_name":"SUGGESTED 2","url":"noUrl.csv","metas":"{\"description\":\"noDescriione\"}"},{"resource_name":"SUGGESTED 3","url":"noUrl.csv","metas":"{\"description\":\"noDescriione\"}"}]'--> - <!--</data-sevc-controllet>--> + </data-sevc-controllet> - <co-datalets-creator-controllet data='[{"a":"0", "b":"1"},{"a":"2", "b":"3a"},{"a":"2", "b":"3"}]' deep-url="http://172.16.15.38/DEEalerProvider/DEEP/" - datalets-list-url="http://172.16.15.38/DEEalerProvider/DEEP/datalets-list"> - </co-datalets-creator-controllet> + <!--<co-datalets-creator-controllet data='[{"a":"0", "b":"1"},{"a":"2", "b":"3a"},{"a":"2", "b":"3"}]' deep-url="http://172.16.15.38/DEEalerProvider/DEEP/"--> + <!--datalets-list-url="http://172.16.15.38/DEEalerProvider/DEEP/datalets-list">--> + <!--</co-datalets-creator-controllet>--> </body> diff --git a/controllets/data-table-controllet/data-table-controllet.html b/controllets/data-table-controllet/data-table-controllet.html index 72bd73a..45fe31f 100644 --- a/controllets/data-table-controllet/data-table-controllet.html +++ b/controllets/data-table-controllet/data-table-controllet.html @@ -216,6 +216,9 @@ <paper-tooltip for="{{_fieldId(index)}}" offset="8"> <p> <span class="type">{{_type()}}:</span> {{item.type}} + <!--<template is="dom-if" if={{item.errorsDescription}}>--> + <!--({{item.subType}})--> + <!--</template>--> <template is="dom-if" if={{item.errorsDescription.length}}> <br/> <span class="warning">{{_warning()}}:</span> {{item.errorsDescription}} @@ -301,6 +304,7 @@ var result = converter.inferJsonDataType(data, ["*"]); result = converter.cast(result); this.fields = ArrayUtils.toFieldsArray(result.types); +// console.log(this.fields); this.data = result.dataset; this.filter = ""; diff --git a/controllets/dataset-table-controllet/dataset-table-controllet.html b/controllets/dataset-table-controllet/dataset-table-controllet.html index 3aa6516..3db9a70 100644 --- a/controllets/dataset-table-controllet/dataset-table-controllet.html +++ b/controllets/dataset-table-controllet/dataset-table-controllet.html @@ -275,10 +275,10 @@ </template> </template> <td> - <paper-icon-button room_id$="{{item.ID}}" version$="{{item.VER}}" class="tools" icon="open-in-new" on-click="_onOpenDatasetClick"></paper-icon-button> - <paper-icon-button room_id$="{{item.ID}}" version$="{{item.VER}}" class="tools" icon="file-download" on-click="_onDownloadDatasetClick"></paper-icon-button> - <paper-icon-button room_id$="{{item.ID}}" version$="{{item.VER}}" class="tools" icon="content-copy" on-click="_onCopyDatasetClick"></paper-icon-button> - <paper-icon-button room_id$="{{item.ID}}" version$="{{item.VER}}" class="tools" icon="description" on-click="_onDownloadInfoClick"></paper-icon-button> + <paper-icon-button title="Open" room_id$="{{item.ID}}" version$="{{item.VER}}" class="tools" icon="open-in-new" on-click="_onOpenDatasetClick"></paper-icon-button> + <paper-icon-button title="Download as CSV" room_id$="{{item.ID}}" version$="{{item.VER}}" class="tools" icon="file-download" on-click="_onDownloadDatasetClick"></paper-icon-button> + <paper-icon-button title="Copy link" room_id$="{{item.ID}}" version$="{{item.VER}}" class="tools" icon="content-copy" on-click="_onCopyDatasetClick"></paper-icon-button> + <paper-icon-button title="Download docs" room_id$="{{item.ID}}" version$="{{item.VER}}" class="tools" icon="description" on-click="_onDownloadInfoClick"></paper-icon-button> </td> </tr> </template> @@ -633,11 +633,11 @@ return Object.keys(obj).map(function(key) { if(key != "ID" && key != "cssClass") { //var test = regExp.test(obj[key]); - var test = (obj[key].constructor === Array); + var isLink = (obj[key].constructor === Array); return { key: key, value: obj[key], //test ? obj[key].split(",") : obj[key], - isLink: test + isLink: isLink } } }); diff --git a/controllets/providers-utility-controllet/providers-utility-controllet.html b/controllets/providers-utility-controllet/providers-utility-controllet.html index 5036452..03a98d2 100644 --- a/controllets/providers-utility-controllet/providers-utility-controllet.html +++ b/controllets/providers-utility-controllet/providers-utility-controllet.html @@ -16,6 +16,8 @@ } }; + //utility non legato al provider, aggiungere copy e creare un altro js!!! + //jsdatachecker utility_getFields = function(types) { return Object.keys(types).map(function(key) { return key; }); @@ -36,26 +38,7 @@ return selectedIndices; }; - // utility_getResourceUrl = function(url) { - // //CKAN - // var strDatasetPos = url.indexOf('/dataset/'); - // var strResourcePos = url.indexOf('/resource/'); - // if (strDatasetPos >= 0 && strResourcePos > strDatasetPos) { - // var urlSegment1 = url.substring(0, strDatasetPos); - // var urlResourceEnd = url.indexOf('/', strResourcePos + 10); - // var resourceId = url.substring(strResourcePos + 10, urlResourceEnd); - // return urlSegment1 + "/api/action/datastore_search?resource_id=" + resourceId; - // } - // //OPENDATASOFT - // var strExploreDatasetPos = url.indexOf('/explore/dataset/'); - // if (strExploreDatasetPos >= 0) { - // var urlSegment1 = url.substring(0, strExploreDatasetPos); - // var datasetEnd = url.indexOf(strExploreDatasetPos + 17, '/'); - // var datasetId = url.substring(strExploreDatasetPos + 17, datasetEnd >= 0 ? datasetEnd : url.length); - // return urlSegment1 + '/api/records/1.0/search?dataset=' + datasetId; - // } - // return ""; - // }; + </script> <dom-module id="providers-utility-controllet"> diff --git a/controllets/select-data-controllet/select-data-controllet.html b/controllets/select-data-controllet/select-data-controllet.html index 7db935a..c5cd0a0 100755 --- a/controllets/select-data-controllet/select-data-controllet.html +++ b/controllets/select-data-controllet/select-data-controllet.html @@ -130,7 +130,15 @@ }, getData : function() { - return this.data; + //return datatable.getData + //this.fields = "*" + var data = alasql_selectData(this.data, this.fields, this.filters); + var converter = new DataTypeConverter(); + var result = converter.inferJsonDataType(data, ["*"]); + result = converter.cast(result); + data = result.dataset; + + return data; }, setSelectedFields : function(selectedFields) { diff --git a/controllets/select-dataset-controllet/select-dataset-controllet.html b/controllets/select-dataset-controllet/select-dataset-controllet.html index 8b6d7fc..302e789 100755 --- a/controllets/select-dataset-controllet/select-dataset-controllet.html +++ b/controllets/select-dataset-controllet/select-dataset-controllet.html @@ -485,11 +485,11 @@ // this.datasets = that.datasets["result"]["datasets"]; $.ajax({ - url: "/cocreation/ajax/get-all-dataset", + url: "http://172.16.15.77/cocreation/ajax/get-all-dataset", dataType: "json", success: function(spodDatasets){ - that.providers = $.extend(that.datasets["result"]["providers"], {99: {api_url: "/cocreation/ajax/get-all-dataset", id: "99", image_hash: "SPOD", title: "SPOD"}}); + 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"}}); that.datasets = $.merge(spodDatasets, that.datasets["result"]["datasets"]); if(that.suggestedDatasets) { diff --git a/controllets/select-visualization-controllet/demo/index.html b/controllets/select-visualization-controllet/demo/index.html index 859dbb5..f2b25b2 100755 --- a/controllets/select-visualization-controllet/demo/index.html +++ b/controllets/select-visualization-controllet/demo/index.html @@ -9,6 +9,10 @@ <link rel="stylesheet" href="../../shared_js/perfect-scrollbar/css/perfect-scrollbar.min.css"> <script src="../../../locales/controllet_ln.js"></script> + + <script type="text/javascript" src="../../../alasql-utility/alasql.min.js"></script> + <script type="text/javascript" src="../../../alasql-utility/alasql-utility.js"></script> + <script> ln["localization"] = "en"; </script> diff --git a/controllets/select-visualization-controllet/select-datalet-inputs.html b/controllets/select-visualization-controllet/select-datalet-inputs.html index 19b1cba..bd0befc 100644 --- a/controllets/select-visualization-controllet/select-datalet-inputs.html +++ b/controllets/select-visualization-controllet/select-datalet-inputs.html @@ -303,9 +303,21 @@ // temp.push({name: name + " " + (i-4), description: description, selection: selection}); // } + else if (inputs.length == 2 && inputs[1].selection == "*") {// + name = inputs[1].name; + description = inputs[1].description; + selection = inputs[1].selection; + temp = [inputs[0]]; + temp.push({name: name + " 1", description: description, selection: selection}); + for (var i = 3; i < this.fields.length; i++) + temp.push({name: name + " " +(i-1), description: description, selection: selection}); + } + this.inputs = this._copy(temp); this.selectedFields = new Array(temp.length); + + this.selectedFields2 = new Array(temp.length); }, fireReady : function() { @@ -381,15 +393,23 @@ this.expert = !this.expert; }, + getFields : function () { + return this.selectedFields2; + }, + _addInput : function(e){ var selectedFields = this._copy(this.selectedFields); var ddl_index = $(e.target).parents("paper-dropdown-menu")[0].id; + var index = e.target.id; selectedFields[ddl_index] = this.fields[index]; this.selectedFields = this._copy(selectedFields); +// console.log(this.inputs[ddl_index].name); + this.selectedFields2[ddl_index] = {field: this.fields[index], input: this.inputs[ddl_index].name}; + if(!this._isReady()) { this.$.group_by.setAttribute("disabled", ""); @@ -518,6 +538,9 @@ // if(key.indexOf("BubbleContent") > -1) { // return ln["BubbleContent" + "_" +ln["localization"]] + key.slice(-2); // } + if(key.indexOf("NumericYAxis") > -1) { + return ln["NumericYAxis" + "_" +ln["localization"]] + key.slice(-2); + } return ln[key + "_" +ln["localization"]]; }, diff --git a/controllets/select-visualization-controllet/select-datalet-inputs_series.html b/controllets/select-visualization-controllet/select-datalet-inputs_series.html index 311ee8d..43056f6 100644 --- a/controllets/select-visualization-controllet/select-datalet-inputs_series.html +++ b/controllets/select-visualization-controllet/select-datalet-inputs_series.html @@ -302,6 +302,10 @@ } }, + getFields : function () { + return null; + }, + setInputs : function(inputs) { this.inputs = this._copy(inputs); }, diff --git a/controllets/select-visualization-controllet/select-datalet-options.html b/controllets/select-visualization-controllet/select-datalet-options.html index fd9e2d6..8eb74be 100644 --- a/controllets/select-visualization-controllet/select-datalet-options.html +++ b/controllets/select-visualization-controllet/select-datalet-options.html @@ -137,11 +137,11 @@ <template is="dom-repeat" items={{options}} index-as="index"> <div class="inputs"> - <template is="dom-if" if="{{_checkType(item.type, 'text')}}"> + <template is="dom-if" if="{{_checkType(item.type, 'TEXT')}}"> <paper-input label={{_getLabelName(item.name)}} on-change="_updateParams"></paper-input> </template> - <template is="dom-if" if="{{_checkType(item.type, 'list')}}"> + <template is="dom-if" if="{{_checkType(item.type, 'LIST')}}"> <paper-dropdown-menu label={{_getLabelName(item.name)}}> <paper-menu class="dropdown-content" selected = 0> <!--<paper-item on-tap="_updateParams"></paper-item>--> diff --git a/controllets/select-visualization-controllet/select-visualization-controllet.html b/controllets/select-visualization-controllet/select-visualization-controllet.html index ed4e2fd..0b8f5ee 100755 --- a/controllets/select-visualization-controllet/select-visualization-controllet.html +++ b/controllets/select-visualization-controllet/select-visualization-controllet.html @@ -342,9 +342,13 @@ this.selectedFields = inputs.getSelectedFields(); +// console.log(inputs.getFields()); + this.params = {'data-url' : this.dataUrl};//?????????????????? // this.params = {}; + this.params["selectedFields"] = JSON.stringify(inputs.getFields()); + this.params["filters"] = JSON.stringify(this.filters); this.params["aggregators"] = JSON.stringify(inputs.getAggregators()); this.params["orders"] = JSON.stringify(inputs.getOrders()); @@ -356,7 +360,9 @@ var data = alasql_complexSelectData(this.data, this.selectedFields, this.filters, inputs.getAggregators(), inputs.getOrders()); data = transformData(data, this.selectedFields, true); - this.params["data"] = JSON.stringify(data).replace(/'/g, "'"); + + //use cache +// this.params["data"] = JSON.stringify(data).replace(/'/g, "'"); var dataletParams ={ component: this.selectedDatalet+"-datalet", diff --git a/datalets/base-ajax-json-alasql-datalet/static/js/AjaxJsonAlasqlBehavior.js b/datalets/base-ajax-json-alasql-datalet/static/js/AjaxJsonAlasqlBehavior.js index 51f1b51..f8885aa 100755 --- a/datalets/base-ajax-json-alasql-datalet/static/js/AjaxJsonAlasqlBehavior.js +++ b/datalets/base-ajax-json-alasql-datalet/static/js/AjaxJsonAlasqlBehavior.js @@ -85,11 +85,13 @@ var AjaxJsonAlasqlBehavior = { selectData : function() { var fields = this._component.fields = JSON.parse(this._component.fields); + //var selectedFields = JSON.parse(this._component.getAttribute("selectedFields")); + var filters = JSON.parse(this._component.getAttribute("filters")); var aggregators = JSON.parse(this._component.getAttribute("aggregators")); var orders = JSON.parse(this._component.getAttribute("orders")); - //preview my space + //preview my space ? if(filters && filters[0] && filters[0].constructor == Array){ filters = filters[0]; aggregators = aggregators[0]; @@ -100,12 +102,28 @@ var AjaxJsonAlasqlBehavior = { var provider = f.getProvider(this._component.dataUrl); var data = provider.selectData(this.properties.json_results.value); + //if(selectedFields) { + // fields = []; + // var inputs = []; + // for (var i=0; i < selectedFields.length; i++) { + // if (selectedFields[i]) { + // fields.push(selectedFields[i].field); + // inputs.push(selectedFields[i].input); + // } + // } + //} + var converter = new DataTypeConverter(); var result = converter.inferJsonDataType(data, ["*"]); result = converter.cast(result); data = result.dataset; - //data = alasql_selectData(data, fields, filters); + data = alasql_selectData(data, fields, filters);//funziona senza? + + result = converter.inferJsonDataType(data, ["*"]); + result = converter.cast(result); + data = result.dataset; + data = alasql_complexSelectData(data, fields, filters, aggregators, orders); this.data = transformData(data, fields, true); diff --git a/datalets/highcharts-datalet/highcharts-datalet.html b/datalets/highcharts-datalet/highcharts-datalet.html index 56e6543..ec10497 100755 --- a/datalets/highcharts-datalet/highcharts-datalet.html +++ b/datalets/highcharts-datalet/highcharts-datalet.html @@ -140,15 +140,20 @@ Example : // }, transformData: function () { + var selectedFields = JSON.parse(this._component.getAttribute("selectedFields")); + if(this.data.length == 0) return; - if(this.data.length == 2){ - this.properties.categories.value = this.data[0].data; - this.properties.series.value = [this.data[1]]; - } + categories = this.data[0].data; + series = []; + for(var i = 1; i < this.data.length; i++) + series.push(this.data[i]); + + this.properties.categories.value = categories; + this.properties.series.value = series; - if(this.data.length == 3){//multi series + if(this.data.length == 3 && !selectedFields){//split cat var x = this.data[0]["data"]; var gb = this.data[1]["data"]; var y = this.data[2]["data"]; @@ -166,19 +171,21 @@ Example : series.push({name: s[i], data: new Array(categories.length+1).join('0').split('').map(parseFloat)}); } - for (var i = 0; i < y.length; i++){ + for(var i = 0; i < y.length; i++){ var index = categories.indexOf(x[i]); var s = series.filter(function( obj ) { return obj.name == gb[i]; }); - s[0]["data"][index] = y[i]; + s[0]["data"][index] = y[i]; } this.properties.categories.value = categories; this.properties.series.value = series; } + }, + // setParameters: function(params) // { // this._component.title = params['title']; diff --git a/datalets/leafletjs-datalet/leafletjs-datalet.html b/datalets/leafletjs-datalet/leafletjs-datalet.html index 64f8d76..0d13222 100755 --- a/datalets/leafletjs-datalet/leafletjs-datalet.html +++ b/datalets/leafletjs-datalet/leafletjs-datalet.html @@ -89,16 +89,28 @@ Example: L.Icon.Default.imagePath = 'http://services.routetopa.eu/DEEalerProvider/COMPONENTS/datalets/leafletjs-datalet/leafletsjs/images'; var coordinates = []; + var coordinates_index = 0; var isArray = t.data[0].data[0].constructor === Array; for(var i=0; i<t.data[0].data.length; i++) { if(isArray) - coordinates.push([parseFloat(t.data[0].data[i][0]), parseFloat(t.data[0].data[i][1])]); + { + if(!isNaN(t.data[0].data[i][0]) && !isNaN(t.data[0].data[i][1])) + coordinates.push([parseFloat(t.data[0].data[i][0]), parseFloat(t.data[0].data[i][1])]); + else + continue; + } else - coordinates.push([parseFloat(t.data[0].data[i]), parseFloat(t.data[1].data[i])]); + { + if(!isNaN(t.data[0].data[i]) && !isNaN(t.data[1].data[i])) + coordinates.push([parseFloat(t.data[0].data[i]), parseFloat(t.data[1].data[i])]); + else + continue; + } - var marker = L.marker([coordinates[i][0], coordinates[i][1]]).addTo(t._component.map); + var marker = L.marker([coordinates[coordinates_index][0], coordinates[coordinates_index][1]]).addTo(t._component.map); + coordinates_index++; if(t.data.length > 2) {