Ejemplo n.º 1
0
        public TaxonRevisionList GetTaxonRevisions(IUserContext userContext, ITaxon taxon)
        {
            TaxonRevisionList list = new TaxonRevisionList();
            ITaxonRevision    rev;

            if (taxon.Id == DyntaxaTestSettings.Default.TestTaxonId)
            {
                rev = GetReferenceRevision(userContext, testTaxonId, TaxonRevisionStateId.Created.ToString());
                list.Add(rev);
                rev = GetReferenceRevision(userContext, testTaxonId, TaxonRevisionStateId.Ongoing.ToString());
                list.Add(rev);
                rev = GetReferenceRevision(userContext, testTaxonId, TaxonRevisionStateId.Closed.ToString());
                list.Add(rev);
            }
            else if (taxon.Id.ToString() == "0")
            {
                rev = null;
            }
            else
            {
                rev = GetReferenceRevision(userContext, testTaxonId, TaxonRevisionStateId.Created.ToString());
                list.Add(rev);
            }
            return(list);
        }
Ejemplo n.º 2
0
 private TaxonRevisionList GetRevision(Boolean refresh)
 {
     if (_revision.IsNull() || refresh)
     {
         _revision = new TaxonRevisionList();
         _revision.Add(RevisionTest.GetRevision(GetUserContext()));
     }
     return(_revision);
 }
Ejemplo n.º 3
0
        public void SquareBracketOperator()
        {
            TaxonRevisionList newRevisionList, oldRevisionList;
            Int32             taxonIndex;

            oldRevisionList = GetRevision(true);
            newRevisionList = new TaxonRevisionList();
            for (taxonIndex = 0; taxonIndex < oldRevisionList.Count; taxonIndex++)
            {
                newRevisionList.Add(oldRevisionList[oldRevisionList.Count - taxonIndex - 1]);
            }
            for (taxonIndex = 0; taxonIndex < oldRevisionList.Count; taxonIndex++)
            {
                Assert.AreEqual(newRevisionList[taxonIndex], oldRevisionList[oldRevisionList.Count - taxonIndex - 1]);
            }
        }
Ejemplo n.º 4
0
        public TaxonRevisionList GetTaxonRevisions(IUserContext userContext, ITaxonRevisionSearchCriteria searchCriteria)
        {
            TaxonRevisionList revList = new TaxonRevisionList();
            ITaxonRevision    taxonRevision;

            if (searchCriteria.StateIds != null && searchCriteria.StateIds.Count == 3 && searchCriteria.TaxonIds == null)
            {
                taxonRevision = GetReferenceRevision(userContext, DyntaxaTestSettings.Default.TestTaxonId, TaxonRevisionStateId.Created.ToString());
                revList.Add(taxonRevision);
                taxonRevision = GetReferenceRevision(userContext, DyntaxaTestSettings.Default.TestTaxonId, TaxonRevisionStateId.Ongoing.ToString());
                revList.Add(taxonRevision);
                taxonRevision = GetReferenceRevision(userContext, DyntaxaTestSettings.Default.TestTaxonId, TaxonRevisionStateId.Closed.ToString());
                revList.Add(taxonRevision);
            }
            else if (searchCriteria.StateIds != null && searchCriteria.StateIds.ElementAtOrDefault(0) == 1)
            {
                taxonRevision = GetReferenceRevision(userContext, DyntaxaTestSettings.Default.TestTaxonId, TaxonRevisionStateId.Created.ToString());
                revList.Add(taxonRevision);
            }
            else if (searchCriteria.StateIds != null && searchCriteria.StateIds.ElementAtOrDefault(0) == 2)
            {
                taxonRevision = GetReferenceRevision(userContext, DyntaxaTestSettings.Default.TestTaxonId, TaxonRevisionStateId.Ongoing.ToString());
                revList.Add(taxonRevision);
            }
            else if (searchCriteria.StateIds != null && searchCriteria.StateIds.ElementAtOrDefault(0) == 3)
            {
                taxonRevision = GetReferenceRevision(userContext, DyntaxaTestSettings.Default.TestTaxonId, TaxonRevisionStateId.Closed.ToString());
                revList.Add(taxonRevision);
            }

            else
            {
                taxonRevision = GetReferenceRevision(userContext, DyntaxaTestSettings.Default.TestTaxonId, TaxonRevisionStateId.Created.ToString());
                revList.Add(taxonRevision);
            }


            return(revList);
        }
        /// <summary>
        /// Get view for startEditing
        /// </summary>
        /// <param name="revisions"></param>
        /// <param name="loggedInUser"></param>
        /// <param name="dyntaxaApplicationUserContext"></param>
        /// <param name="model"></param>
        /// <param name="submit"></param>
        /// <param name="roles"></param>
        /// <returns></returns>
        public RevisionCommonInfoViewModel GetStartEditingViewModel(
            TaxonRevisionList revisions,
            IUserContext loggedInUser,
            IUserContext dyntaxaApplicationUserContext,
            RevisionCommonInfoViewModel model,
            bool submit,
            RoleList roles)
        {
            IList <RevisionInfoItemModelHelper> revisionInfos = new List <RevisionInfoItemModelHelper>();
            //Check if current role is set to any of the avaliable revisions
            bool alreadyEditor = false;

            if (loggedInUser.CurrentRole.IsNotNull())
            {
                foreach (ITaxonRevision revision in revisions)
                {
                    if (loggedInUser.CurrentRole.IsNotNull() && loggedInUser.CurrentRole.Identifier.Contains(revision.Guid))
                    {
                        alreadyEditor = true;
                        break;
                    }
                }
            }

            // Get revisions for this user
            TaxonRevisionList userRevisions = new TaxonRevisionList();

            foreach (ITaxonRevision revision in revisions)
            {
                // Check if user has role to edit the revision
                foreach (IRole role in roles)
                {
                    if (role.Identifier.IsNotNull())
                    {
                        if (role.Identifier.Contains(revision.Guid))
                        {
                            userRevisions.Add(revision);
                            break;
                        }
                    }
                }
            }
            // bool revsionExpanded = false;
            foreach (ITaxonRevision userRevision in userRevisions)
            {
                ITaxon revisionTaxon = userRevision.RootTaxon;
                // First we check which revisions that is enabels for this user
                RevisionInfoItemModelHelper infoItem     = new RevisionInfoItemModelHelper();
                RevisionModelManager        modelManager = new RevisionModelManager();
                infoItem.EnableRevisionEditingButton    = false;
                infoItem.SelectedRevisionForEditingText = string.Empty;
                // Do not enable any buttons if editor is already working on a revision
                if (!alreadyEditor)
                {
                    // Check if user has role to edit the revision
                    foreach (IRole role in roles)
                    {
                        if (role.Identifier.IsNotNull())
                        {
                            if (role.Identifier.Contains(userRevision.Guid))
                            {
                                infoItem.EnableRevisionEditingButton = true;
                                //if (!revsionExpanded)
                                //{
                                //    infoItem.ShowRevisionInformation = true;
                                //    revsionExpanded = true;
                                //}
                                infoItem.ShowRevisionInformation = false;
                                break;
                            }
                        }
                    }
                }
                else
                {
                    if (loggedInUser.CurrentRole.IsNotNull() &&
                        loggedInUser.CurrentRole.Identifier.Contains(userRevision.Id.ToString()))
                    {
                        infoItem.SelectedRevisionForEditingText = Resources.DyntaxaResource.RevisionStartRevisionForEditingText;
                        // infoItem.ShowRevisionInformation = true;
                    }
                }

                infoItem = modelManager.GetRevisionInformation(loggedInUser, revisionTaxon, userRevision, infoItem);
                infoItem.ShowRevisionEditingButton = true;

                infoItem.RevisionEditingButtonText = Resources.DyntaxaResource.RevisionStartEditingButtonText;
                infoItem.RevisionEditingButtonText = Resources.DyntaxaResource.RevisionStartEditingButtonText;
                infoItem.RevisionId           = userRevision.Id.ToString();
                infoItem.TaxonId              = userRevision.RootTaxon.Id.ToString();
                infoItem.RevisionWaitingLabel = " " + Resources.DyntaxaResource.RevisionStartMainHeaderText
                                                + " " + Resources.DyntaxaResource.SharedRevisionText + " " + Resources.DyntaxaResource.SharedRevisionIdLabel + ": "
                                                + userRevision.Id.ToString();
                infoItem.EditingAction     = "StartEditing";
                infoItem.EditingController = "Revision";
                revisionInfos.Add(infoItem);
            }

            // Check that there is any data and if nothing has been set set the first to be expanded if there is only one revision.
            if (revisionInfos.IsNotNull() && revisionInfos.Count == 1)
            {
                revisionInfos.FirstOrDefault().ShowRevisionInformation = true;
            }

            model.EditingAction                   = "StartEditing";
            model.EditingController               = "Revision";
            model.RevisionInfoItems               = revisionInfos;
            model.RevisionEditingHeaderText       = Resources.DyntaxaResource.RevisionStartMainHeaderText;
            model.RevisionEditingActionHeaderText = Resources.DyntaxaResource.RevisionStartEditingActionHeaderText;

            model.DialogTextPopUpText  = Resources.DyntaxaResource.SharedRevisionNoValidRevisionErrorText;
            model.DialogTitlePopUpText = Resources.DyntaxaResource.RevisionStartMainHeaderText;
            model.Submit = submit;
            return(model);
        }