Ejemplo n.º 1
0
        /// <summary>
        /// Deserializes the given SerializedObject and applies its values
        /// Expects the keys "source", "issueId", "projectId" in order to load the issue
        /// </summary>
        /// <param name="serializedObject">The SerializedObject with the save data</param>
        public async void Deserialize(SerializedObject serializedObject)
        {
            DataSource        source    = (DataSource)serializedObject.Integers[sourceKey];
            int               issueId   = serializedObject.Integers[issueIdKey];
            int               projectId = serializedObject.Integers[projectIdKey];
            Issue             issue     = null;
            ApiResult <Issue> res       = null;

            switch (source)
            {
            case DataSource.REQUIREMENTS_BAZAAR:
                res = await RequirementsBazaar.GetRequirement(issueId);

                break;

            case DataSource.GITHUB:
                res = await GitHub.GetIssue(projectId, issueId);

                break;
            }
            if (res != null && res.Successful)
            {
                issue = res.Value;
            }
            dataDisplay.Setup(issue);
        }
Ejemplo n.º 2
0
        private async void ShowExistingRequirement()
        {
            if (requirementId < 0)
            {
                return;
            }

            requirement = await RequirementsBazaar.GetRequirement(requirementId);

            projectId = requirement.ProjectId;

            await GetCategories();

            titleInputField.text       = requirement.Name;
            descriptionInputField.text = requirement.Description;
            if (availableCategories != null && requirement.Categories.Length > 0)
            {
                for (int i = 0; i < availableCategories.Length; i++)
                {
                    if (availableCategories[i].Name == requirement.Categories[0].Name)
                    {
                        categoryDropdown.value = i;
                        categoryDropdown.RefreshShownValue();
                        break;
                    }
                }
            }
            else
            {
                Debug.LogWarning("Categories have not been loaded yet but trying to set requirement category");
            }
        }
Ejemplo n.º 3
0
        private async void Start()
        {
            // in case that the card was already setup, e.g. in the local instance => do not setup again
            if (issueDataDisplay.Content != null)
            {
                Debug.Log("Card was already setup");
                return;
            }

            if (photonView.CreatorActorNr == PhotonNetwork.LocalPlayer.ActorNumber)
            {
                Debug.Log("Card created by local player; will not set up");
                return;
            }

            int issueId;

            if (photonView.InstantiationData.Length == 1) // requirements bazaar => only id was sent
            {
                issueId = (int)photonView.InstantiationData[0];
                ApiResult <Issue> result = await RequirementsBazaar.GetRequirement(issueId);

                if (result.Successful)
                {
                    issueDataDisplay.Setup(result.Value);
                }
                else
                {
                    Debug.LogError("Card synchronizer could not fetch requirement with id " + issueId + ": " + result.ErrorMessage);
                }
            }
            else if (photonView.InstantiationData.Length == 2) // GitHub => id and project id was sent
            {
                issueId = (int)photonView.InstantiationData[0];
                int projectId            = (int)photonView.InstantiationData[1];
                ApiResult <Issue> result = await GitHub.GetIssue(projectId, issueId);

                if (result.Successful)
                {
                    issueDataDisplay.Setup(result.Value);
                }
                else
                {
                    Debug.LogError("Card synchronizer could not fetch GitHub issue of project "
                                   + projectId + " and id " + issueId + ": " + result.ErrorMessage);
                }
            }
            else
            {
                Debug.Log("Unexpected number of instantiation data on issue");
                return;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// If the user presses space, a request to the Requirements Bazaar is started
        /// </summary>
        private async void Update()
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                ApiResult <Issue> res = await RequirementsBazaar.GetRequirement(requirementId);

                if (res.Successful)
                {
                    dataDisplay.Setup(res.Value);
                }
                else
                {
                    Debug.LogError("Error fetching the requirement: (Code " + res.ResponseCode + ") " + res.ErrorMessage);
                    dataDisplay.Setup(null);
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Deserializes the given serializedObject and applies the found relevant properties to the visualization
        /// </summary>
        /// <param name="serializedObject">A serialized object which contains the properties for the visualization</param>
        public async void Deserialize(SerializedObject serializedObject)
        {
            visualization.Title = serializedObject.Strings[titleKey];

            if (visualization == null)
            {
                Debug.LogWarning("No visualization found. Cannot deserialize sava data", gameObject);
                return;
            }

            List <int> projectIds = SerializedObject.GetList(projectIdKey, serializedObject.Integers);
            List <int> ids        = SerializedObject.GetList(idsKey, serializedObject.Integers);

            if (projectIds.Count != ids.Count)
            {
                Debug.LogWarning("Project IDs and issue ID lists have a different lenght. Cannot reconstruct visualization content.", gameObject);
                return;
            }

            List <Issue> issues = new List <Issue>();

            for (int i = 0; i < projectIds.Count; i++)
            {
                if (projectIds[i] < 0)
                {
                    ApiResult <Issue> networkResult = await RequirementsBazaar.GetRequirement(ids[i]);

                    if (networkResult.Successful)
                    {
                        issues.Add(networkResult.Value);
                    }
                }
                else
                {
                    ApiResult <Issue> networkResult = await GitHub.GetIssue(projectIds[i], ids[i]);

                    if (networkResult.Successful)
                    {
                        issues.Add(networkResult.Value);
                    }
                }
            }

            visualization.ContentProvider        = new SingleIssuesProvider();
            visualization.ContentProvider.Issues = issues;
        }