public IList<object> LoadData(DataObjectMetadata metadata) { var type = this.TypeLoader.LoadType(metadata.AssemblyName, metadata.ClassName); var entityName = this.DocumentSession.Advanced.DocumentStore.Conventions.GetTypeTagName(type); var itemQuery = this.DocumentSession.Advanced.LuceneQuery<object>().WhereEquals("@metadata.Raven-Entity-Name", entityName).ToList(); return itemQuery; }
public MetadataDefinitionViewModel() : this(null) { add = new RelayCommand((o) => { if (FieldName != null && FieldName.Trim() != string.Empty) { return(true); } return(false); }, (o) => { DataObjectMetadata meta = FromCurrentToMetadata(); DataObjectMetadataViewModel metaVm = new DataObjectMetadataViewModel(meta); MetadataCollection.Add(metaVm); }); remove = new RelayCommand((o) => { if (o == null) { return(false); } int i = (int)o; return((i >= 0) && (i < MetadataCollection.Count)); }, (o) => { int i = (int)o; MetadataCollection.RemoveAt(i); }); }
public object GetDataObject(DataObjectMetadata metadata, int objectId) { var type = this.TypeLoader.LoadType(metadata.AssemblyName, metadata.ClassName); var entityName = this.DocumentSession.Advanced.DocumentStore.Conventions.GetTypeTagName(type); var itemQuery = this.DocumentSession.Advanced.LuceneQuery<dynamic>().WhereEquals("@metadata.Raven-Entity-Name", entityName); var item = itemQuery.Single(i=>i.Id == objectId); return item; }
public IList <object> LoadData(DataObjectMetadata metadata) { var type = this.TypeLoader.LoadType(metadata.AssemblyName, metadata.ClassName); var entityName = this.DocumentSession.Advanced.DocumentStore.Conventions.GetTypeTagName(type); var itemQuery = this.DocumentSession.Advanced.LuceneQuery <object>().WhereEquals("@metadata.Raven-Entity-Name", entityName).ToList(); return(itemQuery); }
public object GetDataObject(DataObjectMetadata metadata, int objectId) { var type = this.TypeLoader.LoadType(metadata.AssemblyName, metadata.ClassName); var entityName = this.DocumentSession.Advanced.DocumentStore.Conventions.GetTypeTagName(type); var itemQuery = this.DocumentSession.Advanced.LuceneQuery <dynamic>().WhereEquals("@metadata.Raven-Entity-Name", entityName); var item = itemQuery.Single(i => i.Id == objectId); return(item); }
public DataObjectMetadata CreateMetadata(string objectName, string assemblyName, string className) { var item = new DataObjectMetadata { ObjectName = objectName, AssemblyName = assemblyName, ClassName = className }; this.DocumentSession.Store(item); this.DocumentSession.SaveChanges(); return item; }
/// <summary> /// internal function: normalises all the data input between 0 and 1 /// </summary> private void normaliseArray(DataObjectMetadata metadataPreset) { //1 make a copy of the parsed array float[,] normArray = new float[dataArray.GetUpperBound(0) + 1, dataArray.GetUpperBound(1) + 1]; originalDataValues = new float[dataArray.GetUpperBound(0) + 1, dataArray.GetUpperBound(1) + 1]; //for each dimensions (column) normalise all data for (int i = 0; i <= normArray.GetUpperBound(1); i++) { float[] rawDimension = GetCol(dataArray, i); float minDimension = rawDimension.Min(); float maxDimension = rawDimension.Max(); metadata[i].minValue = minDimension; metadata[i].maxValue = maxDimension; metadata[i].binCount = (int)Mathf.Min(maxDimension - minDimension + 1, 200); // TODO: add some automated bin size calculations if (metadataPreset != null) { foreach (var binSizePreset in metadataPreset.BinSizePreset) { if (binSizePreset.index == i) { metadata[i].binCount = binSizePreset.binCount; } } } float[] normalisedDimension = new float[rawDimension.Length]; dimensionsRange.Add(i, new Vector2(minDimension, maxDimension)); for (int j = 0; j < rawDimension.Length; j++) { if (minDimension < maxDimension) { normalisedDimension[j] = normaliseValue(rawDimension[j], minDimension, maxDimension, 0f, 1f); } else { // avoid NaNs or nonsensical normalization normalisedDimension[j] = 0; } } SetCol <float>(normArray, i, normalisedDimension); } originalDataValues = dataArray; dataArray = normArray; }
public DataObjectMetadata CreateMetadata(string objectName, string assemblyName, string className) { var item = new DataObjectMetadata { ObjectName = objectName, AssemblyName = assemblyName, ClassName = className }; this.DocumentSession.Store(item); this.DocumentSession.SaveChanges(); return(item); }
public void loadCSV(string data, DataObjectMetadata metadataPreset) { if (System.IO.File.Exists(override_file)) { StreamReader reader = new StreamReader(override_file); data = reader.ReadToEnd(); } this.metadataPreset = metadataPreset; if (metadataPreset != null) { geocodeIdentifier = metadataPreset.GeocodeIdentifier; geocodeSuffix = metadataPreset.GeocodeSuffix; } string[] lines = data.ToString().TrimEnd(Environment.NewLine.ToCharArray()).Split('\n'); lines = lines.Take(10000).ToArray(); int columnsN = lines[0].Split(split).Length; string[][] cells = new string[columnsN][]; for (int i = 0; i < columnsN; i++) { cells[i] = new string[lines.Length]; } for (int i = 0; i < lines.Length; i++) { string[] line = lines[i].Split(split); for (int j = 0; j < line.Length; j++) { cells[j][i] = line[j].Replace("\r", String.Empty); } } //first line is the identifiers for (int i = 1; i < lines.Length; i++) { dataArray.Add(new List <float>()); originalDataValues.Add(new List <float>()); } dataPoints = lines.Length - 1; foreach (string[] column in cells) { addColumn(column); } }
public DataObject(string data, DataObjectMetadata metadata = null) { loadCSV(data, metadata); }
/// <summary> /// /// </summary> /// <param name="data"></param> public void loadCSV(string data, DataObjectMetadata metadataPreset) { string[] lines = data.ToString().TrimEnd(Environment.NewLine.ToCharArray()).Split('\n'); //1: read types identifiers = lines[0].Split(split); typesToRead = lines[1].Split(split); // create metadata metadata = new DimensionMetadata[identifiers.Count()]; //clean identifiers strings for (int i = 0; i < identifiers.Length; i++) { string id = identifiers[i].Replace("\r", string.Empty); identifiers[i] = id; } nbDimensions = identifiers.Length; dataArray = new float[lines.Length - 1, identifiers.Length]; // ignore the first line of identifiers dataPoints = dataArray.GetUpperBound(0) + 1; string[] theTypes = new string[typesToRead.Length]; //type reading for (int i = 0; i < typesToRead.Length; i++) { if (isBool(typesToRead[i])) { theTypes[i] = "bool"; TypeDimensionDictionary.Add(i, "bool"); } else if (isFloat(typesToRead[i])) { theTypes[i] = "float"; TypeDimensionDictionary.Add(i, "float"); } else { theTypes[i] = "string"; TypeDimensionDictionary.Add(i, "string"); } } float textualPointer = 0f; //line reading for (int i = 1; i < lines.Length; i++) { string[] values = lines[i].Split(split); //dimension reading for (int k = 0; k < identifiers.Length; k++) { string cleanedValue = values[k].Replace("\r", string.Empty); //1- get the corresponding type if (isBool(cleanedValue)) { dataArray[i - 1, k] = Convert.ToSingle(bool.Parse(cleanedValue)); } else if (cleanedValue.Contains(':'))// isDateTime(values[k])) { //DateTime dt = DateTime.Parse(values[k]); string[] valH = cleanedValue.Split(':'); dataArray[i - 1, k] = float.Parse(valH[0]) * 60 + float.Parse(valH[1]);// *60 + float.Parse(valH[2]); } else if (isInt(cleanedValue)) { dataArray[i - 1, k] = (float)int.Parse(cleanedValue); } else if (isFloat(cleanedValue)) { //Debug.Log(k); dataArray[i - 1, k] = float.Parse(cleanedValue); } else if (!String.IsNullOrEmpty(cleanedValue)) { //lookup if already encoded if (textualDimensions.ContainsValue(cleanedValue)) { //Debug.Log(i + " " + k); dataArray[i - 1, k] = textualDimensions.FirstOrDefault(x => x.Value == cleanedValue).Key; } else { //new key textualPointer++; textualDimensions.Add(textualPointer, cleanedValue); dataArray[i - 1, k] = textualPointer; } } else { dataArray[i - 1, k] = 0f; } } } normaliseArray(metadataPreset); //build the dictionnary of sorted dimensions for (int i = 0; i < identifiers.Length; i++) { List <float> sortedDimension = getDimension(identifiers[i]).ToList(); sortedDimension.Sort(); sortedDimensions.Add(identifiers[i], sortedDimension); } }