Commit f689abd6273c0435fc3ed96c03ef2e2bae723365

Authored by Luigi Serra
1 parent 69872d75

updates

bower_components/jsdatachecker/.bower.json
1 { 1 {
2 - "name": "jsdatachecker",  
3 - "version": "0.1.1",  
4 - "homepage": "https://github.com/donpir/jsdatachecker", 2 + "name": "JSDataChecker",
  3 + "version": "0.0.9",
  4 + "homepage": "https://github.com/donpir/JSDataChecker",
5 "authors": [ 5 "authors": [
6 "'Donato Pirozzi <'donatopirozzi@gmail.com'>" 6 "'Donato Pirozzi <'donatopirozzi@gmail.com'>"
7 ], 7 ],
@@ -22,14 +22,14 @@ @@ -22,14 +22,14 @@
22 "polywc": "https://github.com/donpir/polywc.git#master" 22 "polywc": "https://github.com/donpir/polywc.git#master"
23 }, 23 },
24 "private": false, 24 "private": false,
25 - "_release": "0.1.1", 25 + "_release": "0.0.9",
26 "_resolution": { 26 "_resolution": {
27 "type": "version", 27 "type": "version",
28 - "tag": "v0.1.1",  
29 - "commit": "60887fda0d7e7388c5d682228ee1288dd7bcdd09" 28 + "tag": "v0.0.9",
  29 + "commit": "277c51efeee4daa0bd11051de022975ba86f47fa"
30 }, 30 },
31 "_source": "https://github.com/donpir/JSDataChecker.git", 31 "_source": "https://github.com/donpir/JSDataChecker.git",
32 - "_target": "~0.1.1", 32 + "_target": "~0.0.9",
33 "_originalSource": "jsdatachecker", 33 "_originalSource": "jsdatachecker",
34 "_direct": true 34 "_direct": true
35 } 35 }
36 \ No newline at end of file 36 \ No newline at end of file
bower_components/jsdatachecker/README.md
@@ -3,18 +3,6 @@ JavaScript Library to read dataset content (e.g., Open Data), infer data types, @@ -3,18 +3,6 @@ JavaScript Library to read dataset content (e.g., Open Data), infer data types,
3 3
4 In details, it analysis the json (specified paths) to infer the data type. In addition, when request (via code) the library converts the json data based on the inferred type. 4 In details, it analysis the json (specified paths) to infer the data type. In addition, when request (via code) the library converts the json data based on the inferred type.
5 5
6 -Recognised basic types:  
7 - - Text;  
8 - - Number;  
9 - - Date;  
10 - - Object;  
11 - - Null.  
12 -  
13 -Recognised types:  
14 - - Geographic coordinates;  
15 - - JSON;  
16 - - GEOJSON.  
17 -  
18 ## Documentation 6 ## Documentation
19 7
20 See wiki pages [here](https://github.com/donpir/JSDataChecker/wiki). 8 See wiki pages [here](https://github.com/donpir/JSDataChecker/wiki).
bower_components/jsdatachecker/bower.json
1 { 1 {
2 - "name": "jsdatachecker",  
3 - "version": "v0.1.1",  
4 - "homepage": "https://github.com/donpir/jsdatachecker", 2 + "name": "JSDataChecker",
  3 + "version": "v0.0.9",
  4 + "homepage": "https://github.com/donpir/JSDataChecker",
5 "authors": [ 5 "authors": [
6 "'Donato Pirozzi <'donatopirozzi@gmail.com'>" 6 "'Donato Pirozzi <'donatopirozzi@gmail.com'>"
7 ], 7 ],
bower_components/jsdatachecker/jsdatachecker.min.js
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<arrHierarchyTypes.length,curType=arrHierarchyTypes[i];i++){var numItemsOfCurType=fieldType._inferredTypes.hasOwnProperty(curType)?fieldType._inferredTypes[curType]:0;if(lastFieldType.lastType=curType,lastFieldType.lastTypeCounter+=numItemsOfCurType,lastFieldType.typeConfidence=lastFieldType.lastTypeCounter/fieldType.numOfItems,lastFieldType.typeConfidence>=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;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,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;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 curKey=sProcessedKeys+(0==sProcessedKeys.length?"":",")+key,fieldType=ArrayUtils.TestAndInitializeKey(fieldsType,curKey,{name:curKey,_inferredTypes:[],_inferredSubTypes:[],_inferredValues:[],numOfItems:0});fieldType.numOfItems++;var inferredType=_processInferType(item);ArrayUtils.TestAndIncrement(fieldType._inferredTypes,inferredType.name),inferredType===DataTypeConverter.TYPES.TEXT&&ArrayUtils.TestAndIncrement(fieldType._inferredValues,item);var inferredSubType=_processInferSubType(item);null!=inferredSubType&&"undefined"!=typeof inferredSubType&&ArrayUtils.TestAndIncrement(fieldType._inferredSubTypes,inferredSubType.name)}),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="";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});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};  
2 \ No newline at end of file 1 \ No newline at end of file
  2 +function ArrayUtils(){}function DataTypeConverter(){this._fields=[],this._numOfRows=0}function DataTypesUtils(){}function DataTypeHierarchy(){}ArrayUtils.TestAndSet=function(arr,key,object){return"undefined"==typeof arr?null:0==Array.isArray(arr)?null:("undefined"==typeof arr[key]&&(arr[key]=object),arr[key])},ArrayUtils.TestAndInitializeKey=function(obj,key,value){return"undefined"==typeof obj?null:("undefined"==typeof obj[key]&&(obj[key]=value),obj[key])},ArrayUtils.TestAndIncrement=function(arr,key){var exists=arr[key];return"undefined"==typeof exists&&(arr[key]=0),arr[key]++,arr},ArrayUtils.toFieldsArray=function(obj){var fields=[];return ArrayUtils.IteratorOverKeys(obj,function(field,key){field.key=key,fields.push(field)}),fields},ArrayUtils.IteratorOverKeys=function(arr,callback){for(var property in arr)if(arr.hasOwnProperty(property)){var item=arr[property];callback(item,property)}},ArrayUtils.FindMinMax=function(arr,fncompare){var max1=null,max2=null;for(var key in arr)null==max1||fncompare(arr[key],max1.value)?(max2=max1,max1={index:-1,key:key,value:arr[key]}):(null==max2||fncompare(arr[key],max2.value))&&(max2={index:-1,key:key,value:arr[key]});return{first:max1,second:max2}},ArrayUtils.isArray=function(arr){return Array.isArray(arr)?arr.length>0:!1},DataTypeConverter.TYPES={TEXT:{value:0,name:"TEXT"},CODE:{value:1,name:"CODE"},NUMBER:{value:2,name:"NUMBER"},OBJECT:{value:3,name:"OBJECT"},BOOL:{value:5,name:"BOOL"},CONST:{value:6,name:"CONST"},CATEGORY:{value:7,name:"CATEGORY"},DATETIME:{value:8,name:"DATETIME"},EMPTY:{value:101,name:"NULL"}},DataTypeConverter.SUBTYPES={GEOCOORDINATE:{value:1e3,name:"GEOCOORDINATE"},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;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;var isnumber=DataTypesUtils.FilterFloat(value);return isNaN(isnumber)!==!0?isnumber>=-90&&90>=isnumber&&DataTypesUtils.DecimalPlaces(isnumber)>=5?DataTypeConverter.SUBTYPES.GEOCOORDINATE:isnumber>=-180&&180>=isnumber&&DataTypesUtils.DecimalPlaces(isnumber)>=5?DataTypeConverter.SUBTYPES.GEOCOORDINATE:null:null},_filterBasedOnThreshold=function(metadata,threshold){return ArrayUtils.IteratorOverKeys(metadata.types,function(fieldType,key){if(!(fieldType.typeConfidence>=threshold)){var arrHierarchyTypes=DataTypeHierarchy.HIERARCHY[fieldType.type],lastFieldType={lastType:arrHierarchyTypes[0],lastTypeCounter:fieldType._inferredTypes[arrHierarchyTypes[0]],typeConfidence:0};lastFieldType.typeConfidence=lastFieldType.lastTypeCounter/fieldType.numOfItems;for(var curType,i=1;i<arrHierarchyTypes.length,curType=arrHierarchyTypes[i];i++){var numItemsOfCurType=fieldType._inferredTypes.hasOwnProperty(curType)?fieldType._inferredTypes[curType]:0;if(lastFieldType.lastType=curType,lastFieldType.lastTypeCounter+=numItemsOfCurType,lastFieldType.typeConfidence=lastFieldType.lastTypeCounter/fieldType.numOfItems,lastFieldType.typeConfidence>=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;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,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;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 curKey=sProcessedKeys+(0==sProcessedKeys.length?"":",")+key,fieldType=ArrayUtils.TestAndInitializeKey(fieldsType,curKey,{name:curKey,_inferredTypes:[],_inferredSubTypes:[],_inferredValues:[],numOfItems:0});fieldType.numOfItems++;var inferredType=_processInferType(item);ArrayUtils.TestAndIncrement(fieldType._inferredTypes,inferredType.name),inferredType===DataTypeConverter.TYPES.TEXT&&ArrayUtils.TestAndIncrement(fieldType._inferredValues,item);var inferredSubType=_processInferSubType(item);null!=inferredSubType&&"undefined"!=typeof inferredSubType&&ArrayUtils.TestAndIncrement(fieldType._inferredSubTypes,inferredSubType.name)}),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="";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});var metadata={dataset:json,fieldKeys:fieldKeys,types:fieldsType,qualityIndex:quality,warningsTextual:warningsTextual};return _filterBasedOnThreshold(metadata,options.thresholdConfidence),metadata},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.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};
3 \ No newline at end of file 3 \ No newline at end of file
bower_components/jsdatachecker/src/DataTypeConverter.js
@@ -43,16 +43,11 @@ DataTypeConverter.TYPES = { @@ -43,16 +43,11 @@ DataTypeConverter.TYPES = {
43 43
44 DataTypeConverter.SUBTYPES = { 44 DataTypeConverter.SUBTYPES = {
45 GEOCOORDINATE : { value: 1000, name: "GEOCOORDINATE" }, 45 GEOCOORDINATE : { value: 1000, name: "GEOCOORDINATE" },
46 - GEOJSON : { value: 1001, name: "GEOJSON" },  
47 -  
48 - PERCENTAGE : { value: 1100, name: "PERCENTAGE" },  
49 - LATITUDE : { value: 1101, name: "LATITUDE" },  
50 - LONGITUDE : { value: 1102, name: "LONGITUDE" } 46 + PERCENTAGE : { value: 1000, name: "PERCENTAGE" },
  47 + LATITUDE : { value: 1001, name: "LATITUDE" },
  48 + LONGITUDE : { value: 1002, name: "LONGITUDE" }
51 }; 49 };
52 50
53 -DataTypeConverter.GEOJSONTYPES = [ "Point", "MultiPoint", "LineString",  
54 - "MultiLineString", "Polygon", "MultiPolygon", "GeometryCollection" ];  
55 -  
56 DataTypeConverter.prototype = (function () { 51 DataTypeConverter.prototype = (function () {
57 52
58 /*** 53 /***
@@ -227,20 +222,6 @@ DataTypeConverter.prototype = (function () { @@ -227,20 +222,6 @@ DataTypeConverter.prototype = (function () {
227 var _processInferSubType = function (value) { 222 var _processInferSubType = function (value) {
228 if (value === null || typeof value === 'undefined') return null; 223 if (value === null || typeof value === 'undefined') return null;
229 224
230 - //GEOCOORDINATE  
231 - if (Array.isArray(value) && value.length == 2) {//It recognises the LAT LNG as array of two values.  
232 - //Checks if the two array's values are numbers.  
233 - if ( DataTypesUtils.FilterFloat(value[0]) != NaN && DataTypesUtils.FilterFloat(value[1]) != NaN )  
234 - if (DataTypesUtils.DecimalPlaces(value[0]) > 4 && DataTypesUtils.DecimalPlaces(value[1]) > 4 )  
235 - return DataTypeConverter.SUBTYPES.GEOCOORDINATE;  
236 - }//EndIf.  
237 -  
238 - if (typeof value === 'string') {  
239 - var split = value.split(",");  
240 - if (DataTypesUtils.IsLatLng(split[0]) && DataTypesUtils.IsLatLng(split[1]))  
241 - return DataTypeConverter.SUBTYPES.GEOCOORDINATE;  
242 - }  
243 -  
244 //Try to parse the float. 225 //Try to parse the float.
245 var isnumber = DataTypesUtils.FilterFloat(value); 226 var isnumber = DataTypesUtils.FilterFloat(value);
246 if (isNaN(isnumber) !== true) {//It is a number. 227 if (isNaN(isnumber) !== true) {//It is a number.
@@ -259,14 +240,6 @@ DataTypeConverter.prototype = (function () { @@ -259,14 +240,6 @@ DataTypeConverter.prototype = (function () {
259 return null; 240 return null;
260 } 241 }
261 242
262 - //Try to parse GEOJSON.  
263 - if (typeof value === 'object' && value.hasOwnProperty('type')) {  
264 - //Check the type variable.  
265 - var geotype = value.type;  
266 - var isincluded = DataTypeConverter.GEOJSONTYPES.includes(geotype);  
267 - if (isincluded) return DataTypeConverter.SUBTYPES.GEOJSON;  
268 - }  
269 -  
270 return null; 243 return null;
271 };//EndFunction. 244 };//EndFunction.
272 245
@@ -275,9 +248,6 @@ DataTypeConverter.prototype = (function () { @@ -275,9 +248,6 @@ DataTypeConverter.prototype = (function () {
275 if (fieldType.typeConfidence >= threshold) return; 248 if (fieldType.typeConfidence >= threshold) return;
276 249
277 var arrHierarchyTypes = DataTypeHierarchy.HIERARCHY[fieldType.type]; 250 var arrHierarchyTypes = DataTypeHierarchy.HIERARCHY[fieldType.type];
278 - if (arrHierarchyTypes == null)  
279 - return metadata;  
280 -  
281 var lastFieldType = { lastType: arrHierarchyTypes[0], 251 var lastFieldType = { lastType: arrHierarchyTypes[0],
282 lastTypeCounter: fieldType._inferredTypes[arrHierarchyTypes[0]], 252 lastTypeCounter: fieldType._inferredTypes[arrHierarchyTypes[0]],
283 typeConfidence: 0 }; 253 typeConfidence: 0 };
@@ -577,15 +547,6 @@ DataTypeConverter.prototype = (function () { @@ -577,15 +547,6 @@ DataTypeConverter.prototype = (function () {
577 */ 547 */
578 inferDataTypeOfValue: function (value) { 548 inferDataTypeOfValue: function (value) {
579 return _processInferType(value); 549 return _processInferType(value);
580 - },//EndFunction.  
581 -  
582 - /**  
583 - * Given in input a value, the function infers the data type.  
584 - * @param value  
585 - * @returns {*}  
586 - */  
587 - inferDataSubTypeOfValue: function (value) {  
588 - return _processInferSubType(value);  
589 }//EndFunction. 550 }//EndFunction.
590 551
591 }; 552 };
bower_components/jsdatachecker/src/DataTypesUtils.js
@@ -122,10 +122,4 @@ DataTypesUtils.DecimalPlaces = function (num) { @@ -122,10 +122,4 @@ DataTypesUtils.DecimalPlaces = function (num) {
122 (match[1] ? match[1].length : 0) 122 (match[1] ? match[1].length : 0)
123 // Adjust for scientific notation. 123 // Adjust for scientific notation.
124 - (match[2] ? +match[2] : 0)); 124 - (match[2] ? +match[2] : 0));
125 -}//EndFunction.  
126 -  
127 -DataTypesUtils.IsLatLng = function (num) {  
128 - if (DataTypesUtils.FilterFloat(num) == NaN) return false;  
129 - if (DataTypesUtils.DecimalPlaces(num) > 4) return true;  
130 - return false;  
131 }//EndFunction. 125 }//EndFunction.
132 \ No newline at end of file 126 \ No newline at end of file
controllets/cocreation-paper-card-controllet/cocreation-paper-card-controllet.html
@@ -75,6 +75,17 @@ @@ -75,6 +75,17 @@
75 background: #2196F3; 75 background: #2196F3;
76 } 76 }
77 77
  78 + .delete{
  79 + position: absolute;
  80 + right: 14px;
  81 + top: 23px;
  82 + background: #2196F3;
  83 + --iron-icon-height: 18px;
  84 + --iron-icon-width: 18px;
  85 + width: 24px;
  86 + height: 24px;
  87 + }
  88 +
78 </style> 89 </style>
79 90
80 91
@@ -94,6 +105,9 @@ @@ -94,6 +105,9 @@
94 <template is="dom-if" if="{{checkRoomType(roomType)}}"> 105 <template is="dom-if" if="{{checkRoomType(roomType)}}">
95 <paper-fab mini disabled icon="description" class="badge knowledge"></paper-fab> 106 <paper-fab mini disabled icon="description" class="badge knowledge"></paper-fab>
96 </template> 107 </template>
  108 + <template is="dom-if" if="{{isOwner}}">
  109 + <paper-fab class="delete" mini icon="delete" on-click="_handleDeleteClick" style="background-color: #b6b6b6;"></paper-fab>
  110 + </template>
97 </div> 111 </div>
98 </div> 112 </div>
99 <div class="card-actions"> 113 <div class="card-actions">
@@ -144,6 +158,14 @@ @@ -144,6 +158,14 @@
144 roomType:{ 158 roomType:{
145 type: String, 159 type: String,
146 value: undefined 160 value: undefined
  161 + },
  162 + isOwner: {
  163 + type: Boolean,
  164 + value: false
  165 + },
  166 + roomId:{
  167 + type: Number,
  168 + value: undefined
147 } 169 }
148 }, 170 },
149 171
@@ -157,15 +179,16 @@ @@ -157,15 +179,16 @@
157 moreInfo.toggle(); 179 moreInfo.toggle();
158 }, 180 },
159 181
  182 + _handleDeleteClick: function(e){
  183 + this.fire("cocreation-paper-card-controllet_delete", {roomId: this.roomId});
  184 + },
  185 +
160 _onExplore: function(e){ 186 _onExplore: function(e){
161 window.location = this.roomUrl; 187 window.location = this.roomUrl;
162 }, 188 },
163 189
164 checkRoomType: function(type){ 190 checkRoomType: function(type){
165 - if(type == "knowledge")  
166 - return true;  
167 - else  
168 - return false; 191 + return (type == "knowledge") ? true : false;
169 } 192 }
170 }) 193 })
171 </script> 194 </script>
controllets/document-card-controllet/spreadsheet-card-controllet.html
@@ -114,6 +114,14 @@ @@ -114,6 +114,14 @@
114 display: none; 114 display: none;
115 } 115 }
116 116
  117 + button#delete-sheet {
  118 + display: none;
  119 + }
  120 +
  121 + button#rename-sheet{
  122 + display: none;
  123 + }
  124 +
117 </style> 125 </style>
118 126
119 127