public static Model getTestModel() { if (model == null) { ModelBuilder modelBuilder = ModelBuilder; Animals.registerType(modelBuilder); Animal.registerType(modelBuilder); AnimalReference.registerType(modelBuilder); Bird.registerType(modelBuilder); ChildRelationshipDefinition.registerType(modelBuilder); Description.registerType(modelBuilder); FlightPartnerRef.registerType(modelBuilder); FlyingAnimal.registerType(modelBuilder); Guardian.registerType(modelBuilder); GuardEgg.registerType(modelBuilder); Mother.registerType(modelBuilder); SpouseRef.registerType(modelBuilder); FriendRelationshipDefinition.registerType(modelBuilder); RelationshipDefinition.registerType(modelBuilder); RelationshipDefinitionRef.registerType(modelBuilder); Egg.registerType(modelBuilder); FlightInstructor.registerType(modelBuilder); Wings.registerType(modelBuilder); model = modelBuilder.build(); } return(model); }
protected internal static RelationshipDefinition createRelationshipDefinition(ModelInstance modelInstance, Animal animalInRelationshipWith, Type relationshipDefinitionClass) { RelationshipDefinition relationshipDefinition = modelInstance.newInstance(relationshipDefinitionClass, "relationship-" + animalInRelationshipWith.Id); relationshipDefinition.Animal = animalInRelationshipWith; return(relationshipDefinition); }
protected override async Task RemoveAdditionalDependencies( RemoveAllPriceBooksArgument arg, CommercePipelineExecutionContext context, PriceBook entity) { Condition.Requires(arg, nameof(arg)).IsNotNull(); Condition.Requires(context, nameof(context)).IsNotNull(); Condition.Requires(entity, nameof(entity)).IsNotNull(); var relationshipDef = new RelationshipDefinition(Array.Empty <Component>()) { Name = "PriceBookToCatalog" }; var entitiesInListArgument = new FindEntitiesInListArgument(typeof(Catalog), CatalogExportHelper.GetRelationshipListName(entity, relationshipDef), 0, int.MaxValue) { LoadEntities = false, LoadTotalItemCount = false }; foreach (var entityReference in (await Commander.Pipeline <IFindEntitiesInListPipeline>() .Run(entitiesInListArgument, context).ConfigureAwait(false)).EntityReferences) { var inventorySetArgument = new CatalogAndBookArgument(entity.FriendlyId, entityReference.EntityId.SimplifyEntityName()); await Commander.Pipeline <IDisassociateCatalogFromBookPipeline>() .Run(inventorySetArgument, context).ConfigureAwait(false); } }
// --------------------------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Changes the underlying definition to the specified one and propagate the necessary changes. /// </summary> public void ApplyRelationshipDefinitionChange(RelationshipDefinition NewDefinition) { var PreviousDefinitor = this.RelationshipDefinitor.Value; if (PreviousDefinitor.IsEqual(NewDefinition)) { return; } this.RelationshipDefinitor = NewDefinition.Assign(); foreach (var Linking in this.Links) { if (Linking.RoleDefinitor.RoleType == ERoleType.Origin) { Linking.RoleDefinitor = NewDefinition.OriginOrParticipantLinkRoleDef; } else { Linking.RoleDefinitor = NewDefinition.TargetLinkRoleDef; } Linking.RoleVariant = Linking.RoleDefinitor.AllowedVariants.FirstOrDefault(); } this.ApplyIdeaDefinitionChange(PreviousDefinitor); // Must be last, because updates graphics }
public static RelationshipDefinition RelationshipDefinitionCreate(Domain OwnerEntity, IList <RelationshipDefinition> EditedList) { if (!ProductDirector.ValidateEditionPermission(AppExec.LIC_EDITION_FREE, "create Relationship Definitions")) { return(null); } var ItemsCount = OwnerEntity.ConceptDefinitions.Count + EditedList.Count; var MaxQuota = AppExec.CurrentLicenseEdition.TechName.SelectCorresponding(LicensingConfig.IdeaDefinitionsCreationQuotas); if (!ProductDirector.ValidateEditionLimit(ItemsCount + 1, MaxQuota, "create", "Idea Definitions (Concept Defs. + Relationship Defs.)")) { return(null); } int NewNumber = EditedList.Count + 1; string NewName = "RelationshipDef" + NewNumber.ToString(); var Definitor = new RelationshipDefinition(OwnerEntity, Domain.GenericRelationshipDefinition, NewName, NewName.TextToIdentifier(), Shapes.Ellipse); if (RelationshipDefinitionEdit(OwnerEntity, EditedList, Definitor)) { return(Definitor); } return(null); }
public static void addRelationshipDefinition(Animal animalWithRelationship, RelationshipDefinition relationshipDefinition) { Animal animalInRelationshipWith = relationshipDefinition.Animal; relationshipDefinition.Id = animalWithRelationship.Id + "-" + animalInRelationshipWith.Id; animalWithRelationship.RelationshipDefinitions.Add(relationshipDefinition); }
/// <summary> /// This method retrieves a list of parent child relationships for this particual object. /// </summary> /// <param name="tableName">Name of the table to retrieve the definitions for</param> /// <returns></returns> private List <IRelationshipDefinition> GetTableRelations(string tableName) { List <IRelationshipDefinition> relationshipDefinitions = new List <IRelationshipDefinition>(); //Use meta data access to retrieve the foreign key information DataTable foreignKeyIndexes = _metadataAccess.GetTableForeignKeyInformation(tableName); //Parse through each relationship returned in the data table foreach (DataRow foreignKeyRow in foreignKeyIndexes.Rows) { if (relationshipDefinitions.Count > 0) { bool keyFound = false; //Check if the key has already been added to the list of relations. foreach (var definition in relationshipDefinitions) { if (definition.Name != foreignKeyRow["FK_NAME"].ToString()) { continue; } //Append the additional properties to the relationship //Note: these must be added as a comma seperated list definition.ThisProperties += "," + foreignKeyRow["FK_COLUMN_NAME"]; definition.RelatedProperties += "," + foreignKeyRow["PK_COLUMN_NAME"]; keyFound = true; break; } //Don't create a new definition if the current one has been found if (keyFound) { continue; } } //Create a new RelationshipDefinition using the Foreign Key values RelationshipDefinition relationshipDefinition = new RelationshipDefinition { Description = string.Empty, Name = foreignKeyRow["FK_NAME"].ToString(), FullName = foreignKeyRow["FK_NAME"].ToString(), //This is the name of the Parent Object ThisObjectDefinitionFullName = foreignKeyRow["FK_TABLE_NAME"].ToString(), //This is the name of the field or fields in the Parent Object. //Note: Multiple values must be a comma seperated list ThisProperties = foreignKeyRow["FK_COLUMN_NAME"].ToString(), //This is the name of the Referenced Object RelatedObjectDefinitionFullName = foreignKeyRow["PK_TABLE_NAME"].ToString(), //This is the name of the field or fields in the Referenced Object. //Note: Multiple values must be a comma seperated list RelatedProperties = foreignKeyRow["PK_COLUMN_NAME"].ToString(), }; relationshipDefinitions.Add(relationshipDefinition); } return(relationshipDefinitions); }
public RelationshipCreationCommand(CompositionEngine TargetEngine, RelationshipDefinition RelationshipDef) : base("Create Relationship '" + RelationshipDef.Name + "'.") { this.ContextEngine = TargetEngine; this.RelationshipDef = RelationshipDef; this.PointingConnectorFormat = RelationshipDef.DefaultConnectorsFormat; this.Initialize(); this.Assistance = "Press [Left-ALT] to link the pointed Idea as origin."; }
public static Type TryGetTargetEntityType(RelationshipDefinition relationshipDef) { Condition.Requires(relationshipDef, nameof(relationshipDef)).IsNotNull(); Type type = Type.GetType(relationshipDef.TargetType); if (type == null) { BuiltInEntityTypes.TryGetValue(relationshipDef.TargetType, out type); } return(type); }
internal void Add(RelationshipDefinition item) { JsonSchema _schemaRoot = new JsonSchema() { Id = this._config.GetUri("links", item.Name), Description = item.Description, Type = JsonObjectType.Object, AllowAdditionalProperties = true, }; var def1 = new JsonSchema() { Type = JsonObjectType.Object, }; _schemaRoot.Definitions.Add(item.Name, def1); _schemas.Add(item.Name + ".links", _schemaRoot); _schemaRoot.Properties["Target"] = new JsonSchemaProperty() { Type = JsonObjectType.String, IsRequired = true, Pattern = this._config.RestrictionNamePattern }; _schemaRoot.Properties["Referentials"] = new JsonSchemaProperty() { Item = new JsonSchema() { Reference = def1 } }; var dic = new Dictionary <string, JsonSchemaProperty>(); SetLinkProperties(item, dic); foreach (var property in item.Properties) { dic.Add(property.Name, GetProperty(property)); } def1.Properties[nameof(ReferentialBase.Name)] = dic[nameof(ReferentialBase.Name)]; def1.Properties[nameof(ReferentialEntity.Label)] = dic[nameof(ReferentialEntity.Label)]; def1.Properties[nameof(ReferentialEntity.Description)] = dic[nameof(ReferentialEntity.Description)]; foreach (var item2 in dic.Keys.OrderBy(c => c)) { if (!def1.Properties.ContainsKey(item2)) { def1.Properties[item2] = dic[item2]; } } }
/// <summary> /// Constructor /// </summary> /// <param name="OwnerComposition">Composition owning this Relationship.</param> /// <param name="Definitor">Definitor of the Relationship.</param> /// <param name="Name">Name of the Relationship.</param> /// <param name="TechName">Technical Name of the Relationship.</param> /// <param name="Summary">Summary of the Relationship.</param> /// <param name="Pictogram">Image representing the Relationship.</param> public Relationship(Composition OwnerComposition, RelationshipDefinition Definitor, string Name, string TechName, string Summary = "", ImageSource Pictogram = null) : base(OwnerComposition, Name, TechName, Summary, Pictogram) { this.Links = new EditableList <RoleBasedLink>(__Links.TechName, this); this.RelationshipDefinitor = Definitor.Assign(); this.CompositeContentDomain = Definitor.CompositeContentDomain ?? Definitor.OwnerDomain; this.OwnerComposition.UsedDomains.AddNew(Definitor.OwnerDomain); }
private void SetLinkProperties(RelationshipDefinition item, Dictionary <string, JsonSchemaProperty> dic) { var p = new JsonSchemaProperty() { Type = JsonObjectType.Object, IsRequired = true, }; dic.Add("OriginLink", p); Dictionary <string, JsonSchemaProperty> dic2 = new Dictionary <string, JsonSchemaProperty>(); foreach (var property in item.Origin.Properties) { dic2.Add(property.Name, GetProperty(property)); } p.Properties[nameof(ReferentialBase.Name)] = dic2[nameof(ReferentialBase.Name)]; foreach (var item2 in dic2.Keys.OrderBy(c => c)) { if (!p.Properties.ContainsKey(item2)) { p.Properties[item2] = dic2[item2]; } } p = new JsonSchemaProperty() { Type = JsonObjectType.Object, IsRequired = true, }; dic.Add("TargetLink", p); dic2 = new Dictionary <string, JsonSchemaProperty>(); foreach (var property in item.Target.Properties) { dic2.Add(property.Name, GetProperty(property)); } p.Properties[nameof(ReferentialBase.Name)] = dic2[nameof(ReferentialBase.Name)]; foreach (var item2 in dic2.Keys.OrderBy(c => c)) { if (!p.Properties.ContainsKey(item2)) { p.Properties[item2] = dic2[item2]; } } }
public static RelationshipDefinition RelationshipDefinitionClone(Domain OwnerEntity, IList <RelationshipDefinition> EditedList, RelationshipDefinition RelationshipDef) { var Result = new RelationshipDefinition(); Result.PopulateFrom(RelationshipDef, null, ECloneOperationScope.Deep); var NamesWereEquivalent = (Result.TechName == Result.Name.TextToIdentifier()); Result.Name = Result.Name + "(copy)"; // Auto-update of TechName when equivalents if (!NamesWereEquivalent) { Result.TechName = Result.TechName + "_copy"; } return(Result); }
public static IRelationshipDefinition DescribeOneToManyRelationship(this IObjectDefinition source, IObjectDefinition that, string thisProperty, string thatProperty, string name = "", string description = "") { var n = name == string.Empty ? string.Format("{0}_{1}", source.FullName, that.FullName) : name; var d = description == string.Empty ? string.Format("Child Relationship from {0} to {1}.", source.FullName, that.FullName) : description; var rel = new RelationshipDefinition(); rel.Description = d; rel.FullName = n; rel.Name = n; rel.RelatedObjectDefinitionFullName = that.FullName; rel.ThisObjectDefinitionFullName = source.FullName; rel.RelationshipType = RelationshipType.Child; rel.ThisProperties = thisProperty; rel.RelatedProperties = thatProperty; return(rel); }
public ViewpointModel GetViewpointModel() { var models = File.Parent.Models; var result = new ViewpointModel() { Type = typeof(CooperationViewpoint).Name, Name = this.Name, }; foreach (var item in this.Concepts) { result.AddChildren(item.GetViewpointItem(this.File)); } foreach (var item in this.Elements) { result.AddChildren(item.GetViewpointItem(this.File)); } foreach (var item in this.References) { RelationshipDefinition rel = models.GetRelationshipDefinition(item.Name); if (rel == null) { models.Diagnostic.Append(new DiagnositcMessage() { File = File.FullPath, Severity = SeverityEnum.Error, Text = $"Entity definition {item.Name} can't be resolved" }); } else { foreach (var r in result.Children) { r.SetReference(this.File, rel); } } } return(result); }
/// <summary> /// Determines whether a working relationship being created/extended can support the creation of a new link. /// </summary> private static OperationResult <bool> EvaluateLinkability(RelationshipDefinition Definitor, VisualRepresentation OriginRepresentation, VisualRepresentation TargetRepresentation, Relationship PotentialOriginRelationship, Relationship PotentialTargetRelationship, Relationship WorkingRelationship, bool IsForRelink = false) { OperationResult <bool> CanLink = OperationResult.Success(true); if (WorkingRelationship == PotentialOriginRelationship) { if (!IsForRelink && WorkingRelationship.RelationshipDefinitor.Value.IsSimple && WorkingRelationship.Links.Count > 1) { CanLink = OperationResult.Failure <bool>("Simple source working relationship already has origin and target connected."); } /*!? CANCELLED: Inhibits connect a Relationship (thinking that this will extend that Rel links) * if (!IsForRelink * && CanLink.Result && PotentialTargetRelationship != null * && PotentialTargetRelationship.RelationshipDefinitor.Value.IsSimple * && PotentialTargetRelationship.Links.Count > 1) * CanLink = OperationResult.Failure<bool>("Simple destination working relationship already has origin and target connected."); */ if (CanLink.Result && TargetRepresentation != null) { foreach (var SourceLink in PotentialOriginRelationship.Links.Where(link => link.RoleDefinitor.RoleType != ERoleType.Target)) { CanLink = Definitor.CanLink(SourceLink.AssociatedIdea.IdeaDefinitor, TargetRepresentation.RepresentedIdea.IdeaDefinitor); if (CanLink.Result) { break; } } } } else { if (!IsForRelink && WorkingRelationship.RelationshipDefinitor.Value.IsSimple && WorkingRelationship.Links.Count > 1) { CanLink = OperationResult.Failure <bool>("Simple destination relationship already has origin and target connected."); } /*!? CANCELLED: Inhibits connect a Relationship (thinking that this will extend that Rel links) * if (!IsForRelink * && CanLink.Result && PotentialOriginRelationship != null * && PotentialOriginRelationship.RelationshipDefinitor.Value.IsSimple * && PotentialOriginRelationship.Links.Count > 1) * CanLink = OperationResult.Failure<bool>("Simple source relationship already has origin and target connected."); */ if (CanLink.Result && OriginRepresentation != null) { foreach (var DestinationLink in PotentialTargetRelationship.Links.Where(link => link.RoleDefinitor.RoleType == ERoleType.Target)) { CanLink = Definitor.CanLink(OriginRepresentation.RepresentedIdea.IdeaDefinitor, DestinationLink.AssociatedIdea.IdeaDefinitor); if (CanLink.Result) { break; } } } } return(CanLink); }
// --------------------------------------------------------------------------------------------------------------------------------------------------------- public static OperationResult <Relationship> CreateRelationship(Idea DestinationComposite, RelationshipDefinition Definitor, View TargetView, VisualRepresentation OriginRepresentation, Point OriginPosition, VisualRepresentation TargetRepresentation, Point TargetPosition, bool ExtendFromOriginRelationship = true, // (Shift not pressed) Applicable only when origin and target are both relationships. Else (Shift pressed) create Rel. from Target to Origin. bool ExtendExistingRelationship = true) // (Right-Alt not pressed) Applicable only when origin is a not (simple and hiding-central-symbol) relationship. Else (Right-Alt pressed) created Rel. from Rel. { bool EditInPlace = false; General.ContractRequiresNotNull(DestinationComposite, Definitor, TargetView, OriginRepresentation); var MaxQuota = AppExec.CurrentLicenseEdition.TechName.SelectCorresponding(LicensingConfig.IdeasCreationQuotas); if (!ProductDirector.ValidateEditionLimit(DestinationComposite.OwnerComposition.DeclaredIdeas.Count() + 1, MaxQuota, "create", "Ideas (Concepts + Relationships)")) { return(OperationResult.Failure <Relationship>("This product edition cannot create more than " + MaxQuota + " Ideas.")); } if (!ExtendFromOriginRelationship && (TargetRepresentation == null || !(TargetRepresentation.RepresentedIdea is Relationship))) { ExtendFromOriginRelationship = true; } var PotentialOriginRelationship = OriginRepresentation.RepresentedIdea as Relationship; var PotentialTargetRelationship = (TargetRepresentation == null ? (Relationship)null : TargetRepresentation.RepresentedIdea as Relationship); bool CreatingNewRelationship = (/*?*/ !ExtendExistingRelationship || /*?*/ !((PotentialOriginRelationship != null && PotentialOriginRelationship.RelationshipDefinitor.Value == Definitor) || (PotentialTargetRelationship != null && PotentialTargetRelationship.RelationshipDefinitor.Value == Definitor))); bool?ExtensionFromOriginRelationship = (CreatingNewRelationship ? (bool?)null : (PotentialOriginRelationship != null && ExtendFromOriginRelationship)); if (!CreatingNewRelationship && TargetRepresentation == null) { if (OriginRepresentation is RelationshipVisualRepresentation) { return(OperationResult.Success(((RelationshipVisualRepresentation)OriginRepresentation).RepresentedRelationship, "Creating new Relationship.")); } else { return(OperationResult.Failure <Relationship>("There is no targeted Idea to relate.")); } } if (DestinationComposite.IdeaDefinitor.CompositeContentDomain == null) { return(OperationResult.Failure <Relationship>("Destination Container doest not accept Composite-Content.", DestinationComposite)); } if (DestinationComposite.CompositeContentDomain.GlobalId != Definitor.OwnerDomain.GlobalId) { return(OperationResult.Failure <Relationship>("The destination container only accepts content of the '" + DestinationComposite.CompositeContentDomain.Name + "' Domain.")); } Relationship WorkingRelationship = null; LinkRoleDefinition OriginLinkRoleDef = null; RoleBasedLink OriginLink = null; DestinationComposite.EditEngine.StartCommandVariation("Create Relationship"); if (CreatingNewRelationship) { if (TargetRepresentation != null) { var CanLink = Definitor.CanLink(OriginRepresentation.RepresentedIdea.IdeaDefinitor, TargetRepresentation.RepresentedIdea.IdeaDefinitor); if (!CanLink.Result) { DestinationComposite.EditEngine.DiscardCommandVariation(); return(OperationResult.Failure <Relationship>(CanLink.Message)); } } string NewName = Definitor.Name; var AppendNumToName = AppExec.GetConfiguration <bool>("IdeaEditing", "Relationship.OnCreationAppendDefNameAndNumber", true); if (AppendNumToName) { NewName = NewName + " (Idea " + (DestinationComposite.CompositeIdeas.Count + 1).ToString() + ")"; } WorkingRelationship = new Relationship(DestinationComposite.OwnerComposition, Definitor, NewName, NewName.TextToIdentifier()); if (Definitor.IsVersionable) { WorkingRelationship.Version = new VersionCard(); } WorkingRelationship.AddToComposite(DestinationComposite); OriginLinkRoleDef = Definitor.GetLinkForRole(ERoleType.Origin); OriginLink = new RoleBasedLink(WorkingRelationship, OriginRepresentation.RepresentedIdea, OriginLinkRoleDef, OriginLinkRoleDef.AllowedVariants[0]); WorkingRelationship.AddLink(OriginLink); PotentialOriginRelationship = WorkingRelationship; EditInPlace = true; } else { OperationResult <bool> CanLink = OperationResult.Success(true); if (ExtensionFromOriginRelationship.IsTrue()) { WorkingRelationship = PotentialOriginRelationship; } else { WorkingRelationship = (PotentialTargetRelationship != null ? PotentialTargetRelationship : PotentialOriginRelationship); } if (TargetRepresentation != null) { CanLink = EvaluateLinkability(Definitor, OriginRepresentation, TargetRepresentation, PotentialOriginRelationship, PotentialTargetRelationship, WorkingRelationship); if (!CanLink.Result) { DestinationComposite.EditEngine.DiscardCommandVariation(); return(OperationResult.Failure <Relationship>("Cannot create/extend Relationship. Cause: " + CanLink.Message)); } } } LinkRoleDefinition WorkingLinkRoleDef = null; RoleBasedLink WorkingLink = null; if (TargetRepresentation != null && (CreatingNewRelationship || (WorkingRelationship == PotentialOriginRelationship && ExtensionFromOriginRelationship.IsTrue()))) { WorkingLinkRoleDef = Definitor.GetLinkForRole(ERoleType.Target); if (WorkingRelationship.Links.Where(link => link.RoleDefinitor == WorkingLinkRoleDef && link.AssociatedIdea == TargetRepresentation.RepresentedIdea).Any()) { DestinationComposite.EditEngine.DiscardCommandVariation(); return(OperationResult.Failure <Relationship>("Cannot create Target Link. Cause: Already exists one of the same role-type associating the same Idea.")); } WorkingLink = new RoleBasedLink(WorkingRelationship, TargetRepresentation.RepresentedIdea, WorkingLinkRoleDef, WorkingLinkRoleDef.AllowedVariants[0]); WorkingRelationship.AddLink(WorkingLink); } if (OriginRepresentation != null && !CreatingNewRelationship && WorkingRelationship == PotentialTargetRelationship && !ExtensionFromOriginRelationship.IsTrue()) { WorkingLinkRoleDef = Definitor.GetLinkForRole(ERoleType.Origin); if (WorkingRelationship.Links.Where(link => link.RoleDefinitor == WorkingLinkRoleDef && link.AssociatedIdea == OriginRepresentation.RepresentedIdea).Any()) { DestinationComposite.EditEngine.DiscardCommandVariation(); return(OperationResult.Failure <Relationship>("Cannot create Origin Link. Cause: Already exists one of the same role-type associating the same Idea.")); } WorkingLink = new RoleBasedLink(WorkingRelationship, OriginRepresentation.RepresentedIdea, WorkingLinkRoleDef, WorkingLinkRoleDef.AllowedVariants[0]); WorkingRelationship.AddLink(WorkingLink); } RelationshipVisualRepresentation Representator = null; VisualSymbol CentralSymbol = null; if (TargetPosition != Display.NULL_POINT && OriginPosition != Display.NULL_POINT) { VisualConnector OriginConnector = null; var InitialPosition = OriginPosition; var EdgeOriginPosition = OriginPosition; var EdgeTargetPosition = TargetPosition; if (CreatingNewRelationship) { // Force connect from Symbols' centers. if (OriginRepresentation != null) { EdgeOriginPosition = OriginPosition.DetermineNearestIntersectingPoint(TargetPosition, TargetView.Presenter, OriginRepresentation.MainSymbol.Graphic, TargetView.VisualHitTestFilter); } if (TargetRepresentation == null) { InitialPosition = TargetPosition; } else { EdgeTargetPosition = TargetPosition.DetermineNearestIntersectingPoint(OriginPosition, TargetView.Presenter, TargetRepresentation.MainSymbol.Graphic, TargetView.VisualHitTestFilter); InitialPosition = EdgeOriginPosition.DetermineCenterRespect(EdgeTargetPosition); } // Create representation Representator = CreateRelationshipVisualRepresentation(WorkingRelationship, TargetView, InitialPosition); CentralSymbol = Representator.MainSymbol; // Notice that here the Origin connector is being drawn, so the Target plug is empty/none (because is connected to the Relationship Central/Main Symbol). OriginConnector = new VisualConnector(Representator, OriginLink, OriginRepresentation.MainSymbol, CentralSymbol, OriginPosition, CentralSymbol.BaseCenter); } else { if (WorkingRelationship == PotentialOriginRelationship) { Representator = (RelationshipVisualRepresentation)OriginRepresentation; } else { Representator = (RelationshipVisualRepresentation)TargetRepresentation; } CentralSymbol = OriginRepresentation.MainSymbol; InitialPosition = CentralSymbol.BaseCenter; } VisualConnector TargetConnector = null; VisualConnector OriginAutoRefConnector = null; if (TargetRepresentation != null) { TargetConnector = new VisualConnector(Representator, WorkingLink, CentralSymbol, TargetRepresentation.MainSymbol, InitialPosition, TargetPosition); if (WorkingRelationship == PotentialOriginRelationship) { OriginAutoRefConnector = CentralSymbol.OriginConnections.FirstOrDefault(conn => conn.OriginSymbol == TargetRepresentation.MainSymbol); } } if (CreatingNewRelationship) { Representator.AddVisualPart(OriginConnector); } if (TargetConnector != null) { Representator.AddVisualPart(TargetConnector); } if (OriginAutoRefConnector != null) { Representator.BendAutoRefConnectors(OriginAutoRefConnector, TargetConnector); } Representator.Render(); } DestinationComposite.UpdateVersion(); DestinationComposite.EditEngine.CompleteCommandVariation(); var InformedRelationship = WorkingRelationship; if (WorkingRelationship == PotentialTargetRelationship && PotentialOriginRelationship != null) { InformedRelationship = PotentialOriginRelationship; } return(OperationResult.Success(InformedRelationship, null, null, CentralSymbol.OwnerRepresentation, EditInPlace)); }
protected override Type GetTargetEntityType(RelationshipDefinition relationshipDef) { Type targetEntityType = PriceBookExportHelper.TryGetTargetEntityType(relationshipDef); return((object)targetEntityType != null ? targetEntityType : base.GetTargetEntityType(relationshipDef)); }
public static bool RelationshipDefinitionEdit(Domain SourceDomain, IList <RelationshipDefinition> EditedList, RelationshipDefinition RelationshipDef) { /*- if (!ProductDirector.ConfirmImmediateApply("Relationship Definition", "DomainEdit.RelationshipDefinition", "ApplyDialogChangesDirectly")) * return false; */ var CurrentWindow = Display.GetCurrentWindow(); CurrentWindow.Cursor = Cursors.Wait; var InstanceController = EntityInstanceController.AssignInstanceController(RelationshipDef, (current, previous, editpanels) => { var CurrentDetailsEditor = (GlobalDetailsDefinitor)editpanels.First(editpanel => editpanel is GlobalDetailsDefinitor); // IMPORTANT: Ensure that at least one linking variant is available. if (current.OriginOrParticipantLinkRoleDef.AllowedVariants.Count < 1) { current.OriginOrParticipantLinkRoleDef.AllowedVariants.Add(current.OwnerDomain.LinkRoleVariants.FirstOrDefault()); } if (current.TargetLinkRoleDef != null && current.TargetLinkRoleDef.AllowedVariants.Count < 1) { current.TargetLinkRoleDef.AllowedVariants.Add(current.OwnerDomain.LinkRoleVariants.FirstOrDefault()); } return(CurrentDetailsEditor.UpdateRelatedDetailDefinitions(current)); }); var DetDefEd = GlobalDetailsDefinitor.CreateGlobalDetailsDefinitor(InstanceController.EntityEditor, RelationshipDef); InstanceController.StartEdit(); var ExtraGeneralContentsPanel = new Grid(); ExtraGeneralContentsPanel.ColumnDefinitions.Add(new ColumnDefinition()); ExtraGeneralContentsPanel.ColumnDefinitions.Add(new ColumnDefinition()); var ExtraGenContentPanelLeft = new StackPanel(); Grid.SetColumn(ExtraGenContentPanelLeft, 0); ExtraGeneralContentsPanel.Children.Add(ExtraGenContentPanelLeft); var ExtraGenContentPanelRight = new StackPanel(); Grid.SetColumn(ExtraGenContentPanelRight, 1); ExtraGeneralContentsPanel.Children.Add(ExtraGenContentPanelRight); var Expositor = new EntityPropertyExpositor(RelationshipDefinition.__IsComposable.TechName); Expositor.LabelMinWidth = 180; ExtraGenContentPanelLeft.Children.Add(Expositor); Expositor = new EntityPropertyExpositor(ConceptDefinition.__IsVersionable.TechName); Expositor.LabelMinWidth = 180; ExtraGenContentPanelLeft.Children.Add(Expositor); Expositor = new EntityPropertyExpositor(ConceptDefinition.__HasGroupRegion.TechName); Expositor.LabelMinWidth = 180; ExtraGenContentPanelLeft.Children.Add(Expositor); Expositor = new EntityPropertyExpositor(ConceptDefinition.__HasGroupLine.TechName); Expositor.LabelMinWidth = 180; ExtraGenContentPanelLeft.Children.Add(Expositor); Expositor = new EntityPropertyExpositor(RelationshipDefinition.__RepresentativeShape.TechName); Expositor.LabelMinWidth = 180; ExtraGenContentPanelLeft.Children.Add(Expositor); Expositor.PostCall(expo => { var Combo = expo.ValueEditor as ComboBox; if (Combo != null) { var Panel = new FrameworkElementFactory(typeof(WrapPanel)); Panel.SetValue(WrapPanel.WidthProperty, 810.0); Panel.SetValue(WrapPanel.ItemWidthProperty, 200.0); // Don't work as expected: Panel.SetValue(WrapPanel.OrientationProperty, Orientation.Vertical); var Templ = new ItemsPanelTemplate(Panel); Combo.ItemsPanel = Templ; } }, true); Expositor = new EntityPropertyExpositor(ConceptDefinition.__PreciseConnectByDefault.TechName); Expositor.LabelMinWidth = 180; ExtraGenContentPanelLeft.Children.Add(Expositor); var ClosuredExpositor = new EntityPropertyExpositor(IdeaDefinition.__Cluster.TechName); ClosuredExpositor.LabelMinWidth = 210; ExtraGenContentPanelRight.Children.Add(ClosuredExpositor); var PropCtl = InstanceController.GetPropertyController(IdeaDefinition.__Cluster.TechName); PropCtl.ComplexOptionsProviders = Tuple.Create <IRecognizableElement, Action <object> >( new SimplePresentationElement("Edit Clusters", "EditClusters", "Edit Clusters", Display.GetAppImage("def_clusters.png")), obj => { if (DomainServices.DefineDomainIdeaDefClusters(SourceDomain, DomainServices.TABKEY_IDEF_CLUSTER_RELATIONSHIP)) { ClosuredExpositor.RetrieveAvailableItems(); } }).IntoArray(); Expositor = new EntityPropertyExpositor(RelationshipDefinition.__CanAutomaticallyCreateRelatedConcepts.TechName); Expositor.LabelMinWidth = 210; ExtraGenContentPanelRight.Children.Add(Expositor); Expositor = new EntityPropertyExpositor(RelationshipDefinition.__IsSimple.TechName); Expositor.LabelMinWidth = 210; ExtraGenContentPanelRight.Children.Add(Expositor); Expositor = new EntityPropertyExpositor(RelationshipDefinition.__HideCentralSymbolWhenSimple.TechName); Expositor.LabelMinWidth = 210; ExtraGenContentPanelRight.Children.Add(Expositor); Expositor = new EntityPropertyExpositor(RelationshipDefinition.__ShowNameIfHidingCentralSymbol.TechName); Expositor.LabelMinWidth = 210; ExtraGenContentPanelRight.Children.Add(Expositor); var VisualSymbolFormatter = new VisualSymbolFormatSubform("DefaultSymbolFormat"); var VisualConnectorsFormatter = new VisualConnectorsFormatSubform("DefaultConnectorsFormat", RelationshipDef.DefaultConnectorsFormat); var TemplateEd = new TemplateEditor(); TemplateEd.Initialize(SourceDomain, SourceDomain.CurrentExternalLanguage.TechName, typeof(Relationship), RelationshipDef, IdeaDefinition.__OutputTemplates, Domain.__OutputTemplatesForRelationships, false, Tuple.Create <string, ImageSource, string, Action <string> >("Insert predefined...", Display.GetAppImage("page_white_wrench.png"), "Inserts a system predefined Output-Template text, at the current selection.", text => { var tpl = DomainServices.GetPredefinedOutputTemplate(); if (tpl != null) { TemplateEd.SteSyntaxEditor.ReplaceTextAtSelection(tpl); } }), Tuple.Create <string, ImageSource, string, Action <string> >("Test", Display.GetAppImage("page_white_wrench.png"), "Test the Template against a source Relationship.", text => RememberedTemplateTestRelationship[SourceDomain.OwnerComposition] = TemplateTester.TestTemplate(typeof(Relationship), RelationshipDef, IdeaDefinition.__OutputTemplates.Name, RelationshipDef.GetGenerationFinalTemplate(TemplateEd.CurrentTemplate.Language, text, TemplateEd.ChbExtendsBaseTemplate.IsChecked.IsTrue()), SourceDomain.OwnerComposition, RememberedTemplateTestRelationship.GetValueOrDefault(SourceDomain.OwnerComposition) .NullDefault(SourceDomain.OwnerComposition.CompositeIdeas.OrderBy(idea => idea.Name) .FirstOrDefault(idea => idea.IdeaDefinitor == RelationshipDef) .NullDefault(SourceDomain.OwnerComposition.DeclaredIdeas .FirstOrDefault(idea => idea is Relationship)))))); var TemplateTab = TabbedEditPanel.CreateTab(DomainServices.TABKEY_DEF_OUTTEMPLATE, "Output-Templates", "Definition of Output-Templates", TemplateEd); var SpecTabs = General.CreateList( TabbedEditPanel.CreateTab(DomainServices.TABKEY_DEF_ARRANGE, "Arrange", "Settings for relate and group ideas.", new ArrangeTabForRelationshipDef(RelationshipDef)), TabbedEditPanel.CreateTab(TABKEY_DEF_REL_LINKROLEDEF_ORIPAR, "Origin/Participant Link-Role Def.", "Definition of Link-Role for Origin or Participant.", new LinkRoleDefSpecSubform("OriginOrParticipantLinkRoleDef", false, RelationshipDef.OriginOrParticipantLinkRoleDef, RelationshipDef)), TabbedEditPanel.CreateTab(TABKEY_DEF_REL_LINKROLEDEF_TARGET, "Target Link-Role Def.", "Definition of Link-Role for Target.", new LinkRoleDefSpecSubform("TargetLinkRoleDef", true, RelationshipDef.TargetLinkRoleDef, RelationshipDef)), TabbedEditPanel.CreateTab(DomainServices.TABKEY_DEF_FORMAT, "Symbol format", "Definition for the Central/Main-Symbol format.", VisualSymbolFormatter), TabbedEditPanel.CreateTab(TABKEY_DEF_REL_CONNFORMAT, "Connectors format", "Definition for the Connectors format.", VisualConnectorsFormatter), TabbedEditPanel.CreateTab(DomainServices.TABKEY_DEF_DETAILS, "Details", "Details definition.", DetDefEd), TemplateTab); var EditPanel = Display.CreateEditPanel(RelationshipDef, SpecTabs, true, null, Display.TABKEY_TECHSPEC + General.STR_SEPARATOR + DomainServices.TABKEY_DEF_OUTTEMPLATE, true, false, true, true, ExtraGeneralContentsPanel); EditPanel.Loaded += ((sender, args) => { var OwnerWindow = EditPanel.GetNearestVisualDominantOfType <Window>(); OwnerWindow.MinWidth = 750; OwnerWindow.MinHeight = 550; OwnerWindow.PostCall(wnd => CurrentWindow.Cursor = Cursors.Arrow); }); if (IdeaDefinition.__OutputTemplates.IsAdvanced) { EditPanel.ShowAdvancedMembersChanged += ((show) => { TemplateTab.SetVisible(show); if (!show) { var OwnerTabControl = TemplateTab.GetNearestDominantOfType <TabControl>(); if (OwnerTabControl.SelectedItem == TemplateTab) { OwnerTabControl.SelectedIndex = 0; } } }); } var Previewer = new VisualElementPreviewer(VisualSymbolFormatter.VisualElementFormatter.ExpoLineBrush, VisualSymbolFormatter.VisualElementFormatter.ExpoLineThickness, VisualSymbolFormatter.VisualElementFormatter.ExpoLineDash, VisualSymbolFormatter.VisualElementFormatter.ExpoMainBackground, VisualConnectorsFormatter.VisualElementFormatter.ExpoLineBrush, VisualConnectorsFormatter.VisualElementFormatter.ExpoLineThickness, VisualConnectorsFormatter.VisualElementFormatter.ExpoLineDash, VisualConnectorsFormatter.VisualElementFormatter.ExpoMainBackground); Previewer.AttachSource(RelationshipDef); Previewer.Margin = new Thickness(4); EditPanel.HeaderContent = Previewer; Previewer.PostCall(prv => prv.ShowPreview()); // Required because of initially unpopulated properties of old Domains. var Result = InstanceController.Edit(EditPanel, "Edit Relationship Definition - " + RelationshipDef.ToString(), true, null, RELDEFWND_INI_WIDTH, RELDEFWND_INI_HEIGHT).IsTrue(); return(Result); }
public static bool RelationshipDefinitionDelete(Domain OwnerEntity, IList <RelationshipDefinition> EditedList, RelationshipDefinition RelationshipDef) { var Result = Display.DialogMessage("Confirmation", "Are you sure you want to Delete the '" + RelationshipDef.Name + "' Relationship Definition?", EMessageType.Question, System.Windows.MessageBoxButton.YesNo, System.Windows.MessageBoxResult.No); return(Result == MessageBoxResult.Yes); }
public ArrangeTabForRelationshipDef(RelationshipDefinition RelationshipDef) : this() { this.RelationshipDef = RelationshipDef; }
private ReferentialRelationship PopulateLink(JObject jObject, RelationshipDefinition schema) { var target = new ReferentialRelationship(this._referenceSchema.Type, _file) { Schema = this._referenceSchema, }; foreach (var item in jObject.Properties()) { if (item.Name == "OriginLink") { var i = (JObject)item.Value; foreach (var item2 in i.Properties()) { var p = schema.Origin.Properties.FirstOrDefault(c => c.Name.ToLower() == item2.Name.ToLower()); if (p != null) { try { var value = ConvertValue(p.Type, item2.Value); target.Origin[p.Name] = value; } catch (Exception e1) { this._diagnostic.Append(new DiagnositcMessage() { Severity = SeverityEnum.Error, Text = e1.Message, Exception = e1 }); } } else { } } } else if (item.Name == "TargetLink") { var i = (JObject)item.Value; foreach (var item2 in i.Properties()) { var p = schema.Target.Properties.FirstOrDefault(c => c.Name == item2.Name); if (p != null) { try { var value = ConvertValue(p.Type, item2.Value); target.Target[p.Name] = value; } catch (Exception e2) { this._diagnostic.Append(new DiagnositcMessage() { Severity = SeverityEnum.Error, Text = e2.Message, Exception = e2 }); } } else { } } } else { var p = schema.Properties.FirstOrDefault(c => c.Name == item.Name); if (p != null) { try { var value = ConvertValue(p.Type, item.Value); target[item.Name] = value; } catch (Exception e3) { this._diagnostic.Append(new DiagnositcMessage() { Severity = SeverityEnum.Error, Text = e3.Message, Exception = e3 }); } } } } return(target); }
/// <summary> /// This method retrieves a list of parent child relationships for this particual object. /// </summary> /// <param name="tableName">Name of the table to retrieve the definitions for</param> /// <returns></returns> private List<IRelationshipDefinition> GetTableRelations(string tableName) { List<IRelationshipDefinition> relationshipDefinitions = new List<IRelationshipDefinition>(); //Use meta data access to retrieve the foreign key information DataTable foreignKeyIndexes = _metadataAccess.GetTableForeignKeyInformation(tableName); //Parse through each relationship returned in the data table foreach (DataRow foreignKeyRow in foreignKeyIndexes.Rows) { if (relationshipDefinitions.Count > 0) { bool keyFound = false; //Check if the key has already been added to the list of relations. foreach (var definition in relationshipDefinitions) { if (definition.Name != foreignKeyRow["FK_NAME"].ToString()) continue; //Append the additional properties to the relationship //Note: these must be added as a comma seperated list definition.ThisProperties += "," + foreignKeyRow["FK_COLUMN_NAME"]; definition.RelatedProperties += "," + foreignKeyRow["PK_COLUMN_NAME"]; keyFound = true; break; } //Don't create a new definition if the current one has been found if (keyFound) { continue; } } //Create a new RelationshipDefinition using the Foreign Key values RelationshipDefinition relationshipDefinition = new RelationshipDefinition { Description = string.Empty, Name = foreignKeyRow["FK_NAME"].ToString(), FullName = foreignKeyRow["FK_NAME"].ToString(), //This is the name of the Parent Object ThisObjectDefinitionFullName = foreignKeyRow["FK_TABLE_NAME"].ToString(), //This is the name of the field or fields in the Parent Object. //Note: Multiple values must be a comma seperated list ThisProperties = foreignKeyRow["FK_COLUMN_NAME"].ToString(), //This is the name of the Referenced Object RelatedObjectDefinitionFullName = foreignKeyRow["PK_TABLE_NAME"].ToString(), //This is the name of the field or fields in the Referenced Object. //Note: Multiple values must be a comma seperated list RelatedProperties = foreignKeyRow["PK_COLUMN_NAME"].ToString(), }; relationshipDefinitions.Add(relationshipDefinition); } return relationshipDefinitions; }
protected override List <ProjectionItem> List() { var configViewpoint = Referential.GetCooperationViewpoint(this.Diagram.ViewpointType); if (configViewpoint != null) { var item1 = this.ModelElement; var result = new List <ProjectionItem>(300); if (item1 is Bb.ApplicationCooperationViewPoint.ModelElement me) { foreach (var e in configViewpoint.Elements) { var query = new ResolveQuery() { Kind = Galileo.ElementEnum.Entity, TypeName = e.Name }; var items = query.GetReferentials(this.Referential); result.AddRange(GetReferentials(items)); } } else if (item1 is Concept co) { foreach (var e in configViewpoint.Concepts) { var query = new ResolveQuery() { Kind = Galileo.ElementEnum.Entity, TypeName = e.Name }; var items = query.GetReferentials(this.Referential); result.AddRange(GetReferentials(items)); } } else if (item1 is SubElement se) { if (!string.IsNullOrEmpty(se.Parent.Type)) { foreach (var element in configViewpoint.Elements.Where(c => c.Name == se.Parent.Type)) { foreach (CooperationRelationship sElement in element.Children) { RelationshipDefinition itemDef = sElement.GetRelationshipDefinition(this.Referential); ResolveQuery parentQuery = se.Parent.ReferenceSource.AsQuery(); var p = parentQuery.GetReferentials(this.Referential).OfType <ReferentialEntity>().FirstOrDefault(); var children = p.GetTargetEntities(itemDef).ToList(); result.AddRange(GetReferentials(children)); } } } } else if (item1 is ConceptElement ce) { if (!string.IsNullOrEmpty(ce.Parent.Type)) { foreach (var element in configViewpoint.Elements.Where(c => c.Name == ce.Parent.Type)) { foreach (CooperationRelationship sElement in element.Children) { RelationshipDefinition itemDef = sElement.GetRelationshipDefinition(this.Referential); var parentQuery = ce.Parent.ReferenceSource.AsQuery(); var p = parentQuery.GetReferentials(this.Referential).OfType <ReferentialEntity>().FirstOrDefault(); var children = p.GetTargetEntities(itemDef).ToList(); result.AddRange(GetReferentials(children)); } } } } else if (item1 is ConceptSubElement cs) { } else if (item1 is Relationship re) { } return(result.OrderBy(c => c.Name).Cast <ProjectionItem>().ToList()); } throw new System.NotImplementedException(); }
/// <summary> /// Constructor for edit an entity child property. /// </summary> public LinkRoleDefSpecSubform(string ChildPropertyName, bool CanSpecifyDirectionType, LinkRoleDefinition TargetLinkRoleDef, RelationshipDefinition ParentRelDef) : this() { this.ChildPropertyName = ChildPropertyName; this.CanSpecifyDirectionType = CanSpecifyDirectionType; this.TargetLinkRoleDef = TargetLinkRoleDef; this.ParentRelDef = ParentRelDef; this.RelationshipIsDirectional = ParentRelDef.IsDirectional; // Just to force visual update // PENDING: EXPOSE WHEN SUPPORTED. // this.ExpoMaxConnections.SetVisible(!this.TargetLinkRoleDef.OwnerRelationshipDef.IsSimple); this.ExpoMaxConnections.SetVisible(false); // PENDING: EXPOSE WHEN SUPPORTED. this.ExpoRelatedIdeasAreOrdered.SetVisible(false); this.Loaded += new RoutedEventHandler(LinkRoleDefSpecSubform_Loaded); }