-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access to Property Multiplicity #15
Comments
@PatrickRitchie There should be representation for the XMI structures that indicate multiplicity now. However, I don't think the foreign relationships have been "stitched" into the transpiled model. Do you have a specific example/use case that I can focus on to resolve this issue? |
I'm currently using a hard coded list to determine whether a property is an array or is required using the code below. It would be nice if I could read this directly from the UmlProperty class as a hard coded list is not really scalable. Is this available in the latest version? I'm also open to an alternative way to process this if there is something I'm doing incorrectly or something that could be done better. Set IsArray and IsOptional properties: public MTConnectPropertyModel(XmiDocument xmiDocument, string idPrefix, UmlProperty umlProperty)
{
UmlId = umlProperty.Id;
if (xmiDocument != null && umlProperty != null)
{
IsArray = ModelHelper.IsArray(xmiDocument, umlProperty.Id);
IsOptional = ModelHelper.IsOptional(xmiDocument, umlProperty.Id);
var propertyName = umlProperty.Name;
if (propertyName.StartsWith("has") && propertyName != "hash") propertyName = propertyName.Substring(3);
if (propertyName == "xlink:type") propertyName = "xLinkType";
var name = propertyName.ToTitleCase();
if (IsArray) name = ModelHelper.ConvertArrayName(name);
Id = $"{idPrefix}.{name}";
Name = name;
DataType = ParseType(xmiDocument, umlProperty.Id, umlProperty.PropertyType);
DataTypeUmlId = umlProperty.PropertyType;
var description = umlProperty.Comments?.FirstOrDefault().Body;
Description = ModelHelper.ProcessDescription(description);
if (string.IsNullOrEmpty(Description)) Description = ModelHelper.GetClassDescription(xmiDocument, umlProperty.PropertyType);
}
} Hard coded method to determine if property is array: public static bool IsArray(XmiDocument xmiDocument, string id)
{
switch (id)
{
case "_19_0_3_91b028d_1579274935610_708920_3095": return true; // Devices.Component.Components
case "_19_0_3_91b028d_1579274803419_180043_3064": return true; // Devices.Component.Compositions
case "_19_0_3_45f01b9_1581211888318_232581_149": return true; // Devices.Component.References
case "_19_0_3_68e0225_1633431910074_887850_97": return true; // Devices.Configuration.Relationships
case "_19_0_3_68e0225_1633431923171_707595_113": return true; // Devices.Configuration.CoordinateSystems
case "_19_0_3_68e0225_1633431989416_861348_140": return true; // Devices.Configuration.Specifications
case "_19_0_3_68e0225_1677585034568_640359_707": return true; // Devices.Configuration.ImageFiles
...
}
return false;
} Hard coded method to determine if property is required or optional: public static bool IsOptional(XmiDocument xmiDocument, string id)
{
switch (id)
{
case "EAID_C7968EFA_A55E_4ccf_B7CA_CFE13D86C116": return true; // Devices.DataItem.Maximum
case "EAID_72FA9526_7E5D_4084_A7F0_39FD402026E6": return true; // Devices.DataItem.Minimum
case "EAID_7B83A56F_E21C_4aa3_9851_413935CE01A2": return true; // Devices.DataItem.Nominal
...
}
return false;
} |
I have started to implement this project to generate c# classes and so far it has worked great. The main issue I have run into is accessing the multiplicity of a property. I don't see it in the Xmi classes and I don't really even see where it is located in the raw SysML XMI file (although I'm sure it's in there somewhere).
My temporary solution is to create a manual list to determine if a property is an array and also if it is required/optional.
My question is, is the Multiplicity something that is directly pulled from the SysML XMI file? Or is this something that is derived from other properties?
Any help would be appreciated.
Thanks,
-Patrick
The text was updated successfully, but these errors were encountered: