示例#1
0
        public ResponseAapi <ICollection <ICategory> > GetCategoryLink(int id, string link_type)
        {
            _logger.Info("REQUEST - {0}/{1}", id, link_type);

            var categoryList = new List <ICategory>();

            var response = new ResponseAapi <ICollection <ICategory> >();

            if (link_type == "pc")
            {
                var category       = this.categoryRepository.Load(id);
                var parentCategory = this.categoryRepository.Load(category.GetParentCategory().Id);
                if (parentCategory != null)
                {
                    categoryList.Add(parentCategory);
                }
            }
            else if (link_type == "cc")
            {
                var category = this.categoryRepository.Load(id);
                categoryList.AddRange(
                    this.categoryRepository.FindChildren(category).Take(1000000)
                    );
            }

            response.Value = categoryList;
            return(response);
        }
示例#2
0
        public ResponseAapi <ICollection <ICategory> > GetLabelLinkCategory(string query)
        {
            // TODO: queryは、整数のみ(他の入力形式は、将来実装)
            var response = new ResponseAapi <ICollection <ICategory> >();

            try
            {
                // 現設計では、queryで指定できるラベル情報は1つのみであるため、
                // そのラベルを読み込んで、ラベル情報に関連付けされているカテゴリ情報の一覧を返す。
                long labelId = long.Parse(query);
                var  label   = mLabelRepository.Load(labelId) as Label;
                if (label != null)
                {
                    response.Value = label.Categories.Select(prop => (ICategory)prop.Category).ToList();
                }
                else
                {
                    throw new ApplicationException(string.Format("指定したラベル情報(ID:{0})の読み込みに失敗しました", labelId));
                }
            }
            catch (Exception expr)
            {
                _logger.Error(expr.Message);
                throw new InterfaceOperationException();
            }

            return(response);
        }
        public ActionResult <ResponseAapi <ICollection <ICategory> > > SearchAlbumCategory2(string labels)
        {
            mLogger.Info("REQUEST - {0}", labels);
            var response     = new ResponseAapi <ICollection <ICategory> > ();
            var categoryList = new List <ICategory> ();

            // クエリパラメータからラベルIDを取り出します
            List <ILabel> labelentity = new List <ILabel> ();

            string[] labelIdstr = labels.Split(',');
            foreach (var labelId in labelIdstr)
            {
                labelentity.Add(
                    new Label {
                    Id = long.Parse(labelId)
                }
                    );
            }
            var query = this.mCategoryRepository.FindCategoryOr(labelentity)
                        .Where(category => category.AlbumFlag == true);

            categoryList.AddRange(
                query.Take(1000000)
                );

            response.Value = categoryList;
            return(response);
        }
        public ResponseAapi <string> Get_Version()
        {
            var response = new ResponseAapi <string> ();

            response.Value = "1.0.0";
            return(response);
        }
        public ActionResult <ResponseAapi <ICategory> > GetCategory(int id, [FromQuery] CategoryParam param)
        {
            var response = new ResponseAapi <ICategory>();

            mBuilder.AttachCategoryEntity(id, response);
            var category = response.Value;

            // "la"
            if (param.lla_order == CategoryParam.LLA_ORDER_NAME_ASC)
            {
                response.Link.Add("la", category.GetContentList().OrderBy(prop => prop.Name).Select(prop => prop.Id).ToArray());
            }
            else if (param.lla_order == CategoryParam.LLA_ORDER_NAME_DESC)
            {
                response.Link.Add("la", category.GetContentList().OrderByDescending(prop => prop.Name).Select(prop => prop.Id).ToArray());
            }
            else
            {
                response.Link.Add("la", category.GetContentList().Select(prop => prop.Id).ToArray());
            }

            // "cc"
            var ccQuery = this.mCategoryRepository.FindChildren(category);

            response.Link.Add("cc", ccQuery.Select(prop => prop.Id).ToArray());

            // 拡張機能の呼び出し
            this.mExtentionManager.Execute(ExtentionCutpointType.API_GET_CATEGORY, category);

            return(response);
        }
        public ResponseAapi <Boolean> UpdateContentStatus(long id, string operation)
        {
            _logger.Debug("IN");
            var response = new ResponseAapi <Boolean> ();

            var content = mContentRepository.Load(id);

            if (content == null)
            {
                throw new InterfaceOperationException("コンテント情報が見つかりません");
            }

            bool result = false;

            switch (operation)
            {
            case "read":
                content.ReadableFlag = true;
                result = true;
                break;

            default:
                _logger.Warn($"不明なオペレーション({@operation})です。");
                break;
            }

            if (result)
            {
                mContentRepository.Save();
            }

            response.Value = result;
            _logger.Debug("OUT");
            return(response);
        }
        public ActionResult <ResponseAapi <ICollection <ICategory> > > GetCategoryLink_cc(int id)
        {
            var response = new ResponseAapi <ICollection <ICategory> > {
                Value = GetCategoryLink(id, "cc")
            };

            return(response);
        }
        public ResponseAapi <Category> GetCategoryLink_albc(int id, int link_id)
        {
            mLogger.Info("REQUEST - {0}/albc/{1}", id, link_id);

            var response = new ResponseAapi <Category>();

            response.Value = new Category {
                Id = link_id, Name = "リンクカテゴリ " + link_id
            };
            return(response);
        }
        public ActionResult <ResponseAapi <ICategory> > GetCategoryLink_pc(int id)
        {
            var response = new ResponseAapi <ICategory> {
                Value = GetCategoryLink(id, "pc").FirstOrDefault()
            };

            if (response.Value == null)
            {
                return(NotFound());
            }

            return(response);
        }
        public ResponseAapi <ICategory> GetContentLink_Category(int id)
        {
            var response = new ResponseAapi <ICategory> ();

            try {
                var content = mContentRepository.Load(id);
                mBuilder.AttachCategoryEntity(content.GetCategory().Id, response);
            } catch (Exception expr) {
                _logger.Error(expr.Message);
                throw new InterfaceOperationException();
            }
            return(response);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <param name="out_respponse"></param>
        public void AttachContentEntity(long id, ResponseAapi <IContent> out_respponse)
        {
            var content = mContentRepository.Load(id);

            if (content != null)
            {
                out_respponse.Value = content;
            }
            else
            {
                throw new InterfaceOperationException("コンテント情報が見つかりません");
            }
        }
        public ResponseAapi <string> Get_RegisterWorkspace()
        {
            var workspace = workspaceRepository.New();

            workspace.Name         = "Private";
            workspace.PhysicalPath = "/home/atachi/PixstockSample";
            workspaceRepository.Save();

            var response = new ResponseAapi <string> ();

            response.Value = "1.0.0";
            return(response);
        }
        /// <summary>
        ///
        /// /// </summary>
        /// <param name="id"></param>
        /// <param name="out_response"></param>
        public void AttachLabelEntity(long id, ResponseAapi <ILabel> out_response)
        {
            var label = mLabelRepository.Load(id);

            if (label != null)
            {
                out_response.Value = label;
            }
            else
            {
                throw new InterfaceOperationException("ラベル情報が見つかりません");
            }
        }
        public ActionResult <ResponseAapi <ICollection <IContent> > > GetCategoryLink_la(int id)
        {
            mLogger.Info("REQUEST - {0}", id);

            var categoryList = new List <IContent>();
            var response     = new ResponseAapi <ICollection <IContent> >();

            var category = this.mCategoryRepository.Load(id);

            categoryList.AddRange(
                category.GetContentList().OrderBy(prop => prop.Name).Select(prop => prop).Take(100000)
                );
            response.Value = categoryList;
            return(response);
        }
示例#15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ResponseAapi <IContent> GetContent(int id)
        {
            var response = new ResponseAapi <IContent>();
            var content  = contentRepository.Load(id);

            if (content != null)
            {
                response.Value = content;
            }
            else
            {
                throw new InterfaceOperationException();
            }

            return(response);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <param name="out_response"></param>
        public void AttachCategoryEntity(long id, ResponseAapi <ICategory> out_response)
        {
            var category = mCategoryRepository.Load(id);

            if (category != null)
            {
                out_response.Value = category;

                // 関連データ設定
                out_response.Rel.Add("labels", JsonConvert.SerializeObject(category.GetLabelList()));
            }
            else
            {
                throw new InterfaceOperationException("カテゴリが見つかりません");
            }
        }
示例#17
0
        public ActionResult <ResponseAapi <ICollection <ICategory> > > GetLabelLink_CategoryList(int id)
        {
            // TODO: すべての要素を返さずに、ページングで特定範囲の取得に対応する
            var categoryList = new List <ICategory> ();
            var label        = this.mLabelRepository.Load(id);

            categoryList.AddRange(
                label.GetCategoryList().Take(1000000) // 本来はEnumerationを返す
                );

            var response = new ResponseAapi <ICollection <ICategory> > {
                Value = categoryList
            };

            return(response);
        }
示例#18
0
        public ResponseAapi <ICategory> GetCategory(int id, [FromQuery] CategoryParam param)
        {
            var response = new ResponseAapi <ICategory>();
            var category = this.categoryRepository.Load(id);

            if (category != null)
            {
                response.Value = category;

                // "la"
                if (param.lla_order == CategoryParam.LLA_ORDER_NAME_ASC)
                {
                    response.Link.Add("la", category.GetContentList().OrderBy(prop => prop.Name).Select(prop => prop.Id).ToArray());
                }
                else if (param.lla_order == CategoryParam.LLA_ORDER_NAME_DESC)
                {
                    response.Link.Add("la", category.GetContentList().OrderByDescending(prop => prop.Name).Select(prop => prop.Id).ToArray());
                }
                else
                {
                    response.Link.Add("la", category.GetContentList().Select(prop => prop.Id).ToArray());
                }

                // "cc"
                var ccQuery = this.categoryRepository.FindChildren(category);
                response.Link.Add("cc", ccQuery.Select(prop => prop.Id).ToArray());
            }
            else
            {
                throw new InterfaceOperationException("カテゴリが見つかりません");
            }

            try
            {
                // 拡張機能の呼び出し
                this.extentionManager.Execute(ExtentionCutpointType.API_GET_CATEGORY, category);
            }
            catch (Exception expr)
            {
                _logger.Error(expr.Message);
                throw new InterfaceOperationException();
            }

            return(response);
        }
示例#19
0
        public ActionResult <ResponseAapi <ICollection <ILabel> > > GetLabelLink_Children(int id)
        {
            ResponseAapi <ICollection <ILabel> > response;

            if (id == 0)
            {
                response = new ResponseAapi <ICollection <ILabel> > {
                    Value = this.mLabelRepository.FindRoot().Take(100000).ToList()
                };
            }
            else
            {
                response = new ResponseAapi <ICollection <ILabel> > {
                    Value = this.mLabelRepository.FindChildren(id).Take(100000).ToList()
                };
            }
            return(response);
        }
        public ActionResult <ResponseAapi <IContent> > GetCategoryLink_la(int id, int link_id)
        {
            mLogger.Info("REQUEST - {0}/la/{1}", id, link_id);

            var response      = new ResponseAapi <IContent>();
            var linkedContent = this.mCategoryRepository.Load(id).GetContentList().Where(prop => prop.Id == link_id).SingleOrDefault();

            if (linkedContent != null)
            {
                mBuilder.AttachContentEntity(link_id, response);
            }
            else
            {
                return(NotFound());
            }

            return(response);
        }
示例#21
0
        public ActionResult <ResponseAapi <ILabel> > GetLabel(int id)
        {
            var response = new ResponseAapi <ILabel> ();

            mBuilder.AttachLabelEntity(id, response);

            var label = response.Value;

            // リンクデータの生成
            response.Link.Add("category-list", label.GetCategoryList().OrderBy(prop => prop.Name).Select(prop => prop.Id).ToArray());

            response.Link.Add("content-list", label.GetContentList().OrderBy(prop => prop.Name).Select(prop => prop.Id).ToArray());

            var ccQuery = this.mLabelRepository.FindChildren(label.Id);

            response.Link.Add("children", ccQuery.Select(prop => prop.Id).ToArray());

            return(response);
        }
        public ResponseAapi <IContent> GetContent(int id)
        {
            var response = new ResponseAapi <IContent> ();

            try {
                mBuilder.AttachContentEntity(id, response);
                var content = response.Value;

                // リンクデータ
                // "category"
                if (content.GetCategory() != null)
                {
                    response.Link.Add("category", content.GetCategory().Id);
                }
            } catch (Exception expr) {
                _logger.Error(expr.Message);
                throw new InterfaceOperationException();
            }
            return(response);
        }
        public ResponseAapi <ICategory> GetCategoryLink_cc(int id, int link_id)
        {
            _logger.Info("REQUEST - {0}/cc/{1}", id, link_id);
            var response = new ResponseAapi <ICategory> ();

            var linkedCategory = this.mCategoryRepository.FindChildren(id).Where(prop => prop.Id == link_id).SingleOrDefault();

            if (linkedCategory != null)
            {
                mBuilder.AttachCategoryEntity(link_id, response);

                var sub = this.mCategoryRepository.FindChildren(linkedCategory).FirstOrDefault();
                if (sub != null)
                {
                    response.Link.Add("cc_available", true);
                }
            }

            return(response);
        }
        public ResponseAapi <ICollection <ILabel> > GetLabel([FromQuery] RequestParamGetLabel requestParam)
        {
            // TODO: オフセット値を使用したデータ取得
            _logger.Info("Parameter Offset:{}", requestParam.Offset);

            List <ILabel> labels   = new List <ILabel> ();
            var           response = new ResponseAapi <ICollection <ILabel> > ();

            try {
                foreach (var prop in mLabelRepository.GetAll())
                {
                    labels.Add(prop);
                }
                response.Value = labels;
            } catch (Exception expr) {
                _logger.Error(expr.Message);
                throw new InterfaceOperationException();
            }

            return(response);
        }
        public ResponseAapi <Boolean> UpdateContent(long id, [FromBody] Content content)
        {
            _logger.Debug("IN");
            var response = new ResponseAapi <Boolean> ();

            var targetContent = mContentRepository.Load(id);

            if (content == null)
            {
                throw new InterfaceOperationException("コンテント情報が見つかりません");
            }

            targetContent.ArchiveFlag = content.ArchiveFlag;
            targetContent.Caption     = content.Caption;
            targetContent.Comment     = content.Comment;
            targetContent.StarRating  = content.StarRating;
            targetContent.Name        = content.Name;

            mContentRepository.Save();
            response.Value = true;
            _logger.Debug("OUT");
            return(response);
        }
示例#26
0
        public ResponseAapi <IContent> GetCategoryLink_la(int id, int la_id)
        {
            _logger.Info("REQUEST - {0}/la/{1}", id, la_id);

            var response = new ResponseAapi <IContent>();

            var content = contentRepository.Load(la_id);

            if (content != null)
            {
                if (content.GetCategory().Id != id)
                {
                    throw new InterfaceOperationException();
                }
                response.Value = content;
            }
            else
            {
                throw new InterfaceOperationException();
            }

            return(response);
        }