private static void addCustomValue(XElement parent, PropertyAuditingData propertyAuditingData, IValue value, ISimpleMapperBuilder mapper, bool insertable, bool key, System.Type typeOfUserImplementation) { if (parent != null) { var propMapping = MetadataTools.AddProperty(parent, propertyAuditingData.Name, typeOfUserImplementation.AssemblyQualifiedName, insertable, key); MetadataTools.AddColumns(propMapping, value.ColumnIterator.OfType <Column>()); var typeElement = new XElement(MetadataTools.CreateElementName("type"), new XAttribute("name", typeOfUserImplementation.AssemblyQualifiedName)); var simpleValue = value as SimpleValue; if (simpleValue != null) { var typeParameters = simpleValue.TypeParameters; if (typeParameters != null) { foreach (var paramKeyValue in typeParameters) { var typeParam = new XElement(MetadataTools.CreateElementName("param"), new XAttribute("name", paramKeyValue.Key), paramKeyValue.Value); typeElement.Add(typeParam); } } } propMapping.Add(typeElement); } if (mapper != null) { mapper.Add(propertyAuditingData.GetPropertyData()); } }
public bool AddBasic(XElement parent, PropertyAuditingData propertyAuditingData, IValue value, ISimpleMapperBuilder mapper, bool insertable, bool key) { var type = value.Type; var custType = type as CustomType; var compType = type as CompositeCustomType; if (type is ImmutableType || type is MutableType) { var mappingType = type.GetType(); var userDefined = isUserDefined(mappingType); if (userDefined) { addCustomValue(parent, propertyAuditingData, value, mapper, insertable, key, mappingType); } else { addSimpleValue(parent, propertyAuditingData, value, mapper, insertable, key); } } else if (custType != null) { addCustomValue(parent, propertyAuditingData, value, mapper, insertable, key, custType.UserType.GetType()); } else if (compType != null) { addCustomValue(parent, propertyAuditingData, value, mapper, insertable, key, compType.UserType.GetType()); } else { return(false); } return(true); }
private void AddCustomValue(XmlElement parent, PropertyAuditingData propertyAuditingData, IValue value, ISimpleMapperBuilder mapper, bool insertable, bool key) { if (parent != null) { XmlElement prop_mapping = MetadataTools.AddProperty(parent, propertyAuditingData.Name, null, insertable, key); //CustomType propertyType = (CustomType) value.getType(); XmlElement type_mapping = parent.OwnerDocument.CreateElement("type"); prop_mapping.AppendChild(type_mapping); type_mapping.SetAttribute("name", value.GetType().Name); if (value is SimpleValue) { IDictionary<string, string> typeParameters = ((SimpleValue)value).TypeParameters; if (typeParameters != null) { foreach (KeyValuePair<string,string> paramKeyValue in typeParameters) { XmlElement type_param = parent.OwnerDocument.CreateElement("param"); type_param.SetAttribute("name", (String) paramKeyValue.Key); type_param["name"].Value = paramKeyValue.Value; } } } MetadataTools.AddColumns(prop_mapping, (IEnumerator<ISelectable>)value.ColumnIterator); } if (mapper != null) { mapper.Add(propertyAuditingData.getPropertyData()); } }
public bool AddBasic(XmlElement parent, PropertyAuditingData propertyAuditingData, IValue value, ISimpleMapperBuilder mapper, bool insertable, bool key) { NHibernate.Type.IType type = value.Type; if (type is ImmutableType || type is MutableType) { AddSimpleValue(parent, propertyAuditingData, value, mapper, insertable, key); } else if (type is CustomType || type is CompositeCustomType) { AddCustomValue(parent, propertyAuditingData, value, mapper, insertable, key); } // TODO Simon: There is no equivalent of PrimitiveByteArrayBlobType in NHibernate, will see later if needed // ORIG: //else if ("org.hibernate.type.PrimitiveByteArrayBlobType".equals(type.getClass().getName())) //{ // AddSimpleValue(parent, propertyAuditingData, value, mapper, insertable, key); //} else { return(false); } return(true); }
private static void AddCustomValue(XmlElement parent, PropertyAuditingData propertyAuditingData, IValue value, ISimpleMapperBuilder mapper, bool insertable, bool key, System.Type typeOfUserImplementation) { if (parent != null) { var prop_mapping = MetadataTools.AddProperty(parent, propertyAuditingData.Name, null, insertable, key); MetadataTools.AddColumns(prop_mapping, value.ColumnIterator.OfType<Column>()); var typeElement = parent.OwnerDocument.CreateElement("type"); typeElement.SetAttribute("name", typeOfUserImplementation.AssemblyQualifiedName); var simpleValue = value as SimpleValue; if (simpleValue != null) { var typeParameters = simpleValue.TypeParameters; if (typeParameters != null) { foreach (var paramKeyValue in typeParameters) { var type_param = typeElement.OwnerDocument.CreateElement("param"); type_param.SetAttribute("name", paramKeyValue.Key); type_param.InnerText = paramKeyValue.Value; typeElement.AppendChild(type_param); } } } prop_mapping.AppendChild(typeElement); } if (mapper != null) { mapper.Add(propertyAuditingData.GetPropertyData()); } }
public bool AddBasic(XmlElement parent, PropertyAuditingData propertyAuditingData, IValue value, ISimpleMapperBuilder mapper, bool insertable, bool key) { var type = value.Type; var custType = type as CustomType; var compType = type as CompositeCustomType; if (type is ImmutableType || type is MutableType) { AddSimpleValue(parent, propertyAuditingData, value, mapper, insertable, key); } else if (custType != null) { AddCustomValue(parent, propertyAuditingData, value, mapper, insertable, key, custType.UserType.GetType()); } else if (compType != null) { AddCustomValue(parent, propertyAuditingData, value, mapper, insertable, key, compType.UserType.GetType()); } else { return false; } return true; }
private static void addSimpleValue(XElement parent, PropertyAuditingData propertyAuditingData, IValue value, ISimpleMapperBuilder mapper, bool insertable, bool key) { if (parent != null) { var propMapping = MetadataTools.AddProperty(parent, propertyAuditingData.Name, value.Type.Name, propertyAuditingData.ForceInsertable || insertable, key, propertyAuditingData.AccessType); MetadataTools.AddColumns(propMapping, value.ColumnIterator.OfType <Column>()); } // A null mapper means that we only want to add xml mappings mapper?.Add(propertyAuditingData.GetPropertyData()); }
private void AddSimpleValue(XmlElement parent, PropertyAuditingData propertyAuditingData, IValue value, ISimpleMapperBuilder mapper, bool insertable, bool key) { if (parent != null) { XmlElement prop_mapping = MetadataTools.AddProperty(parent, propertyAuditingData.Name, value.Type.Name, propertyAuditingData.ForceInsertable || insertable, key); MetadataTools.AddColumns(prop_mapping, (IEnumerator<ISelectable>)value.ColumnIterator.GetEnumerator()); } // A null mapper means that we only want to add xml mappings if (mapper != null) { mapper.Add(propertyAuditingData.getPropertyData()); } }
private void AddSimpleValue(XmlElement parent, PropertyAuditingData propertyAuditingData, IValue value, ISimpleMapperBuilder mapper, bool insertable, bool key) { if (parent != null) { XmlElement prop_mapping = MetadataTools.AddProperty(parent, propertyAuditingData.Name, value.Type.Name, propertyAuditingData.ForceInsertable || insertable, key); MetadataTools.AddColumns(prop_mapping, (IEnumerator <ISelectable>)value.ColumnIterator.GetEnumerator()); } // A null mapper means that we only want to add xml mappings if (mapper != null) { mapper.Add(propertyAuditingData.getPropertyData()); } }
//@SuppressWarnings({"unchecked"}) private void AddIdProperties(XmlElement parent, IEnumerator<Property> properties, ISimpleMapperBuilder mapper, bool key) { while (properties.MoveNext() ) { Property property = properties.Current; IType propertyType = property.Type; if (!"_identifierMapper".Equals(property.Name)) { if (propertyType is ImmutableType) { // Last but one parameter: ids are always insertable mainGenerator.BasicMetadataGenerator.AddBasic(parent, GetIdPersistentPropertyAuditingData(property), property.Value, mapper, true, key); } else { throw new MappingException("Type not supported: " + propertyType.Name); } } } }
public bool AddBasic(XmlElement parent, PropertyAuditingData propertyAuditingData, IValue value, ISimpleMapperBuilder mapper, bool insertable, bool key) { NHibernate.Type.IType type = value.Type; if (type is ImmutableType || type is MutableType) { AddSimpleValue(parent, propertyAuditingData, value, mapper, insertable, key); } else if (type is CustomType || type is CompositeCustomType) { AddCustomValue(parent, propertyAuditingData, value, mapper, insertable, key); } // TODO Simon: There is no equivalent of PrimitiveByteArrayBlobType in NHibernate, will see later if needed // ORIG: //else if ("org.hibernate.type.PrimitiveByteArrayBlobType".equals(type.getClass().getName())) //{ // AddSimpleValue(parent, propertyAuditingData, value, mapper, insertable, key); //} else { return false; } return true; }
private void AddCustomValue(XmlElement parent, PropertyAuditingData propertyAuditingData, IValue value, ISimpleMapperBuilder mapper, bool insertable, bool key) { if (parent != null) { XmlElement prop_mapping = MetadataTools.AddProperty(parent, propertyAuditingData.Name, null, insertable, key); //CustomType propertyType = (CustomType) value.getType(); XmlElement type_mapping = parent.OwnerDocument.CreateElement("type"); prop_mapping.AppendChild(type_mapping); type_mapping.SetAttribute("name", value.GetType().Name); if (value is SimpleValue) { IDictionary <string, string> typeParameters = ((SimpleValue)value).TypeParameters; if (typeParameters != null) { foreach (KeyValuePair <string, string> paramKeyValue in typeParameters) { XmlElement type_param = parent.OwnerDocument.CreateElement("param"); type_param.SetAttribute("name", (String)paramKeyValue.Key); type_param["name"].Value = paramKeyValue.Value; } } } MetadataTools.AddColumns(prop_mapping, (IEnumerator <ISelectable>)value.ColumnIterator); } if (mapper != null) { mapper.Add(propertyAuditingData.getPropertyData()); } }
private void addIdProperties(XElement parent, IEnumerable <Property> properties, ISimpleMapperBuilder mapper, bool key) { foreach (var property in properties) { var propertyType = property.Type; if (!"_identifierMapper".Equals(property.Name)) { if (!propertyType.IsMutable) { if (propertyType is ManyToOneType) { _mainGenerator.BasicMetadataGenerator.AddKeyManyToOne(parent, getIdPersistentPropertyAuditingData(property), property.Value, mapper); } else { // Last but one parameter: ids are always insertable _mainGenerator.BasicMetadataGenerator.AddBasic(parent, getIdPersistentPropertyAuditingData(property), property.Value, mapper, true, key); } } else { throw new MappingException("Type not supported: " + propertyType.Name); } } } }
public void AddKeyManyToOne(XElement parent, PropertyAuditingData propertyAuditingData, IValue value, ISimpleMapperBuilder mapper) { var type = value.Type; var element = mapper == null? MetadataTools.AddKeyManyToOne(parent, propertyAuditingData.Name, type.ReturnedClass.AssemblyQualifiedName) : MetadataTools.AddManyToOne(parent, propertyAuditingData.Name, type.ReturnedClass.AssemblyQualifiedName, true, false); MetadataTools.AddColumns(element, value.ColumnIterator.OfType <Column>()); // A null mapper occurs when adding to composite-id element if (mapper != null) { mapper.Add(propertyAuditingData.GetPropertyData()); } }
//@SuppressWarnings({"unchecked"}) private void AddIdProperties(XmlElement parent, IEnumerator <Property> properties, ISimpleMapperBuilder mapper, bool key) { while (properties.MoveNext()) { Property property = properties.Current; IType propertyType = property.Type; if (!"_identifierMapper".Equals(property.Name)) { if (propertyType is ImmutableType) { // Last but one parameter: ids are always insertable mainGenerator.BasicMetadataGenerator.AddBasic(parent, GetIdPersistentPropertyAuditingData(property), property.Value, mapper, true, key); } else { throw new MappingException("Type not supported: " + propertyType.Name); } } } }