Author: amarkhel
Date: 2009-05-19 13:28:16 -0400 (Tue, 19 May 2009)
New Revision: 14243
Added:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/ISearchAction.java
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/ISearchStrategy.java
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchAction.java
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchBothAlbumsStrategy.java
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchBothImagesStrategy.java
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchBothShelvesStrategy.java
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchEntityEnum.java
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchMetatagsStrategy.java
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchMyAlbumsStrategy.java
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchMyImagesStrategy.java
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchMyShelvesStrategy.java
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchQueryFactory.java
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchSharedAlbumsStrategy.java
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchSharedImagesStrategy.java
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchSharedShelvesStrategy.java
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchUserStrategy.java
Removed:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/ISearchAction.java
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/SearchAction.java
Modified:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/Album.java
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/Shelf.java
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/Constants.java
Log:
Modified:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/Album.java
===================================================================
---
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/Album.java 2009-05-19
17:27:59 UTC (rev 14242)
+++
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/Album.java 2009-05-19
17:28:16 UTC (rev 14243)
@@ -80,7 +80,7 @@
@OneToOne(fetch = FetchType.LAZY)
private Image coveringImage;
- @Temporal(TemporalType.TIMESTAMP)
+ @Temporal(TemporalType.DATE)
private Date created;
@Column(length = 255, nullable = false)
Modified:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/Shelf.java
===================================================================
---
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/Shelf.java 2009-05-19
17:27:59 UTC (rev 14242)
+++
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/Shelf.java 2009-05-19
17:28:16 UTC (rev 14243)
@@ -56,7 +56,7 @@
@NotNull
private boolean shared;
- @Temporal(TemporalType.TIMESTAMP)
+ @Temporal(TemporalType.DATE)
private Date created;
/**
Added:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/ISearchAction.java
===================================================================
---
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/ISearchAction.java
(rev 0)
+++
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/ISearchAction.java 2009-05-19
17:28:16 UTC (rev 14243)
@@ -0,0 +1,51 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.photoalbum.search;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.richfaces.photoalbum.domain.Album;
+import org.richfaces.photoalbum.domain.Image;
+import org.richfaces.photoalbum.domain.MetaTag;
+import org.richfaces.photoalbum.domain.Shelf;
+import org.richfaces.photoalbum.domain.User;
+import org.richfaces.photoalbum.service.PhotoAlbumException;
+
+/**
+ * Interface for search actions
+ *
+ * @author Andrey Markhel
+ */
+@Local
+public interface ISearchAction {
+ public List<Image> searchByImage(String query, boolean searchInMyAlbums, boolean
searchInShared) throws PhotoAlbumException;
+
+ public List<MetaTag> searchByTags(String query, boolean searchInMyAlbums, boolean
searchInShared) throws PhotoAlbumException;
+
+ public List<Album> searchByAlbum(String query, boolean searchInMyAlbums, boolean
searchInShared) throws PhotoAlbumException;
+
+ public List<User> searchByUsers(String query, boolean searchInMyAlbums, boolean
searchInShared) throws PhotoAlbumException;
+
+ public List<Shelf> searchByShelves(String query,boolean searchInMyAlbums, boolean
searchInShared) throws PhotoAlbumException;
+
+}
Property changes on:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/ISearchAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/ISearchStrategy.java
===================================================================
---
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/ISearchStrategy.java
(rev 0)
+++
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/ISearchStrategy.java 2009-05-19
17:28:16 UTC (rev 14243)
@@ -0,0 +1,56 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.photoalbum.search;
+
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+/**
+ * Generic interface for determine what query need for particular entity and other
parameters
+ *
+ *
+ * @author Andrey Markhel
+ */
+public interface ISearchStrategy {
+
+ public abstract Query getQuery(EntityManager em, Map<String, Object> params,
String name);
+}
Property changes on:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/ISearchStrategy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchAction.java
===================================================================
---
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchAction.java
(rev 0)
+++
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchAction.java 2009-05-19
17:28:16 UTC (rev 14243)
@@ -0,0 +1,166 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.photoalbum.search;
+
+import java.util.List;
+
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.jboss.seam.annotations.AutoCreate;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.richfaces.photoalbum.domain.Album;
+import org.richfaces.photoalbum.domain.Image;
+import org.richfaces.photoalbum.domain.MetaTag;
+import org.richfaces.photoalbum.domain.Shelf;
+import org.richfaces.photoalbum.domain.User;
+import org.richfaces.photoalbum.service.Constants;
+import org.richfaces.photoalbum.service.PhotoAlbumException;
+
+/**
+ * This class is entry point to retrieve search result
+ * EJB3 Bean
+ *
+ * @author Andrey Markhel
+ */
+
+@Name("searchAction")
+@Stateless
+@AutoCreate
+@SuppressWarnings("unchecked")
+public class SearchAction implements ISearchAction {
+
+ @In(value="entityManager")
+ EntityManager em;
+
+ @In SearchQueryFactory searchQueryFactory;
+
+ @In private User user;
+
+ /**
+ * Return List of albums, founded by query
+ * Search albums by name and description(like)
+ * @param searchQuery - string to search
+ * @param searchInMyAlbums - determine is search will be making by only user's
albums
+ * @param searchInShared - determine is search will be making in only shared albums
+ * @return list of founded albums
+ * @throws PhotoAlbumException if search parameter is wrong
+ */
+ public List<Album> searchByAlbum(String searchQuery, boolean searchInMyAlbums,
boolean searchInShared) throws PhotoAlbumException {
+ Query query = searchQueryFactory.getQuery(SearchEntityEnum.ALBUM, user, searchInShared,
searchInMyAlbums, searchQuery);
+ if(null == query){
+ throw new PhotoAlbumException(Constants.WRONG_SEARCH_PARAMETERS_ERROR);
+ }
+ return (List<Album>)query.getResultList();
+ }
+
+ /**
+ * Return List of images, founded by query
+ * Search images by name and description(like)
+ * @param searchQuery - string to search
+ * @param searchInMyAlbums - determine is search will be making by only user's
images
+ * @param searchInShared - determine is search will be making in only shared images
+ * @return list of founded images
+ * @throws PhotoAlbumException if search parameter is wrong
+ */
+ public List<Image> searchByImage(String searchQuery, boolean searchInMyAlbums,
boolean searchInShared) throws PhotoAlbumException {
+ Query query = searchQueryFactory.getQuery(SearchEntityEnum.IMAGE, user, searchInShared,
searchInMyAlbums, searchQuery);
+ if(null == query){
+ throw new PhotoAlbumException(Constants.WRONG_SEARCH_PARAMETERS_ERROR);
+ }
+ return (List<Image>)query.getResultList();
+ }
+
+ /**
+ * Return List of users, founded by query
+ * Search users by login, firstname and secondname(like)
+ * @param searchQuery - string to search
+ * @param searchInMyAlbums - unused
+ * @param searchInShared - unused
+ * @return list of founded users
+ * @throws PhotoAlbumException if search parameter is wrong
+ */
+ public List<User> searchByUsers(String searchQuery, boolean searchInMyAlbums,
boolean searchInShared) throws PhotoAlbumException {
+ Query query = searchQueryFactory.getQuery(SearchEntityEnum.USER, user, searchInShared,
searchInMyAlbums, searchQuery);
+ if(null == query){
+ throw new PhotoAlbumException(Constants.WRONG_SEARCH_PARAMETERS_ERROR);
+ }
+ return (List<User>)query.getResultList();
+ }
+
+ /**
+ * Return List of metatags, founded by query
+ * Search users by tagname(like)
+ * @param searchQuery - string to search
+ * @param searchInMyAlbums - unused
+ * @param searchInShared - unused
+ * @return list of founded metatags
+ * @throws PhotoAlbumException if search parameter is wrong
+ */
+ public List<MetaTag> searchByTags(String searchQuery, boolean searchInMyAlbums,
boolean searchInShared) throws PhotoAlbumException {
+ Query query = searchQueryFactory.getQuery(SearchEntityEnum.METATAG, user,
searchInShared, searchInMyAlbums, searchQuery);
+ if(null == query){
+ throw new PhotoAlbumException(Constants.WRONG_SEARCH_PARAMETERS_ERROR);
+ }
+ return (List<MetaTag>)query.getResultList();
+ }
+
+ /**
+ * Return List of shelves, founded by query
+ * Search images by name and description(like)
+ * @param searchQuery - string to search
+ * @param searchInMyAlbums - determine is search will be making by only user's
shelves
+ * @param searchInShared - determine is search will be making in only shared shelves
+ * @return list of founded images
+ * @throws PhotoAlbumException if search parameter is wrong
+ */
+ public List<Shelf> searchByShelves(String searchQuery, boolean searchInMyAlbums,
+ boolean searchInShared) throws PhotoAlbumException {
+ Query query = searchQueryFactory.getQuery(SearchEntityEnum.SHELF, user, searchInShared,
searchInMyAlbums, searchQuery);
+ if(null == query){
+ throw new PhotoAlbumException(Constants.WRONG_SEARCH_PARAMETERS_ERROR);
+ }
+ return (List<Shelf>)query.getResultList();
+ }
+
+}
\ No newline at end of file
Property changes on:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchBothAlbumsStrategy.java
===================================================================
---
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchBothAlbumsStrategy.java
(rev 0)
+++
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchBothAlbumsStrategy.java 2009-05-19
17:28:16 UTC (rev 14243)
@@ -0,0 +1,55 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.photoalbum.search;
+
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.richfaces.photoalbum.domain.User;
+import org.richfaces.photoalbum.service.Constants;
+/**
+ * Strategy to retrieve albums, that are shared or belongs to user, that perform search
+ *
+ * @author Andrey Markhel
+ */
+public class SearchBothAlbumsStrategy implements ISearchStrategy {
+ /**
+ * Create query to retrieve albums, that are shared or belongs to user, that perform
search
+ *
+ * @param em - entityManager
+ * @param params - map of additional params for this query
+ * @param searchQuery - string to search
+ * @return List of albums that are shared or belongs to user, that perform search
+ */
+ public Query getQuery(EntityManager em, Map<String, Object> params, String
searchQuery) {
+ Query query = em.createQuery(Constants.SEARCH_ALBUM_QUERY +
Constants.SEARCH_ALBUM_BOTH_ADDON);
+ query.setParameter(Constants.QUERY_PARAMETER, Constants.PERCENT +
searchQuery.toLowerCase() + Constants.PERCENT);
+ User user = (User)params.get(Constants.USER_PARAMETER);
+ if(null == user){
+ return null;
+ }
+ query.setParameter(Constants.LOGIN_PARAMETER, user.getLogin());
+ return query;
+ }
+
+}
Property changes on:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchBothAlbumsStrategy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchBothImagesStrategy.java
===================================================================
---
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchBothImagesStrategy.java
(rev 0)
+++
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchBothImagesStrategy.java 2009-05-19
17:28:16 UTC (rev 14243)
@@ -0,0 +1,55 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.photoalbum.search;
+
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.richfaces.photoalbum.domain.User;
+import org.richfaces.photoalbum.service.Constants;
+/**
+ * Strategy to retrieve images, that are shared or belongs to user, that perform search
+ *
+ * @author Andrey Markhel
+ */
+public class SearchBothImagesStrategy implements ISearchStrategy {
+ /**
+ * Create query to retrieve images, that are shared or belongs to user, that perform
search
+ *
+ * @param em - entityManager
+ * @param params - map of additional params for this query
+ * @param searchQuery - string to search
+ * @return List of images that are shared or belongs to user, that perform search
+ */
+ public Query getQuery(EntityManager em, Map<String, Object> params, String
searchQuery) {
+ Query query = em.createQuery(Constants.SEARCH_IMAGE_QUERY +
Constants.SEARCH_IMAGE_BOTH_ADDON);
+ query.setParameter(Constants.QUERY_PARAMETER, Constants.PERCENT +
searchQuery.toLowerCase() + Constants.PERCENT);
+ User user = (User)params.get(Constants.USER_PARAMETER);
+ if(null == user){
+ return null;
+ }
+ query.setParameter(Constants.LOGIN_PARAMETER, user.getLogin());
+ return query;
+ }
+
+}
Property changes on:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchBothImagesStrategy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchBothShelvesStrategy.java
===================================================================
---
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchBothShelvesStrategy.java
(rev 0)
+++
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchBothShelvesStrategy.java 2009-05-19
17:28:16 UTC (rev 14243)
@@ -0,0 +1,55 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.photoalbum.search;
+
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.richfaces.photoalbum.domain.User;
+import org.richfaces.photoalbum.service.Constants;
+/**
+ * Strategy to retrieve shelves, that are shared or belongs to user, that perform search
+ *
+ * @author Andrey Markhel
+ */
+public class SearchBothShelvesStrategy implements ISearchStrategy {
+ /**
+ * Create query to retrieve shelves, that are shared or belongs to user, that perform
search
+ *
+ * @param em - entityManager
+ * @param params - map of additional params for this query
+ * @param searchQuery - string to search
+ * @return List of shelves that are shared or belongs to user, that perform search
+ */
+ public Query getQuery(EntityManager em, Map<String, Object> params, String
searchQuery) {
+ Query query = em.createQuery(Constants.SEARCH_SHELVES_QUERY +
Constants.SEARCH_SHELF_BOTH_ADDON);
+ query.setParameter(Constants.QUERY_PARAMETER, Constants.PERCENT +
searchQuery.toLowerCase() + Constants.PERCENT);
+ User user = (User)params.get(Constants.USER_PARAMETER);
+ if(null == user){
+ return null;
+ }
+ query.setParameter(Constants.LOGIN_PARAMETER, user.getLogin());
+ return query;
+ }
+
+}
Property changes on:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchBothShelvesStrategy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchEntityEnum.java
===================================================================
---
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchEntityEnum.java
(rev 0)
+++
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchEntityEnum.java 2009-05-19
17:28:16 UTC (rev 14243)
@@ -0,0 +1,29 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.photoalbum.search;
+/**
+ * This enumeration represent all possible entities for search
+ *
+ * @author Andrey Markhel
+ */
+public enum SearchEntityEnum {
+ USER,SHELF,ALBUM,IMAGE,METATAG;
+}
Property changes on:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchEntityEnum.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchMetatagsStrategy.java
===================================================================
---
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchMetatagsStrategy.java
(rev 0)
+++
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchMetatagsStrategy.java 2009-05-19
17:28:16 UTC (rev 14243)
@@ -0,0 +1,50 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.photoalbum.search;
+
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.richfaces.photoalbum.service.Constants;
+/**
+ * Strategy to retrieve metatags
+ *
+ * @author Andrey Markhel
+ */
+public class SearchMetatagsStrategy implements ISearchStrategy {
+ /**
+ * Create query to retrieve metatags
+ *
+ * @param em - entityManager
+ * @param params - map of additional params for this query
+ * @param searchQuery - string to search
+ * @return List of metatags
+ */
+ public Query getQuery(EntityManager em, Map<String, Object> params,
+ String searchQuery) {
+ Query query = em.createQuery(Constants.SEARCH_METATAG_QUERY);
+ query.setParameter(Constants.QUERY_PARAMETER, Constants.PERCENT +
searchQuery.toLowerCase() + Constants.PERCENT);
+ return query;
+ }
+
+}
Property changes on:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchMetatagsStrategy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchMyAlbumsStrategy.java
===================================================================
---
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchMyAlbumsStrategy.java
(rev 0)
+++
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchMyAlbumsStrategy.java 2009-05-19
17:28:16 UTC (rev 14243)
@@ -0,0 +1,55 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.photoalbum.search;
+
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.richfaces.photoalbum.domain.User;
+import org.richfaces.photoalbum.service.Constants;
+/**
+ * Strategy to retrieve albums, that belongs to user, that perform search
+ *
+ * @author Andrey Markhel
+ */
+public class SearchMyAlbumsStrategy implements ISearchStrategy {
+ /**
+ * Create query to retrieve albums, that belongs to user, that perform search
+ *
+ * @param em - entityManager
+ * @param params - map of additional params for this query
+ * @param searchQuery - string to search
+ * @return List of albums, that belongs to user, that perform search
+ */
+ public Query getQuery(EntityManager em, Map<String, Object> params, String
searchQuery) {
+ Query query = em.createQuery(Constants.SEARCH_ALBUM_QUERY +
Constants.SEARCH_ALBUM_MY_ADDON);
+ query.setParameter(Constants.QUERY_PARAMETER, Constants.PERCENT +
searchQuery.toLowerCase() + Constants.PERCENT);
+ User user = (User)params.get(Constants.USER_PARAMETER);
+ if(null == user){
+ return null;
+ }
+ query.setParameter(Constants.LOGIN_PARAMETER, user.getLogin());
+ return query;
+ }
+
+}
Property changes on:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchMyAlbumsStrategy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchMyImagesStrategy.java
===================================================================
---
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchMyImagesStrategy.java
(rev 0)
+++
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchMyImagesStrategy.java 2009-05-19
17:28:16 UTC (rev 14243)
@@ -0,0 +1,54 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.photoalbum.search;
+
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.richfaces.photoalbum.domain.User;
+import org.richfaces.photoalbum.service.Constants;
+/**
+ * Strategy to retrieve images, that belongs to user, that perform search
+ *
+ * @author Andrey Markhel
+ */
+public class SearchMyImagesStrategy implements ISearchStrategy {
+ /**
+ * Create query to retrieve images, that belongs to user, that perform search
+ *
+ * @param em - entityManager
+ * @param params - map of additional params for this query
+ * @param searchQuery - string to search
+ * @return List of images, that belongs to user, that perform search
+ */
+ public Query getQuery(EntityManager em, Map<String, Object> params, String
searchQuery) {
+ Query query = em.createQuery(Constants.SEARCH_IMAGE_QUERY +
Constants.SEARCH_IMAGE_MY_ADDON);
+ query.setParameter(Constants.QUERY_PARAMETER, Constants.PERCENT +
searchQuery.toLowerCase() + Constants.PERCENT);
+ User user = (User)params.get(Constants.USER_PARAMETER);
+ if(null == user){
+ return null;
+ }
+ query.setParameter(Constants.LOGIN_PARAMETER, user.getLogin());
+ return query;
+ }
+}
Property changes on:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchMyImagesStrategy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchMyShelvesStrategy.java
===================================================================
---
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchMyShelvesStrategy.java
(rev 0)
+++
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchMyShelvesStrategy.java 2009-05-19
17:28:16 UTC (rev 14243)
@@ -0,0 +1,55 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.photoalbum.search;
+
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.richfaces.photoalbum.domain.User;
+import org.richfaces.photoalbum.service.Constants;
+/**
+ * Strategy to retrieve shelves, that belongs to user, that perform search
+ *
+ * @author Andrey Markhel
+ */
+public class SearchMyShelvesStrategy implements ISearchStrategy {
+ /**
+ * Create query to retrieve shelves, that belongs to user, that perform search
+ *
+ * @param em - entityManager
+ * @param params - map of additional params for this query
+ * @param searchQuery - string to search
+ * @return List of shelves, that belongs to user, that perform search
+ */
+ public Query getQuery(EntityManager em, Map<String, Object> params,
+ String searchQuery) {
+ Query query = em.createQuery(Constants.SEARCH_SHELVES_QUERY +
Constants.SEARCH_SHELF_MY_ADDON);
+ query.setParameter(Constants.QUERY_PARAMETER, Constants.PERCENT +
searchQuery.toLowerCase() + Constants.PERCENT);
+ User user = (User)params.get(Constants.USER_PARAMETER);
+ if(null == user){
+ return null;
+ }
+ query.setParameter(Constants.LOGIN_PARAMETER, user.getLogin());
+ return query;
+ }
+}
Property changes on:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchMyShelvesStrategy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchQueryFactory.java
===================================================================
---
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchQueryFactory.java
(rev 0)
+++
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchQueryFactory.java 2009-05-19
17:28:16 UTC (rev 14243)
@@ -0,0 +1,110 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.photoalbum.search;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.Startup;
+import org.richfaces.photoalbum.domain.User;
+import org.richfaces.photoalbum.service.Constants;
+import org.richfaces.photoalbum.service.PhotoAlbumException;
+/**
+ * This class is factory to retrieve query object, dependent of type of searched entity
and other parameters
+ *
+ * @author Andrey Markhel
+ */
+@Name("searchQueryFactory")
+(a)Scope(ScopeType.APPLICATION)
+@Startup
+public class SearchQueryFactory {
+ @In(value="entityManager")
+ EntityManager em;
+ /**
+ * This method is return query object,that dependent of type of searched entity and
other parameters
+ *
+ * @param entity - one of instances from SearchEntityEnum enumeration, indicate waht
type of entities user want to search
+ * @param user - user, that perform search
+ * @param searchInMy - boolean parameter that indicate, is user want search in her
space
+ * @param searchInShared - boolean parameter that indicate, is user want search in all
shared entities
+ * @param queryString - string to search
+ * @throws PhotoAlbumException - in case of wrong search parameters
+ * @return query object, that dependent of type of searched entity and other parameters
+ */
+ public Query getQuery(SearchEntityEnum entity, User user, boolean searchInShared,
boolean searchInMy, String queryString) throws PhotoAlbumException{
+ ISearchStrategy strategy = null;
+ Map<String, Object> parameters = new HashMap<String, Object>();
+ parameters.put(Constants.USER_PARAMETER, user);
+ switch(entity){
+ case USER:{
+ strategy = new SearchUserStrategy();break;
+ }
+ case SHELF:{
+ if(searchInShared && searchInMy){
+ strategy = new SearchBothShelvesStrategy();
+ }else if(searchInShared){
+ strategy = new SearchSharedShelvesStrategy();
+ }else if(searchInMy){
+ strategy = new SearchMyShelvesStrategy();
+ }else{
+ throw new PhotoAlbumException(Constants.WRONG_SEARCH_PARAMETERS_ERROR);
+ }
+ break;
+ }
+ case ALBUM:{
+ if(searchInShared && searchInMy){
+ strategy = new SearchBothAlbumsStrategy();
+ }else if(searchInShared){
+ strategy = new SearchSharedAlbumsStrategy();
+ }else if(searchInMy){
+ strategy = new SearchMyAlbumsStrategy();
+ }else{
+ throw new PhotoAlbumException(Constants.WRONG_SEARCH_PARAMETERS_ERROR);
+ }
+ break;
+ }
+ case IMAGE:{
+ if(searchInShared && searchInMy){
+ strategy = new SearchBothImagesStrategy();
+ }else if(searchInShared){
+ strategy = new SearchSharedImagesStrategy();
+ }else if(searchInMy){
+ strategy = new SearchMyImagesStrategy();
+ }else{
+ throw new PhotoAlbumException(Constants.WRONG_SEARCH_PARAMETERS_ERROR);
+ }
+ break;
+ }
+ case METATAG:{
+ strategy = new SearchMetatagsStrategy();break;
+ }
+ default: throw new PhotoAlbumException(Constants.WRONG_SEARCH_PARAMETERS_ERROR);
+ }
+ return strategy.getQuery(em, parameters, queryString);
+ }
+}
Property changes on:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchQueryFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchSharedAlbumsStrategy.java
===================================================================
---
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchSharedAlbumsStrategy.java
(rev 0)
+++
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchSharedAlbumsStrategy.java 2009-05-19
17:28:16 UTC (rev 14243)
@@ -0,0 +1,49 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.photoalbum.search;
+
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.richfaces.photoalbum.service.Constants;
+/**
+ * Strategy to retrieve albums, that are shared
+ *
+ * @author Andrey Markhel
+ */
+public class SearchSharedAlbumsStrategy implements ISearchStrategy {
+ /**
+ * Create query to retrieve albums, that are shared
+ *
+ * @param em - entityManager
+ * @param params - map of additional params for this query
+ * @param searchQuery - string to search
+ * @return List of albums that are shared
+ */
+ public Query getQuery(EntityManager em, Map<String, Object> params, String
searchQuery) {
+ Query query = em.createQuery(Constants.SEARCH_ALBUM_QUERY +
Constants.SEARCH_ALBUM_SHARED_ADDON);
+ query.setParameter(Constants.QUERY_PARAMETER, Constants.PERCENT +
searchQuery.toLowerCase() + Constants.PERCENT);
+ return query;
+ }
+
+}
Property changes on:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchSharedAlbumsStrategy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchSharedImagesStrategy.java
===================================================================
---
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchSharedImagesStrategy.java
(rev 0)
+++
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchSharedImagesStrategy.java 2009-05-19
17:28:16 UTC (rev 14243)
@@ -0,0 +1,48 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.photoalbum.search;
+
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.richfaces.photoalbum.service.Constants;
+/**
+ * Strategy to retrieve images, that are shared
+ *
+ * @author Andrey Markhel
+ */
+public class SearchSharedImagesStrategy implements ISearchStrategy {
+ /**
+ * Create query to retrieve images, that are shared
+ *
+ * @param em - entityManager
+ * @param params - map of additional params for this query
+ * @param searchQuery - string to search
+ * @return List of images that are shared
+ */
+ public Query getQuery(EntityManager em, Map<String, Object> params, String
searchQuery) {
+ Query query = em.createQuery(Constants.SEARCH_IMAGE_QUERY +
Constants.SEARCH_IMAGE_SHARED_ADDON);
+ query.setParameter(Constants.QUERY_PARAMETER, Constants.PERCENT +
searchQuery.toLowerCase() + Constants.PERCENT);
+ return query;
+ }
+}
Property changes on:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchSharedImagesStrategy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchSharedShelvesStrategy.java
===================================================================
---
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchSharedShelvesStrategy.java
(rev 0)
+++
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchSharedShelvesStrategy.java 2009-05-19
17:28:16 UTC (rev 14243)
@@ -0,0 +1,48 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.photoalbum.search;
+
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.richfaces.photoalbum.service.Constants;
+/**
+ * Strategy to retrieve shelves, that are shared
+ *
+ * @author Andrey Markhel
+ */
+public class SearchSharedShelvesStrategy implements ISearchStrategy {
+ /**
+ * Create query to retrieve shelves, that are shared
+ *
+ * @param em - entityManager
+ * @param params - map of additional params for this query
+ * @param searchQuery - string to search
+ * @return List of shelves that are shared
+ */
+ public Query getQuery(EntityManager em, Map<String, Object> params, String
searchQuery) {
+ Query query = em.createQuery(Constants.SEARCH_SHELVES_QUERY +
Constants.SEARCH_SHELF_SHARED_ADDON);
+ query.setParameter(Constants.QUERY_PARAMETER, Constants.PERCENT +
searchQuery.toLowerCase() + Constants.PERCENT);
+ return query;
+ }
+}
Property changes on:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchSharedShelvesStrategy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchUserStrategy.java
===================================================================
---
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchUserStrategy.java
(rev 0)
+++
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchUserStrategy.java 2009-05-19
17:28:16 UTC (rev 14243)
@@ -0,0 +1,49 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.photoalbum.search;
+
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.richfaces.photoalbum.service.Constants;
+/**
+ * Strategy to retrieve users
+ *
+ * @author Andrey Markhel
+ */
+public class SearchUserStrategy implements ISearchStrategy {
+ /**
+ * Create query to retrieve users
+ *
+ * @param em - entityManager
+ * @param params - map of additional params for this query
+ * @param searchQuery - string to search
+ * @return List of users
+ */
+ public Query getQuery(EntityManager em, Map<String, Object> params, String
searchQuery) {
+ Query query = em.createQuery(Constants.SEARCH_USERS_QUERY);
+ query.setParameter(Constants.QUERY_PARAMETER, Constants.PERCENT +
searchQuery.toLowerCase() + Constants.PERCENT);
+ return query;
+ }
+
+}
Property changes on:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/search/SearchUserStrategy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/Constants.java
===================================================================
---
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/Constants.java 2009-05-19
17:27:59 UTC (rev 14242)
+++
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/Constants.java 2009-05-19
17:28:16 UTC (rev 14243)
@@ -53,6 +53,7 @@
public static final String USER_DELETED_EVENT = "userDeletedEvent";
//Errors(Internationalization pending)
+ public static final String WRONG_SEARCH_PARAMETERS_ERROR = "Wrong search
parameters";
public static final String YOU_ALREADY_DOWNLOAD_MANY_COPIES_OF_THIS_IMAGE_ERROR =
"You already download 256 copies of this image. Please specify another name for
uploaded image";
public static final String SAME_IMAGE_EXIST_ERROR = "You already have an image with
the given name in selected album";
public static final String SAME_ALBUM_EXIST_ERROR = "You already have an album with
the given name in selected shelf";
@@ -156,19 +157,22 @@
public static final String TAG_POPULAR_QUERY = "tag-popular";
public static final String TAG_PARAMETER = "tag";
public static final String TAG_BY_NAME_QUERY = "tag-byName";
- public static final String SEARCH_QUERY_SHARED_ADDON = " and sh.shared=true";
- public static final String SEARCH_QUERY_MY_ADDON = " and
sh.owner.login=:login";
- public static final String SEARCH_SHELVES_QUERY = "from Shelf sh where
(lower(sh.name) like :name or lower(sh.description) like :name) ";
- public static final String SEARCH_METATAG_QUERY = "from MetaTag t where
lower(t.tag) like :name";
- public static final String SEARCH_USERS_QUERY = "select u from User u where
(lower(u.login) like :name or lower(u.firstName) like :name or lower(u.secondName) like
:name) ";
+ public static final String SEARCH_SHELF_SHARED_ADDON = " and sh.shared=true";
+ public static final String SEARCH_SHELF_MY_ADDON = " and
sh.owner.login=:login";
+ public static final String SEARCH_SHELF_BOTH_ADDON = " and sh.shared=true or
sh.owner.login=:login";
+ public static final String SEARCH_SHELVES_QUERY = "from Shelf sh where
(lower(sh.name) like :queryString or lower(sh.description) like :queryString) ";
+ public static final String SEARCH_METATAG_QUERY = "from MetaTag t where
lower(t.tag) like :queryString";
+ public static final String SEARCH_USERS_QUERY = "select u from User u where
(lower(u.login) like :queryString or lower(u.firstName) like :queryString or
lower(u.secondName) like :queryString) ";
public static final String SEARCH_IMAGE_SHARED_ADDON = " and
i.album.shelf.shared=true";
public static final String SEARCH_IMAGE_MY_ADDON = " and
i.album.shelf.owner.login=:login";
- public static final String SEARCH_IMAGE_QUERY = "from Image i where (lower(i.name)
like :name or lower(i.description) like :name or lower(i.cameraModel) like :name) ";
+ public static final String SEARCH_IMAGE_BOTH_ADDON = " and
i.album.shelf.shared=true or i.album.shelf.owner.login=:login";
+ public static final String SEARCH_IMAGE_QUERY = "from Image i where (lower(i.name)
like :queryString or lower(i.description) like :queryString or lower(i.cameraModel) like
:queryString) ";
public static final String SHARED_PARAMETER = "shared";
- public static final String NAME_PARAMETER = "name";
+ public static final String QUERY_PARAMETER = "queryString";
public static final String SEARCH_ALBUM_SHARED_ADDON = " and
a.shelf.shared=true";
public static final String SEARCH_ALBUM_MY_ADDON = " and
a.shelf.owner.login=:login";
- public static final String SEARCH_ALBUM_QUERY = "from Album a where (lower(a.name)
like :name or lower(a.description) like :name)";
+ public static final String SEARCH_ALBUM_BOTH_ADDON = " and a.shelf.shared=true or
a.shelf.owner.login=:login";
+ public static final String SEARCH_ALBUM_QUERY = "from Album a where (lower(a.name)
like :queryString or lower(a.description) like :queryString)";
public static final String USER_SHELVES_QUERY = "user-shelves";
public static final String SHELF_PARAMETER = "shelf";
public static final String PATH_PARAMETER = "path";
@@ -176,6 +180,7 @@
public static final String IMAGE_IDENTICAL_QUERY =
"image-countIdenticalImages";
public static final String SEARCH_NO_OPTIONS_ERROR = "You must select at least one
search option";
public static final String TREE_ID = "treeform";
+ public static final String MAINAREA_ID = "mainform:mainArea";
public static final String USER_COMMENTS_QUERY = "user-comments";
public static final String AUTHOR_PARAMETER = "author";
public static final String EMAIL_EXIST_QUERY = "email-exist";
Deleted:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/ISearchAction.java
===================================================================
---
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/ISearchAction.java 2009-05-19
17:27:59 UTC (rev 14242)
+++
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/ISearchAction.java 2009-05-19
17:28:16 UTC (rev 14243)
@@ -1,50 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.photoalbum.service;
-
-import java.util.List;
-
-import javax.ejb.Local;
-
-import org.richfaces.photoalbum.domain.Album;
-import org.richfaces.photoalbum.domain.Image;
-import org.richfaces.photoalbum.domain.MetaTag;
-import org.richfaces.photoalbum.domain.Shelf;
-import org.richfaces.photoalbum.domain.User;
-
-/**
- * Interface for search actions
- *
- * @author Andrey Markhel
- */
-@Local
-public interface ISearchAction {
- public List<Image> searchByImage(String query, boolean searchInMyAlbums, boolean
searchInShared);
-
- public List<MetaTag> searchByTags(String query, boolean searchInMyAlbums, boolean
searchInShared);
-
- public List<Album> searchByAlbum(String query, boolean searchInMyAlbums, boolean
searchInShared);
-
- public List<User> searchByUsers(String query, boolean searchInMyAlbums, boolean
searchInShared);
-
- public List<Shelf> searchByShelves(String query,boolean searchInMyAlbums, boolean
searchInShared);
-
-}
Deleted:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/SearchAction.java
===================================================================
---
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/SearchAction.java 2009-05-19
17:27:59 UTC (rev 14242)
+++
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/SearchAction.java 2009-05-19
17:28:16 UTC (rev 14243)
@@ -1,184 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.photoalbum.service;
-
-import java.util.List;
-
-import javax.ejb.Stateless;
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-
-import org.jboss.seam.annotations.AutoCreate;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.richfaces.photoalbum.domain.Album;
-import org.richfaces.photoalbum.domain.Image;
-import org.richfaces.photoalbum.domain.MetaTag;
-import org.richfaces.photoalbum.domain.Shelf;
-import org.richfaces.photoalbum.domain.User;
-
-/**
- * Search Builder
- * EJB3 Bean
- *
- * @author Andrey Markhel
- */
-
-@Name("searchAction")
-@Stateless
-@AutoCreate
-@SuppressWarnings("unchecked")
-public class SearchAction implements ISearchAction {
-
- @In(value="entityManager")
- EntityManager em;
-
- @In private User user;
-
- /**
- * Return List of albums, founded by query
- * Search albums by name and description(like)
- * @param searchQuery - string to search
- * @param searchInMyAlbums - determine is search will be making by only user's
albums
- * @param searchInShared - determine is search will be making in only shared albums
- * @return list of founded albums
- */
- public List<Album> searchByAlbum(String searchQuery, boolean searchInMyAlbums,
boolean searchInShared) {
- StringBuilder b = new StringBuilder(Constants.SEARCH_ALBUM_QUERY);
- //If we search in user's albums
- if (searchInMyAlbums) {
- b.append(Constants.SEARCH_ALBUM_MY_ADDON);
- }
- //If we search only in shared albums
- if(searchInShared){
- b.append(Constants.SEARCH_ALBUM_SHARED_ADDON);
- }
- //Create query
- Query query = em.createQuery(b.toString());
- //Set search string
- query.setParameter(Constants.NAME_PARAMETER, Constants.PERCENT +
searchQuery.toLowerCase() + Constants.PERCENT);
- //If we search only in shared albums
- //If we search in user's albums
- if (searchInMyAlbums) {
- query.setParameter(Constants.LOGIN_PARAMETER, user.getLogin());
- }
- //Get result
- return query.getResultList();
- }
-
- /**
- * Return List of images, founded by query
- * Search images by name and description(like)
- * @param searchQuery - string to search
- * @param searchInMyAlbums - determine is search will be making by only user's
images
- * @param searchInShared - determine is search will be making in only shared images
- * @return list of founded images
- */
- public List<Image> searchByImage(String searchQuery, boolean searchInMyAlbums,
boolean searchInShared) {
- StringBuilder b = new StringBuilder(Constants.SEARCH_IMAGE_QUERY);
- //If we search in user's images
- if (searchInMyAlbums) {
- b.append(Constants.SEARCH_IMAGE_MY_ADDON);
- }
- //If we search only in shared images
- if(searchInShared){
- b.append(Constants.SEARCH_IMAGE_SHARED_ADDON);
- }
- //Create query
- Query query = em.createQuery(b.toString());
- //Set search string
- query.setParameter(Constants.NAME_PARAMETER, Constants.PERCENT +
searchQuery.toLowerCase() + Constants.PERCENT);
- //If we search only in shared images
- if (searchInMyAlbums) {
- query.setParameter(Constants.LOGIN_PARAMETER, user.getLogin());
- }
- //Get result
- return query.getResultList();
- }
-
- /**
- * Return List of users, founded by query
- * Search users by login, firstname and secondname(like)
- * @param searchQuery - string to search
- * @param searchInMyAlbums - unused
- * @param searchInShared - unused
- * @return list of founded users
- */
- public List<User> searchByUsers(String searchQuery, boolean searchInMyAlbums,
boolean searchInShared) {
- StringBuilder b = new StringBuilder(Constants.SEARCH_USERS_QUERY);
- //Create query
- Query query = em.createQuery(b.toString());
- //Set search string
- query.setParameter(Constants.NAME_PARAMETER, Constants.PERCENT +
searchQuery.toLowerCase() + Constants.PERCENT);
- //Get result
- return query.getResultList();
- }
-
- /**
- * Return List of metatags, founded by query
- * Search users by tagname(like)
- * @param searchQuery - string to search
- * @param searchInMyAlbums - unused
- * @param searchInShared - unused
- * @return list of founded metatags
- */
- public List<MetaTag> searchByTags(String searchQuery, boolean searchInMyAlbums,
boolean searchInShared) {
- StringBuilder b = new StringBuilder(Constants.SEARCH_METATAG_QUERY);
- //Create query
- Query query = em.createQuery(b.toString());
- //Set search string
- query.setParameter(Constants.NAME_PARAMETER, Constants.PERCENT +
searchQuery.toLowerCase() + Constants.PERCENT);
- //Get result
- return query.getResultList();
- }
-
- /**
- * Return List of shelves, founded by query
- * Search images by name and description(like)
- * @param searchQuery - string to search
- * @param searchInMyAlbums - determine is search will be making by only user's
shelves
- * @param searchInShared - determine is search will be making in only shared shelves
- * @return list of founded images
- */
- public List<Shelf> searchByShelves(String searchQuery, boolean searchInMyAlbums,
- boolean searchInShared) {
- StringBuilder b = new StringBuilder(Constants.SEARCH_SHELVES_QUERY);
- //If we search in user's shelves
- if (searchInMyAlbums) {
- b.append(Constants.SEARCH_QUERY_MY_ADDON);
- }
- //If we search only in shared shelves
- if (searchInShared) {
- b.append(Constants.SEARCH_QUERY_SHARED_ADDON);
- }
- //Create query
- Query query = em.createQuery(b.toString());
- //If we search in user's shelves
- if (searchInMyAlbums) {
- query.setParameter(Constants.LOGIN_PARAMETER, user.getLogin());
- }
- //Set search string
- query.setParameter(Constants.NAME_PARAMETER, Constants.PERCENT +
searchQuery.toLowerCase() + Constants.PERCENT);
- //Get result
- return query.getResultList();
- }
-
-}
\ No newline at end of file