// Static Methods private static TimeSpan GetRetentionTime(FieldMapping fieldMapping) { decimal amount = fieldMapping.RelativeTime; TimeSpan unit = fieldMapping.RelativeUnit; decimal sampleAmount = fieldMapping.SampleRate; TimeSpan sampleUnit = fieldMapping.SampleUnit; return(GetRelativeTime(amount, unit, sampleAmount, sampleUnit)); }
/// <summary> /// Creates a sample window defined by the given field mapping. /// </summary> /// <param name="fieldMapping">The mapping that defines the parameters for the sample window.</param> /// <returns>The sample window defined by the given field mapping.</returns> protected AlignmentCoordinator.SampleWindow CreateSampleWindow(FieldMapping fieldMapping) { decimal relativeTime = fieldMapping.RelativeTime; TimeSpan relativeUnit = fieldMapping.RelativeUnit; decimal sampleRate = fieldMapping.SampleRate; TimeSpan sampleUnit = fieldMapping.SampleUnit; return(AlignmentCoordinator.CreateSampleWindow(relativeTime, relativeUnit, sampleRate, sampleUnit)); }
public ReferenceTable(FieldMapping condition, string filterCond, RelatedApp relatedApp, int size, List <string> displayFields) { this.condition = condition; this.filterCond = filterCond; this.relatedApp = relatedApp; this.size = size; this.displayFields = displayFields; }
private static FieldMapping CreateFieldMapping(Expression <Func <Person, object> > expression, string name = null) { var field = new FieldMapping(CreateMember(expression)); if (name != null) { field.Name = name; } return(field); }
/// <summary> /// Gets a value from the underlying data store to be used in an outbound /// field mapping operation /// </summary> /// <param name="fieldName"> The field name that is mapped to a SIFElement</param> /// <param name="typeConverter">The converter class for the requested SIF data type</param> /// <param name="mapping">The FieldMapping this value was generated from or null</param> /// <returns>The value to set to the SIF element. This value must contain the /// SIFSimpleType subclass represented by the SIFTypeConverter passed in to the /// method.</returns> public override SifSimpleType GetSifValue(string fieldName, TypeConverter typeConverter, FieldMapping mapping) { int ordinal = SafeGetOrdinal(fieldName); if (ordinal == -1) { return null; } object value = fDataRow[ordinal]; return typeConverter.GetSifSimpleType(value); }
/// <summary> /// Gets a value from the underlying data store to be used in an outbound /// field mapping operation /// </summary> /// <param name="fieldName"> The field name that is mapped to a SIFElement</param> /// <param name="typeConverter">The converter class for the requested SIF data type</param> /// <param name="mapping">The FieldMapping this value was generated from or null</param> /// <returns>The value to set to the SIF element. This value must contain the /// SIFSimpleType subclass represented by the SIFTypeConverter passed in to the /// method.</returns> public SifSimpleType GetSifValue(string fieldName, TypeConverter typeConverter, FieldMapping mapping) { int ordinal = SafeGetOrdinal(fieldName); if( ordinal == -1 ) { return null; } object value = fReader.GetValue(ordinal); return typeConverter.GetSifSimpleType(value); }
private void CollectFromLSENullOutput(List <IMeasurement> measurements, TypeMapping typeMapping, NullOutput data, _NullOutputMeta meta) { Dictionary <string, FieldMapping> fieldLookup = typeMapping.FieldMappings.ToDictionary(mapping => mapping.Field.Identifier); { // Convert value from "Value" field to measurement FieldMapping fieldMapping = fieldLookup["Value"]; IMeasurement measurement = MakeMeasurement(meta.Value, Convert.ToDouble(data.Value)); measurements.Add(measurement); } }
public async Task EnsureIndexerCreatedAsync() { var definition = new Index() { Name = ConfigurationReader.SearchIndexName, Fields = FieldBuilder.BuildForType <IndexDocument>() }; var dataSource = new DataSource(); dataSource.Name = ConfigurationReader.SearchDataSourceName; dataSource.Credentials = new DataSourceCredentials(ConfigurationReader.BlobStorageConnectionString); dataSource.Type = DataSourceType.AzureBlob; dataSource.Container = new DataContainer(ConfigurationReader.BlobStorageContainerName); await Task.WhenAll( ServiceClient.DataSources.CreateOrUpdateAsync(dataSource), ServiceClient.Indexes.CreateOrUpdateAsync(definition)); var mappingFunctionId = new FieldMappingFunction(); mappingFunctionId.Name = "extractTokenAtPosition"; mappingFunctionId.Parameters = new Dictionary <string, object>(); mappingFunctionId.Parameters.Add("delimiter", "."); mappingFunctionId.Parameters.Add("position", 0); var fieldMappingId = new FieldMapping(); fieldMappingId.SourceFieldName = "metadata_storage_name"; // source field name for azure blob name fieldMappingId.TargetFieldName = nameof(IndexDocument.Id); fieldMappingId.MappingFunction = mappingFunctionId; var fieldMappingContent = new FieldMapping(); fieldMappingContent.SourceFieldName = "content"; // source field name for azure blob content fieldMappingContent.TargetFieldName = nameof(IndexDocument.Content); var indexer = new Indexer(); indexer.Name = ConfigurationReader.SearchIndexerName; indexer.DataSourceName = dataSource.Name; indexer.TargetIndexName = definition.Name; indexer.Parameters = new IndexingParameters(); indexer.Parameters.DoNotFailOnUnsupportedContentType(); indexer.Parameters.IndexFileNameExtensions(ConfigurationReader.SearchIndexerExtensions); indexer.Parameters.MaxFailedItems = -1; indexer.Parameters.MaxFailedItemsPerBatch = -1; indexer.FieldMappings = new List <FieldMapping>(); indexer.FieldMappings.Add(fieldMappingContent); indexer.FieldMappings.Add(fieldMappingId); indexer.Schedule = new IndexingSchedule(TimeSpan.FromMinutes(5)); await ServiceClient.Indexers.CreateOrUpdateAsync(indexer); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Verify everything. /// </summary> /// ------------------------------------------------------------------------------------ protected override bool Verify() { // Commit pending changes in the grid. m_fieldsGrid.CommitEdit(DataGridViewDataErrorContexts.Commit); // Make sure the record marker was specified. if (cboRecordMarkers.SelectedItem == null) { return(ShowError(cboRecordMarkers, LocalizationManager.GetString( "DialogBoxes.SFDataSourcePropertiesDlg.MissingRecordMarkerSpecificationMsg", "You must specify a record marker to identify the beginning of each record."))); } // Make sure a phonetic mapping is specified. if (!FieldMapping.IsPhoneticMapped(m_fieldsGrid.Mappings, true)) { m_fieldsGrid.Focus(); return(false); } // Make sure no field is mapped more than once. if (m_fieldsGrid.GetAreAnyFieldsMappedMultipleTimes()) { return(ShowError(m_fieldsGrid, LocalizationManager.GetString( "DialogBoxes.SFDataSourcePropertiesDlg.MultipleMappingsForSingleFieldMsg", "Each field may only be mapped once."))); } // Make sure the phonetic field is not mapped more than once. if (m_fieldsGrid.GetIsPhoneticMappedMultipleTimes()) { return(ShowError(m_fieldsGrid, LocalizationManager.GetString( "DialogBoxes.SFDataSourcePropertiesDlg.MultiplePhoneticMappingsMsg", "You may only map the phonetic field once.\nA phonetic mapping is specified using the field type."))); } // Make sure the field specified as the toolbox sort field is mapped to a marker. if (ToolBoxSortField != null && !m_fieldsGrid.GetIsSourceFieldMapped(ToolBoxSortField)) { return(ShowError(cboToolboxSortField, LocalizationManager.GetString( "DialogBoxes.SFDataSourcePropertiesDlg.InvalidToolboxSortFieldSpecifiedMsg", "The first Toolbox sort field marker specified was\nnot mapped. It must have a mapping."))); } foreach (var mapping in m_fieldsGrid.Mappings.Where(m => PaField.GetIsReservedFieldName(m.Field.Name))) { return(ShowError(m_fieldsGrid, string.Format(LocalizationManager.GetString( "DialogBoxes.SFDataSourcePropertiesDlg.InvalidFieldNameSpecifiedMsg", "The field name '{0}' is reserved and cannot be used.\nEnter a different name."), mapping.Field.DisplayName))); } return(VerifyInterlinearInfo()); }
private void CollectAnalyzer(FieldMapping field, Analyzer parentAnalyzer, string prefix) { // Field > property > entity analyzer var localAnalyzer = field.Analyzer ?? parentAnalyzer; if (localAnalyzer == null) { throw new NotSupportedException("Analyzer should not be undefined"); } analyzer.AddScopedAnalyzer(prefix + field.Name, localAnalyzer); }
protected void CheckRequiredField <T>(string name, string displayName) { ViewField field = ViewFields.FindByName(name); Assert.That(field, Is.Not.Null, "Unabled to find field: {0}", name); FieldMapping requiredFieldMapping = ModuleMapping.GetFieldMapping(field, false); Assert.That(requiredFieldMapping, Is.Not.Null); Assert.That(requiredFieldMapping, Is.TypeOf <T>()); Assert.That(requiredFieldMapping.Name, Is.EqualTo(displayName)); }
public BatchBuilder Map(Action <BatchFieldBuilder> builder) { var fieldMapping = new FieldMapping(); var fieldBuilder = new BatchFieldBuilder(fieldMapping); builder(fieldBuilder); _batchJob.SourceMapping.Add(fieldMapping); return(this); }
protected IMeasurement GetMeasurement(FieldMapping fieldMapping) { if (fieldMapping.RelativeTime != 0.0M) { AlignmentCoordinator.SampleWindow sampleWindow = CreateSampleWindow(fieldMapping); MeasurementKey key = Keys[m_keyIndex++].Single(); return(AlignmentCoordinator.GetMeasurement(key, CurrentFrameTime, sampleWindow)); } return(SignalLookup.GetMeasurement(Keys[m_keyIndex++].Single())); }
private _NullOutputMeta FillLSE_NullOutputMeta(TypeMapping typeMapping) { Dictionary <string, FieldMapping> fieldLookup = typeMapping.FieldMappings.ToDictionary(mapping => mapping.Field.Identifier); _NullOutputMeta obj = new _NullOutputMeta(); { // Initialize meta value structure to "Value" field FieldMapping fieldMapping = fieldLookup["Value"]; obj.Value = CreateMetaValues(fieldMapping); } return(obj); }
/// <summary> /// These mappings should only be used for Linq querying within the SelectMany() body /// </summary> /// <param name="type"></param> /// <returns></returns> internal IFieldMapping ChildTypeMappingFor(Type type) { if (_childFieldMappings.TryFind(type, out var mapping)) { return(mapping); } mapping = new FieldMapping("d.data", type, this); _childFieldMappings = _childFieldMappings.AddOrUpdate(type, mapping); return(mapping); }
/// <summary> /// 从属性加载表映射关系 /// </summary> /// <param name="Class">实体类型</param> /// <returns></returns> public ITableMapping LoadTableMapping(Type Class) { object[] TAttrs = Class.GetCustomAttributes(typeof(TableMappingAttribute), false); if (TAttrs == null || TAttrs.Length == 0) { throw new MappingException("无法识别的实体类型[" + Class.FullName + "],找不到表映射关系"); } TableMappingAttribute TblMappingAttr = TAttrs[0] as TableMappingAttribute; TableMapping TabMapping = new TableMapping(); TabMapping.TypeName = TblMappingAttr.TableName; TabMapping.TableName = TblMappingAttr.TableName; TabMapping.Generator = TblMappingAttr.KeyGenerator; TabMapping.IsTable = TblMappingAttr.IsTable; //开始查找属性映射 PropertyInfo[] Properties = Class.GetProperties(); if (Properties != null && Properties.Length > 0) { foreach (PropertyInfo Property in Properties) { object[] FAttrs = Property.GetCustomAttributes(typeof(FieldMappingAttribute), false); if (FAttrs != null && FAttrs.Length > 0) { FieldMappingAttribute FMAttr = FAttrs[0] as FieldMappingAttribute; FieldMapping FM = new FieldMapping(); FM.PropertyName = FMAttr.PropertyName; FM.ColumnName = FMAttr.ColumnName; FM.DefauleValue = FMAttr.DefauleValue; FM.FieldLength = FMAttr.FieldLength; FM.FieldType = FMAttr.FieldType; FM.IsNullable = FMAttr.IsNullable; FM.Remark = FMAttr.Remark; TabMapping.FieldMappingCollection.Add(FM); } object[] KeyAttrs = Property.GetCustomAttributes(typeof(PrimaryKeyMappingAttribute), false); if (KeyAttrs != null && KeyAttrs.Length > 0) { PrimaryKeyMappingAttribute FMAttr = KeyAttrs[0] as PrimaryKeyMappingAttribute; PrimaryKeyMapping FM = new PrimaryKeyMapping(); FM.PropertyName = FMAttr.PropertyName; FM.ColumnName = FMAttr.ColumnName; FM.FieldLength = FMAttr.FieldLength; FM.FieldType = FMAttr.FieldType; FM.Remark = FMAttr.Remark; TabMapping.PrimaryKeyCollection.Add(FM); } } } return(TabMapping); }
private void ConnectDestinationProjectButton_Click() { TeamProjectPicker tpp = new TeamProjectPicker(TeamProjectPickerMode.SingleProject, false); System.Windows.Forms.DialogResult result = tpp.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { TargetProject = new TfsProject(tpp.SelectedTeamProjectCollection, tpp.SelectedProjects[0].Name); RaisePropertyChanged("TargetProject"); FieldMapping.Refresh(); UserMapping.Refresh(); } }
/// ------------------------------------------------------------------------------------ protected virtual void PushFieldName(FieldMapping mapping, string fieldName, int rowIndex) { if (fieldName == GetNoMappingText() || fieldName == string.Empty) { mapping.Field = null; mapping.IsParsed = false; mapping.IsInterlinear = false; } else { mapping.Field = m_potentialFields.SingleOrDefault(f => f.DisplayName == fieldName) ?? new PaField(fieldName, GetTypeAtOrDefault(rowIndex)); } }
/// ------------------------------------------------------------------------------------ private IEnumerable <FieldMapping> CreateDefaultFw6Mappings(IEnumerable <PaField> projectFields) { var writingSystems = FwDataSourceInfo.GetWritingSystems(); var defaultFieldNames = Properties.Settings.Default.DefaultMappedFw6Fields.Cast <string>(); // Add mappings for all the other fields. return(from field in projectFields.Where(f => defaultFieldNames.Contains(f.Name)) let wsId = (field.Type == FieldType.Phonetic ? FwDBUtils.GetDefaultPhoneticWritingSystem(writingSystems).Hvo.ToString() : FieldMapping.GetDefaultFw6WsIdForField(field, writingSystems)) select new FieldMapping(field, field.Type == FieldType.Phonetic) { FwWsId = wsId }); }
public string GetOtherType(List <R_FieldInf> fieldInfs, FieldMapping vitalFields) { string othertype = ""; int FieldCount = fieldInfs.Count(); for (int i = 0; i < FieldCount; i++) { if (fieldInfs[i].FieldName != vitalFields.ID && fieldInfs[i].FieldName != vitalFields.Name && fieldInfs[i].FieldName != vitalFields.Address && fieldInfs[i].FieldName != vitalFields.Xcoordinate && fieldInfs[i].FieldName != vitalFields.Ycoordinate) { othertype += "\"" + fieldInfs[i].FieldName + "\":\"" + fieldInfs[i].FieldType + "\","; } } othertype = othertype.Substring(0, othertype.Length - 1); return(othertype); }
private openLSE.Model.LSE.Input CreateLSEInput(TypeMapping typeMapping) { Dictionary <string, FieldMapping> fieldLookup = typeMapping.FieldMappings.ToDictionary(mapping => mapping.Field.Identifier); openLSE.Model.LSE.Input obj = new openLSE.Model.LSE.Input(); { // Create openLSE.Model.ECA.Digitals UDT for "Digitals" field FieldMapping fieldMapping = fieldLookup["Digitals"]; TypeMapping nestedMapping = GetTypeMapping(fieldMapping); PushRelativeFrame(fieldMapping); obj.Digitals = CreateECADigitals(nestedMapping); PopRelativeFrame(fieldMapping); } { // Create openLSE.Model.ECA.StatusWords UDT for "StatusWords" field FieldMapping fieldMapping = fieldLookup["StatusWords"]; TypeMapping nestedMapping = GetTypeMapping(fieldMapping); PushRelativeFrame(fieldMapping); obj.StatusWords = CreateECAStatusWords(nestedMapping); PopRelativeFrame(fieldMapping); } { // Create openLSE.Model.ECA.PhasorCollection UDT for "VoltagePhasors" field FieldMapping fieldMapping = fieldLookup["VoltagePhasors"]; TypeMapping nestedMapping = GetTypeMapping(fieldMapping); PushRelativeFrame(fieldMapping); obj.VoltagePhasors = CreateECAPhasorCollection(nestedMapping); PopRelativeFrame(fieldMapping); } { // Create openLSE.Model.ECA.PhasorCollection UDT for "CurrentPhasors" field FieldMapping fieldMapping = fieldLookup["CurrentPhasors"]; TypeMapping nestedMapping = GetTypeMapping(fieldMapping); PushRelativeFrame(fieldMapping); obj.CurrentPhasors = CreateECAPhasorCollection(nestedMapping); PopRelativeFrame(fieldMapping); } return(obj); }
public void testFieldMapping010() { StudentPersonal sp = new StudentPersonal(); Mappings mappings = fCfg.Mappings.GetMappings("Default"); IDictionary map = buildIDictionaryForStudentPersonalTest(); // Add a "default" to the middle name rule and assert that it gets // created ObjectMapping om = mappings.GetObjectMapping("StudentPersonal", false); FieldMapping middleNameRule = om.GetRule(3); middleNameRule.DefaultValue = "Jerry"; map.Remove("MIDDLE_NAME"); StringMapAdaptor adaptor = new StringMapAdaptor(map); mappings.MapOutbound(adaptor, sp); SifWriter writer = new SifWriter(Console.Out); writer.Write(sp); writer.Flush(); // For the purposes of this test, all we care about is the Ethnicity // mapping. // It should have the default outbound value we specified, which is "7" Assertion.AssertEquals("Middle Name should be Jerry", "Jerry", sp .Name.MiddleName); // Now, remap the student back into application fields IDictionary restoredData = new Hashtable(); adaptor.Dictionary = restoredData; mappings.MapInbound(sp, adaptor); Assertion.AssertEquals("Middle Name should be Jerry", "Jerry", restoredData["MIDDLE_NAME"]); sp.Name.LastName = null; // Now, remap the student back into application fields restoredData = new Hashtable(); adaptor.Dictionary = restoredData; mappings.MapInbound(sp, adaptor); Object lastName = restoredData["LAST_NAME"]; Console.WriteLine(sp.ToXml()); Assertion.AssertNull("Last Name should be null", lastName); }
/// <summary> /// 把字符串格式转化成此格式 /// </summary> /// <param name="stuExpress"></param> /// <returns></returns> private FieldMapping ParseTo(string stuExpress) { if (String.IsNullOrEmpty(stuExpress)) { return(null); } FieldMapping mapping = new FieldMapping(); string[] atts = stuExpress.Split(','); if (atts == null || atts.Length == 0) { return(mapping); } foreach (string att in atts) { if (att.Length == 0) { continue; } string[] nmVal = att.Split('='); if (nmVal == null || nmVal.Length != 2) { continue; } string name = nmVal[0].Trim().ToUpper(); string val = nmVal[1].Trim(); bool btemp = false; int itemp = 0; switch (name) { case "PROPERTYNAME": mapping.PropertyName = val; break; case "COLUMNNAME": mapping.ColumnName = val; break; case "ISNULLABLE": Boolean.TryParse(val, out btemp); mapping.IsNullable = btemp; break; case "FIELDTYPE": mapping.FieldType = Utility.ParseFieldType(val); break; case "FIELDLENGTH": Int32.TryParse(val, out itemp); mapping.FieldLength = itemp; break; case "DEFAULEVALUE": mapping.DefauleValue = val; break; case "REMARK": mapping.Remark = val; break; } } return(mapping); }
public BatchFieldBuilder Map(string name) { var fieldMapping = _batchJob.SourceMapping.FirstOrDefault(m => m.Name == name); if (fieldMapping == null) { fieldMapping = new FieldMapping { Name = name }; _batchJob.SourceMapping.Add(fieldMapping); } var fieldBuilder = new BatchFieldBuilder(fieldMapping); return(fieldBuilder); }
protected MetaValues CreateMetaValues(FieldMapping fieldMapping) { if (fieldMapping.RelativeTime != 0.0M) { AlignmentCoordinator.SampleWindow sampleWindow = CreateSampleWindow(fieldMapping); MeasurementKey key = m_keys[m_keyIndex++].Single(); return(AlignmentCoordinator.CreateMetaValue(key, CurrentFrameTime, sampleWindow)); } return(new MetaValues() { ID = m_keys[m_keyIndex++].Single().SignalID, Timestamp = m_currentFrameTime, Flags = MeasurementFlags.CalculatedValue }); }
protected FieldMapping <TRevision> MergeMapping(params FieldMapping <TRevision>[] mappings) { var merged = new FieldMapping <TRevision>(); foreach (var mapping in mappings) { foreach (var m in mapping) { if (!merged.ContainsKey(m.Key)) { merged[m.Key] = m.Value; } } } return(merged); }
private _InputMeta CreateLSE_InputMeta(TypeMapping typeMapping) { Dictionary <string, FieldMapping> fieldLookup = typeMapping.FieldMappings.ToDictionary(mapping => mapping.Field.Identifier); _InputMeta obj = new _InputMeta(); { // Create _DigitalsMeta UDT for "Digitals" field FieldMapping fieldMapping = fieldLookup["Digitals"]; TypeMapping nestedMapping = GetTypeMapping(fieldMapping); PushRelativeFrame(fieldMapping); obj.Digitals = CreateECA_DigitalsMeta(nestedMapping); PopRelativeFrame(fieldMapping); } { // Create _StatusWordsMeta UDT for "StatusWords" field FieldMapping fieldMapping = fieldLookup["StatusWords"]; TypeMapping nestedMapping = GetTypeMapping(fieldMapping); PushRelativeFrame(fieldMapping); obj.StatusWords = CreateECA_StatusWordsMeta(nestedMapping); PopRelativeFrame(fieldMapping); } { // Create _PhasorCollectionMeta UDT for "VoltagePhasors" field FieldMapping fieldMapping = fieldLookup["VoltagePhasors"]; TypeMapping nestedMapping = GetTypeMapping(fieldMapping); PushRelativeFrame(fieldMapping); obj.VoltagePhasors = CreateECA_PhasorCollectionMeta(nestedMapping); PopRelativeFrame(fieldMapping); } { // Create _PhasorCollectionMeta UDT for "CurrentPhasors" field FieldMapping fieldMapping = fieldLookup["CurrentPhasors"]; TypeMapping nestedMapping = GetTypeMapping(fieldMapping); PushRelativeFrame(fieldMapping); obj.CurrentPhasors = CreateECA_PhasorCollectionMeta(nestedMapping); PopRelativeFrame(fieldMapping); } return(obj); }
public LoadValuesResult LoadValues(string relex, bool totalcount) { var res = new LoadValuesResult(); var relexParser = new RelExParser(); var q = relexParser.Parse(relex); var fldMapping = new FieldMapping(q.Fields); q.Fields = fldMapping.GetCompactFields(); if (totalcount) { res.TotalCount = StorageDalc.RecordsCount(q); } var cols = new List <string>(); var data = new List <object[]>(); StorageDalc.ExecuteReader(q, (reader) => { for (int i = 0; i < q.StartRecord; i++) { reader.Read(); // skip first N records } for (int i = 0; i < reader.FieldCount; i++) { var fName = reader.GetName(i); cols.Add(fldMapping.GetOriginalFieldName(fName)); } while (reader.Read() && data.Count < q.RecordCount) { var values = new object[reader.FieldCount]; reader.GetValues(values); for (int i = 0; i < reader.FieldCount; i++) { if (DBNull.Value.Equals(values[i])) { values[i] = null; } } data.Add(values); } }); res.Columns = cols.ToArray(); res.Data = data; return(res); }
public virtual ClassMapping<object> createMapping(Type type) { ClassMapping<object> mapping = new ClassMapping<object>(); // type mapping.ClassType = type; // table LogicalTable logicalTable = new LogicalTable(); mapping.CorrespondingTable = logicalTable; TableDefinition table = new TableDefinition(); Table tableAttr = AttributeUtils.getSingleAttribute<Table>(type); if (tableAttr != null) { table.Name = tableAttr.Name; } else { table.Name = generateTableName(type.Name); } logicalTable.Name = table.Name; // all fields including id foreach (FieldInfo field in getClassFields(type)) { if (isFieldPersistent(field)) { FieldMapping<object, object> fieldMapping = new FieldMapping<object, object>() {ClassField = field}; TableColumn column = new TableColumn(); logicalTable.AddColumn(column); Column colAttr = AttributeUtils.getSingleAttribute<Column>(field); if (colAttr != null) { column.Name = colAttr.Name; } else { column.Name = field.Name; } fieldMapping.Column = column; table.addColumn(column); mapping.AddPropertyMapping (fieldMapping); Id idAttr = AttributeUtils.getSingleAttribute<Id>(field); if (idAttr != null) { mapping.IdMapping = fieldMapping; column.IsPrimaryKey = true; fieldMapping.IsId = true; } } } return mapping; }
private void CollectFromLVC118DataOutputs(List <IMeasurement> measurements, TypeMapping typeMapping, LVC118.Model.LVC118Data.Outputs data, LVC118.Model.LVC118Data._OutputsMeta meta) { Dictionary <string, FieldMapping> fieldLookup = typeMapping.FieldMappings.ToDictionary(mapping => mapping.Field.Identifier); { // Convert value from "ActTxRaise" field to measurement FieldMapping fieldMapping = fieldLookup["ActTxRaise"]; IMeasurement measurement = MakeMeasurement(meta.ActTxRaise, (double)data.ActTxRaise); measurements.Add(measurement); } { // Convert value from "ActTxLower" field to measurement FieldMapping fieldMapping = fieldLookup["ActTxLower"]; IMeasurement measurement = MakeMeasurement(meta.ActTxLower, (double)data.ActTxLower); measurements.Add(measurement); } { // Convert value from "ActSn1Close" field to measurement FieldMapping fieldMapping = fieldLookup["ActSn1Close"]; IMeasurement measurement = MakeMeasurement(meta.ActSn1Close, (double)data.ActSn1Close); measurements.Add(measurement); } { // Convert value from "ActSn1Trip" field to measurement FieldMapping fieldMapping = fieldLookup["ActSn1Trip"]; IMeasurement measurement = MakeMeasurement(meta.ActSn1Trip, (double)data.ActSn1Trip); measurements.Add(measurement); } { // Convert value from "ActSn2Close" field to measurement FieldMapping fieldMapping = fieldLookup["ActSn2Close"]; IMeasurement measurement = MakeMeasurement(meta.ActSn2Close, (double)data.ActSn2Close); measurements.Add(measurement); } { // Convert value from "ActSn2Trip" field to measurement FieldMapping fieldMapping = fieldLookup["ActSn2Trip"]; IMeasurement measurement = MakeMeasurement(meta.ActSn2Trip, (double)data.ActSn2Trip); measurements.Add(measurement); } }
static public SortFieldType GetSortFieldType(this FieldMapping fieldMapping) { switch (fieldMapping?.FieldType) { case FieldTypes.DoubleType: return(SortFieldType.DOUBLE); case FieldTypes.Int32Type: return(SortFieldType.INT32); case FieldTypes.SingleType: return(SortFieldType.SINGLE); default: return(SortFieldType.STRING); } }
public LogEvent Parse(string line, FieldMapping fieldMap) { var returnValue = new LogEvent(); var fieldValueIndex = 0; foreach (var fieldValue in line.Split(' ')) { if (fieldMap.TryGetValue(fieldValueIndex, out var fieldInfo)) { fieldInfo.SetValue(returnValue, fieldInfo.Convertor.Convert(fieldValue)); } fieldValueIndex += 1; } return(returnValue); }
public LoadRowsResult LoadRows(string relex, bool totalcount) { var res = new LoadRowsResult(); var relexParser = new RelExParser(); var q = relexParser.Parse(relex); var fldMapping = new FieldMapping(q.Fields); q.Fields = fldMapping.GetCompactFields(); if (totalcount) { res.TotalCount = StorageDalc.RecordsCount(q); } var data = new RowList(); StorageDalc.ExecuteReader(q, (reader) => { for (int i = 0; i < q.StartRecord; i++) { reader.Read(); // skip first N records } var cols = new List <string>(); for (int i = 0; i < reader.FieldCount; i++) { var fName = reader.GetName(i); cols.Add(fldMapping.GetOriginalFieldName(fName)); } while (reader.Read() && data.Count < q.RecordCount) { var values = new object[reader.FieldCount]; reader.GetValues(values); var row = new Dictionary <string, object>(values.Length); for (int i = 0; i < reader.FieldCount; i++) { row[cols[i]] = DBNull.Value.Equals(values[i]) ? null : values[i]; } data.Add(new DictionaryItem(row)); } }); res.Data = data; return(res); }
/// <summary> Produces a duplicate of this Rule object /// /// </summary> /// <returns> A "deep copy" of this Rule object /// </returns> public abstract Rule Copy(FieldMapping newParent);
public static OtherIdMapping FromXml(ObjectMapping parent, FieldMapping field, XmlElement element) { // The OtherId type= attribute is required String type = element.GetAttribute("type"); if (type == null) type = element.GetAttribute("Type"); if (type == null) throw new AdkConfigException("Field mapping rule " + parent.ObjectType + "." + field.FieldName + " specifies an <OtherId> without a 'type' attribute"); // The OtherId prefix= attribute is required String prefix = element.GetAttribute("prefix"); if (prefix == null) prefix = element.GetAttribute("Prefix"); if (prefix == null) throw new AdkConfigException("Field mapping rule " + parent.ObjectType + "." + field.FieldName + " specifies an <OtherId> without a 'prefix' attribute"); // Create a new OtherIdMapping as a child of the FieldMapping OtherIdMapping id = new OtherIdMapping(type, prefix, element); return id; }
/// <summary> /// Sets the specified value /// </summary> /// <param name="fieldName"></param> /// <param name="resultingValue"></param> /// <param name="mapping"></param> public void SetSifValue(String fieldName, SifSimpleType resultingValue, FieldMapping mapping) { if (fOverwriteValues || !fMap.Contains(fieldName)) { Object mapValue = ToMapValue(resultingValue); fMap[fieldName] = mapValue; } }
/// <summary> /// Sets a value that has been retrieved from a SIF Element in an inbound field /// mapping operation. /// </summary> /// <param name="fieldName">The field name that is mapped to a SIFElement</param> /// <param name="value">The value of the SIF element</param> /// <param name="mapping">The FieldMappings that will be used to set this value or null</param> public abstract void SetSifValue(string fieldName, SifSimpleType value, FieldMapping mapping);
/// <summary> Insert a FieldMapping definition at the specified index. /// /// </summary> /// <param name="mapping">A FieldMapping that defines the rules for mapping a field /// of the application to an element or attribute of a SIF Data Object. /// There can only be one FieldMapping per unique field name (i.e. if /// you have defined a FieldMapping rule with a field name of 'STUDENTNUM', /// there cannot be another FieldMapping rule with that same field name.) /// To map a single application field to more than one SIF element or /// attribute, create a FieldMapping with a unique field name (e.g. 'STUDENTNUM_2') /// and call the <code>setAlias</code> method to define it as an alias /// of an existing field. /// /// </param> /// <exception cref="AdkMappingException"> thrown if there is already a FieldMapping /// with the specified field name /// </exception> /// <param name="index">The index to insert the rule at</param> public void InsertRule(FieldMapping mapping, int index) { InsertRule(mapping, index, true); }
/// <summary> /// Sets a value that has been retrieved from a SIF Element in an inbound field /// mapping operation. /// </summary> /// <param name="fieldName">The field name that is mapped to a SIFElement</param> /// <param name="value">The value of the SIF element</param> /// <param name="mapping">The FieldMappings that will be used to set this value or null</param> public void SetSifValue(string fieldName, SifSimpleType value, FieldMapping mapping) { throw new NotSupportedException("Unable to set values to a DataReader"); }
/// <summary> Appends a FieldMapping definition /// /// </summary> /// <param name="mapping">A FieldMapping that defines the rules for mapping a field /// of the application to an element or attribute of a SIF Data Object. /// There can only be one FieldMapping per unique field name (i.e. if /// you have defined a FieldMapping rule with a field name of 'STUDENTNUM', /// there cannot be another FieldMapping rule with that same field name.) /// To map a single application field to more than one SIF element or /// attribute, create a FieldMapping with a unique field name (e.g. 'STUDENTNUM_2') /// and call the <code>setAlias</code> method to define it as an alias /// of an existing field. /// /// </param> /// <param name="buildDomTree">true to create a DOM XmlElement element for this /// FieldMapping and append it to the parent XmlElement /// /// </param> /// <exception cref="AdkMappingException"> thrown if there is already a FieldMapping /// with the specified field name /// </exception> protected internal void AddRule(FieldMapping mapping, bool buildDomTree) { InsertRule(mapping, fFieldRules == null ? 0 : fFieldRules.Count, buildDomTree); }
/// <summary> Produces a duplicate of this Rule object /// /// </summary> /// <returns> A "deep copy" of this Rule object /// </returns> public override Rule Copy(FieldMapping newParent) { XPathRule clone = new XPathRule(fDef); if (newParent.fNode != null) { newParent.fNode.InnerText = fDef; } return clone; }
/// <summary> /// Sets a value that has been retrieved from a SIF Element in an inbound field /// mapping operation. /// </summary> /// <param name="fieldName">The field name that is mapped to a SIFElement</param> /// <param name="value">The value of the SIF element</param> /// <param name="mapping">The FieldMappings that will be used to set this value or null</param> public override void SetSifValue(string fieldName, SifSimpleType value, FieldMapping mapping) { int ordinal = SafeGetOrdinal(fieldName); if( ordinal > -1 ) { fDataRow[ordinal] = value.RawValue; } }
protected void SetIdentityColumnInternal(string columnName) { if (string.IsNullOrWhiteSpace(columnName)) throw new ArgumentNullException("columnName"); this.IdentityColumn = columnName; this._identityColumn = GetFieldMappingForColumn(columnName); }
/// <summary> /// TODO /// </summary> /// <param name="fieldMapping"></param> protected void AddFieldMapping(FieldMapping fieldMapping) { if (fieldMapping == null) throw new ArgumentNullException("fieldMapping"); lock (this._mutex) { this._fieldMappings.Add(fieldMapping.ColumnName, fieldMapping); } }
public RecordAttribute() { mColumnMapping = FieldMapping.PrivateFields | FieldMapping.PublicFields; mOverflowBehaviour = OverflowBehaviour.ThrowError; }
/** * Creates a set of mappings that operations can be applied to, such as * saving to a DOM or Agent.cfg. The results can be asserted by calling * {@see #assertMappings(Mappings)}. * * NOTE: This method returns an AgentConfig instance instead of a mappings * instance because there is no way set the Mappings instance on * AgentConfig. This might change in the future * * @return */ private AgentConfig createMappings() { Mappings root = fCfg.Mappings; // Remove the mappings being used root.RemoveChild( root.GetMappings( "Default" ) ); root.RemoveChild( root.GetMappings( "TestID" ) ); Mappings newMappings = root.CreateChild( "Test" ); // Add an object mapping ObjectMapping objMap = new ObjectMapping( "StudentPersonal" ); // Currently, the Adk code requires that an Object Mapping be added // to it's parent before fields are added. // We should re-examine this and perhaps fix it, if possible newMappings.AddRules( objMap ); objMap.AddRule( new FieldMapping( "FIELD1", "Name/FirstName" ) ); // Field 2 FieldMapping field2 = new FieldMapping( "FIELD2", "Name/LastName" ); field2.ValueSetID = "VS1"; field2.Alias = "ALIAS1"; field2.DefaultValue = "DEFAULT1"; MappingsFilter mf = new MappingsFilter(); mf.Direction = MappingDirection.Inbound; mf.SifVersion = SifVersion.SIF11.ToString(); field2.Filter = mf; objMap.AddRule( field2 ); // Field 3 test setting the XML values after it's been added to the // parent object (the code paths are different) FieldMapping field3 = new FieldMapping( "FIELD3", "Name/MiddleName" ); objMap.AddRule( field3 ); field3.ValueSetID = "VS2"; field3.Alias = "ALIAS2"; field3.DefaultValue = "DEFAULT2"; MappingsFilter mf2 = new MappingsFilter(); mf2.Direction = MappingDirection.Outbound; mf2.SifVersion = SifVersion.SIF15r1.ToString(); field3.Filter = mf2; field3.NullBehavior = MappingBehavior.IfNullDefault; OtherIdMapping oim = new OtherIdMapping( "ZZ", "BUSROUTE" ); FieldMapping field4 = new FieldMapping( "FIELD4", oim ); objMap.AddRule( field4 ); field4.DefaultValue = "Default"; field4.ValueSetID = "vs"; field4.Alias = "alias"; field4.DefaultValue = null; field4.ValueSetID = null; field4.Alias = null; field4.NullBehavior = MappingBehavior.IfNullSuppress; // Field4 tests the new datatype attribute FieldMapping field5 = new FieldMapping( "FIELD5", "Demographics/BirthDate" ); objMap.AddRule( field5 ); field5.DataType = SifDataType.Date; // Add a valueset translation ValueSet vs = new ValueSet( "VS1" ); newMappings.AddValueSet( vs ); // Add a few definitions for ( int a = 0; a < 10; a++ ) { vs.Define( "Value" + a, "SifValue" + a, "Title" + a ); } vs.Define( "AppDefault", "0000", "Default App Value" ); vs.SetAppDefault( "AppDefault", true ); vs.Define( "0000", "SifDefault", "Default Sif Value" ); vs.SetSifDefault( "SifDefault", false ); // Add a valueset translation vs = new ValueSet( "VS2" ); newMappings.AddValueSet( vs ); // Add a few definitions for ( int a = 0; a < 3; a++ ) { vs.Define( "q" + a, "w" + a, "t" + a ); } vs.Define( "AppDefault", "0000", "Default Value" ); vs.SetAppDefault( "AppDefault", true ); vs.SetSifDefault( "0000", true ); return fCfg; }
/// <summary> Appends a FieldMapping definition /// /// </summary> /// <param name="mapping">A FieldMapping that defines the rules for mapping a field /// of the application to an element or attribute of a SIF Data Object. /// There can only be one FieldMapping per unique field name (i.e. if /// you have defined a FieldMapping rule with a field name of 'STUDENTNUM', /// there cannot be another FieldMapping rule with that same field name.) /// To map a single application field to more than one SIF element or /// attribute, create a FieldMapping with a unique field name (e.g. 'STUDENTNUM_2') /// and call the <code>setAlias</code> method to define it as an alias /// of an existing field. /// /// </param> /// <exception cref="AdkMappingException"> thrown if there is already a FieldMapping /// with the specified field name /// </exception> public void AddRule(FieldMapping mapping) { InsertRule(mapping, fFieldRules == null ? 0 : fFieldRules.Count, true); }
/// <summary> /// Gets the specified value from the underlying IDictionary /// </summary> /// <param name="fieldName"></param> /// <param name="typeConverter"></param> /// <param name="mapping"></param> /// <returns></returns> public SifSimpleType GetSifValue(String fieldName, TypeConverter typeConverter, FieldMapping mapping) { if (fMap.Contains(fieldName)) { Object value = fMap[fieldName]; return FromMapValue(value, typeConverter); } else { // No value in the Map. Return null return null; } }
/// <summary> Remove a FieldMapping definition</summary> public void RemoveRule(FieldMapping mapping) { if (fFieldRules != null) { fFieldRules.Remove(mapping); // Remove the DOM XmlElement if there is one XmlElement n = mapping.XmlElement; if (n != null) { n.ParentNode.RemoveChild(n); } } }
/// <summary> /// Gets a value from the underlying data store to be used in an outbound /// field mapping operation /// </summary> /// <param name="fieldName"> The field name that is mapped to a SIFElement</param> /// <param name="typeConverter">The converter class for the requested SIF data type</param> /// <param name="mapping">The FieldMapping this value was generated from or null</param> /// <returns>The value to set to the SIF element. This value must contain the /// SIFSimpleType subclass represented by the SIFTypeConverter passed in to the /// method.</returns> public abstract SifSimpleType GetSifValue(string fieldName, TypeConverter typeConverter, FieldMapping mapping);
/// <summary> Insert a FieldMapping definition at the specified index. /// /// </summary> /// <param name="mapping">A FieldMapping that defines the rules for mapping a field /// of the application to an element or attribute of a SIF Data Object. /// There can only be one FieldMapping per unique field name (i.e. if /// you have defined a FieldMapping rule with a field name of 'STUDENTNUM', /// there cannot be another FieldMapping rule with that same field name.) /// To map a single application field to more than one SIF element or /// attribute, create a FieldMapping with a unique field name (e.g. 'STUDENTNUM_2') /// and call the <code>setAlias</code> method to define it as an alias /// of an existing field. /// /// </param> /// <param name="index">The index to insert the rule at</param> /// <param name="buildDomTree">true to create a DOM XmlElement element for this /// FieldMapping and append it to the parent XmlElement /// /// </param> /// <exception cref="OpenADK.Library.Tools.Mapping.AdkMappingException"> AdkMappingException thrown if there is already a FieldMapping /// with the specified field name /// </exception> protected internal void InsertRule(FieldMapping mapping, int index, bool buildDomTree) { XmlElement relativeTo = null; if (fFieldRules == null) { fFieldRules = new List<FieldMapping>(); } else { // Check for duplicate foreach( FieldMapping existing in fFieldRules ) { if( existing.Key == mapping.Key ) { throw new AdkMappingException("Duplicate field mapping: " + mapping.Key, null); } } // If we'll be building a child DOM XmlElement, find the existing XmlElement // that it will be inserted at if (buildDomTree && fNode != null && fFieldRules.Count > index) { relativeTo = fFieldRules[index].XmlElement; } } try { fFieldRules.Insert(index, mapping); } catch (Exception ex) { throw new AdkMappingException(ex.ToString(), null); } if (buildDomTree && fNode != null) { // Create and insert a child DOM XmlElement XmlElement element = fNode.OwnerDocument.CreateElement(Mappings.XML_FIELD); mapping.XmlElement = element; mapping.ToXml( element); if (relativeTo != null) { fNode.InsertBefore(element, relativeTo); } else { fNode.AppendChild(element); } } }
public FieldMapping GetMapping() { FieldMapping mapping = new FieldMapping(_fieldName, _member); mapping.Index = ((IHasIndex)this).Index; mapping.Store = ((IHasStore)this).Store; mapping.IsRequired = _required; mapping.AnalyzerType = ((IHasAnalyzer)this).AnalyzerType; mapping.Boost = _boost; mapping.IsNumeric = _isNumeric; return mapping; }
/** * Evaluates the filters defined for this FieldMapping. If any of the filters * evaluate to false, the FieldMapping is not added * * @param fieldMapping The FieldMapping to add * @return True if the FieldMapping was added. Otherwise false */ private bool AddRule(FieldMapping fieldMapping) { MappingsFilter filt = fieldMapping.Filter; // Filter out this rule? if (filt != null) { if (!filt.EvalDirection(fDirection) || !filt.EvalVersion(fSIFVersion)) return false; } fFieldMappings.Add(fieldMapping); return true; }
private void BuildProperty( DocumentMapping documentMapping, MemberInfo member, Analyzer parentAnalyzer, bool isRoot, string path, BuildContext context ) { IFieldBridge bridge = null; var analyzer = GetAnalyzer(member) ?? parentAnalyzer; var boost = GetBoost(member); var getter = GetGetterFast(documentMapping.MappedClass, member); var documentIdAttribute = AttributeUtil.GetAttribute<DocumentIdAttribute>(member); if (documentIdAttribute != null) { string documentIdName = documentIdAttribute.Name ?? member.Name; bridge = GetFieldBridge(member); if (isRoot) { if (!(bridge is ITwoWayFieldBridge)) { throw new SearchException("Bridge for document id does not implement TwoWayFieldBridge: " + member.Name); } documentMapping.DocumentId = new DocumentIdMapping( documentIdName, member.Name, (ITwoWayFieldBridge)bridge, getter ) { Boost = boost }; } else { // Components should index their document id documentMapping.Fields.Add(new FieldMapping( GetAttributeName(member, documentIdName), bridge, getter ) { Store = Attributes.Store.Yes, Index = Attributes.Index.UnTokenized, Boost = boost }); } } var fieldAttributes = AttributeUtil.GetFields(member); if (fieldAttributes.Length > 0) { if (bridge == null) bridge = GetFieldBridge(member); foreach (var fieldAttribute in fieldAttributes) { var fieldAnalyzer = GetAnalyzerByType(fieldAttribute.Analyzer) ?? analyzer; var field = new FieldMapping( GetAttributeName(member, fieldAttribute.Name), bridge, getter ) { Store = fieldAttribute.Store, Index = fieldAttribute.Index, Analyzer = fieldAnalyzer }; documentMapping.Fields.Add(field); } } var embeddedAttribute = AttributeUtil.GetAttribute<IndexedEmbeddedAttribute>(member); if (embeddedAttribute != null) { int oldMaxLevel = maxLevel; int potentialLevel = embeddedAttribute.Depth + level; if (potentialLevel < 0) { potentialLevel = int.MaxValue; } maxLevel = potentialLevel > maxLevel ? maxLevel : potentialLevel; level++; System.Type elementType = embeddedAttribute.TargetElement ?? GetMemberTypeOrGenericArguments(member); var localPrefix = embeddedAttribute.Prefix == "." ? member.Name + "." : embeddedAttribute.Prefix; if (maxLevel == int.MaxValue && context.Processed.Contains(elementType)) { throw new SearchException( string.Format( "Circular reference, Duplicate use of {0} in root entity {1}#{2}", elementType.FullName, context.Root.MappedClass.FullName, path + localPrefix)); } if (level <= maxLevel) { context.Processed.Add(elementType); // push var embedded = new EmbeddedMapping(new DocumentMapping(elementType) { Boost = GetBoost(member), Analyzer = GetAnalyzer(member) ?? parentAnalyzer }, getter) { Prefix = localPrefix }; BuildClass(embedded.Class, false, path + localPrefix, context); /** * We will only index the "expected" type but that's OK, HQL cannot do downcasting either */ // ayende: because we have to deal with generic collections here, we aren't // actually using the element type to determine what the value is, since that // was resolved to the element type of the possible collection Type actualFieldType = GetMemberTypeOrGenericCollectionType(member); embedded.IsCollection = typeof(IEnumerable).IsAssignableFrom(actualFieldType); documentMapping.Embedded.Add(embedded); context.Processed.Remove(actualFieldType); // pop } else if (logger.IsDebugEnabled) { logger.Debug("Depth reached, ignoring " + path + localPrefix); } level--; maxLevel = oldMaxLevel; // set back the old max level } if (AttributeUtil.HasAttribute<ContainedInAttribute>(member)) { documentMapping.ContainedIn.Add(new ContainedInMapping(getter)); } }