view war/scripts/sti/DataSet.js @ 68:8b58d9bc0bb6 trimmed_data

add functionality for additional tabular data from the description field (work in progress)
author Sebastian Kruse <skruse@mpiwg-berlin.mpg.de>
date Thu, 03 Jan 2013 18:43:28 +0100
parents cf06b77a8bbd
children
line wrap: on
line source

/**
 * class that represents all needed informations about a performed dataset
 * @param {DataObject[]} objects corresponding data objects of this data set
 * @param {String} termIdentifier is a textual identifier for this dataset
 * @param {int} maxGranularity is the maximum granularity of the dataobjects of the set
 * 
 * @constructor
 */
function DataSet(objects, termIdentifier, maxGranularity){

    this.objects = objects;
    this.termIdentifier = termIdentifier;
    this.maxGranularity = maxGranularity;

    //check through each object if the description field contained a table, 
    //and "remember" the column names for easy access later
	this.descriptionDataColumns = new Array();
	for (var i = 0; i < this.objects.length; i++) {
		for (var columnName in this.objects[i].descriptionData) {
			if ($.inArray(columnName, this.descriptionDataColumns) == -1)
				this.descriptionDataColumns.push(columnName);
		}
	}
}

DataSet.prototype = {

    /**
     * adds an object to the data set
     * @param {DataObject} object the object to add
     */
    addObject: function(object){
        this.objects.push(object);
        if( this.maxGranularity < object.granularity ){
        	this.maxGranularity = object.granularity;
        }
    },
    
    /**
     * copies this dataset without objects
     * @return a DataSet object copy
     */
    copy: function(){
        return new DataSet( [], this.termIdentifier, 0 );
    }
    
}