Exemple #1
0
        public void Promote(Relationships.LifeCycleState NewState)
        {
            IO.Request request = this.ItemType.Session.IO.Request(IO.Request.Operations.PromoteItem);
            IO.Item    item    = request.NewItem(this.ItemType.Name, "get");
            item.ID = this.ID;
            item.SetProperty("state", NewState.Name);
            IO.Response response = request.Execute();

            if (!response.IsError)
            {
                // Update Current State
                this.Property(this.ItemType.PropertyType("current_state")).SetValue(NewState);
                this.Property(this.ItemType.PropertyType("state")).SetValue(NewState.Name);
            }
            else
            {
                throw new Exceptions.ServerException(response);
            }
        }
Exemple #2
0
        public IEnumerable <Relationships.LifeCycleState> NextStates()
        {
            List <Relationships.LifeCycleState> ret = new List <Relationships.LifeCycleState>();

            if (this.State == Model.Item.States.Stored)
            {
                if (this.LifeCycleMap != null)
                {
                    IO.Request request = this.ItemType.Session.IO.Request(IO.Request.Operations.GetItemNextStates);
                    IO.Item    item    = request.NewItem(this.ItemType.Name, "get");
                    item.ID = this.ID;
                    IO.Response response = request.Execute();

                    if (!response.IsError)
                    {
                        if (response.Items.Count() > 0)
                        {
                            IO.Item lifecycletransisiton = response.Items.First();

                            foreach (IO.Item dblifecyclestate in lifecycletransisiton.ToStates)
                            {
                                foreach (Relationships.LifeCycleState lifecyclestate in this.LifeCycleMap.Relationships("Life Cycle State"))
                                {
                                    if (lifecyclestate.ID.Equals(dblifecyclestate.ID))
                                    {
                                        ret.Add(lifecyclestate);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        throw new Exceptions.ServerException(response);
                    }
                }
            }

            return(ret);
        }
Exemple #3
0
        private void BuildCaches()
        {
            this.ItemTypeNameCache = new Dictionary <String, ItemType>();
            this.ItemTypeIDCache   = new Dictionary <String, ItemType>();

            // Build ItemType Cache
            IO.Request itemtyperequest = this.IO.Request(Aras.IO.Request.Operations.ApplyItem);
            IO.Item    itemtypequery   = itemtyperequest.NewItem("ItemType", "get");
            itemtypequery.Select = "id,name,is_relationship,class_structure,label,label_plural";

            IO.Item lifecyclemapquery = itemtyperequest.NewItem("ItemType Life Cycle", "get");
            lifecyclemapquery.Select = "class_path,related_id";
            itemtypequery.AddRelationship(lifecyclemapquery);

            IO.Response itemtyperesponse = itemtyperequest.Execute();

            if (!itemtyperesponse.IsError)
            {
                foreach (IO.Item dbitem in itemtyperesponse.Items)
                {
                    ItemType itemtype = null;

                    if (dbitem.GetProperty("is_relationship").Equals("1"))
                    {
                        itemtype = new RelationshipType(this, dbitem.ID, dbitem.GetProperty("name"), dbitem.GetProperty("label"), dbitem.GetProperty("label_plural"), dbitem.GetProperty("class_structure"));
                    }
                    else
                    {
                        itemtype = new ItemType(this, dbitem.ID, dbitem.GetProperty("name"), dbitem.GetProperty("label"), dbitem.GetProperty("label_plural"), dbitem.GetProperty("class_structure"));
                    }

                    this.ItemTypeIDCache[itemtype.ID]     = itemtype;
                    this.ItemTypeNameCache[itemtype.Name] = itemtype;

                    foreach (IO.Item itemtypelifecyclemap in dbitem.Relationships)
                    {
                        itemtype.AddLifeCycleMap(itemtypelifecyclemap.GetProperty("class_path"), itemtypelifecyclemap.GetPropertyItem("related_id").ID);
                    }
                }
            }
            else
            {
                throw new Exceptions.ServerException(itemtyperesponse);
            }

            // Build RelationshipType Cache
            IO.Request relationshiptyperequest = this.IO.Request(Aras.IO.Request.Operations.ApplyItem);
            IO.Item    relationshiptypequery   = relationshiptyperequest.NewItem("RelationshipType", "get");
            relationshiptypequery.Select = "relationship_id,source_id(id),related_id(id),grid_view";
            IO.Response relationshiptyperesponse = relationshiptyperequest.Execute();

            if (!relationshiptyperesponse.IsError)
            {
                foreach (IO.Item dbitem in relationshiptyperesponse.Items)
                {
                    RelationshipType relationshiptype = (RelationshipType)this.ItemTypeIDCache[dbitem.GetProperty("relationship_id")];

                    String source_id = dbitem.GetProperty("source_id");

                    if (!String.IsNullOrEmpty(source_id))
                    {
                        relationshiptype.Source = this.ItemTypeIDCache[source_id];
                        relationshiptype.Source.AddRelationshipType(relationshiptype);
                    }

                    String related_id = dbitem.GetProperty("related_id");

                    if (!String.IsNullOrEmpty(related_id))
                    {
                        relationshiptype.Related = this.ItemTypeIDCache[related_id];
                    }

                    switch (dbitem.GetProperty("grid_view"))
                    {
                    case "right":
                        relationshiptype.RelationshipGridView = RelationshipGridViews.Right;
                        break;

                    case "intermix":
                        relationshiptype.RelationshipGridView = RelationshipGridViews.InterMix;
                        break;

                    default:
                        relationshiptype.RelationshipGridView = RelationshipGridViews.Left;
                        break;
                    }
                }
            }
            else
            {
                throw new Exceptions.ServerException(relationshiptyperesponse);
            }
        }