Commit c377c98f3b3473e525df7ae770d51c689f0a04aa

Authored by mwasiluk
2 parents 93a54ea8 38120605

Merge remote-tracking branch 'upstream/master'

Showing 65 changed files with 2886 additions and 6212 deletions
.htaccess 0 → 100644
  1 +RewriteEngine On
  2 +RewriteCond %{REQUEST_FILENAME} !-f
  3 +RewriteRule ^ index.php [QSA,L]
0 4 \ No newline at end of file
... ...
alasql-utility/alasql-utility.js
... ... @@ -125,7 +125,8 @@ function _addParenthesis (fields) {
125 125 }
126 126  
127 127 function _normalizeField (field) {
128   - return "[" + field + "]";
  128 + return "`" + field + "`";
  129 + //return "[" + field + "]";
129 130 }
130 131  
131 132 function alasql_transformData (data, fields, round) {
... ...
bower_components/jsdatachecker/.bower.json
1 1 {
2 2 "name": "jsdatachecker",
3   - "version": "0.1.1",
  3 + "version": "0.1.3",
4 4 "homepage": "https://github.com/donpir/jsdatachecker",
5 5 "authors": [
6 6 "'Donato Pirozzi <'donatopirozzi@gmail.com'>"
... ... @@ -19,17 +19,16 @@
19 19 "polymer": "Polymer/polymer#1.2.0",
20 20 "qunit": "~1.22.0",
21 21 "csvjson": "0.1.1",
22   - "polywc": "https://github.com/donpir/polywc.git#master"
  22 + "polywc-data-table": "https://github.com/donpir/polywc-data-table.git#master"
23 23 },
24 24 "private": false,
25   - "_release": "0.1.1",
  25 + "_release": "0.1.3",
26 26 "_resolution": {
27 27 "type": "version",
28   - "tag": "v0.1.1",
29   - "commit": "60887fda0d7e7388c5d682228ee1288dd7bcdd09"
  28 + "tag": "v0.1.3",
  29 + "commit": "186392b9d8576e98e269150ab2a88562215a2b2a"
30 30 },
31 31 "_source": "https://github.com/donpir/JSDataChecker.git",
32   - "_target": "~0.1.1",
33   - "_originalSource": "jsdatachecker",
34   - "_direct": true
  32 + "_target": "~0.1.2",
  33 + "_originalSource": "jsdatachecker"
35 34 }
36 35 \ No newline at end of file
... ...
bower_components/jsdatachecker/bower.json
1 1 {
2 2 "name": "jsdatachecker",
3   - "version": "v0.1.1",
  3 + "version": "v0.1.3",
4 4 "homepage": "https://github.com/donpir/jsdatachecker",
5 5 "authors": [
6 6 "'Donato Pirozzi <'donatopirozzi@gmail.com'>"
... ... @@ -19,7 +19,7 @@
19 19 "polymer": "Polymer/polymer#1.2.0",
20 20 "qunit": "~1.22.0",
21 21 "csvjson": "0.1.1",
22   - "polywc": "https://github.com/donpir/polywc.git#master"
  22 + "polywc-data-table": "https://github.com/donpir/polywc-data-table.git#master"
23 23 },
24 24 "private": false
25 25 }
... ...
bower_components/jsdatachecker/build.cmd
1 1 del jsdatachecker.min.js
2   -uglifyjs src\ArrayUtils.js src\DataTypeConverter.js src\DataTypesUtils.js src\DataTypeHierarchy.js --compress -o jsdatachecker.min.js
3 2 \ No newline at end of file
  3 +uglifyjs src\ArrayUtils.js src\DataTypeConverter.js src\DataTypesUtils.js src\DataTypeHierarchy.js src\langs.js --compress -o jsdatachecker.min.js
4 4 \ No newline at end of file
... ...
bower_components/jsdatachecker/jsdatachecker.min.js
1   -function ArrayUtils(){}function DataTypeConverter(){this._fields=[],this._numOfRows=0}function DataTypesUtils(){}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 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={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<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},_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;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,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<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++}}var _numOfRows=0;ArrayUtils.IteratorOverKeys(fieldsType,function(fieldType){fieldType.numOfItems>_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.idx<idxComma.idx?idxDot:idxComma;var idxLastDot={idx:value.lastIndexOf("."),sym:"."},idxLastComma={idx:value.lastIndexOf(","),sym:","},idxLast={};idxLast=-1==idxLastDot.idx?idxLastComma:-1==idxLastComma.idx?idxLastDot:idxLastDot.idx>idxLastComma.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;i<splitted.length,str=splitted[i];i++)if("."==str)numOfDots++;else if(","==str)numOfComma++;else if(0==/^(0|([1-9][0-9]*))$/g.test(str))return NaN;var lastValue=splitted[splitted.length-1];if("."==lastValue||","==lastValue||0==lastValue.length)return NaN;if(-1==idxFirst.idx&&-1==idxLast.idx)return DataTypesUtils.FilterFloat(value);if(idxFirst.idx==idxLast.idx&&"."==idxFirst.sym)return Number(value);if(idxFirst.idx==idxLast.idx&&","==idxFirst.sym){var nval=value.replace(",",".");return Number(nval)}return 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};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"}};
3 3 \ No newline at end of file
... ...
bower_components/jsdatachecker/src/DataTypeConverter.js
... ... @@ -25,33 +25,39 @@ function DataTypeConverter() {
25 25 };//EndConstructor.
26 26  
27 27 DataTypeConverter.TYPES = {
28   - TEXT : { value: 0, name: "TEXT" },
29   - CODE : { value: 1, name: "CODE"},
  28 + EMPTY : { value: 0, name: "NULL"},
30 29  
  30 + TEXT : { value: 1, name: "TEXT" },
31 31 NUMBER : { value: 2, name: "NUMBER" },
32 32 OBJECT : { value: 3, name: "OBJECT" },
33   -
34   -
35   - BOOL : { value: 5, name: "BOOL"},
36   - CONST : { value: 6, name: "CONST" },
37   - CATEGORY : { value: 7, name: "CATEGORY" },
38   -
39   - DATETIME : { value: 8, name: "DATETIME" },
40   -
41   - EMPTY : { value: 101, name: "NULL" }
  33 + DATETIME : { value: 4, name: "DATETIME" }
42 34 };
43 35  
44 36 DataTypeConverter.SUBTYPES = {
45 37 GEOCOORDINATE : { value: 1000, name: "GEOCOORDINATE" },
46 38 GEOJSON : { value: 1001, name: "GEOJSON" },
  39 + BOOL : { value: 1002, name: "BOOL"},
  40 + CONST : { value: 1003, name: "CONST" },
  41 + CATEGORY : { value: 1004, name: "CATEGORY" },
47 42  
48 43 PERCENTAGE : { value: 1100, name: "PERCENTAGE" },
49 44 LATITUDE : { value: 1101, name: "LATITUDE" },
50 45 LONGITUDE : { value: 1102, name: "LONGITUDE" }
  46 +
  47 + /*CODE : { value: 2000, name: "CODE"},*/
  48 +};
  49 +
  50 +DataTypeConverter.LANGS = {
  51 + EN : { value: 1000, name: "EN" },
  52 + IT : { value: 1001, name: "IT" },
  53 + FR : { value: 1100, name: "FR" },
  54 + NL : { value: 1101, name: "NL" }
51 55 };
52 56  
  57 +
53 58 DataTypeConverter.GEOJSONTYPES = [ "Point", "MultiPoint", "LineString",
54   - "MultiLineString", "Polygon", "MultiPolygon", "GeometryCollection" ];
  59 + "MultiLineString", "Polygon", "MultiPolygon", "GeometryCollection", "Feature",
  60 + "FeatureCollection" ];
55 61  
56 62 DataTypeConverter.prototype = (function () {
57 63  
... ... @@ -116,6 +122,10 @@ DataTypeConverter.prototype = (function () {
116 122  
117 123 var _analyseDataTypes = function(fields) {
118 124 ArrayUtils.IteratorOverKeys(fields, function(field) {
  125 +
  126 +
  127 + /*
  128 + //TODO: removed CODE, I don't know whether it must be inserted
119 129 if (field._inferredTypes[DataTypeConverter.TYPES.CODE.name]) {
120 130 var confidence = field._inferredTypes[DataTypeConverter.TYPES.CODE.name] / field.numOfItems;
121 131 var _numericalInferredType = field._inferredTypes[DataTypeConverter.TYPES.NUMBER.name];
... ... @@ -124,7 +134,7 @@ DataTypeConverter.prototype = (function () {
124 134 field.type = DataTypeConverter.TYPES.CODE.name;
125 135 field.typeConfidence = confidence;
126 136 return;
127   - }
  137 + }*/
128 138  
129 139 //Infers the field TYPE.
130 140 var max = ArrayUtils.FindMinMax(field._inferredTypes, function (curval, lastval) {
... ... @@ -194,13 +204,9 @@ DataTypeConverter.prototype = (function () {
194 204 if (typeof value === 'object')
195 205 return DataTypeConverter.TYPES.OBJECT;
196 206  
197   - //If the value starts with a zero and contains all numbers, it is
198   - //inferred as textual content.
199   - if (/^0[0-9]+$/.test(value))
200   - return DataTypeConverter.TYPES.CODE;
201   -
202 207 //Try to parse the float.
203   - var isnumber = DataTypesUtils.FilterFloat(value);
  208 + //var isnumber = DataTypesUtils.FilterFloat(value);
  209 + var isnumber = DataTypesUtils.FilterNumber(value);
204 210 if (isNaN(isnumber) !== true) {//It is a number.
205 211 //If the number ranges from -90.0 to 90.0, the value is marked as Latitude.
206 212 //if (-90.0 <= isnumber && isnumber <= 90.0 && _dataTypesUtils.decimalPlaces(isnumber) >= 5)
... ... @@ -230,19 +236,22 @@ DataTypeConverter.prototype = (function () {
230 236 //GEOCOORDINATE
231 237 if (Array.isArray(value) && value.length == 2) {//It recognises the LAT LNG as array of two values.
232 238 //Checks if the two array's values are numbers.
233   - if ( DataTypesUtils.FilterFloat(value[0]) != NaN && DataTypesUtils.FilterFloat(value[1]) != NaN )
  239 + //if ( DataTypesUtils.FilterFloat(value[0]) != NaN && DataTypesUtils.FilterFloat(value[1]) != NaN )
  240 + if ( DataTypesUtils.FilterNumber(value[0]) != NaN && DataTypesUtils.FilterNumber(value[1]) != NaN )
234 241 if (DataTypesUtils.DecimalPlaces(value[0]) > 4 && DataTypesUtils.DecimalPlaces(value[1]) > 4 )
235 242 return DataTypeConverter.SUBTYPES.GEOCOORDINATE;
236 243 }//EndIf.
237 244  
238 245 if (typeof value === 'string') {
239 246 var split = value.split(",");
240   - if (DataTypesUtils.IsLatLng(split[0]) && DataTypesUtils.IsLatLng(split[1]))
241   - return DataTypeConverter.SUBTYPES.GEOCOORDINATE;
  247 + //if (split.length == 2)
  248 + if (DataTypesUtils.IsLatLng(split[0]) && DataTypesUtils.IsLatLng(split[1]))
  249 + return DataTypeConverter.SUBTYPES.GEOCOORDINATE;
242 250 }
243 251  
244 252 //Try to parse the float.
245   - var isnumber = DataTypesUtils.FilterFloat(value);
  253 + //var isnumber = DataTypesUtils.FilterFloat(value);
  254 + var isnumber = DataTypesUtils.FilterNumber(value);
246 255 if (isNaN(isnumber) !== true) {//It is a number.
247 256 //If the number ranges from -90.0 to 90.0, the value is marked as Latitude.
248 257 if (-90.0 <= isnumber && isnumber <= 90.0 && DataTypesUtils.DecimalPlaces(isnumber) >= 5)
... ... @@ -267,6 +276,11 @@ DataTypeConverter.prototype = (function () {
267 276 if (isincluded) return DataTypeConverter.SUBTYPES.GEOJSON;
268 277 }
269 278  
  279 + //If the value starts with a zero and contains all numbers, it is
  280 + //inferred as textual content.
  281 + /*if (/^0[0-9]+$/.test(value))
  282 + return DataTypeConverter.TYPES.CODE;*/
  283 +
270 284 return null;
271 285 };//EndFunction.
272 286  
... ... @@ -300,6 +314,15 @@ DataTypeConverter.prototype = (function () {
300 314 return metadata;
301 315 };//EndFunction.
302 316  
  317 + var _capitalizeFirstLetter = function(string) {
  318 + return string.charAt(0).toUpperCase() + string.slice(1);
  319 + };//EndFunction.
  320 +
  321 + var _replaceAll = function(search, replacement) {
  322 + var target = this;
  323 + return target.split(search).join(replacement);
  324 + };
  325 +
303 326 var jsonTraverse = function(json, fieldKeys, callback) {
304 327 var stack = [];
305 328 var numOfRows = 0;
... ... @@ -349,15 +372,19 @@ DataTypeConverter.prototype = (function () {
349 372 return {
350 373 constructor: DataTypeConverter,
351 374  
  375 +
352 376 /**
353   - * It parses the json in input and converts the content
354   - * in according to the inferred data types.
355   - * @param json
356   - * @param path Format: field1->field2->field3
  377 + *
  378 + * @param metadata Previous information on the inferred types.
  379 + * @param options Some options to cast the data.
  380 + * - castThresholdConfidence: for which threshold the library must perform the cast (default 1)
  381 + * - makeChangesToDataset: is a boolean value, to indicate whether the library can do improvement on the storage
  382 + * values, for instance, numbers with the comma will be replaced with the dot.
  383 + * @returns {*}
357 384 */
358 385 cast: function(metadata, options) {
359 386 if (typeof options === 'undefined' || options == null)
360   - options = { castThresholdConfidence: 1, castIfNull: false };
  387 + options = { castThresholdConfidence: 1, castIfNull: false, makeChangesToDataset: false };
361 388 return this.convert(metadata, options);
362 389 },
363 390  
... ... @@ -380,7 +407,7 @@ DataTypeConverter.prototype = (function () {
380 407 var datasetMissingValues = 0;
381 408  
382 409 if (typeof options === 'undefined' || options == null)
383   - options = { castThresholdConfidence: 1, castIfNull: false };
  410 + options = { castThresholdConfidence: 1, castIfNull: false, makeChangesToDataset: false };
384 411  
385 412 jsonTraverse(metadata.dataset, metadata.fieldKeys, function(value, key, traversedKeys, rowIndex) {
386 413 var inferredType = metadata.types[traversedKeys];
... ... @@ -399,6 +426,9 @@ DataTypeConverter.prototype = (function () {
399 426 //var isCast = !(options.castIfNull == false && inferredType.totalNullValues > 0);
400 427 var isCast = inferredType.typeConfidence >= options.castThresholdConfidence;
401 428 if (inferredType.type == DataTypeConverter.TYPES.NUMBER.name && isCast) {
  429 + if (isNaN(DataTypesUtils.FilterNumber(value)) == false && typeof value === "string")
  430 + value = value.replace(',', '.');
  431 +
402 432 var number = parseFloat(value);
403 433  
404 434 if (isNaN(number)) {
... ... @@ -426,8 +456,17 @@ DataTypeConverter.prototype = (function () {
426 456 * @param options Infer Data Type options, in particular the threshold value for the confidence.
427 457 */
428 458 inferJsonDataType: function (json, fieldKeys, options) {
429   - if (typeof options === 'undefined' || options == null)
430   - options = { thresholdConfidence: 1 };
  459 +
  460 + //Default options initialisation.
  461 + if (typeof options === 'undefined' || options == null) options = { };
  462 +
  463 + if (options.hasOwnProperty("thresholdConfidence") == false)
  464 + options.thresholdConfidence = 1;
  465 +
  466 + if (options.hasOwnProperty("language") == false)
  467 + options.language = DataTypeConverter.LANGS.EN.name;
  468 + else
  469 + options.language = options.language.toUpperCase();
431 470  
432 471 var stack = [];
433 472 var fieldsType = {};
... ... @@ -500,6 +539,25 @@ DataTypeConverter.prototype = (function () {
500 539 }
501 540 }//EndWhile.
502 541  
  542 +
  543 + //Calculates the number of rows in the dataset.
  544 + var _numOfRows = 0;
  545 + ArrayUtils.IteratorOverKeys(fieldsType, function(fieldType) {
  546 + if (fieldType.numOfItems > _numOfRows)
  547 + _numOfRows = fieldType.numOfItems;
  548 + });
  549 +
  550 + //Computes the number of null values.
  551 + ArrayUtils.IteratorOverKeys(fieldsType, function(fieldType) {
  552 + if (!fieldType._inferredTypes.hasOwnProperty(DataTypeConverter.TYPES.EMPTY.name)) {
  553 + //Initialises the field.
  554 + fieldType._inferredTypes[DataTypeConverter.TYPES.EMPTY.name] = 0;
  555 + }
  556 +
  557 + fieldType._inferredTypes[DataTypeConverter.TYPES.EMPTY.name] = fieldType._inferredTypes[DataTypeConverter.TYPES.EMPTY.name] + (_numOfRows - fieldType.numOfItems);
  558 + });
  559 +
  560 + //Infers the data type.
503 561 _analyseDataTypes(fieldsType);
504 562  
505 563 //Data quality.
... ... @@ -538,22 +596,47 @@ DataTypeConverter.prototype = (function () {
538 596  
539 597 var incorrect = fieldType.numOfItems - fieldType.totalNullValues - fieldType._inferredTypes[fieldType.type];
540 598 if (incorrect > 0) {
541   - description += "The column <" + fieldType.name + "> has the type <" + fieldType.type + ">";
  599 + var _descr1 = _capitalizeFirstLetter(JDC_LNG['key_declaretype'][options.language]) + ".";
  600 + var _descr2 = _capitalizeFirstLetter(JDC_LNG['key_notoftype_singular'][options.language]) + ".";
  601 + if (incorrect > 1)
  602 + _descr2 = _capitalizeFirstLetter(JDC_LNG['key_notoftype_plural'][options.language]) + ".";
  603 +
  604 + var descr = _descr1 + " " + _descr2;
  605 + descr = descr.replace(/%COL_NAME/g, fieldType.name);
  606 + descr = descr.replace(/%COL_TYPE/g, fieldType.type);
  607 + descr = descr.replace(/%COL_ERRORS/g, incorrect);
  608 +
  609 + description += descr;
  610 +
  611 + /*description += "The column <" + fieldType.name + "> has the type <" + fieldType.type + ">";
542 612 var verb = (incorrect == 1) ? " value is" : " values are";
543   - description += ", but " + incorrect + verb + " not a " + fieldType.type;
  613 + description += ", but " + incorrect + verb + " not a " + fieldType.type;*/
544 614 }
545 615 }
546 616  
547   - if (fieldType.totalNullValues > 0) {
  617 + var descr = "";
  618 + if (fieldType.totalNullValues == 1)
  619 + descr = _capitalizeFirstLetter(JDC_LNG['key_emptyvalue_singolar'][options.language]) + ".";
  620 + else if (fieldType.totalNullValues > 1 )
  621 + descr = _capitalizeFirstLetter(JDC_LNG['key_emptyvalue_plural'][options.language]) + ".";
  622 +
  623 + descr = descr.replace(/%COL_NAME/g, fieldType.name);
  624 + descr = descr.replace(/%COL_TYPE/g, fieldType.type);
  625 + descr = descr.replace(/%COL_NULLVALUES/g, fieldType.totalNullValues);
  626 + description = description + " " + descr;
  627 +
  628 + /*if (fieldType.totalNullValues > 0) {
  629 + var descr = _capitalizeFirstLetter(JDC_LNG['key_declaretype'][options.language]) + ".";
  630 +
548 631 description += "The column <" + fieldType.name + "> has " + fieldType.totalNullValues + " EMPTY value";
549 632 if (fieldType.totalNullValues > 1) description += "s";
550 633 }
551 634  
552 635 if (description.length > 0)
553   - description += ".";
  636 + description += ".";*/
554 637  
555   - fieldType.errorsDescription = description;
556   - warningsTextual += description;
  638 + fieldType.errorsDescription = description.trim();
  639 + warningsTextual += description.trim();
557 640 });
558 641  
559 642 var metadata = { dataset: json, fieldKeys: fieldKeys, types: fieldsType, qualityIndex: quality, warningsTextual: warningsTextual };
... ...
bower_components/jsdatachecker/src/DataTypesUtils.js
... ... @@ -107,6 +107,71 @@ DataTypesUtils.FilterFloat = function (value) {
107 107 return NaN;
108 108 };//EndFunction.
109 109  
  110 +DataTypesUtils.FilterNumber = function (value) {
  111 + //Check immediatly if it is a classical number.
  112 + var valnum = DataTypesUtils.FilterFloat(value);
  113 + if (isNaN(valnum) == false) return valnum;
  114 +
  115 + //Checks if the value is a string.
  116 + if (typeof value !== "string")
  117 + return NaN;
  118 +
  119 + var parts = value.split(/(,|\.)/g);
  120 +
  121 + //Find the smallest symbol.
  122 + var idxDot = { idx: value.indexOf('.'), sym: '.' };
  123 + var idxComma = { idx: value.lastIndexOf(','), sym: ',' };
  124 + var idxFirst = {};
  125 + if (idxDot.idx == -1) idxFirst = idxComma;
  126 + else if (idxComma.idx == -1) idxFirst = idxDot;
  127 + else if (idxDot.idx < idxComma.idx) idxFirst = idxDot;
  128 + else idxFirst = idxComma;
  129 +
  130 + //Find the greatest symbol.
  131 + var idxLastDot = { idx: value.lastIndexOf('.'), sym: '.' };
  132 + var idxLastComma = { idx: value.lastIndexOf(','), sym: ',' };
  133 + var idxLast = {};
  134 + if (idxLastDot.idx == -1) idxLast = idxLastComma;
  135 + else if (idxLastComma.idx == -1) idxLast = idxLastDot;
  136 + else if (idxLastDot.idx > idxLastComma.idx) idxLast = idxLastDot;
  137 + else idxLast = idxLastComma;
  138 +
  139 + //Splits over the dot and comma and check that are all numbers.
  140 + var splitted = value.split(/(\.|,|\-|\+)/g);
  141 + if (splitted.length == 0) return NaN;
  142 +
  143 + var numOfDots = 0;
  144 + var numOfComma = 0;
  145 + var i=0;
  146 + if (splitted[0] == '-' || splitted[0] == '+') i=1;
  147 +
  148 + for (var str; i<splitted.length, str=splitted[i]; i++) {
  149 + if (str == '.') numOfDots++;
  150 + else if (str == ',') numOfComma++;
  151 + else if (/^(0|([1-9][0-9]*))$/g.test(str) == false)
  152 + return NaN;
  153 + }//EndFor.
  154 +
  155 + var lastValue = splitted[splitted.length-1];
  156 + if (lastValue == '.' || lastValue == ',' || lastValue.length == 0) return NaN;
  157 +
  158 + //No dot/comma char found
  159 + if (idxFirst.idx == -1 && idxLast.idx == -1)
  160 + return DataTypesUtils.FilterFloat(value);
  161 +
  162 + //Only one dot symbol found
  163 + if (idxFirst.idx == idxLast.idx && idxFirst.sym == '.')
  164 + return Number(value);
  165 +
  166 + //Only one comma symbol found
  167 + if (idxFirst.idx == idxLast.idx && idxFirst.sym == ',') {
  168 + var nval = value.replace(',', '.');
  169 + return Number(nval);
  170 + }
  171 +
  172 + return NaN;
  173 +};//EndFunction.
  174 +
110 175 /**
111 176 * Solution from here:
112 177 * http://stackoverflow.com/questions/10454518/javascript-how-to-retrieve-the-number-of-decimals-of-a-string-number
... ...
bower_components/jsdatachecker/src/ODPlatforms/CKAN.js
... ... @@ -39,6 +39,7 @@ CKANApi.prototype = (function() {
39 39 errorCallback("Check DataStoreAPI.");
40 40 };
41 41 xhttp.open("GET", theUrl, true);//true for asynchronous.
  42 + //xhttp.setRequestHeader('Content-yype')
42 43 xhttp.send(null);
43 44 };//EndFunction.
44 45  
... ...
bower_components/jsdatachecker/src/ODPlatforms/ODStatistics.js
... ... @@ -53,18 +53,44 @@ ODStatistics.prototype = (function() {
53 53  
54 54 stats.numOfDatasets = datasets.length;
55 55 stats.formats = [];
  56 + stats.formatsAggregated = [];
56 57  
57 58 for (var i=0; i<datasets.length; i++) {
58 59 var dataset = datasets[i];
59 60  
60 61 //Statistics on the datasets' formats.
61 62 ArrayUtils.TestAndIncrement(stats.formats, dataset.format);
  63 +
  64 + var dsformat = dataset.format.toLowerCase();
  65 +
  66 + //Aggregated formats.
  67 + if (dsformat.includes("csv"))
  68 + ArrayUtils.TestAndIncrement(stats.formatsAggregated, "csv");
  69 + else if (dsformat.includes("pdf"))
  70 + ArrayUtils.TestAndIncrement(stats.formatsAggregated, "pdf");
  71 + else if (dsformat.includes("html"))
  72 + ArrayUtils.TestAndIncrement(stats.formatsAggregated, "html");
  73 + else if (dsformat.includes("json"))
  74 + ArrayUtils.TestAndIncrement(stats.formatsAggregated, "json");
  75 + else if (dsformat.includes("xml"))
  76 + ArrayUtils.TestAndIncrement(stats.formatsAggregated, "xml");
  77 + else if (dsformat.includes("shp"))
  78 + ArrayUtils.TestAndIncrement(stats.formatsAggregated, "shp");
  79 + else if (dsformat.includes("geojson"))
  80 + ArrayUtils.TestAndIncrement(stats.formatsAggregated, "geojson");
  81 + else if (dsformat.includes("kml"))
  82 + ArrayUtils.TestAndIncrement(stats.formatsAggregated, "kml");
  83 + else if (dsformat.includes("txt"))
  84 + ArrayUtils.TestAndIncrement(stats.formatsAggregated, "txt");
  85 + else if (dsformat.includes("xls") || dsformat.includes("xlsx") || dsformat.includes("ods"))
  86 + ArrayUtils.TestAndIncrement(stats.formatsAggregated, "xls/ods");
  87 + else
  88 + ArrayUtils.TestAndIncrement(stats.formatsAggregated, "other");
62 89 }//EndForI.
63 90  
64 91 //Calculates the formats percentages.
65 92 var tmpArrFormats = stats.formats;
66 93 stats.formats = [];
67   -
68 94 ArrayUtils.IteratorOverKeys(tmpArrFormats, function(item, property) {
69 95 var recordFormat = {};
70 96 recordFormat.name = property;
... ... @@ -74,6 +100,18 @@ ODStatistics.prototype = (function() {
74 100 stats.formats.push(recordFormat);
75 101 });
76 102  
  103 + //Calculates the formats percentage for the aggregated formats.
  104 + var tmpArrFormatsAggregated = stats.formatsAggregated;
  105 + stats.formatsAggregated = [];
  106 + ArrayUtils.IteratorOverKeys(tmpArrFormatsAggregated, function(item, property) {
  107 + var recordFormat = {};
  108 + recordFormat.name = property;
  109 + recordFormat.occurrance = item;
  110 + recordFormat.occurrancePercentage = (item / datasets.length) * 100;
  111 + recordFormat.occurrancePercentage = Math.round(recordFormat.occurrancePercentage * 100) / 100;
  112 + stats.formatsAggregated.push(recordFormat);
  113 + });
  114 +
77 115 return stats;
78 116 };//EndFunction.
79 117  
... ...
bower_components/jsdatachecker/src/langs.js 0 → 100644
  1 +
  2 +
  3 +
  4 +var JDC_LNG = {
  5 +
  6 + "key_declaretype": {
  7 + "EN": "the column <%COL_NAME> is of type <%COL_TYPE>",
  8 + "IT": "la colonna <%COL_NAME> è di tipo <%COL_TYPE>",
  9 + "FR": "le colum <%COL_NAME> est de type <%COL_TYPE>",
  10 + "NL": "de kolom <%COL_NAME> is van het type <%COL_TYPE>"
  11 + },
  12 +
  13 + "key_notoftype_singular": {
  14 + "EN": "a value is not <%COL_TYPE>",
  15 + "IT": "un valore non è un <%COL_TYPE>",
  16 + "FR": "une valeur est pas <%COL_TYPE> se trouvant",
  17 + "NL": "een waarde is niet <%COL_TYPE>"
  18 + },
  19 +
  20 + "key_notoftype_plural": {
  21 + "EN": "%COL_ERRORS values are not <%COL_TYPE>",
  22 + "IT": "%COL_ERRORS valori non sono di tipo <%COL_TYPE>",
  23 + "FR": "les valeurs %COL_ERRORS sont du type <%COL_TYPE>",
  24 + "NL": "%COL_ERRORS waarden niet <%COL_TYPE>"
  25 + },
  26 +
  27 + "key_emptyvalue_singolar": {
  28 + "EN": "the column <%COL_NAME> has an empty value",
  29 + "IT": "la colonna <%COL_NAME> ha un valore vuoto",
  30 + "FR": "la colonne <%COL_NAME> a une valeur vide",
  31 + "NL": "de kolom <%COL_NAME> heeft een lege waarde"
  32 + },
  33 +
  34 + "key_emptyvalue_plural": {
  35 + "EN": "the column <%COL_NAME> has <%COL_NULLVALUES> empty values",
  36 + "IT": "la colonna <%COL_NAME> ha <%COL_NULLVALUES> valori vuoti",
  37 + "FR": "la colonne <%COL_NAME> a <%COL_NULLVALUES> valeurs vide",
  38 + "NL": "de kolom <%COL_NAME> heeft <%COL_NULLVALUES> lege waarde"
  39 + },
  40 +
  41 + "key_type": {
  42 + "EN": "type",
  43 + "IT": "tipo",
  44 + "FR": "type",
  45 + "NL": "type"
  46 + },
  47 +
  48 + "key_subtype": {
  49 + "EN": "subtype",
  50 + "IT": "sottotipo",
  51 + "FR": "sous-type",
  52 + "NL": "subtype"
  53 + },
  54 +
  55 + "key_typetext": {
  56 + "EN": "text",
  57 + "IT": "testo",
  58 + "FR": "texte",
  59 + "NL": "tekst"
  60 + },
  61 +
  62 + "key_typenumber": {
  63 + "EN": "number",
  64 + "IT": "numero",
  65 + "FR": "nombre",
  66 + "NL": "aantal"
  67 + },
  68 +
  69 + "key_typeobject": {
  70 + "EN": "object",
  71 + "IT": "oggetto",
  72 + "FR": "objet",
  73 + "NL": "voorwerp"
  74 + },
  75 +
  76 + "key_typedatetime": {
  77 + "EN": "date or time",
  78 + "IT": "data o orario",
  79 + "FR": "date ou l'heure",
  80 + "NL": "datum of tijd"
  81 + },
  82 +
  83 + "key_typeempty": {
  84 + "EN": "empty",
  85 + "IT": "vuoto",
  86 + "FR": "vide",
  87 + "NL": "leeg"
  88 + },
  89 +
  90 + "key_typelatitude": {
  91 + "EN": "latitude",
  92 + "IT": "latitudine",
  93 + "FR": "latitude",
  94 + "NL": "breedtegraad"
  95 + },
  96 +
  97 + "key_typelongitude": {
  98 + "EN": "longitude",
  99 + "IT": "longitudine",
  100 + "FR": "longitude",
  101 + "NL": "lengtegraad"
  102 + }
  103 +
  104 +};
0 105 \ No newline at end of file
... ...
controllet.html 0 → 100644
  1 +<script type="text/javascript" src="controllets/shared_js/jquery-1.11.2.min.js"></script>
  2 +<script type="text/javascript" src="bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
  3 +<link rel="import" href="controllets/data-sevc-controllet/demo-data-sevc-controllet.html" />
  4 +
  5 +<style>
  6 + #controllet paper-material {
  7 + overflow: hidden;
  8 + }
  9 +</style>
  10 +
  11 +<script type="text/javascript">
  12 + $(document).ready(function () {
  13 + var datasets = {"result":{
  14 + "providers":{"1":{"title":"CKAN","api_url":"http://ckan.routetopa.eu","image_hash":"11","id":"1"}},
  15 + "datasets":[
  16 + {"w":1,"provider_name":"p:1","organization_name":"SPOD","package_name":"isislab","resource_name":"SPOD SUPER HEROES","url":"http:\/\/ckan.routetopa.eu\/\/api/action\/datastore_search?resource_id=642ceea8-711e-4124-b450-0d23010c44e6","metas":"{\"organization\":\"SPOD\",\"description\":\"This is a test datasets.\",\"format\":\"CSV\"}"},
  17 + {"w":1,"provider_name":"p:1","organization_name":"SPOD","package_name":"isislab","resource_name":"Wonders of the World","url":"http:\/\/ckan.routetopa.eu\/\/api\/action\/datastore_search?resource_id=1d9c8e62-47ab-40d5-8943-b4c3bca14b50","metas":"{\"organization\":\"SPOD\",\"description\":\"This is a test datasets.\",\"format\":\"CSV\"}"},
  18 + {"w":1,"provider_name":"p:1","organization_name":"SPOD","package_name":"isislab","resource_name":"Animal Sounds","url":"http:\/\/ckan.routetopa.eu\/\/api\/action\/datastore_search?resource_id=0937845d-c398-4416-a229-993f64e1d71d","metas":"{\"organization\":\"SPOD\",\"description\":\"This is a test datasets.\",\"format\":\"CSV\"}"}
  19 + ]}};
  20 +
  21 + var controllet = document.getElementById("controllet");
  22 + controllet.setAttribute("datasets", JSON.stringify(datasets));
  23 +
  24 + window.addEventListener("data-sevc-controllet.dataletCreated", function(e){parent.createHTML(e);});
  25 + });
  26 +
  27 + //http://ckan.routetopa.eu/api/action/datastore_search?resource_id=1d9c8e62-47ab-40d5-8943-b4c3bca14b50
  28 +
  29 +</script>
  30 +
  31 +<demo-data-sevc-controllet id="controllet"
  32 + deep-url="http://172.16.15.38/DEEalerProvider/DEEP/"
  33 + datalets-list-url="http://172.16.15.38/DEEalerProvider/DEEP/datalets-list"
  34 + >
  35 +</demo-data-sevc-controllet>
  36 +
  37 +<!--datasets='{"result":{"providers":{"1":{"title":"CKAN","api_url":"http:\/\/ckan.routetopa.eu","image_hash":"11","id":"1"}},"datasets":[{"w":1,"provider_name":"p:1","organization_name":"SPOD","package_name":"isislab","resource_name":"EXAMPLE 1","url":"http:\/\/ckan.routetopa.eu\/\/api\/action\/datastore_search?resource_id=642ceea8-711e-4124-b450-0d23010c44e6","metas":"{\"organization\":\"SPOD\",\"description\":\"This is a test datasets.\",\"format\":\"CSV\"}"}, {"w":1,"provider_name":"p:1","organization_name":"SPOD","package_name":"isislab","resource_name":"EXAMPLE 2","url":"http:\/\/ckan2.routetopa.eu\/\/api\/action\/datastore_search?resource_id=642ceea8-711e-4124-b450-0d23010c44e6","metas":"{\"organization\":\"SPOD\",\"description\":\"This is a test datasets.\",\"format\":\"CSV\"}"}, {"w":1,"provider_name":"p:1","organization_name":"SPOD","package_name":"isislab","resource_name":"EXAMPLE 3","url":"http:\/\/ckan3.routetopa.eu\/\/api\/action\/datastore_search?resource_id=642ceea8-711e-4124-b450-0d23010c44e6","metas":"{\"organization\":\"SPOD\",\"description\":\"This is a test datasets.\",\"format\":\"CSV\"}"}]}}'-->
... ...
controllets/animated-button-container-controllet/animated-button-container-controllet.html
... ... @@ -18,17 +18,12 @@
18 18 color: #FFFFFF;
19 19 height: 32px;
20 20 width: 32px;
21   - background-color: #00BCD4;
22   - }
23   -
24   - .button-container {
25   - cursor: pointer;
26   - height: 36px;
27   - width: 36px;
  21 + background-color: #2196F3;
  22 + border-radius: 18px;
28 23 box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
29 24 }
30 25  
31   - .button-container:hover {
  26 + iron-icon.myspace:hover {
32 27 box-shadow: 0 5px 11px 0 rgba(0, 0, 0, 0.18), 0 4px 15px 0 rgba(0, 0, 0, 0.15);
33 28 -webkit-transition: 0.2s ease-out;
34 29 -moz-transition: 0.2s ease-out;
... ... @@ -37,6 +32,13 @@
37 32 transition: 0.2s ease-out;
38 33 }
39 34  
  35 + .button-container {
  36 + cursor: pointer;
  37 + height: 36px;
  38 + width: 36px;
  39 + border-radius: 18px;
  40 + }
  41 +
40 42 .window {
41 43 height: 620px;
42 44 width: 760px;
... ...
controllets/cocreation-paper-card-controllet/cocreation-paper-card-controllet.html
... ... @@ -4,108 +4,208 @@
4 4 <link rel="import" href="../../bower_components/paper-icon-button/paper-icon-button.html"/>
5 5 <link rel="import" href="../../bower_components/paper-button/paper-button.html"/>
6 6 <link rel="import" href="../../bower_components/iron-icon/iron-icon.html"/>
7   -<link rel="import" href="../../bower_components/iron-collapse/iron-collapse.html"/>
  7 +<link rel="import" href="../../bower_components/paper-tooltip/paper-tooltip.html">
8 8  
  9 +<script src="../../locales/cocreation_paper_card_ln.js"></script>
9 10  
10 11 <dom-module id="cocreation-paper-card-controllet">
11 12  
12 13 <template>
13 14 <style>
14 15  
15   - iron-icon{
16   - padding-left: 5px;
17   - padding-right: 5px;
18   - --iron-icon-height: 16px;
19   - --iron-icon-width: 16px;
  16 + #card_container {
  17 + height: 200px;
  18 + width: 300px;
  19 + margin-top: 32px;
  20 + margin-left: 32px;
  21 + margin-right: -3.7px;
20 22 }
21 23  
22   - iron-icon.icon-from{
23   - --iron-icon-fill-color : #000000;
  24 + #card_container * {
  25 + font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  26 + font-size: 16px;
  27 + line-height: 24px;
24 28 }
25 29  
26   - iron-icon.icon-to{
27   - --iron-icon-fill-color : #ff0000;
  30 + .card-content {
  31 + padding: 12px;
  32 + height: 103px;
  33 + /*overflow: hidden;*/
  34 + background: #E0E0E0;
28 35 }
29 36  
30   - paper-card.cocreation {
31   - width: 310px;
  37 + .card-actions {
  38 + padding: 12px;
  39 + height: 48px;
  40 + /*border-color: #2196F3;*/
  41 + /*border-color: #4CAF50;*/
32 42 }
33 43  
34   - .from, .to {
35   - font-size: 13px;
36   - color: #CCCCCC;
  44 + paper-button {
  45 + height: 48px;
  46 + width: 136px;/*+2*/
  47 + padding: 12px;
  48 + margin: 0;
  49 + font-weight: 700;
  50 +
  51 + background: #FFFFFF;
  52 + color: #000000;
  53 + --paper-button-ink-color: #00BCD4;
  54 + }
  55 +
  56 + paper-button.info {
  57 + cursor: help;
  58 + float: right;
37 59 }
38 60  
39   - .rate-content {
40   - @apply(--layout-flex);
41   - float: left;
42   - width: 100%;
  61 + paper-button.info:hover {
  62 + color: #000000;
43 63 }
44 64  
45   - .rate-header { @apply(--paper-font-headline); }
46   - .rate-name { color: var(--paper-grey-600); margin: 10px 0; }
  65 + paper-button:hover {
  66 + color: #00BCD4;
  67 + }
  68 +
  69 + paper-icon-button[icon="info-outline"] {
  70 + cursor: help;
  71 + float: right;
47 72  
48   - paper-icon-button.rate-icon {
49   - --iron-icon-fill-color: white;
50   - --iron-icon-stroke-color: var(--paper-grey-600);
  73 + height: 48px;
  74 + width: 48px;
  75 + padding: 8px;
  76 + color: #000000;
51 77 }
52 78  
53   - .collapse-content {
54   - width: 200px;
55   - padding: 15px;
  79 + paper-tooltip {
  80 + min-width: 400px;
  81 + --paper-tooltip-background: black;
56 82 }
57 83  
58   - iron-collapse.iron-collapse-over
59   - {
60   - position: absolute;
61   - left: -1px;
62   - margin:0;
63   - padding:0;
64   - z-index:10;
65   - background-color: #FFFFFF;
66   - border: solid 1px #E6E6E6;
67   - border-top: none !important;
68   - min-width: 310px;
69   - min-height: 188px;
70   - }
71   - .badge{
  84 + paper-fab {
72 85 position: absolute;
73   - right: 5px;
74   - bottom: 5px;
  86 + z-index: 10;
  87 + }
  88 +
  89 + paper-fab.delete {
  90 + top: -12px;
  91 + right: -12px;
  92 + --iron-icon-height: 18px;
  93 + --iron-icon-width: 18px;
  94 + width: 24px;
  95 + height: 24px;
  96 + --paper-fab-background:#B6B6B6;
  97 + }
  98 +
  99 + #card_container br {
  100 + display: block;
  101 + margin-top: 8px;
  102 + content: " ";
  103 + }
  104 +
  105 + #card_container p {
  106 + margin: 0;
  107 + padding: 0;
  108 + }
  109 +
  110 + #card_container p .title{
  111 + font-weight: 700;
  112 + /*color: #2196F3;*/
  113 + /*color: #4CAF50;*/
  114 + white-space: nowrap;
  115 + }
  116 +
  117 + #card_container p .description{
  118 + }
  119 +
  120 + #card_container .name{
  121 + font-size: 18px;
  122 + font-weight: 700;
  123 + /*color: #2196F3;*/
  124 + /*color: #4CAF50;*/
  125 + height: 32px;
  126 +
  127 + overflow: hidden;
  128 + white-space: nowrap;
  129 + text-overflow: ellipsis;
  130 + }
  131 +
  132 + #card_container .owner{
  133 + font-size: 14px;
  134 + height: 47px;
  135 +
  136 + overflow: hidden;
  137 + white-space: nowrap;
  138 + text-overflow: ellipsis;
  139 + }
  140 +
  141 + #card_container .time{
  142 + display: flex;
  143 + flex-direction: row;
  144 + height: 24px;
  145 + }
  146 +
  147 + #card_container .from {
  148 + width: 50%;
  149 + font-size: 12px;
  150 + }
  151 +
  152 + #card_container .to {
  153 + width: 50%;
  154 + font-size: 12px;
  155 + }
  156 +
  157 + paper-fab.assessment,
  158 + paper-fab.description {
  159 + bottom: -20px;
  160 + right: 12px;
  161 + cursor: auto;
  162 + }
  163 +
  164 + paper-fab.description {
75 165 background: #2196F3;
76 166 }
77 167  
78   - </style>
  168 + paper-fab.assessment {
  169 + background: #4CAF50;
  170 + }
79 171  
  172 + </style>
80 173  
81   - <paper-card class="cocreation">
82   - <div class="rate-content">
  174 + <paper-card id="card_container">
83 175 <div class="card-content">
84   - <div class="rate-header">{{name}}</div>
85   - <div class="rate-name">{{owner}}</div>
86   - <div>
87   - <iron-icon class="icon-from" icon="alarm"></iron-icon>
88   - <span class="from">{{from}}</span>
89   - <iron-icon class="icon-to" icon="alarm-off"></iron-icon>
90   - <span class="to">{{to}}</span>
91   - <template is="dom-if" if="{{!checkRoomType(roomType)}}">
92   - <paper-fab mini disabled icon="assessment" class="badge data"></paper-fab>
93   - </template>
94   - <template is="dom-if" if="{{checkRoomType(roomType)}}">
95   - <paper-fab mini disabled icon="description" class="badge knowledge"></paper-fab>
96   - </template>
  176 + <template is="dom-if" if="{{isOwner}}">
  177 + <paper-fab id="card_delete" class="delete" mini icon="delete" on-click="_handleDeleteClick"></paper-fab>
  178 + </template>
  179 + <div class="name" style$="color: {{color}};">{{name}}</div>
  180 + <div class="owner">{{owner}}</div>
  181 + <div class="time">
  182 + <div class="from">
  183 + <iron-icon class="icon-from" icon="alarm"></iron-icon>&nbsp; {{from}}
  184 + </div>
  185 + <div class="to">
  186 + <iron-icon class="icon-to" icon="alarm-off"></iron-icon>&nbsp; {{to}}
  187 + </div>
97 188 </div>
  189 + <template is="dom-if" if="{{!_checkRoomType(roomType)}}">
  190 + <paper-fab mini icon="assessment" class="assessment" noink></paper-fab>
  191 + </template>
  192 + <template is="dom-if" if="{{_checkRoomType(roomType)}}">
  193 + <paper-fab mini icon="description" class="description" noink></paper-fab>
  194 + </template>
98 195 </div>
99   - <div class="card-actions">
100   - <paper-button on-click="_onExplore">Explore</paper-button>
101   - <paper-icon-button icon="expand-less" on-click="_toggle" style="float:right;"></paper-icon-button>
102   - <iron-collapse class="iron-collapse-over" id="more_info" no-animation>
103   - <div class="collapse-content">
104   - {{goal}}
105   - </div>
106   - </iron-collapse>
  196 + <div class="card-actions" style$="border-color: {{color}};">
  197 + <paper-button on-click="_onExplore"><span id="explore"></span></paper-button>
  198 + <paper-button id="goal_button" class="info" noink><span id="goal"></span></paper-button>
  199 + <!--<paper-icon-button id="goal_button" icon="info-outline" noink></paper-icon-button>-->
  200 +
  201 + <paper-tooltip for="goal_button" position="bottom" offset="-8">
  202 + <p>
  203 + <span class="title" style$="color: {{color}};" id="tooltip_goal"></span>
  204 + <br>
  205 + <span class="description">{{goal}}</span>
  206 + </p>
  207 + </paper-tooltip>
107 208 </div>
108   - </div>
109 209 </paper-card>
110 210  
111 211 </template>
... ... @@ -119,23 +219,23 @@
119 219 properties: {
120 220 name:{
121 221 type: String,
122   - value: "text"
  222 + value: ""
123 223 },
124 224 owner:{
125 225 type: String,
126   - value: "text"
  226 + value: ""
127 227 },
128 228 from:{
129 229 type: String,
130   - value: "text"
  230 + value: ""
131 231 },
132 232 to:{
133 233 type: String,
134   - value: "text"
  234 + value: ""
135 235 },
136 236 goal:{
137 237 type: String,
138   - value: "text"
  238 + value: ""
139 239 },
140 240 roomUrl: {
141 241 type: String,
... ... @@ -144,28 +244,46 @@
144 244 roomType:{
145 245 type: String,
146 246 value: undefined
  247 + },
  248 + isOwner: {
  249 + type: Boolean,
  250 + value: false
  251 + },
  252 + roomId:{
  253 + type: Number,
  254 + value: undefined
  255 + },
  256 + color:{
  257 + type: String,
  258 + value: ""
147 259 }
148 260 },
149 261  
  262 + ready: function() {
  263 + var color = "#4CAF50";
  264 + if(this.roomType == "knowledge")
  265 + color = "#2196F3";
  266 + this.color = color;
  267 + },
  268 +
150 269 attached: function(){
  270 + cocreation_room_ln["ln"] = ODE.user_language;
  271 +
  272 + this.$.goal.innerHTML = cocreation_room_ln["goal_" + cocreation_room_ln["ln"]];
  273 + this.$.tooltip_goal.innerHTML = cocreation_room_ln["goal_" + cocreation_room_ln["ln"]];
  274 + this.$.explore.innerHTML = cocreation_room_ln["explore_" + cocreation_room_ln["ln"]];
151 275 },
152 276  
153   - _toggle: function(){
154   - var moreInfo = this.$.more_info;
155   - var iconButton = Polymer.dom(event).localTarget;
156   - iconButton.icon = moreInfo.opened ? 'expand-less' : 'expand-more';
157   - moreInfo.toggle();
  277 + _handleDeleteClick: function(){
  278 + this.fire("cocreation-paper-card-controllet_delete", {roomId: this.roomId});
158 279 },
159 280  
160   - _onExplore: function(e){
  281 + _onExplore: function(){
161 282 window.location = this.roomUrl;
162 283 },
163 284  
164   - checkRoomType: function(type){
165   - if(type == "knowledge")
166   - return true;
167   - else
168   - return false;
  285 + _checkRoomType: function(type){
  286 + return (type == "knowledge") ? true : false;
169 287 }
170 288 })
171 289 </script>
... ...
controllets/data-sevc-controllet/data-sevc-controllet.html
... ... @@ -47,7 +47,7 @@
47 47  
48 48 listeners : {
49 49 'page-slider-controllet_selected' : '_updateSlider',
50   - 'dataset-selection-controllet_data-url' : '_allowSecondStep',
  50 + 'select-dataset-controllet_data-url' : '_allowSecondStep',
51 51 'select-fields-controllet_selected-fields' : '_allowThirdStep',
52 52 'filters-controllet_filters': '_allowThirdStep',
53 53 'aggregators-controllet_aggregators': '_allowThirdStep',
... ... @@ -117,7 +117,7 @@
117 117  
118 118 _allowSecondStep : function(e){
119 119 this.$.slider.chevronRight(false);
120   -//
  120 +
121 121 var f = Object.create(providerFactory);
122 122 var provider = f.getProvider(e.detail.url);
123 123 var dataUrl = provider.addLimit(e.detail.url);
... ... @@ -135,6 +135,8 @@
135 135 }
136 136 else
137 137 this.$.select_dataset.$.selected_url.invalid = true;
  138 +
  139 + this.$.select_dataset.showDatasetInfo();
138 140 },
139 141  
140 142 _allowThirdStep : function(){
... ...
controllets/data-sevc-controllet/data-sevc-controllet_old.html deleted
1   -<script src="../shared_js/perfect-scrollbar/js/min/perfect-scrollbar.jquery.min.js"></script>
2   -<link rel="stylesheet" href="../shared_js/perfect-scrollbar/css/perfect-scrollbar.min.css">
3   -
4   -<script src="../../locales/controllet_ln.js"></script>
5   -
6   -<link rel="import" href="../../bower_components/polymer/polymer.html">
7   -
8   -<link rel="import" href="../page-slider-controllet/page-slider-controllet.html">
9   -
10   -<link rel="import" href="../select-dataset-controllet/select-dataset-controllet.html">
11   -<link rel="import" href="../select-data-controllet/select-data-controllet.html" />
12   -<link rel="import" href="../select-visualization-controllet/select-visualization-controllet.html" />
13   -
14   -<dom-module id="data-sevc-controllet">
15   -
16   - <template>
17   -
18   - <page-slider-controllet id="slider">
19   -
20   - <neon-animatable>
21   -
22   - <template is="dom-if" if={{!modify}}>
23   - <select-dataset-controllet id="select_dataset" data={{data}} datasets={{datasets}} suggested-datasets={{suggestedDatasets}}></select-dataset-controllet>
24   - </template>
25   -
26   - </neon-animatable>
27   -
28   - <neon-animatable>
29   -
30   - <select-data-controllet id="select_data" data-url={{dataUrl}} preselected-fields={{selectedFields}} datalet-preset="{{dataletPreset}}"></select-data-controllet>
31   -
32   - </neon-animatable>
33   -
34   - <neon-animatable>
35   -
36   - <select-visualization-controllet id="select_visualization" deep-url={{deepUrl}} datalets-list-url={{dataletsListUrl}} data-url={{dataUrl}} preselected-datalet={{selectedDatalet}} datalet-preset={{dataletPreset}}></select-visualization-controllet>
37   -
38   - </neon-animatable>
39   -
40   - </page-slider-controllet>
41   -
42   - </template>
43   -
44   - <script>
45   -
46   - Polymer({
47   -
48   - is : 'data-sevc-controllet',
49   -
50   - listeners : {
51   - 'page-slider-controllet_selected' : '_updateSlider',
52   - 'dataset-selection-controllet_data-url' : '_allowSecondStep',
53   - 'tree-view-controllet_selected-fields' : '_allowThirdStep'
54   - },
55   -
56   - properties : {
57   -
58   - deepUrl : {
59   - type : String,
60   - value : undefined
61   - },
62   -
63   - dataletsListUrl : {
64   - type : String ,
65   - value : undefined
66   - },
67   -
68   - datasets : {
69   - type : Array,
70   - value : undefined
71   - },
72   -
73   - suggestedDatasets : {
74   - type : Array,
75   - value : undefined
76   - },
77   -
78   - dataUrl : {
79   - type : String,
80   - value : undefined
81   - },
82   -
83   - jsonData : {
84   - type : Object,
85   - value : undefined
86   - },
87   -
88   - modify : {
89   - type : Boolean,
90   - value : false
91   - },
92   -
93   - selectedDatalet : {
94   - type : String,
95   - value : undefined
96   - },
97   -
98   - selectedFields : {
99   - type : Array,
100   - value : []
101   - },
102   -
103   - dataletPreset : {
104   - type : Object,
105   - value : []
106   - },
107   -
108   - localization : {
109   - type : String,
110   - value : "en"
111   - }
112   -
113   - },
114   -
115   - ready : function(){
116   - if(this.selectedDatalet){
117   - this.modify = true;
118   - this.$.slider.selected = 1;
119   - this.dataUrl = this.dataletPreset["data-url"];
120   - }
121   - ln["localization"] = this.localization;
122   - },
123   -
124   - _updateSlider : function(e){
125   - switch (e.detail.selected) {
126   - case 0:
127   - slider.setTitle(ln["slide1Title_" + this.localization], ln["slide1Subtitle_" + this.localization]);
128   - slider.chevronLeft("invisible");
129   - slider.chevronRight(false);
130   - if(slider.getPrevSelected() == 1)
131   - slider.chevronRight(true);
132   - break;
133   - case 1:
134   - slider.setTitle(ln["slide2Title_" + this.localization], ln["slide2Subtitle_" + this.localization]);
135   - if(this.modify){
136   - slider.chevronLeft("invisible");
137   - }
138   - else{
139   - slider.chevronLeft(true);
140   - }
141   - slider.chevronRight(false);
142   - this._allowThirdStep({detail: {fields: select_data.getSelectedFields()}});
143   - if(this.modify){
144   - this.$.select_visualization.setFields(select_data.getSelectedFields());
145   - this.$.select_visualization.setFilters(select_data.getFilters());
146   - }
147   - break;
148   - case 2:
149   - slider.setTitle(ln["slide3Title_" + this.localization], ln["slide3Subtitle_" + this.localization]);
150   - slider.chevronLeft(true);
151   - slider.chevronRight("invisible");
152   -
153   - this.$.select_visualization.setFields(select_data.getSelectedFields());
154   - this.$.select_visualization.setFilters(select_data.getFilters());
155   - if(this.modify) {
156   - this.$.select_visualization.show();//resize
157   - }
158   - }
159   - },
160   -
161   - _allowSecondStep : function(e){
162   - if(e.detail.url == "") {
163   - slider.chevronRight(false);
164   - select_dataset.$.selected_url.invalid = false;
165   - return;
166   - }
167   -
168   - this.dataUrl = e.detail.url;
169   -
170   - var that = this;
171   -
172   - $.ajax({
173   - url: e.detail.url,
174   - dataType: "json",
175   - success: function(data){
176   -// this.dataUrl = e.detail.url
177   -// this.jsonData = JSON.stringify(data);
178   - slider.chevronRight(true);
179   - select_dataset.$.selected_url.invalid = false;
180   -
181   - that.$.select_data._init();
182   - },
183   - error: function(){
184   -// this.jsonData = undefined;
185   - slider.chevronRight(false);
186   - select_dataset.$.selected_url.invalid = true;
187   -
188   - that.$.select_data._reset();
189   - }
190   - });
191   -
192   - //NOT HERE ma quando VADO al secondo passo e l'url è cambiato
193   -// this.$.select_data._init();
194   - this.$.select_visualization.reset();
195   - },
196   -
197   - _allowThirdStep : function(e){
198   - if(e.detail.fields.length > 0)
199   - slider.chevronRight(true);
200   - else
201   - slider.chevronRight(false);
202   -
203   - //this.$.select_visualization.reset();
204   - }
205   -
206   - });
207   -
208   - </script>
209   -
210   -</dom-module>
211 0 \ No newline at end of file
controllets/data-sevc-controllet/datalets-modifier-controllet.html deleted
1   -<script src="../shared_js/perfect-scrollbar/js/min/perfect-scrollbar.jquery.min.js"></script>
2   -<link rel="stylesheet" href="../shared_js/perfect-scrollbar/css/perfect-scrollbar.min.css">
3   -
4   -<script src="../../locales/controllet_ln.js"></script>
5   -
6   -<link rel="import" href="../../bower_components/polymer/polymer.html">
7   -
8   -<link rel="import" href="../page-slider-controllet/page-slider-controllet.html">
9   -
10   -<link rel="import" href="../select-data-controllet/select-data-controllet.html" />
11   -<link rel="import" href="../select-visualization-controllet/select-visualization-controllet.html" />
12   -
13   -<dom-module id="datalets-modifier-controllet">
14   -
15   - <template>
16   -
17   - <page-slider-controllet id="slider">
18   -
19   - <neon-animatable>
20   -
21   - <select-data-controllet id="select_data"></select-data-controllet>
22   -
23   - </neon-animatable>
24   -
25   - <neon-animatable>
26   -
27   - <select-visualization-controllet id="select_visualization" deep-url={{deepUrl}} datalets-list-url={{dataletsListUrl}}></select-visualization-controllet>
28   -
29   - </neon-animatable>
30   -
31   - </page-slider-controllet>
32   -
33   - </template>
34   -
35   - <script>
36   -
37   - Polymer({
38   -
39   - is : 'datalets-modifier-controllet',
40   -
41   - listeners : {
42   - 'page-slider-controllet_selected' : '_updateSlider',
43   - 'dataset-selection-controllet_data-url' : '_allowSecondStep',
44   - 'tree-view-controllet_selected-fields' : '_allowThirdStep'
45   - },
46   -
47   - properties : {
48   -// dataUrl : {
49   -// type : String,
50   -// value : undefined
51   -// },
52   -
53   - preselectedDatalet : { //datalet
54   - type : String,
55   - value : undefined
56   - },
57   -
58   - preselectedFields : { //fields
59   - type : Array,
60   - value : undefined
61   - },
62   -
63   - dataletPreset : { //params
64   - type : String,
65   - value : undefined
66   - },
67   -
68   - deepUrl : {
69   - type : String,
70   - value : undefined
71   - },
72   -
73   - dataletsListUrl : {
74   - type : String ,
75   - value : undefined
76   - },
77   -
78   - localization : {
79   - type : String,
80   - value : "en"
81   - }
82   -
83   - },
84   -
85   - ready : function(){
86   - if(this.selectedDatalet){
87   - this.modify = true;
88   - this.$.slider.selected = 1;
89   - this.dataUrl = this.dataletPreset["data-url"];
90   - }
91   - ln["localization"] = this.localization;
92   - },
93   -
94   - _updateSlider : function(e){
95   - switch (e.detail.selected) {
96   - case 0:
97   - slider.setTitle(ln["slide1Title_" + this.localization], ln["slide1Subtitle_" + this.localization]);
98   - slider.chevronLeft("invisible");
99   - slider.chevronRight(false);
100   - if(slider.getPrevSelected() == 1)
101   - slider.chevronRight(true);
102   - break;
103   - case 1:
104   - slider.setTitle(ln["slide2Title_" + this.localization], ln["slide2Subtitle_" + this.localization]);
105   - if(this.modify){
106   - slider.chevronLeft("invisible");
107   - }
108   - else{
109   - slider.chevronLeft(true);
110   - }
111   - slider.chevronRight(false);
112   - this._allowThirdStep({detail: {fields: select_data.getSelectedFields()}});
113   - if(this.modify){
114   - this.$.select_visualization.setFields(select_data.getSelectedFields());
115   - this.$.select_visualization.setFilters(select_data.getFilters());
116   - }
117   - break;
118   - case 2:
119   - slider.setTitle(ln["slide3Title_" + this.localization], ln["slide3Subtitle_" + this.localization]);
120   - slider.chevronLeft(true);
121   - slider.chevronRight("invisible");
122   -
123   - this.$.select_visualization.setFields(select_data.getSelectedFields());
124   - this.$.select_visualization.setFilters(select_data.getFilters());
125   - if(this.modify) {
126   - this.$.select_visualization.show();//resize
127   - }
128   - }
129   - },
130   -
131   - _allowSecondStep : function(e){
132   - if(e.detail.url == "") {
133   - slider.chevronRight(false);
134   - select_dataset.$.selected_url.invalid = false;
135   - return;
136   - }
137   -
138   - this.dataUrl = e.detail.url;
139   -
140   - var that = this;
141   -
142   - $.ajax({
143   - url: e.detail.url,
144   - dataType: "json",
145   - success: function(data){
146   -// this.dataUrl = e.detail.url
147   -// this.jsonData = JSON.stringify(data);
148   - slider.chevronRight(true);
149   - select_dataset.$.selected_url.invalid = false;
150   -
151   - that.$.select_data._init();
152   - },
153   - error: function(){
154   -// this.jsonData = undefined;
155   - slider.chevronRight(false);
156   - select_dataset.$.selected_url.invalid = true;
157   -
158   - that.$.select_data._reset();
159   - }
160   - });
161   -
162   - //NOT HERE ma quando VADO al secondo passo e l'url è cambiato
163   -// this.$.select_data._init();
164   - this.$.select_visualization.reset();
165   - },
166   -
167   - _allowThirdStep : function(e){
168   - if(e.detail.fields.length > 0)
169   - slider.chevronRight(true);
170   - else
171   - slider.chevronRight(false);
172   -
173   - //this.$.select_visualization.reset();
174   - }
175   -
176   - });
177   -
178   - </script>
179   -
180   -</dom-module>
181 0 \ No newline at end of file
controllets/data-sevc-controllet/demo-data-sevc-controllet.html 0 → 100644
  1 +<script src="../shared_js/perfect-scrollbar/js/min/perfect-scrollbar.jquery.min.js"></script>
  2 +<link rel="stylesheet" href="../shared_js/perfect-scrollbar/css/perfect-scrollbar.min.css">
  3 +
  4 +<script src="../../locales/controllet_ln.js"></script>
  5 +
  6 +<link rel="import" href="../../bower_components/polymer/polymer.html">
  7 +
  8 +<link rel="import" href="../page-slider-controllet/page-slider-controllet.html">
  9 +
  10 +<link rel="import" href="../select-dataset-controllet/demo-select-dataset-controllet.html">
  11 +<link rel="import" href="../select-data-controllet/select-data-controllet.html" />
  12 +<link rel="import" href="../select-visualization-controllet/select-visualization-controllet.html" />
  13 +
  14 +<dom-module id="demo-data-sevc-controllet">
  15 +
  16 + <template>
  17 +
  18 + <page-slider-controllet id="slider">
  19 +
  20 + <neon-animatable>
  21 +
  22 + <demo-select-dataset-controllet id="select_dataset" datasets={{datasets}} suggested-datasets={{suggestedDatasets}}></demo-select-dataset-controllet>
  23 +
  24 + </neon-animatable>
  25 +
  26 + <neon-animatable>
  27 +
  28 + <select-data-controllet id="select_data"></select-data-controllet>
  29 +
  30 + </neon-animatable>
  31 +
  32 + <neon-animatable>
  33 +
  34 + <select-visualization-controllet id="select_visualization" deep-url={{deepUrl}} datalets-list-url={{dataletsListUrl}}></select-visualization-controllet>
  35 +
  36 + </neon-animatable>
  37 +
  38 + </page-slider-controllet>
  39 +
  40 + </template>
  41 +
  42 + <script>
  43 +
  44 + Polymer({
  45 +
  46 + is : 'demo-data-sevc-controllet',
  47 +
  48 + listeners : {
  49 + 'page-slider-controllet_selected' : '_updateSlider',
  50 + 'select-dataset-controllet_data-url' : '_allowSecondStep',
  51 + 'select-fields-controllet_selected-fields' : '_allowThirdStep',
  52 + 'filters-controllet_filters': '_allowThirdStep',
  53 + 'aggregators-controllet_aggregators': '_allowThirdStep',
  54 + 'data-ready': '_dataReady'
  55 + },
  56 +
  57 + properties : {
  58 +
  59 + datasets : {
  60 + type : Object,
  61 + value : undefined
  62 + },
  63 +
  64 + suggestedDatasets : {
  65 + type : Array,
  66 + value : undefined
  67 + },
  68 +
  69 + deepUrl : {
  70 + type : String,
  71 + value : undefined
  72 + },
  73 +
  74 + dataletsListUrl : {
  75 + type : String ,
  76 + value : undefined
  77 + },
  78 +
  79 + localization : {
  80 + type : String,
  81 + value : "en"
  82 + }
  83 +
  84 + },
  85 +
  86 + ready : function(){
  87 + ln["localization"] = this.localization;
  88 + },
  89 +
  90 + _updateSlider : function(e){
  91 + switch (e.detail.selected) {
  92 + case 0:
  93 + this.$.slider.setTitle(ln["slide1Title_" + this.localization], ln["slide1Subtitle_" + this.localization]);
  94 +
  95 + this.$.slider.chevronLeft("invisible");
  96 + this.$.slider.chevronRight(false);
  97 +
  98 + if(this.$.slider.getPrevSelected() == 1)
  99 + this.$.slider.chevronRight(true);
  100 + break;
  101 + case 1:
  102 + this.$.slider.setTitle(ln["slide2Title_" + this.localization], ln["slide2Subtitle_" + this.localization]);
  103 +
  104 + this.$.slider.chevronLeft(true);
  105 + this.$.slider.chevronRight(false);
  106 +
  107 + if(this.$.slider.getPrevSelected() == 2)
  108 + this.$.slider.chevronRight(true);
  109 + break;
  110 + case 2:
  111 + this.$.slider.setTitle(ln["slide3Title_" + this.localization], ln["slide3Subtitle_" + this.localization]);
  112 +
  113 + this.$.slider.chevronLeft(true);
  114 + this.$.slider.chevronRight("invisible");
  115 + }
  116 + },
  117 +
  118 + _allowSecondStep : function(e){
  119 + this.$.slider.chevronRight(false);
  120 +
  121 + var f = Object.create(providerFactory);
  122 + var provider = f.getProvider(e.detail.url);
  123 + var dataUrl = provider.addLimit(e.detail.url);
  124 +
  125 + this.$.select_data.dataUrl = dataUrl;
  126 + this.$.select_data.init();
  127 + this.$.select_visualization.dataUrl = dataUrl;
  128 + this.$.select_visualization.init();
  129 + },
  130 +
  131 + _dataReady : function(e){
  132 + if(e.detail.ready) {
  133 + this.$.slider.chevronRight(true);
  134 + this.$.select_dataset.$.selected_url.invalid = false;
  135 + }
  136 + else
  137 + this.$.select_dataset.$.selected_url.invalid = true;
  138 +
  139 + this.$.select_dataset.showDatasetInfo();
  140 + },
  141 +
  142 + _allowThirdStep : function(){
  143 + this.$.slider.chevronRight(false);
  144 + var selectedFields = this.$.select_data.getSelectedFields();
  145 + var filters = this.$.select_data.getFilters();
  146 + var aggregators = this.$.select_data.getAggregators();
  147 + var data = this.$.select_data.getData();
  148 + if(selectedFields.length > 0) {
  149 + this.$.select_visualization.init();
  150 + this.$.select_visualization.setSelectedFields(selectedFields);
  151 + this.$.select_visualization.setFilters(filters);
  152 + this.$.select_visualization.setAggregators(aggregators);
  153 + this.$.select_visualization.setData(data);
  154 + this.$.slider.chevronRight(true);
  155 + }
  156 + }
  157 +
  158 + });
  159 +
  160 + </script>
  161 +
  162 +</dom-module>
0 163 \ No newline at end of file
... ...
controllets/data-sevc-controllet/demo/index.html
... ... @@ -18,8 +18,10 @@
18 18 <data-sevc-controllet deep-url="http://172.16.15.38/DEEalerProvider/DEEP/"
19 19 datalets-list-url="http://172.16.15.38/DEEalerProvider/DEEP/datalets-list"
20 20 datasets='{"result":{"providers":{"1":{"title":"CKAN","api_url":"http:\/\/ckan.routetopa.eu","image_hash":"11","id":"1"}},"datasets":[{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url&qu