コード例 #1
0
        static ReadOnlyCollection <Relation <T> > CreateRelation <T> (XmlReader reader) where T : MusicBrainzObject
        {
            List <Relation <T> > relations = new List <Relation <T> > ();

            while (reader.ReadToFollowing("relation"))
            {
                string            type             = reader ["type"];
                RelationDirection direction        = RelationDirection.Forward;
                string            direction_string = reader ["direction"];
                if (direction_string != null && direction_string == "backward")
                {
                    direction = RelationDirection.Backward;
                }
                string    begin             = reader ["begin"];
                string    end               = reader ["end"];
                string    attributes_string = reader ["attributes"];
                string [] attributes        = attributes_string == null
                    ? null : attributes_string.Split(' ');

                reader.Read();
                relations.Add(new Relation <T> (
                                  type,
                                  ConstructMusicBrainzObjectFromXml <T> (reader.ReadSubtree()),
                                  direction,
                                  begin,
                                  end,
                                  attributes));
            }
            reader.Close();
            return(relations.AsReadOnly());
        }
コード例 #2
0
ファイル: IntTblWiz2.cs プロジェクト: mirkomaty/NDO
        private void IntTblWiz2_Load(object sender, System.EventArgs e)
        {
            Frame.Description = "Choose, if the relation is directed or bidirectional.";

            RelatedTableInfo rti1 = model.IntermediateTableNode.IntermediateTable[0];
            RelatedTableInfo rti2 = model.IntermediateTableNode.IntermediateTable[1];

            RelationDirection dir = rti1.RelationDirection;

            if (dir == RelationDirection.Bidirectional)
            {
                radioBi.Checked = true;
            }
            else if (dir == RelationDirection.DirectedFromMe)
            {
                radioFromMe.Checked = true;
            }
            else
            {
                radioToMe.Checked = true;
            }
            this.lblBi.Text     = rti1.Table + " <-> " + rti2.Table;
            this.lblFromMe.Text = rti1.Table + " -> " + rti2.Table;
            this.lblToMe.Text   = rti1.Table + " <- " + rti2.Table;

            // This would be the right view to specify a relation name.
            // But we don't implement it, because it doesn't make much sense,
            // as long as a mapping table can't be mapped twice.
        }
コード例 #3
0
        static ReadOnlyCollection <UrlRelation> CreateUrlRelation(XmlReader reader)
        {
            List <UrlRelation> url_rels = new List <UrlRelation> ();

            while (reader.ReadToDescendant("relation"))
            {
                RelationDirection direction        = RelationDirection.Forward;
                string            direction_string = reader["direction"];
                if (direction_string != null && direction_string == "backward")
                {
                    direction = RelationDirection.Backward;
                }
                string   attributes_string = reader["attributes"];
                string[] attributes        = attributes_string == null
                    ? null : attributes_string.Split(' ');
                url_rels.Add(new UrlRelation(
                                 reader["type"],
                                 reader["target"],
                                 direction,
                                 reader["begin"],
                                 reader["end"],
                                 attributes));
            }
            return(url_rels.AsReadOnly());
        }
コード例 #4
0
ファイル: SubGraphs.cs プロジェクト: BHoM/BHoM_Engine
        public static List <Graph> SubGraphs(this Graph graph, RelationDirection relationDirection = RelationDirection.Forwards)
        {
            if (graph == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Cannot query the sub graphs of a null graph.");
                return(new List <Graph>());
            }

            List <Graph> subGraphs = new List <Graph>();

            m_Adjacency      = graph.Adjacency(relationDirection);
            m_MarkedEntity   = new Dictionary <Guid, int>();
            m_MarkedRelation = new Dictionary <Guid, int>();
            m_SubNumber      = 0;
            graph.Entities.Keys.ToList().ForEach(entity => m_MarkedEntity[entity] = -1);
            graph.Relations.ForEach(rel => m_MarkedRelation[rel.BHoM_Guid]        = -1);
            Random random = new Random();

            while (m_MarkedEntity.ContainsValue(-1))
            {
                List <Guid> entitys = m_MarkedEntity.Where(pair => pair.Value == -1)
                                      .Select(pair => pair.Key).ToList();
                //random start entity
                Guid start = entitys[random.Next(0, entitys.Count)];

                graph.Traverse(start);

                subGraphs.Add(graph.SetSubGraph());

                m_SubNumber++;
            }

            return(subGraphs);
        }
コード例 #5
0
 public void SetRelation(IClassifiable relatable, IClassifiable related, RelationDirection direction = RelationDirection.Undefined, TaxonomyNode type = null)
 {
     foreach (var relEntity in relationRepo.GetRelated(relatable, direction, type == null ? null : type.entity))
     {
         relationRepo.Delete(relEntity);
     }
     RelateInternal(relatable, related, direction, type);
 }
コード例 #6
0
ファイル: Relation.cs プロジェクト: thoja21/banshee-1
 internal Relation(string type,
                   T target,
                   RelationDirection direction,
                   string begin,
                   string end,
                   string [] attributes)
     : base(type, target, direction, begin, end, attributes)
 {
 }
コード例 #7
0
ファイル: Relation.cs プロジェクト: thoja21/banshee-1
 internal UrlRelation(string type,
                      string target,
                      RelationDirection direction,
                      string begin,
                      string end,
                      string [] attributes)
     : base(type, new Uri(target), direction, begin, end, attributes)
 {
 }
コード例 #8
0
 public virtual void FromXml(XmlElement element)
 {
     this.codingStyle          = (CodingStyle)Enum.Parse(typeof(CodingStyle), element.Attributes["CodingStyle"].Value);
     this.ownFieldName         = element.Attributes["OwnFieldName"].Value;
     this.foreignFieldName     = element.Attributes["ForeignFieldName"].Value;
     this.foreignKeyColumnName = element.Attributes["ForeignKeyColumnName"].Value;
     this.relationDirection    = (RelationDirection)Enum.Parse(typeof(RelationDirection), element.Attributes["RelationDirection"].Value);
     this.table = element.Attributes["Table"].Value;
     this.type  = element.Attributes["RelationType"].Value;
 }
コード例 #9
0
ファイル: Relation.cs プロジェクト: thoja21/banshee-1
 internal RelationBase(string type, T target, RelationDirection direction,
                       string begin, string end, string [] attributes)
 {
     this.type       = type;
     this.target     = target;
     this.direction  = direction;
     this.begin      = begin;
     this.end        = end;
     this.attributes = new ReadOnlyCollection <string> (attributes ?? new string [0]);
 }
コード例 #10
0
ファイル: FkRelation.cs プロジェクト: mirkomaty/NDO
 public static RelationDirection Reverse(RelationDirection dir)
 {
     if (dir == RelationDirection.Bidirectional)
     {
         return(dir);
     }
     return((dir == RelationDirection.DirectedFromMe)
                         ? RelationDirection.DirectedToMe
                         : RelationDirection.DirectedFromMe);
 }
コード例 #11
0
ファイル: IntermediateTable.cs プロジェクト: mirkomaty/NDO
 public virtual void FromXml(XmlElement element)
 {
     this.CodingStyle          = (CodingStyle)CodingStyle.Parse(typeof(CodingStyle), element.Attributes["CodingStyle"].Value);
     this.fieldName            = element.Attributes["FieldName"].Value;
     this.table                = element.Attributes["Table"].Value;
     this.foreignKeyColumnName = element.Attributes["ForeignKeyColumnName"].Value;
     this.isComposite          = bool.Parse(element.Attributes["IsComposite"].Value);
     this.isElement            = bool.Parse(element.Attributes["IsElement"].Value);
     this.relationDirection    = (RelationDirection)RelationDirection.Parse(typeof(RelationDirection), element.Attributes["RelationDirection"].Value);
     this.type = element.Attributes["RelationType"].Value;
 }
コード例 #12
0
ファイル: UserPositionVM.cs プロジェクト: T1Easyware/Soheil
 /// <summary>
 /// Initializes a new instance of the <see cref="ProductVM"/> class from the model.
 /// </summary>
 /// <param name="entity">The model.</param>
 /// <param name="access"></param>
 /// <param name="presentationType"></param>
 public UserPositionVM(User_Position entity, AccessType access, RelationDirection presentationType):base(access, presentationType)
 {
     _model = entity;
     InitializeData();
     UserId = entity.User.Id;
     PositionId = entity.Position.Id;
     UserName = entity.User.Username;
     UserCode = entity.User.Code.ToString(CultureInfo.InvariantCulture);
     PositionName = entity.Position.Name;
     PositionCode = entity.Position.Id.ToString(CultureInfo.InvariantCulture);
 }
コード例 #13
0
ファイル: ProductReworkVM.cs プロジェクト: T1Easyware/Soheil
 /// <summary>
 /// Initializes a new instance of the <see cref="ProductVM"/> class from the model.
 /// </summary>
 /// <param name="entity">The model.</param>
 /// <param name="access"></param>
 /// <param name="dataService"></param>
 /// <param name="presentationType"></param>
 public ProductReworkVM(ProductRework entity, AccessType access, ProductReworkDataService dataService, RelationDirection presentationType):base(access, presentationType)
 {
     InitializeData(dataService);
     _model = entity;
     ProductId = entity.Product.Id;
     ReworkId = entity.Rework.Id;
     ProductName = entity.Product.Name;
     ProductCode = entity.Product.Code;
     ReworkName = entity.Rework.Name;
     ReworkCode = entity.Rework.Code;
 }
コード例 #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProductVM"/> class from the model.
 /// </summary>
 /// <param name="entity">The model.</param>
 /// <param name="access"></param>
 /// <param name="dataService"></param>
 /// <param name="presentationType"></param>
 public ProductDefectionVM(ProductDefection entity, AccessType access, ProductDefectionDataService dataService, RelationDirection presentationType):base(access, presentationType)
 {
     InitializeData(dataService);
     _model = entity;
     ProductId = entity.Product.Id;
     DefectionId = entity.Defection.Id;
     ProductName = entity.Product.Name;
     ProductCode = entity.Product.Code;
     DefectionName = entity.Defection.Name;
     DefectionCode = entity.Defection.Code;
 }
コード例 #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProductVM"/> class from the model.
 /// </summary>
 /// <param name="entity">The model.</param>
 /// <param name="access"></param>
 /// <param name="presentationType"></param>
 public ActionPlanFishboneVM(FishboneNode_ActionPlan entity, AccessType access,RelationDirection presentationType)
     : base(access, presentationType)
 {
     InitializeData();
     _model = entity;
     ActionPlanId = entity.ActionPlan.Id;
     RootId = entity.FishboneNode.Id;
     FishboneNodeId = entity.FishboneNode.Id;
     ActionPlanCode = entity.ActionPlan.Code;
     ActionPlanName = entity.ActionPlan.Name;
     FishboneNodeName = entity.FishboneNode.Description;
 }
コード例 #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProductVM"/> class from the model.
 /// </summary>
 /// <param name="entity">The model.</param>
 /// <param name="access"></param>
 /// <param name="presentationType"></param>
 public PositionAccessRuleVM(Position_AccessRule entity, AccessType access, RelationDirection presentationType):base(access, presentationType)
 {
     InitializeData();
     _model = entity;
     PositionId = entity.Position.Id;
     AccessRuleId = entity.AccessRule.Id;
     PositionName = entity.Position.Name;
     PositionCode = entity.Position.Id.ToString(CultureInfo.InvariantCulture);
     AccessRuleName = entity.AccessRule.Name;
     AccessRuleCode = entity.AccessRule.Code;
     if (entity.Type != null) Type = (AccessType)entity.Type;
 }
コード例 #17
0
ファイル: UserAccessRuleVM.cs プロジェクト: T1Easyware/Soheil
 /// <summary>
 /// Initializes a new instance of the <see cref="ProductVM"/> class from the model.
 /// </summary>
 /// <param name="entity">The model.</param>
 /// <param name="access"></param>
 /// <param name="presentationType"></param>
 public UserAccessRuleVM(User_AccessRule entity, AccessType access, RelationDirection presentationType):base(access, presentationType)
 {
     InitializeData();
     _model = entity;
     UserId = entity.User.Id;
     AccessRuleId = entity.AccessRule.Id;
     UserName = entity.User.Username;
     UserCode = entity.User.Code.ToString(CultureInfo.InvariantCulture);
     AccessRuleName = entity.AccessRule.Name;
     AccessRuleCode = entity.AccessRule.Code;
     if (entity.Type != null) Type = (AccessType) entity.Type;
 }
コード例 #18
0
 public static RelationEntity Create(IClassifiable relatable, IClassifiable related, TaxonEntity type = null, RelationDirection direction = RelationDirection.Undefined)
 {
     return new RelationEntity()
     {
         Type = type,
         Direction = direction,
         ObjectName = relatable.ObjectName,
         ObjectID = relatable.Id,
         RelatedObjectName = related.ObjectName,
         RelatedObjectID = related.Id,
     };
 }
コード例 #19
0
ファイル: ForeignFkRelation.cs プロジェクト: mirkomaty/NDO
        public override void FromXml(XmlElement element)
        {
            base.FromXml(element);
            this.CodingStyle       = (CodingStyle)CodingStyle.Parse(typeof(CodingStyle), element.Attributes["CodingStyle"].Value);
            this.fieldName         = element.Attributes["FieldName"].Value;
            this.isComposite       = bool.Parse(element.Attributes["IsComposite"].Value);
            this.relationDirection = (RelationDirection)RelationDirection.Parse(typeof(RelationDirection), element.Attributes["RelationDirection"].Value);
            XmlElement masterElement = (XmlElement)element.SelectSingleNode("Master");

            master = new FkRelation();
            master.FromXml(masterElement);
        }
コード例 #20
0
 public IList <RelationEntity> GetByRelated(IClassifiable classifiable, RelationDirection direction = RelationDirection.Undefined, TaxonEntity type = null)
 {
     if (classifiable == null)
     {
         log.Warn("GetByRelated null request");
         return(null);
     }
     using (var wu = SessionManager.WorkUnitFor(this, DbWorkUnitType.Read))
     {
         var criteria = CreateGetByRelatedCriteria(wu, classifiable, direction, type);
         return(criteria.List <RelationEntity>());
     }
 }
コード例 #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProductVM"/> class from the model.
 /// </summary>
 /// <param name="entity">The model.</param>
 /// <param name="access"></param>
 /// <param name="dataService"></param>
 /// <param name="presentationType"></param>
 public ActivityOperatorVM(ActivitySkill entity, AccessType access, ActivitySkillDataService dataService, RelationDirection presentationType)
     : base(access, presentationType)
 {
     InitializeData(dataService);
     _model = entity;
     ActivityId = entity.Activity.Id;
     OperatorId = entity.Operator.Id;
     ActivityName = entity.Activity.Name;
     ActivityCode = entity.Activity.Code;
     OperatorName = entity.Operator.Name;
     OperatorCode = entity.Operator.Code;
     //SkillPoint = (ILUO)entity.IluoNr;
 }
コード例 #22
0
ファイル: StationMachineVM.cs プロジェクト: T1Easyware/Soheil
        /// <summary>
        /// Initializes a new instance of the <see cref="StationVM"/> class from the model.
        /// </summary>
        /// <param name="entity">The model.</param>
        /// <param name="access"></param>
        /// <param name="presentationType"></param>
        public StationMachineVM(StationMachine entity, AccessType access, StationMachineDataService dataService, RelationDirection presentationType)
            : base(access,presentationType)
        {
            InitializeData(dataService);
            _model = entity;
            StationId = entity.Station.Id;
            MachineId = entity.Machine.Id;
			//Status = entity.RecordStatus;
            StationName = entity.Station.Name;
            StationCode = entity.Station.Code;
            MachineName = entity.Machine.Name;
            MachineCode = entity.Machine.Code;
        }
コード例 #23
0
 string DirectionToString(RelationDirection dir)
 {
     switch (dir)
     {
         case RelationDirection.Back:
             return "<--";
         case RelationDirection.Forward:
             return "-->";
         case RelationDirection.Both:
             return "<->";
         default:
             return ">-<";
     }
 }
コード例 #24
0
ファイル: FkRelation.cs プロジェクト: mirkomaty/NDO
 public override void FromXml(XmlElement element)
 {
     base.FromXml(element);
     this.CodingStyle        = (CodingStyle)CodingStyle.Parse(typeof(CodingStyle), element.Attributes["CodingStyle"].Value);
     this.fieldName          = element.Attributes["FieldName"].Value;
     this.foreignCodingStyle = (CodingStyle)CodingStyle.Parse(typeof(CodingStyle), element.Attributes["ForeignCodingStyle"].Value);
     this.foreignFieldName   = element.Attributes["ForeignFieldName"].Value;
     this.foreignIsComposite = bool.Parse(element.Attributes["ForeignIsComposite"].Value);
     this.isComposite        = bool.Parse(element.Attributes["IsComposite"].Value);
     this.name              = element.Attributes["Name"].Value;
     this.owningTable       = element.Attributes["OwningTable"].Value;
     this.relatedTable      = element.Attributes["RelatedTable"].Value;
     this.relationDirection = (RelationDirection)RelationDirection.Parse(typeof(RelationDirection), element.Attributes["RelationDirection"].Value);
     this.relationName      = element.Attributes["RelationName"].Value;
 }
コード例 #25
0
        protected override void SwitchToState(int newState, out ViewBase newView, out WizardState wizardState)
        {
            int oldState = this.State;
            IntermediateTableWizardModel model = (IntermediateTableWizardModel)this.Model;
            RelationDirection            dir   = model.IntermediateTableNode.IntermediateTable[0].RelationDirection;

            if (dir == RelationDirection.DirectedFromMe)
            {
                base.LastState = 2;
            }
            else
            {
                base.LastState = 3;
            }

            // State 2 is shared, state 3 is a dummy.
            // State 2: Index = 0
            // State 3: Index = 1
            if (newState == 2)             // means: State == 1
            {
                if (dir == RelationDirection.DirectedToMe)
                {
                    // Skip State 2, Index 0
                    model.Index    = 1;
                    base.LastState = 2;
                }
                else
                {
                    model.Index = 0;
                }
            }

            if (newState == 1 && State == 2 && model.Index == 1 && dir != RelationDirection.DirectedToMe)
            {
                newState    = 2;
                model.Index = 0;
            }

            if (newState == 3)
            {
// dir == RelationDirection.DirectedFromMe shouldn't occur
                newState       = 2;
                model.Index    = 1;
                base.LastState = 2;
            }
            base.SwitchToState(newState, out newView, out wizardState);
        }
コード例 #26
0
        string DirectionToString(RelationDirection dir)
        {
            switch (dir)
            {
            case RelationDirection.Back:
                return("<--");

            case RelationDirection.Forward:
                return("-->");

            case RelationDirection.Both:
                return("<->");

            default:
                return(">-<");
            }
        }
コード例 #27
0
 public IList <RelatedIdsResult> GetByRelatedIds(IClassifiable classifiable, RelationDirection direction = RelationDirection.Undefined, TaxonEntity type = null)
 {
     if (classifiable == null)
     {
         log.Warn("GetByRelatedIds null request");
         return(null);
     }
     using (var wu = SessionManager.WorkUnitFor(this, DbWorkUnitType.Read))
     {
         var criteria = CreateGetByRelatedCriteria(wu, classifiable, direction, type)
                        .SetProjection(Projections.ProjectionList()
                                       .Add(Projections.Property("ObjectID"), "Id")
                                       .Add(Projections.Property("ObjectName"), "Name"))
                        .SetResultTransformer(new AliasToBeanResultTransformer(typeof(RelatedIdsResult)));
         return(criteria.List <RelatedIdsResult>());
     }
 }
コード例 #28
0
ファイル: IntClassWiz2.cs プロジェクト: mirkomaty/NDO
        private void IntClassWiz2_Load(object sender, System.EventArgs e)
        {
            IntermediateClassInfo classInfo = model[model.Index];

            RelationDirection dir = classInfo.RelationDirection;

            this.lblBi.Text   = model.TableNode.Text + "<->" + classInfo.Table;
            this.lblToMe.Text = model.TableNode.Text + "->" + classInfo.Table;
            if (dir == RelationDirection.DirectedToMe)
            {
                radioToMe.Checked = true;
            }
            else
            {
                radioBi.Checked = true;
            }

            this.lblClass.Text = classInfo.Type;
            if (classInfo.ForeignFieldName == string.Empty)
            {
                string name = model.TableNode.Text.Replace(" ", string.Empty);
                name = name.Substring(0, 1).ToLower() + name.Substring(1);
                classInfo.ForeignFieldName = name;
            }
            this.txtFieldName.DataBindings.Add("Text", classInfo, "ForeignFieldName");

            if (classInfo.CodingStyle == CodingStyle.IList)
            {
                this.radioIList.Checked = true;
            }
            else if (classInfo.CodingStyle == CodingStyle.ArrayList)
            {
                this.radioArrayList.Checked = true;
            }
            else if (classInfo.CodingStyle == CodingStyle.NDOArrayList)
            {
                this.radioNDOArrayList.Checked = true;
            }
#if !NDO11
            radioArrayList.Text       = "List<T>";
            radioIList.Text           = "IList<T>";
            radioNDOArrayList.Visible = false;
#endif

            Frame.Description = "The relation is visible in class '" + classInfo.Type + "', if Relation Direction is bidirectional.\n\nIf this is the case, enter the name of the field, which will contain the relation, and the relation coding style.";
        }
コード例 #29
0
        public IList <T> GetByRelated <T>(IClassifiable classifiable, RelationDirection direction = RelationDirection.Undefined, TaxonEntity type = null) where T : Entity, IClassifiable
        {
            List <T> ret = new List <T>();

            using (var repo = new Repository <T>(context, log))
            {
                var idList = GetByRelated(classifiable, direction, type).Select(y => y.ObjectID).ToList();
                if (idList.Count() > 0)
                {
                    using (var wu = SessionManager.WorkUnitFor(this, DbWorkUnitType.Read))
                    {
                        ret = repo.AsQueryable(wu.Session).Where(x => idList.Contains(x.Id)).ToList();
                    }
                }
                ret.ForEach(x => repo.Evict(x));
            }
            return(ret);
        }
コード例 #30
0
        private void ForeignKeyWiz1_Load(object sender, System.EventArgs e)
        {
            this.cbRelatedTable.DataSource = model.TableNodes;
            Frame.Description = "Enter the Table, the foreign key points to.\n\nThe relation direction determines, in which class the relation will be defined";
            RelationDirection dir = ((FkRelation)model.RelationNode.Relation).RelationDirection;

            if (dir == RelationDirection.DirectedToMe)
            {
                radioToMe.Checked = true;
            }
            else if (dir == RelationDirection.DirectedFromMe)
            {
                radioFromMe.Checked = true;
            }
            else
            {
                radioBi.Checked = true;
            }
        }
コード例 #31
0
        public static List <Graph> EntityNeighbourhood(this Graph graph, RelationDirection relationDirection = RelationDirection.Forwards)
        {
            if (graph == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Cannot query the entity neighbourhood of a null graph.");
                return(new List <Graph>());
            }

            List <Graph> subGraphs = new List <Graph>();

            m_Adjacency = graph.Adjacency(relationDirection);

            foreach (KeyValuePair <Guid, List <Guid> > kvp in m_Adjacency)
            {
                subGraphs.Add(graph.SetSubGraph(kvp.Key, kvp.Value, relationDirection));
            }

            return(subGraphs);
        }
コード例 #32
0
 public RelationDirection BackDirection(RelationDirection direction)
 {
     if (direction == RelationDirection.Undefined)
     {
         return(RelationDirection.Undefined);
     }
     else if (direction == RelationDirection.Forward)
     {
         return(RelationDirection.Back);
     }
     else if (direction == RelationDirection.Back)
     {
         return(RelationDirection.Forward);
     }
     else if (direction == RelationDirection.Both)
     {
         return(RelationDirection.Both);
     }
     throw new Exception("Unknown direction");
 }
コード例 #33
0
ファイル: ToRelation.cs プロジェクト: BHoM/BHoM_Engine
 public static List<IRelation> ToRelation<TNode>(this ILink<TNode> link, RelationDirection linkDirection = RelationDirection.Forwards)
     where TNode : INode
 {
     List<IRelation> relations = new List<IRelation>();
     IRelation forward = ToRelation(link);
     switch (linkDirection)
     {
         case RelationDirection.Forwards:
             relations.Add(forward);
             break;
         case RelationDirection.Backwards:
             relations.Add(forward.Reverse());
             break;
         case RelationDirection.Both:
             relations.Add(forward); 
             relations.Add(forward.DeepClone().IReverse());
             break;
     }
     return relations;
 }
コード例 #34
0
ファイル: Adjacency.cs プロジェクト: BHoM/BHoM_Engine
        public static Dictionary <Guid, List <Guid> > Adjacency(this Graph graph, RelationDirection relationDirection = RelationDirection.Forwards)
        {
            if (graph == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Cannot query the adjacency of a null graph.");
                return(new Dictionary <Guid, List <Guid> >());
            }

            Dictionary <Guid, List <Guid> > adjacency = new Dictionary <Guid, List <Guid> >();

            graph.Entities.ToList().ForEach(n => adjacency.Add(n.Key, new List <Guid>()));
            foreach (Guid entity in graph.Entities.Keys.ToList())
            {
                List <Guid> connected = new List <Guid>();
                switch (relationDirection)
                {
                case RelationDirection.Forwards:
                    connected.AddRange(graph.Destinations(entity));
                    break;

                case RelationDirection.Backwards:
                    connected.AddRange(graph.Incoming(entity));
                    break;

                case RelationDirection.Both:
                    connected.AddRange(graph.Incoming(entity));
                    connected.AddRange(graph.Destinations(entity));
                    break;
                }

                //keep unique only
                foreach (Guid d in connected)
                {
                    if (!adjacency[entity].Contains(d))
                    {
                        adjacency[entity].Add(d);
                    }
                }
            }
            return(adjacency);
        }
コード例 #35
0
ファイル: Graph.cs プロジェクト: BHoM/BHoM_Engine
        /***************************************************/

        private static List <IRelation> RelationsToAdd(IRelation relation, RelationDirection linkDirection)
        {
            List <IRelation> relations = new List <IRelation>();

            if (linkDirection == RelationDirection.Forwards)
            {
                relations.Add(relation);
            }

            if (linkDirection == RelationDirection.Backwards)
            {
                relations.Add(relation.IReverse());
            }

            if (linkDirection == RelationDirection.Both)
            {
                relations.Add(relation);
                IRelation clone = relation.DeepClone();
                relations.Add(clone.IReverse());
            }
            return(relations);
        }
コード例 #36
0
ファイル: RelationProvider.cs プロジェクト: dkme/moooyo
        public static long getRelationCount(String me, String you, String RelationName, RelationDirection dir)
        {
            try
            {
                IMongoQuery qc=null;
                if (dir == RelationDirection.FromMe) qc = Query.EQ("FromMember", me);
                if (dir == RelationDirection.ToMe) qc = Query.EQ("ToMember", me);
                if (dir == RelationDirection.FromMeToYou) qc =
                    Query.And(Query.EQ("FromMember", me), Query.EQ("ToMember", you));
                if (dir == RelationDirection.ToMeFromYou) qc =
                    Query.And(Query.EQ("FromMember", you), Query.EQ("ToMember", me));
                if (dir == RelationDirection.Both) qc =
                    Query.Or(
                        Query.And(Query.EQ("FromMember", you), Query.EQ("ToMember", me)),
                        Query.And(Query.EQ("FromMember", me), Query.EQ("ToMember", you))
                    );

                long count = MongoDBHelper.GetCount(
                    RelationName,
                    qc);

                return count;
            }
            catch (System.Exception err)
            {
                throw new CBB.ExceptionHelper.OperationException(
                    CBB.ExceptionHelper.ErrType.SystemErr,
                    CBB.ExceptionHelper.ErrNo.DBOperationError,
                    err);
            }
        }
コード例 #37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProductGroupVM"/> class initialized with default values.
 /// </summary>
 public ActivityOperatorVM(AccessType access, ActivitySkillDataService dataService, RelationDirection presentationType):base(access, presentationType)
 {
     InitializeData(dataService);
 }
コード例 #38
0
        public static Graph EntityNeighbourhood(this Graph graph, IBHoMObject entity, int maximumDepth, RelationDirection relationDirection = RelationDirection.Forwards)
        {
            if (graph == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Cannot query the entity neighbourhood of a null graph.");
                return(null);
            }

            if (entity == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Cannot search from a null entity.");
                return(null);
            }

            List <Graph> subGraphs = new List <Graph>();

            m_Adjacency           = graph.Adjacency(relationDirection);
            m_AccessibleEntities  = new List <Guid>();
            m_AccessibleRelations = new List <Guid>();

            //add start entity
            m_AccessibleEntities.Add(entity.BHoM_Guid);

            graph.Traverse(entity.BHoM_Guid, maximumDepth, 0, relationDirection);

            Graph subgraph = new Graph();

            foreach (Guid guid in m_AccessibleEntities)
            {
                if (!subgraph.Entities.ContainsKey(guid))
                {
                    subgraph.Entities.Add(guid, graph.Entities[guid].DeepClone());
                }
            }

            foreach (Guid guid in m_AccessibleRelations)
            {
                if (!subgraph.Relations.Any(r => r.BHoM_Guid.Equals(guid)))
                {
                    subgraph.Relations.Add(graph.Relations.Find(r => r.BHoM_Guid.Equals(guid)));
                }
            }

            return(subgraph);
        }
コード例 #39
0
ファイル: StationMachineVM.cs プロジェクト: T1Easyware/Soheil
 /// <summary>
 /// Initializes a new instance of the class initialized with default values.
 /// </summary>
 public StationMachineVM(AccessType access, StationMachineDataService dataService, RelationDirection presentationType):base(access, presentationType)
 {
     InitializeData(dataService);
 }
コード例 #40
0
        /***************************************************/
        private static Graph SetSubGraph(this Graph graph, Guid sourceEntity, List <Guid> entityAdjacency, RelationDirection relationDirection)
        {
            Graph subgraph = new Graph();

            //add start entity
            subgraph.Entities.Add(sourceEntity, graph.Entities[sourceEntity].DeepClone());

            entityAdjacency.ForEach(ent => subgraph.Entities.Add(ent, graph.Entities[ent].DeepClone()));

            entityAdjacency.ForEach(ent => subgraph.Relations.AddRange(graph.Relation(graph.Entities[sourceEntity], graph.Entities[ent], relationDirection)));

            return(subgraph);
        }
コード例 #41
0
 /***************************************************/
 /**** Private Methods                           ****/
 /***************************************************/
 private static void Traverse(this Graph graph, Guid entity, int maxDepth, int currentDepth, RelationDirection relationDirection)
 {
     if (currentDepth >= maxDepth)
     {
         return;
     }
     foreach (Guid c in m_Adjacency[entity])
     {
         m_AccessibleEntities.Add(c);
         m_AccessibleRelations.AddRange(graph.Relation(entity, c, relationDirection));
         graph.Traverse(c, maxDepth, currentDepth + 1, relationDirection);
     }
 }
コード例 #42
0
 protected ItemRelationDetailViewModel(AccessType access, RelationDirection presentationType)
     : base(access)
 {
     PresentationType = presentationType;
 }
コード例 #43
0
ファイル: UserPositionVM.cs プロジェクト: T1Easyware/Soheil
 /// <summary>
 /// Initializes a new instance of the <see cref="ProductGroupVM"/> class initialized with default values.
 /// </summary>
 public UserPositionVM(AccessType access, RelationDirection presentationType):base(access, presentationType)
 {
     InitializeData();
 }
コード例 #44
0
        private MvcWidgetProxy CreateMvcWidget(string resolveType, string widgetName, string relatedFieldName = null, string relatedItemType = null, RelationDirection relationTypeToDisplay = RelationDirection.Child)
        {
            var mvcProxy = new MvcWidgetProxy();
            mvcProxy.ControllerName = typeof(DynamicContentController).FullName;
            var dynamicController = new DynamicContentController();
            dynamicController.Model.ContentType = TypeResolutionService.ResolveType(resolveType);
            dynamicController.Model.RelatedFieldName = relatedFieldName;
            dynamicController.Model.RelatedItemType = relatedItemType;
            dynamicController.Model.RelationTypeToDisplay = relationTypeToDisplay;

            mvcProxy.Settings = new ControllerSettings(dynamicController);
            mvcProxy.WidgetName = widgetName;

            return mvcProxy;
        }
コード例 #45
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProductGroupVM"/> class initialized with default values.
 /// </summary>
 public ProductDefectionVM(AccessType access, ProductDefectionDataService dataService, RelationDirection presentationType)
     : base(access, presentationType)
 {
     InitializeData(dataService);
 }
コード例 #46
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProductGroupVM"/> class initialized with default values.
 /// </summary>
 public ActionPlanFishboneVM(AccessType access, RelationDirection presentationType):base(access, presentationType)
 {
     InitializeData();
 }
コード例 #47
0
 public static RelationEntity Create(IClassifiable relatable, IClassifiable related, TaxonEntity type = null, RelationDirection direction = RelationDirection.Undefined)
 {
     return(new RelationEntity()
     {
         Type = type,
         Direction = direction,
         ObjectName = relatable.ObjectName,
         ObjectID = relatable.Id,
         RelatedObjectName = related.ObjectName,
         RelatedObjectID = related.Id,
     });
 }
コード例 #48
0
 public Relation(PersonId secondPersonId, RelationDirection relationDirection, RelationType relationType)
 {
     SecondPersonId    = secondPersonId;
     RelationDirection = relationDirection;
     RelationType      = relationType;
 }