Beispiel #1
0
        public RQItem Get(string dbname, string id, string format, string verb = "", string queryString = "")
        {
            if (System.Web.HttpContext.Current.Request.Headers.Get("Accept").ToLower().Contains("text/html"))
            {
                throw new HttpResponseException(JsonErrorResponse.Redirect(Request.RequestUri.ToString().Replace("rqds/" + dbname + "/" + id + "/" + format, dbname + "/" + "RQItemLD/" + id + "?verb=" + format)));
            }
            else
            {
                UserState.States state;
                bool             forEdit;

                RQItemModelRepository repo = new RQItemModelRepository(new FormatParameter((FormatParameter.FormatEnum)Enum.Parse(typeof(FormatParameter.FormatEnum), format + ((format == "rqi") ? "_single_item" : ""))));
                if (!string.IsNullOrEmpty(verb))
                {
                    switch (verb.ToLower())
                    {
                    case "queryitem":
                        state   = UserState.States.ListViewState;
                        forEdit = false;
                        break;

                    case "browseitem":
                        state   = UserState.States.BrowseViewState;
                        forEdit = false;
                        break;

                    case "edititem":
                        state   = RQItem.IsExternal(id) ? UserState.States.ListViewState : UserState.States.EditState;
                        forEdit = RQItem.IsExternal(id) ? false : true;
                        break;

                    default:
                        state   = UserState.States.ListViewState;
                        forEdit = false;
                        break;
                    }
                }
                else
                {
                    state   = UserState.States.ListViewState;
                    forEdit = false;
                }
                return(repo.GetRQItem(id, state, forEdit));
            }
        }
Beispiel #2
0
        public ActionResult RQItemRecord(string verb, string rqitemId, string serviceId)
        {
            RQItem rqitem = null;
            string view   = "";

            if ((!string.IsNullOrEmpty(verb)) && ((verb.ToLower() == "edit")))
            {
                if (MvcRQ.Helpers.AccessRightsResolver.HasEditAccess())
                {
                    ViewBag.Title  = "RiQuest | Edit";
                    ViewBag.Header = "Dokument editieren";
                    if (bClientEditing)
                    {
                        ViewBag.RQItemId = rqitemId;
                        return(View("ClientEditor"));
                    }
                    else
                    {
                        ViewBag.EditButton1 = RQResources.Views.Shared.SharedStrings.update;
                        ViewBag.EditButton2 = RQResources.Views.Shared.SharedStrings.cancel;
                        view   = "EditRQItem";
                        rqitem = modelRepository.GetRQItem(rqitemId, UserState.States.EditState, true);
                    }
                }
                else
                {
                    throw new AccessViolationException("Not authorized for this function!");
                }
            }
            else if ((!string.IsNullOrEmpty(verb)) && ((verb.ToLower() == "copy")))
            {
                if (MvcRQ.Helpers.AccessRightsResolver.HasAddAccess())
                {
                    ViewBag.Title  = "RiQuest | Copy";
                    ViewBag.Header = "Dokument kopieren";
                    if (bClientEditing)
                    {
                        ViewBag.RQItemId = rqitemId;
                        return(View("ClientEditor"));
                    }
                    else
                    {
                        ViewBag.EditButton1 = RQResources.Views.Shared.SharedStrings.add;
                        ViewBag.EditButton2 = RQResources.Views.Shared.SharedStrings.cancel;
                        rqitem       = new RQItem(modelRepository.GetRQItem(rqitemId, (RQItem.IsExternal(rqitemId) ? UserState.States.ListViewState : UserState.States.EditState), true)._resultItem);
                        rqitem.DocNo = "";
                        rqitem.ID    = "";
                        view         = "EditRQItem";
                    }
                }
                else
                {
                    throw new AccessViolationException("Not authorized for this function!");
                }
            }
            else if ((!string.IsNullOrEmpty(verb)) && ((verb.ToLower() == "queryitem")))
            {
                rqitem = modelRepository.GetRQItem(rqitemId, UserState.States.ListViewState, false);
                if (HttpContext.Request.AcceptTypes.Contains("text/html"))
                {
                    return(this.Content(rqitem.TransformItem(RQItem.DisplFormat.single_item), "text/html", System.Text.Encoding.UTF8));
                }
                else
                {
                    view = "DisplRQItem";
                }
            }
            else if ((!string.IsNullOrEmpty(verb)) && ((verb.ToLower() == "browseitem")))
            {
                rqitem = modelRepository.GetRQItem(rqitemId, UserState.States.BrowseViewState, false);
                if (HttpContext.Request.AcceptTypes.Contains("text/html"))
                {
                    return(this.Content(rqitem.TransformItem(RQItem.DisplFormat.single_item), "text/html", System.Text.Encoding.UTF8));
                }
                else
                {
                    view = "DisplRQItem";
                }
            }
            else if ((!string.IsNullOrEmpty(verb)) && ((verb.ToLower() == "edititem")))
            {
                view   = "EditRQItem";
                rqitem = modelRepository.GetRQItem(rqitemId, (RQItem.IsExternal(rqitemId) ? UserState.States.ListViewState : UserState.States.EditState), RQItem.IsExternal(rqitemId) ? false : true);
            }
            else
            {
                rqitem = modelRepository.GetRQItem(rqitemId, UserState.States.ItemViewState, false);
                if (string.IsNullOrEmpty(serviceId))
                {
                    modelRepository.GetQuery(rqitemId);
                    ViewBag.docNo = HttpContext.Request.QueryString.Get("d") != null?HttpContext.Request.QueryString.Get("d") : "";

                    ViewBag.HasAddPermit  = MvcRQ.Helpers.AccessRightsResolver.HasAddAccess(); // Enable the add new button if user is allowed to add RQItems ti the database.
                    ViewBag.GetRQItemVerb = "QueryItem";                                       // Tell GetRQItem() in ResultViewer the appropiate verb for saving the user state.
                    return(View("Index"));
                }
                else
                {
                    view = "ServRQItem";
                    ViewBag.ServiceType = serviceId;
                    ViewBag.TextSeg0    = "an individual RQItem";
                }
                switch (serviceId)
                {
                case "mods":
                    throw new NotImplementedException("RiQuest data service not yet implemented for mods format.");

                case "oai_dc":
                    EnableXmlAttribute.XSLTransform = "~/xslt/rqi2dc.xslt";
                    break;

                case "srw_dc":
                    throw new NotImplementedException("RiQuest data service not yet implemented for srw_dc format.");

                case "info_ofi":
                    throw new NotImplementedException("RiQuest data service not yet implemented for info_ofi format.");

                case "rqi":
                    EnableXmlAttribute.XSLTransform = "";
                    break;

                case "rq":
                    EnableXmlAttribute.XSLTransform = "~/xslt/rqi2rq.xslt";
                    break;

                default:
                    throw new NotImplementedException("RiQuest data service not yet implemented for unknown format.");
                }
            }
            if (rqitem == null)
            {
                throw new NotImplementedException("Could not find a RiQuest item with requested document number.");
            }
            else
            {
                bool bClassificationLinkedData = false;  //all semantic web servers for classification data not working properly

                if (bClassificationLinkedData == true)
                {
                    rqitem.LoadLinkedData("Classification");
                }
                return(View(view, rqitem));
            }
        }