diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..a7b90e2 --- /dev/null +++ b/.htaccess @@ -0,0 +1,3 @@ +RewriteEngine On +RewriteCond %{REQUEST_FILENAME} !-f +RewriteRule ^ index.php [QSA,L] \ No newline at end of file diff --git a/alasql-utility/alasql-utility.js b/alasql-utility/alasql-utility.js index 5fcab1c..a2e6e00 100644 --- a/alasql-utility/alasql-utility.js +++ b/alasql-utility/alasql-utility.js @@ -125,7 +125,8 @@ function _addParenthesis (fields) { } function _normalizeField (field) { - return "[" + field + "]"; + return "`" + field + "`"; + //return "[" + field + "]"; } function alasql_transformData (data, fields, round) { diff --git a/bower_components/jsdatachecker/.bower.json b/bower_components/jsdatachecker/.bower.json index 7001714..d5c91dc 100644 --- a/bower_components/jsdatachecker/.bower.json +++ b/bower_components/jsdatachecker/.bower.json @@ -1,6 +1,6 @@ { "name": "jsdatachecker", - "version": "0.1.1", + "version": "0.1.3", "homepage": "https://github.com/donpir/jsdatachecker", "authors": [ "'Donato Pirozzi <'donatopirozzi@gmail.com'>" @@ -19,17 +19,16 @@ "polymer": "Polymer/polymer#1.2.0", "qunit": "~1.22.0", "csvjson": "0.1.1", - "polywc": "https://github.com/donpir/polywc.git#master" + "polywc-data-table": "https://github.com/donpir/polywc-data-table.git#master" }, "private": false, - "_release": "0.1.1", + "_release": "0.1.3", "_resolution": { "type": "version", - "tag": "v0.1.1", - "commit": "60887fda0d7e7388c5d682228ee1288dd7bcdd09" + "tag": "v0.1.3", + "commit": "186392b9d8576e98e269150ab2a88562215a2b2a" }, "_source": "https://github.com/donpir/JSDataChecker.git", - "_target": "~0.1.1", - "_originalSource": "jsdatachecker", - "_direct": true + "_target": "~0.1.2", + "_originalSource": "jsdatachecker" } \ No newline at end of file diff --git a/bower_components/jsdatachecker/bower.json b/bower_components/jsdatachecker/bower.json index 0378f9d..6f66898 100644 --- a/bower_components/jsdatachecker/bower.json +++ b/bower_components/jsdatachecker/bower.json @@ -1,6 +1,6 @@ { "name": "jsdatachecker", - "version": "v0.1.1", + "version": "v0.1.3", "homepage": "https://github.com/donpir/jsdatachecker", "authors": [ "'Donato Pirozzi <'donatopirozzi@gmail.com'>" @@ -19,7 +19,7 @@ "polymer": "Polymer/polymer#1.2.0", "qunit": "~1.22.0", "csvjson": "0.1.1", - "polywc": "https://github.com/donpir/polywc.git#master" + "polywc-data-table": "https://github.com/donpir/polywc-data-table.git#master" }, "private": false } diff --git a/bower_components/jsdatachecker/build.cmd b/bower_components/jsdatachecker/build.cmd index 96692db..71a4b0f 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 src\DataTypeHierarchy.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 src\langs.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 325f3e3..bb14fac 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(){}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={GEOCOORDINATE:{value:1e3,name:"GEOCOORDINATE"},GEOJSON:{value:1001,name:"GEOJSON"},PERCENTAGE:{value:1100,name:"PERCENTAGE"},LATITUDE:{value:1101,name:"LATITUDE"},LONGITUDE:{value:1102,name:"LONGITUDE"}},DataTypeConverter.GEOJSONTYPES=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon","GeometryCollection"],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;var max=ArrayUtils.FindMinMax(field._inferredSubTypes,function(curval,lastval){return curval>lastval});if(field.subtype=null,null!=max&&null!=max.first){field.subtype=max.first.key,field.subtypeConfidence=field._inferredSubTypes[field.subtype]/field.numOfItems;var fieldName=field.name.toLowerCase(),isLatType=field.subtype===DataTypeConverter.SUBTYPES.LATITUDE.name,fieldNameContainsLat=fieldName.indexOf("lat")>=0,fieldNameContainsLon=fieldName.indexOf("ng")>=0;1==isLatType&&0==fieldNameContainsLat&&1==fieldNameContainsLon&&(field.subtype=DataTypeConverter.SUBTYPES.LONGITUDE.name)}})},_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},_processInferSubType=function(value){if(null===value||"undefined"==typeof value)return null;if(Array.isArray(value)&&2==value.length&&NaN!=DataTypesUtils.FilterFloat(value[0])&&NaN!=DataTypesUtils.FilterFloat(value[1])&&DataTypesUtils.DecimalPlaces(value[0])>4&&DataTypesUtils.DecimalPlaces(value[1])>4)return DataTypeConverter.SUBTYPES.GEOCOORDINATE;if("string"==typeof value){var split=value.split(",");if(DataTypesUtils.IsLatLng(split[0])&&DataTypesUtils.IsLatLng(split[1]))return DataTypeConverter.SUBTYPES.GEOCOORDINATE}var isnumber=DataTypesUtils.FilterFloat(value);if(isNaN(isnumber)!==!0)return isnumber>=-90&&90>=isnumber&&DataTypesUtils.DecimalPlaces(isnumber)>=5?DataTypeConverter.SUBTYPES.GEOCOORDINATE:isnumber>=-180&&180>=isnumber&&DataTypesUtils.DecimalPlaces(isnumber)>=5?DataTypeConverter.SUBTYPES.GEOCOORDINATE:null;if("object"==typeof value&&value.hasOwnProperty("type")){var geotype=value.type,isincluded=DataTypeConverter.GEOJSONTYPES.includes(geotype);if(isincluded)return DataTypeConverter.SUBTYPES.GEOJSON}return null},_filterBasedOnThreshold=function(metadata,threshold){return ArrayUtils.IteratorOverKeys(metadata.types,function(fieldType,key){if(!(fieldType.typeConfidence>=threshold)){var arrHierarchyTypes=DataTypeHierarchy.HIERARCHY[fieldType.type];if(null==arrHierarchyTypes)return metadata;var lastFieldType={lastType:arrHierarchyTypes[0],lastTypeCounter:fieldType._inferredTypes[arrHierarchyTypes[0]],typeConfidence:0};lastFieldType.typeConfidence=lastFieldType.lastTypeCounter/fieldType.numOfItems;for(var curType,i=1;i=threshold){fieldType.type=lastFieldType.lastType,fieldType.typeConfidence=lastFieldType.typeConfidence;break}}}}),metadata},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;j0?",":"")+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,options){"undefined"!=typeof options&&null!=options||(options={thresholdConfidence:1});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;j0){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});var metadata={dataset:json,fieldKeys:fieldKeys,types:fieldsType,qualityIndex:quality,warningsTextual:warningsTextual};return _filterBasedOnThreshold(metadata,options.thresholdConfidence),metadata},inferDataTypeOfValue:function(value){return _processInferType(value)},inferDataSubTypeOfValue:function(value){return _processInferSubType(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},DataTypesUtils.IsLatLng=function(num){return NaN==DataTypesUtils.FilterFloat(num)?!1:DataTypesUtils.DecimalPlaces(num)>4},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.GEOCOORDINATE.name]=[DataTypeConverter.SUBTYPES.GEOCOORDINATE.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 +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={EMPTY:{value:0,name:"NULL"},TEXT:{value:1,name:"TEXT"},NUMBER:{value:2,name:"NUMBER"},OBJECT:{value:3,name:"OBJECT"},DATETIME:{value:4,name:"DATETIME"}},DataTypeConverter.SUBTYPES={GEOCOORDINATE:{value:1e3,name:"GEOCOORDINATE"},GEOJSON:{value:1001,name:"GEOJSON"},BOOL:{value:1002,name:"BOOL"},CONST:{value:1003,name:"CONST"},CATEGORY:{value:1004,name:"CATEGORY"},PERCENTAGE:{value:1100,name:"PERCENTAGE"},LATITUDE:{value:1101,name:"LATITUDE"},LONGITUDE:{value:1102,name:"LONGITUDE"}},DataTypeConverter.LANGS={EN:{value:1e3,name:"EN"},IT:{value:1001,name:"IT"},FR:{value:1100,name:"FR"},NL:{value:1101,name:"NL"}},DataTypeConverter.GEOJSONTYPES=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon","GeometryCollection","Feature","FeatureCollection"],DataTypeConverter.prototype=function(){var _analyseDataTypes=function(fields){ArrayUtils.IteratorOverKeys(fields,function(field){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;var max=ArrayUtils.FindMinMax(field._inferredSubTypes,function(curval,lastval){return curval>lastval});if(field.subtype=null,null!=max&&null!=max.first){field.subtype=max.first.key,field.subtypeConfidence=field._inferredSubTypes[field.subtype]/field.numOfItems;var fieldName=field.name.toLowerCase(),isLatType=field.subtype===DataTypeConverter.SUBTYPES.LATITUDE.name,fieldNameContainsLat=fieldName.indexOf("lat")>=0,fieldNameContainsLon=fieldName.indexOf("ng")>=0;1==isLatType&&0==fieldNameContainsLat&&1==fieldNameContainsLon&&(field.subtype=DataTypeConverter.SUBTYPES.LONGITUDE.name)}})},_processInferType=function(value){if(null===value||"undefined"==typeof value)return DataTypeConverter.TYPES.EMPTY;if("object"==typeof value)return DataTypeConverter.TYPES.OBJECT;var isnumber=DataTypesUtils.FilterNumber(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},_processInferSubType=function(value){if(null===value||"undefined"==typeof value)return null;if(Array.isArray(value)&&2==value.length&&NaN!=DataTypesUtils.FilterNumber(value[0])&&NaN!=DataTypesUtils.FilterNumber(value[1])&&DataTypesUtils.DecimalPlaces(value[0])>4&&DataTypesUtils.DecimalPlaces(value[1])>4)return DataTypeConverter.SUBTYPES.GEOCOORDINATE;if("string"==typeof value){var split=value.split(",");if(DataTypesUtils.IsLatLng(split[0])&&DataTypesUtils.IsLatLng(split[1]))return DataTypeConverter.SUBTYPES.GEOCOORDINATE}var isnumber=DataTypesUtils.FilterNumber(value);if(isNaN(isnumber)!==!0)return isnumber>=-90&&90>=isnumber&&DataTypesUtils.DecimalPlaces(isnumber)>=5?DataTypeConverter.SUBTYPES.GEOCOORDINATE:isnumber>=-180&&180>=isnumber&&DataTypesUtils.DecimalPlaces(isnumber)>=5?DataTypeConverter.SUBTYPES.GEOCOORDINATE:null;if("object"==typeof value&&value.hasOwnProperty("type")){var geotype=value.type,isincluded=DataTypeConverter.GEOJSONTYPES.includes(geotype);if(isincluded)return DataTypeConverter.SUBTYPES.GEOJSON}return null},_filterBasedOnThreshold=function(metadata,threshold){return ArrayUtils.IteratorOverKeys(metadata.types,function(fieldType,key){if(!(fieldType.typeConfidence>=threshold)){var arrHierarchyTypes=DataTypeHierarchy.HIERARCHY[fieldType.type];if(null==arrHierarchyTypes)return metadata;var lastFieldType={lastType:arrHierarchyTypes[0],lastTypeCounter:fieldType._inferredTypes[arrHierarchyTypes[0]],typeConfidence:0};lastFieldType.typeConfidence=lastFieldType.lastTypeCounter/fieldType.numOfItems;for(var curType,i=1;i=threshold){fieldType.type=lastFieldType.lastType,fieldType.typeConfidence=lastFieldType.typeConfidence;break}}}}),metadata},_capitalizeFirstLetter=function(string){return string.charAt(0).toUpperCase()+string.slice(1)},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;j0?",":"")+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,makeChangesToDataset:!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,makeChangesToDataset:!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){0==isNaN(DataTypesUtils.FilterNumber(value))&&"string"==typeof value&&(value=value.replace(",","."));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,options){"undefined"!=typeof options&&null!=options||(options={}),0==options.hasOwnProperty("thresholdConfidence")&&(options.thresholdConfidence=1),0==options.hasOwnProperty("language")?options.language=DataTypeConverter.LANGS.EN.name:options.language=options.language.toUpperCase();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_numOfRows&&(_numOfRows=fieldType.numOfItems)}),ArrayUtils.IteratorOverKeys(fieldsType,function(fieldType){fieldType._inferredTypes.hasOwnProperty(DataTypeConverter.TYPES.EMPTY.name)||(fieldType._inferredTypes[DataTypeConverter.TYPES.EMPTY.name]=0),fieldType._inferredTypes[DataTypeConverter.TYPES.EMPTY.name]=fieldType._inferredTypes[DataTypeConverter.TYPES.EMPTY.name]+(_numOfRows-fieldType.numOfItems)}),_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="";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){var _descr1=_capitalizeFirstLetter(JDC_LNG.key_declaretype[options.language])+".",_descr2=_capitalizeFirstLetter(JDC_LNG.key_notoftype_singular[options.language])+".";incorrect>1&&(_descr2=_capitalizeFirstLetter(JDC_LNG.key_notoftype_plural[options.language])+".");var descr=_descr1+" "+_descr2;descr=descr.replace(/%COL_NAME/g,fieldType.name),descr=descr.replace(/%COL_TYPE/g,fieldType.type),descr=descr.replace(/%COL_ERRORS/g,incorrect),description+=descr}}var descr="";1==fieldType.totalNullValues?descr=_capitalizeFirstLetter(JDC_LNG.key_emptyvalue_singolar[options.language])+".":fieldType.totalNullValues>1&&(descr=_capitalizeFirstLetter(JDC_LNG.key_emptyvalue_plural[options.language])+"."),descr=descr.replace(/%COL_NAME/g,fieldType.name),descr=descr.replace(/%COL_TYPE/g,fieldType.type),descr=descr.replace(/%COL_NULLVALUES/g,fieldType.totalNullValues),description=description+" "+descr,fieldType.errorsDescription=description.trim(),warningsTextual+=description.trim()});var metadata={dataset:json,fieldKeys:fieldKeys,types:fieldsType,qualityIndex:quality,warningsTextual:warningsTextual};return _filterBasedOnThreshold(metadata,options.thresholdConfidence),metadata},inferDataTypeOfValue:function(value){return _processInferType(value)},inferDataSubTypeOfValue:function(value){return _processInferSubType(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.FilterNumber=function(value){var valnum=DataTypesUtils.FilterFloat(value);if(0==isNaN(valnum))return valnum;if("string"!=typeof value)return NaN;var idxDot=(value.split(/(,|\.)/g),{idx:value.indexOf("."),sym:"."}),idxComma={idx:value.lastIndexOf(","),sym:","},idxFirst={};idxFirst=-1==idxDot.idx?idxComma:-1==idxComma.idx?idxDot:idxDot.idxidxLastComma.idx?idxLastDot:idxLastComma;var splitted=value.split(/(\.|,|\-|\+)/g);if(0==splitted.length)return NaN;var numOfDots=0,numOfComma=0,i=0;"-"!=splitted[0]&&"+"!=splitted[0]||(i=1);for(var str;i4},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.GEOCOORDINATE.name]=[DataTypeConverter.SUBTYPES.GEOCOORDINATE.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};var JDC_LNG={key_declaretype:{EN:"the column <%COL_NAME> is of type <%COL_TYPE>",IT:"la colonna <%COL_NAME> è di tipo <%COL_TYPE>",FR:"le colum <%COL_NAME> est de type <%COL_TYPE>",NL:"de kolom <%COL_NAME> is van het type <%COL_TYPE>"},key_notoftype_singular:{EN:"a value is not <%COL_TYPE>",IT:"un valore non è un <%COL_TYPE>",FR:"une valeur est pas <%COL_TYPE> se trouvant",NL:"een waarde is niet <%COL_TYPE>"},key_notoftype_plural:{EN:"%COL_ERRORS values are not <%COL_TYPE>",IT:"%COL_ERRORS valori non sono di tipo <%COL_TYPE>",FR:"les valeurs %COL_ERRORS sont du type <%COL_TYPE>",NL:"%COL_ERRORS waarden niet <%COL_TYPE>"},key_emptyvalue_singolar:{EN:"the column <%COL_NAME> has an empty value",IT:"la colonna <%COL_NAME> ha un valore vuoto",FR:"la colonne <%COL_NAME> a une valeur vide",NL:"de kolom <%COL_NAME> heeft een lege waarde"},key_emptyvalue_plural:{EN:"the column <%COL_NAME> has <%COL_NULLVALUES> empty values",IT:"la colonna <%COL_NAME> ha <%COL_NULLVALUES> valori vuoti",FR:"la colonne <%COL_NAME> a <%COL_NULLVALUES> valeurs vide",NL:"de kolom <%COL_NAME> heeft <%COL_NULLVALUES> lege waarde"},key_type:{EN:"type",IT:"tipo",FR:"type",NL:"type"},key_subtype:{EN:"subtype",IT:"sottotipo",FR:"sous-type",NL:"subtype"},key_typetext:{EN:"text",IT:"testo",FR:"texte",NL:"tekst"},key_typenumber:{EN:"number",IT:"numero",FR:"nombre",NL:"aantal"},key_typeobject:{EN:"object",IT:"oggetto",FR:"objet",NL:"voorwerp"},key_typedatetime:{EN:"date or time",IT:"data o orario",FR:"date ou l'heure",NL:"datum of tijd"},key_typeempty:{EN:"empty",IT:"vuoto",FR:"vide",NL:"leeg"},key_typelatitude:{EN:"latitude",IT:"latitudine",FR:"latitude",NL:"breedtegraad"},key_typelongitude:{EN:"longitude",IT:"longitudine",FR:"longitude",NL:"lengtegraad"}}; \ No newline at end of file diff --git a/bower_components/jsdatachecker/src/DataTypeConverter.js b/bower_components/jsdatachecker/src/DataTypeConverter.js index 201c21a..56cc662 100644 --- a/bower_components/jsdatachecker/src/DataTypeConverter.js +++ b/bower_components/jsdatachecker/src/DataTypeConverter.js @@ -25,33 +25,39 @@ function DataTypeConverter() { };//EndConstructor. DataTypeConverter.TYPES = { - TEXT : { value: 0, name: "TEXT" }, - CODE : { value: 1, name: "CODE"}, + EMPTY : { value: 0, name: "NULL"}, + TEXT : { value: 1, name: "TEXT" }, 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" } + DATETIME : { value: 4, name: "DATETIME" } }; DataTypeConverter.SUBTYPES = { GEOCOORDINATE : { value: 1000, name: "GEOCOORDINATE" }, GEOJSON : { value: 1001, name: "GEOJSON" }, + BOOL : { value: 1002, name: "BOOL"}, + CONST : { value: 1003, name: "CONST" }, + CATEGORY : { value: 1004, name: "CATEGORY" }, PERCENTAGE : { value: 1100, name: "PERCENTAGE" }, LATITUDE : { value: 1101, name: "LATITUDE" }, LONGITUDE : { value: 1102, name: "LONGITUDE" } + + /*CODE : { value: 2000, name: "CODE"},*/ +}; + +DataTypeConverter.LANGS = { + EN : { value: 1000, name: "EN" }, + IT : { value: 1001, name: "IT" }, + FR : { value: 1100, name: "FR" }, + NL : { value: 1101, name: "NL" } }; + DataTypeConverter.GEOJSONTYPES = [ "Point", "MultiPoint", "LineString", - "MultiLineString", "Polygon", "MultiPolygon", "GeometryCollection" ]; + "MultiLineString", "Polygon", "MultiPolygon", "GeometryCollection", "Feature", + "FeatureCollection" ]; DataTypeConverter.prototype = (function () { @@ -116,6 +122,10 @@ DataTypeConverter.prototype = (function () { var _analyseDataTypes = function(fields) { ArrayUtils.IteratorOverKeys(fields, function(field) { + + + /* + //TODO: removed CODE, I don't know whether it must be inserted if (field._inferredTypes[DataTypeConverter.TYPES.CODE.name]) { var confidence = field._inferredTypes[DataTypeConverter.TYPES.CODE.name] / field.numOfItems; var _numericalInferredType = field._inferredTypes[DataTypeConverter.TYPES.NUMBER.name]; @@ -124,7 +134,7 @@ DataTypeConverter.prototype = (function () { field.type = DataTypeConverter.TYPES.CODE.name; field.typeConfidence = confidence; return; - } + }*/ //Infers the field TYPE. var max = ArrayUtils.FindMinMax(field._inferredTypes, function (curval, lastval) { @@ -194,13 +204,9 @@ DataTypeConverter.prototype = (function () { if (typeof value === 'object') return DataTypeConverter.TYPES.OBJECT; - //If the value starts with a zero and contains all numbers, it is - //inferred as textual content. - if (/^0[0-9]+$/.test(value)) - return DataTypeConverter.TYPES.CODE; - //Try to parse the float. - var isnumber = DataTypesUtils.FilterFloat(value); + //var isnumber = DataTypesUtils.FilterFloat(value); + var isnumber = DataTypesUtils.FilterNumber(value); if (isNaN(isnumber) !== true) {//It is a number. //If the number ranges from -90.0 to 90.0, the value is marked as Latitude. //if (-90.0 <= isnumber && isnumber <= 90.0 && _dataTypesUtils.decimalPlaces(isnumber) >= 5) @@ -230,19 +236,22 @@ DataTypeConverter.prototype = (function () { //GEOCOORDINATE if (Array.isArray(value) && value.length == 2) {//It recognises the LAT LNG as array of two values. //Checks if the two array's values are numbers. - if ( DataTypesUtils.FilterFloat(value[0]) != NaN && DataTypesUtils.FilterFloat(value[1]) != NaN ) + //if ( DataTypesUtils.FilterFloat(value[0]) != NaN && DataTypesUtils.FilterFloat(value[1]) != NaN ) + if ( DataTypesUtils.FilterNumber(value[0]) != NaN && DataTypesUtils.FilterNumber(value[1]) != NaN ) if (DataTypesUtils.DecimalPlaces(value[0]) > 4 && DataTypesUtils.DecimalPlaces(value[1]) > 4 ) return DataTypeConverter.SUBTYPES.GEOCOORDINATE; }//EndIf. if (typeof value === 'string') { var split = value.split(","); - if (DataTypesUtils.IsLatLng(split[0]) && DataTypesUtils.IsLatLng(split[1])) - return DataTypeConverter.SUBTYPES.GEOCOORDINATE; + //if (split.length == 2) + if (DataTypesUtils.IsLatLng(split[0]) && DataTypesUtils.IsLatLng(split[1])) + return DataTypeConverter.SUBTYPES.GEOCOORDINATE; } //Try to parse the float. - var isnumber = DataTypesUtils.FilterFloat(value); + //var isnumber = DataTypesUtils.FilterFloat(value); + var isnumber = DataTypesUtils.FilterNumber(value); if (isNaN(isnumber) !== true) {//It is a number. //If the number ranges from -90.0 to 90.0, the value is marked as Latitude. if (-90.0 <= isnumber && isnumber <= 90.0 && DataTypesUtils.DecimalPlaces(isnumber) >= 5) @@ -267,6 +276,11 @@ DataTypeConverter.prototype = (function () { if (isincluded) return DataTypeConverter.SUBTYPES.GEOJSON; } + //If the value starts with a zero and contains all numbers, it is + //inferred as textual content. + /*if (/^0[0-9]+$/.test(value)) + return DataTypeConverter.TYPES.CODE;*/ + return null; };//EndFunction. @@ -300,6 +314,15 @@ DataTypeConverter.prototype = (function () { return metadata; };//EndFunction. + var _capitalizeFirstLetter = function(string) { + return string.charAt(0).toUpperCase() + string.slice(1); + };//EndFunction. + + var _replaceAll = function(search, replacement) { + var target = this; + return target.split(search).join(replacement); + }; + var jsonTraverse = function(json, fieldKeys, callback) { var stack = []; var numOfRows = 0; @@ -349,15 +372,19 @@ DataTypeConverter.prototype = (function () { return { constructor: DataTypeConverter, + /** - * It parses the json in input and converts the content - * in according to the inferred data types. - * @param json - * @param path Format: field1->field2->field3 + * + * @param metadata Previous information on the inferred types. + * @param options Some options to cast the data. + * - castThresholdConfidence: for which threshold the library must perform the cast (default 1) + * - makeChangesToDataset: is a boolean value, to indicate whether the library can do improvement on the storage + * values, for instance, numbers with the comma will be replaced with the dot. + * @returns {*} */ cast: function(metadata, options) { if (typeof options === 'undefined' || options == null) - options = { castThresholdConfidence: 1, castIfNull: false }; + options = { castThresholdConfidence: 1, castIfNull: false, makeChangesToDataset: false }; return this.convert(metadata, options); }, @@ -380,7 +407,7 @@ DataTypeConverter.prototype = (function () { var datasetMissingValues = 0; if (typeof options === 'undefined' || options == null) - options = { castThresholdConfidence: 1, castIfNull: false }; + options = { castThresholdConfidence: 1, castIfNull: false, makeChangesToDataset: false }; jsonTraverse(metadata.dataset, metadata.fieldKeys, function(value, key, traversedKeys, rowIndex) { var inferredType = metadata.types[traversedKeys]; @@ -399,6 +426,9 @@ DataTypeConverter.prototype = (function () { //var isCast = !(options.castIfNull == false && inferredType.totalNullValues > 0); var isCast = inferredType.typeConfidence >= options.castThresholdConfidence; if (inferredType.type == DataTypeConverter.TYPES.NUMBER.name && isCast) { + if (isNaN(DataTypesUtils.FilterNumber(value)) == false && typeof value === "string") + value = value.replace(',', '.'); + var number = parseFloat(value); if (isNaN(number)) { @@ -426,8 +456,17 @@ DataTypeConverter.prototype = (function () { * @param options Infer Data Type options, in particular the threshold value for the confidence. */ inferJsonDataType: function (json, fieldKeys, options) { - if (typeof options === 'undefined' || options == null) - options = { thresholdConfidence: 1 }; + + //Default options initialisation. + if (typeof options === 'undefined' || options == null) options = { }; + + if (options.hasOwnProperty("thresholdConfidence") == false) + options.thresholdConfidence = 1; + + if (options.hasOwnProperty("language") == false) + options.language = DataTypeConverter.LANGS.EN.name; + else + options.language = options.language.toUpperCase(); var stack = []; var fieldsType = {}; @@ -500,6 +539,25 @@ DataTypeConverter.prototype = (function () { } }//EndWhile. + + //Calculates the number of rows in the dataset. + var _numOfRows = 0; + ArrayUtils.IteratorOverKeys(fieldsType, function(fieldType) { + if (fieldType.numOfItems > _numOfRows) + _numOfRows = fieldType.numOfItems; + }); + + //Computes the number of null values. + ArrayUtils.IteratorOverKeys(fieldsType, function(fieldType) { + if (!fieldType._inferredTypes.hasOwnProperty(DataTypeConverter.TYPES.EMPTY.name)) { + //Initialises the field. + fieldType._inferredTypes[DataTypeConverter.TYPES.EMPTY.name] = 0; + } + + fieldType._inferredTypes[DataTypeConverter.TYPES.EMPTY.name] = fieldType._inferredTypes[DataTypeConverter.TYPES.EMPTY.name] + (_numOfRows - fieldType.numOfItems); + }); + + //Infers the data type. _analyseDataTypes(fieldsType); //Data quality. @@ -538,22 +596,47 @@ DataTypeConverter.prototype = (function () { var incorrect = fieldType.numOfItems - fieldType.totalNullValues - fieldType._inferredTypes[fieldType.type]; if (incorrect > 0) { - description += "The column <" + fieldType.name + "> has the type <" + fieldType.type + ">"; + var _descr1 = _capitalizeFirstLetter(JDC_LNG['key_declaretype'][options.language]) + "."; + var _descr2 = _capitalizeFirstLetter(JDC_LNG['key_notoftype_singular'][options.language]) + "."; + if (incorrect > 1) + _descr2 = _capitalizeFirstLetter(JDC_LNG['key_notoftype_plural'][options.language]) + "."; + + var descr = _descr1 + " " + _descr2; + descr = descr.replace(/%COL_NAME/g, fieldType.name); + descr = descr.replace(/%COL_TYPE/g, fieldType.type); + descr = descr.replace(/%COL_ERRORS/g, incorrect); + + description += descr; + + /*description += "The column <" + fieldType.name + "> has the type <" + fieldType.type + ">"; var verb = (incorrect == 1) ? " value is" : " values are"; - description += ", but " + incorrect + verb + " not a " + fieldType.type; + description += ", but " + incorrect + verb + " not a " + fieldType.type;*/ } } - if (fieldType.totalNullValues > 0) { + var descr = ""; + if (fieldType.totalNullValues == 1) + descr = _capitalizeFirstLetter(JDC_LNG['key_emptyvalue_singolar'][options.language]) + "."; + else if (fieldType.totalNullValues > 1 ) + descr = _capitalizeFirstLetter(JDC_LNG['key_emptyvalue_plural'][options.language]) + "."; + + descr = descr.replace(/%COL_NAME/g, fieldType.name); + descr = descr.replace(/%COL_TYPE/g, fieldType.type); + descr = descr.replace(/%COL_NULLVALUES/g, fieldType.totalNullValues); + description = description + " " + descr; + + /*if (fieldType.totalNullValues > 0) { + var descr = _capitalizeFirstLetter(JDC_LNG['key_declaretype'][options.language]) + "."; + description += "The column <" + fieldType.name + "> has " + fieldType.totalNullValues + " EMPTY value"; if (fieldType.totalNullValues > 1) description += "s"; } if (description.length > 0) - description += "."; + description += ".";*/ - fieldType.errorsDescription = description; - warningsTextual += description; + fieldType.errorsDescription = description.trim(); + warningsTextual += description.trim(); }); var metadata = { dataset: json, fieldKeys: fieldKeys, types: fieldsType, qualityIndex: quality, warningsTextual: warningsTextual }; diff --git a/bower_components/jsdatachecker/src/DataTypesUtils.js b/bower_components/jsdatachecker/src/DataTypesUtils.js index 45f8b5c..a6c36db 100644 --- a/bower_components/jsdatachecker/src/DataTypesUtils.js +++ b/bower_components/jsdatachecker/src/DataTypesUtils.js @@ -107,6 +107,71 @@ DataTypesUtils.FilterFloat = function (value) { return NaN; };//EndFunction. +DataTypesUtils.FilterNumber = function (value) { + //Check immediatly if it is a classical number. + var valnum = DataTypesUtils.FilterFloat(value); + if (isNaN(valnum) == false) return valnum; + + //Checks if the value is a string. + if (typeof value !== "string") + return NaN; + + var parts = value.split(/(,|\.)/g); + + //Find the smallest symbol. + var idxDot = { idx: value.indexOf('.'), sym: '.' }; + var idxComma = { idx: value.lastIndexOf(','), sym: ',' }; + var idxFirst = {}; + if (idxDot.idx == -1) idxFirst = idxComma; + else if (idxComma.idx == -1) idxFirst = idxDot; + else if (idxDot.idx < idxComma.idx) idxFirst = idxDot; + else idxFirst = idxComma; + + //Find the greatest symbol. + var idxLastDot = { idx: value.lastIndexOf('.'), sym: '.' }; + var idxLastComma = { idx: value.lastIndexOf(','), sym: ',' }; + var idxLast = {}; + if (idxLastDot.idx == -1) idxLast = idxLastComma; + else if (idxLastComma.idx == -1) idxLast = idxLastDot; + else if (idxLastDot.idx > idxLastComma.idx) idxLast = idxLastDot; + else idxLast = idxLastComma; + + //Splits over the dot and comma and check that are all numbers. + var splitted = value.split(/(\.|,|\-|\+)/g); + if (splitted.length == 0) return NaN; + + var numOfDots = 0; + var numOfComma = 0; + var i=0; + if (splitted[0] == '-' || splitted[0] == '+') i=1; + + for (var str; i is of type <%COL_TYPE>", + "IT": "la colonna <%COL_NAME> è di tipo <%COL_TYPE>", + "FR": "le colum <%COL_NAME> est de type <%COL_TYPE>", + "NL": "de kolom <%COL_NAME> is van het type <%COL_TYPE>" + }, + + "key_notoftype_singular": { + "EN": "a value is not <%COL_TYPE>", + "IT": "un valore non è un <%COL_TYPE>", + "FR": "une valeur est pas <%COL_TYPE> se trouvant", + "NL": "een waarde is niet <%COL_TYPE>" + }, + + "key_notoftype_plural": { + "EN": "%COL_ERRORS values are not <%COL_TYPE>", + "IT": "%COL_ERRORS valori non sono di tipo <%COL_TYPE>", + "FR": "les valeurs %COL_ERRORS sont du type <%COL_TYPE>", + "NL": "%COL_ERRORS waarden niet <%COL_TYPE>" + }, + + "key_emptyvalue_singolar": { + "EN": "the column <%COL_NAME> has an empty value", + "IT": "la colonna <%COL_NAME> ha un valore vuoto", + "FR": "la colonne <%COL_NAME> a une valeur vide", + "NL": "de kolom <%COL_NAME> heeft een lege waarde" + }, + + "key_emptyvalue_plural": { + "EN": "the column <%COL_NAME> has <%COL_NULLVALUES> empty values", + "IT": "la colonna <%COL_NAME> ha <%COL_NULLVALUES> valori vuoti", + "FR": "la colonne <%COL_NAME> a <%COL_NULLVALUES> valeurs vide", + "NL": "de kolom <%COL_NAME> heeft <%COL_NULLVALUES> lege waarde" + }, + + "key_type": { + "EN": "type", + "IT": "tipo", + "FR": "type", + "NL": "type" + }, + + "key_subtype": { + "EN": "subtype", + "IT": "sottotipo", + "FR": "sous-type", + "NL": "subtype" + }, + + "key_typetext": { + "EN": "text", + "IT": "testo", + "FR": "texte", + "NL": "tekst" + }, + + "key_typenumber": { + "EN": "number", + "IT": "numero", + "FR": "nombre", + "NL": "aantal" + }, + + "key_typeobject": { + "EN": "object", + "IT": "oggetto", + "FR": "objet", + "NL": "voorwerp" + }, + + "key_typedatetime": { + "EN": "date or time", + "IT": "data o orario", + "FR": "date ou l'heure", + "NL": "datum of tijd" + }, + + "key_typeempty": { + "EN": "empty", + "IT": "vuoto", + "FR": "vide", + "NL": "leeg" + }, + + "key_typelatitude": { + "EN": "latitude", + "IT": "latitudine", + "FR": "latitude", + "NL": "breedtegraad" + }, + + "key_typelongitude": { + "EN": "longitude", + "IT": "longitudine", + "FR": "longitude", + "NL": "lengtegraad" + } + +}; \ No newline at end of file diff --git a/controllet.html b/controllet.html new file mode 100644 index 0000000..b5aa827 --- /dev/null +++ b/controllet.html @@ -0,0 +1,37 @@ + + + + + + + + + + + + diff --git a/controllets/animated-button-container-controllet/animated-button-container-controllet.html b/controllets/animated-button-container-controllet/animated-button-container-controllet.html index 4c91dc7..5b5c068 100755 --- a/controllets/animated-button-container-controllet/animated-button-container-controllet.html +++ b/controllets/animated-button-container-controllet/animated-button-container-controllet.html @@ -18,17 +18,12 @@ color: #FFFFFF; height: 32px; width: 32px; - background-color: #00BCD4; - } - - .button-container { - cursor: pointer; - height: 36px; - width: 36px; + background-color: #2196F3; + border-radius: 18px; box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12); } - .button-container:hover { + iron-icon.myspace:hover { box-shadow: 0 5px 11px 0 rgba(0, 0, 0, 0.18), 0 4px 15px 0 rgba(0, 0, 0, 0.15); -webkit-transition: 0.2s ease-out; -moz-transition: 0.2s ease-out; @@ -37,6 +32,13 @@ transition: 0.2s ease-out; } + .button-container { + cursor: pointer; + height: 36px; + width: 36px; + border-radius: 18px; + } + .window { height: 620px; width: 760px; diff --git a/controllets/cocreation-paper-card-controllet/cocreation-paper-card-controllet.html b/controllets/cocreation-paper-card-controllet/cocreation-paper-card-controllet.html index d7635bd..86a2550 100755 --- a/controllets/cocreation-paper-card-controllet/cocreation-paper-card-controllet.html +++ b/controllets/cocreation-paper-card-controllet/cocreation-paper-card-controllet.html @@ -4,108 +4,208 @@ - + + @@ -119,23 +219,23 @@ properties: { name:{ type: String, - value: "text" + value: "" }, owner:{ type: String, - value: "text" + value: "" }, from:{ type: String, - value: "text" + value: "" }, to:{ type: String, - value: "text" + value: "" }, goal:{ type: String, - value: "text" + value: "" }, roomUrl: { type: String, @@ -144,28 +244,46 @@ roomType:{ type: String, value: undefined + }, + isOwner: { + type: Boolean, + value: false + }, + roomId:{ + type: Number, + value: undefined + }, + color:{ + type: String, + value: "" } }, + ready: function() { + var color = "#4CAF50"; + if(this.roomType == "knowledge") + color = "#2196F3"; + this.color = color; + }, + attached: function(){ + cocreation_room_ln["ln"] = ODE.user_language; + + this.$.goal.innerHTML = cocreation_room_ln["goal_" + cocreation_room_ln["ln"]]; + this.$.tooltip_goal.innerHTML = cocreation_room_ln["goal_" + cocreation_room_ln["ln"]]; + this.$.explore.innerHTML = cocreation_room_ln["explore_" + cocreation_room_ln["ln"]]; }, - _toggle: function(){ - var moreInfo = this.$.more_info; - var iconButton = Polymer.dom(event).localTarget; - iconButton.icon = moreInfo.opened ? 'expand-less' : 'expand-more'; - moreInfo.toggle(); + _handleDeleteClick: function(){ + this.fire("cocreation-paper-card-controllet_delete", {roomId: this.roomId}); }, - _onExplore: function(e){ + _onExplore: function(){ window.location = this.roomUrl; }, - checkRoomType: function(type){ - if(type == "knowledge") - return true; - else - return false; + _checkRoomType: function(type){ + return (type == "knowledge") ? true : false; } }) diff --git a/controllets/data-sevc-controllet/data-sevc-controllet.html b/controllets/data-sevc-controllet/data-sevc-controllet.html index 8c340e9..067fd17 100755 --- a/controllets/data-sevc-controllet/data-sevc-controllet.html +++ b/controllets/data-sevc-controllet/data-sevc-controllet.html @@ -47,7 +47,7 @@ listeners : { 'page-slider-controllet_selected' : '_updateSlider', - 'dataset-selection-controllet_data-url' : '_allowSecondStep', + 'select-dataset-controllet_data-url' : '_allowSecondStep', 'select-fields-controllet_selected-fields' : '_allowThirdStep', 'filters-controllet_filters': '_allowThirdStep', 'aggregators-controllet_aggregators': '_allowThirdStep', @@ -117,7 +117,7 @@ _allowSecondStep : function(e){ this.$.slider.chevronRight(false); -// + var f = Object.create(providerFactory); var provider = f.getProvider(e.detail.url); var dataUrl = provider.addLimit(e.detail.url); @@ -135,6 +135,8 @@ } else this.$.select_dataset.$.selected_url.invalid = true; + + this.$.select_dataset.showDatasetInfo(); }, _allowThirdStep : function(){ diff --git a/controllets/data-sevc-controllet/data-sevc-controllet_old.html b/controllets/data-sevc-controllet/data-sevc-controllet_old.html deleted file mode 100755 index 27f6702..0000000 --- a/controllets/data-sevc-controllet/data-sevc-controllet_old.html +++ /dev/null @@ -1,210 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/controllets/data-sevc-controllet/datalets-modifier-controllet.html b/controllets/data-sevc-controllet/datalets-modifier-controllet.html deleted file mode 100755 index 86caf36..0000000 --- a/controllets/data-sevc-controllet/datalets-modifier-controllet.html +++ /dev/null @@ -1,180 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/controllets/data-sevc-controllet/demo-data-sevc-controllet.html b/controllets/data-sevc-controllet/demo-data-sevc-controllet.html new file mode 100644 index 0000000..19dae8e --- /dev/null +++ b/controllets/data-sevc-controllet/demo-data-sevc-controllet.html @@ -0,0 +1,162 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/controllets/data-sevc-controllet/demo/index.html b/controllets/data-sevc-controllet/demo/index.html index ac38ffb..7731b2c 100755 --- a/controllets/data-sevc-controllet/demo/index.html +++ b/controllets/data-sevc-controllet/demo/index.html @@ -18,8 +18,10 @@ - + diff --git a/controllets/data-sevc-controllet/static/css/reset.css b/controllets/data-sevc-controllet/static/css/reset.css deleted file mode 100755 index 1914369..0000000 --- a/controllets/data-sevc-controllet/static/css/reset.css +++ /dev/null @@ -1,78 +0,0 @@ -::content html { - color: #000; - background: #FFF; -} - -::content body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, -h4, h5, h6, pre, code, form, fieldset, legend, -input, button, textarea, p, blockquote, th, td { - margin: 0; - padding: 0; -} - -::content table { - border-collapse: collapse; - border-spacing: 0; -} - -::content fieldset, img { - border: 0; -} - -::content address, caption, cite, code, dfn, em, strong, -th, var, optgroup { - font-style: inherit; - font-weight: inherit; -} - -::content del, ins { - text-decoration: none; -} - -::content li { - list-style: none; -} - -::content caption, th { - text-align: left; -} - -::content h1, h2, h3, h4, h5, h6 { - font-size: 100%; - font-weight: normal; -} - -::content q:before, q:after { - content: ''; -} - -::content abbr, acronym { - border: 0; - font-variant: normal; -} - -::content sup { - vertical-align: baseline; -} - -::content sub { - vertical-align: baseline; -} - -/*because legend doesn't inherit in IE */ -::content legend { - color: #000; -} - -::content input, button, textarea, select, optgroup, option { - font-family: inherit; - font-size: inherit; - font-style: inherit; - font-weight: inherit; -} - -/*@purpose To enable resizing for IE */ -/*@branch For IE6-Win, IE7-Win */ -::content input, button, textarea, select { - *font-size: 100%; -} \ No newline at end of file diff --git a/controllets/data-sevc-controllet/static/images/UnderConstruction.png b/controllets/data-sevc-controllet/static/images/UnderConstruction.png deleted file mode 100755 index fd03947..0000000 --- a/controllets/data-sevc-controllet/static/images/UnderConstruction.png +++ /dev/null diff --git a/controllets/data-sevc-controllet/static/images/or.png b/controllets/data-sevc-controllet/static/images/or.png deleted file mode 100755 index 5b62d26..0000000 --- a/controllets/data-sevc-controllet/static/images/or.png +++ /dev/null diff --git a/controllets/data-table-controllet/data-table-controllet.html b/controllets/data-table-controllet/data-table-controllet.html index 9729380..21dd851 100644 --- a/controllets/data-table-controllet/data-table-controllet.html +++ b/controllets/data-table-controllet/data-table-controllet.html @@ -40,15 +40,20 @@ } paper-icon-button.order { - height: 24px; - width: 24px; + height: 40px; + width: 40px; + padding: 4px; + cursor: pointer; } paper-icon-button.warning { - height: 24px; - width: 24px; + height: 40px; + width: 40px; + padding: 4px; color: #FFEB3B; + --paper-icon-button-ink-color: #FFEB3B; + cursor: help; } @@ -77,18 +82,22 @@ #data_table_container #header { background: #B6B6B6; - height: 24px; - padding: 12px; + height: 40px; + padding: 4px; text-align: center; font-weight: 700; cursor: help; } + #data_table_container #header * { + line-height: 40px !important; + } + #data_table_container table { height: calc(100% - 96px); width: 100%; - border-spacing: 0px; + border-spacing: 0; } #data_table_container tbody { @@ -103,22 +112,35 @@ #data_table_container th, #data_table_container td{ - height: 24px; - padding: 12px; + height: 32px; + /*padding: 12px;*/ text-align: center; - max-width: 256px; - min-width: 156px; + /*max-width: 256px;*/ + /*min-width: 156px;*/ overflow: hidden; white-space: nowrap; text-overflow: ellipsis; width: 1%; } + #data_table_container td { + font-size: 14px; + padding: 4px 12px; + max-width: calc(360px - 24px); + } + #data_table_container th { background: #2196F3; color: #FFFFFF; font-weight: 700; cursor: help; + border-right: 2px solid #FFFFFF; + height: 40px; + padding: 4px 12px; + } + + #data_table_container tr :nth-last-child(2) { + border-right: 0; } #data_table_container th, @@ -128,17 +150,13 @@ #data_table_container th .th_label { display: inline-block; - max-width: calc(100% - 48px - 8px); + /*max-width: calc(100% - 48px - 8px);*/ vertical-align: middle; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; line-height: 24px;/**/ - } - - #data_table_container td { - font-size: 14px; - padding: 4px; + max-width: calc(360px - 114px); } #data_table_container #footer { @@ -202,10 +220,10 @@ @@ -223,10 +241,11 @@ @@ -340,7 +359,7 @@ setData : function(data) { var converter = new DataTypeConverter(); - var result = converter.inferJsonDataType(data, ["*"]); + var result = converter.inferJsonDataType(data, ["*"], { language: ln["localization"] } ); result = converter.cast(result); this.fields = ArrayUtils.toFieldsArray(result.types); this.data = result.dataset; diff --git a/controllets/datalet-selection-controllet/datalet-selection-controllet.html b/controllets/datalet-selection-controllet/datalet-selection-controllet.html deleted file mode 100755 index ae89580..0000000 --- a/controllets/datalet-selection-controllet/datalet-selection-controllet.html +++ /dev/null @@ -1,953 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/controllets/datalet-selection-controllet/demo/index.html b/controllets/datalet-selection-controllet/demo/index.html deleted file mode 100755 index 7e36d6f..0000000 --- a/controllets/datalet-selection-controllet/demo/index.html +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/controllets/dataset-selection-controllet/dataset-selection-controllet.html b/controllets/dataset-selection-controllet/dataset-selection-controllet.html deleted file mode 100755 index f9ef224..0000000 --- a/controllets/dataset-selection-controllet/dataset-selection-controllet.html +++ /dev/null @@ -1,389 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/controllets/dataset-selection-controllet/demo/index.html b/controllets/dataset-selection-controllet/demo/index.html deleted file mode 100755 index 5f43f5d..0000000 --- a/controllets/dataset-selection-controllet/demo/index.html +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/controllets/dataset-selection-controllet/paper-input-search.html b/controllets/dataset-selection-controllet/paper-input-search.html deleted file mode 100755 index 411b5d9..0000000 --- a/controllets/dataset-selection-controllet/paper-input-search.html +++ /dev/null @@ -1,444 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/controllets/dataset-table-controllet/dataset-table-controllet.html b/controllets/dataset-table-controllet/dataset-table-controllet.html index b407135..0441a63 100644 --- a/controllets/dataset-table-controllet/dataset-table-controllet.html +++ b/controllets/dataset-table-controllet/dataset-table-controllet.html @@ -434,7 +434,10 @@ //2nd loop will extract each column and convert it in string comma-seprated for (var index in arrData[i]) { - row += arrData[i][index] + ','; + if(typeof arrData[i][index] == 'string') + row += '"' + arrData[i][index].replace('"', '""') + '",'; + else + row += arrData[i][index] + ','; } row.slice(0, row.length - 1); diff --git a/controllets/datasets-list-controllet/datasets-list-controllet.html b/controllets/datasets-list-controllet/datasets-list-controllet.html new file mode 100644 index 0000000..e28f6d4 --- /dev/null +++ b/controllets/datasets-list-controllet/datasets-list-controllet.html @@ -0,0 +1,472 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/controllets/datasets-list-controllet/demo/index.html b/controllets/datasets-list-controllet/demo/index.html new file mode 100644 index 0000000..59bcd50 --- /dev/null +++ b/controllets/datasets-list-controllet/demo/index.html @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+ + + + + + diff --git a/controllets/document-card-controllet/spreadsheet-card-controllet.html b/controllets/document-card-controllet/spreadsheet-card-controllet.html index b19a7f9..13395b7 100644 --- a/controllets/document-card-controllet/spreadsheet-card-controllet.html +++ b/controllets/document-card-controllet/spreadsheet-card-controllet.html @@ -114,6 +114,14 @@ display: none; } + button#delete-sheet { + display: none; + } + + button#rename-sheet{ + display: none; + } + diff --git a/controllets/expert-query-controllet/expert-query-controllet.html b/controllets/expert-query-controllet/expert-query-controllet.html index 4c03d5f..2d24ca4 100755 --- a/controllets/expert-query-controllet/expert-query-controllet.html +++ b/controllets/expert-query-controllet/expert-query-controllet.html @@ -359,7 +359,8 @@ .replace('WHERE', '

WHERE') .replace('GROUP BY', '

GROUP BY') .replace(/\[/g, '') - .replace(/\]/g, ''); + .replace(/\]/g, '') + .replace(/`/g, ''); else this.$.query_container.innerHTML = ""; } diff --git a/controllets/select-dataset-controllet/demo-select-dataset-controllet.html b/controllets/select-dataset-controllet/demo-select-dataset-controllet.html new file mode 100644 index 0000000..5f8fb34 --- /dev/null +++ b/controllets/select-dataset-controllet/demo-select-dataset-controllet.html @@ -0,0 +1,495 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/controllets/select-dataset-controllet/select-dataset-controllet.html b/controllets/select-dataset-controllet/select-dataset-controllet.html index 3dcc522..f585940 100755 --- a/controllets/select-dataset-controllet/select-dataset-controllet.html +++ b/controllets/select-dataset-controllet/select-dataset-controllet.html @@ -1,413 +1,270 @@ + - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - +