protected override void ApplyValueTypeListTemplate(ValueTypeProperty prop) { this.WriteLine(" // value list property"); Properties.ValueCollectionProperty.Call(Host, ctx, this.MembersToSerialize, prop); }
/// <summary> /// returns a <Property/> element describing the property /// without regards for the IsList flag. /// </summary> /// therefore it can be used both when defining a type (IsList == /// false) and when defining the CollectionEntry (IsList == true) internal static string PlainPropertyDefinitionFromValueType(ValueTypeProperty prop, string name, string implementationSuffix) { string type = prop.GetElementTypeString(); string maxlength = String.Empty; string precScaleAttr = String.Empty; string concurrency = String.Empty; // strip nullable "?" if (prop.IsNullable() && type.EndsWith("?")) { type = type.Substring(0, type.Length - 1); } switch (type) { case "bool": type = "Boolean"; break; case "decimal": type = "Decimal"; break; case "double": type = "Double"; break; case "int": type = "Int32"; break; case "string": type = "String"; break; } if (prop is EnumerationProperty) { type = "Int32"; name += implementationSuffix; } if (prop is StringProperty) { maxlength = String.Format("MaxLength=\"{0}\" ", ((StringProperty)prop).GetMaxLength()); } if (prop is DecimalProperty) { DecimalProperty dp = (DecimalProperty)prop; // must have one space at the end precScaleAttr = String.Format("Precision=\"{0}\" Scale=\"{1}\" ", dp.Precision, dp.Scale); } if (prop.ObjectClass is ObjectClass && ((ObjectClass)prop.ObjectClass).ImplementsIChangedBy() && prop.Name == "ChangedOn") { concurrency = "ConcurrencyMode=\"Fixed\""; } return String.Format("<Property Name=\"{0}\" Type=\"{1}\" Nullable=\"{2}\" {3}{4} {5}/>", name, type, prop.IsNullable() ? "true" : "false", maxlength, precScaleAttr, concurrency); }
protected override void ApplyValueTypeListTemplate(ValueTypeProperty prop) { this.WriteLine(" // value list property"); Templates.Properties.ValueCollectionProperty.Call(Host, ctx, MembersToSerialize, prop, "ClientValueCollectionAsListWrapper", "ClientValueListWrapper"); }
protected override void ApplyValueTypeListTemplate(ValueTypeProperty prop) { this.WriteLine(" // value list property"); Templates.Properties.ValueCollectionProperty.Call(Host, ctx, MembersToSerialize, prop, "ClientValueCollectionAsListWrapper", "ClientValueListWrapper"); }
public static void Call(Arebis.CodeGeneration.IGenerationHost host, IZetboxContext ctx, Templates.Serialization.SerializationMembersList serializationList, ValueTypeProperty prop) { if (prop == null) throw new ArgumentNullException("prop"); Call(host, ctx, serializationList, prop, prop.HasPersistentOrder, prop.IsList, !prop.HasPersistentOrder); }
public static void Call(Arebis.CodeGeneration.IGenerationHost _host, string prefix, ValueTypeProperty prop, string propName, string columnName, bool forceDefinition, string implementationSuffix, bool needsConcurrency) { if (_host == null) throw new ArgumentNullException("_host"); if (prop == null) throw new ArgumentNullException("prop"); // shortcut unmapped properties if (prop.IsCalculated) { _host.WriteOutput(string.Format("<!-- ValueTypeProperty {0} is calculated and persisted -->\n", prop.Name)); } propName = string.IsNullOrEmpty(propName) ? prop.Name : propName; columnName = string.IsNullOrEmpty(columnName) ? Construct.ColumnName(prop, prefix) : prefix + columnName; var optimisticLock = needsConcurrency && propName == "ChangedOn"; string typeAttr = String.Empty; if (prop is DateTimeProperty) { typeAttr = "type=\"Timestamp\""; } string ceClassAttr; if (prop.IsList && !forceDefinition) { // set the proper type for collection entries ceClassAttr = String.Format("class=\"{0}.{1}{2}+{1}Proxy,Zetbox.Objects.NHibernateImpl\"", prop.GetCollectionEntryNamespace(), prop.GetCollectionEntryClassName(), implementationSuffix); } else { // not needed ceClassAttr = String.Empty; } string ceReverseKeyColumnName = Construct.ForeignKeyColumnName(prop); string listPositionColumnName = Construct.ListPositionColumnName(prop); Call(_host, prefix, propName, columnName, prop.IsList && !forceDefinition, typeAttr, ceClassAttr, ceReverseKeyColumnName, listPositionColumnName, optimisticLock); }
public static void Call(Arebis.CodeGeneration.IGenerationHost host, IZetboxContext ctx, Serialization.SerializationMembersList serializationList, ValueTypeProperty prop, string collectionWrapperClass, string listWrapperClass) { if (prop == null) throw new ArgumentNullException("prop"); Call(host, ctx, serializationList, prop, prop.HasPersistentOrder, prop.IsList, collectionWrapperClass, listWrapperClass); }
public static void Call(Arebis.CodeGeneration.IGenerationHost host, IZetboxContext ctx, Templates.Serialization.SerializationMembersList serializationList, ValueTypeProperty prop) { if (prop == null) { throw new ArgumentNullException("prop"); } Call(host, ctx, serializationList, prop, prop.HasPersistentOrder, prop.IsList, !prop.HasPersistentOrder); }
public static void Call(Arebis.CodeGeneration.IGenerationHost host, IZetboxContext ctx, Serialization.SerializationMembersList serializationList, ValueTypeProperty prop, string collectionWrapperClass, string listWrapperClass) { if (prop == null) { throw new ArgumentNullException("prop"); } Call(host, ctx, serializationList, prop, prop.HasPersistentOrder, prop.IsList, collectionWrapperClass, listWrapperClass); }
public bool IsMoveValueTypePropertyList(ValueTypeProperty prop) { var saved = savedSchema.FindPersistenceObject<ValueTypeProperty>(prop.ExportGuid); if (saved == null) return false; return saved.ObjectClass.ExportGuid != prop.ObjectClass.ExportGuid; }
public static string ValueListCollectionTableName(ValueTypeProperty prop) { throw new NotImplementedException(); }
set => this.SetValue(ValueTypeProperty, value);
public static void Call(Arebis.CodeGeneration.IGenerationHost host, IZetboxContext ctx, ValueTypeProperty prop) { if (host == null) { throw new ArgumentNullException("host"); } host.CallTemplate("CollectionEntries.ValueCollectionEntry", ctx, prop); }
protected virtual void ApplyValueTypeListTemplate(ValueTypeProperty prop) { this.WriteLine(" // value list property"); ApplyListProperty(prop, this.MembersToSerialize); }
public static string ValueListCollectionTableName(ValueTypeProperty prop) { throw new NotImplementedException(); }
protected virtual void ApplyValueTypeListTemplate(ValueTypeProperty prop) { this.WriteLine(" // value list property"); ApplyListProperty(prop, this.MembersToSerialize); }
public static string ListPositionColumnName(ValueTypeProperty prop) { if (prop == null) throw new ArgumentNullException("prop"); return prop.Name + Zetbox.API.Helper.PositionSuffix; }
protected override void ApplyValueTypeListTemplate(ValueTypeProperty prop) { this.WriteLine(" // value list property"); Properties.ValueCollectionProperty.Call(Host, ctx, this.MembersToSerialize, prop); }
public void DoChangeValueTypeProperty_To_NotNullable(ObjectClass objClass, ValueTypeProperty prop, string prefix) { var tblName = db.GetTableName(objClass.Module.SchemaName, objClass.TableName); var colName = Construct.NestedColumnName(prop, prefix); if (db.CheckColumnContainsNulls(tblName, colName)) { Log.ErrorFormat("column '{0}.{1}' contains NULL values, cannot set NOT NULLABLE", tblName, colName); } else { db.AlterColumn(tblName, colName, prop.GetDbType(), prop.GetSize(), prop.GetScale(), prop.IsNullable(), null); } }
public bool IsRenameValueTypePropertyListName(ValueTypeProperty prop) { var saved = savedSchema.FindPersistenceObject<ValueTypeProperty>(prop.ExportGuid); if (saved == null) return false; return saved.Name != prop.Name; }
public bool IsNewValueTypePropertyList(ValueTypeProperty prop) { return savedSchema.FindPersistenceObject<Property>(prop.ExportGuid) == null; }
protected virtual void ApplyValueTypePropertyTemplate(ValueTypeProperty prop) { this.WriteLine(" // value type property"); ApplyNotifyingValueProperty(prop, this.MembersToSerialize); }
protected override void ApplyValueTypePropertyTemplate(ValueTypeProperty prop) { ApplyNotifyingValueProperty(prop, this.MembersToSerialize); }
public static void Call(Arebis.CodeGeneration.IGenerationHost host, IZetboxContext ctx, ValueTypeProperty prop) { if (host == null) { throw new ArgumentNullException("host"); } host.CallTemplate("CollectionEntries.ValueCollectionEntry", ctx, prop); }
public bool IsNewValueTypePropertyNullable(ValueTypeProperty prop) { return prop.IsNullable() && savedSchema.FindPersistenceObject<ValueTypeProperty>(prop.ExportGuid) == null; }
/// <summary> /// returns a <Property/> element describing the property /// without regards for the IsList flag. /// </summary> /// therefore it can be used both when defining a type (IsList == /// false) and when defining the CollectionEntry (IsList == true) internal static string PlainPropertyDefinitionFromValueType(ValueTypeProperty prop, string name, string implementationSuffix) { string type = prop.GetElementTypeString(); string maxlength = String.Empty; string precScaleAttr = String.Empty; string concurrency = String.Empty; // strip nullable "?" if (prop.IsNullable() && type.EndsWith("?")) { type = type.Substring(0, type.Length - 1); } switch (type) { case "bool": type = "Boolean"; break; case "decimal": type = "Decimal"; break; case "double": type = "Double"; break; case "int": type = "Int32"; break; case "string": type = "String"; break; } if (prop is EnumerationProperty) { type = "Int32"; name += implementationSuffix; } if (prop is StringProperty) { maxlength = String.Format("MaxLength=\"{0}\" ", ((StringProperty)prop).GetMaxLength()); } if (prop is DecimalProperty) { DecimalProperty dp = (DecimalProperty)prop; // must have one space at the end precScaleAttr = String.Format("Precision=\"{0}\" Scale=\"{1}\" ", dp.Precision, dp.Scale); } if (prop.ObjectClass is ObjectClass && ((ObjectClass)prop.ObjectClass).ImplementsIChangedBy() && prop.Name == "ChangedOn") { concurrency = "ConcurrencyMode=\"Fixed\""; } return(String.Format("<Property Name=\"{0}\" Type=\"{1}\" Nullable=\"{2}\" {3}{4} {5}/>", name, type, prop.IsNullable() ? "true" : "false", maxlength, precScaleAttr, concurrency)); }
public bool IsRenameValueTypePropertyName(ObjectClass objClass, ValueTypeProperty prop, string prefix) { var saved = savedSchema.FindPersistenceObject<ValueTypeProperty>(prop.ExportGuid); if (saved == null) return false; return Construct.NestedColumnName(saved, prefix) != Construct.NestedColumnName(prop, prefix); }
public void DoChangeDefaultValue(ObjectClass objClass, ValueTypeProperty prop, string prefix) { var tblName = db.GetTableName(objClass.Module.SchemaName, objClass.TableName); var colName = Construct.NestedColumnName(prop, prefix); // Use current nullable definition. // Another case is responsible to change that. var currentIsNullable = db.GetIsColumnNullable(tblName, colName); db.AlterColumn(tblName, colName, prop.GetDbType(), prop.GetSize(), prop.GetScale(), currentIsNullable, SchemaManager.GetDefaultConstraint(prop)); }
public void DoChangeValueTypeProperty_To_Nullable(ObjectClass objClass, ValueTypeProperty prop, string prefix) { var tblName = db.GetTableName(objClass.Module.SchemaName, objClass.TableName); var colName = Construct.NestedColumnName(prop, prefix); db.AlterColumn(tblName, colName, prop.GetDbType(), prop.GetSize(), prop.GetScale(), prop.IsNullable(), null); }
public void DoMoveValueTypeProperty(ObjectClass objClass, ValueTypeProperty prop, string prefix) { var saved = savedSchema.FindPersistenceObject<ValueTypeProperty>(prop.ExportGuid); // Refleced changed hierarchie var currentOriginObjClass = schema.FindPersistenceObject<ObjectClass>(saved.ObjectClass.ExportGuid); var movedUp = IsParentOf(objClass, currentOriginObjClass); var movedDown = IsParentOf(currentOriginObjClass, objClass); var tblName = db.GetTableName(objClass.Module.SchemaName, objClass.TableName); var srcTblName = db.GetTableName(saved.Module.SchemaName, ((ObjectClass)saved.ObjectClass).TableName); var colName = Construct.NestedColumnName(prop, prefix); var srcColName = Construct.NestedColumnName(saved, prefix); // TODO: What if prefix has changed var dbType = prop.GetDbType(); var size = prop.GetSize(); var scale = prop.GetScale(); var defConstr = SchemaManager.GetDefaultConstraint(prop); if (movedUp) { Log.InfoFormat("Moving property '{0}' from '{1}' up to '{2}'", prop.Name, saved.ObjectClass.Name, objClass.Name); db.CreateColumn(tblName, colName, dbType, size, scale, true, defConstr); db.CopyColumnData(srcTblName, srcColName, tblName, colName); if (!prop.IsNullable()) { if (db.CheckColumnContainsNulls(tblName, colName)) { Log.ErrorFormat("column '{0}.{1}' contains NULL values, cannot set NOT NULLABLE", tblName, colName); } else { db.AlterColumn(tblName, colName, dbType, size, scale, prop.IsNullable(), defConstr); } } if (db.CheckColumnExists(srcTblName, srcColName)) db.DropColumn(srcTblName, srcColName); } else if (movedDown) { Log.InfoFormat("Moving property '{0}' from '{1}' down to '{2}' (dataloss possible)", prop.Name, saved.ObjectClass.Name, objClass.Name); db.CreateColumn(tblName, colName, dbType, size, scale, true, defConstr); db.CopyColumnData(srcTblName, srcColName, tblName, colName); if (!prop.IsNullable()) { db.AlterColumn(tblName, colName, dbType, size, scale, prop.IsNullable(), defConstr); } if (db.CheckColumnExists(srcTblName, srcColName)) db.DropColumn(srcTblName, srcColName); } else { Log.ErrorFormat("Moving property '{2}' from '{0}' to '{1}' is not supported. ObjectClasses are not in the same hierarchy. Will only create destination column.", saved.ObjectClass.Name, prop.ObjectClass.Name, prop.Name); db.CreateColumn(tblName, colName, dbType, size, scale, true, defConstr); } }
public void DoNewValueTypePropertyList(ObjectClass objClass, ValueTypeProperty prop) { Log.InfoFormat("New ValueType Property List: {0}", prop.Name); var tblName = db.GetTableName(prop.Module.SchemaName, prop.GetCollectionEntryTable()); string fkName = prop.GetCollectionEntryReverseKeyColumnName(); string valPropName = prop.Name; string valPropIndexName = prop.Name + "Index"; string assocName = prop.GetAssociationName(); bool hasPersistentOrder = prop.HasPersistentOrder; db.CreateTable(tblName, true); db.CreateColumn(tblName, fkName, System.Data.DbType.Int32, 0, 0, false); db.CreateColumn(tblName, valPropName, prop.GetDbType(), prop.GetSize(), prop.GetScale(), false, SchemaManager.GetDefaultConstraint(prop)); if (hasPersistentOrder) { db.CreateColumn(tblName, valPropIndexName, System.Data.DbType.Int32, 0, 0, false); } db.CreateFKConstraint(tblName, db.GetTableName(objClass.Module.SchemaName, objClass.TableName), fkName, assocName, true); db.CreateIndex(tblName, Construct.IndexName(tblName.Name, fkName), false, false, fkName); }
public void DoNewValueTypePropertyNotNullable(ObjectClass objClass, ValueTypeProperty prop, string prefix) { var tblName = db.GetTableName(objClass.Module.SchemaName, objClass.TableName); var colName = Construct.NestedColumnName(prop, prefix); var dbType = prop.GetDbType(); var size = prop.GetSize(); var scale = prop.GetScale(); var def = SchemaManager.GetDefaultConstraint(prop); Log.InfoFormat("New not nullable ValueType Property: [{0}.{1}] (col:{2})", prop.ObjectClass.Name, prop.Name, colName); if (!db.CheckTableContainsData(tblName)) { db.CreateColumn(tblName, colName, dbType, size, scale, false, def); } else { db.CreateColumn(tblName, colName, dbType, size, scale, true, def); Log.ErrorFormat("unable to create new not nullable ValueType Property '{0}' when table '{1}' contains data. Created nullable column instead.", colName, tblName); } }
public static string ForeignKeyColumnName(ValueTypeProperty listProp) { if (listProp == null) { throw new ArgumentNullException("listProp"); } return ForeignKeyColumnName(listProp.ObjectClass.Name); }
public void DoNewValueTypePropertyNullable(ObjectClass objClass, ValueTypeProperty prop, string prefix) { string colName = Construct.NestedColumnName(prop, prefix); Log.InfoFormat("New nullable ValueType Property: '{0}' ('{1}')", prop.Name, colName); db.CreateColumn(db.GetTableName(objClass.Module.SchemaName, objClass.TableName), colName, prop.GetDbType(), prop.GetSize(), prop.GetScale(), true, SchemaManager.GetDefaultConstraint(prop)); }
protected virtual void ApplyValueTypePropertyTemplate(ValueTypeProperty prop) { this.WriteLine(" // value type property"); ApplyNotifyingValueProperty(prop, this.MembersToSerialize); }
public void DoRenameValueTypePropertyListName(ObjectClass objClass, ValueTypeProperty prop) { var saved = savedSchema.FindPersistenceObject<ValueTypeProperty>(prop.ExportGuid); Log.ErrorFormat("renaming a Property from '{0}' to '{1}' is not supported yet", saved.Name, prop.Name); }
public static string ListPositionColumnName(ValueTypeProperty prop) { return prop.Name + Zetbox.API.Helper.PositionSuffix; }
public void DoRenameValueTypePropertyName(ObjectClass objClass, ValueTypeProperty prop, string prefix) { var saved = savedSchema.FindPersistenceObject<ValueTypeProperty>(prop.ExportGuid); // TODO: What if prefix has changed db.RenameColumn(db.GetTableName(objClass.Module.SchemaName, objClass.TableName), Construct.NestedColumnName(saved, prefix), Construct.NestedColumnName(prop, prefix)); }
protected virtual void ApplyValueTypeProperty(string prefix, ValueTypeProperty prop) { ValueTypePropertyHbm.Call(Host, prefix, prop, null, null, false, ImplementationSuffix, needsConcurrency); }
public bool IsChangeValueTypeProperty_To_Nullable(ValueTypeProperty prop) { var saved = savedSchema.FindPersistenceObject<ValueTypeProperty>(prop.ExportGuid); if (saved == null) return false; return !saved.IsNullable() && prop.IsNullable(); }
public static void Call(Arebis.CodeGeneration.IGenerationHost _host, string prefix, ValueTypeProperty prop, string propName, string columnName, bool forceDefinition, string implementationSuffix, bool needsConcurrency) { if (_host == null) { throw new ArgumentNullException("_host"); } // shortcut unmapped properties if (prop.IsCalculated) { _host.WriteOutput(string.Format("<!-- ValueTypeProperty {0} is calculated and persisted -->\n", prop.Name)); } propName = string.IsNullOrEmpty(propName) ? prop.Name : propName; columnName = string.IsNullOrEmpty(columnName) ? propName : columnName; var optimisticLock = needsConcurrency && propName == "ChangedOn"; string typeAttr = String.Empty; if (prop is DateTimeProperty) { typeAttr = "type=\"Timestamp\""; } string ceClassAttr; if (prop.IsList && !forceDefinition) { // set the proper type for collection entries ceClassAttr = String.Format("class=\"{0}.{1}{2}+{1}Proxy,Zetbox.Objects.NHibernateImpl\"", prop.GetCollectionEntryNamespace(), prop.GetCollectionEntryClassName(), implementationSuffix); } else { // not needed ceClassAttr = String.Empty; } string ceReverseKeyColumnName = prop.GetCollectionEntryReverseKeyColumnName(); string listPositionColumnName = Construct.ListPositionColumnName(prop); Call(_host, prefix, propName, columnName, prop.IsList && !forceDefinition, typeAttr, ceClassAttr, ceReverseKeyColumnName, listPositionColumnName, optimisticLock); }
public bool IsDeleteValueTypeProperty(ValueTypeProperty prop) { return schema.FindPersistenceObject<ValueTypeProperty>(prop.ExportGuid) == null; }
protected virtual void ApplyValueTypeProperty(string prefix, ValueTypeProperty prop) { ValueTypePropertyHbm.Call(Host, prefix, prop, null, null, false, ImplementationSuffix, needsConcurrency); }
public static string ListPositionColumnName(ValueTypeProperty prop) { return(prop.Name + Zetbox.API.Helper.PositionSuffix); }