//***************************************************************************// // Legenerálja a megadott entitás Validate() metódusát // //***************************************************************************// template GenerateEntityValidation(MClass as ENTITY) #region Ellenőrzés protected override void Validate(bool skipValidateAttributes = false) { base.Validate(); [if (IsProtectedDictionaryItem([ENTITY]) == "True")] // Védett kódtétel... //if (m_Protected == false) { throw new InvalidEntityAttributeException("[ENTITY.name]", "Protected", EntityAttributeError.Unknown); } [end if] [if (IsEntityDictionaryItem([ENTITY]) == "True")] [if (GetTaggedValue([ENTITY], "dkt") != "true")] if (m_Protected && (HasChanged("Name") || HasChanged("Code"))) [else] if (!m_IsModosithato && (HasChanged("Name") || HasChanged("Code"))) [end if] { throw new ProtectedDictionaryItemException("[ENTITY.name]", ID); } [end if] if (!skipValidateAttributes) { // korlátos hosszúságú mezők ellenőrzése... [loop (ENTITY -> MAttribute as ATTRIBUTE)] [if (GetCSharpType([ATTRIBUTE.type]) == "string")] if (m_[ATTRIBUTE.name] != null && m_[ATTRIBUTE.name].Length > [GetAttributeLength([ATTRIBUTE])]) { [if (IsAttributeTruncateable([ATTRIBUTE]) == _True())] m_[ATTRIBUTE.name] = m_[ATTRIBUTE.name].Substring(0,[GetAttributeLength([ATTRIBUTE])]-3) + "..."; [else] throw new InvalidEntityAttributeException("[ENTITY.name]", "[ATTRIBUTE.name]", EntityAttributeError.TooLong); [end if] } [end if] [end loop] [loop (ENTITY -> MAttribute as ATTRIBUTE)] [loop (ATTRIBUTE -> TaggedValue where toLower([TaggedValue.tag]) == "value")] if (m_[ATTRIBUTE.name] != null && this.m_[ATTRIBUTE.name] != "") { if (EntityUtil.VerifyRegEx(m_[ATTRIBUTE.name], @"[PrepareRegEx([TaggedValue.value])]") == false) { throw new InvalidEntityAttributeException("[ENTITY.name]", "[ATTRIBUTE.name]", EntityAttributeError.WrongFormat); } } [end loop] [end loop] } // kötelező asszociációk ellenőrzése... [loop (ENTITY -> Role as STARTROLE -> MAssociation as CURRENTASSOCIATION -> MAssociationEnd as ENDROLE -> MClass as PARTNERCLASS where (([STARTROLE.id] != [ENDROLE.id]) and GetStereoType([PARTNERCLASS]) == "Entity"))] [if (HasAssociationClass([CURRENTASSOCIATION]) == "")] [if ([ENDROLE.multiplicity] == "1")] if (m_[ConvertRoleToName([ENDROLE])] == [GetCSharpDefaultValueOfType("ID")]) { throw new InvalidEntityAttributeException("[ENTITY.name]", "[ConvertRoleToName([ENDROLE])]", EntityAttributeError.Empty); } [end if] [end if] [end loop] [loop (ENTITY -> MAssociation as CURRENTASSOCIATION -> MAssociationEnd as STARTROLE -> MClass as STARTCLASS where (GetStereoType([STARTCLASS]) == "Entity") )] [loop (CURRENTASSOCIATION -> MAssociationEnd as ENDROLE -> MClass as ENDCLASS where([STARTROLE.id] < [ENDROLE.id] and GetStereoType([ENDCLASS]) == "Entity" ))] if (this.[ConvertRoleToName([ENDROLE])] == [GetCSharpDefaultValueOfType("ID")]) { throw new InvalidEntityAttributeException("[ENTITY.name]", "[ConvertRoleToName([ENDROLE])]", EntityAttributeError.Empty); } if (this.[ConvertRoleToName([STARTROLE])] == [GetCSharpDefaultValueOfType("ID")]) { throw new InvalidEntityAttributeException("[ENTITY.name]", "[ConvertRoleToName([STARTROLE])]", EntityAttributeError.Empty); } [end loop] [end loop] [/* // XXX '1..*' ! [loop (MClass->Role as StartRole ->MAssociation as CurrentAssoc ->MAssociationEnd as EndRole -> MClass as PartnerClass where (([StartRole.id] != [EndRole.id]) and GetStereoType([PartnerClass]) == "Entity"))] [if (HasAssociationClass([CurrentAssoc]) == "")] [if ([EndRole.multiplicity] == "1..*")] //if (this.m_[ConvertRoleToName([EndRole])] == [GetCSharpDefaultValueOfType("ID")]) { throw new InvalidEntityAttributeException(); } [end if] [end if] [end loop] */] } #endregion end template //***************************************************************************// // A reguláris kifejezésben lecsréli a " karaktert "" karakterekre. Ez // // amiatt kell, hogy a C# szintaktikának megfelelő legyen, mert @-cal // // deklaráljuk a sztringliterált. // //***************************************************************************// proc PrepareRegEx(input) local result = replace([input], """", """"""); return [result]; end proc