internal static UmlDataTypeSpec Convert(PrimSpec primSpec)
        {
            var umlDataTypeSpec = new UmlDataTypeSpec
            {
                Stereotype   = "PRIM",
                Name         = primSpec.Name,
                TaggedValues = new[]
                {
                    new UmlTaggedValueSpec("businessTerm", primSpec.BusinessTerms),
                    new UmlTaggedValueSpec("definition", primSpec.Definition),
                    new UmlTaggedValueSpec("dictionaryEntryName", primSpec.DictionaryEntryName)
                    {
                        DefaultValue = GenerateDictionaryEntryNameDefaultValue(primSpec)
                    },
                    new UmlTaggedValueSpec("fractionDigits", primSpec.FractionDigits),
                    new UmlTaggedValueSpec("languageCode", primSpec.LanguageCode),
                    new UmlTaggedValueSpec("length", primSpec.Length),
                    new UmlTaggedValueSpec("maximumExclusive", primSpec.MaximumExclusive),
                    new UmlTaggedValueSpec("maximumInclusive", primSpec.MaximumInclusive),
                    new UmlTaggedValueSpec("maximumLength", primSpec.MaximumLength),
                    new UmlTaggedValueSpec("minimumExclusive", primSpec.MinimumExclusive),
                    new UmlTaggedValueSpec("minimumInclusive", primSpec.MinimumInclusive),
                    new UmlTaggedValueSpec("minimumLength", primSpec.MinimumLength),
                    new UmlTaggedValueSpec("pattern", primSpec.Pattern),
                    new UmlTaggedValueSpec("totalDigits", primSpec.TotalDigits),
                    new UmlTaggedValueSpec("uniqueIdentifier", primSpec.UniqueIdentifier)
                    {
                        DefaultValue = GenerateUniqueIdentifierDefaultValue(primSpec)
                    },
                    new UmlTaggedValueSpec("versionIdentifier", primSpec.VersionIdentifier),
                    new UmlTaggedValueSpec("whiteSpace", primSpec.WhiteSpace),
                },
            };

            var dependencySpecs = new List <UmlDependencySpec>();

            if (primSpec.IsEquivalentTo != null)
            {
                dependencySpecs.Add(new UmlDependencySpec
                {
                    Stereotype = "isEquivalentTo",
                    Target     = ((UpccPrim)primSpec.IsEquivalentTo).UmlDataType,
                    LowerBound = "0",
                    UpperBound = "1",
                });
            }
            umlDataTypeSpec.Dependencies = dependencySpecs;

            return(umlDataTypeSpec);
        }
Example #2
0
 public IPrim UpdatePrim(IPrim element, PrimSpec spec)
 {
     throw new NotImplementedException();
 }
Example #3
0
 public IPrim CreatePrim(PrimSpec spec)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Creates a PRIM based on the given <paramref name="specification"/>.
 /// <param name="specification">A specification for a PRIM.</param>
 /// <returns>The newly created PRIM.</returns>
 /// </summary>
 public IPrim CreatePrim(PrimSpec specification)
 {
     return(new UpccPrim(UmlPackage.CreateDataType(PrimSpecConverter.Convert(specification))));
 }
 /// <summary>
 /// Updates a PRIM to match the given <paramref name="specification"/>.
 /// <param name="prim">A PRIM.</param>
 /// <param name="specification">A new specification for the given PRIM.</param>
 /// <returns>The updated PRIM. Depending on the implementation, this might be the same updated instance or a new instance!</returns>
 /// </summary>
 public IPrim UpdatePrim(IPrim prim, PrimSpec specification)
 {
     return(new UpccPrim(UmlPackage.UpdateDataType(((UpccPrim)prim).UmlDataType, PrimSpecConverter.Convert(specification))));
 }
 private static string GenerateDictionaryEntryNameDefaultValue(PrimSpec primSpec)
 {
     return(primSpec.Name);
 }
 private static string GenerateUniqueIdentifierDefaultValue(PrimSpec primSpec)
 {
     return(Guid.NewGuid().ToString());
 }