r3815 - in branches/pollen-2.0: . pollen-persistence pollen-persistence/src pollen-persistence/src/license pollen-persistence/src/main pollen-persistence/src/main/java pollen-persistence/src/main/java/org pollen-persistence/src/main/java/org/chorem pollen-persistence/src/main/java/org/chorem/pollen pollen-persistence/src/main/java/org/chorem/pollen/persistence pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao pollen-persistence/src/main/java/org/chorem/pollen/persistence/en
Author: tchemit Date: 2013-06-04 16:47:08 +0200 (Tue, 04 Jun 2013) New Revision: 3815 Url: http://chorem.org/projects/pollen/repository/revisions/3815 Log: refs #885: Design a new Persistence Model API refs #886: Design a REST API layer Added: branches/pollen-2.0/pollen-persistence/ branches/pollen-2.0/pollen-persistence/LICENSE.txt branches/pollen-2.0/pollen-persistence/README.txt branches/pollen-2.0/pollen-persistence/changelog.txt branches/pollen-2.0/pollen-persistence/pom.xml branches/pollen-2.0/pollen-persistence/src/ branches/pollen-2.0/pollen-persistence/src/license/ branches/pollen-2.0/pollen-persistence/src/license/THIRD-PARTY.properties branches/pollen-2.0/pollen-persistence/src/main/ branches/pollen-2.0/pollen-persistence/src/main/java/ branches/pollen-2.0/pollen-persistence/src/main/java/org/ branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/ branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/ branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/ branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/JpaEntityIdGeneratorIfNotEmpty.java branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/JpaPollenPersistenceContext.java branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenPersistenceContext.java branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/ branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/ChoiceDao.java branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/CommentDao.java branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/FavoriteListDao.java branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/PollDao.java branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/PollJpaDao.java branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/PollenUserDao.java branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/PollenUserJpaDao.java branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/VoteDao.java branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/VoterListDao.java branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/VoterListMemberDao.java branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/VoterListMemberJpaDao.java branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/ branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUser.java branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/Polls.java branches/pollen-2.0/pollen-persistence/src/main/resources/ branches/pollen-2.0/pollen-persistence/src/main/resources/META-INF/ branches/pollen-2.0/pollen-persistence/src/main/resources/META-INF/persistence.xml branches/pollen-2.0/pollen-persistence/src/main/xmi/ branches/pollen-2.0/pollen-persistence/src/main/xmi/pollen.properties branches/pollen-2.0/pollen-persistence/src/main/xmi/pollen.zargo branches/pollen-2.0/pollen-persistence/src/test/ branches/pollen-2.0/pollen-persistence/src/test/java/ branches/pollen-2.0/pollen-persistence/src/test/java/org/ branches/pollen-2.0/pollen-persistence/src/test/java/org/chorem/ branches/pollen-2.0/pollen-persistence/src/test/java/org/chorem/pollen/ branches/pollen-2.0/pollen-persistence/src/test/java/org/chorem/pollen/persistence/ branches/pollen-2.0/pollen-persistence/src/test/java/org/chorem/pollen/persistence/entity/ branches/pollen-2.0/pollen-persistence/src/test/resources/ branches/pollen-2.0/pollen-persistence/src/test/resources/db.properties branches/pollen-2.0/pollen-persistence/src/test/resources/log4j.properties branches/pollen-2.0/pollen-rest-api/ branches/pollen-2.0/pollen-rest-api/LICENSE.txt branches/pollen-2.0/pollen-rest-api/README.txt branches/pollen-2.0/pollen-rest-api/changelog.txt branches/pollen-2.0/pollen-rest-api/pom.xml branches/pollen-2.0/pollen-rest-api/src/ branches/pollen-2.0/pollen-rest-api/src/main/ branches/pollen-2.0/pollen-rest-api/src/main/java/ branches/pollen-2.0/pollen-rest-api/src/main/java/org/ branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/ branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/ branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/ branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/PollenJpaTransactionFilter.java branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/PollenServiceContextFilter.java branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/PollenServiceListener.java branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/PollenServices.java branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/ branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/AuthService.java branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/CommentService.java branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/FavoriteListService.java branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollService.java branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/UserService.java branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/VoteCountingService.java branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/VoteService.java branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/VoterListService.java branches/pollen-2.0/pollen-rest-api/src/main/resources/ branches/pollen-2.0/pollen-rest-api/src/main/resources/mapping branches/pollen-2.0/pollen-rest-api/src/main/webapp/ branches/pollen-2.0/pollen-rest-api/src/main/webapp/WEB-INF/ branches/pollen-2.0/pollen-rest-api/src/main/webapp/WEB-INF/web.xml branches/pollen-2.0/pollen-rest-api/src/test/ branches/pollen-2.0/pollen-rest-api/src/test/java/ branches/pollen-2.0/pollen-rest-api/src/test/java/org/ branches/pollen-2.0/pollen-rest-api/src/test/java/org/chorem/ branches/pollen-2.0/pollen-rest-api/src/test/java/org/chorem/pollen/ branches/pollen-2.0/pollen-rest-api/src/test/java/org/chorem/pollen/service/ branches/pollen-2.0/pollen-rest-api/src/test/java/org/chorem/pollen/service/impl/ branches/pollen-2.0/pollen-rest-api/src/test/resources/ branches/pollen-2.0/pollen-rest-api/src/test/resources/log4j.properties branches/pollen-2.0/pollen-service/ branches/pollen-2.0/pollen-service/LICENSE.txt branches/pollen-2.0/pollen-service/README.txt branches/pollen-2.0/pollen-service/changelog.txt branches/pollen-2.0/pollen-service/pom.xml branches/pollen-2.0/pollen-service/src/ branches/pollen-2.0/pollen-service/src/main/ branches/pollen-2.0/pollen-service/src/main/java/ branches/pollen-2.0/pollen-service/src/main/java/org/ branches/pollen-2.0/pollen-service/src/main/java/org/chorem/ branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/ branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/ branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/AbstractPollenService.java branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/AuthService.java branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/CommentService.java branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/DefaultPollenServiceContext.java branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/FavoriteListService.java branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/FixturesService.java branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollResult.java branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollService.java branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollenFixtures.java branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollenServiceContext.java branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollenServiceSupport.java branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollenTechnicalException.java branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/UserService.java branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/VoteCountingService.java branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/VoteService.java branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/VoterListService.java branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/config/ branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/config/PollenServiceConfig.java branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/config/PollenServiceConfigOption.java branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/config/package-info.java branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/package-info.java branches/pollen-2.0/pollen-service/src/main/resources/ branches/pollen-2.0/pollen-service/src/main/resources/fixtures.yaml branches/pollen-2.0/pollen-service/src/test/ branches/pollen-2.0/pollen-service/src/test/java/ branches/pollen-2.0/pollen-service/src/test/java/org/ branches/pollen-2.0/pollen-service/src/test/java/org/chorem/ branches/pollen-2.0/pollen-service/src/test/java/org/chorem/pollen/ branches/pollen-2.0/pollen-service/src/test/java/org/chorem/pollen/service/ branches/pollen-2.0/pollen-service/src/test/java/org/chorem/pollen/service/AbstractPollenServiceTest.java branches/pollen-2.0/pollen-service/src/test/java/org/chorem/pollen/service/FakePollenServiceContext.java branches/pollen-2.0/pollen-service/src/test/java/org/chorem/pollen/service/UserServiceTest.java branches/pollen-2.0/pollen-service/src/test/resources/ branches/pollen-2.0/pollen-service/src/test/resources/log4j.properties Modified: branches/pollen-2.0/pollen-services/pom.xml branches/pollen-2.0/pollen-ui-struts2/pom.xml branches/pollen-2.0/pollen-votecounting-aggregator/pom.xml branches/pollen-2.0/pollen-votecounting-api/pom.xml branches/pollen-2.0/pollen-votecounting-borda/pom.xml branches/pollen-2.0/pollen-votecounting-condorcet/pom.xml branches/pollen-2.0/pollen-votecounting-coombs/pom.xml branches/pollen-2.0/pollen-votecounting-instant-runoff/pom.xml branches/pollen-2.0/pollen-votecounting-normal/pom.xml branches/pollen-2.0/pollen-votecounting-number/pom.xml branches/pollen-2.0/pollen-votecounting-percentage/pom.xml branches/pollen-2.0/pom.xml branches/pollen-2.0/src/site/rst/service.rst Property changes on: branches/pollen-2.0/pollen-persistence ___________________________________________________________________ Added: svn:ignore + target .idea *.ipr *.iws *.iml Added: branches/pollen-2.0/pollen-persistence/LICENSE.txt =================================================================== --- branches/pollen-2.0/pollen-persistence/LICENSE.txt (rev 0) +++ branches/pollen-2.0/pollen-persistence/LICENSE.txt 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +<http://www.gnu.org/licenses/>. \ No newline at end of file Property changes on: branches/pollen-2.0/pollen-persistence/LICENSE.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-persistence/README.txt =================================================================== --- branches/pollen-2.0/pollen-persistence/README.txt (rev 0) +++ branches/pollen-2.0/pollen-persistence/README.txt 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,4 @@ +Pollen Persistance +------------------ + +Module de la persistence de Pollen. \ No newline at end of file Property changes on: branches/pollen-2.0/pollen-persistence/README.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-persistence/changelog.txt =================================================================== --- branches/pollen-2.0/pollen-persistence/changelog.txt (rev 0) +++ branches/pollen-2.0/pollen-persistence/changelog.txt 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,4 @@ +ChangeLog + +2.0 +- initiale release Property changes on: branches/pollen-2.0/pollen-persistence/changelog.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-persistence/pom.xml =================================================================== --- branches/pollen-2.0/pollen-persistence/pom.xml (rev 0) +++ branches/pollen-2.0/pollen-persistence/pom.xml 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,189 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> +<!-- ************************************************************* --> + <!-- *** POM Relationships *************************************** --> + <!-- ************************************************************* --> + <parent> + <groupId>org.chorem</groupId> + <artifactId>pollen</artifactId> + <version>2.0-SNAPSHOT</version> + </parent> + + <groupId>org.chorem.pollen</groupId> + <artifactId>pollen-persistence</artifactId> + + <name>Pollen :: Persistence</name> + <description>Pollen Persistence Layer</description> + + <dependencies> + + <!--dependency> + <groupId>${project.groupId}</groupId> + <artifactId>pollen-votecounting-api</artifactId> + <version>${project.version}</version> + </dependency--> + + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </dependency> + + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </dependency> + <dependency> + <groupId>commons-collections</groupId> + <artifactId>commons-collections</artifactId> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + </dependency> + <!--dependency> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-utils</artifactId> + </dependency> + <dependency> + <groupId>org.nuiton.i18n</groupId> + <artifactId>nuiton-i18n</artifactId> + </dependency--> + + <dependency> + <groupId>org.nuiton.jpa</groupId> + <artifactId>nuiton-jpa-api</artifactId> + </dependency> + + <dependency> + <groupId>org.hibernate.javax.persistence</groupId> + <artifactId>hibernate-jpa-2.0-api</artifactId> + </dependency> + + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-core</artifactId> + </dependency> + <dependency> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </dependency> + + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + </dependency> + + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-jcl</artifactId> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <scope>test</scope> + </dependency> + + </dependencies> + + <build> + <plugins> + + <!-- Plug in Topia --> + <plugin> + <groupId>org.nuiton.eugene</groupId> + <artifactId>eugene-maven-plugin</artifactId> + <configuration> + <inputs>zargo</inputs> + <resolver>org.nuiton.util.FasterCachedResourceResolver</resolver> + </configuration> + <executions> + <execution> + <id>generate-entities</id> + <phase>generate-sources</phase> + <configuration> + <!-- Corresponding to extracted package from zargo file --> + <fullPackagePath> + org.chorem.pollen.persistence.entity + </fullPackagePath> + <!-- defaultPackage used for generation --> + <defaultPackage> + org.chorem.pollen.persistence + </defaultPackage> + <templates> + org.nuiton.eugene.java.JavaEnumerationTransformer, + org.nuiton.jpa.templates.JpaMetaTransformer + </templates> + </configuration> + <goals> + <goal>generate</goal> + </goals> + </execution> + </executions> + </plugin> + + <!--plugin> + <groupId>org.nuiton.eugene</groupId> + <artifactId>eugene-maven-plugin</artifactId> + <executions> + <execution> + <phase>generate-sources</phase> + <id>generate-entities</id> + <configuration> + <fullPackagePath>org.chorem.pollen</fullPackagePath> + <defaultPackage>org.chorem.pollen.entities</defaultPackage> + <templates> + org.nuiton.topia.generator.TopiaMetaTransformer, + org.nuiton.topia.generator.BinderHelperTransformer + </templates> + </configuration> + <goals> + <goal>generate</goal> + </goals> + </execution> + </executions> + <dependencies> + <dependency> + <groupId>org.nuiton.topia</groupId> + <artifactId>topia-persistence</artifactId> + <version>${topiaVersion}</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-utils</artifactId> + <version>${nuitonUtilsVersion}</version> + <scope>compile</scope> + </dependency> + </dependencies> + </plugin--> + <!--plugin> + <groupId>org.nuiton.i18n</groupId> + <artifactId>i18n-maven-plugin</artifactId> + <executions> + <execution> + <configuration> + <entries> + <entry> + <basedir>${maven.gen.dir}/java</basedir> + </entry> + </entries> + </configuration> + <goals> + <goal>parserJava</goal> + <goal>gen</goal> + </goals> + </execution> + </executions> + </plugin--> + </plugins> + </build> + +</project> Property changes on: branches/pollen-2.0/pollen-persistence/pom.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-persistence/src/license/THIRD-PARTY.properties =================================================================== --- branches/pollen-2.0/pollen-persistence/src/license/THIRD-PARTY.properties (rev 0) +++ branches/pollen-2.0/pollen-persistence/src/license/THIRD-PARTY.properties 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,27 @@ +# Generated by org.codehaus.mojo.license.AddThirdPartyMojo +#------------------------------------------------------------------------------- +# Already used licenses in project : +# - Apache License 2.0 +# - BSD License +# - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 +# - Common Development and Distribution License +# - Common Public License Version 1.0 +# - GNU General Public License, Version 2 with the Classpath Exception +# - GNU Lesser General Public License, version 2.1 +# - Indiana University Extreme! Lab Software License, vesion 1.1.1 +# - Lesser General Public License (LGPL) v 3.0 +# - Lesser General Public License (LPGL) +# - Lesser General Public License (LPGL) v 2.1 +# - MIT License +# - MPL 1.1 +# - New BSD License +# - The Apache Software License, Version 2.0 +# - The H2 License, Version 1.0 +# - The MIT License +# - license.txt +#------------------------------------------------------------------------------- +# Please fill the missing licenses for dependencies : +# +# +#Sun Jun 02 18:32:57 CEST 2013 +dom4j--dom4j--1.6.1=BSD License Property changes on: branches/pollen-2.0/pollen-persistence/src/license/THIRD-PARTY.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/JpaEntityIdGeneratorIfNotEmpty.java =================================================================== --- branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/JpaEntityIdGeneratorIfNotEmpty.java (rev 0) +++ branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/JpaEntityIdGeneratorIfNotEmpty.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,56 @@ +package org.chorem.pollen.persistence; + +/* + * #%L + * Nuiton Jpa :: API + * $Id$ + * $HeadURL: http://svn.nuiton.org/svn/sandbox/nuiton-jpa/nuiton-jpa-api/src/main/java/or... $ + * %% + * Copyright (C) 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + +import org.apache.commons.lang3.StringUtils; +import org.nuiton.jpa.api.JpaEntity; +import org.nuiton.jpa.api.JpaEntityIdGenerator; + +/** + * Default implementation of {@link JpaEntityIdGenerator}. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.1 + */ +public class JpaEntityIdGeneratorIfNotEmpty implements JpaEntityIdGenerator { + + @Override + public String generate(JpaEntity entity) { + String result; + boolean notEmpty = StringUtils.isNotEmpty(entity.getId()); + + if (notEmpty) { + result = entity.getId(); + } else { + double random = Math.random(); + while (Double.toString(random).contains("E-")) { + random = Math.random(); + } + result = entity.getClass().getName() + '#' + System.currentTimeMillis() + '#' + + random; + } + return result; + } +} Property changes on: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/JpaEntityIdGeneratorIfNotEmpty.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/JpaPollenPersistenceContext.java =================================================================== --- branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/JpaPollenPersistenceContext.java (rev 0) +++ branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/JpaPollenPersistenceContext.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,32 @@ +package org.chorem.pollen.persistence; + +import org.nuiton.jpa.api.JpaEntityIdGenerator; +import org.nuiton.jpa.api.hibernate.HibernateUtil; + +import javax.persistence.EntityManager; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class JpaPollenPersistenceContext extends AbstractJpaPollenPersistenceContext { + + public JpaPollenPersistenceContext(EntityManager entityManager) { + super(entityManager); + } + + public JpaPollenPersistenceContext(JpaEntityIdGenerator idGenerator, + EntityManager entityManager) { + super(idGenerator, entityManager); + } + + @Override + public void clearDatabase() { + rollback(); + HibernateUtil.cleanDatabase(entityManager); + commit(); + } + +} //JpaPollenPersistenceContext Property changes on: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/JpaPollenPersistenceContext.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenPersistenceContext.java =================================================================== --- branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenPersistenceContext.java (rev 0) +++ branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenPersistenceContext.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,53 @@ +package org.chorem.pollen.persistence; + +import org.chorem.pollen.persistence.dao.ChoiceJpaDao; +import org.chorem.pollen.persistence.dao.CommentJpaDao; +import org.chorem.pollen.persistence.dao.FavoriteListJpaDao; +import org.chorem.pollen.persistence.dao.FavoriteListMemberJpaDao; +import org.chorem.pollen.persistence.dao.PollJpaDao; +import org.chorem.pollen.persistence.dao.PollenPermanentPermissionJpaDao; +import org.chorem.pollen.persistence.dao.PollenUserJpaDao; +import org.chorem.pollen.persistence.dao.VoteJpaDao; +import org.chorem.pollen.persistence.dao.VoteToChoiceJpaDao; +import org.chorem.pollen.persistence.dao.VoterJpaDao; +import org.chorem.pollen.persistence.dao.VoterListJpaDao; +import org.chorem.pollen.persistence.dao.VoterListMemberJpaDao; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public interface PollenPersistenceContext { + + void commit(); + + void rollback(); + + void clearDatabase(); + + ChoiceJpaDao getChoiceDao(); + + CommentJpaDao getCommentDao(); + + FavoriteListJpaDao getFavoriteListDao(); + + FavoriteListMemberJpaDao getFavoriteListMemberDao(); + + PollJpaDao getPollDao(); + + PollenPermanentPermissionJpaDao getPollenPermanentPermissionDao(); + + PollenUserJpaDao getPollenUserDao(); + + VoteJpaDao getVoteDao(); + + VoteToChoiceJpaDao getVoteToChoiceDao(); + + VoterJpaDao getVoterDao(); + + VoterListJpaDao getVoterListDao(); + + VoterListMemberJpaDao getVoterListMemberDao(); +} Property changes on: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/PollenPersistenceContext.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/ChoiceDao.java =================================================================== --- branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/ChoiceDao.java (rev 0) +++ branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/ChoiceDao.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,10 @@ +package org.chorem.pollen.persistence.dao; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public interface ChoiceDao { +} Property changes on: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/ChoiceDao.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/CommentDao.java =================================================================== --- branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/CommentDao.java (rev 0) +++ branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/CommentDao.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,10 @@ +package org.chorem.pollen.persistence.dao; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public interface CommentDao { +} Property changes on: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/CommentDao.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/FavoriteListDao.java =================================================================== --- branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/FavoriteListDao.java (rev 0) +++ branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/FavoriteListDao.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,10 @@ +package org.chorem.pollen.persistence.dao; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public interface FavoriteListDao { +} Property changes on: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/FavoriteListDao.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/PollDao.java =================================================================== --- branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/PollDao.java (rev 0) +++ branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/PollDao.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,20 @@ +package org.chorem.pollen.persistence.dao; + +import org.chorem.pollen.persistence.entity.Poll; + +import java.util.Set; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public interface PollDao { + + Set<Poll> findAllCreated(String userId); + + Set<Poll> findAllInvited(String userId); + + Set<Poll> findAllParticipated(String userId); +} Property changes on: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/PollDao.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/PollJpaDao.java =================================================================== --- branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/PollJpaDao.java (rev 0) +++ branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/PollJpaDao.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,39 @@ +package org.chorem.pollen.persistence.dao; + +import com.google.common.collect.Sets; +import org.chorem.pollen.persistence.entity.Poll; + +import javax.persistence.EntityManager; +import java.util.Set; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class PollJpaDao extends AbstractPollJpaDao { + + public PollJpaDao(EntityManager entityManager) { + super(entityManager); + } + + @Override + public Set<Poll> findAllCreated(String userId) { + //TODO + return Sets.newHashSet(); + } + + @Override + public Set<Poll> findAllInvited(String userId) { + //TODO + return Sets.newHashSet(); + } + + @Override + public Set<Poll> findAllParticipated(String userId) { + //TODO + return Sets.newHashSet(); + } + +} //PollJpaDao Property changes on: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/PollJpaDao.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/PollenUserDao.java =================================================================== --- branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/PollenUserDao.java (rev 0) +++ branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/PollenUserDao.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,14 @@ +package org.chorem.pollen.persistence.dao; + +import org.chorem.pollen.persistence.entity.PollenUser; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public interface PollenUserDao { + + PollenUser findByLogin(String login); +} Property changes on: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/PollenUserDao.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/PollenUserJpaDao.java =================================================================== --- branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/PollenUserJpaDao.java (rev 0) +++ branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/PollenUserJpaDao.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,27 @@ +package org.chorem.pollen.persistence.dao; + +import org.chorem.pollen.persistence.entity.PollenUser; + +import javax.persistence.EntityManager; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class PollenUserJpaDao extends AbstractPollenUserJpaDao { + + public PollenUserJpaDao(EntityManager entityManager) { + super(entityManager); + } + + @Override + public PollenUser findByLogin(String login) { + PollenUser result = createQuery( + "from " + getEntityClass() + " where login = :login"). + setParameter("login", login). + getSingleResult(); + return result; + } +} //PollenUserJpaDao Property changes on: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/PollenUserJpaDao.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/VoteDao.java =================================================================== --- branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/VoteDao.java (rev 0) +++ branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/VoteDao.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,10 @@ +package org.chorem.pollen.persistence.dao; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public interface VoteDao { +} Property changes on: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/VoteDao.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/VoterListDao.java =================================================================== --- branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/VoterListDao.java (rev 0) +++ branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/VoterListDao.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,10 @@ +package org.chorem.pollen.persistence.dao; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public interface VoterListDao { +} Property changes on: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/VoterListDao.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/VoterListMemberDao.java =================================================================== --- branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/VoterListMemberDao.java (rev 0) +++ branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/VoterListMemberDao.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,16 @@ +package org.chorem.pollen.persistence.dao; + +import org.chorem.pollen.persistence.entity.VoterListMember; + +import java.util.Set; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public interface VoterListMemberDao { + + Set<VoterListMember> findAllByVoterList(String voterListId); +} Property changes on: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/VoterListMemberDao.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/VoterListMemberJpaDao.java =================================================================== --- branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/VoterListMemberJpaDao.java (rev 0) +++ branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/VoterListMemberJpaDao.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,29 @@ +package org.chorem.pollen.persistence.dao; + +import com.google.common.collect.Sets; +import org.chorem.pollen.persistence.entity.VoterListMember; + +import javax.persistence.EntityManager; +import javax.persistence.TypedQuery; +import java.util.Set; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class VoterListMemberJpaDao extends AbstractVoterListMemberJpaDao { + + public VoterListMemberJpaDao(EntityManager entityManager) { + super(entityManager); + } + + public Set<VoterListMember> findAllByVoterList(String voterListId) { + + TypedQuery<VoterListMember> query = createQuery("from " + getEntityClass() + " where voterList.id := voterListId").setParameter("voterListId", voterListId); + Set<VoterListMember> result = Sets.newHashSet(findAll(query)); + return result; + } + +} //VoterListMemberJpaDao Property changes on: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/dao/VoterListMemberJpaDao.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUser.java =================================================================== --- branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUser.java (rev 0) +++ branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUser.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,14 @@ +package org.chorem.pollen.persistence.entity; + +import javax.persistence.Entity; + +@Entity +public class PollenUser extends AbstractJpaPollenUser { + + private static final long serialVersionUID = 1L; + + public boolean isEmailActivated() { + return emailActivationToken == null; + } + +} //PollenUser Property changes on: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUser.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/Polls.java =================================================================== --- branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/Polls.java (rev 0) +++ branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/Polls.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,24 @@ +package org.chorem.pollen.persistence.entity; + +import org.apache.commons.lang3.ObjectUtils; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class Polls { + + public boolean isPollFree(Poll poll) { + return ObjectUtils.equals(PollType.FREE, poll.getPollType()); + } + + public boolean isPollRestricted(Poll poll) { + return ObjectUtils.equals(PollType.RESTRICTED, poll.getPollType()); + } + + public boolean isPollGroup(Poll poll) { + return ObjectUtils.equals(PollType.GROUP, poll.getPollType()); + } +} Property changes on: branches/pollen-2.0/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/Polls.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-persistence/src/main/resources/META-INF/persistence.xml =================================================================== --- branches/pollen-2.0/pollen-persistence/src/main/resources/META-INF/persistence.xml (rev 0) +++ branches/pollen-2.0/pollen-persistence/src/main/resources/META-INF/persistence.xml 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,14 @@ +<persistence xmlns="http://java.sun.com/xml/ns/persistence" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" + version="2.0"> + + <persistence-unit name="pollenPersistenceUnit" + transaction-type="RESOURCE_LOCAL"> + + <description></description> + <provider>org.hibernate.ejb.HibernatePersistence</provider> + + </persistence-unit> + +</persistence> \ No newline at end of file Property changes on: branches/pollen-2.0/pollen-persistence/src/main/resources/META-INF/persistence.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-persistence/src/main/xmi/pollen.properties =================================================================== --- branches/pollen-2.0/pollen-persistence/src/main/xmi/pollen.properties (rev 0) +++ branches/pollen-2.0/pollen-persistence/src/main/xmi/pollen.properties 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,48 @@ +### +# #%L +# Pollen :: Persistence +# $Id$ +# $HeadURL$ +# %% +# Copyright (C) 2009 - 2013 CodeLutin +# %% +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# #L% +### +model.tagValue.idGenerator=org.nuiton.jpa.api.DefaultJpaEntityIdGenerator +model.tagvalue.version=2.0 +model.tagvalue.constantPrefix=PROPERTY_ + +org.chorem.pollen.persistence.entity.Poll.attribute.choice.stereotype=ordered +org.chorem.pollen.persistence.entity.Poll.attribute.voterList.stereotype=ordered +org.chorem.pollen.persistence.entity.Poll.attribute.vote.stereotype=ordered +org.chorem.pollen.persistence.entity.Poll.attribute.comment.stereotype=ordered +org.chorem.pollen.persistence.entity.PollenUser.attribute.favoriteList.stereotype=ordered +org.chorem.pollen.persistence.entity.FavoriteList.attribute.favoriteListMember.stereotype=ordered + +#org.chorem.pollen.persistence.entity.Poll.attribute.choice.stereotype=indexed + +#org.chorem.pollen.persistence.entity.Poll.attribute.vote.stereotype=ordered +#org.chorem.pollen.persistence.entity.Poll.attribute.vote.tagvalue.orderBy=topiaCreateDate + +# clef naturelle non modifiable sur Poll#pollId +#org.chorem.pollen.persistence.entity.Poll.class.tagValue.naturalIdMutable=true +#org.chorem.pollen.persistence.entity.Poll.attribute.pollId.stereotype=unique +#org.chorem.pollen.persistence.entity.Poll.attribute.pollId.tagValue.naturalId=true + +# clef naturelle non modifiable sur PollAccount#accountId +#org.chorem.pollen.persistence.entity.PollAccount.class.tagValue.naturalIdMutable=true +#org.chorem.pollen.persistence.entity.PollAccount.attribute.accountId.stereotype=unique +#org.chorem.pollen.persistence.entity.PollAccount.attribute.accountId.tagValue.naturalId=true + Property changes on: branches/pollen-2.0/pollen-persistence/src/main/xmi/pollen.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-persistence/src/main/xmi/pollen.zargo =================================================================== (Binary files differ) Property changes on: branches/pollen-2.0/pollen-persistence/src/main/xmi/pollen.zargo ___________________________________________________________________ Added: svn:mime-type + application/zip Added: svn:keywords + Author Date Id Revision HeadURL Added: branches/pollen-2.0/pollen-persistence/src/test/resources/db.properties =================================================================== --- branches/pollen-2.0/pollen-persistence/src/test/resources/db.properties (rev 0) +++ branches/pollen-2.0/pollen-persistence/src/test/resources/db.properties 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,28 @@ +### +# #%L +# Pollen :: Persistence +# $Id$ +# $HeadURL$ +# %% +# Copyright (C) 2009 - 2012 CodeLutin +# %% +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# #L% +### +hibernate.show_sql=false +hibernate.hbm2ddl.auto=update +hibernate.dialect=org.hibernate.dialect.H2Dialect +hibernate.connection.username=sa +hibernate.connection.password=sa +hibernate.connection.driver_class=org.h2.Driver Property changes on: branches/pollen-2.0/pollen-persistence/src/test/resources/db.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-persistence/src/test/resources/log4j.properties =================================================================== --- branches/pollen-2.0/pollen-persistence/src/test/resources/log4j.properties (rev 0) +++ branches/pollen-2.0/pollen-persistence/src/test/resources/log4j.properties 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,32 @@ +### +# #%L +# Pollen :: Persistence +# $Id$ +# $HeadURL$ +# %% +# Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit +# %% +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# #L% +### +log4j.rootCategory=WARN, A1 + +# A1 is set to be a ConsoleAppender. +log4j.appender.A1=org.apache.log4j.ConsoleAppender + +# A1 uses PatternLayout. +log4j.appender.A1.layout=org.apache.log4j.PatternLayout +log4j.appender.A1.layout.ConversionPattern=[%p] %c %m%n + +log4j.logger.org.chorem.pollen=INFO Property changes on: branches/pollen-2.0/pollen-persistence/src/test/resources/log4j.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: branches/pollen-2.0/pollen-rest-api ___________________________________________________________________ Added: svn:ignore + target .idea *.ipr *.iws *.iml Property changes on: branches/pollen-2.0/pollen-rest-api/LICENSE.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Property changes on: branches/pollen-2.0/pollen-rest-api/README.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Property changes on: branches/pollen-2.0/pollen-rest-api/changelog.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-rest-api/pom.xml =================================================================== --- branches/pollen-2.0/pollen-rest-api/pom.xml (rev 0) +++ branches/pollen-2.0/pollen-rest-api/pom.xml 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,141 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.chorem</groupId> + <artifactId>pollen</artifactId> + <version>2.0-SNAPSHOT</version> + </parent> + + <groupId>org.chorem.pollen</groupId> + <artifactId>pollen-rest-api</artifactId> + + <name>Pollen :: Rest Api</name> + <description>Pollen Rest Api</description> + + <dependencies> + + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>pollen-persistence</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>pollen-service</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.debux.webmotion</groupId> + <artifactId>webmotion</artifactId> + </dependency> + + <dependency> + <groupId>org.debux.webmotion</groupId> + <artifactId>webmotion-unittest</artifactId> + </dependency> + + <!--dependency> + <groupId>org.debux.webmotion</groupId> + <artifactId>webmotion-extra-jpa</artifactId> + </dependency--> + + <dependency> + <groupId>org.hibernate.javax.persistence</groupId> + <artifactId>hibernate-jpa-2.0-api</artifactId> + </dependency> + + <dependency> + <groupId>org.nuiton.web</groupId> + <artifactId>nuiton-web</artifactId> + </dependency> + + <dependency> + <groupId>com.esotericsoftware.yamlbeans</groupId> + <artifactId>yamlbeans</artifactId> + </dependency> + + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </dependency> + <dependency> + <groupId>commons-collections</groupId> + <artifactId>commons-collections</artifactId> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-email</artifactId> + </dependency> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </dependency> + + <dependency> + <groupId>javax.mail</groupId> + <artifactId>mail</artifactId> + </dependency> + <dependency> + <groupId>rome</groupId> + <artifactId>rome</artifactId> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </dependency> + + <dependency> + <groupId>org.nuiton.jpa</groupId> + <artifactId>nuiton-jpa-junit</artifactId> + </dependency> + + <dependency> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-utils</artifactId> + </dependency> + + <dependency> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-config</artifactId> + </dependency> + + <dependency> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-jcl</artifactId> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <scope>test</scope> + </dependency> + + </dependencies> + +</project> Property changes on: branches/pollen-2.0/pollen-rest-api/pom.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/PollenJpaTransactionFilter.java =================================================================== --- branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/PollenJpaTransactionFilter.java (rev 0) +++ branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/PollenJpaTransactionFilter.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,55 @@ +package org.chorem.pollen.rest; + +import com.google.common.base.Preconditions; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.web.filter.JpaTransactionFilter; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.PersistenceException; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; + +public class PollenJpaTransactionFilter extends JpaTransactionFilter { + + private static final Log log = + LogFactory.getLog(PollenJpaTransactionFilter.class); + + protected EntityManagerFactory entityManagerFactory; + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + + super.init(filterConfig); + + if (log.isInfoEnabled()) { + log.info("Init JPA Filter"); + } + + entityManagerFactory = PollenServices.getEntityManagerFactory( + filterConfig.getServletContext()); + + Preconditions.checkNotNull(entityManagerFactory, "Could not find entit manager factory at ServletContext#pollen_EntityManagerFactory"); + } + + @Override + protected EntityManager createEntityManager(ServletRequest request) { + + EntityManager entityManager; + + try { + + entityManager = entityManagerFactory.createEntityManager(); + + } catch (PersistenceException e) { + + if (log.isErrorEnabled()) { + log.error("unable to create entity manager", e); + } + throw e; + } + return entityManager; + } +} Property changes on: branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/PollenJpaTransactionFilter.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/PollenServiceContextFilter.java =================================================================== --- branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/PollenServiceContextFilter.java (rev 0) +++ branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/PollenServiceContextFilter.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,35 @@ +package org.chorem.pollen.rest; + +import org.chorem.pollen.service.DefaultPollenServiceContext; +import org.chorem.pollen.service.config.PollenServiceConfig; +import org.debux.webmotion.server.WebMotionFilter; +import org.debux.webmotion.server.call.HttpContext; + +import javax.persistence.EntityManager; + +/** + * Inject le service context dans les controlleurs. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class PollenServiceContextFilter extends WebMotionFilter { + + public void inject(HttpContext context) { + + DefaultPollenServiceContext serviceContext = + new DefaultPollenServiceContext(); + + PollenServiceConfig serviceConfig = + PollenServices.getServiceConfig(context.getServletContext()); + serviceContext.setPollenServiceConfig(serviceConfig); + + EntityManager entityManager = + PollenServices.getEntityManager(context.getRequest()); + serviceContext.setEntityManager(entityManager); + + PollenServices.setServiceContext(context.getRequest(), serviceContext); + + doProcess(); + } +} Property changes on: branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/PollenServiceContextFilter.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/PollenServiceListener.java =================================================================== --- branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/PollenServiceListener.java (rev 0) +++ branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/PollenServiceListener.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,92 @@ +package org.chorem.pollen.rest; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.pollen.service.PollenServiceContext; +import org.chorem.pollen.service.config.PollenServiceConfig; +import org.debux.webmotion.server.WebMotionServerListener; +import org.debux.webmotion.server.call.Call; +import org.debux.webmotion.server.call.HttpContext; +import org.debux.webmotion.server.call.ServerContext; +import org.debux.webmotion.server.handler.ExecutorParametersInjectorHandler; +import org.debux.webmotion.server.mapping.Mapping; + +import javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; +import javax.persistence.PersistenceException; +import javax.servlet.http.HttpServletRequest; +import java.lang.reflect.Type; +import java.util.Map; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class PollenServiceListener implements WebMotionServerListener { + + /** Logger. */ + private static final Log log = + LogFactory.getLog(PollenServiceListener.class); + + @Override + public void onStart(Mapping mapping, ServerContext serverContext) { + + serverContext.addInjector(new PollenServiceContextInjector()); + + // get configuration + PollenServiceConfig config = new PollenServiceConfig(); + + // push config in context + PollenServices.setServiceConfig(serverContext.getServletContext(), config); + + // get persistence properties + Map<String, String> jpaParameters = config.getJpaParameters(); + + if (log.isInfoEnabled()) { + log.info("creating entity manager factory"); + } + + // get entity manager factory + try { + + EntityManagerFactory entityManagerFactory = + Persistence.createEntityManagerFactory("pollenPersistenceUnit", jpaParameters); + + // store it in server context + PollenServices.setEntityManagerFactory(serverContext.getServletContext(), entityManagerFactory); + + } catch (PersistenceException e) { + + if (log.isErrorEnabled()) { + log.error("unable to create entity manager factory", e); + } + + throw e; + } + } + + @Override + public void onStop(ServerContext serverContext) { + + EntityManagerFactory entityManagerFactory = + PollenServices.getEntityManagerFactory(serverContext.getServletContext()); + + if (entityManagerFactory != null) { + entityManagerFactory.close(); + } + } + + protected static class PollenServiceContextInjector implements ExecutorParametersInjectorHandler.Injector { + @Override + public Object getValue(Mapping mapping, Call call, Class<?> type, Type generic) { + if (PollenServiceContext.class.isAssignableFrom(type)) { + HttpContext httpContext = call.getContext(); + HttpServletRequest request = httpContext.getRequest(); + return PollenServices.getServiceContext(request); + } + return null; + } + } +} Property changes on: branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/PollenServiceListener.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/PollenServices.java =================================================================== --- branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/PollenServices.java (rev 0) +++ branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/PollenServices.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,63 @@ +package org.chorem.pollen.rest; + +import org.chorem.pollen.service.PollenServiceContext; +import org.chorem.pollen.service.config.PollenServiceConfig; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.servlet.ServletContext; +import javax.servlet.ServletRequest; +import javax.servlet.http.HttpServletRequest; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class PollenServices { + + static final String APPLICATION_POLLEN_SERVICE_CONFIG = "pollen_PollenServiceConfig"; + + static final String APPLICATION_ENTITY_MANAGER_FACTORY = "pollen_EntityManagerFactory"; + + static final String REQUEST_POLLEN_SERVICE_CONTEXT = "pollen_PollenServiceContext"; + + public static PollenServiceConfig getServiceConfig(ServletContext servletContext) { + PollenServiceConfig result = (PollenServiceConfig) + servletContext.getAttribute(APPLICATION_POLLEN_SERVICE_CONFIG); + return result; + } + + public static void setServiceConfig(ServletContext servletContext, + PollenServiceConfig serviceConfig) { + servletContext.setAttribute(APPLICATION_POLLEN_SERVICE_CONFIG, serviceConfig); + } + + public static EntityManagerFactory getEntityManagerFactory(ServletContext servletContext) { + EntityManagerFactory result = (EntityManagerFactory) + servletContext.getAttribute(APPLICATION_ENTITY_MANAGER_FACTORY); + return result; + } + + public static void setEntityManagerFactory(ServletContext servletContext, + EntityManagerFactory entityManagerFactory) { + servletContext.setAttribute(APPLICATION_ENTITY_MANAGER_FACTORY, entityManagerFactory); + } + + public static EntityManager getEntityManager(ServletRequest servletRequest) { + return PollenJpaTransactionFilter.getTransaction(servletRequest); + } + + public static PollenServiceContext getServiceContext(HttpServletRequest request) { + PollenServiceContext result = (PollenServiceContext) + request.getAttribute(REQUEST_POLLEN_SERVICE_CONTEXT); + return result; + } + + public static void setServiceContext(HttpServletRequest request, + PollenServiceContext serviceContext) { + request.setAttribute(REQUEST_POLLEN_SERVICE_CONTEXT, serviceContext); + } + +} Property changes on: branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/PollenServices.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/AuthService.java =================================================================== --- branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/AuthService.java (rev 0) +++ branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/AuthService.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,25 @@ +package org.chorem.pollen.rest.api; + +import org.chorem.pollen.service.PollenServiceContext; +import org.debux.webmotion.server.WebMotionController; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class AuthService extends WebMotionController { + + public String login(PollenServiceContext context, String login, String password) { + return context.getAuthService().login(login, password); + } + + public void lostPassword(PollenServiceContext context, String token) { + context.getAuthService().lostPassword(token); + } + + public void logout(PollenServiceContext context, String login) { + context.getAuthService().logout(login); + } +} Property changes on: branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/AuthService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/CommentService.java =================================================================== --- branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/CommentService.java (rev 0) +++ branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/CommentService.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,37 @@ +package org.chorem.pollen.rest.api; + +import org.chorem.pollen.persistence.entity.Comment; +import org.chorem.pollen.service.PollenServiceContext; +import org.debux.webmotion.server.WebMotionController; + +import java.util.List; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class CommentService extends WebMotionController { + + public Comment[] getComments(PollenServiceContext context, String pollId) { + List<Comment> comments = context.getCommentService().getComments(pollId); + return comments.toArray(new Comment[comments.size()]); + } + + public Comment getComment(PollenServiceContext context, String pollId, String commentId) { + return context.getCommentService().getComment(pollId, commentId); + } + + public Comment addComment(PollenServiceContext context, String pollId, Comment comment) { + return context.getCommentService().addComment(pollId, comment); + } + + public Comment editComment(PollenServiceContext context, String pollId, Comment comment) { + return context.getCommentService().editComment(pollId, comment); + } + + public void deleteComment(PollenServiceContext context, String pollId, String commentId) { + context.getCommentService().deleteComment(pollId, commentId); + } +} Property changes on: branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/CommentService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/FavoriteListService.java =================================================================== --- branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/FavoriteListService.java (rev 0) +++ branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/FavoriteListService.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,59 @@ +package org.chorem.pollen.rest.api; + +import org.chorem.pollen.persistence.entity.FavoriteList; +import org.chorem.pollen.persistence.entity.FavoriteListMember; +import org.chorem.pollen.service.PollenServiceContext; +import org.debux.webmotion.server.WebMotionController; + +import java.util.List; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class FavoriteListService extends WebMotionController { + + public FavoriteList[] getFavoriteLists(PollenServiceContext context, String userId) { + List<FavoriteList> favoriteLists = context.getFavoriteListService().getFavoriteLists(userId); + return favoriteLists.toArray(new FavoriteList[favoriteLists.size()]); + } + + public FavoriteList getFavoriteList(PollenServiceContext context, String userId, String favoriteListId) { + return context.getFavoriteListService().getFavoriteList(userId, favoriteListId); + } + + public FavoriteList createFavoriteList(PollenServiceContext context, String userId, FavoriteList favoriteList) { + return context.getFavoriteListService().createFavoriteList(userId, favoriteList); + } + + public FavoriteList editFavoriteList(PollenServiceContext context, String userId, FavoriteList favoriteList) { + return context.getFavoriteListService().editFavoriteList(userId, favoriteList); + } + + public void deleteFavoriteList(PollenServiceContext context, String userId, String favoriteListId) { + context.getFavoriteListService().deleteFavoriteList(userId, favoriteListId); + } + + public FavoriteListMember[] getMembers(PollenServiceContext context, String userId, String favoriteListId) { + List<FavoriteListMember> members = context.getFavoriteListService().getMembers(userId, favoriteListId); + return members.toArray(new FavoriteListMember[members.size()]); + } + + public FavoriteListMember getMember(PollenServiceContext context, String userId, String favoriteListId, String memberId) { + return context.getFavoriteListService().getMember(userId, favoriteListId, memberId); + } + + public FavoriteListMember addMember(PollenServiceContext context, String userId, String favoriteListId, FavoriteListMember member) { + return context.getFavoriteListService().addMember(userId, favoriteListId, member); + } + + public FavoriteListMember editMember(PollenServiceContext context, String userId, String favoriteListId, FavoriteListMember member) { + return context.getFavoriteListService().editMember(userId, favoriteListId, member); + } + + public void removeMember(PollenServiceContext context, String userId, String favoriteListId, String memberId) { + context.getFavoriteListService().removeMember(userId, favoriteListId, memberId); + } +} Property changes on: branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/FavoriteListService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollService.java =================================================================== --- branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollService.java (rev 0) +++ branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollService.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,79 @@ +package org.chorem.pollen.rest.api; + +import org.chorem.pollen.persistence.entity.Choice; +import org.chorem.pollen.persistence.entity.Poll; +import org.chorem.pollen.service.PollenServiceContext; +import org.debux.webmotion.server.WebMotionController; + +import java.io.File; +import java.util.List; +import java.util.Set; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class PollService extends WebMotionController { + + public Poll[] getCreatedPolls(PollenServiceContext context, String userId) { + Set<Poll> polls = context.getPollService().getCreatedPolls(userId); + return polls.toArray(new Poll[polls.size()]); + } + + public Poll[] getInvitedPolls(PollenServiceContext context, String userId) { + Set<Poll> polls = context.getPollService().getInvitedPolls(userId); + return polls.toArray(new Poll[polls.size()]); + } + + public Poll[] getParticipatedPolls(PollenServiceContext context, String userId) { + Set<Poll> polls = context.getPollService().getParticipatedPolls(userId); + return polls.toArray(new Poll[polls.size()]); + } + + public Poll createPoll(PollenServiceContext context, String userId, Poll poll) { + return context.getPollService().createPoll(userId, poll); + } + + public Poll editPoll(PollenServiceContext context, Poll poll) { + return context.getPollService().editPoll(poll); + } + + public void deletePoll(PollenServiceContext context, String pollId) { + context.getPollService().deletePoll(pollId); + } + + public Poll clonePoll(PollenServiceContext context, String pollId) { + return context.getPollService().clonePoll(pollId); + } + + public File closePoll(PollenServiceContext context, String pollId) { + return context.getPollService().closePoll(pollId); + } + + public File exportPoll(PollenServiceContext context, String pollId) { + return context.getPollService().exportPoll(pollId); + } + + public Choice[] getChoices(PollenServiceContext context, String pollId) { + List<Choice> choices = context.getPollService().getChoices(pollId); + return choices.toArray(new Choice[choices.size()]); + } + + public Choice getChoice(PollenServiceContext context, String pollId, String choiceId) { + return context.getPollService().getChoice(pollId, choiceId); + } + + public Choice addChoice(PollenServiceContext context, String pollId, Choice choice) { + return context.getPollService().addChoice(pollId, choice); + } + + public Choice editChoice(PollenServiceContext context, String pollId, Choice choice) { + return context.getPollService().editChoice(pollId, choice); + } + + public void deleteChoice(PollenServiceContext context, String pollId, String choiceId) { + context.getPollService().deleteChoice(pollId, choiceId); + } +} Property changes on: branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/UserService.java =================================================================== --- branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/UserService.java (rev 0) +++ branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/UserService.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,37 @@ +package org.chorem.pollen.rest.api; + +import org.chorem.pollen.persistence.entity.PollenUser; +import org.chorem.pollen.service.PollenServiceContext; +import org.debux.webmotion.server.WebMotionController; + +import java.util.List; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class UserService extends WebMotionController { + + public PollenUser[] getUsers(PollenServiceContext context) { + List<PollenUser> users = context.getUserService().getUsers(); + return users.toArray(new PollenUser[users.size()]); + } + + public PollenUser getUser(PollenServiceContext context, String userId) { + return context.getUserService().getUser(userId); + } + + public PollenUser createUser(PollenServiceContext context, PollenUser user) { + return context.getUserService().createUser(user); + } + + public PollenUser editUser(PollenServiceContext context, PollenUser user) { + return context.getUserService().editUser(user); + } + + public void validateUserEmail(PollenServiceContext context, String userId, String token) { + context.getUserService().validateUserEmail(userId, token); + } +} Property changes on: branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/UserService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/VoteCountingService.java =================================================================== --- branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/VoteCountingService.java (rev 0) +++ branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/VoteCountingService.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,18 @@ +package org.chorem.pollen.rest.api; + +import org.chorem.pollen.service.PollResult; +import org.chorem.pollen.service.PollenServiceContext; +import org.debux.webmotion.server.WebMotionController; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class VoteCountingService extends WebMotionController { + + public PollResult getResult(PollenServiceContext context, String pollId) { + return context.getVoteCountingService().getResult(pollId); + } +} Property changes on: branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/VoteCountingService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/VoteService.java =================================================================== --- branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/VoteService.java (rev 0) +++ branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/VoteService.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,37 @@ +package org.chorem.pollen.rest.api; + +import org.chorem.pollen.persistence.entity.Vote; +import org.chorem.pollen.service.PollenServiceContext; +import org.debux.webmotion.server.WebMotionController; + +import java.util.List; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class VoteService extends WebMotionController { + + public Vote[] getVotes(PollenServiceContext context, String pollId) { + List<Vote> votes = context.getVoteService().getVotes(pollId); + return votes.toArray(new Vote[votes.size()]); + } + + public Vote getVote(PollenServiceContext context, String pollId, String voteId) { + return context.getVoteService().getVote(pollId, voteId); + } + + public Vote addVote(PollenServiceContext context, String pollId, Vote vote) { + return context.getVoteService().addVote(pollId, vote); + } + + public Vote editVote(PollenServiceContext context, String pollId, Vote vote) { + return context.getVoteService().editVote(pollId, vote); + } + + public void deleteVote(PollenServiceContext context, String pollId, String voteId) { + context.getVoteService().deleteVote(pollId, voteId); + } +} Property changes on: branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/VoteService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/VoterListService.java =================================================================== --- branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/VoterListService.java (rev 0) +++ branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/VoterListService.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,64 @@ +package org.chorem.pollen.rest.api; + +import org.chorem.pollen.persistence.entity.VoterList; +import org.chorem.pollen.persistence.entity.VoterListMember; +import org.chorem.pollen.service.PollenServiceContext; +import org.debux.webmotion.server.WebMotionController; + +import java.util.List; +import java.util.Set; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class VoterListService extends WebMotionController { + + public VoterList importFavoriteList(PollenServiceContext context, String userId, String pollId, String favoriteListId) { + return context.getVoterListService().importFavoriteList(userId, pollId, favoriteListId); + } + + public VoterList[] getVoterLists(PollenServiceContext context, String pollId) { + List<VoterList> voterLists = context.getVoterListService().getVoterLists(pollId); + return voterLists.toArray(new VoterList[voterLists.size()]); + } + + public VoterList getVoterList(PollenServiceContext context, String pollId, String voterListId) { + return context.getVoterListService().getVoterList(pollId, voterListId); + } + + public VoterList addVoterList(PollenServiceContext context, String pollId, VoterList voterList) { + return context.getVoterListService().addVoterList(pollId, voterList); + } + + public VoterList editVoterList(PollenServiceContext context, String pollId, VoterList voterList) { + return context.getVoterListService().editVoterList(pollId, voterList); + } + + public void deleteVoterList(PollenServiceContext context, String pollId, String voterListId) { + context.getVoterListService().deleteVoterList(pollId, voterListId); + } + + public VoterListMember[] getMembers(PollenServiceContext context, String pollId, String voterListId) { + Set<VoterListMember> members = context.getVoterListService().getMembers(pollId, voterListId); + return members.toArray(new VoterListMember[members.size()]); + } + + public VoterListMember getMember(PollenServiceContext context, String pollId, String voterListId, String memberId) { + return context.getVoterListService().getMember(pollId, voterListId, memberId); + } + + public VoterListMember addMember(PollenServiceContext context, String pollId, String voterListId, VoterListMember member) { + return context.getVoterListService().addMember(pollId, voterListId, member); + } + + public VoterListMember editMember(PollenServiceContext context, String pollId, String voterListId, VoterListMember member) { + return context.getVoterListService().editMember(pollId, voterListId, member); + } + + public void deleteMember(PollenServiceContext context, String pollId, String voterListId, String memberId) { + context.getVoterListService().deleteMember(pollId, voterListId, memberId); + } +} Property changes on: branches/pollen-2.0/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/VoterListService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-rest-api/src/main/resources/mapping =================================================================== --- branches/pollen-2.0/pollen-rest-api/src/main/resources/mapping (rev 0) +++ branches/pollen-2.0/pollen-rest-api/src/main/resources/mapping 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,97 @@ +[config] +#package.views=WEB-INF/jsp +package.filters=org.chorem.pollen.rest +package.actions=org.chorem.pollen.rest.api +server.listener.class=org.chorem.pollen.rest.PollenServiceListener + +[filters] +* /* PollenServiceContextFilter.inject + +##### +#/!\# +##### il y a un bug si on met le DecoratorFilter en POST avec les formulaires +##### enctype="multipart/form-data", il faut donc que tous les form post +##### fasse un redirect en GET apres leur action, sinon on a pas de decorateur +##### le symptome de l'erreur est qu'il n'y a aucun parametre qui nous arrive :( + +[actions] + +# AuthService + +POST /login action:AuthService.login +GET /lostpassword/{token} action:AuthService.lostPassword +GET /logout action:AuthService.logout + +# CommentService + +GET /poll/{pollId}/comments action:CommentService.getComments +GET /poll/{pollId}/comments/{commentId} action:CommentService.getComment +PUT /poll/{pollId}/comments action:CommentService.addComment +POST /poll/{pollId}/comments action:CommentService.editComment +DELETE /poll/{pollId}/comments/{commentId} action:CommentService.deleteComment + +# FavoriteListService + +GET /favoritelists action:FavoriteList.getFavoriteLists +GET /favoritelists/{flId} action:FavoriteList.getFavoriteList +PUT /favoritelists action:FavoriteList.createFavoriteList +POST /favoritelists action:FavoriteList.editFavoriteList +DELETE /favoritelists/{flId} action:FavoriteList.deleteFavoriteList +GET /favoritelists/{flId}/members action:FavoriteList.getMembers +GET /favoritelists/{flId}/members/{mId} action:FavoriteList.getMember +PUT /favoritelists/{flId}/members action:FavoriteList.addMember +POST /favoritelists/{flId}/members action:FavoriteList.editMember +DELETE /favoritelists/{flId}/members/{mId} action:FavoriteList.removeMember + +# PollService + +GET /user/{userId}/polls?filter=created action:PollService.getCreatedPolls +GET /user/{userId}/polls?filter=invited action:PollService.getInvitedPolls +GET /user/{userId}/polls?filter=participated action:PollService.getParticipatedPolls +PUT /poll action:PollService.createPoll +POST /poll action:PollService.editPoll +DELETE /poll/{pollId} action:PollService.deletePoll +PUT /poll/{pollId} action:PollService.clonePoll +POST /poll/{pollId}?action={action} action:PollService.{action}Poll +GET /poll/{pollId}/choices action:PollService.getChoices +GET /poll/{pollId}/choices/{choiceId} action:PollService.getChoice +PUT /poll/{pollId}/choices action:PollService.addChoice +POST /poll/{pollId}/choices action:PollService.editChoice +DELETE /poll/{pollId}/choices/{choiceId} action:PollService.deleteChoice + +# UserService + +GET /users action:UserService.getUsers +GET /user/{userId} action:UserService.getUser +PUT /user action:UserService.createUser +POST /user action:UserService.editUser +GET /validateemail/{token} action:UserService.validateUserEmail + +# VoteCountingService + +GET /poll/{pollId}/results action:VoteCountingService.getResult + +# VoterListService + +POST /poll/{pollId}/favoriteLists/{flId} action:VoterListService.importFavoriteList +GET /poll/{pollId}/voterLists action:VoterListService.getVoterLists +GET /poll/{pollId}/voterLists/{vlId} action:VoterListService.getVoterList +POST /poll/{pollId}/voterLists {voterList} action:VoterListService.editVoterList +DELETE /poll/{pollId}/voterLists/{vlId} action:VoterListService.deleteVoterList +GET /poll/{pollId}/members action:VoterListService.getMembers +GET /poll/{pollId}/voterLists/{vlId}/members action:VoterListService.getMembers +GET /poll/{pollId}/voterLists/{vlId}/members/{mId} action:VoterListService.getMember +PUT /poll/{pollId}/members action:VoterListService.addMember +PUT /poll/{pollId}/voterLists/{vlId}/members action:VoterListService.addMember +POST /poll/{pollId}/members action:VoterListService.editMember +POST /poll/{pollId}/voterLists/{vlId}/members action:VoterListService.editMember +DELETE /poll/{pollId}/members/{mId} action:VoterListService.deleteMember +DELETE /poll/{pollId}/voterLists/{vlId}/members/{mId} action:VoterListService.deleteMember + +# VoteService + +GET /poll/{pollId}/votes action:VoteService.getVotes +GET /poll/{pollId}/votes/{voteId} action:VoteService.getVote +PUT /poll/{pollId}/votes action:VoteService.addVote +POST /poll/{pollId}/votes action:VoteService.editVote +DELETE /poll/{pollId}/votes/{voteId} action:VoteService.deleteVote Added: branches/pollen-2.0/pollen-rest-api/src/main/webapp/WEB-INF/web.xml =================================================================== --- branches/pollen-2.0/pollen-rest-api/src/main/webapp/WEB-INF/web.xml (rev 0) +++ branches/pollen-2.0/pollen-rest-api/src/main/webapp/WEB-INF/web.xml 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<web-app version="3.0" + xmlns="http://java.sun.com/xml/ns/javaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee + http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> + + <!-- workarround for webmotion bug http://projects.debux.org/issues/293 --> + <!--session-config> + <tracking-mode>COOKIE</tracking-mode> + </session-config--> + + <filter> + <filter-name>jpaTransaction</filter-name> + <filter-class> + org.chorem.pollen.rest.PollenJpaTransactionFilter + </filter-class> + </filter> + + <filter-mapping> + <filter-name>jpaTransaction</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> +</web-app> \ No newline at end of file Property changes on: branches/pollen-2.0/pollen-rest-api/src/main/webapp/WEB-INF/web.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-rest-api/src/test/resources/log4j.properties =================================================================== --- branches/pollen-2.0/pollen-rest-api/src/test/resources/log4j.properties (rev 0) +++ branches/pollen-2.0/pollen-rest-api/src/test/resources/log4j.properties 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,9 @@ +log4j.rootCategory=ERROR, console + +log4j.appender.console=org.apache.log4j.ConsoleAppender +log4j.appender.console.layout=org.apache.log4j.PatternLayout +log4j.appender.console.layout.ConversionPattern=%d{hh:mm:ss} %5p (%F:%L) %m%n + +# log4j.logger.org.chorem.pollen=TRACE + +# log4j.logger.org.hibernate.tool.hbm2ddl.SchemaExport=FATAL Property changes on: branches/pollen-2.0/pollen-rest-api/src/test/resources/log4j.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Property changes on: branches/pollen-2.0/pollen-service ___________________________________________________________________ Added: svn:ignore + target .idea *.ipr *.iws *.iml Property changes on: branches/pollen-2.0/pollen-service/LICENSE.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Property changes on: branches/pollen-2.0/pollen-service/README.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Property changes on: branches/pollen-2.0/pollen-service/changelog.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-service/pom.xml =================================================================== --- branches/pollen-2.0/pollen-service/pom.xml (rev 0) +++ branches/pollen-2.0/pollen-service/pom.xml 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,121 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.chorem</groupId> + <artifactId>pollen</artifactId> + <version>2.0-SNAPSHOT</version> + </parent> + + <groupId>org.chorem.pollen</groupId> + <artifactId>pollen-service</artifactId> + + <name>Pollen :: Service </name> + <description>Pollen Service Layer</description> + + <dependencies> + + <!--dependency> + <groupId>${project.groupId}</groupId> + <artifactId>pollen-votecounting-api</artifactId> + <version>${project.version}</version> + </dependency--> + + <dependency> + <groupId>org.hibernate.javax.persistence</groupId> + <artifactId>hibernate-jpa-2.0-api</artifactId> + </dependency> + + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>pollen-persistence</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>com.esotericsoftware.yamlbeans</groupId> + <artifactId>yamlbeans</artifactId> + </dependency> + + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </dependency> + <dependency> + <groupId>commons-collections</groupId> + <artifactId>commons-collections</artifactId> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-email</artifactId> + </dependency> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </dependency> + + <dependency> + <groupId>javax.mail</groupId> + <artifactId>mail</artifactId> + </dependency> + <dependency> + <groupId>rome</groupId> + <artifactId>rome</artifactId> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </dependency> + + <dependency> + <groupId>org.nuiton.jpa</groupId> + <artifactId>nuiton-jpa-junit</artifactId> + </dependency> + + <dependency> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-utils</artifactId> + </dependency> + + <dependency> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-config</artifactId> + </dependency> + + <dependency> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-jcl</artifactId> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <scope>test</scope> + </dependency> + + </dependencies> + +</project> Property changes on: branches/pollen-2.0/pollen-service/pom.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/AbstractPollenService.java =================================================================== --- branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/AbstractPollenService.java (rev 0) +++ branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/AbstractPollenService.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,81 @@ +package org.chorem.pollen.service; + +import com.google.common.base.Preconditions; +import org.chorem.pollen.persistence.PollenPersistenceContext; +import org.chorem.pollen.service.config.PollenServiceConfig; +import org.nuiton.jpa.api.JpaEntities; +import org.nuiton.jpa.api.JpaEntity; + +import java.util.Date; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public abstract class AbstractPollenService implements PollenServiceSupport { + + protected PollenServiceContext serviceContext; + + protected void checkHasId(JpaEntity entity) { + Preconditions.checkState(JpaEntities.isEntityHasId(entity)); + } + + protected void checkHasNoId(JpaEntity entity) { + Preconditions.checkState(JpaEntities.isEntityHasNoId(entity)); + } + + @Override + public void setServiceContext(PollenServiceContext serviceContext) { + this.serviceContext = serviceContext; + } + + protected Date getNow() { + return serviceContext.getNow(); + } + + protected String generateId() { + return serviceContext.generateUUID(); + } + + protected PollenPersistenceContext getPersistenceContext() { + return serviceContext.getPersistenceContext(); + } + + protected PollenServiceConfig getPollenServiceConfig() { + return serviceContext.getPollenServiceConfig(); + } + + protected AuthService getAuthService() { + return serviceContext.getAuthService(); + } + + protected CommentService getCommentService() { + return serviceContext.getCommentService(); + } + + protected FavoriteListService getFavoriteListService() { + return serviceContext.getFavoriteListService(); + } + + protected PollService getPollService() { + return serviceContext.getPollService(); + } + + protected UserService getUserService() { + return serviceContext.getUserService(); + } + + protected VoteCountingService getVoteCountingService() { + return serviceContext.getVoteCountingService(); + } + + protected VoterListService getVoterListService() { + return serviceContext.getVoterListService(); + } + + protected VoteService getVoteService() { + return serviceContext.getVoteService(); + } +} Property changes on: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/AbstractPollenService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/AuthService.java =================================================================== --- branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/AuthService.java (rev 0) +++ branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/AuthService.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,29 @@ +package org.chorem.pollen.service; + +import com.google.common.base.Preconditions; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class AuthService extends AbstractPollenService { + + public String login(String login, String password) { + Preconditions.checkNotNull(login); + Preconditions.checkNotNull(password); + //TODO + return null; + } + + public void lostPassword(String token) { + Preconditions.checkNotNull(token); + //TODO + } + + public void logout(String login) { + Preconditions.checkNotNull(login); + //TODO + } +} Property changes on: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/AuthService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/CommentService.java =================================================================== --- branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/CommentService.java (rev 0) +++ branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/CommentService.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,103 @@ +package org.chorem.pollen.service; + +/* + * #%L + * Pollen :: Service API + * $Id$ + * $HeadURL:$ + * %% + * Copyright (C) 2009 - 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import com.google.common.base.Preconditions; +import org.chorem.pollen.persistence.entity.Comment; +import org.chorem.pollen.persistence.entity.Poll; + +import java.util.List; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class CommentService extends AbstractPollenService { + + public List<Comment> getComments(String pollId) { + Preconditions.checkNotNull(pollId); + Poll poll = getPollService().getPoll(pollId); + Preconditions.checkNotNull(poll); + + return poll.getComment(); + } + + public Comment getComment(String pollId, String commentId) { + Preconditions.checkNotNull(pollId); + Preconditions.checkNotNull(commentId); + Poll poll = getPollService().getPoll(pollId); + Preconditions.checkNotNull(poll); + + Comment comment = poll.getCommentById(commentId); + Preconditions.checkNotNull(comment); + + return comment; + } + + public Comment addComment(String pollId, Comment comment) { + Preconditions.checkNotNull(pollId); + checkHasNoId(comment); + Poll poll = getPollService().getPoll(pollId); + Preconditions.checkNotNull(poll); + + poll.addComment(comment); + getPersistenceContext().getPollDao().merge(poll); + getPersistenceContext().commit(); + return null; + } + + public Comment editComment(String pollId, Comment comment) { + Preconditions.checkNotNull(pollId); + checkHasId(comment); + Poll poll = getPollService().getPoll(pollId); + Preconditions.checkNotNull(poll); + + Comment persisted = poll.getCommentById(comment.getId()); + Preconditions.checkNotNull(persisted); + + getPersistenceContext().getCommentDao().merge(comment); + + getPersistenceContext().commit(); + return null; + } + + public void deleteComment(String pollId, String commentId) { + Preconditions.checkNotNull(pollId); + Preconditions.checkNotNull(commentId); + Poll poll = getPollService().getPoll(pollId); + Preconditions.checkNotNull(poll); + + Comment comment = poll.getCommentById(commentId); + Preconditions.checkNotNull(comment); + + poll.removeComment(comment); + + getPersistenceContext().getPollDao().merge(poll); + + getPersistenceContext().commit(); + } + +} Property changes on: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/CommentService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/DefaultPollenServiceContext.java =================================================================== --- branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/DefaultPollenServiceContext.java (rev 0) +++ branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/DefaultPollenServiceContext.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,126 @@ +package org.chorem.pollen.service; + +import org.chorem.pollen.persistence.JpaPollenPersistenceContext; +import org.chorem.pollen.persistence.PollenPersistenceContext; +import org.chorem.pollen.service.config.PollenServiceConfig; + +import javax.persistence.EntityManager; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.Date; +import java.util.UUID; + +public class DefaultPollenServiceContext implements PollenServiceContext { + + protected EntityManager entityManager; + + protected PollenServiceConfig pollenServiceConfig; + + protected PollenPersistenceContext persistenceContext; + + public void setEntityManager(EntityManager entityManager) { + this.entityManager = entityManager; + } + + public void setPollenServiceConfig(PollenServiceConfig pollenServiceConfig) { + this.pollenServiceConfig = pollenServiceConfig; + } + + @Override + public PollenServiceConfig getPollenServiceConfig() { + return pollenServiceConfig; + } + + @Override + public String generateUUID() { + return UUID.randomUUID().toString(); + } + + @Override + public Date getNow() { + Date now = new Date(); + return now; + } + + @Override + public PollenPersistenceContext getPersistenceContext() { + if (persistenceContext == null) { + persistenceContext = new JpaPollenPersistenceContext(entityManager); + } + return persistenceContext; + } + + @Override + public AuthService getAuthService() { + return newService(AuthService.class); + } + + @Override + public CommentService getCommentService() { + return newService(CommentService.class); + } + + @Override + public FavoriteListService getFavoriteListService() { + return newService(FavoriteListService.class); + } + + @Override + public PollService getPollService() { + return newService(PollService.class); + } + + @Override + public UserService getUserService() { + return newService(UserService.class); + } + + @Override + public VoteCountingService getVoteCountingService() { + return newService(VoteCountingService.class); + } + + @Override + public VoterListService getVoterListService() { + return newService(VoterListService.class); + } + + @Override + public VoteService getVoteService() { + return newService(VoteService.class); + } + + protected <E extends PollenServiceSupport> E newService(Class<E> serviceClass) { + + E service; + + try { + + Constructor<E> constructor = serviceClass.getConstructor(); + + service = constructor.newInstance(); + + } catch (NoSuchMethodException e) { + + throw new PollenTechnicalException("all services must provide a default public constructor", e); + + } catch (InvocationTargetException e) { + + throw new PollenTechnicalException("unable to instantiate pollen service", e); + + } catch (InstantiationException e) { + + throw new PollenTechnicalException("unable to instantiate pollen service", e); + + } catch (IllegalAccessException e) { + + throw new PollenTechnicalException("unable to instantiate pollen service", e); + } + + service.setServiceContext(this); + + return service; + + } + +} Property changes on: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/DefaultPollenServiceContext.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/FavoriteListService.java =================================================================== --- branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/FavoriteListService.java (rev 0) +++ branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/FavoriteListService.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,196 @@ +package org.chorem.pollen.service; + +/* + * #%L + * Pollen :: Service API + * $Id$ + * $HeadURL:$ + * %% + * Copyright (C) 2009 - 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import com.google.common.base.Preconditions; +import org.chorem.pollen.persistence.entity.FavoriteList; +import org.chorem.pollen.persistence.entity.FavoriteListMember; +import org.chorem.pollen.persistence.entity.PollenUser; + +import java.util.List; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class FavoriteListService extends AbstractPollenService { + + public List<FavoriteList> getFavoriteLists(String userId) { + Preconditions.checkNotNull(userId); + PollenUser user = getUserService().getUser(userId); + Preconditions.checkNotNull(user); + + List<FavoriteList> result = user.getFavoriteList(); + return result; + } + + public FavoriteList getFavoriteList(String userId, String favoriteListId) { + Preconditions.checkNotNull(userId); + Preconditions.checkNotNull(favoriteListId); + PollenUser user = getUserService().getUser(userId); + Preconditions.checkNotNull(user); + FavoriteList favoriteList = user.getFavoriteListById(favoriteListId); + return favoriteList; + } + + public FavoriteList createFavoriteList(String userId, FavoriteList favoriteList) { + Preconditions.checkNotNull(userId); + Preconditions.checkNotNull(favoriteList); + checkHasNoId(favoriteList); + + PollenUser user = getUserService().getUser(userId); + Preconditions.checkNotNull(user); + + user.addFavoriteList(favoriteList); + user = getPersistenceContext().getPollenUserDao().merge(user); + + getPersistenceContext().commit(); + return user.getFavoriteListById(favoriteList.getId()); + } + + public FavoriteList editFavoriteList(String userId, FavoriteList favoriteList) { + Preconditions.checkNotNull(userId); + Preconditions.checkNotNull(favoriteList); + checkHasId(favoriteList); + + PollenUser user = getUserService().getUser(userId); + Preconditions.checkNotNull(user); + + FavoriteList persisted = user.getFavoriteListById(favoriteList.getId()); + Preconditions.checkNotNull(persisted); + + getPersistenceContext().getFavoriteListDao().persist(favoriteList); + + getPersistenceContext().commit(); + return favoriteList; + } + + public void deleteFavoriteList(String userId, String favoriteListId) { + Preconditions.checkNotNull(userId); + Preconditions.checkNotNull(favoriteListId); + + PollenUser user = getUserService().getUser(userId); + Preconditions.checkNotNull(user); + + FavoriteList persisted = user.getFavoriteListById(favoriteListId); + Preconditions.checkNotNull(persisted); + + user.removeFavoriteList(persisted); + getPersistenceContext().getPollenUserDao().merge(user); + + getPersistenceContext().commit(); + } + + public List<FavoriteListMember> getMembers(String userId, String favoriteListId) { + Preconditions.checkNotNull(userId); + Preconditions.checkNotNull(favoriteListId); + + PollenUser user = getUserService().getUser(userId); + Preconditions.checkNotNull(user); + + FavoriteList favoriteList = user.getFavoriteListById(favoriteListId); + Preconditions.checkNotNull(favoriteList); + + return favoriteList.getFavoriteListMember(); + } + + public FavoriteListMember getMember(String userId, String favoriteListId, String memberId) { + Preconditions.checkNotNull(userId); + Preconditions.checkNotNull(favoriteListId); + Preconditions.checkNotNull(memberId); + + PollenUser user = getUserService().getUser(userId); + Preconditions.checkNotNull(user); + + FavoriteList favoriteList = user.getFavoriteListById(favoriteListId); + Preconditions.checkNotNull(favoriteList); + + FavoriteListMember member = favoriteList.getFavoriteListMemberById(memberId); + return member; + } + + public FavoriteListMember addMember(String userId, String favoriteListId, FavoriteListMember member) { + Preconditions.checkNotNull(userId); + Preconditions.checkNotNull(favoriteListId); + Preconditions.checkNotNull(member); + checkHasNoId(member); + + PollenUser user = getUserService().getUser(userId); + Preconditions.checkNotNull(user); + + FavoriteList favoriteList = user.getFavoriteListById(favoriteListId); + Preconditions.checkNotNull(favoriteList); + + favoriteList.addFavoriteListMember(member); + + favoriteList = getPersistenceContext().getFavoriteListDao().merge(favoriteList); + + getPersistenceContext().commit(); + FavoriteListMember result = favoriteList.getFavoriteListMemberById(member.getId()); + return result; + } + + public FavoriteListMember editMember(String userId, String favoriteListId, FavoriteListMember member) { + Preconditions.checkNotNull(userId); + Preconditions.checkNotNull(favoriteListId); + Preconditions.checkNotNull(member); + checkHasId(member); + + PollenUser user = getUserService().getUser(userId); + Preconditions.checkNotNull(user); + + FavoriteList favoriteList = user.getFavoriteListById(favoriteListId); + Preconditions.checkNotNull(favoriteList); + + FavoriteListMember persisted = favoriteList.getFavoriteListMemberById(member.getId()); + Preconditions.checkNotNull(persisted); + + member = getPersistenceContext().getFavoriteListMemberDao().merge(member); + getPersistenceContext().commit(); + return member; + } + + public void removeMember(String userId, String favoriteListId, String memberId) { + Preconditions.checkNotNull(userId); + Preconditions.checkNotNull(favoriteListId); + Preconditions.checkNotNull(memberId); + + PollenUser user = getUserService().getUser(userId); + Preconditions.checkNotNull(user); + + FavoriteList favoriteList = user.getFavoriteListById(favoriteListId); + Preconditions.checkNotNull(favoriteList); + + FavoriteListMember member = favoriteList.getFavoriteListMemberById(memberId); + Preconditions.checkNotNull(member); + + favoriteList.removeFavoriteListMember(member); + + getPersistenceContext().getFavoriteListDao().merge(favoriteList); + getPersistenceContext().commit(); + } + +} Property changes on: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/FavoriteListService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/FixturesService.java =================================================================== --- branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/FixturesService.java (rev 0) +++ branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/FixturesService.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,76 @@ +package org.chorem.pollen.service; + +import com.google.common.base.Preconditions; +import com.google.common.collect.Maps; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.pollen.persistence.PollenPersistenceContext; +import org.chorem.pollen.persistence.dao.PollenUserJpaDao; +import org.chorem.pollen.persistence.entity.PollenUser; + +import java.util.Collection; +import java.util.Map; + +public class FixturesService extends AbstractPollenService { + + private static final Log log = LogFactory.getLog(FixturesService.class); + + protected Map<String, PollenFixtures> fixtureSets = Maps.newHashMap(); + + public PollenFixtures cleanDatabaseAndLoadFixtures(String fixturesSetName) { + + return loadFixtures(fixturesSetName, true); + + } + + public PollenFixtures loadFixtures(String fixturesSetName) { + + return loadFixtures(fixturesSetName, false); + + } + + protected PollenFixtures loadFixtures(String fixturesSetName, boolean cleanDatabase) { + + boolean devMode = serviceContext.getPollenServiceConfig().isDevMode(); + + Preconditions.checkState(devMode); + + PollenFixtures fixtures = fixtureSets.get(fixturesSetName); + + if (fixtures == null) { + + fixtures = new PollenFixtures(fixturesSetName); + + fixtureSets.put(fixturesSetName, fixtures); + + if (log.isInfoEnabled()) { + log.info("will restore database with fixture set"); + } + + PollenPersistenceContext persistenceContext = serviceContext.getPersistenceContext(); + + if (cleanDatabase) { + + persistenceContext.clearDatabase(); + + } + + PollenUserJpaDao userDao = persistenceContext.getPollenUserDao(); + + Collection<PollenUser> users = fixtures.fixture("users"); + + for (PollenUser user : users) { + + userDao.persist(user); + } + + persistenceContext.commit(); + + + } + + return fixtures; + + } + +} Property changes on: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/FixturesService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollResult.java =================================================================== --- branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollResult.java (rev 0) +++ branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollResult.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,13 @@ +package org.chorem.pollen.service; + +import java.io.Serializable; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class PollResult implements Serializable { + private static final long serialVersionUID = 1L; +} Property changes on: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollResult.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollService.java =================================================================== --- branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollService.java (rev 0) +++ branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollService.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,188 @@ +package org.chorem.pollen.service; + +import com.google.common.base.Preconditions; +import org.chorem.pollen.persistence.entity.Choice; +import org.chorem.pollen.persistence.entity.Poll; +import org.chorem.pollen.persistence.entity.PollenUser; + +import java.io.File; +import java.util.List; +import java.util.Set; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class PollService extends AbstractPollenService { + + public Set<Poll> getCreatedPolls(String userId) { + Preconditions.checkNotNull(userId); + + PollenUser user = getUserService().getUser(userId); + Preconditions.checkNotNull(user); + + return getPersistenceContext().getPollDao().findAllCreated(userId); + } + + public Set<Poll> getInvitedPolls(String userId) { + Preconditions.checkNotNull(userId); + + PollenUser user = getUserService().getUser(userId); + Preconditions.checkNotNull(user); + + return getPersistenceContext().getPollDao().findAllInvited(userId); + } + + public Set<Poll> getParticipatedPolls(String userId) { + Preconditions.checkNotNull(userId); + + PollenUser user = getUserService().getUser(userId); + Preconditions.checkNotNull(user); + + return getPersistenceContext().getPollDao().findAllParticipated(userId); + } + + public Poll getPoll(String pollId) { + Preconditions.checkNotNull(pollId); + Poll result = getPersistenceContext().getPollDao().findById(pollId); + return result; + } + + public Poll createPoll(String userId, Poll poll) { + Preconditions.checkNotNull(userId); + Preconditions.checkNotNull(poll); + checkHasNoId(poll); + + PollenUser user = getUserService().getUser(userId); + + if (user != null) { + + // link to creator + //TODO + } + getPersistenceContext().getPollDao().persist(poll); + + getPersistenceContext().commit(); + return poll; + } + + public Poll editPoll(Poll poll) { + Preconditions.checkNotNull(poll); + checkHasId(poll); + + Poll persisted = getPoll(poll.getId()); + Preconditions.checkNotNull(persisted); + + Poll result = getPersistenceContext().getPollDao().merge(poll); + getPersistenceContext().commit(); + return result; + } + + public void deletePoll(String pollId) { + Preconditions.checkNotNull(pollId); + + Poll poll = getPoll(pollId); + Preconditions.checkNotNull(poll); + + getPersistenceContext().getPollDao().remove(poll); + getPersistenceContext().commit(); + } + + public Poll clonePoll(String pollId) { + Preconditions.checkNotNull(pollId); + + Poll poll = getPoll(pollId); + Preconditions.checkNotNull(poll); + + getPersistenceContext().commit(); + return null; + } + + public File closePoll(String pollId) { + Preconditions.checkNotNull(pollId); + + Poll poll = getPoll(pollId); + Preconditions.checkNotNull(poll); + + getPersistenceContext().commit(); + return null; + } + + public File exportPoll(String pollId) { + Preconditions.checkNotNull(pollId); + //TODO + return null; + } + + public List<Choice> getChoices(String pollId) { + Preconditions.checkNotNull(pollId); + + Poll poll = getPoll(pollId); + Preconditions.checkNotNull(poll); + + return poll.getChoice(); + } + + public Choice getChoice(String pollId, String choiceId) { + Preconditions.checkNotNull(pollId); + Preconditions.checkNotNull(choiceId); + + Poll poll = getPoll(pollId); + Preconditions.checkNotNull(poll); + + Choice result = poll.getChoiceById(choiceId); + return result; + } + + public Choice addChoice(String pollId, Choice choice) { + Preconditions.checkNotNull(pollId); + Preconditions.checkNotNull(choice); + checkHasNoId(choice); + + Poll poll = getPoll(pollId); + Preconditions.checkNotNull(poll); + + poll.addChoice(choice); + + getPersistenceContext().getPollDao().merge(poll); + + getPersistenceContext().commit(); + return null; + } + + public Choice editChoice(String pollId, Choice choice) { + Preconditions.checkNotNull(pollId); + Preconditions.checkNotNull(choice); + checkHasId(choice); + + Poll poll = getPoll(pollId); + Preconditions.checkNotNull(poll); + + Choice persisted = poll.getChoiceById(choice.getId()); + Preconditions.checkNotNull(persisted); + + Choice result = getPersistenceContext().getChoiceDao().merge(choice); + + getPersistenceContext().commit(); + return result; + } + + public void deleteChoice(String pollId, String choiceId) { + Preconditions.checkNotNull(pollId); + Preconditions.checkNotNull(choiceId); + + Poll poll = getPoll(pollId); + Preconditions.checkNotNull(poll); + + Choice choice = poll.getChoiceById(choiceId); + Preconditions.checkNotNull(choice); + + poll.removeChoice(choice); + + getPersistenceContext().getPollDao().merge(poll); + + getPersistenceContext().commit(); + } +} Property changes on: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollenFixtures.java =================================================================== --- branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollenFixtures.java (rev 0) +++ branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollenFixtures.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,55 @@ +package org.chorem.pollen.service; + +import com.esotericsoftware.yamlbeans.YamlException; +import com.esotericsoftware.yamlbeans.YamlReader; +import org.apache.commons.io.Charsets; +import org.apache.commons.io.IOUtils; +import org.chorem.pollen.persistence.entity.Choice; +import org.chorem.pollen.persistence.entity.Comment; +import org.chorem.pollen.persistence.entity.FavoriteList; +import org.chorem.pollen.persistence.entity.FavoriteListMember; +import org.chorem.pollen.persistence.entity.Poll; +import org.chorem.pollen.persistence.entity.PollenUser; +import org.chorem.pollen.persistence.entity.Vote; +import org.chorem.pollen.persistence.entity.VoterList; +import org.chorem.pollen.persistence.entity.VoterListMember; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Map; + +public class PollenFixtures { + + protected Map<String, Object> fixtures; + + public PollenFixtures(String fixturesName) { + String yamlPath = "/" + fixturesName + ".yaml"; + InputStream inputStream = PollenFixtures.class.getResourceAsStream(yamlPath); + String yaml; + try { + yaml = IOUtils.toString(inputStream, Charsets.UTF_8); + } catch (IOException e) { + throw new IllegalArgumentException(fixturesName + " is not a valid fixtures set name", e); + } + YamlReader reader = new YamlReader(yaml); + reader.getConfig().setClassTag("poll", Poll.class); + reader.getConfig().setClassTag("user", PollenUser.class); + reader.getConfig().setClassTag("favorite-list", FavoriteList.class); + reader.getConfig().setClassTag("favorite-list-member", FavoriteListMember.class); + reader.getConfig().setClassTag("comment", Comment.class); + reader.getConfig().setClassTag("choice", Choice.class); + reader.getConfig().setClassTag("voter-list", VoterList.class); + reader.getConfig().setClassTag("voter-list-member", VoterListMember.class); + reader.getConfig().setClassTag("vote", Vote.class); + + try { + fixtures = (Map<String, Object>) reader.read(); + } catch (YamlException e) { + throw new PollenTechnicalException("unable to read yaml file", e); + } + } + + public <E> E fixture(String id) { + return (E) fixtures.get(id); + } +} Property changes on: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollenFixtures.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollenServiceContext.java =================================================================== --- branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollenServiceContext.java (rev 0) +++ branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollenServiceContext.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,38 @@ +package org.chorem.pollen.service; + +import org.chorem.pollen.persistence.PollenPersistenceContext; +import org.chorem.pollen.service.config.PollenServiceConfig; + +import java.util.Date; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public interface PollenServiceContext { + + String generateUUID(); + + Date getNow(); + + PollenPersistenceContext getPersistenceContext(); + + PollenServiceConfig getPollenServiceConfig(); + + AuthService getAuthService(); + + CommentService getCommentService(); + + FavoriteListService getFavoriteListService(); + + PollService getPollService(); + + UserService getUserService(); + + VoteCountingService getVoteCountingService(); + + VoterListService getVoterListService(); + + VoteService getVoteService(); + +} Property changes on: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollenServiceContext.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollenServiceSupport.java =================================================================== --- branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollenServiceSupport.java (rev 0) +++ branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollenServiceSupport.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,12 @@ +package org.chorem.pollen.service; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public interface PollenServiceSupport { + + void setServiceContext(PollenServiceContext serviceContext); +} Property changes on: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollenServiceSupport.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollenTechnicalException.java =================================================================== --- branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollenTechnicalException.java (rev 0) +++ branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollenTechnicalException.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,21 @@ +package org.chorem.pollen.service; + +public class PollenTechnicalException extends RuntimeException { + + private static final long serialVersionUID = 1L; + + public PollenTechnicalException() { + } + + public PollenTechnicalException(String message) { + super(message); + } + + public PollenTechnicalException(String message, Throwable cause) { + super(message, cause); + } + + public PollenTechnicalException(Throwable cause) { + super(cause); + } +} Property changes on: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/PollenTechnicalException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/UserService.java =================================================================== --- branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/UserService.java (rev 0) +++ branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/UserService.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,115 @@ +package org.chorem.pollen.service; + +import com.google.common.base.Preconditions; +import org.apache.commons.lang3.ObjectUtils; +import org.chorem.pollen.persistence.dao.PollenUserJpaDao; +import org.chorem.pollen.persistence.entity.PollenUser; + +import java.util.List; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class UserService extends AbstractPollenService implements PollenServiceSupport { + + public List<PollenUser> getUsers() { + return getPollenUserDao().findAll(); + } + + public PollenUser getUser(String userId) { + Preconditions.checkNotNull(userId); + + return getPollenUserDao().findById(userId); + } + + public PollenUser createUserByAdmin(PollenUser user) { + Preconditions.checkNotNull(user); + checkHasNoId(user); + + getPollenUserDao().persist(user); + getPersistenceContext().commit(); + + // send a notification to user (to validate his email changed) + notifyUserCreated(user, true); + return user; + } + + public PollenUser createUser(PollenUser user) { + Preconditions.checkNotNull(user); + checkHasNoId(user); + + // add a emailValidationToken + String emailValidationToken = generateId(); + user.setEmailActivationToken(emailValidationToken); + + PollenUserJpaDao dao = getPollenUserDao(); + dao.persist(user); + getPersistenceContext().commit(); + + // send a notification to user (to validate his email changed) + notifyUserCreated(user, false); + return user; + } + + public PollenUser editUser(PollenUser user) { + Preconditions.checkNotNull(user); + checkHasId(user); + PollenUser persisted = getUser(user.getId()); + + Preconditions.checkNotNull(persisted); + + boolean emailChanged = ObjectUtils.notEqual(persisted.getEmail(), user.getEmail()); + + if (emailChanged) { + + // add a new emailValidationtoken + String emailValidationToken = generateId(); + user.setEmailActivationToken(emailValidationToken); + } + + user = getPollenUserDao().merge(user); + getPersistenceContext().commit(); + + if (emailChanged) { + + // send a notification to user (to validate his email changed) + notifyEmailChanged(persisted); + } + return user; + } + + public void validateUserEmail(String userId, String token) { + + Preconditions.checkNotNull(userId); + Preconditions.checkNotNull(token); + + PollenUser user = getUser(userId); + + Preconditions.checkNotNull(user); + + boolean valid = ObjectUtils.equals( + user.getEmailActivationToken(), token); + + if (valid) { + user.setEmailActivationToken(null); + } + + getPollenUserDao().merge(user); + getPersistenceContext().commit(); + } + + protected void notifyEmailChanged(PollenUser user) { + //TODO + } + + protected void notifyUserCreated(PollenUser user, boolean createByAdmin) { + //TODO + } + + protected PollenUserJpaDao getPollenUserDao() { + return getPersistenceContext().getPollenUserDao(); + } +} Property changes on: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/UserService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/VoteCountingService.java =================================================================== --- branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/VoteCountingService.java (rev 0) +++ branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/VoteCountingService.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,22 @@ +package org.chorem.pollen.service; + +import com.google.common.base.Preconditions; +import org.chorem.pollen.persistence.entity.Poll; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class VoteCountingService extends AbstractPollenService { + + //GET /poll/{pollId}/results + public PollResult getResult(String pollId) { + Preconditions.checkNotNull(pollId); + Poll poll = getPollService().getPoll(pollId); + Preconditions.checkNotNull(poll); + //TODO + return null; + } +} Property changes on: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/VoteCountingService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/VoteService.java =================================================================== --- branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/VoteService.java (rev 0) +++ branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/VoteService.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,85 @@ +package org.chorem.pollen.service; + +import com.google.common.base.Preconditions; +import org.chorem.pollen.persistence.entity.Poll; +import org.chorem.pollen.persistence.entity.Vote; + +import java.util.List; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class VoteService extends AbstractPollenService { + + public List<Vote> getVotes(String pollId) { + Preconditions.checkNotNull(pollId); + + Poll poll = getPollService().getPoll(pollId); + Preconditions.checkNotNull(poll); + + return poll.getVote(); + } + + public Vote getVote(String pollId, String voteId) { + Preconditions.checkNotNull(pollId); + Preconditions.checkNotNull(voteId); + + Poll poll = getPollService().getPoll(pollId); + Preconditions.checkNotNull(poll); + + Vote result = poll.getVoteById(voteId); + return result; + } + + public Vote addVote(String pollId, Vote vote) { + Preconditions.checkNotNull(pollId); + Preconditions.checkNotNull(vote); + checkHasNoId(vote); + + Poll poll = getPollService().getPoll(pollId); + Preconditions.checkNotNull(poll); + + poll.addVote(vote); + getPersistenceContext().getPollDao().merge(poll); + + getPersistenceContext().commit(); + return null; + } + + public Vote editVote(String pollId, Vote vote) { + Preconditions.checkNotNull(pollId); + Preconditions.checkNotNull(vote); + checkHasId(vote); + + Poll poll = getPollService().getPoll(pollId); + Preconditions.checkNotNull(poll); + + Preconditions.checkState(poll.containsVoteById(vote.getId())); + + Vote result = getPersistenceContext().getVoteDao().merge(vote); + + getPersistenceContext().commit(); + return result; + } + + public void deleteVote(String pollId, String voteId) { + Preconditions.checkNotNull(pollId); + Preconditions.checkNotNull(voteId); + + Poll poll = getPollService().getPoll(pollId); + Preconditions.checkNotNull(poll); + + Vote vote = getVote(pollId, voteId); + Preconditions.checkNotNull(vote); + + poll.removeVote(vote); + + getPersistenceContext().getPollDao().merge(poll); + + getPersistenceContext().commit(); + } + +} Property changes on: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/VoteService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/VoterListService.java =================================================================== --- branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/VoterListService.java (rev 0) +++ branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/VoterListService.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,207 @@ +package org.chorem.pollen.service; + +import com.google.common.base.Preconditions; +import org.chorem.pollen.persistence.dao.VoterListJpaDao; +import org.chorem.pollen.persistence.dao.VoterListMemberJpaDao; +import org.chorem.pollen.persistence.entity.FavoriteList; +import org.chorem.pollen.persistence.entity.FavoriteListMember; +import org.chorem.pollen.persistence.entity.Poll; +import org.chorem.pollen.persistence.entity.VoterList; +import org.chorem.pollen.persistence.entity.VoterListMember; + +import java.util.List; +import java.util.Set; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class VoterListService extends AbstractPollenService { + + public VoterList importFavoriteList(String userId, String pollId, String favoriteListId) { + Preconditions.checkNotNull(userId); + Preconditions.checkNotNull(pollId); + Preconditions.checkNotNull(favoriteListId); + + Poll poll = getPollService().getPoll(pollId); + Preconditions.checkNotNull(poll); + + FavoriteList favoriteList = getFavoriteListService().getFavoriteList(userId, favoriteListId); + Preconditions.checkNotNull(favoriteList); + + VoterListJpaDao dao = getPersistenceContext().getVoterListDao(); + VoterList result = dao.newInstance(); + + result.setName(favoriteList.getName()); + result.setWeight(1d); + + dao.persist(result); + + VoterListMemberJpaDao voterListMemberDao = getPersistenceContext().getVoterListMemberDao(); + + for (FavoriteListMember favoriteListMember : favoriteList.getFavoriteListMember()) { + + VoterListMember voterListMember = voterListMemberDao.newInstance(); + voterListMember.setWeight(1d); + voterListMember.setEmail(favoriteListMember.getEmail()); + voterListMember.setVoterList(result); + + voterListMemberDao.persist(voterListMember); + } + + getPersistenceContext().commit(); + return result; + } + + public List<VoterList> getVoterLists(String pollId) { + Preconditions.checkNotNull(pollId); + + Poll poll = getPollService().getPoll(pollId); + Preconditions.checkNotNull(poll); + + List<VoterList> result = poll.getVoterList(); + return result; + } + + public VoterList getVoterList(String pollId, String voterListId) { + Preconditions.checkNotNull(pollId); + + Poll poll = getPollService().getPoll(pollId); + Preconditions.checkNotNull(poll); + + if (voterListId == null) { + + Preconditions.checkState(!poll.isVoterListEmpty()); + + // use the first poll one + voterListId = poll.getVoterList(0).getId(); + } + + Preconditions.checkNotNull(voterListId); + VoterList result = poll.getVoterListById(voterListId); + + return result; + } + + public VoterList addVoterList(String pollId, VoterList voterList) { + Preconditions.checkNotNull(pollId); + Preconditions.checkNotNull(voterList); + checkHasNoId(voterList); + + Poll poll = getPollService().getPoll(pollId); + Preconditions.checkNotNull(poll); + + getPersistenceContext().getVoterListDao().persist(voterList); + getPersistenceContext().commit(); + return voterList; + } + + public VoterList editVoterList(String pollId, VoterList voterList) { + Preconditions.checkNotNull(pollId); + Preconditions.checkNotNull(voterList); + checkHasId(voterList); + + Poll poll = getPollService().getPoll(pollId); + Preconditions.checkNotNull(poll); + + Preconditions.checkState(poll.containsVoterListById(voterList.getId())); + + VoterList result = getPersistenceContext().getVoterListDao().merge(voterList); + getPersistenceContext().commit(); + return result; + } + + public void deleteVoterList(String pollId, String voterListId) { + Preconditions.checkNotNull(pollId); + Preconditions.checkNotNull(voterListId); + + VoterList voterList = getVoterList(pollId, voterListId); + Preconditions.checkNotNull(voterList); + + getPersistenceContext().getVoterListDao().remove(voterList); + + getPersistenceContext().commit(); + } + + public Set<VoterListMember> getMembers(String pollId, String voterListId) { + Preconditions.checkNotNull(pollId); + Preconditions.checkNotNull(voterListId); + + VoterList voterList = getVoterList(pollId, voterListId); + Preconditions.checkNotNull(voterList); + + Set<VoterListMember> result = getPersistenceContext().getVoterListMemberDao().findAllByVoterList(voterListId); + return result; + } + + public VoterListMember getMember(String pollId, String voterListId, String memberId) { + Preconditions.checkNotNull(pollId); + Preconditions.checkNotNull(voterListId); + Preconditions.checkNotNull(memberId); + + VoterList voterList = getVoterList(pollId, voterListId); + Preconditions.checkNotNull(voterList); + + VoterListMember result = getPersistenceContext().getVoterListMemberDao().findById(memberId); + + return result; + } + + public VoterListMember addMember(String pollId, String voterListId, VoterListMember member) { + Preconditions.checkNotNull(pollId); + Preconditions.checkNotNull(voterListId); + Preconditions.checkNotNull(member); + checkHasNoId(member); + + VoterList voterList = getVoterList(pollId, voterListId); + Preconditions.checkNotNull(voterList); + + member.setVoterList(voterList); + getPersistenceContext().getVoterListMemberDao().persist(member); + + getPersistenceContext().commit(); + return member; + } + + public VoterListMember editMember(String pollId, String voterListId, VoterListMember member) { + Preconditions.checkNotNull(pollId); + Preconditions.checkNotNull(voterListId); + Preconditions.checkNotNull(member); + checkHasId(member); + + VoterList voterList = getVoterList(pollId, voterListId); + Preconditions.checkNotNull(voterList); + + VoterListMemberJpaDao dao = getPersistenceContext().getVoterListMemberDao(); + + VoterListMember persisted = dao.findById(member.getId()); + Preconditions.checkNotNull(persisted); + + VoterListMember result = + dao.merge(member); + + getPersistenceContext().commit(); + return result; + } + + public void deleteMember(String pollId, String voterListId, String memberId) { + Preconditions.checkNotNull(pollId); + Preconditions.checkNotNull(voterListId); + Preconditions.checkNotNull(memberId); + + VoterList voterList = getVoterList(pollId, voterListId); + Preconditions.checkNotNull(voterList); + + VoterListMemberJpaDao dao = getPersistenceContext().getVoterListMemberDao(); + + VoterListMember result = dao.findById(memberId); + Preconditions.checkNotNull(result); + + dao.remove(result); + + getPersistenceContext().commit(); + } + +} Property changes on: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/VoterListService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/config/PollenServiceConfig.java =================================================================== --- branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/config/PollenServiceConfig.java (rev 0) +++ branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/config/PollenServiceConfig.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,61 @@ +package org.chorem.pollen.service.config; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.pollen.service.PollenTechnicalException; +import org.nuiton.util.config.ApplicationConfig; +import org.nuiton.util.config.ArgumentsParserException; + +import java.util.List; +import java.util.Map; +import java.util.Properties; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class PollenServiceConfig { + + private static final Log log = LogFactory.getLog(PollenServiceConfig.class); + + protected ApplicationConfig applicationConfig; + + public PollenServiceConfig() { + applicationConfig = new ApplicationConfig(); + applicationConfig.loadDefaultOptions(PollenServiceConfigOption.values()); + applicationConfig.setConfigFileName("pollen.properties"); + try { + applicationConfig.parse(); + } catch (ArgumentsParserException e) { + throw new PollenTechnicalException(e); + } + if (log.isInfoEnabled()) { + StringBuilder builder = new StringBuilder(); + List<PollenServiceConfigOption> options = Lists.newArrayList(PollenServiceConfigOption.values()); + for (PollenServiceConfigOption option : options) { + builder.append(String.format("\n%1$-40s = %2$s", + option.getKey(), + applicationConfig.getOption(option))); + } + log.info("Pollen configuration:" + builder.toString()); + } + } + + public Map<String, String> getJpaParameters() { + Map<String, String> jpaParameters = Maps.newHashMap(); + Properties hibernateProperties = applicationConfig.getOptionStartsWith("hibernate"); + jpaParameters.putAll((Map) hibernateProperties); + Properties jpaProperties = applicationConfig.getOptionStartsWith("javax.persistence"); + jpaParameters.putAll((Map) jpaProperties); + return jpaParameters; + } + + public boolean isDevMode() { + boolean isDevMode = applicationConfig.getOptionAsBoolean(PollenServiceConfigOption.DEV_MODE.key); + return isDevMode; + } +} Property changes on: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/config/PollenServiceConfig.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/config/PollenServiceConfigOption.java =================================================================== --- branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/config/PollenServiceConfigOption.java (rev 0) +++ branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/config/PollenServiceConfigOption.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,95 @@ +package org.chorem.pollen.service.config; + +import org.nuiton.util.config.ConfigOptionDef; + + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public enum PollenServiceConfigOption implements ConfigOptionDef { + + SMTP_HOST( + "smtp.host", + "Nom d'hôte du serveur SMTP", + "", String.class), + + SMTP_PORT( + "smtp.port", + "Le port du serveur SMTP", + "25", Integer.class), + + SMTP_FROM( + "smtp.from", + "L'adresse d'expéditeur pour les mails de notifications", + "", String.class), + + DEV_MODE( + "devMode", + "Mode développement, court-circuite l'envoi de mail", + "true", Boolean.class),; + + protected final String key; + + protected final String description; + + protected final Class<?> type; + + protected String defaultValue; + + private PollenServiceConfigOption(String key, String description, + String defaultValue, Class<?> type) { + this.key = key; + this.description = description; + this.defaultValue = defaultValue; + this.type = type; + } + + @Override + public String getKey() { + return key; + } + + @Override + public Class<?> getType() { + return type; + } + + @Override + public String getDescription() { + return description; + } + + @Override + public String getDefaultValue() { + return defaultValue; + } + + @Override + public boolean isTransient() { + return false; + } + + @Override + public boolean isFinal() { + return false; + } + + @Override + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } + + @Override + public void setTransient(boolean isTransient) { + // Nothing to do + } + + @Override + public void setFinal(boolean isFinal) { + // Nothing to do + } + +} Property changes on: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/config/PollenServiceConfigOption.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/config/package-info.java =================================================================== --- branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/config/package-info.java (rev 0) +++ branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/config/package-info.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,7 @@ +/** + * Package where to find configuration Pollen services. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +package org.chorem.pollen.service.config; Property changes on: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/config/package-info.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/package-info.java =================================================================== --- branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/package-info.java (rev 0) +++ branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/package-info.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,7 @@ +/** + * Base Package for the pollen business service. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +package org.chorem.pollen.service; Property changes on: branches/pollen-2.0/pollen-service/src/main/java/org/chorem/pollen/service/package-info.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-service/src/main/resources/fixtures.yaml =================================================================== --- branches/pollen-2.0/pollen-service/src/main/resources/fixtures.yaml (rev 0) +++ branches/pollen-2.0/pollen-service/src/main/resources/fixtures.yaml 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,30 @@ +tony: + &tony !user + id: pollen_user_tony + login: tony + password: fake + name: T + email: tony@pollen.fake + administrator: false + +jean: + &jean !user + id: pollen_user_jean + login: jean + password: fake + name: J + email: jean@pollen.fake + administrator: true + +julien: + &julien !user + id: pollen_user_julien + login: julien + name: J + email: julien@pollen.fake + administrator: true + +users: + - *tony + - *jean + - *julien \ No newline at end of file Added: branches/pollen-2.0/pollen-service/src/test/java/org/chorem/pollen/service/AbstractPollenServiceTest.java =================================================================== --- branches/pollen-2.0/pollen-service/src/test/java/org/chorem/pollen/service/AbstractPollenServiceTest.java (rev 0) +++ branches/pollen-2.0/pollen-service/src/test/java/org/chorem/pollen/service/AbstractPollenServiceTest.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,86 @@ +package org.chorem.pollen.service; + +import org.chorem.pollen.service.config.PollenServiceConfig; +import org.junit.Rule; +import org.nuiton.jpa.junit.JpaEntityManagerRule; + +import javax.persistence.EntityManager; +import java.util.Map; + +public abstract class AbstractPollenServiceTest { + + protected static final double DELTA = 0.0001; + + protected static PollenServiceConfig config; + + protected JpaEntityManagerRule jpaEntityManagerRule; + + protected FakePollenServiceContext serviceContext; + + protected PollenFixtures fixtures; + + protected static PollenServiceConfig getPollenServiceConfig() { + + if (config == null) { + + config = new PollenServiceConfig(); + } + + return config; + + } + + protected FakePollenServiceContext getServiceContext() { + + if (serviceContext == null) { + + synchronized (this) { + serviceContext = new FakePollenServiceContext(); + + serviceContext.setPollenServiceConfig(getPollenServiceConfig()); + + EntityManager entityManager = getJpaEntityManagerRule().getEntityManager(); + + serviceContext.setEntityManager(entityManager); + } + } + + return serviceContext; + + } + + protected void loadFixtures(String fixturesSetName) { + + FixturesService fixturesService = getServiceContext().newService(FixturesService.class); + + fixtures = fixturesService.loadFixtures(fixturesSetName); + + } + + protected <E> E fixture(String id) { + + return fixtures.fixture(id); + + } + + protected <E extends PollenServiceSupport> E newService(Class<E> serviceClass) { + + return getServiceContext().newService(serviceClass); + + } + + @Rule + public JpaEntityManagerRule getJpaEntityManagerRule() { + + if (jpaEntityManagerRule == null) { + + Map<String, String> jpaParameters = getPollenServiceConfig().getJpaParameters(); + + jpaEntityManagerRule = new JpaEntityManagerRule("pollenPersistenceUnit", jpaParameters); + } + + return jpaEntityManagerRule; + + } + +} Property changes on: branches/pollen-2.0/pollen-service/src/test/java/org/chorem/pollen/service/AbstractPollenServiceTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-service/src/test/java/org/chorem/pollen/service/FakePollenServiceContext.java =================================================================== --- branches/pollen-2.0/pollen-service/src/test/java/org/chorem/pollen/service/FakePollenServiceContext.java (rev 0) +++ branches/pollen-2.0/pollen-service/src/test/java/org/chorem/pollen/service/FakePollenServiceContext.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,41 @@ +package org.chorem.pollen.service; + +import com.google.common.base.Preconditions; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.pollen.persistence.JpaEntityIdGeneratorIfNotEmpty; +import org.chorem.pollen.persistence.JpaPollenPersistenceContext; +import org.chorem.pollen.persistence.PollenPersistenceContext; + +import java.util.Date; + +public class FakePollenServiceContext extends DefaultPollenServiceContext { + + private static final Log log = + LogFactory.getLog(FakePollenServiceContext.class); + + protected Date date; + + @Override + public Date getNow() { + Preconditions.checkState(date != null, "you must provide a date before running service test"); + if (log.isTraceEnabled()) { + log.trace("injecting fake date in service: " + date); + } + return date; + } + + @Override + public PollenPersistenceContext getPersistenceContext() { + if (persistenceContext == null) { + JpaEntityIdGeneratorIfNotEmpty idGenerator = new JpaEntityIdGeneratorIfNotEmpty(); + persistenceContext = new JpaPollenPersistenceContext(idGenerator, entityManager); + } + return persistenceContext; + } + + public void setDate(Date date) { + this.date = date; + } + +} Property changes on: branches/pollen-2.0/pollen-service/src/test/java/org/chorem/pollen/service/FakePollenServiceContext.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-service/src/test/java/org/chorem/pollen/service/UserServiceTest.java =================================================================== --- branches/pollen-2.0/pollen-service/src/test/java/org/chorem/pollen/service/UserServiceTest.java (rev 0) +++ branches/pollen-2.0/pollen-service/src/test/java/org/chorem/pollen/service/UserServiceTest.java 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,54 @@ +package org.chorem.pollen.service; + +import org.apache.commons.collections.CollectionUtils; +import org.chorem.pollen.persistence.entity.PollenUser; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.text.ParseException; +import java.util.Date; +import java.util.List; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class UserServiceTest extends AbstractPollenServiceTest { + + protected UserService service; + + protected PollenUser user; + + @Before + public void setUp() throws ParseException { + + loadFixtures("fixtures"); + + service = serviceContext.getUserService(); + + serviceContext.setDate(new Date(1363948427576l)); + + user = fixture("tony"); + } + + @Test + public void testGetPollenUsers() { + + List<PollenUser> users = service.getUsers(); + + Assert.assertNotNull(users); + Assert.assertTrue(CollectionUtils.isNotEmpty(users)); + } + + @Test + public void testGetPollenUser() { + + PollenUser user = service.getUser("pollen_user_tony"); + + Assert.assertNotNull(user); + Assert.assertEquals(this.user, user); + } +} Property changes on: branches/pollen-2.0/pollen-service/src/test/java/org/chorem/pollen/service/UserServiceTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: branches/pollen-2.0/pollen-service/src/test/resources/log4j.properties =================================================================== --- branches/pollen-2.0/pollen-service/src/test/resources/log4j.properties (rev 0) +++ branches/pollen-2.0/pollen-service/src/test/resources/log4j.properties 2013-06-04 14:47:08 UTC (rev 3815) @@ -0,0 +1,9 @@ +log4j.rootCategory=ERROR, console + +log4j.appender.console=org.apache.log4j.ConsoleAppender +log4j.appender.console.layout=org.apache.log4j.PatternLayout +log4j.appender.console.layout.ConversionPattern=%d{hh:mm:ss} %5p (%F:%L) %m%n + +# log4j.logger.org.chorem.pollen=TRACE + +# log4j.logger.org.hibernate.tool.hbm2ddl.SchemaExport=FATAL Property changes on: branches/pollen-2.0/pollen-service/src/test/resources/log4j.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: branches/pollen-2.0/pollen-services/pom.xml =================================================================== --- branches/pollen-2.0/pollen-services/pom.xml 2013-06-02 08:11:58 UTC (rev 3814) +++ branches/pollen-2.0/pollen-services/pom.xml 2013-06-04 14:47:08 UTC (rev 3815) @@ -6,7 +6,7 @@ <parent> <groupId>org.chorem</groupId> <artifactId>pollen</artifactId> - <version>1.5.5-SNAPSHOT</version> + <version>2.0-SNAPSHOT</version> </parent> <groupId>org.chorem.pollen</groupId> Modified: branches/pollen-2.0/pollen-ui-struts2/pom.xml =================================================================== --- branches/pollen-2.0/pollen-ui-struts2/pom.xml 2013-06-02 08:11:58 UTC (rev 3814) +++ branches/pollen-2.0/pollen-ui-struts2/pom.xml 2013-06-04 14:47:08 UTC (rev 3815) @@ -6,7 +6,7 @@ <parent> <groupId>org.chorem</groupId> <artifactId>pollen</artifactId> - <version>1.5.5-SNAPSHOT</version> + <version>2.0-SNAPSHOT</version> </parent> <groupId>org.chorem.pollen</groupId> Modified: branches/pollen-2.0/pollen-votecounting-aggregator/pom.xml =================================================================== --- branches/pollen-2.0/pollen-votecounting-aggregator/pom.xml 2013-06-02 08:11:58 UTC (rev 3814) +++ branches/pollen-2.0/pollen-votecounting-aggregator/pom.xml 2013-06-04 14:47:08 UTC (rev 3815) @@ -6,7 +6,7 @@ <parent> <groupId>org.chorem</groupId> <artifactId>pollen</artifactId> - <version>1.5.5-SNAPSHOT</version> + <version>2.0-SNAPSHOT</version> </parent> <groupId>org.chorem.pollen</groupId> Modified: branches/pollen-2.0/pollen-votecounting-api/pom.xml =================================================================== --- branches/pollen-2.0/pollen-votecounting-api/pom.xml 2013-06-02 08:11:58 UTC (rev 3814) +++ branches/pollen-2.0/pollen-votecounting-api/pom.xml 2013-06-04 14:47:08 UTC (rev 3815) @@ -6,7 +6,7 @@ <parent> <groupId>org.chorem</groupId> <artifactId>pollen</artifactId> - <version>1.5.5-SNAPSHOT</version> + <version>2.0-SNAPSHOT</version> </parent> <groupId>org.chorem.pollen</groupId> Modified: branches/pollen-2.0/pollen-votecounting-borda/pom.xml =================================================================== --- branches/pollen-2.0/pollen-votecounting-borda/pom.xml 2013-06-02 08:11:58 UTC (rev 3814) +++ branches/pollen-2.0/pollen-votecounting-borda/pom.xml 2013-06-04 14:47:08 UTC (rev 3815) @@ -6,7 +6,7 @@ <parent> <groupId>org.chorem</groupId> <artifactId>pollen</artifactId> - <version>1.5.5-SNAPSHOT</version> + <version>2.0-SNAPSHOT</version> </parent> <groupId>org.chorem.pollen</groupId> Modified: branches/pollen-2.0/pollen-votecounting-condorcet/pom.xml =================================================================== --- branches/pollen-2.0/pollen-votecounting-condorcet/pom.xml 2013-06-02 08:11:58 UTC (rev 3814) +++ branches/pollen-2.0/pollen-votecounting-condorcet/pom.xml 2013-06-04 14:47:08 UTC (rev 3815) @@ -6,7 +6,7 @@ <parent> <groupId>org.chorem</groupId> <artifactId>pollen</artifactId> - <version>1.5.5-SNAPSHOT</version> + <version>2.0-SNAPSHOT</version> </parent> <groupId>org.chorem.pollen</groupId> Modified: branches/pollen-2.0/pollen-votecounting-coombs/pom.xml =================================================================== --- branches/pollen-2.0/pollen-votecounting-coombs/pom.xml 2013-06-02 08:11:58 UTC (rev 3814) +++ branches/pollen-2.0/pollen-votecounting-coombs/pom.xml 2013-06-04 14:47:08 UTC (rev 3815) @@ -6,7 +6,7 @@ <parent> <groupId>org.chorem</groupId> <artifactId>pollen</artifactId> - <version>1.5.5-SNAPSHOT</version> + <version>2.0-SNAPSHOT</version> </parent> <groupId>org.chorem.pollen</groupId> Modified: branches/pollen-2.0/pollen-votecounting-instant-runoff/pom.xml =================================================================== --- branches/pollen-2.0/pollen-votecounting-instant-runoff/pom.xml 2013-06-02 08:11:58 UTC (rev 3814) +++ branches/pollen-2.0/pollen-votecounting-instant-runoff/pom.xml 2013-06-04 14:47:08 UTC (rev 3815) @@ -6,7 +6,7 @@ <parent> <groupId>org.chorem</groupId> <artifactId>pollen</artifactId> - <version>1.5.5-SNAPSHOT</version> + <version>2.0-SNAPSHOT</version> </parent> <groupId>org.chorem.pollen</groupId> Modified: branches/pollen-2.0/pollen-votecounting-normal/pom.xml =================================================================== --- branches/pollen-2.0/pollen-votecounting-normal/pom.xml 2013-06-02 08:11:58 UTC (rev 3814) +++ branches/pollen-2.0/pollen-votecounting-normal/pom.xml 2013-06-04 14:47:08 UTC (rev 3815) @@ -6,7 +6,7 @@ <parent> <groupId>org.chorem</groupId> <artifactId>pollen</artifactId> - <version>1.5.5-SNAPSHOT</version> + <version>2.0-SNAPSHOT</version> </parent> <groupId>org.chorem.pollen</groupId> Modified: branches/pollen-2.0/pollen-votecounting-number/pom.xml =================================================================== --- branches/pollen-2.0/pollen-votecounting-number/pom.xml 2013-06-02 08:11:58 UTC (rev 3814) +++ branches/pollen-2.0/pollen-votecounting-number/pom.xml 2013-06-04 14:47:08 UTC (rev 3815) @@ -6,7 +6,7 @@ <parent> <groupId>org.chorem</groupId> <artifactId>pollen</artifactId> - <version>1.5.5-SNAPSHOT</version> + <version>2.0-SNAPSHOT</version> </parent> <groupId>org.chorem.pollen</groupId> Modified: branches/pollen-2.0/pollen-votecounting-percentage/pom.xml =================================================================== --- branches/pollen-2.0/pollen-votecounting-percentage/pom.xml 2013-06-02 08:11:58 UTC (rev 3814) +++ branches/pollen-2.0/pollen-votecounting-percentage/pom.xml 2013-06-04 14:47:08 UTC (rev 3815) @@ -6,7 +6,7 @@ <parent> <groupId>org.chorem</groupId> <artifactId>pollen</artifactId> - <version>1.5.5-SNAPSHOT</version> + <version>2.0-SNAPSHOT</version> </parent> <groupId>org.chorem.pollen</groupId> Modified: branches/pollen-2.0/pom.xml =================================================================== --- branches/pollen-2.0/pom.xml 2013-06-02 08:11:58 UTC (rev 3814) +++ branches/pollen-2.0/pom.xml 2013-06-04 14:47:08 UTC (rev 3815) @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> <parent> @@ -11,21 +10,13 @@ <groupId>org.chorem</groupId> <artifactId>pollen</artifactId> - <version>1.5.5-SNAPSHOT</version> + <version>2.0-SNAPSHOT</version> + <packaging>pom</packaging> - <modules> - <module>pollen-votecounting-api</module> - <module>pollen-votecounting-aggregator</module> - <module>pollen-persistence</module> - <module>pollen-services</module> - <module>pollen-ui-struts2</module> - </modules> - <name>Pollen</name> <description>Application de vote Pollen</description> - <inceptionYear>2009</inceptionYear> <url>http://maven-site.chorem.org/pollen</url> - + <inceptionYear>2009</inceptionYear> <licenses> <license> <name>GNU Affero General Public License version 3</name> @@ -93,7 +84,6 @@ </roles> </developer> </developers> - <contributors> <contributor> <name>Erwan NEMA</name> @@ -139,8 +129,31 @@ </contributor> </contributors> - <packaging>pom</packaging> + <modules> + <!--module>pollen-votecounting-api</module> + <module>pollen-votecounting-aggregator</module--> + <!--module>pollen-persistence</module> + <module>pollen-services</module> + <module>pollen-ui-struts2</module--> + <module>pollen-persistence</module> + <module>pollen-service</module> + <module>pollen-rest-api</module> + </modules> + <scm> + <connection>scm:svn:http://svn.chorem.org/svn/pollen/trunk</connection> + <developerConnection> + scm:svn:http://svn.chorem.org/svn/pollen/trunk + </developerConnection> + <url>http://www.chorem.org/repositories/browse/pollen/trunk</url> + </scm> + <distributionManagement> + <site> + <id>${platform}</id> + <url>${our.site.repository}/${projectId}</url> + </site> + </distributionManagement> + <properties> <!-- redmine configuration --> @@ -148,7 +161,10 @@ <projectId>pollen</projectId> <!-- customized versions --> - <topiaVersion>2.8</topiaVersion> + <nuitonJpaVersion>0.1-SNAPSHOT</nuitonJpaVersion> + <webmotionVersion>2.4-SNAPSHOT</webmotionVersion> + + <!--<topiaVersion>2.8</topiaVersion>--> <eugenePluginVersion>2.6.3</eugenePluginVersion> <nuitonI18nVersion>2.5.1</nuitonI18nVersion> @@ -156,13 +172,13 @@ <nuitonUtilsVersion>2.6.12</nuitonUtilsVersion> <h2Version>1.3.172</h2Version> <postgresqlVersion>9.1-901-1.jdbc4</postgresqlVersion> - <struts2Version>2.3.14.2</struts2Version> - <jqueryPluginVersion>3.5.0</jqueryPluginVersion> + <!--<struts2Version>2.3.14.2</struts2Version>--> + <!--<jqueryPluginVersion>3.5.0</jqueryPluginVersion>--> <shiroVersion>1.2.2</shiroVersion> <slf4jVersion>1.7.5</slf4jVersion> <jettyVersion>8.1.11.v20130520</jettyVersion> <!--jettyVersion>${jettyPluginVersion}</jettyVersion--> - <hibernateVersion>4.2.1.Final</hibernateVersion> + <hibernateVersion>4.2.2.Final</hibernateVersion> <seleniumVersion>2.33.0</seleniumVersion> <mockitoVersion>1.9.5</mockitoVersion> @@ -180,30 +196,80 @@ <signatureVersion>1.0</signatureVersion--> </properties> + <repositories> + + <repository> + <id>chorem-group</id> + <name>Chorem Group</name> + <url>http://nexus.nuiton.org/nexus/content/groups/pollen-group</url> + <snapshots> + <enabled>true</enabled> + </snapshots> + <releases> + <enabled>true</enabled> + </releases> + </repository> + + </repositories> + <pluginRepositories> + + <pluginRepository> + + <id>nuiton.release</id> + <name>NuitonReleaseRepository</name> + <url>http://nexus.nuiton.org/nexus/content/groups/pollen-group</url> + <snapshots> + <enabled>true</enabled> + </snapshots> + <releases> + <enabled>true</enabled> + </releases> + </pluginRepository> + + </pluginRepositories> + <dependencyManagement> <dependencies> - <!-- ToPIA (and db) --> - <dependency> - <groupId>org.nuiton.topia</groupId> - <artifactId>topia-persistence</artifactId> - <version>${topiaVersion}</version> + <groupId>org.hibernate.javax.persistence</groupId> + <artifactId>hibernate-jpa-2.0-api</artifactId> + <version>1.0.1.Final</version> </dependency> <dependency> - <groupId>org.nuiton.topia</groupId> - <artifactId>topia-service-migration</artifactId> - <version>${topiaVersion}</version> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-core</artifactId> + <version>${hibernateVersion}</version> + <scope>runtime</scope> </dependency> <dependency> <groupId>org.hibernate</groupId> - <artifactId>hibernate-core</artifactId> + <artifactId>hibernate-entitymanager</artifactId> <version>${hibernateVersion}</version> + <scope>runtime</scope> </dependency> <dependency> + <groupId>org.nuiton.jpa</groupId> + <artifactId>nuiton-jpa-api</artifactId> + <version>${nuitonJpaVersion}</version> + </dependency> + + <dependency> + <groupId>org.nuiton.jpa</groupId> + <artifactId>nuiton-jpa-junit</artifactId> + <version>${nuitonJpaVersion}</version> + </dependency> + + <dependency> + <groupId>com.esotericsoftware.yamlbeans</groupId> + <artifactId>yamlbeans</artifactId> + <version>1.06</version> + </dependency> + + <dependency> <groupId>postgresql</groupId> <artifactId>postgresql</artifactId> <version>${postgresqlVersion}</version> @@ -215,6 +281,24 @@ <version>${h2Version}</version> </dependency> + <dependency> + <groupId>org.debux.webmotion</groupId> + <artifactId>webmotion</artifactId> + <version>${webmotionVersion}</version> + </dependency> + + <dependency> + <groupId>org.debux.webmotion</groupId> + <artifactId>webmotion-unittest</artifactId> + <version>${webmotionVersion}</version> + </dependency> + + <dependency> + <groupId>org.debux.webmotion</groupId> + <artifactId>webmotion-extra-jpa</artifactId> + <version>${webmotionVersion}</version> + </dependency> + <!-- Nuiton libs --> <dependency> @@ -225,21 +309,20 @@ <dependency> <groupId>org.nuiton</groupId> - <artifactId>nuiton-csv</artifactId> + <artifactId>nuiton-config</artifactId> <version>${nuitonUtilsVersion}</version> </dependency> <dependency> <groupId>org.nuiton</groupId> - <artifactId>nuiton-validator</artifactId> + <artifactId>nuiton-csv</artifactId> <version>${nuitonUtilsVersion}</version> </dependency> <dependency> - <groupId>org.nuiton.web</groupId> - <artifactId>nuiton-struts2</artifactId> - <version>${nuitonWebVersion}</version> - <scope>compile</scope> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-validator</artifactId> + <version>${nuitonUtilsVersion}</version> </dependency> <dependency> @@ -296,71 +379,10 @@ <version>1.0</version> </dependency> - <!-- Struts 2 --> - <dependency> - <groupId>org.apache.struts</groupId> - <artifactId>struts2-core</artifactId> - <version>${struts2Version}</version> - </dependency> - <dependency> - <groupId>com.jgeppert.struts2.jquery</groupId> - <artifactId>struts2-jquery-plugin</artifactId> - <version>${jqueryPluginVersion}</version> - </dependency> - - <dependency> - <groupId>com.jgeppert.struts2.jquery</groupId> - <artifactId>struts2-jquery-grid-plugin</artifactId> - <version>${jqueryPluginVersion}</version> - </dependency> - - <dependency> - <groupId>com.jgeppert.struts2.jquery</groupId> - <artifactId>struts2-jquery-richtext-plugin</artifactId> - <version>${jqueryPluginVersion}</version> - </dependency> - - <dependency> - <groupId>org.apache.struts</groupId> - <artifactId>struts2-json-plugin</artifactId> - <version>${struts2Version}</version> - </dependency> - - <dependency> - <groupId>org.apache.struts</groupId> - <artifactId>struts2-sitemesh-plugin</artifactId> - <version>${struts2Version}</version> - </dependency> - - <dependency> - <groupId>org.apache.struts</groupId> - <artifactId>struts2-jfreechart-plugin</artifactId> - <version>${struts2Version}</version> - </dependency> - - <dependency> - <groupId>org.apache.struts.xwork</groupId> - <artifactId>xwork-core</artifactId> - <version>${struts2Version}</version> - <exclusions> - <exclusion> - <groupId>org.springframework</groupId> - <artifactId>spring-test</artifactId> - </exclusion> - </exclusions> - </dependency> - <!-- Logging --> - <!--dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - <version>${slf4jVersion}</version> - <scope>compile</scope> - </dependency--> - <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-jcl</artifactId> @@ -463,7 +485,12 @@ </dependencyManagement> <build> - + <resources> + <resource> + <directory>src/main/resources</directory> + <filtering>true</filtering> + </resource> + </resources> <pluginManagement> <plugins> @@ -501,9 +528,9 @@ </configuration> <dependencies> <dependency> - <groupId>org.nuiton.topia</groupId> - <artifactId>topia-persistence</artifactId> - <version>${topiaVersion}</version> + <groupId>org.nuiton.jpa</groupId> + <artifactId>nuiton-jpa-templates</artifactId> + <version>${nuitonJpaVersion}</version> </dependency> </dependencies> </plugin> @@ -527,99 +554,8 @@ </plugins> </pluginManagement> - - <resources> - <resource> - <directory>src/main/resources</directory> - <filtering>true</filtering> - </resource> - </resources> </build> - <scm> - <connection>scm:svn:http://svn.chorem.org/svn/pollen/trunk</connection> - <developerConnection> - scm:svn:http://svn.chorem.org/svn/pollen/trunk - </developerConnection> - <url>http://www.chorem.org/repositories/browse/pollen/trunk</url> - </scm> - - <distributionManagement> - <site> - <id>${platform}</id> - <url>${our.site.repository}/${projectId}</url> - </site> - </distributionManagement> - - <repositories> - - <!-- depot des releases nuiton --> - - <repository> - <id>nuiton.release</id> - <name>NuitonReleaseRepository</name> - <url>http://nexus.nuiton.org/nexus/content/groups/public/</url> - <snapshots> - <enabled>false</enabled> - </snapshots> - <releases> - <enabled>true</enabled> - <checksumPolicy>warn</checksumPolicy> - </releases> - </repository> - - <!-- depot des snapshots nuiton --> - - <repository> - <id>nuiton.snapshot</id> - <name>NuitonSnapshotRepository</name> - <url>http://nexus.nuiton.org/nexus/content/repositories/snapshots/</url> - <snapshots> - <enabled>true</enabled> - <checksumPolicy>fail</checksumPolicy> - </snapshots> - <releases> - <enabled>false</enabled> - </releases> - </repository> - - </repositories> - - <pluginRepositories> - - <!-- depot des releases nuiton --> - - <pluginRepository> - - <id>nuiton.release</id> - <name>NuitonReleaseRepository</name> - <url>http://nexus.nuiton.org/nexus/content/groups/public/</url> - <snapshots> - <enabled>false</enabled> - </snapshots> - <releases> - <enabled>true</enabled> - <checksumPolicy>warn</checksumPolicy> - </releases> - </pluginRepository> - - <!-- depot des snapshots nuiton --> - - <pluginRepository> - <id>nuiton.snapshot</id> - <name>NuitonSnapshotRepository</name> - <url>http://nexus.nuiton.org/nexus/content/repositories/snapshots/</url> - <snapshots> - <enabled>true</enabled> - <checksumPolicy>fail</checksumPolicy> - </snapshots> - <releases> - <enabled>false</enabled> - </releases> - </pluginRepository> - - </pluginRepositories> - <reporting> <!-- par defaut pas de report pour les sites --> @@ -698,5 +634,4 @@ </profile> </profiles> - </project> Modified: branches/pollen-2.0/src/site/rst/service.rst =================================================================== --- branches/pollen-2.0/src/site/rst/service.rst 2013-06-02 08:11:58 UTC (rev 3814) +++ branches/pollen-2.0/src/site/rst/service.rst 2013-06-04 14:47:08 UTC (rev 3815) @@ -40,6 +40,7 @@ ---- - signin PUT /user {...} : UserService.createUser(...) -> User +- get users GET /users UserService.getUsers() -> User[] - get user profile GET /user[/userId] UserService.getUser(userId) -> User - edit user profile POST /user {[userId +] properties) UserService.editUser(User) -> User - validate email GET /validateemail/token UserService.validateEmail(token) @@ -47,9 +48,9 @@ Voting List ----------- +- get user's list of voting list GET /votinglists VotingListService.getUserVotingLists(userId) -> VotingList[] +- get voting list GET /votinglist/votinglistId VotingListService.getVotingList(vlId) -> VotingList - create voting list PUT /votinglist {...} VotingListService.createVotingList(userId,...) -> VotingList -- get voting list GET /votinglist/votinglistId VotingListService.getVotingList(vlId) -> VotingList -- get user's list of voting list GET /votinglists VotingListService.getUserVotingLists(userId) -> VotingList[] - edit voting list POST /votinglist {votinglistId,name, description, ..., but not voter} VotingListService.editVotingList(VotingList) -> VotingList - delete voting list DELETE /votinglist/vlId VotingListService.deleteVotingList(vlId) - add voter to voting list PUT /votinglist/voId/voter {...} VotingListService.addVoter(voId, Voter) -> Voter @@ -65,39 +66,43 @@ - delete poll: DELETE /poll/{pollId} PollService.deletePoll(pollId) - clone poll : PUT /poll/{fromPollId} ? PollService.clonePoll(fromPollId) -> Poll - close poll : POST /poll/{pollId} {action=close} PollService.closePoll(pollId) -- export poll : GET /poll/{pollId} {action=export} PollService.exportPoll(pollId) ->File +- export poll : GET /poll/{pollId} {action=export} PollService.exportPoll(pollId) -> File - edit poll : POST /poll {...} PollService.editPoll(Poll) -> Poll -- import voting list : +- import voting list : POST /poll/{pollId}/votingList/{votingListId} PollService.importVotingList(pollId, votingListId) -- add choice in poll: PUT /poll/{pollId}/choices {choice object} -- remove choice in poll: DELETE /poll/{pollId}/choices/{choiceId} +- get poll's choice: GET /poll/{pollId}/choices getChoices(pollId) -> Choice[] +- get a choice: GET /poll/{pollId}/choices/{choiceID} getChoice(pollId, choiceId) -> Choice +- add choice in poll: PUT /poll/{pollId}/choices {choice} addChoice(pollId, choice) -> Choice +- edit choice in poll: POST /poll/{pollId}/choices {choice} editChoice(choice) -> Choice +- remove choice in poll: DELETE /poll/{pollId}/choices/{choiceId} deleteChoice(pollId, choiceId) -- get poll's voters: GET /poll/{pollId}/voters -- add voter: PUT /poll/{pollId}/voters {voter object} -- remove voter: DELETE /poll/{pollId}/voters/{choiceId} +- get poll's invited: GET /poll/{pollId}/inviteds +- get a poll's invited: GET /poll/{pollId}/inviteds{invitedId} +- add invited: PUT /poll/{pollId}/inviteds {invited} +- remove invited: DELETE /poll/{pollId}/inviteds/{invitedId} -# Give up this way -#- set poll property: ??? en fait, c'est un update partiel du poll ? dans ce cas, il faudrait savoir comment détecter une info non donnée d'une info effacée :/ sinon, c'est renvoyer toutes les infos du poll :/ -# - set poll name: ??? -# - set poll description: ??? -# - ... +Comment +------- -Voting ------- +- get poll's comment: GET /poll/{pollId}/comments CommentService.getComments(pollId) -> Comment[] +- get a poll's comment: GET /poll/{pollId}/comments/{commentId} CommentService.getComment(commentId) -> Comment +- add comment: PUT /poll/{pollId}/comments {comment} CommentService.addComment(pollId, comment) -> Comment +- edit comment: POST /poll/{pollId}/comments {comment} CommentService.editComment(comment) -> Comment +- remove comment: DELETE /poll/{pollId}/comments/{commentId} CommentService.deleteComment(commentId) -?- vote in poll for one choice: ??? -- get votes' poll: ??? -- vote for poll: ??? -- remove vote: ??? +Vote +---- -- get poll's comment: GET /poll/{pollId}/comments -- add comment: PUT /poll/{pollId}/comments {comment object} -- remove comment: DELETE /poll/{pollId}/comments/commentId +- get poll's votes: GET /poll/{pollId}/votes VoteService.getVotes(pollId) -> Vote[] +- get a poll's vote: GET /poll/{pollId}/votes/{voteId} VoteService.getVote(voteId) -> Vote +- add vote: PUT /poll/{pollId}/votes {vote} VoteService.addVote(pollId, vote) -> Vote +- edit vote: POST /poll/{pollId}/votes {vote} VoteService.editVote(vote) -> Vote +- remove vote: DELETE /poll/{pollId}/votes/{voteId} VoteService.deleteVote(voteId) Counting -------- -- winners list: GET /polls/{pollId}/result +- winners list: GET /polls/{pollId}/result VoteCountingService.getResult(pollId) -> Result each counting type can have specific result type, how handle it ? (table, image, ...) : dans l'objet de retour, on peut avoir une entrée qui donne le type avant de donner le contenu ?
participants (1)
-
tchemit@users.chorem.org