Пример #1
0
 public async Task DeleteByIdAsync <T>(IRequestContext context, EntityId entityId)
     where T : BaseEntity
 {
     string          collectionName = EntityTypeRegistry.GetInstance().GetCollectionName(typeof(T));
     string          url            = context.GetPath() + "/" + collectionName + "/" + entityId;
     ResponseWrapper response       = await rc.ExecuteDeleteAsync(url).ConfigureAwait(RestConnector.AwaitContinueOnCapturedContext);
 }
        public async void InitialisePluginComponents()
        {
            await OctaneServices.GetInstance().Connect();

            await OctaneMyItemsViewModel.Instance.LoadMyItemsAsync();

            await EntityTypeRegistry.Init();
        }
Пример #3
0
 public async Task DeleteByFilterAsync <T>(IRequestContext context, IList <QueryPhrase> queryPhrases)
     where T : BaseEntity
 {
     string          collectionName = EntityTypeRegistry.GetInstance().GetCollectionName(typeof(T));
     string          queryString    = QueryBuilder.Create().SetQueryPhrases(queryPhrases).Build();
     string          url            = context.GetPath() + "/" + collectionName + "?" + queryString;
     ResponseWrapper response       = await rc.ExecuteDeleteAsync(url).ConfigureAwait(RestConnector.AwaitContinueOnCapturedContext);
 }
        /// <summary>
        /// Load the necessary information for the given entity
        /// </summary>
        internal void LoadEntity(BaseEntity entity)
        {
            var viewModel = new DetailedItemViewModel(entity);

            viewModel.InitializeAsync();

            var entityTypeInformation = EntityTypeRegistry.GetEntityTypeInformation(viewModel.Entity);

            Caption = $"{entityTypeInformation?.ShortLabel} {viewModel.ID}";
            detailsControl.DataContext = viewModel;
        }
Пример #5
0
        private async Task <BaseEntity> GetByIdInternalAsync(IRequestContext context, EntityId id, Type entityType, IList <string> fields)
        {
            string collectionName = EntityTypeRegistry.GetInstance().GetCollectionName(entityType);
            string url            = context.GetPath() + "/" + collectionName + "/" + id;
            string queryString    = QueryBuilder.Create().SetFields(fields).Build();

            ResponseWrapper response = await rc.ExecuteGetAsync(url, queryString).ConfigureAwait(RestConnector.AwaitContinueOnCapturedContext);

            BaseEntity result = (BaseEntity)jsonSerializer.Deserialize(response.Data, entityType);

            return(result);
        }
Пример #6
0
        public async Task <EntityListResult <T> > UpdateEntitiesAsync <T>(IRequestContext context, EntityList <T> entities)
            where T : BaseEntity
        {
            string          collectionName = EntityTypeRegistry.GetInstance().GetCollectionName(typeof(T));
            string          url            = context.GetPath() + "/" + collectionName;
            string          data           = jsonSerializer.Serialize(entities);
            ResponseWrapper response       = await rc.ExecutePutAsync(url, null, data).ConfigureAwait(RestConnector.AwaitContinueOnCapturedContext);

            EntityListResult <T> result = jsonSerializer.Deserialize <EntityListResult <T> >(response.Data);

            return(result);
        }
Пример #7
0
        private async Task <BaseEntity> UpdateInternalAsync(IRequestContext context, BaseEntity entity, Type entityType, Dictionary <string, string> serviceArguments, IList <string> fieldsToReturn)
        {
            string collectionName = EntityTypeRegistry.GetInstance().GetCollectionName(entityType);
            string queryString    = QueryBuilder.Create().SetFields(fieldsToReturn).SetServiceArguments(serviceArguments).Build();

            string          url      = context.GetPath() + "/" + collectionName + "/" + entity.Id;
            string          data     = jsonSerializer.Serialize(entity);
            ResponseWrapper response = await rc.ExecutePutAsync(url, queryString, data).ConfigureAwait(RestConnector.AwaitContinueOnCapturedContext);

            BaseEntity result = (BaseEntity)jsonSerializer.Deserialize(response.Data, entityType);

            return(result);
        }
Пример #8
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="entity"></param>
        public BaseItemViewModel(BaseEntity entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            Entity = entity;
            if (entity.TypeName != null)
            {
                EntityTypeInformation = EntityTypeRegistry.GetEntityTypeInformation(entity);
            }
        }
Пример #9
0
        /// <summary>
        /// Search for all entities of given type that satify the search criteria
        /// </summary>
        public async Task <EntityListResult <T> > SearchAsync <T>(IRequestContext context, string searchString, List <string> subTypes, int limit = 30)
            where T : BaseEntity
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (string.IsNullOrEmpty(searchString))
            {
                throw new ArgumentException("searchString parameter is null or empty");
            }
            if (limit <= 0)
            {
                throw new ArgumentException("search limit should be greater than 0");
            }

            string url = context.GetPath() + "/" + EntityTypeRegistry.GetInstance().GetCollectionName(typeof(T));

            List <QueryPhrase> query = null;

            if (subTypes != null && subTypes.Count > 0)
            {
                query = new List <QueryPhrase> {
                    new InQueryPhrase("subtype", subTypes)
                };
            }

            var serviceArguments = new Dictionary <string, string>
            {
                { "text_search", "{\"type\":\"global\",\"text\":\"" + searchString + "\"}" }
            };
            var queryString = QueryBuilder.Create().SetQueryPhrases(query).SetOrderBy("id").SetLimit(limit).SetServiceArguments(serviceArguments).Build();

            ResponseWrapper response = await rc.ExecuteGetAsync(url, queryString).ConfigureAwait(RestConnector.AwaitContinueOnCapturedContext);

            EntityListResult <T> result = jsonSerializer.Deserialize <EntityListResult <T> >(response.Data);

            foreach (var entity in result.data)
            {
                var searchResult = entity.GetValue("global_text_search_result") as BaseEntity;
                if (searchResult == null)
                {
                    continue;
                }

                entity.SetValue("name", searchResult.GetValue("name"));
                entity.SetValue("description", searchResult.GetValue("description"));
            }
            return(result);
        }
        public void DetailedItemViewModelTests_VariousProperties_BeforeAndAfterInitialize_Success()
        {
            var viewModel = new DetailedItemViewModel(_story);

            Assert.AreEqual(WindowMode.Loading, viewModel.Mode, "Mismatched initial mode");

            viewModel.InitializeAsync().Wait();
            Assert.AreEqual(WindowMode.Loaded, viewModel.Mode, "Mismatched mode after initialization");

            var entityTypeInformation = EntityTypeRegistry.GetEntityTypeInformation(_story);

            Assert.AreEqual(entityTypeInformation.ShortLabel, viewModel.IconText, "Mismatched icon text");
            Assert.AreEqual(entityTypeInformation.Color, viewModel.IconBackgroundColor, "Mismatched icon background color");
        }
Пример #11
0
        public async Task <EntityListResult <T> > GetAsync <T>(IRequestContext context, IList <QueryPhrase> queryPhrases, List <string> fields, int?limit) where T : BaseEntity
        {
            string collectionName = EntityTypeRegistry.GetInstance().GetCollectionName(typeof(T));
            string url            = context.GetPath() + "/" + collectionName;

            string queryString = QueryBuilder.Create().SetQueryPhrases(queryPhrases).SetFields(fields).SetLimit(limit).Build();

            ResponseWrapper response = await rc.ExecuteGetAsync(url, queryString).ConfigureAwait(RestConnector.AwaitContinueOnCapturedContext);

            if (response.Data != null)
            {
                EntityListResult <T> result = jsonSerializer.Deserialize <EntityListResult <T> >(response.Data);
                return(result);
            }
            return(null);
        }
Пример #12
0
        private string GetCollectionName <T>() where T : BaseEntity
        {
            CustomCollectionPathAttribute customCollectionPathAttribute =
                (CustomCollectionPathAttribute)Attribute.GetCustomAttribute(typeof(T), typeof(CustomCollectionPathAttribute));

            String collectionName = null;

            if (customCollectionPathAttribute != null)
            {
                collectionName = customCollectionPathAttribute.Path;
            }
            else
            {
                collectionName = EntityTypeRegistry.GetInstance().GetCollectionName(typeof(T));
            }

            return(collectionName);
        }
Пример #13
0
        public async Task <EntityListResult <T> > CreateAsync <T>(IRequestContext context, EntityList <T> entityList, IList <string> fieldsToReturn = null) where T : BaseEntity
        {
            String collectionName = EntityTypeRegistry.GetInstance().GetCollectionName(typeof(T));

            string queryParams = "";

            if (fieldsToReturn != null && fieldsToReturn.Count > 0)
            {
                queryParams += "fields=" + string.Join(",", fieldsToReturn);
            }

            string          url      = context.GetPath() + "/" + collectionName;
            String          data     = jsonSerializer.Serialize(entityList);
            ResponseWrapper response = await rc.ExecutePostAsync(url, queryParams, data).ConfigureAwait(RestConnector.AwaitContinueOnCapturedContext);

            EntityListResult <T> result = jsonSerializer.Deserialize <EntityListResult <T> >(response.Data);

            return(result);
        }
Пример #14
0
        public async Task <GroupResult> GetWithGroupByAsync <T>(IRequestContext context, IList <QueryPhrase> queryPhrases, String groupBy) where T : BaseEntity
        {
            String collectionName = EntityTypeRegistry.GetInstance().GetCollectionName(typeof(T));
            string url            = context.GetPath() + "/" + collectionName + "/groups";

            // Octane group API now return logical name by default as ID field,
            // this parameter change this to return numeric ID.
            var serviceArgs = new Dictionary <string, string>();

            serviceArgs.Add("use_numeric_id", "true");

            string queryString = QueryStringBuilder.BuildQueryString(queryPhrases, null, null, null, null, groupBy, serviceArgs);

            ResponseWrapper response = await rc.ExecuteGetAsync(url, queryString).ConfigureAwait(RestConnector.AwaitContinueOnCapturedContext);

            if (response.Data != null)
            {
                GroupResult result = jsonSerializer.Deserialize <GroupResult>(response.Data);
                return(result);
            }
            return(null);
        }
Пример #15
0
        /// <summary>
        /// Update active item button in toolbar with the current active item's information
        /// </summary>
        public void UpdateActiveItemInToolbar()
        {
            try
            {
                var activeEntity = WorkspaceSessionPersistanceManager.GetActiveEntity();

                if (activeEntity != null)
                {
                    _activeItemMenuCommand.Text       = EntityTypeRegistry.GetEntityTypeInformation(activeEntity).ShortLabel + " " + activeEntity.Id;
                    _activeItemMenuCommand.Enabled    = true;
                    _copyCommitMessageCommand.Enabled = true;
                    _stopWorkCommand.Enabled          = true;
                }
                else
                {
                    DisableActiveItemToolbar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to update active item in Octane toolbar.\n\n" + "Failed with message: " + ex.Message,
                                ToolWindowHelper.AppName, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Пример #16
0
        public async Task <BaseEntity> GetByIdAsync(IRequestContext context, EntityId id, string type, IList <string> fields)
        {
            Type entityType = EntityTypeRegistry.GetInstance().GetTypeByEntityTypeName(type);

            return(await GetByIdInternalAsync(context, id, entityType, fields).ConfigureAwait(RestConnector.AwaitContinueOnCapturedContext));
        }
Пример #17
0
        public async Task <BaseEntity> GetByIdAsync(IRequestContext context, EntityId id, string type, IList <String> fields)
        {
            Type entityType = EntityTypeRegistry.GetInstance().GetTypeByEntityTypeName(type);

            return(await GetByIdInternalAsync(context, id, entityType, fields));
        }
        private MyWorkMetadata()
        {
            _entitiesFieldsFetchInfo = new Dictionary <Type, Dictionary <string, FieldInfo[]> >();
            fieldsByEntityType       = new Dictionary <Type, List <string> >();

            AddSubType <WorkItem>(WorkItem.SUBTYPE_DEFECT,
                                  FieldAtSubTitle(CommonFields.Environment, "Environment", "No environment"),
                                  FieldAtTop(CommonFields.Owner, "Owner"),
                                  FieldAtTop(CommonFields.DetectedBy, "Detected By"),
                                  FieldAtTop(CommonFields.StoryPoints, "SP"),
                                  FieldAtTop(CommonFields.Severity, "Severity"),
                                  FieldAtBottom(CommonFields.InvestedHours, "Invested Hours"),
                                  FieldAtBottom(CommonFields.RemainingHours, "Remaining Hours"),
                                  FieldAtBottom(CommonFields.EstimatedHours, "Estimated Hours")
                                  );

            AddSubType <WorkItem>(WorkItem.SUBTYPE_STORY,
                                  FieldAtSubTitle(CommonFields.Release, "Release", "No release"),
                                  FieldAtTop(CommonFields.Phase, "Phase"),
                                  FieldAtTop(CommonFields.StoryPoints, "SP"),
                                  FieldAtTop(CommonFields.Owner, "Owner"),
                                  FieldAtTop(CommonFields.Author, "Author", string.Empty, Utility.GetAuthorFullName),
                                  FieldAtBottom(CommonFields.InvestedHours, "Invested Hours"),
                                  FieldAtBottom(CommonFields.RemainingHours, "Remaining Hours"),
                                  FieldAtBottom(CommonFields.EstimatedHours, "Estimated Hours")
                                  );

            AddSubType <WorkItem>(WorkItem.SUBTYPE_QUALITY_STORY,
                                  FieldAtSubTitle(CommonFields.Release, "Release", "No release"),
                                  FieldAtTop(CommonFields.Phase, "Phase"),
                                  FieldAtTop(CommonFields.StoryPoints, "SP"),
                                  FieldAtTop(CommonFields.Owner, "Owner"),
                                  FieldAtTop(CommonFields.Author, "Author", string.Empty, Utility.GetAuthorFullName),
                                  FieldAtBottom(CommonFields.InvestedHours, "Invested Hours"),
                                  FieldAtBottom(CommonFields.RemainingHours, "Remaining Hours"),
                                  FieldAtBottom(CommonFields.EstimatedHours, "Estimated Hours")
                                  );

            AddSubType <Test>(Test.SUBTYPE_MANUAL_TEST,
                              FieldAtSubTitle("test_type", "Test Type"),
                              FieldAtTop(CommonFields.Phase, "Phase"),
                              FieldAtTop(CommonFields.Owner, "Owner"),
                              FieldAtTop(CommonFields.Author, "Author", string.Empty, Utility.GetAuthorFullName),
                              FieldAtBottom(CommonFields.StepsNum, "Steps"),
                              FieldAtBottom(CommonFields.AutomationStatus, "Automation status")
                              );

            AddSubType <Test>(TestGherkin.SUBTYPE_GHERKIN_TEST,
                              FieldAtSubTitle("test_type", "Test Type"),
                              FieldAtTop(CommonFields.Phase, "Phase"),
                              FieldAtTop(CommonFields.Owner, "Owner"),
                              FieldAtTop(CommonFields.Author, "Author", string.Empty, Utility.GetAuthorFullName),
                              FieldAtBottom(CommonFields.AutomationStatus, "Automation status")
                              );

            AddSubType <Run>(RunSuite.SUBTYPE_RUN_SUITE,
                             FieldAtSubTitle(CommonFields.Environment, "Environment", "[No environment]"),
                             FieldAtTop(CommonFields.TestRunNativeStatus, "Status"),
                             FieldAtBottom(CommonFields.Started, "Started")
                             );

            AddSubType <Run>(RunManual.SUBTYPE_RUN_MANUAL,
                             FieldAtSubTitle(CommonFields.Environment, "Environment", "[No environment]"),
                             FieldAtTop(CommonFields.TestRunNativeStatus, "Status"),
                             FieldAtBottom(CommonFields.Started, "Started")
                             );

            AddSubType <Requirement>(Requirement.SUBTYPE_DOCUMENT,
                                     FieldAtSubTitle(CommonFields.Phase, "Phase"),
                                     FieldAtTop(CommonFields.Author, "Author", string.Empty, Utility.GetAuthorFullName)
                                     );

            AddSubType <Task>(SIMPLE_ENTITY_SUBTYPE_PLACEHOLDER,
                              FieldAtSubTitle(Task.STORY_FIELD, string.Empty, string.Empty, entity =>
            {
                var parentEntity = entity.GetValue("story") as BaseEntity;
                if (parentEntity == null)
                {
                    return(string.Empty);
                }

                var parentEntityInformation = EntityTypeRegistry.GetEntityTypeInformation(parentEntity);
                if (parentEntityInformation == null)
                {
                    return(string.Empty);
                }

                var sb = new StringBuilder("Task of ")
                         .Append(parentEntityInformation.DisplayName.ToLower())
                         .Append(" ")
                         .Append(parentEntity.Id.ToString())
                         .Append(": ")
                         .Append(parentEntity.Name);
                return(sb.ToString());
            }),
                              FieldAtTop(Task.OWNER_FIELD, "Owner"),
                              FieldAtTop(Task.PHASE_FIELD, "Phase"),
                              FieldAtTop(Task.AUTHOR_FIELD, "Author", string.Empty, Utility.GetAuthorFullName),
                              FieldAtBottom(Task.INVESTED_HOURS_FIELD, "Invested Hours"),
                              FieldAtBottom(Task.REMAINING_HOURS_FIELD, "Remaining Hours"),
                              FieldAtBottom(Task.ESTIMATED_HOURS_FIELD, "Estimated Hours")
                              );

            AddSubType <Comment>(SIMPLE_ENTITY_SUBTYPE_PLACEHOLDER,
                                 FieldAtSubTitle(Comment.TEXT_FIELD, string.Empty, string.Empty, entity =>
            {
                return(Utility.StripHtml(entity.GetStringValue(Comment.TEXT_FIELD)));
            }),
                                 FieldAtTop(Comment.AUTHOR_FIELD, "Author", string.Empty, Utility.GetAuthorFullName)
                                 );

            AddSubType <Test>(TestBDDScenario.SUBTYPE_BDD_SCENARIO_TEST,
                              FieldAtSubTitle("test_type", "Test Type"),
                              FieldAtTop(CommonFields.Owner, "Owner"),
                              FieldAtBottom(CommonFields.AutomationStatus, "Automation status")
                              );
        }
Пример #19
0
 public MyWorkItemsSublist(string entityType)
 {
     TypeInformation = EntityTypeRegistry.GetEntityTypeInformation(entityType);
     Items           = new ObservableCollection <OctaneItemViewModel>();
 }
Пример #20
0
        public async Task <BaseEntity> UpdateAsync(IRequestContext context, BaseEntity entity, string type, Dictionary <string, string> serviceArguments = null, IList <string> fieldsToReturn = null)
        {
            Type entityType = EntityTypeRegistry.GetInstance().GetTypeByEntityTypeName(type);

            return(await UpdateInternalAsync(context, entity, entityType, serviceArguments, fieldsToReturn).ConfigureAwait(RestConnector.AwaitContinueOnCapturedContext));
        }