public static relationship NewRelationship(PropertyAndValue pavcIn)
        {
            relationship r = null;

            if (pavcIn.pValues[(int)CecilConst.PropertyName.Name] == null)
            {
                throw new ArgumentNullException(CecilConst.PropertyName.Name.ToString());
            }
            if (pavcIn.pValues[(int)CecilConst.PropertyName.FullName] == null)
            {
                throw new ArgumentNullException(CecilConst.PropertyName.FQName.ToString());
            }
            if (pavcIn.pValues[(int)CecilConst.PropertyName.ArchiMateElementType] == null)
            {
                throw new ArgumentNullException(CecilConst.PropertyName.ArchiMateElementType.ToString());
            }
            if (pavcIn.pValues[(int)CecilConst.PropertyName.APIType] == null)
            {
                throw new ArgumentNullException(CecilConst.PropertyName.APIType.ToString());
            }
            if (pavcIn.pValues[(int)CecilConst.PropertyName.SourceIdentifier] == null)
            {
                throw new ArgumentNullException(CecilConst.PropertyName.SourceIdentifier.ToString());
            }
            if (pavcIn.pValues[(int)CecilConst.PropertyName.TargetIdentifier] == null)
            {
                throw new ArgumentNullException(CecilConst.PropertyName.TargetIdentifier.ToString());
            }

            string label             = pavcIn.pValues[(int)CecilConst.PropertyName.Name];
            string fullname          = pavcIn.pValues[(int)CecilConst.PropertyName.FullName];
            string type              = pavcIn.pValues[(int)CecilConst.PropertyName.ArchiMateElementType];
            string eSourceIdentifier = pavcIn.pValues[(int)CecilConst.PropertyName.SourceIdentifier];
            string eTargetIdentifier = pavcIn.pValues[(int)CecilConst.PropertyName.TargetIdentifier];

            properties ps = ModelFactory.NewProperties();

            foreach (CecilConst.PropertyName pn in Enum.GetValues(typeof(CecilConst.PropertyName)))
            {
                if (pn == CecilConst.PropertyName.NumberOfItems)
                {
                    break;
                }

                int ipn = (int)pn;
                if (pavcIn.pValues[ipn] != null)
                {
                    property p = ModelFactory.NewProperty(ModelFactory.NewValue(pavcIn.pValues[ipn]), pdc[ipn]);
                    ps.property.Add(p);
                }
            }

            ModelConst.RelationshipType eType = (ModelConst.RelationshipType)Enum.Parse(typeof(ModelConst.RelationshipType), type);
            r = ModelFactory.NewRelationship(fullname, eType, eSourceIdentifier, eTargetIdentifier, ps);

            r.label.ElementAt(0).label_text = label; // short name for display; fullname to compute unique identifier

            return(r);
        }
Beispiel #2
0
        public static string MakeModelRelationshipIdentifier(string modelNameIn, string labelIn,
                                                             ModelConst.RelationshipType typeIn,
                                                             string eSourceIdentifier, string eTargetIdentifier)
        {
            string id = "";

            id = Util.MakeIdentifierFromParentIdentifier(
                Util.MakeIdentifierRootIdentifier(MakeBaseObjectTypeName(typeof(model)), Util.TrimWhitespace(modelNameIn)),
                MakeBaseObjectTypeName(typeof(relationship)),
                typeIn.ToString(),
                Util.TrimWhitespace(labelIn) + "-" + eSourceIdentifier + "-" + eTargetIdentifier);
            return(id);
        }