Changeset 9919 for extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/service/CategoryService.java
- Timestamp:
- Mar 29, 2011, 8:21:25 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/service/CategoryService.java
r9879 r9919 4 4 import java.util.List; 5 5 6 import fr.mael.jiwigo.dao.CategoryDao;7 6 import fr.mael.jiwigo.om.Category; 8 7 import fr.mael.jiwigo.transverse.exception.ProxyAuthenticationException; 9 import fr.mael.jiwigo.transverse.session.SessionManager;10 8 11 /* 12 * jiwigo-ws-api Piwigo webservice access Api 13 * Copyright (c) 2010-2011 Mael mael@le-guevel.com 14 * All Rights Reserved 15 * 16 * This library is free software. It comes without any warranty, to 17 * the extent permitted by applicable law. You can redistribute it 18 * and/or modify it under the terms of the Do What The Fuck You Want 19 * To Public License, Version 2, as published by Sam Hocevar. See 20 * http://sam.zoy.org/wtfpl/COPYING for more details. 21 */ 22 /** 23 24 * @author mael 25 * 26 */ 27 public class CategoryService { 28 /** 29 * Logger 30 */ 31 public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory 32 .getLog(CategoryService.class); 33 34 /** 35 * singleton 36 */ 37 private static CategoryService instance; 38 39 private SessionManager sessionManager; 40 41 /** 42 * @return the singleton 43 */ 44 public static CategoryService getInstance(SessionManager sessionManager) { 45 if (instance == null) { 46 instance = new CategoryService(sessionManager); 47 } 48 return instance; 49 } 50 51 /** 52 * private constructor to use a singleton 53 */ 54 private CategoryService(SessionManager sessionManager) { 55 this.sessionManager = sessionManager; 56 57 } 58 9 public interface CategoryService { 59 10 /** 60 11 * Lists all categories … … 64 15 * @throws ProxyAuthenticationException 65 16 */ 66 public List<Category> list(boolean recursive) throws IOException, ProxyAuthenticationException { 67 return CategoryDao.getInstance(sessionManager).list(recursive); 68 } 17 public List<Category> list(boolean recursive) throws IOException, ProxyAuthenticationException; 69 18 70 19 /** … … 74 23 * @throws ProxyAuthenticationException 75 24 */ 76 public List<Category> makeTree() throws IOException, ProxyAuthenticationException { 77 List<Category> list = CategoryDao.getInstance(sessionManager).list(true); 78 for (Category category : list) { 79 for (Category category2 : list) { 80 if (category2.getIdParentCategories().size() != 1 81 && category.getIdentifier().equals( 82 category2.getIdParentCategories().get(category2.getIdParentCategories().size() - 2))) { 83 category.getChildCategories().add(category2); 84 category2.getParentCategories().add(category); 85 } 86 87 } 88 } 89 90 return list; 91 92 } 25 public List<Category> makeTree() throws IOException, ProxyAuthenticationException; 93 26 94 27 /** … … 99 32 * @throws ProxyAuthenticationException 100 33 */ 101 public boolean create(String nom, Integer parent) throws ProxyAuthenticationException { 102 Category category = new Category(); 103 category.setDirectParent(parent); 104 category.setName(nom); 105 return CategoryDao.getInstance(sessionManager).create(category); 106 } 34 public boolean create(String nom, Integer parent) throws ProxyAuthenticationException; 107 35 108 36 /** … … 112 40 * @throws ProxyAuthenticationException 113 41 */ 114 public boolean create(String nom) throws ProxyAuthenticationException { 115 Category category = new Category(); 116 category.setName(nom); 117 return CategoryDao.getInstance(sessionManager).create(category); 118 } 42 public boolean create(String nom) throws ProxyAuthenticationException; 119 43 }
Note: See TracChangeset
for help on using the changeset viewer.