/// <summary> /// Constructor for <see cref="TransactionalSingleRelationship"/> /// </summary> /// <param name="relationship"></param> /// <param name="relatedBO"></param> protected TransactionalSingleRelationship(IRelationship relationship, IBusinessObject relatedBO) { if (relatedBO == null) throw new ArgumentNullException("relatedBO"); _transactionID = Guid.NewGuid().ToString(); _relationship = relationship; _relatedBO = relatedBO; }
public SpecificationProperty(ISpecificationModel model, string name, string propertyType, bool required) { this.model = model; this.name = name; this.propertyType = propertyType; this.required = required; string common = this.name.Substring(1, this.name.Length - 1); this._default = null; this.isEnumeration = false; this.instanceName = this.name.Length <= 2 ? this.name.ToLower() : this.name.Substring(0, 1).ToLower() + common; this.name = this.name.Substring(0, 1).ToUpper() + common; if (this.instanceName.EndsWith("y")) { this.listInstanceName = this.instanceName.Substring(0, this.instanceName.Length - 1) + "ies"; } else if (this.instanceName.EndsWith("ss")) { this.listInstanceName = this.instanceName + "es"; } else if (this.instanceName.EndsWith("s")) { this.listInstanceName = this.instanceName; } else { this.listInstanceName = this.instanceName + "s"; } this.relationship = null; }
protected override ITopic[] FetchNextTopics() { IEntity listener = this.ConversationEngine.Listener; IEntity instigator = this.ConversationEngine.Instigator; IEnumerable <IRelationship> relationships = this.RelationshipHandler.Get( new[] { instigator.Guid, listener.Guid }, new[] { "romantic" }); int highestValue = int.MinValue; IRelationship chosenRelationship = null; foreach (IRelationship relationship in relationships) { int value = relationship.GetRelationshipValue(instigator.Guid, listener.Guid); if (value > highestValue) { highestValue = value; chosenRelationship = relationship; } } string decision = ""; bool bonded = false; if (highestValue > listener.Romance.BondingThreshold && chosenRelationship is null == false) { decision = "Yes, I will!"; chosenRelationship.AddTag("bonded"); bonded = true; }
public void SelectEdgeAsync(IRelationship edge) { this.Edge = edge; this.Header.Text = string.Format("Edge {0}", edge.Type); this.Properties.Add(new PropertyItem() { Key = "Id", Value = edge.Id.ToString() }); this.Properties.Add(new PropertyItem() { Key = "Start Node", Value = edge.StartNodeId.ToString() }); this.Properties.Add(new PropertyItem() { Key = "End Node", Value = edge.EndNodeId.ToString() }); foreach (var property in edge.Properties) { this.Properties.Add(new PropertyItem() { Key = property.Key, Value = property.Value.ToString() }); } }
// <summary> // Used during the resolve phase to resolve the type name to the object that represents that type // </summary> internal override void ResolveTopLevelNames() { base.ResolveTopLevelNames(); if (_relationship == null) { SchemaType element; if (!Schema.ResolveTypeName(this, _unresolvedRelationshipTypeName, out element)) { return; } _relationship = element as IRelationship; if (_relationship == null) { AddError( ErrorCode.InvalidPropertyType, EdmSchemaErrorSeverity.Error, Strings.InvalidRelationshipSetType(element.Name)); return; } } foreach (var end in Ends) { end.ResolveTopLevelNames(); } }
protected static string GetEntityName(IRelationship relationship, Mappings mappings) { string entityName = string.IsNullOrEmpty(relationship.EntityName) ? null : relationship.EntityName; string className = string.IsNullOrEmpty(relationship.Class) ? null : relationship.Class; return(entityName ?? (className == null ? null : StringHelper.GetFullClassname(FullQualifiedClassName(className, mappings)))); }
public ConnectionSet GetConnection(INode node, IRelationship relationship, ConnectionType connectionType) { if (Connections.ContainsKey(node)) { if (Connections[node].ContainsKey(relationship)) { if (Connections[node][relationship].ContainsKey(connectionType)) { return Connections[node][relationship][connectionType]; } } else { Connections[node][relationship] = new Dictionary<ConnectionType, ConnectionSet>(); } } else { Connections[node] = new Dictionary<IRelationship, Dictionary<ConnectionType, ConnectionSet>>(); Connections[node][relationship] = new Dictionary<ConnectionType, ConnectionSet>(); } ConnectionSet newConnectionSet = new ConnectionSet() { Node = node, Relationship = relationship, ConnectionType = connectionType }; Connections[node][relationship][connectionType] = newConnectionSet; return newConnectionSet; }
internal override void ResolveSecondLevelNames() { base.ResolveSecondLevelNames(); if (this._unresolvedRelationshipEndRole == null && this.EntitySet != null) { this.RelationshipEnd = this.InferRelationshipEnd(this.EntitySet); if (this.RelationshipEnd == null) { return; } this._unresolvedRelationshipEndRole = this.RelationshipEnd.Name; } else { if (this._unresolvedRelationshipEndRole == null) { return; } IRelationship relationship = this.ParentElement.Relationship; IRelationshipEnd end; if (relationship.TryGetEnd(this._unresolvedRelationshipEndRole, out end)) { this.RelationshipEnd = end; } else { this.AddError(ErrorCode.InvalidContainerTypeForEnd, EdmSchemaErrorSeverity.Error, (object)Strings.InvalidEntityEndName((object)this.Role, (object)relationship.FQName)); } } }
/// <summary> /// Creates a <see cref="RelatedBusinessObjectCollection{TBusinessObject}"/> with boType as its type parameter, using the Activator. /// </summary> /// <param name="boClassName"></param> /// <param name="relationship">The relationship that this <see cref="RelatedBusinessObjectCollection{TBusinessObject}"/> is the collection for</param> /// <param name="boAssemblyName"></param> /// <returns>The instantiated <see cref="RelatedBusinessObjectCollection{TBusinessObject}"/></returns> private static IBusinessObjectCollection CreateNewRelatedBusinessObjectCollection(string boAssemblyName, string boClassName, IRelationship relationship) { Type classType = null; TypeLoader.LoadClassType(ref classType, boAssemblyName, boClassName, "related object", "relationship definition"); return CreateNewRelatedBusinessObjectCollection(classType, relationship); }
///<summary> /// Returns a single relationship for with the specified relationship name. ///</summary> ///<param name="relationshipName">The specified relationship name</param> ///<returns>THe single relationship</returns> public ISingleRelationship GetSingle(string relationshipName) { ArgumentValidationHelper.CheckStringArgumentNotEmpty(relationshipName, "relationshipName"); IRelationship relationship = GetRelationshipAsSingle(relationshipName); return((ISingleRelationship)relationship); }
public ConnectionSet GetConnection(INode node, IRelationship relationship, ConnectionType connectionType) { if (Connections.ContainsKey(node)) { if (Connections[node].ContainsKey(relationship)) { if (Connections[node][relationship].ContainsKey(connectionType)) { return(Connections[node][relationship][connectionType]); } } else { Connections[node][relationship] = new Dictionary <ConnectionType, ConnectionSet>(); } } else { Connections[node] = new Dictionary <IRelationship, Dictionary <ConnectionType, ConnectionSet> >(); Connections[node][relationship] = new Dictionary <ConnectionType, ConnectionSet>(); } ConnectionSet newConnectionSet = new ConnectionSet() { Node = node, Relationship = relationship, ConnectionType = connectionType }; Connections[node][relationship][connectionType] = newConnectionSet; return(newConnectionSet); }
private static void UnloadGraph <T>(T obj, ActiveRecordMap activeRecordMap) where T : class, IActiveRecord, new() { foreach (BelongsToMap belongsToMap in activeRecordMap.BelongsToMappings) { IRelationship relationship = (IRelationship)belongsToMap.Field.GetValue(obj); relationship.Unload(); } foreach (HasOneMap hasOneMap in activeRecordMap.HasOneMappings) { IRelationship relationship = (IRelationship)hasOneMap.Field.GetValue(obj); relationship.Unload(); } foreach (HasManyMap hasManyMap in activeRecordMap.HasManyMappings) { IRelationship relationship = (IRelationship)hasManyMap.Field.GetValue(obj); relationship.Unload(); } foreach (HasAndBelongsToManyMap hasAndBelongsToManyMap in activeRecordMap.HasAndBelongsToManyMappings) { IRelationship relationship = (IRelationship)hasAndBelongsToManyMap.Field.GetValue(obj); relationship.Unload(); } }
public EdgeInformationControl(Model model, IRelationship edge) { InitializeComponent(); this.properties = new ObservableCollection <PropertyItem>(); this.Model = model; this.Edge = edge; this.DataContext = this; this.Header.Text = string.Format("Edge {0}", edge.Type); this.Properties.Add(new PropertyItem() { Key = "Id", Value = edge.Id.ToString() }); this.Properties.Add(new PropertyItem() { Key = "Start Node", Value = edge.StartNodeId.ToString() }); this.Properties.Add(new PropertyItem() { Key = "End Node", Value = edge.EndNodeId.ToString() }); foreach (var property in edge.Properties) { this.Properties.Add(new PropertyItem() { Key = property.Key, Value = property.Value.ToString() }); } }
/// <summary> /// Returns whether the relationship should be shown in the tree view or not.<br/> /// By default all Composition and Aggregation relationships will be shown in the /// tree. This method can be overriden to only show the relationships that you want. /// </summary> /// <param name="relationship"></param> /// <returns></returns> protected virtual bool MustRelationshipBeVisible(IRelationship relationship) { IRelationshipDef relationshipDef = relationship.RelationshipDef; return(relationshipDef.RelationshipType == RelationshipType.Composition || relationshipDef.RelationshipType == RelationshipType.Aggregation); }
/// <summary> /// This will return the target column name. this is important because we do not want to return the column name of the current table, but rather that /// column it is pointing to /// </summary> /// <param name="This">The Context Relationship</param> /// <param name="ContextSchemaObjectName">The parent with the column name you don't want</param> /// <returns></returns> public static string ToUniqueColumnName(this IRelationship This) { var targetColumnNameCount = 0; var fromColumnNameCount = 0; foreach (var rel in This.Parent.Relationships) { if (rel.ToColumnName == This.ToColumnName) { targetColumnNameCount++; } } foreach (var rel in This.Parent.Relationships) { if (rel.FromColumnName == This.FromColumnName) { fromColumnNameCount++; } } if (targetColumnNameCount == 1) { return(This.ToColumnName); } if (fromColumnNameCount == 1) { return(This.FromColumnName); } throw new Exception(string.Format("EzDbSchemaRelationshipExtentions.ToUniqueColumnName: Could not find any unique column names to write to :( {0} or {1} for {2}", This.ToColumnName, This.FromColumnName, This.Name)); }
public void ExecuteOperation() { var chain = new TransactionChain(); chain.TransactionCompleted += ChainOnTransactionCompleted; INode newNode = MapManager.CreateNode(Map.DomainId, Map.RootMapId.Value, Node.Proxy.NodeType, string.Empty, ref chain); IRelationship newMapContainerRelationship = MapManager.CreateRelationship(Map.DomainId, Map.RootMapId.Value, MapContainerRelationshipType, string.Empty, ref chain); newMapContainerRelationship.ConnectNode(FromConnectionType, newNode, ref chain); newMapContainerRelationship.ConnectNode(ToConnectionType, Map, ref chain); newNode.Metadata.Add(newMapContainerRelationship, FromConnectionType, "XPosition", (Node.Location.X + 100).ToString(), ref chain); newNode.Metadata.Add(newMapContainerRelationship, FromConnectionType, "YPosition", (Node.Location.Y + 100).ToString(), ref chain); newNode.Metadata.Add(newMapContainerRelationship, FromConnectionType, "CollapseState", "None", ref chain); newNode.Metadata.Add(newMapContainerRelationship, FromConnectionType, "Visibility", "Visible", ref chain); foreach (var metadata in Node.Metadata) { if (!string.IsNullOrEmpty(metadata.Value.Value)) { newNode.Metadata.Add(null, null, metadata.Key, metadata.Value.Value, ref chain); } } Response = new InProcessTransactionResponse(); Response.Nodes.Add(newNode); Response.Relationships.Add(newMapContainerRelationship); MapManager.ExecuteTransaction(chain); }
internal override void ResolveTopLevelNames() { base.ResolveTopLevelNames(); SchemaType type; if (!this.Schema.ResolveTypeName((SchemaElement)this, this._unresolvedRelationshipName, out type)) { return; } this._relationship = type as IRelationship; if (this._relationship == null) { this.AddError(ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error, (object)Strings.BadNavigationPropertyRelationshipNotRelationship((object)this._unresolvedRelationshipName)); } else { bool flag = true; if (!this._relationship.TryGetEnd(this._unresolvedFromEndRole, out this._fromEnd)) { this.AddError(ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error, (object)Strings.BadNavigationPropertyUndefinedRole((object)this._unresolvedFromEndRole, (object)this._relationship.FQName)); flag = false; } if (!this._relationship.TryGetEnd(this._unresolvedToEndRole, out this._toEnd)) { this.AddError(ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error, (object)Strings.BadNavigationPropertyUndefinedRole((object)this._unresolvedToEndRole, (object)this._relationship.FQName)); flag = false; } if (!flag || this._fromEnd != this._toEnd) { return; } this.AddError(ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error, (object)Strings.BadNavigationPropertyRolesCannotBeTheSame); } }
public CompendiumTransclusionRelationship(IRelationship relationship, CompendiumViewRelationship viewRelationship, INode toNode, INode fromNode, INode transclusionNode, INode mapNode) : this() { _toNode = toNode; IDescriptor toDescriptor = new CompendiumRelationshipDescriptor(toNode, this, IoCContainer.GetInjectionInstance().GetInstance<CompendiumToDescriptor>()); _descriptors.Add(toDescriptor); _toNode.AddDescriptor(toDescriptor); _fromNode = fromNode; IDescriptor fromDescriptor = new CompendiumRelationshipDescriptor(fromNode, this, IoCContainer.GetInjectionInstance().GetInstance<CompendiumFromDescriptor>()); _descriptors.Add(fromDescriptor); _fromNode.AddDescriptor(fromDescriptor); _transclusionNode = transclusionNode; IDescriptor transclusionNodeDescriptor = new CompendiumRelationshipDescriptor(transclusionNode, this, IoCContainer.GetInjectionInstance().GetInstance<CompendiumTransclusionNodeDescriptor>()); _descriptors.Add(transclusionNodeDescriptor); _transclusionNode.AddDescriptor(transclusionNodeDescriptor); _mapNode = mapNode; IDescriptor mapDescriptor = new CompendiumRelationshipDescriptor(mapNode, this, IoCContainer.GetInjectionInstance().GetInstance<CompendiumTransclusionMapDescriptor>()); _descriptors.Add(mapDescriptor); _mapNode.AddDescriptor(mapDescriptor); this.Id = relationship.Id; this.Created = relationship.Created; this.CreatedBy = relationship.CreatedBy; this.LastModified = relationship.LastModified; this.Name = relationship.Name; this.XPosition = viewRelationship.XPosition; this.YPosition = viewRelationship.YPosition; }
public IRelationship GetBestRelationship( Guid speaker, Guid listener, IEnumerable <string> tags = null) { Guid[] participants = { speaker, listener }; IEnumerable <IRelationship> relationships = this.Get(participants, tags, false); int highestValue = int.MinValue; IRelationship bestMatch = null; foreach (IRelationship relationship in relationships) { int value = relationship.GetRelationshipValue(speaker, listener); if (value > highestValue) { highestValue = value; bestMatch = relationship; } } if (bestMatch is null) { throw new InvalidOperationException("No relationship between " + speaker + " and " + listener + "."); } return(bestMatch); }
public void Test_IsDeletable_WhenDeleteAction_EQ_DeleteRelated_WhenHasRelatedObject_ShouldBeTrue() { //---------------Set up test pack------------------- BORegistry.DataAccessor = new DataAccessorInMemory(); ClassDef.ClassDefs.Clear(); IClassDef classDef = MyBO.LoadClassDefWithRelationship(); MyRelatedBo.LoadClassDef(); MyBO bo = (MyBO)classDef.CreateNewBusinessObject(); bo.Save(); IRelationship relationship = bo.Relationships["MyMultipleRelationship"]; SetDeleteRelatedAction(relationship, DeleteParentAction.DeleteRelated); bo.MyMultipleRelationship.CreateBusinessObject(); //---------------Assert Precondition---------------- Assert.IsFalse(bo.Status.IsDeleted); Assert.AreEqual(1, bo.MyMultipleRelationship.Count); Assert.AreEqual(DeleteParentAction.DeleteRelated, relationship.DeleteParentAction); //---------------Execute Test ---------------------- string message; bool isDeletable = relationship.IsDeletable(out message); //---------------Test Result ----------------------- Assert.IsTrue(isDeletable); }
private ITreeNode SetupRelationshipNode(IRelationship relationship, ITreeNodeCollection nodes) { bool isNewColTag = !RelationshipNodes.ContainsKey(relationship); ITreeNode node; NodeState nodeState; if (isNewColTag) { node = nodes.Add(""); node.Collapse(false); if (_levelsToDisplay > -1 && node.Level > _levelsToDisplay) { nodes.Remove(node); return(null); } nodeState = new NodeState(node); RelationshipNodes.Add(relationship, nodeState); SetupRelationshipNodeDummy(relationship, nodeState); } else { nodeState = RelationshipNodes[relationship]; node = nodeState.Node; } DoSetupNodeWithRelationship(node, relationship); node.Tag = relationship; return(node); }
public virtual void Update(string name, string value, INode node, IRelationship relationship, ConnectionType connectionType, ref TransactionChain chain) { if (name != null) { Name = name; } if (value != null) { Value = value; } if (node != null) { Node = node; } if (relationship != null) { Relationship = relationship; } if (connectionType != null) { ConnectionType = connectionType; } }
private void RemoveBusinessObjectNode(IBusinessObject businessObject) { if (businessObject != null && ObjectNodes.ContainsKey(businessObject)) { NodeState nodeState = ObjectNodes[businessObject]; ITreeNode node = nodeState.Node; ITreeNode parentNode = node.Parent; RemoveNode(businessObject, node); IDictionary <string, IRelationship> relationships = GetVisibleRelationships(businessObject); foreach (KeyValuePair <string, IRelationship> relationshipPair in relationships) { IRelationship relationship = relationshipPair.Value; RemoveRelationshipNode(relationship); } if (parentNode != null) { IBusinessObjectCollection businessObjectCollection = parentNode.Tag as IBusinessObjectCollection; if (businessObjectCollection != null) { UpdateNodeDummy(nodeState, businessObjectCollection.Count); } } } }
public void Relationship_Can_Recreate_Id() { IRelationship createdRelationship = Relate <Person, PersonDto>(); IRelationship recreatedRelationship = Relate <Person, PersonDto>(); Assert.AreEqual(createdRelationship.Id, recreatedRelationship.Id); }
protected void CalculateListenerInfo() { try { IEnumerable <IRelationship> relationships = this.RelationshipHandler.Get(new[] { this.Instigator.Guid, this.Listener.Guid }); IRelationship chosenRelationship = null; int best = Int32.MinValue; foreach (IRelationship relationship in relationships) { if (relationship.HasTag("romantic")) { chosenRelationship = relationship; break; } int value = relationship.GetRelationshipValue(this.Instigator.Guid, this.Listener.Guid); if (value > best) { best = value; chosenRelationship = relationship; } } this.ListenerInfo = this.Listener.JoyName + ", " + chosenRelationship?.DisplayName; } catch (Exception e) { this.ListenerInfo = this.Listener.JoyName + ", acquaintance."; } }
/// <summary> /// Executes the specified relationship AU. /// </summary> /// <param name="pRelationship">The relationship.</param> /// <param name="mode">The AU mode.</param> /// <param name="eEvent">The edit event.</param> public void Execute(IRelationship pRelationship, mmAutoUpdaterMode mode, mmEditEvent eEvent) { try { if (InoperableAutoUpdaters.Instance.Contains(pRelationship.RelationshipClass.RelationshipClassID, -1, this.GetType())) { return; } if (this.CanExecute(mode)) { this.InternalExecute(pRelationship, mode, eEvent); } } catch (COMException e) { // If the MM_E_CANCELEDIT error is thrown, let it out. if (e.ErrorCode == (int)mmErrorCodes.MM_E_CANCELEDIT) { throw; } this.WriteError(e); } catch (Exception e) { this.WriteError(e); } }
public void Create(IRelationship Relationship, ITransaction Transaction) { Relationship thisrel = new Relationship(this, Relationship); this.AddItemToCache(thisrel); ((Transaction)Transaction).AddItem(thisrel); }
/// <summary> /// Adds the given relationship to this node. /// </summary> /// <param name="relationship">The relationship to add</param> /// <param name="relatedNode">The related node</param> public void AddRelationship(IRelationship relationship, INode relatedNode) { NodeContentType relatedType; Guid relatedId; if (Guid.TryParse(relatedNode["id"].As <string>(), out relatedId) && Enum.TryParse <NodeContentType>(relatedNode.Labels[0], out relatedType)) { // Create the relationship RelationshipModel relModel = new RelationshipModel { SourceId = Id, TargetId = relatedId, TargetName = relatedNode["commonName"].As <string>(), Roles = relationship["roles"].As <List <string> >() }; // Add the relationship to the correct list if (relatedType == NodeContentType.Company) { RelatedCompanies.Add(relModel); } else if (relatedType == NodeContentType.Media) { RelatedMedia.Add(relModel); } else if (relatedType == NodeContentType.Person) { RelatedPeople.Add(relModel); } } }
public void Relationship_CanCreate() { IRelationship relationship = Relate <Person, PersonDto>(); var actual = RelationshipValidator.IsValid(relationship); Assert.AreEqual(true, actual); }
public CompendiumTransclusionRelationship(IRelationship relationship, CompendiumViewRelationship viewRelationship, INode toNode, INode fromNode, INode transclusionNode, INode mapNode) : this() { _toNode = toNode; IDescriptor toDescriptor = new CompendiumRelationshipDescriptor(toNode, this, IoCContainer.GetInjectionInstance().GetInstance <CompendiumToDescriptor>()); _descriptors.Add(toDescriptor); _toNode.AddDescriptor(toDescriptor); _fromNode = fromNode; IDescriptor fromDescriptor = new CompendiumRelationshipDescriptor(fromNode, this, IoCContainer.GetInjectionInstance().GetInstance <CompendiumFromDescriptor>()); _descriptors.Add(fromDescriptor); _fromNode.AddDescriptor(fromDescriptor); _transclusionNode = transclusionNode; IDescriptor transclusionNodeDescriptor = new CompendiumRelationshipDescriptor(transclusionNode, this, IoCContainer.GetInjectionInstance().GetInstance <CompendiumTransclusionNodeDescriptor>()); _descriptors.Add(transclusionNodeDescriptor); _transclusionNode.AddDescriptor(transclusionNodeDescriptor); _mapNode = mapNode; IDescriptor mapDescriptor = new CompendiumRelationshipDescriptor(mapNode, this, IoCContainer.GetInjectionInstance().GetInstance <CompendiumTransclusionMapDescriptor>()); _descriptors.Add(mapDescriptor); _mapNode.AddDescriptor(mapDescriptor); this.Id = relationship.Id; this.Created = relationship.Created; this.CreatedBy = relationship.CreatedBy; this.LastModified = relationship.LastModified; this.Name = relationship.Name; this.XPosition = viewRelationship.XPosition; this.YPosition = viewRelationship.YPosition; }
/// <summary> /// Used during the resolve phase to resolve the type name to the object that represents that type /// </summary> internal override void ResolveTopLevelNames() { base.ResolveTopLevelNames(); if (_relationship == null) { SchemaType element; if (!Schema.ResolveTypeName(this, _unresolvedRelationshipTypeName, out element)) { return; } _relationship = element as IRelationship; if (_relationship == null) { AddError( ErrorCode.InvalidPropertyType, EdmSchemaErrorSeverity.Error, Strings.InvalidRelationshipSetType(element.Name)); return; } } foreach (var end in Ends) { end.ResolveTopLevelNames(); } }
internal override void ResolveSecondLevelNames() { base.ResolveSecondLevelNames(); if (_unresolvedRelationshipEndRole == null && EntitySet != null) { // no role provided, infer it RelationshipEnd = InferRelationshipEnd(EntitySet); if (RelationshipEnd != null) { _unresolvedRelationshipEndRole = RelationshipEnd.Name; } } else if (_unresolvedRelationshipEndRole != null) { IRelationship relationship = ParentElement.Relationship; IRelationshipEnd end; if (relationship.TryGetEnd(_unresolvedRelationshipEndRole, out end)) { RelationshipEnd = end; } else { // couldn't find a matching relationship end for this RelationshipSet end AddError(ErrorCode.InvalidContainerTypeForEnd, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.InvalidEntityEndName(Role, relationship.FQName)); } } }
/// <summary> /// Implementation of execute method for derived classes. /// </summary> /// <param name="relationship">The relationship.</param> /// <param name="mode">The mode.</param> /// <param name="editEvent">The edit event.</param> /// <remarks> /// This method will be called from IMMRelationshipAUStrategy::Execute /// and is wrapped within the exception handling for that method. /// </remarks> protected override void InternalExecute(IRelationship relationship, mmAutoUpdaterMode mode, mmEditEvent editEvent) { foreach (IMMRelationshipAUStrategy item in this.Items) { item.Execute(relationship, mode, editEvent); } }
public void Test_MarkForDelete_WhenMultiple_WhenDerefenceRelated_WhenHasRelatedBO_ShouldDoNothing() { //---------------Set up test pack------------------- BORegistry.DataAccessor = new DataAccessorInMemory(); ClassDef.ClassDefs.Clear(); IClassDef classDef = MyBO.LoadClassDefWithRelationship(); MyRelatedBo.LoadClassDef(); MyBO bo = (MyBO)classDef.CreateNewBusinessObject(); bo.Save(); ReflectionUtilities.SetPropertyValue(bo.Status, "IsDeleted", true); MyRelatedBo myRelatedBO = bo.MyMultipleRelationship.CreateBusinessObject(); IRelationship relationship = bo.Relationships["MyMultipleRelationship"]; ((RelationshipDef)relationship.RelationshipDef).DeleteParentAction = DeleteParentAction.DereferenceRelated; //---------------Assert Precondition---------------- Assert.IsTrue(bo.Status.IsDeleted); Assert.IsFalse(myRelatedBO.Status.IsDeleted); Assert.AreEqual(1, bo.MyMultipleRelationship.Count); Assert.AreEqual(DeleteParentAction.DereferenceRelated, relationship.DeleteParentAction); //---------------Execute Test ---------------------- relationship.MarkForDelete(); //---------------Test Result ----------------------- Assert.IsTrue(bo.Status.IsDeleted); Assert.IsFalse(myRelatedBO.Status.IsDeleted); }
static void GenerateRelationship(StringBuilder b, int indent, IRelationship relationship) { var indentString = new string(' ', indent); b.AppendLine(indentString + "{"); b.AppendLine(indentString + " id: " + relationship.Id.ToString() + ","); b.AppendLine(indentString + " type: " + relationship.Type + ","); b.AppendLine(indentString + " start: " + relationship.StartNodeId.ToString() + ", "); b.AppendLine(indentString + " end: " + relationship.EndNodeId.ToString() + ", "); b.AppendLine(indentString + " properties: {"); var first = true; foreach (var prop in relationship.Properties.OrderBy(p => p.Key)) { if (!first) { b.AppendLine(","); } else { first = false; } b.Append(indentString + " " + prop.Key + ": " + prop.Value.ToString()); } b.AppendLine(); b.AppendLine(indentString + " }"); }
/// <summary> /// Creates a <see cref="RelatedBusinessObjectCollection{TBusinessObject}"/> with boType as its type parameter, using the Activator. /// </summary> /// <param name="boType">The type parameter to be used</param> /// <param name="relationship">The relationship that this <see cref="RelatedBusinessObjectCollection{TBusinessObject}"/> is the collection for</param> /// <returns>The instantiated <see cref="RelatedBusinessObjectCollection{TBusinessObject}"/></returns> private static IBusinessObjectCollection CreateNewRelatedBusinessObjectCollection(Type boType, IRelationship relationship) { // Utilities.CheckTypeCanBeCreated(boType); Type relatedCollectionType = typeof(RelatedBusinessObjectCollection<>); relatedCollectionType = relatedCollectionType.MakeGenericType(boType); IBusinessObjectCollection collection = (IBusinessObjectCollection)Activator.CreateInstance(relatedCollectionType, relationship); return collection; }
public GlymaRelationship(IRelationship relationship) { _relationship = relationship; ///TODO: Need to get the actual value from the server Created = "1380778119656"; LastModified = "1380778119656"; }
public void Apply(IRelationship relationship) { var conventions = conventionFinder.Find<IHasOneConvention>(); var oneToOne = (IOneToOnePart)relationship; foreach (var convention in conventions) { if (convention.Accept(oneToOne)) convention.Apply(oneToOne); } }
public void Apply(IRelationship relationship) { var conventions = conventionFinder.Find<IReferenceConvention>(); var manyToOne = (IManyToOnePart)relationship; foreach (var convention in conventions) { if (convention.Accept(manyToOne)) convention.Apply(manyToOne); } }
public void Apply(IRelationship relationship) { var conventions = conventionFinder.Find<IHasManyToManyConvention>(); var manyToMany = (IManyToManyPart)relationship; foreach (var convention in conventions) { if (convention.Accept(manyToMany)) convention.Apply(manyToMany); } }
/// <summary> /// Shows the form as a dialog with the specified database table. /// </summary> /// <param name="owner">The owner window.</param> /// <param name="server">The database server.</param> /// <param name="table">The database relationship.</param> /// <returns>The dialog result.</returns> public DialogResult ShowDialog(IWin32Window owner, DbServerSql server, IRelationship relationship) { // If the table is null, do nothing. if (null == relationship) return DialogResult.Abort; // Set the control relationsip. this.control.Relationship = relationship; // Set the form title. this.Text = "{0} Relationship Properties".FormatWith(this.control.Title); // Disable the apply button. this.buttonApply.Enabled = false; // Open the dialog. return base.ShowDialog(owner); }
protected override void OnNodeFound(INode node, IRelationship relationship) { var glymaNode = new CompendiumNode(relationship, node); CompendiumXmlMap.AddView(Map.Id, glymaNode); CompendiumXmlMap.AddNode(glymaNode); if (glymaNode.ReferenceNode != null) { CompendiumXmlMap.AddView(Map.Id, glymaNode.ReferenceNode); CompendiumXmlMap.AddNode(glymaNode.ReferenceNode); CompendiumXmlMap.AddReferenceLink(Map.Id, glymaNode.ReferenceNode, glymaNode); } }
public override void Update(string name, string value, INode node, IRelationship relationship, ConnectionType connectionType, ref TransactionChain chain) { base.Update(name, value, node, relationship, connectionType, ref chain); DelayedMetadataAction delayedAction = new DelayedMetadataAction(); delayedAction.Action = TransactionActionType.Updated; delayedAction.Name = name; delayedAction.Value = value; delayedAction.Node = node; delayedAction.Relationship = relationship; delayedAction.ConnectionType = connectionType; DelayedActions.Enqueue(delayedAction); }
public SoapMetadataSet(IMapManager mapManager, ServerObjects.Metadata serviceMetadata, INode node, IRelationship relationship) { MapManager = mapManager; ServiceMetadata = serviceMetadata; Id = serviceMetadata.MetadataId; DomainId = serviceMetadata.DomainUid; RootMapId = serviceMetadata.RootMapUid; Name = serviceMetadata.MetadataName; Value = serviceMetadata.MetadataValue; if (serviceMetadata.NodeUid.HasValue && serviceMetadata.NodeUid == node.Id) { Node = node; } else if (serviceMetadata.NodeUid.HasValue && serviceMetadata.NodeUid != node.Id) { throw new NotSupportedException("The node ID in the service metadata object differs to the provided node."); } else { Node = null; } if (serviceMetadata.RelationshipUid.HasValue && serviceMetadata.RelationshipUid == relationship.Id) { Relationship = relationship; } else if (serviceMetadata.RelationshipUid.HasValue && serviceMetadata.RelationshipUid != relationship.Id) { throw new NotSupportedException("The relationship ID in the service metadata object differs to the provided relationship."); } else { Relationship = null; } ConnectionType = null; if (serviceMetadata.DescriptorTypeUid.HasValue && serviceMetadata.DescriptorTypeUid != Guid.Empty) { if (MapManager.ConnectionTypes.ContainsKey(serviceMetadata.DescriptorTypeUid.Value)) { ConnectionType = MapManager.ConnectionTypes[serviceMetadata.DescriptorTypeUid.Value]; } } }
void IRelationshipManager.Remove(IRelationship relationship) { IEnumerable<ConnectionSet> relationshipTuples = from relationshipPair in Connections where relationshipPair.Relationship == relationship select relationshipPair; List<ConnectionSet> tuplesToDelete = new List<ConnectionSet>(); foreach (ConnectionSet relationshipTuple in relationshipTuples) { tuplesToDelete.Add(relationshipTuple); } foreach (ConnectionSet relationshipTuple in tuplesToDelete) { Connections.Remove(relationshipTuple); } }
private bool AreRelationshipsEqual(IRelationship relationship, IMetadataSet metadataSet) { if (metadataSet == null) { return false; } if (relationship == null && metadataSet.Relationship == null) { return true; } if (relationship != null && metadataSet.Relationship != null && relationship.Id == metadataSet.Relationship.Id) { return true; } return false; }
public IMetadataSet Load(ServerObjects.Metadata serviceMetadata, IRelationship relationship) { IMetadataSet metadataSet = MetadataSetFactory.GetInstance(MapManager).GetMetadata(serviceMetadata, Parent, relationship); if (!ContainedMetadata.Contains(metadataSet.Id)) { Metadata.Add(metadataSet); ContainedMetadata.Add(metadataSet.Id); } IMetadataSetManager metadataSetManager = metadataSet as IMetadataSetManager; if (metadataSetManager != null) { metadataSetManager.Container = this; } return metadataSet; }
//public IMetadataSet GetMetadata(Guid metadataId) //{ // if (Metadata.ContainsKey(metadataId)) // { // return Metadata[metadataId]; // } // return null; //} public IMetadataSet GetMetadata(ServerObjects.Metadata serviceMetadata, INode node, IRelationship relationship) { IMetadataSet metadataSet = null; if (Metadata.ContainsKey(serviceMetadata.MetadataId)) { metadataSet = Metadata[serviceMetadata.MetadataId]; if (metadataSet is IUpdatableMetadataSet) { IUpdatableMetadataSet updatableMetadataSet = metadataSet as IUpdatableMetadataSet; updatableMetadataSet.UpdateMetadataSet(serviceMetadata); } } else { metadataSet = new Soap.SoapMetadataSet(MapManager, serviceMetadata, node, relationship); Metadata[metadataSet.Id] = metadataSet; } return metadataSet; }
/// <summary> /// </summary> internal override void ResolveTopLevelNames() { base.ResolveTopLevelNames(); SchemaType element; if (!Schema.ResolveTypeName(this, _unresolvedRelationshipName, out element)) { return; } _relationship = element as IRelationship; if (_relationship == null) { AddError( ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error, Strings.BadNavigationPropertyRelationshipNotRelationship(_unresolvedRelationshipName)); return; } var foundBothEnds = true; if (!_relationship.TryGetEnd(_unresolvedFromEndRole, out _fromEnd)) { AddError( ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error, Strings.BadNavigationPropertyUndefinedRole(_unresolvedFromEndRole, _relationship.FQName)); foundBothEnds = false; } if (!_relationship.TryGetEnd(_unresolvedToEndRole, out _toEnd)) { AddError( ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error, Strings.BadNavigationPropertyUndefinedRole(_unresolvedToEndRole, _relationship.FQName)); foundBothEnds = false; } if (foundBothEnds && _fromEnd == _toEnd) { AddError( ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error, Strings.BadNavigationPropertyRolesCannotBeTheSame); } }
protected override void OnNodeFound(INode node, IRelationship relationship) { var glymaNode = new GlymaNode(relationship, node); GlymaMap.AddNode(glymaNode); }
protected static string GetEntityName(IRelationship relationship, Mappings mappings) { string entityName = string.IsNullOrEmpty(relationship.EntityName) ? null : relationship.EntityName; string className = string.IsNullOrEmpty(relationship.Class) ? null : relationship.Class; entityName = entityName ?? (className == null ? null : StringHelper.GetFullClassname(FullQualifiedClassName(className, mappings))); return entityName; }
public IMetadataSet GetMetadata(TransactionFramework.ISoapTransactionLink link, Guid domainId, Guid rootMapId, string name, string value, INode node, IRelationship relationship, ConnectionType connectionType) { /// Return a FacadeNode containing an InProcessMetadataSet InProcess.InProcessMetadata newMetadataSet = new InProcess.InProcessMetadata(MapManager); newMetadataSet.OriginLink = link; newMetadataSet.Id = Guid.Empty; newMetadataSet.DomainId = domainId; newMetadataSet.RootMapId = rootMapId; newMetadataSet.Name = name; newMetadataSet.Value = value; newMetadataSet.Node = node; newMetadataSet.Relationship = relationship; newMetadataSet.ConnectionType = connectionType; FacadeMetadataSet facadeMetadataSet = new FacadeMetadataSet(); facadeMetadataSet.BaseMetadata = newMetadataSet; newMetadataSet.Facade = facadeMetadataSet; InProcessMetadata[link] = facadeMetadataSet; return facadeMetadataSet; }
public IRelationship CreateInProcessObjects() { if (_inProcessResponse == null) { _inProcessResponse = MapManager.RelationshipFactory.CreateRelationship(this, DomainParameter.GetParameterValue(Guid.Empty).V, RootMapParameter.GetParameterValue(Guid.Empty).V, ProxyNodeConnections, RelationshipType, OriginalId); TransactionStatus = ServerStatus.ProcessingClient; FacadeRelationship facadeRelationship = _inProcessResponse as FacadeRelationship; if (facadeRelationship != null) { facadeRelationship.TransactionOrigin = this; _inProcessResponse = facadeRelationship; } } return _inProcessResponse; }
private void AddRelationshipNode(ITreeNodeCollection nodes, IRelationship relationship) { ITreeNode newNode = SetupNode(nodes, relationship); if (newNode == null) return; if (newNode.IsExpanded) { LoadRelationshipNode(relationship, newNode.Nodes); } }
private ITreeNode SetupRelationshipNode(IRelationship relationship, ITreeNodeCollection nodes) { bool isNewColTag = !RelationshipNodes.ContainsKey(relationship); ITreeNode node; NodeState nodeState; if (isNewColTag) { node = nodes.Add(""); node.Collapse(false); if (_levelsToDisplay > -1 && node.Level > _levelsToDisplay) { nodes.Remove(node); return null; } nodeState = new NodeState(node); RelationshipNodes.Add(relationship, nodeState); SetupRelationshipNodeDummy(relationship, nodeState); } else { nodeState = RelationshipNodes[relationship]; node = nodeState.Node; } DoSetupNodeWithRelationship(node, relationship); node.Tag = relationship; return node; }
private void SetupRelationshipNodeDummy(IRelationship relationship, NodeState nodeState) { int childCount = 0; if (relationship is IMultipleRelationship) { IMultipleRelationship multipleRelationship = (IMultipleRelationship)relationship; IBusinessObjectCollection businessObjectCollection = multipleRelationship.BusinessObjectCollection; ChildCollectionNodes.Add(businessObjectCollection, nodeState); RegisterForBusinessObjectCollectionEvents(businessObjectCollection); childCount = businessObjectCollection.Count; } else { //TODO: Do something decent with Single Relationship Updated Event ISingleRelationship singleRelationship = (ISingleRelationship)relationship; if (singleRelationship.HasRelatedObject()) { childCount = 1; } } UpdateNodeDummy(nodeState, childCount); }
private void DoSetupNodeWithRelationship(ITreeNode node, IRelationship relationship) { node.Text = GetRelationshipDescription(relationship); if (SetupNodeWithRelationship != null) { SetupNodeWithRelationship(node, relationship); } }
public GlymaNode(IRelationship relationship, INode node) { Relationship = relationship; Proxy = node; double x, y; if (!double.TryParse(FindRelationshipBindedMetadata("XPosition"), out x)) { x = 0; } XPosition = x; if (!double.TryParse(FindRelationshipBindedMetadata("YPosition"), out y)) { y = 0; } YPosition = y; NodeVideo = new NodeVideo(FindMetadata("Video.Source"), FindMetadata("Video.StartPosition"), FindMetadata("Video.EndPosition")); if (FindMetadata("DescriptionType") != string.Empty) { NodeDescription = new NodeDescription(FindMetadata("DescriptionType"), FindMetadata("Description")); } else if (FindMetadata("Description.Type") != string.Empty) { NodeDescription = new NodeDescription(FindMetadata("Description.Type"), FindMetadata("Description.Content"), FindMetadata("Description.Url")); } else { NodeDescription = new NodeDescription(null, null); } }
private void RemoveRelationshipNode(IRelationship relationship) { this.RelationshipNodes.Remove(relationship); if (relationship is IMultipleRelationship) { IMultipleRelationship multipleRelationship = (IMultipleRelationship)relationship; IBusinessObjectCollection children = multipleRelationship.BusinessObjectCollection; ChildCollectionNodes.Remove(children); foreach (IBusinessObject businessObject in children.Clone()) { RemoveBusinessObjectNode(businessObject); } } else { ISingleRelationship singleRelationship = (ISingleRelationship)relationship; IBusinessObject businessObject = singleRelationship.GetRelatedObject(); if (businessObject != null) { RemoveBusinessObjectNode(businessObject); } } }
protected override void OnRelationshipFound(IRelationship relationship) { GlymaMap.AddRelationship(new GlymaRelationship(relationship)); }