public override bool VerifyConsistency(object superordinateObject, object candidate) { PIMSchema pimSchema = (PIMSchema)superordinateObject; PIMComponent pimComponent = (PIMComponent)candidate; return(pimSchema.SchemaComponents.Contains(pimComponent)); }
/// <summary> /// Constructs a PIMOperation and registers it with schema <paramref name="schema"/> and inserts it into <see cref="PIMClass"/> <paramref name="c"/>. Also sets <see cref="Guid"/> to <paramref name="g"/> /// </summary> /// <param name="p">Project</param> /// <param name="g"><see cref="Guid"/> to be set</param> /// <param name="c"><see cref="PIMClass"/> to insert to</param> /// <param name="schema"><see cref="PIMSchema"/> to register with</param> public ModelOperation(Project p, Guid g, PIMClass c, PIMSchema schema, int index = -1) : base(p, g) { InitializeCollections(); //schema.PIMOperation.Add(this); //if (index == -1) // c.PIMOperation.Add(this); //else c.PIMOperation.Insert(this, index); PIMClass = c; }
internal override CommandBase.OperationResult UndoOperation() { PIMGeneralization g = Project.TranslateComponent <PIMGeneralization>(GeneralizationGuid); PIMSchema s = Project.TranslateComponent <PIMSchema>(schemaGuid); g.General.GeneralizationsAsGeneral.Remove(g); g.Specific.GeneralizationAsSpecific = null; s.PIMGeneralizations.Remove(g); Project.mappingDictionary.Remove(g); return(OperationResult.OK); }
public static void TestTranslation(PIMSchema schema, string expected, TranslationSettings settings = null) { if (settings == null) { settings = new TranslationSettings(); } Exolutio.SupportingClasses.ILog log; SourceFile[] files = Translations.TranslatePIMToCSharp(schema, settings, out log); string s = files[0].Code; string prolog = "using Exolutio.CodeContracts.Support; using System; using System.Collections.Generic; using System.Diagnostics.Contracts; "; TestUtils.AssertEqualIgnoreSpace(prolog + expected, s); }
public override void FillCopy(IExolutioCloneable copyComponent, ProjectVersion projectVersion, ElementCopiesMap createdCopies) { base.FillCopy(copyComponent, projectVersion, createdCopies); ProjectVersion copyProjectVersion = (ProjectVersion)copyComponent; copyProjectVersion.versionGuid = projectVersion.versionGuid; this.CopyCollection(PIMAttributeTypes, copyProjectVersion.PIMAttributeTypes, projectVersion, createdCopies); copyProjectVersion.PIMSchema = PIMSchema.CreateTypedCopy(projectVersion, createdCopies); this.CopyCollection(PSMSchemas, copyProjectVersion.PSMSchemas, projectVersion, createdCopies); this.CopyCollection(PIMDiagrams, copyProjectVersion.PIMDiagrams, projectVersion, createdCopies); this.CopyCollection(PSMDiagrams, copyProjectVersion.PSMDiagrams, projectVersion, createdCopies); }
private static void CheckPIMSchema(PIMSchema pimSchema) { CheckSchema(pimSchema); foreach (PIMClass pimClass in pimSchema.PIMClasses) { CheckPIMClass(pimClass); } foreach (PIMAssociation pimAssociation in pimSchema.PIMAssociations) { CheckPIMAssociation(pimAssociation); } foreach (PIMComponent pimComponent in ModelIterator.GetPIMComponents(pimSchema)) { Assert.AreEqual(pimComponent.PIMSchema, pimSchema); } }
internal override CommandBase.OperationResult UndoOperation() { if (endGuids.Count != 2) { return(OperationResult.Failed); } PIMClass class1 = Project.TranslateComponent <PIMClass>(classGuids[0]); PIMClass class2 = Project.TranslateComponent <PIMClass>(classGuids[1]); PIMSchema pimSchema = class1.PIMSchema; new PIMAssociation( Project, AssociationGuid, pimSchema, new KeyValuePair <PIMClass, Guid>(class1, endGuids[class1]), new KeyValuePair <PIMClass, Guid>(class2, endGuids[class2]) ); return(OperationResult.OK); }
internal override CommandBase.OperationResult UndoOperation() { PIMAssociation a = Project.TranslateComponent <PIMAssociation>(AssociationGuid); PIMSchema s = Project.TranslateComponent <PIMSchema>(schemaGuid); foreach (PIMAssociationEnd e in a.PIMAssociationEnds) { s.PIMAssociationEnds.Remove(e); if (e.PIMClass != null) { e.PIMClass.PIMAssociationEnds.Remove(e); } Project.mappingDictionary.Remove(e); } s.PIMAssociations.Remove(a); Project.mappingDictionary.Remove(a); return(OperationResult.OK); }
private EvoX.Model.Project ConvertToNonversionedEvoXProject(Project project) { evoxProject = new EvoX.Model.Project(); evoxProject.InitNewEmptyProject(true); projectVersion = evoxProject.SingleVersion; pimSchema = projectVersion.PIMSchema; ConvertPIMSchema(); foreach (PSMDiagram psmDiagram in project.PSMDiagrams) { psmSchema = new PSMSchema(evoxProject); PSMSchemaClass psmSchemaClass = new PSMSchemaClass(evoxProject, psmSchema); psmSchemaClass.Name = psmDiagram.Caption; psmSchema.RegisterPSMSchemaClass(psmSchemaClass); projectVersion.AddPSMSchema(psmSchema); ConvertPSMSchema(psmDiagram); } return(evoxProject); }
public static Project CreateSimpleSampleProject() { Project p = new Project(); p.InitNewEmptyProject(); PSMSchema Spsm1 = new PSMSchema(p); p.SingleVersion.PSMSchemas.Add(Spsm1); PIMSchema sPIM = new PIMSchema(p); p.SingleVersion.PIMSchema = sPIM; PIMClass pimcProduct = new PIMClass(p, sPIM) { Name = "Product" }; PIMClass pimcItem = new PIMClass(p, sPIM) { Name = "Item" }; PIMAssociation a = new PIMAssociation(p, sPIM, pimcItem, pimcProduct); a.PIMAssociationEnds[0].Upper = 2; a.PIMAssociationEnds[1].Upper = UnlimitedInt.Infinity; AttributeType stringType = new AttributeType(p) { Name = "string", IsSealed = true, XSDDefinition = "string" }; p.SingleVersion.PIMAttributeTypes.Add(stringType); #if SILVERLIGHT #else ModelConsistency.CheckProject(p); #endif return(p); }
internal override void CommandOperation() { PIMAssociation a = Project.TranslateComponent <PIMAssociation>(AssociationGuid); PIMSchema s = a.PIMSchema; endGuids = new Dictionary <Guid, Guid>(); classGuids = new List <Guid>(); Debug.Assert(a.PIMClasses.Count == 2, "PIMAssociation " + a.Name + " has " + a.PIMClasses.Count + " PIMClasses on delete."); Report = new CommandReport(CommandReports.PIM_component_deleted, a); foreach (PIMAssociationEnd e in a.PIMAssociationEnds) { s.PIMAssociationEnds.Remove(e); if (e.PIMClass != null) { e.PIMClass.PIMAssociationEnds.Remove(e); classGuids.Add(e.PIMClass); endGuids.Add(e.PIMClass, e); } Project.mappingDictionary.Remove(e); } s.PIMAssociations.Remove(a); Project.mappingDictionary.Remove(a); }
public override void Deserialize(XElement parentNode, SerializationContext context) { base.Deserialize(parentNode, context); context.CurrentProjectVersion = this; if (Project.UsesVersioning) { if (parentNode.Attribute("versionID") == null) { context.Log.AddErrorFormat("Missing attribute 'versionID' in node {0}", parentNode); } versionGuid = this.DeserializeIDRef("versionID", parentNode, context); } else { if (parentNode.Attribute("versionID") != null) { context.Log.AddErrorFormat("Attribute 'versionID' should not be present in node {0} because the project does not use versioning.", parentNode); } } this.DeserializeWrappedCollection("PIMAttributeTypes", PIMAttributeTypes, AttributeType.CreateInstance, parentNode, context, true); PIMSchema objPIMSchema = new PIMSchema(Project, Guid.Empty); objPIMSchema.DeserializeFromChildElement("PIMSchema", parentNode, context); PIMSchema = objPIMSchema; this.DeserializeWrappedCollection("PSMSchemas", PSMSchemas, PSMSchema.CreateInstance, parentNode, context); this.DeserializeWrappedCollection("PIMDiagrams", PIMDiagrams, PIMDiagram.CreateInstance, parentNode, context); this.DeserializeWrappedCollection("PSMDiagrams", PSMDiagrams, PSMDiagram.CreateInstance, parentNode, context); context.CurrentProjectVersion = null; }
public virtual TResult ProcessPIMSchema(PIMSchema pimSchema) { return(DefaultResult); }
public virtual void ProcessPIMSchema(PIMSchema pimSchema, ref TContext context) { ProcessSchema(pimSchema, ref context); }
public static Project CreateSampleProject() { //return CreateSimpleSampleProject(); Project p = new Project(); p.InitNewEmptyProject(); PIMSchema sPIM = new PIMSchema(p); AttributeType stringType = new AttributeType(p) { Name = "string", IsSealed = true, XSDDefinition = "string" }; p.SingleVersion.PIMAttributeTypes.Add(stringType); p.SingleVersion.PIMSchema = sPIM; PIMClass pimcProduct = new PIMClass(p, sPIM) { Name = "Product" }; PIMClass pimcCustomer = new PIMClass(p, sPIM) { Name = "Customer" }; PIMClass pimcPurchase = new PIMClass(p, sPIM) { Name = "Purchase" }; PIMClass pimcItem = new PIMClass(p, sPIM) { Name = "Item" }; PIMClass pimcAddress = new PIMClass(p, sPIM) { Name = "Address" }; PIMAttribute pimattProduct_title = new PIMAttribute(p, pimcProduct, sPIM) { Name = "title", AttributeType = stringType }; PIMAttribute pimattProduct_price = new PIMAttribute(p, pimcProduct, sPIM) { Name = "price" }; PIMAttribute pimattCustomer_name = new PIMAttribute(p, pimcCustomer, sPIM) { Name = "name" }; PIMAttribute pimattCustomer_email = new PIMAttribute(p, pimcCustomer, sPIM) { Name = "email", Lower = 1, Upper = UnlimitedInt.Infinity }; PIMAttribute pimattCustomer_phone = new PIMAttribute(p, pimcCustomer, sPIM) { Name = "phone", Lower = 0, Upper = UnlimitedInt.Infinity }; PIMAttribute pimattItem_tester = new PIMAttribute(p, pimcItem, sPIM) { Name = "tester" }; PIMAttribute pimattItem_itemprice = new PIMAttribute(p, pimcItem, sPIM) { Name = "itemprice" }; PIMAttribute pimattItem_amount = new PIMAttribute(p, pimcItem, sPIM) { Name = "amount" }; PIMAttribute pimattPurchase_code = new PIMAttribute(p, pimcPurchase, sPIM) { Name = "code" }; PIMAttribute pimattPurchase_create_date = new PIMAttribute(p, pimcPurchase, sPIM) { Name = "create-date" }; PIMAttribute pimattPurchase_status = new PIMAttribute(p, pimcPurchase, sPIM) { Name = "status" }; PIMAttribute pimattAddress_street = new PIMAttribute(p, pimcAddress, sPIM) { Name = "street" }; PIMAttribute pimattAddress_city = new PIMAttribute(p, pimcAddress, sPIM) { Name = "city" }; PIMAttribute pimattAddress_country = new PIMAttribute(p, pimcAddress, sPIM) { Name = "country" }; PIMAttribute pimattAddress_gps = new PIMAttribute(p, pimcAddress, sPIM) { Name = "gps" }; PIMAssociationEnd pimaeProduct1 = new PIMAssociationEnd(p, pimcProduct, sPIM); PIMAssociationEnd pimaeItem1 = new PIMAssociationEnd(p, pimcItem, sPIM) { Lower = 0, Upper = UnlimitedInt.Infinity }; PIMAssociation pimaProduct_Item = new PIMAssociation(p, sPIM, pimaeProduct1, pimaeItem1); PIMAssociationEnd pimaeItem2 = new PIMAssociationEnd(p, pimcItem, sPIM); PIMAssociationEnd pimaePurchase1 = new PIMAssociationEnd(p, pimcPurchase, sPIM) { Lower = 1, Upper = UnlimitedInt.Infinity }; PIMAssociation pimaItem_Purchase = new PIMAssociation(p, sPIM, pimaeItem2, pimaePurchase1); PIMAssociationEnd pimaePurchase2 = new PIMAssociationEnd(p, pimcPurchase, sPIM) { Lower = 1, Upper = UnlimitedInt.Infinity }; PIMAssociationEnd pimaeCustomer1 = new PIMAssociationEnd(p, pimcCustomer, sPIM); PIMAssociation pimaMakes = new PIMAssociation(p, sPIM, pimaePurchase2, pimaeCustomer1) { Name = "makes" }; PIMAssociationEnd pimaePurchase3 = new PIMAssociationEnd(p, pimcPurchase, sPIM) { Lower = 0, Upper = 1 }; PIMAssociationEnd pimaeAddress1 = new PIMAssociationEnd(p, pimcAddress, sPIM) { Lower = 0, Upper = 1 }; PIMAssociation pimaShipTo = new PIMAssociation(p, sPIM, pimaePurchase3, pimaeAddress1) { Name = "ship-to" }; PIMAssociationEnd pimaePurchase4 = new PIMAssociationEnd(p, pimcPurchase, sPIM) { Lower = 0, Upper = 1 }; PIMAssociationEnd pimaeAddress2 = new PIMAssociationEnd(p, pimcAddress, sPIM); PIMAssociation pimaBillTo = new PIMAssociation(p, sPIM, pimaePurchase4, pimaeAddress2) { Name = "bill-to" }; PSMSchema sPSM1 = new PSMSchema(p); p.SingleVersion.PSMSchemas.Add(sPSM1); PSMSchemaClass sPSM1C = new PSMSchemaClass(p, sPSM1) { Name = "PSMSchemaClass1" }; PSMClass psmcAddress = new PSMClass(p, sPSM1) { Name = "Address", Interpretation = pimcAddress }; //sPSM1.Roots.Add(psmcAddress); PSMAttribute psmattStreet = new PSMAttribute(p, psmcAddress, sPSM1) { Name = "street", Element = true, Interpretation = pimattAddress_street }; PSMAttribute psmattCity = new PSMAttribute(p, psmcAddress, sPSM1) { Name = "city", Element = true, Interpretation = pimattAddress_city }; PSMClass psmcPurchase = new PSMClass(p, sPSM1) { Name = "Purchase", Interpretation = pimcPurchase }; PSMAssociation psmaPurchase = new PSMAssociation(p, sPSM1C, psmcPurchase, sPSM1) { Name = "purchase" }; PSMAttribute psmattPurchase_code = new PSMAttribute(p, psmcPurchase, sPSM1) { Name = "code", Element = false, Interpretation = pimattPurchase_code }; PSMAttribute psmattPurchase_create_date = new PSMAttribute(p, psmcPurchase, sPSM1) { Name = "create-date", Element = true, Interpretation = pimattPurchase_create_date }; PSMAttribute psmattPurchase_version = new PSMAttribute(p, psmcPurchase, sPSM1) { Name = "version", Element = false }; PSMClass psmcBillAddress = new PSMClass(p, sPSM1) { Name = "BillAddress", Interpretation = pimcAddress, RepresentedClass = psmcAddress }; PSMClass psmcShipAddress = new PSMClass(p, sPSM1) { Name = "ShipAddress", Interpretation = pimcAddress, RepresentedClass = psmcAddress }; PSMClass psmcCustomer = new PSMClass(p, sPSM1) { Name = "Customer", Interpretation = pimcCustomer }; PSMClass psmcItems = new PSMClass(p, sPSM1) { Name = "Items" }; PSMAttribute psmattCustomer_name = new PSMAttribute(p, psmcCustomer, sPSM1) { Name = "name", Element = true, Interpretation = pimattCustomer_name }; PSMAssociation psmaBillTo = new PSMAssociation(p, psmcPurchase, psmcBillAddress, sPSM1) { Name = "bill-to", Interpretation = pimaBillTo }; PSMAssociation psmaShipTo = new PSMAssociation(p, psmcPurchase, psmcShipAddress, sPSM1) { Name = "ship-to", Interpretation = pimaShipTo, Lower = 0 }; PSMAssociation psmacust = new PSMAssociation(p, psmcPurchase, psmcCustomer, sPSM1) { Name = "cust", Interpretation = pimaMakes }; PSMAssociation psmaItems = new PSMAssociation(p, psmcPurchase, psmcItems, sPSM1) { Name = "items" }; PSMClass psmcContact = new PSMClass(p, sPSM1) { Name = "Contact" }; PSMAttribute psmattContactEmail = new PSMAttribute(p, psmcContact, sPSM1) { Name = "email", Lower = 1, Upper = UnlimitedInt.Infinity, Interpretation = pimattCustomer_email, Element = true }; PSMAttribute psmattContactPhone = new PSMAttribute(p, psmcContact, sPSM1) { Name = "phone", Lower = 0, Upper = UnlimitedInt.Infinity, Interpretation = pimattCustomer_phone, Element = true }; PSMAssociation psmaCustomerContact = new PSMAssociation(p, psmcCustomer, psmcContact, sPSM1); PSMClass psmcItem = new PSMClass(p, sPSM1) { Name = "Item", Interpretation = pimcItem }; PSMAssociation psmaItemsItem = new PSMAssociation(p, psmcItems, psmcItem, sPSM1) { Name = "item", Lower = 1, Upper = UnlimitedInt.Infinity, Interpretation = pimaItem_Purchase }; PSMContentModel psmcm1 = new PSMContentModel(p, sPSM1) { Type = PSMContentModelType.Choice }; PSMAssociation psmaPSMC1 = new PSMAssociation(p, psmcItem, psmcm1, sPSM1); PSMClass psmcProduct = new PSMClass(p, sPSM1) { Name = "Product", Interpretation = pimcProduct }; PSMAttribute psmattProduct_code = new PSMAttribute(p, psmcProduct, sPSM1) { Name = "code", Element = true, Interpretation = pimattProduct_title }; PSMAssociation psmaPSMC1Product = new PSMAssociation(p, psmcm1, psmcProduct, sPSM1) { Interpretation = pimaProduct_Item }; PSMClass psmcItemTester = new PSMClass(p, sPSM1) { Name = "ItemTester" }; PSMAttribute psmattItemTester_tester = new PSMAttribute(p, psmcItemTester, sPSM1) { Name = "tester", Element = false, Interpretation = pimattItem_tester }; PSMAssociation psmaPSMC1ItemTester = new PSMAssociation(p, psmcm1, psmcItemTester, sPSM1); PSMClass psmcItemPricing = new PSMClass(p, sPSM1) { Name = "ItemPricing" }; PSMAttribute psmattItemPricing_price = new PSMAttribute(p, psmcItemPricing, sPSM1) { Name = "price", Element = true, Interpretation = pimattItem_itemprice }; PSMAttribute psmattItemPricing_amount = new PSMAttribute(p, psmcItemPricing, sPSM1) { Name = "amount", Element = true, Interpretation = pimattItem_amount }; PSMAssociation psmaPSMC1ItemPricing = new PSMAssociation(p, psmcm1, psmcItemPricing, sPSM1); p.HasUnsavedChanges = true; // classes were added to roots... foreach (PSMAssociationMember member in sPSM1.Roots.ToArray()) { if (member.ParentAssociation != null) { sPSM1.Roots.Remove(member); } } #if SILVERLIGHT #else ModelConsistency.CheckProject(p); #endif return(p); }
public static void CommandTest() { Project p = new Project(); p.InitNewEmptyProject(); PIMSchema sPIM = new PIMSchema(p); AttributeType stringType = new AttributeType(p) { Name = "string", IsSealed = true, XSDDefinition = "string" }; p.SingleVersion.PIMAttributeTypes.Add(stringType); p.SingleVersion.PIMSchema = sPIM; PIMClass pimcProduct = new PIMClass(p, sPIM) { Name = "Product" }; PIMClass pimcCustomer = new PIMClass(p, sPIM) { Name = "Customer" }; PIMClass pimcPurchase = new PIMClass(p, sPIM) { Name = "Purchase" }; PIMClass pimcItem = new PIMClass(p, sPIM) { Name = "Item" }; PIMClass pimcAddress = new PIMClass(p, sPIM) { Name = "Address" }; PIMAttribute pimattProduct_title = new PIMAttribute(p, pimcProduct, sPIM) { Name = "title", AttributeType = stringType }; PIMAttribute pimattProduct_price = new PIMAttribute(p, pimcProduct, sPIM) { Name = "price" }; PIMAttribute pimattCustomer_name = new PIMAttribute(p, pimcCustomer, sPIM) { Name = "name" }; PIMAttribute pimattCustomer_email = new PIMAttribute(p, pimcCustomer, sPIM) { Name = "email", Lower = 1, Upper = UnlimitedInt.Infinity }; PIMAttribute pimattCustomer_phone = new PIMAttribute(p, pimcCustomer, sPIM) { Name = "phone", Lower = 0, Upper = UnlimitedInt.Infinity }; PIMAttribute pimattItem_tester = new PIMAttribute(p, pimcItem, sPIM) { Name = "tester" }; PIMAttribute pimattItem_itemprice = new PIMAttribute(p, pimcItem, sPIM) { Name = "itemprice" }; PIMAttribute pimattItem_amount = new PIMAttribute(p, pimcItem, sPIM) { Name = "amount" }; PIMAttribute pimattPurchase_code = new PIMAttribute(p, pimcPurchase, sPIM) { Name = "code" }; PIMAttribute pimattPurchase_create_date = new PIMAttribute(p, pimcPurchase, sPIM) { Name = "create-date" }; PIMAttribute pimattPurchase_status = new PIMAttribute(p, pimcPurchase, sPIM) { Name = "status" }; PIMAttribute pimattAddress_street = new PIMAttribute(p, pimcAddress, sPIM) { Name = "street" }; PIMAttribute pimattAddress_city = new PIMAttribute(p, pimcAddress, sPIM) { Name = "city" }; PIMAttribute pimattAddress_country = new PIMAttribute(p, pimcAddress, sPIM) { Name = "country" }; PIMAttribute pimattAddress_gps = new PIMAttribute(p, pimcAddress, sPIM) { Name = "gps" }; PIMAssociationEnd pimaeProduct1 = new PIMAssociationEnd(p, pimcProduct, sPIM); PIMAssociationEnd pimaeItem1 = new PIMAssociationEnd(p, pimcItem, sPIM) { Lower = 0, Upper = UnlimitedInt.Infinity }; PIMAssociation pimaProduct_Item = new PIMAssociation(p, sPIM, pimaeProduct1, pimaeItem1); PIMAssociationEnd pimaeItem2 = new PIMAssociationEnd(p, pimcItem, sPIM); PIMAssociationEnd pimaePurchase1 = new PIMAssociationEnd(p, pimcPurchase, sPIM) { Lower = 1, Upper = UnlimitedInt.Infinity }; PIMAssociation pimaItem_Purchase = new PIMAssociation(p, sPIM, pimaeItem2, pimaePurchase1); PIMAssociationEnd pimaePurchase2 = new PIMAssociationEnd(p, pimcPurchase, sPIM) { Lower = 1, Upper = UnlimitedInt.Infinity }; PIMAssociationEnd pimaeCustomer1 = new PIMAssociationEnd(p, pimcCustomer, sPIM); PIMAssociation pimaMakes = new PIMAssociation(p, sPIM, pimaePurchase2, pimaeCustomer1) { Name = "makes" }; PIMAssociationEnd pimaePurchase3 = new PIMAssociationEnd(p, pimcPurchase, sPIM) { Lower = 0, Upper = 1 }; PIMAssociationEnd pimaeAddress1 = new PIMAssociationEnd(p, pimcAddress, sPIM) { Lower = 0, Upper = 1 }; PIMAssociation pimaShipTo = new PIMAssociation(p, sPIM, pimaePurchase3, pimaeAddress1) { Name = "ship-to" }; PIMAssociationEnd pimaePurchase4 = new PIMAssociationEnd(p, pimcPurchase, sPIM) { Lower = 0, Upper = 1 }; PIMAssociationEnd pimaeAddress2 = new PIMAssociationEnd(p, pimcAddress, sPIM); PIMAssociation pimaBillTo = new PIMAssociation(p, sPIM, pimaePurchase4, pimaeAddress2) { Name = "bill-to" }; PSMSchema sPSM1 = new PSMSchema(p); p.SingleVersion.PSMSchemas.Add(sPSM1); PSMSchemaClass sPSM1C = new PSMSchemaClass(p, sPSM1) { Name = "PSMSchemaClass1" }; PSMClass psmcAddress = new PSMClass(p, sPSM1) { Name = "Address", Interpretation = pimcAddress }; sPSM1.Roots.Add(psmcAddress); PSMAttribute psmattStreet = new PSMAttribute(p, psmcAddress, sPSM1) { Name = "street", Element = true, Interpretation = pimattAddress_street }; PSMAttribute psmattCity = new PSMAttribute(p, psmcAddress, sPSM1) { Name = "city", Element = true, Interpretation = pimattAddress_city }; PSMClass psmcPurchase = new PSMClass(p, sPSM1) { Name = "Purchase", Interpretation = pimcPurchase }; PSMAssociation psmaPurchase = new PSMAssociation(p, sPSM1C, psmcPurchase, sPSM1) { Name = "purchase" }; PSMAttribute psmattPurchase_code = new PSMAttribute(p, psmcPurchase, sPSM1) { Name = "code", Element = false, Interpretation = pimattPurchase_code }; PSMAttribute psmattPurchase_create_date = new PSMAttribute(p, psmcPurchase, sPSM1) { Name = "create-date", Element = true, Interpretation = pimattPurchase_create_date }; PSMAttribute psmattPurchase_version = new PSMAttribute(p, psmcPurchase, sPSM1) { Name = "version", Element = false }; PSMClass psmcBillAddress = new PSMClass(p, sPSM1) { Name = "BillAddress", Interpretation = pimcAddress, RepresentedClass = psmcAddress }; PSMClass psmcShipAddress = new PSMClass(p, sPSM1) { Name = "ShipAddress", Interpretation = pimcAddress, RepresentedClass = psmcAddress }; PSMClass psmcCustomer = new PSMClass(p, sPSM1) { Name = "Customer", Interpretation = pimcCustomer }; PSMClass psmcItems = new PSMClass(p, sPSM1) { Name = "Items" }; PSMAttribute psmattCustomer_name = new PSMAttribute(p, psmcCustomer, sPSM1) { Name = "name", Element = true, Interpretation = pimattCustomer_name }; PSMAssociation psmaBillTo = new PSMAssociation(p, psmcPurchase, psmcBillAddress, sPSM1) { Name = "bill-to", Interpretation = pimaBillTo }; PSMAssociation psmaShipTo = new PSMAssociation(p, psmcPurchase, psmcShipAddress, sPSM1) { Name = "ship-to", Interpretation = pimaShipTo, Lower = 0 }; PSMAssociation psmacust = new PSMAssociation(p, psmcPurchase, psmcCustomer, sPSM1) { Name = "cust", Interpretation = pimaMakes }; PSMAssociation psmaItems = new PSMAssociation(p, psmcPurchase, psmcItems, sPSM1) { Name = "items" }; PSMClass psmcContact = new PSMClass(p, sPSM1) { Name = "Contact" }; PSMAttribute psmattContactEmail = new PSMAttribute(p, psmcContact, sPSM1) { Name = "email", Lower = 1, Upper = UnlimitedInt.Infinity, Interpretation = pimattCustomer_email, Element = true }; PSMAttribute psmattContactPhone = new PSMAttribute(p, psmcContact, sPSM1) { Name = "phone", Lower = 0, Upper = UnlimitedInt.Infinity, Interpretation = pimattCustomer_phone, Element = true }; PSMAssociation psmaCustomerContact = new PSMAssociation(p, psmcCustomer, psmcContact, sPSM1); PSMClass psmcItem = new PSMClass(p, sPSM1) { Name = "Item", Interpretation = pimcItem }; PSMAssociation psmaItemsItem = new PSMAssociation(p, psmcItems, psmcItem, sPSM1) { Name = "item", Lower = 1, Upper = UnlimitedInt.Infinity, Interpretation = pimaItem_Purchase }; PSMContentModel psmcm1 = new PSMContentModel(p, sPSM1) { Type = PSMContentModelType.Choice }; PSMAssociation psmaPSMC1 = new PSMAssociation(p, psmcItem, psmcm1, sPSM1); PSMClass psmcProduct = new PSMClass(p, sPSM1) { Name = "Product", Interpretation = pimcProduct }; PSMAttribute psmattProduct_code = new PSMAttribute(p, psmcProduct, sPSM1) { Name = "code", Element = true, Interpretation = pimattProduct_title }; PSMAssociation psmaPSMC1Product = new PSMAssociation(p, psmcm1, psmcProduct, sPSM1) { Interpretation = pimaProduct_Item }; PSMClass psmcItemTester = new PSMClass(p, sPSM1) { Name = "ItemTester" }; PSMAttribute psmattItemTester_tester = new PSMAttribute(p, psmcItemTester, sPSM1) { Name = "tester", Element = false, Interpretation = pimattItem_tester }; PSMAssociation psmaPSMC1ItemTester = new PSMAssociation(p, psmcm1, psmcItemTester, sPSM1); PSMClass psmcItemPricing = new PSMClass(p, sPSM1) { Name = "ItemPricing" }; PSMAttribute psmattItemPricing_price = new PSMAttribute(p, psmcItemPricing, sPSM1) { Name = "price", Element = true, Interpretation = pimattItem_itemprice }; PSMAttribute psmattItemPricing_amount = new PSMAttribute(p, psmcItemPricing, sPSM1) { Name = "amount", Element = true, Interpretation = pimattItem_amount }; PSMAssociation psmaPSMC1ItemPricing = new PSMAssociation(p, psmcm1, psmcItemPricing, sPSM1); PSMSchema sPSM2 = new PSMSchema(p); p.SingleVersion.PSMSchemas.Add(sPSM2); p.HasUnsavedChanges = true; Controller.Controller c = new Controller.Controller(p); Guid sPSM1Guid = sPSM1; ModelConsistency.CheckProject(p); //Exolutio.Controller.Commands.Atomic.PIM.MacroWrappers.cmdDeletePIMClass command = new Exolutio.Controller.Commands.Atomic.PIM.MacroWrappers.cmdDeletePIMClass(c); //command.Set(pimcItem); //command.Execute(); Exolutio.Controller.Commands.UndoCommand undo = new Exolutio.Controller.Commands.UndoCommand(c); undo.Execute(); Exolutio.Controller.Commands.RedoCommand redo = new Exolutio.Controller.Commands.RedoCommand(c); redo.Execute(); /*cmdDeletePSMSchema command = new cmdDeletePSMSchema(c); * * command.Set(sPSM1); * * command.Execute(); * ModelConsistency.CheckProject(p); * * try * { * p.TranslateComponent<PSMSchema>(sPSM1Guid); * } * catch { } * * command.UnExecute(); * * sPSM1 = p.TranslateComponent<PSMSchema>(sPSM1Guid); * ModelConsistency.CheckProject(p); * * command.ExecuteAsRedo();*/ }
public IList <ClassifierConstraintBlock> FindSuitableConstraints(PIMSchema pimSchema, PSMSchema psmSchema) { List <ClassifierConstraintBlock> result = new List <ClassifierConstraintBlock>(); foreach (OCLScript oclScript in pimSchema.OCLScripts) { OclCompilerResult compilerResult = oclScript.CompileToAst(); if (!compilerResult.Errors.HasError) { ConstraintSuitabilityChecker constraintSuitabilityChecker = new ConstraintSuitabilityChecker { TargetPSMSchema = psmSchema, Bridge = compilerResult.Bridge }; ConstraintConvertor constraintConvertor = new ConstraintConvertor { TargetPSMSchema = psmSchema, Bridge = compilerResult.Bridge }; foreach (ClassifierConstraintBlock classifierConstraint in compilerResult.Constraints.ClassifierConstraintBlocks) { /* constraints from one PIM context can be distributed amont several * PSM contexts (different PSM classes with identical interpretation) */ Dictionary <Classifier, ClassifierConstraintBlock> translatedInvariants = new Dictionary <Classifier, ClassifierConstraintBlock>(); foreach (InvariantWithMessage pimInvariant in classifierConstraint.Invariants) { constraintSuitabilityChecker.Clear(); bool suitable = constraintSuitabilityChecker.CheckConstraintSuitability( classifierConstraint, pimInvariant.Constraint); if (suitable) { Classifier psmContextSuggestion = null; constraintConvertor.Clear(); try { OclExpression psmInvariant = constraintConvertor.TranslateConstraint(classifierConstraint, pimInvariant.Constraint, constraintSuitabilityChecker.VariableClassMappings, constraintSuitabilityChecker.PathMappings, constraintSuitabilityChecker.VariableTranslations, out psmContextSuggestion); if (!translatedInvariants.ContainsKey(psmContextSuggestion)) { translatedInvariants[psmContextSuggestion] = new ClassifierConstraintBlock(psmContextSuggestion, new List <InvariantWithMessage>(), constraintConvertor.SelfVariableDeclaration); } translatedInvariants[psmContextSuggestion].Invariants.Add(new InvariantWithMessage(psmInvariant)); } catch { } } } foreach (KeyValuePair <Classifier, ClassifierConstraintBlock> kvp in translatedInvariants) { result.Add(kvp.Value); } } } } return(result); }
private static void RelationsCorrespond(IVersionedItem versionedItem, IVersionedItem other) { #region PIMSchema { PIMSchema PIMSchema1 = versionedItem as PIMSchema; if (PIMSchema1 != null) { SubcollectionCheck(PIMSchema1, other, owner => owner.PIMAttributes); SubcollectionCheck(PIMSchema1, other, owner => owner.PIMAssociationEnds); SubcollectionCheck(PIMSchema1, other, owner => owner.PIMClasses); SubcollectionCheck(PIMSchema1, other, owner => owner.PIMAssociations); } } #endregion #region PIMClass { PIMClass pimClass1 = versionedItem as PIMClass; if (pimClass1 != null) { SubcollectionCheck(pimClass1, other, owner => owner.PIMAttributes); SubcollectionCheck(pimClass1, other, owner => owner.PIMAssociationEnds); } } #endregion #region PIMAttribute { PIMAttribute PIMAttribute1 = versionedItem as PIMAttribute; if (PIMAttribute1 != null) { ReferenceCheck(PIMAttribute1, other, owner => owner.PIMClass); ReferenceCheck(PIMAttribute1, other, owner => owner.AttributeType); } } #endregion #region PIMAssociation { PIMAssociation PIMAssociation1 = versionedItem as PIMAssociation; if (PIMAssociation1 != null) { SubcollectionCheck(PIMAssociation1, other, owner => owner.PIMClasses); SubcollectionCheck(PIMAssociation1, other, owner => owner.PIMAssociationEnds); } } #endregion #region PSMClass { PSMClass PSMClass1 = versionedItem as PSMClass; if (PSMClass1 != null) { SubcollectionCheck(PSMClass1, other, owner => owner.PSMAttributes); SubcollectionCheck(PSMClass1, other, owner => owner.ChildPSMAssociations); ReferenceCheck(PSMClass1, other, owner => owner.RepresentedClass); ReferenceCheck(PSMClass1, other, owner => owner.ParentAssociation); } } #endregion #region PSMAttribute { PSMAttribute PSMAttribute1 = versionedItem as PSMAttribute; if (PSMAttribute1 != null) { ReferenceCheck(PSMAttribute1, other, owner => owner.PSMClass); ReferenceCheck(PSMAttribute1, other, owner => owner.AttributeType); } } #endregion #region PSMAssociation { PSMAssociation PSMAssociation1 = versionedItem as PSMAssociation; if (PSMAssociation1 != null) { ReferenceCheck(PSMAssociation1, other, owner => owner.Parent); ReferenceCheck(PSMAssociation1, other, owner => owner.Child); } } #endregion #region PSMContentModel { PSMContentModel PSMContentModel1 = versionedItem as PSMContentModel; if (PSMContentModel1 != null) { SubcollectionCheck(PSMContentModel1, other, owner => owner.ChildPSMAssociations); ReferenceCheck(PSMContentModel1, other, owner => owner.ParentAssociation); } } #endregion #region PSMSchema { PSMSchema PSMSchema1 = versionedItem as PSMSchema; if (PSMSchema1 != null) { SubcollectionCheck(PSMSchema1, other, owner => owner.PSMAttributes); SubcollectionCheck(PSMSchema1, other, owner => owner.PSMContentModels); SubcollectionCheck(PSMSchema1, other, owner => owner.PSMClasses); SubcollectionCheck(PSMSchema1, other, owner => owner.PSMAssociations); SubcollectionCheck(PSMSchema1, other, owner => owner.PSMSchemaReferences); SubcollectionCheck(PSMSchema1, other, owner => owner.Roots); ReferenceCheck(PSMSchema1, other, owner => owner.PSMSchemaClass); } } #endregion }