diff options
author | Ralf Mollik | 2018-02-23 14:28:09 +0000 |
---|---|---|
committer | Ralf Mollik | 2018-02-23 14:28:09 +0000 |
commit | 82181d0289a589ecaa686ec60f5cce7c2d1f6f81 (patch) | |
tree | 56321b9d8882f57ee02162a2ace305b883721f86 | |
download | org.eclipse.osbp.jpa.services-82181d0289a589ecaa686ec60f5cce7c2d1f6f81.tar.gz org.eclipse.osbp.jpa.services-82181d0289a589ecaa686ec60f5cce7c2d1f6f81.tar.xz org.eclipse.osbp.jpa.services-82181d0289a589ecaa686ec60f5cce7c2d1f6f81.zip |
initial commit
72 files changed, 7627 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3bdfa6a --- /dev/null +++ b/.gitignore @@ -0,0 +1,53 @@ +/bin/ +**/bin/ +/workspace/ +**/bin/ +**/target/ +**.java._trace +**.log.properties +**git.properties +**/target/ +**/.metadata/ + +**/emf-gen/**/.gitignore +**/src-gen/**/.gitignore +**/git.properties +**/*.java._trace +**/*.log +**/*.log.properties + +**/bin/ +**/build/ +*.class +*.ctrl +**/Debug/ +.DS_Store +*.ear +*.war + +**/*.actionbin +**/*.authorizationbin +**/*.blipbin +**/*.chartbin +**/*.cubebin +**/*.databin +**/*.datamartbin +**/*.datatypebin +**/*.dialogbin +**/*.dtobin +**/*.entitybin +**/*.entitymockbin +**/*.functionlibrarybin +**/*.menubin +**/*.messagebin +**/*.organizationbin +**/*.reportbin +**/*.perspectivebin +**/*.servicebin +**/*.statemachinebin +**/*.strategybin +**/*.tablebin +**/*.topologybin +**/*.uibin +**/*.uisemanticbin + diff --git a/.project b/.project new file mode 100644 index 0000000..15c5170 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.osbp.jpa.services.aggregator</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.m2e.core.maven2Builder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.m2e.core.maven2Nature</nature> + </natures> +</projectDescription> diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/<project>=UTF-8 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/epl-v10.html b/epl-v10.html new file mode 100644 index 0000000..b398acc --- /dev/null +++ b/epl-v10.html @@ -0,0 +1,259 @@ +<!--?xml version="1.0" encoding="ISO-8859-1" ?--> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"><head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> +<title>Eclipse Public License - Version 1.0</title> +<style type="text/css"> + body { + size: 8.5in 11.0in; + margin: 0.25in 0.5in 0.25in 0.5in; + tab-interval: 0.5in; + } + p { + margin-left: auto; + margin-top: 0.5em; + margin-bottom: 0.5em; + } + p.list { + margin-left: 0.5in; + margin-top: 0.05em; + margin-bottom: 0.05em; + } + </style> + +</head> + +<body lang="EN-US"> + +<h2>Eclipse Public License - v 1.0</h2> + +<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE +PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR +DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS +AGREEMENT.</p> + +<p><b>1. DEFINITIONS</b></p> + +<p>"Contribution" means:</p> + +<p class="list">a) in the case of the initial Contributor, the initial +code and documentation distributed under this Agreement, and</p> +<p class="list">b) in the case of each subsequent Contributor:</p> +<p class="list">i) changes to the Program, and</p> +<p class="list">ii) additions to the Program;</p> +<p class="list">where such changes and/or additions to the Program +originate from and are distributed by that particular Contributor. A +Contribution 'originates' from a Contributor if it was added to the +Program by such Contributor itself or anyone acting on such +Contributor's behalf. Contributions do not include additions to the +Program which: (i) are separate modules of software distributed in +conjunction with the Program under their own license agreement, and (ii) +are not derivative works of the Program.</p> + +<p>"Contributor" means any person or entity that distributes +the Program.</p> + +<p>"Licensed Patents" mean patent claims licensable by a +Contributor which are necessarily infringed by the use or sale of its +Contribution alone or when combined with the Program.</p> + +<p>"Program" means the Contributions distributed in accordance +with this Agreement.</p> + +<p>"Recipient" means anyone who receives the Program under +this Agreement, including all Contributors.</p> + +<p><b>2. GRANT OF RIGHTS</b></p> + +<p class="list">a) Subject to the terms of this Agreement, each +Contributor hereby grants Recipient a non-exclusive, worldwide, +royalty-free copyright license to reproduce, prepare derivative works +of, publicly display, publicly perform, distribute and sublicense the +Contribution of such Contributor, if any, and such derivative works, in +source code and object code form.</p> + +<p class="list">b) Subject to the terms of this Agreement, each +Contributor hereby grants Recipient a non-exclusive, worldwide, +royalty-free patent license under Licensed Patents to make, use, sell, +offer to sell, import and otherwise transfer the Contribution of such +Contributor, if any, in source code and object code form. This patent +license shall apply to the combination of the Contribution and the +Program if, at the time the Contribution is added by the Contributor, +such addition of the Contribution causes such combination to be covered +by the Licensed Patents. The patent license shall not apply to any other +combinations which include the Contribution. No hardware per se is +licensed hereunder.</p> + +<p class="list">c) Recipient understands that although each Contributor +grants the licenses to its Contributions set forth herein, no assurances +are provided by any Contributor that the Program does not infringe the +patent or other intellectual property rights of any other entity. Each +Contributor disclaims any liability to Recipient for claims brought by +any other entity based on infringement of intellectual property rights +or otherwise. As a condition to exercising the rights and licenses +granted hereunder, each Recipient hereby assumes sole responsibility to +secure any other intellectual property rights needed, if any. For +example, if a third party patent license is required to allow Recipient +to distribute the Program, it is Recipient's responsibility to acquire +that license before distributing the Program.</p> + +<p class="list">d) Each Contributor represents that to its knowledge it +has sufficient copyright rights in its Contribution, if any, to grant +the copyright license set forth in this Agreement.</p> + +<p><b>3. REQUIREMENTS</b></p> + +<p>A Contributor may choose to distribute the Program in object code +form under its own license agreement, provided that:</p> + +<p class="list">a) it complies with the terms and conditions of this +Agreement; and</p> + +<p class="list">b) its license agreement:</p> + +<p class="list">i) effectively disclaims on behalf of all Contributors +all warranties and conditions, express and implied, including warranties +or conditions of title and non-infringement, and implied warranties or +conditions of merchantability and fitness for a particular purpose;</p> + +<p class="list">ii) effectively excludes on behalf of all Contributors +all liability for damages, including direct, indirect, special, +incidental and consequential damages, such as lost profits;</p> + +<p class="list">iii) states that any provisions which differ from this +Agreement are offered by that Contributor alone and not by any other +party; and</p> + +<p class="list">iv) states that source code for the Program is available +from such Contributor, and informs licensees how to obtain it in a +reasonable manner on or through a medium customarily used for software +exchange.</p> + +<p>When the Program is made available in source code form:</p> + +<p class="list">a) it must be made available under this Agreement; and</p> + +<p class="list">b) a copy of this Agreement must be included with each +copy of the Program.</p> + +<p>Contributors may not remove or alter any copyright notices contained +within the Program.</p> + +<p>Each Contributor must identify itself as the originator of its +Contribution, if any, in a manner that reasonably allows subsequent +Recipients to identify the originator of the Contribution.</p> + +<p><b>4. COMMERCIAL DISTRIBUTION</b></p> + +<p>Commercial distributors of software may accept certain +responsibilities with respect to end users, business partners and the +like. While this license is intended to facilitate the commercial use of +the Program, the Contributor who includes the Program in a commercial +product offering should do so in a manner which does not create +potential liability for other Contributors. Therefore, if a Contributor +includes the Program in a commercial product offering, such Contributor +("Commercial Contributor") hereby agrees to defend and +indemnify every other Contributor ("Indemnified Contributor") +against any losses, damages and costs (collectively "Losses") +arising from claims, lawsuits and other legal actions brought by a third +party against the Indemnified Contributor to the extent caused by the +acts or omissions of such Commercial Contributor in connection with its +distribution of the Program in a commercial product offering. The +obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In +order to qualify, an Indemnified Contributor must: a) promptly notify +the Commercial Contributor in writing of such claim, and b) allow the +Commercial Contributor to control, and cooperate with the Commercial +Contributor in, the defense and any related settlement negotiations. The +Indemnified Contributor may participate in any such claim at its own +expense.</p> + +<p>For example, a Contributor might include the Program in a commercial +product offering, Product X. That Contributor is then a Commercial +Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance +claims and warranties are such Commercial Contributor's responsibility +alone. Under this section, the Commercial Contributor would have to +defend claims against the other Contributors related to those +performance claims and warranties, and if a court requires any other +Contributor to pay any damages as a result, the Commercial Contributor +must pay those damages.</p> + +<p><b>5. NO WARRANTY</b></p> + +<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS +PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS +OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, +ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY +OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely +responsible for determining the appropriateness of using and +distributing the Program and assumes all risks associated with its +exercise of rights under this Agreement , including but not limited to +the risks and costs of program errors, compliance with applicable laws, +damage to or loss of data, programs or equipment, and unavailability or +interruption of operations.</p> + +<p><b>6. DISCLAIMER OF LIABILITY</b></p> + +<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT +NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING +WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR +DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED +HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p> + +<p><b>7. GENERAL</b></p> + +<p>If any provision of this Agreement is invalid or unenforceable under +applicable law, it shall not affect the validity or enforceability of +the remainder of the terms of this Agreement, and without further action +by the parties hereto, such provision shall be reformed to the minimum +extent necessary to make such provision valid and enforceable.</p> + +<p>If Recipient institutes patent litigation against any entity +(including a cross-claim or counterclaim in a lawsuit) alleging that the +Program itself (excluding combinations of the Program with other +software or hardware) infringes such Recipient's patent(s), then such +Recipient's rights granted under Section 2(b) shall terminate as of the +date such litigation is filed.</p> + +<p>All Recipient's rights under this Agreement shall terminate if it +fails to comply with any of the material terms or conditions of this +Agreement and does not cure such failure in a reasonable period of time +after becoming aware of such noncompliance. If all Recipient's rights +under this Agreement terminate, Recipient agrees to cease use and +distribution of the Program as soon as reasonably practicable. However, +Recipient's obligations under this Agreement and any licenses granted by +Recipient relating to the Program shall continue and survive.</p> + +<p>Everyone is permitted to copy and distribute copies of this +Agreement, but in order to avoid inconsistency the Agreement is +copyrighted and may only be modified in the following manner. The +Agreement Steward reserves the right to publish new versions (including +revisions) of this Agreement from time to time. No one other than the +Agreement Steward has the right to modify this Agreement. The Eclipse +Foundation is the initial Agreement Steward. The Eclipse Foundation may +assign the responsibility to serve as the Agreement Steward to a +suitable separate entity. Each new version of the Agreement will be +given a distinguishing version number. The Program (including +Contributions) may always be distributed subject to the version of the +Agreement under which it was received. In addition, after a new version +of the Agreement is published, Contributor may elect to distribute the +Program (including its Contributions) under the new version. Except as +expressly stated in Sections 2(a) and 2(b) above, Recipient receives no +rights or licenses to the intellectual property of any Contributor under +this Agreement, whether expressly, by implication, estoppel or +otherwise. All rights in the Program not expressly granted under this +Agreement are reserved.</p> + +<p>This Agreement is governed by the laws of the State of New York and +the intellectual property laws of the United States of America. No party +to this Agreement will bring a legal action under this Agreement more +than one year after the cause of action arose. Each party waives its +rights to a jury trial in any resulting litigation.</p> + + + +</body></html>
\ No newline at end of file diff --git a/jenkins.build.config.xml b/jenkins.build.config.xml new file mode 100644 index 0000000..d2c5ac8 --- /dev/null +++ b/jenkins.build.config.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--#======================================================================= --> +<!--# Copyright (c) 2017 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) --> +<!--# All rights reserved. This program and the accompanying materials --> +<!--# are made available under the terms of the Eclipse Public License v1.0 --> +<!--# which accompanies this distribution, and is available at --> +<!--# http://www.eclipse.org/legal/epl-v10.html --> +<!--# --> +<!--# Contributors: --> +<!--# Loetz GmbH&Co.KG - initial API and implementation --> +<!--#======================================================================= --> +<!--# Module specific parameters for the Jenkins Job --> +<!--#======================================================================= --> +<jenkins> + <!-- DO NOT EDIT BELOW THIS LINE --> + <jenkins.build.dependencies> + <jenkins.build.dependency>org.eclipse.osbp.runtime</jenkins.build.dependency> + </jenkins.build.dependencies> +</jenkins> diff --git a/mavenizing_started b/mavenizing_started new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/mavenizing_started diff --git a/notice.html b/notice.html new file mode 100644 index 0000000..c3d34c3 --- /dev/null +++ b/notice.html @@ -0,0 +1,107 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> +<title>Eclipse Foundation Software User Agreement</title> +</head> + +<body lang="EN-US"> +<h2>Eclipse Foundation Software User Agreement</h2> +<p>April 9, 2014</p> + +<h3>Usage Of Content</h3> + +<p>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS + (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND + CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE + OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR + NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND + CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.</p> + +<h3>Applicable Licenses</h3> + +<p>Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 + ("EPL"). A copy of the EPL is provided with this Content and is also available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. + For purposes of the EPL, "Program" will mean the Content.</p> + +<p>Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse Foundation source code + repository ("Repository") in software modules ("Modules") and made available as downloadable archives ("Downloads").</p> + +<ul> + <li>Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and features ("Features").</li> + <li>Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java™ ARchive) in a directory named "plugins".</li> + <li>A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Each Feature may be packaged as a sub-directory in a directory named "features". Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of the Plug-ins + and/or Fragments associated with that Feature.</li> + <li>Features may also include other Features ("Included Features"). Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of Included Features.</li> +</ul> + +<p>The terms and conditions governing Plug-ins and Fragments should be contained in files named "about.html" ("Abouts"). The terms and conditions governing Features and +Included Features should be contained in files named "license.html" ("Feature Licenses"). Abouts and Feature Licenses may be located in any directory of a Download or Module +including, but not limited to the following locations:</p> + +<ul> + <li>The top-level (root) directory</li> + <li>Plug-in and Fragment directories</li> + <li>Inside Plug-ins and Fragments packaged as JARs</li> + <li>Sub-directories of the directory named "src" of certain Plug-ins</li> + <li>Feature directories</li> +</ul> + +<p>Note: if a Feature made available by the Eclipse Foundation is installed using the Provisioning Technology (as defined below), you must agree to a license ("Feature Update License") during the +installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or +inform you where you can locate them. Feature Update Licenses may be found in the "license" property of files named "feature.properties" found within a Feature. +Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in +that directory.</p> + +<p>THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE +OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</p> + +<ul> + <li>Eclipse Distribution License Version 1.0 (available at <a href="http://www.eclipse.org/licenses/edl-v10.html">http://www.eclipse.org/licenses/edl-v1.0.html</a>)</li> + <li>Common Public License Version 1.0 (available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>)</li> + <li>Apache Software License 1.1 (available at <a href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</a>)</li> + <li>Apache Software License 2.0 (available at <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>)</li> + <li>Mozilla Public License Version 1.1 (available at <a href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</a>)</li> +</ul> + +<p>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please +contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.</p> + + +<h3>Use of Provisioning Technology</h3> + +<p>The Eclipse Foundation makes available provisioning software, examples of which include, but are not limited to, p2 and the Eclipse + Update Manager ("Provisioning Technology") for the purpose of allowing users to install software, documentation, information and/or + other materials (collectively "Installable Software"). This capability is provided with the intent of allowing such users to + install, extend and update Eclipse-based products. Information about packaging Installable Software is available at <a + href="http://eclipse.org/equinox/p2/repository_packaging.html">http://eclipse.org/equinox/p2/repository_packaging.html</a> + ("Specification").</p> + +<p>You may use Provisioning Technology to allow other parties to install Installable Software. You shall be responsible for enabling the + applicable license agreements relating to the Installable Software to be presented to, and accepted by, the users of the Provisioning Technology + in accordance with the Specification. By using Provisioning Technology in such a manner and making it available in accordance with the + Specification, you further acknowledge your agreement to, and the acquisition of all necessary rights to permit the following:</p> + +<ol> + <li>A series of actions may occur ("Provisioning Process") in which a user may execute the Provisioning Technology + on a machine ("Target Machine") with the intent of installing, extending or updating the functionality of an Eclipse-based + product.</li> + <li>During the Provisioning Process, the Provisioning Technology may cause third party Installable Software or a portion thereof to be + accessed and copied to the Target Machine.</li> + <li>Pursuant to the Specification, you will provide to the user the terms and conditions that govern the use of the Installable + Software ("Installable Software Agreement") and such Installable Software Agreement shall be accessed from the Target + Machine in accordance with the Specification. Such Installable Software Agreement must inform the user of the terms and conditions that govern + the Installable Software and must solicit acceptance by the end user in the manner prescribed in such Installable Software Agreement. Upon such + indication of agreement by the user, the provisioning Technology will complete installation of the Installable Software.</li> +</ol> + +<h3>Cryptography</h3> + +<p>Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to + another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import, + possession, or use, and re-export of encryption software, to see if this is permitted.</p> + +<p><small>Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.</small></p> +</body> +</html> diff --git a/org.eclipse.osbp.jpa.services.feature/.project b/org.eclipse.osbp.jpa.services.feature/.project new file mode 100644 index 0000000..59b8e6f --- /dev/null +++ b/org.eclipse.osbp.jpa.services.feature/.project @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.osbp.jpa.services.feature</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.xtext.ui.shared.xtextBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.FeatureBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.sonarlint.eclipse.core.sonarlintBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.m2e.core.maven2Builder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.xtext.ui.shared.xtextNature</nature> + <nature>org.eclipse.m2e.core.maven2Nature</nature> + <nature>org.eclipse.pde.FeatureNature</nature> + </natures> +</projectDescription> diff --git a/org.eclipse.osbp.jpa.services.feature/.settings/org.eclipse.core.resources.prefs b/org.eclipse.osbp.jpa.services.feature/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/org.eclipse.osbp.jpa.services.feature/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/<project>=UTF-8 diff --git a/org.eclipse.osbp.jpa.services.feature/.settings/org.eclipse.m2e.core.prefs b/org.eclipse.osbp.jpa.services.feature/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/org.eclipse.osbp.jpa.services.feature/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/org.eclipse.osbp.jpa.services.feature/.settings/org.eclipse.xtend.core.Xtend.prefs b/org.eclipse.osbp.jpa.services.feature/.settings/org.eclipse.xtend.core.Xtend.prefs new file mode 100644 index 0000000..19e3115 --- /dev/null +++ b/org.eclipse.osbp.jpa.services.feature/.settings/org.eclipse.xtend.core.Xtend.prefs @@ -0,0 +1,11 @@ +//outlet.DEFAULT_OUTPUT.sourceFolder.src/test/java.directory=src/test/generated-sources/xtend +BuilderConfiguration.is_project_specific=true +eclipse.preferences.version=1 +is_project_specific=true +outlet.DEFAULT_OUTPUT.hideLocalSyntheticVariables=true +outlet.DEFAULT_OUTPUT.installDslAsPrimarySource=false +outlet.DEFAULT_OUTPUT.sourceFolder.emf-gen.directory=xtend-gen +outlet.DEFAULT_OUTPUT.sourceFolder.src-gen.directory=xtend-gen +outlet.DEFAULT_OUTPUT.sourceFolder.src.directory=xtend-gen +outlet.DEFAULT_OUTPUT.sourceFolder.xtend-gen.directory=xtend-gen +outlet.DEFAULT_OUTPUT.userOutputPerSourceFolder=true diff --git a/org.eclipse.osbp.jpa.services.feature/LICENSE.txt b/org.eclipse.osbp.jpa.services.feature/LICENSE.txt new file mode 100644 index 0000000..ff42ad4 --- /dev/null +++ b/org.eclipse.osbp.jpa.services.feature/LICENSE.txt @@ -0,0 +1,161 @@ +Eclipse Public License -v 1.0 + +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION +OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + +a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and + +b) in the case of each subsequent Contributor: + +i) changes to the Program, and + +ii) additions to the Program; + +where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. +A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone +acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate +modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not +derivative works of the Program. + +"Contributor" means any person or entity that distributes the Program. + +"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of +its Contribution alone or when combined with the Program. + +"Program" means the Contributions distributed in accordance with this Agreement. + +"Recipient" means anyone who receives the Program under this Agreement, including all Contributors. + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, +royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute +and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code +form. + +b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, +royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the +Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the +combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such +addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not +apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. + +c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no +assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property +rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity +based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and +licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property +rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the +Program, it is Recipient's responsibility to acquire that license before distributing the Program. + +d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to +grant the copyright license set forth in this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that: + +a) it complies with the terms and conditions of this Agreement; and + +b) its license agreement: + +i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including +warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and +fitness for a particular purpose; + +ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, +incidental and consequential damages, such as lost profits; + +iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any +other party; and + +iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it +in a reasonable manner on or through a medium customarily used for software exchange. + +When the Program is made available in source code form: + +a) it must be made available under this Agreement; and + +b) a copy of this Agreement must be included with each copy of the Program. + +Contributors may not remove or alter any copyright notices contained within the Program. + +Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows +subsequent Recipients to identify the originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and +the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes +the Program in a commercial product offering should do so in a manner which does not create potential liability for +other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor +("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") +against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions +brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such +Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The +obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual +property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the +Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may + participate in any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is +then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties +related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. +Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to +those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, +the Commercial Contributor must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR +CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, +NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for +determining the appropriateness of using and distributing the Program and assumes all risks associated with its +exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance +with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED +HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or +enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such +provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. + +If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) +alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such +Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such +litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or +conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such +noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution +of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses + granted by Recipient relating to the Program shall continue and survive. + +Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement +is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish +new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the +right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may +assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the +Agreement will be given a distinguishing version number. The Program (including Contributions) may always be +distributed subject to the version of the Agreement under which it was received. In addition, after a new version of +the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the +new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to +the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or +otherwise. All rights in the Program not expressly granted under this Agreement are reserved. + +This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States +of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause +of action arose. Each party waives its rights to a jury trial in any resulting litigation.
\ No newline at end of file diff --git a/org.eclipse.osbp.jpa.services.feature/build.properties b/org.eclipse.osbp.jpa.services.feature/build.properties new file mode 100644 index 0000000..0ea4044 --- /dev/null +++ b/org.eclipse.osbp.jpa.services.feature/build.properties @@ -0,0 +1,10 @@ +bin.includes = feature.xml,\ + feature.properties,\ + notice.html,\ + license.html,\ + LICENSE.txt,\ + epl-v10.html +src.includes = license.html,\ + LICENSE.txt,\ + notice.html,\ + epl-v10.html diff --git a/org.eclipse.osbp.jpa.services.feature/epl-v10.html b/org.eclipse.osbp.jpa.services.feature/epl-v10.html new file mode 100644 index 0000000..b398acc --- /dev/null +++ b/org.eclipse.osbp.jpa.services.feature/epl-v10.html @@ -0,0 +1,259 @@ +<!--?xml version="1.0" encoding="ISO-8859-1" ?--> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"><head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> +<title>Eclipse Public License - Version 1.0</title> +<style type="text/css"> + body { + size: 8.5in 11.0in; + margin: 0.25in 0.5in 0.25in 0.5in; + tab-interval: 0.5in; + } + p { + margin-left: auto; + margin-top: 0.5em; + margin-bottom: 0.5em; + } + p.list { + margin-left: 0.5in; + margin-top: 0.05em; + margin-bottom: 0.05em; + } + </style> + +</head> + +<body lang="EN-US"> + +<h2>Eclipse Public License - v 1.0</h2> + +<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE +PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR +DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS +AGREEMENT.</p> + +<p><b>1. DEFINITIONS</b></p> + +<p>"Contribution" means:</p> + +<p class="list">a) in the case of the initial Contributor, the initial +code and documentation distributed under this Agreement, and</p> +<p class="list">b) in the case of each subsequent Contributor:</p> +<p class="list">i) changes to the Program, and</p> +<p class="list">ii) additions to the Program;</p> +<p class="list">where such changes and/or additions to the Program +originate from and are distributed by that particular Contributor. A +Contribution 'originates' from a Contributor if it was added to the +Program by such Contributor itself or anyone acting on such +Contributor's behalf. Contributions do not include additions to the +Program which: (i) are separate modules of software distributed in +conjunction with the Program under their own license agreement, and (ii) +are not derivative works of the Program.</p> + +<p>"Contributor" means any person or entity that distributes +the Program.</p> + +<p>"Licensed Patents" mean patent claims licensable by a +Contributor which are necessarily infringed by the use or sale of its +Contribution alone or when combined with the Program.</p> + +<p>"Program" means the Contributions distributed in accordance +with this Agreement.</p> + +<p>"Recipient" means anyone who receives the Program under +this Agreement, including all Contributors.</p> + +<p><b>2. GRANT OF RIGHTS</b></p> + +<p class="list">a) Subject to the terms of this Agreement, each +Contributor hereby grants Recipient a non-exclusive, worldwide, +royalty-free copyright license to reproduce, prepare derivative works +of, publicly display, publicly perform, distribute and sublicense the +Contribution of such Contributor, if any, and such derivative works, in +source code and object code form.</p> + +<p class="list">b) Subject to the terms of this Agreement, each +Contributor hereby grants Recipient a non-exclusive, worldwide, +royalty-free patent license under Licensed Patents to make, use, sell, +offer to sell, import and otherwise transfer the Contribution of such +Contributor, if any, in source code and object code form. This patent +license shall apply to the combination of the Contribution and the +Program if, at the time the Contribution is added by the Contributor, +such addition of the Contribution causes such combination to be covered +by the Licensed Patents. The patent license shall not apply to any other +combinations which include the Contribution. No hardware per se is +licensed hereunder.</p> + +<p class="list">c) Recipient understands that although each Contributor +grants the licenses to its Contributions set forth herein, no assurances +are provided by any Contributor that the Program does not infringe the +patent or other intellectual property rights of any other entity. Each +Contributor disclaims any liability to Recipient for claims brought by +any other entity based on infringement of intellectual property rights +or otherwise. As a condition to exercising the rights and licenses +granted hereunder, each Recipient hereby assumes sole responsibility to +secure any other intellectual property rights needed, if any. For +example, if a third party patent license is required to allow Recipient +to distribute the Program, it is Recipient's responsibility to acquire +that license before distributing the Program.</p> + +<p class="list">d) Each Contributor represents that to its knowledge it +has sufficient copyright rights in its Contribution, if any, to grant +the copyright license set forth in this Agreement.</p> + +<p><b>3. REQUIREMENTS</b></p> + +<p>A Contributor may choose to distribute the Program in object code +form under its own license agreement, provided that:</p> + +<p class="list">a) it complies with the terms and conditions of this +Agreement; and</p> + +<p class="list">b) its license agreement:</p> + +<p class="list">i) effectively disclaims on behalf of all Contributors +all warranties and conditions, express and implied, including warranties +or conditions of title and non-infringement, and implied warranties or +conditions of merchantability and fitness for a particular purpose;</p> + +<p class="list">ii) effectively excludes on behalf of all Contributors +all liability for damages, including direct, indirect, special, +incidental and consequential damages, such as lost profits;</p> + +<p class="list">iii) states that any provisions which differ from this +Agreement are offered by that Contributor alone and not by any other +party; and</p> + +<p class="list">iv) states that source code for the Program is available +from such Contributor, and informs licensees how to obtain it in a +reasonable manner on or through a medium customarily used for software +exchange.</p> + +<p>When the Program is made available in source code form:</p> + +<p class="list">a) it must be made available under this Agreement; and</p> + +<p class="list">b) a copy of this Agreement must be included with each +copy of the Program.</p> + +<p>Contributors may not remove or alter any copyright notices contained +within the Program.</p> + +<p>Each Contributor must identify itself as the originator of its +Contribution, if any, in a manner that reasonably allows subsequent +Recipients to identify the originator of the Contribution.</p> + +<p><b>4. COMMERCIAL DISTRIBUTION</b></p> + +<p>Commercial distributors of software may accept certain +responsibilities with respect to end users, business partners and the +like. While this license is intended to facilitate the commercial use of +the Program, the Contributor who includes the Program in a commercial +product offering should do so in a manner which does not create +potential liability for other Contributors. Therefore, if a Contributor +includes the Program in a commercial product offering, such Contributor +("Commercial Contributor") hereby agrees to defend and +indemnify every other Contributor ("Indemnified Contributor") +against any losses, damages and costs (collectively "Losses") +arising from claims, lawsuits and other legal actions brought by a third +party against the Indemnified Contributor to the extent caused by the +acts or omissions of such Commercial Contributor in connection with its +distribution of the Program in a commercial product offering. The +obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In +order to qualify, an Indemnified Contributor must: a) promptly notify +the Commercial Contributor in writing of such claim, and b) allow the +Commercial Contributor to control, and cooperate with the Commercial +Contributor in, the defense and any related settlement negotiations. The +Indemnified Contributor may participate in any such claim at its own +expense.</p> + +<p>For example, a Contributor might include the Program in a commercial +product offering, Product X. That Contributor is then a Commercial +Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance +claims and warranties are such Commercial Contributor's responsibility +alone. Under this section, the Commercial Contributor would have to +defend claims against the other Contributors related to those +performance claims and warranties, and if a court requires any other +Contributor to pay any damages as a result, the Commercial Contributor +must pay those damages.</p> + +<p><b>5. NO WARRANTY</b></p> + +<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS +PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS +OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, +ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY +OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely +responsible for determining the appropriateness of using and +distributing the Program and assumes all risks associated with its +exercise of rights under this Agreement , including but not limited to +the risks and costs of program errors, compliance with applicable laws, +damage to or loss of data, programs or equipment, and unavailability or +interruption of operations.</p> + +<p><b>6. DISCLAIMER OF LIABILITY</b></p> + +<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT +NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING +WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR +DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED +HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p> + +<p><b>7. GENERAL</b></p> + +<p>If any provision of this Agreement is invalid or unenforceable under +applicable law, it shall not affect the validity or enforceability of +the remainder of the terms of this Agreement, and without further action +by the parties hereto, such provision shall be reformed to the minimum +extent necessary to make such provision valid and enforceable.</p> + +<p>If Recipient institutes patent litigation against any entity +(including a cross-claim or counterclaim in a lawsuit) alleging that the +Program itself (excluding combinations of the Program with other +software or hardware) infringes such Recipient's patent(s), then such +Recipient's rights granted under Section 2(b) shall terminate as of the +date such litigation is filed.</p> + +<p>All Recipient's rights under this Agreement shall terminate if it +fails to comply with any of the material terms or conditions of this +Agreement and does not cure such failure in a reasonable period of time +after becoming aware of such noncompliance. If all Recipient's rights +under this Agreement terminate, Recipient agrees to cease use and +distribution of the Program as soon as reasonably practicable. However, +Recipient's obligations under this Agreement and any licenses granted by +Recipient relating to the Program shall continue and survive.</p> + +<p>Everyone is permitted to copy and distribute copies of this +Agreement, but in order to avoid inconsistency the Agreement is +copyrighted and may only be modified in the following manner. The +Agreement Steward reserves the right to publish new versions (including +revisions) of this Agreement from time to time. No one other than the +Agreement Steward has the right to modify this Agreement. The Eclipse +Foundation is the initial Agreement Steward. The Eclipse Foundation may +assign the responsibility to serve as the Agreement Steward to a +suitable separate entity. Each new version of the Agreement will be +given a distinguishing version number. The Program (including +Contributions) may always be distributed subject to the version of the +Agreement under which it was received. In addition, after a new version +of the Agreement is published, Contributor may elect to distribute the +Program (including its Contributions) under the new version. Except as +expressly stated in Sections 2(a) and 2(b) above, Recipient receives no +rights or licenses to the intellectual property of any Contributor under +this Agreement, whether expressly, by implication, estoppel or +otherwise. All rights in the Program not expressly granted under this +Agreement are reserved.</p> + +<p>This Agreement is governed by the laws of the State of New York and +the intellectual property laws of the United States of America. No party +to this Agreement will bring a legal action under this Agreement more +than one year after the cause of action arose. Each party waives its +rights to a jury trial in any resulting litigation.</p> + + + +</body></html>
\ No newline at end of file diff --git a/org.eclipse.osbp.jpa.services.feature/feature.properties b/org.eclipse.osbp.jpa.services.feature/feature.properties new file mode 100644 index 0000000..7146492 --- /dev/null +++ b/org.eclipse.osbp.jpa.services.feature/feature.properties @@ -0,0 +1,172 @@ +#======================================================================= +# Copyright (c) 2017 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany). +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Loetz GmbH&Co.KG - initial API and implementation +#======================================================================= +# feature.properties +# contains externalized strings for feature.xml +# "%foo" in feature.xml corresponds to the key "foo" in this file +# java.io.Properties file (ISO 8859-1 with "\" escapes) +# This file should be translated. + +# "featureName" property - name of the feature +featureName =OSBP jpa.services + +# "providerName" property - name of the company that provides the feature +providerName=Eclipse OSBP + +# "description" property - description of the feature +description=This feature provides the OSBP jpa.services bundle. + +# "updateSiteName" property - label for the update site +updateSiteName= + +# "copyright" property - text of the "Feature Update Copyright" +copyright=\ +Copyright (c) 2017 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany). \n\ +All rights reserved. This program and the accompanying materials\n\ +are made available under the terms of the Eclipse Public License v1.0\n\ +which accompanies this distribution, and is available at\n\ +http://www.eclipse.org/legal/epl-v10.html\n\ +\n\ +Contributors:\n\ + Loetz GmbH&Co.KG - initial API and basis\n\ + +################ end of copyright property #################################### + +# "licenseURL" property - URL of the "Feature License" +# do not translate value - just change to point to a locale-specific HTML page +licenseURL=license.html + +# "license" property - text of the "Feature Update License" +# should be plain text version of license agreement pointed to be "licenseURL" +license=\ +Eclipse Foundation Software User Agreement\n\ +February 1, 2011\n\ +\n\ +Usage Of Content\n\ +\n\ +THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\ +OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\ +USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\ +AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\ +NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\ +AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\ +AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\ +OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\ +TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\ +OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\ +BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\ +\n\ +Applicable Licenses\n\ +\n\ +Unless otherwise indicated, all Content made available by the\n\ +Eclipse Foundation is provided to you under the terms and conditions of\n\ +the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is\n\ +provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\ +For purposes of the EPL, "Program" will mean the Content.\n\ +\n\ +Content includes, but is not limited to, source code, object code,\n\ +documentation and other files maintained in the Eclipse Foundation source code\n\ +repository ("Repository") in software modules ("Modules") and made available\n\ +as downloadable archives ("Downloads").\n\ +\n\ + - Content may be structured and packaged into modules to facilitate delivering,\n\ + extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\ + plug-in fragments ("Fragments"), and features ("Features").\n\ + - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java(TM) ARchive)\n\ + in a directory named "plugins".\n\ + - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\ + Each Feature may be packaged as a sub-directory in a directory named "features".\n\ + Within a Feature, files named "feature.xml" may contain a list of the names and version\n\ + numbers of the Plug-ins and/or Fragments associated with that Feature.\n\ + - Features may also include other Features ("Included Features"). Within a Feature, files\n\ + named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\ +\n\ +The terms and conditions governing Plug-ins and Fragments should be\n\ +contained in files named "about.html" ("Abouts"). The terms and\n\ +conditions governing Features and Included Features should be contained\n\ +in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\ +Licenses may be located in any directory of a Download or Module\n\ +including, but not limited to the following locations:\n\ +\n\ + - The top-level (root) directory\n\ + - Plug-in and Fragment directories\n\ + - Inside Plug-ins and Fragments packaged as JARs\n\ + - Sub-directories of the directory named "src" of certain Plug-ins\n\ + - Feature directories\n\ +\n\ +Note: if a Feature made available by the Eclipse Foundation is installed using the\n\ +Provisioning Technology (as defined below), you must agree to a license ("Feature \n\ +Update License") during the installation process. If the Feature contains\n\ +Included Features, the Feature Update License should either provide you\n\ +with the terms and conditions governing the Included Features or inform\n\ +you where you can locate them. Feature Update Licenses may be found in\n\ +the "license" property of files named "feature.properties" found within a Feature.\n\ +Such Abouts, Feature Licenses, and Feature Update Licenses contain the\n\ +terms and conditions (or references to such terms and conditions) that\n\ +govern your use of the associated Content in that directory.\n\ +\n\ +THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER\n\ +TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\ +SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\ +\n\ + - Eclipse Distribution License Version 1.0 (available at http://www.eclipse.org/licenses/edl-v1.0.html)\n\ + - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\ + - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\ + - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\ + - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\ + - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\ +\n\ +IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\ +TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License\n\ +is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\ +govern that particular Content.\n\ +\n\ +\n\Use of Provisioning Technology\n\ +\n\ +The Eclipse Foundation makes available provisioning software, examples of which include,\n\ +but are not limited to, p2 and the Eclipse Update Manager ("Provisioning Technology") for\n\ +the purpose of allowing users to install software, documentation, information and/or\n\ +other materials (collectively "Installable Software"). This capability is provided with\n\ +the intent of allowing such users to install, extend and update Eclipse-based products.\n\ +Information about packaging Installable Software is available at\n\ +http://eclipse.org/equinox/p2/repository_packaging.html ("Specification").\n\ +\n\ +You may use Provisioning Technology to allow other parties to install Installable Software.\n\ +You shall be responsible for enabling the applicable license agreements relating to the\n\ +Installable Software to be presented to, and accepted by, the users of the Provisioning Technology\n\ +in accordance with the Specification. By using Provisioning Technology in such a manner and\n\ +making it available in accordance with the Specification, you further acknowledge your\n\ +agreement to, and the acquisition of all necessary rights to permit the following:\n\ +\n\ + 1. A series of actions may occur ("Provisioning Process") in which a user may execute\n\ + the Provisioning Technology on a machine ("Target Machine") with the intent of installing,\n\ + extending or updating the functionality of an Eclipse-based product.\n\ + 2. During the Provisioning Process, the Provisioning Technology may cause third party\n\ + Installable Software or a portion thereof to be accessed and copied to the Target Machine.\n\ + 3. Pursuant to the Specification, you will provide to the user the terms and conditions that\n\ + govern the use of the Installable Software ("Installable Software Agreement") and such\n\ + Installable Software Agreement shall be accessed from the Target Machine in accordance\n\ + with the Specification. Such Installable Software Agreement must inform the user of the\n\ + terms and conditions that govern the Installable Software and must solicit acceptance by\n\ + the end user in the manner prescribed in such Installable Software Agreement. Upon such\n\ + indication of agreement by the user, the provisioning Technology will complete installation\n\ + of the Installable Software.\n\ +\n\ +Cryptography\n\ +\n\ +Content may contain encryption software. The country in which you are\n\ +currently may have restrictions on the import, possession, and use,\n\ +and/or re-export to another country, of encryption software. BEFORE\n\ +using any encryption software, please check the country's laws,\n\ +regulations and policies concerning the import, possession, or use, and\n\ +re-export of encryption software, to see if this is permitted.\n\ +\n\ +Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.\n +########### end of license property ########################################## diff --git a/org.eclipse.osbp.jpa.services.feature/feature.xml b/org.eclipse.osbp.jpa.services.feature/feature.xml new file mode 100644 index 0000000..81c4ed3 --- /dev/null +++ b/org.eclipse.osbp.jpa.services.feature/feature.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<feature + id="org.eclipse.osbp.jpa.services.feature" + label="%featureName" + version="0.9.0.qualifier" + provider-name="%providerName"> + + <description> + %description + </description> + + <copyright> + %copyright + </copyright> + + <license url="%licenseURL"> + %license + </license> + + <plugin + id="org.eclipse.osbp.jpa.services" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + + +</feature>
\ No newline at end of file diff --git a/org.eclipse.osbp.jpa.services.feature/license.html b/org.eclipse.osbp.jpa.services.feature/license.html new file mode 100644 index 0000000..6e579a5 --- /dev/null +++ b/org.eclipse.osbp.jpa.services.feature/license.html @@ -0,0 +1,164 @@ +<!--?xml version="1.0" encoding="ISO-8859-1" ?--> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"><head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> +<title>Eclipse Foundation Software User Agreement</title> +</head> + +<body lang="EN-US"> +<h2>Eclipse Foundation Software User Agreement</h2> +<p>February 1, 2011</p> + +<h3>Usage Of Content</h3> + +<p>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS + (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND + CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE + OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR + NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND + CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.</p> + +<h3>Applicable Licenses</h3> + +<p>Unless otherwise indicated, all Content made available by the Eclipse + Foundation is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 + ("EPL"). A copy of the EPL is provided with this Content and is also + available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. + For purposes of the EPL, "Program" will mean the Content.</p> + +<p>Content includes, but is not limited to, source code, object code, +documentation and other files maintained in the Eclipse Foundation +source code + repository ("Repository") in software modules ("Modules") and made +available as downloadable archives ("Downloads").</p> + +<ul> + <li>Content may be structured and packaged into modules to +facilitate delivering, extending, and upgrading the Content. Typical +modules may include plug-ins ("Plug-ins"), plug-in fragments +("Fragments"), and features ("Features").</li> + <li>Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java™ ARchive) in a directory named "plugins".</li> + <li>A Feature is a bundle of one or more Plug-ins and/or +Fragments and associated material. Each Feature may be packaged as a +sub-directory in a directory named "features". Within a Feature, files +named "feature.xml" may contain a list of the names and version numbers +of the Plug-ins + and/or Fragments associated with that Feature.</li> + <li>Features may also include other Features ("Included +Features"). Within a Feature, files named "feature.xml" may contain a +list of the names and version numbers of Included Features.</li> +</ul> + +<p>The terms and conditions governing Plug-ins and Fragments should be +contained in files named "about.html" ("Abouts"). The terms and +conditions governing Features and +Included Features should be contained in files named "license.html" +("Feature Licenses"). Abouts and Feature Licenses may be located in any + directory of a Download or Module +including, but not limited to the following locations:</p> + +<ul> + <li>The top-level (root) directory</li> + <li>Plug-in and Fragment directories</li> + <li>Inside Plug-ins and Fragments packaged as JARs</li> + <li>Sub-directories of the directory named "src" of certain Plug-ins</li> + <li>Feature directories</li> +</ul> + +<p>Note: if a Feature made available by the Eclipse Foundation is +installed using the Provisioning Technology (as defined below), you must + agree to a license ("Feature Update License") during the +installation process. If the Feature contains Included Features, the +Feature Update License should either provide you with the terms and +conditions governing the Included Features or +inform you where you can locate them. Feature Update Licenses may be +found in the "license" property of files named "feature.properties" +found within a Feature. +Such Abouts, Feature Licenses, and Feature Update Licenses contain the +terms and conditions (or references to such terms and conditions) that +govern your use of the associated Content in +that directory.</p> + +<p>THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER +TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. + SOME OF THESE +OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</p> + +<ul> + <li>Eclipse Distribution License Version 1.0 (available at <a href="http://www.eclipse.org/licenses/edl-v10.html">http://www.eclipse.org/licenses/edl-v1.0.html</a>)</li> + <li>Common Public License Version 1.0 (available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>)</li> + <li>Apache Software License 1.1 (available at <a href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</a>)</li> + <li>Apache Software License 2.0 (available at <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>)</li> + <li>Metro Link Public License 1.00 (available at <a href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</a>)</li> + <li>Mozilla Public License Version 1.1 (available at <a href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</a>)</li> +</ul> + +<p>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND +CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, +or Feature Update License is provided, please +contact the Eclipse Foundation to determine what terms and conditions +govern that particular Content.</p> + + +<h3>Use of Provisioning Technology</h3> + +<p>The Eclipse Foundation makes available provisioning software, +examples of which include, but are not limited to, p2 and the Eclipse + Update Manager ("Provisioning Technology") for the purpose of +allowing users to install software, documentation, information and/or + other materials (collectively "Installable Software"). This +capability is provided with the intent of allowing such users to + install, extend and update Eclipse-based products. Information about +packaging Installable Software is available at <a href="http://eclipse.org/equinox/p2/repository_packaging.html">http://eclipse.org/equinox/p2/repository_packaging.html</a> + ("Specification").</p> + +<p>You may use Provisioning Technology to allow other parties to install + Installable Software. You shall be responsible for enabling the + applicable license agreements relating to the Installable Software to + be presented to, and accepted by, the users of the Provisioning +Technology + in accordance with the Specification. By using Provisioning +Technology in such a manner and making it available in accordance with +the + Specification, you further acknowledge your agreement to, and the +acquisition of all necessary rights to permit the following:</p> + +<ol> + <li>A series of actions may occur ("Provisioning Process") in +which a user may execute the Provisioning Technology + on a machine ("Target Machine") with the intent of installing, +extending or updating the functionality of an Eclipse-based + product.</li> + <li>During the Provisioning Process, the Provisioning Technology +may cause third party Installable Software or a portion thereof to be + accessed and copied to the Target Machine.</li> + <li>Pursuant to the Specification, you will provide to the user +the terms and conditions that govern the use of the Installable + Software ("Installable Software Agreement") and such Installable +Software Agreement shall be accessed from the Target + Machine in accordance with the Specification. Such Installable +Software Agreement must inform the user of the terms and conditions that + govern + the Installable Software and must solicit acceptance by the end +user in the manner prescribed in such Installable Software Agreement. +Upon such + indication of agreement by the user, the provisioning Technology +will complete installation of the Installable Software.</li> +</ol> + +<h3>Cryptography</h3> + +<p>Content may contain encryption software. The country in which you are + currently may have restrictions on the import, possession, and use, +and/or re-export to + another country, of encryption software. BEFORE using any encryption +software, please check the country's laws, regulations and policies +concerning the import, + possession, or use, and re-export of encryption software, to see if +this is permitted.</p> + +<p><small>Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.</small></p> + + +</body></html>
\ No newline at end of file diff --git a/org.eclipse.osbp.jpa.services.feature/notice.html b/org.eclipse.osbp.jpa.services.feature/notice.html new file mode 100644 index 0000000..c3d34c3 --- /dev/null +++ b/org.eclipse.osbp.jpa.services.feature/notice.html @@ -0,0 +1,107 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> +<title>Eclipse Foundation Software User Agreement</title> +</head> + +<body lang="EN-US"> +<h2>Eclipse Foundation Software User Agreement</h2> +<p>April 9, 2014</p> + +<h3>Usage Of Content</h3> + +<p>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS + (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND + CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE + OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR + NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND + CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.</p> + +<h3>Applicable Licenses</h3> + +<p>Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 + ("EPL"). A copy of the EPL is provided with this Content and is also available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. + For purposes of the EPL, "Program" will mean the Content.</p> + +<p>Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse Foundation source code + repository ("Repository") in software modules ("Modules") and made available as downloadable archives ("Downloads").</p> + +<ul> + <li>Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and features ("Features").</li> + <li>Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java™ ARchive) in a directory named "plugins".</li> + <li>A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Each Feature may be packaged as a sub-directory in a directory named "features". Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of the Plug-ins + and/or Fragments associated with that Feature.</li> + <li>Features may also include other Features ("Included Features"). Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of Included Features.</li> +</ul> + +<p>The terms and conditions governing Plug-ins and Fragments should be contained in files named "about.html" ("Abouts"). The terms and conditions governing Features and +Included Features should be contained in files named "license.html" ("Feature Licenses"). Abouts and Feature Licenses may be located in any directory of a Download or Module +including, but not limited to the following locations:</p> + +<ul> + <li>The top-level (root) directory</li> + <li>Plug-in and Fragment directories</li> + <li>Inside Plug-ins and Fragments packaged as JARs</li> + <li>Sub-directories of the directory named "src" of certain Plug-ins</li> + <li>Feature directories</li> +</ul> + +<p>Note: if a Feature made available by the Eclipse Foundation is installed using the Provisioning Technology (as defined below), you must agree to a license ("Feature Update License") during the +installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or +inform you where you can locate them. Feature Update Licenses may be found in the "license" property of files named "feature.properties" found within a Feature. +Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in +that directory.</p> + +<p>THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE +OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</p> + +<ul> + <li>Eclipse Distribution License Version 1.0 (available at <a href="http://www.eclipse.org/licenses/edl-v10.html">http://www.eclipse.org/licenses/edl-v1.0.html</a>)</li> + <li>Common Public License Version 1.0 (available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>)</li> + <li>Apache Software License 1.1 (available at <a href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</a>)</li> + <li>Apache Software License 2.0 (available at <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>)</li> + <li>Mozilla Public License Version 1.1 (available at <a href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</a>)</li> +</ul> + +<p>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please +contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.</p> + + +<h3>Use of Provisioning Technology</h3> + +<p>The Eclipse Foundation makes available provisioning software, examples of which include, but are not limited to, p2 and the Eclipse + Update Manager ("Provisioning Technology") for the purpose of allowing users to install software, documentation, information and/or + other materials (collectively "Installable Software"). This capability is provided with the intent of allowing such users to + install, extend and update Eclipse-based products. Information about packaging Installable Software is available at <a + href="http://eclipse.org/equinox/p2/repository_packaging.html">http://eclipse.org/equinox/p2/repository_packaging.html</a> + ("Specification").</p> + +<p>You may use Provisioning Technology to allow other parties to install Installable Software. You shall be responsible for enabling the + applicable license agreements relating to the Installable Software to be presented to, and accepted by, the users of the Provisioning Technology + in accordance with the Specification. By using Provisioning Technology in such a manner and making it available in accordance with the + Specification, you further acknowledge your agreement to, and the acquisition of all necessary rights to permit the following:</p> + +<ol> + <li>A series of actions may occur ("Provisioning Process") in which a user may execute the Provisioning Technology + on a machine ("Target Machine") with the intent of installing, extending or updating the functionality of an Eclipse-based + product.</li> + <li>During the Provisioning Process, the Provisioning Technology may cause third party Installable Software or a portion thereof to be + accessed and copied to the Target Machine.</li> + <li>Pursuant to the Specification, you will provide to the user the terms and conditions that govern the use of the Installable + Software ("Installable Software Agreement") and such Installable Software Agreement shall be accessed from the Target + Machine in accordance with the Specification. Such Installable Software Agreement must inform the user of the terms and conditions that govern + the Installable Software and must solicit acceptance by the end user in the manner prescribed in such Installable Software Agreement. Upon such + indication of agreement by the user, the provisioning Technology will complete installation of the Installable Software.</li> +</ol> + +<h3>Cryptography</h3> + +<p>Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to + another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import, + possession, or use, and re-export of encryption software, to see if this is permitted.</p> + +<p><small>Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.</small></p> +</body> +</html> diff --git a/org.eclipse.osbp.jpa.services.feature/pom.xml b/org.eclipse.osbp.jpa.services.feature/pom.xml new file mode 100644 index 0000000..ab580bb --- /dev/null +++ b/org.eclipse.osbp.jpa.services.feature/pom.xml @@ -0,0 +1,84 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +#======================================================================= +# Copyright (c) 2017 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany). +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Loetz GmbH&Co.KG - initial API and implementation +#======================================================================= +--> +<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/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.eclipse.osbp.jpa.services</groupId> + <artifactId>org.eclipse.osbp.jpa.services.aggregator</artifactId> + <version>0.9.0-SNAPSHOT</version> + </parent> + + <artifactId>org.eclipse.osbp.jpa.services.feature</artifactId> + <packaging>eclipse-feature</packaging> + + <build> + <plugins> + <plugin> + <groupId>org.eclipse.tycho.extras</groupId> + <artifactId>tycho-source-feature-plugin</artifactId> + <version>${tychoExtrasVersion}</version> + <executions> + <execution> + <id>source-feature</id> + <phase>package</phase> + <goals> + <goal>source-feature</goal> + </goals> + </execution> + </executions> + <configuration> + <labelSuffix> (source)</labelSuffix> + </configuration> + </plugin> + <plugin> + <!-- workaround while bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=398250 + is not fixed --> + <groupId>org.eclipse.tycho</groupId> + <artifactId>tycho-p2-plugin</artifactId> + <version>${tycho-version}</version> + <executions> + <execution> + <id>attached-p2-metadata</id> + <phase>package</phase> + <goals> + <goal>p2-metadata</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-javadoc-plugin</artifactId> + <executions> + <execution> + <id>javadoc-jar</id> + <phase>package</phase> + <goals> + <goal>jar</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>org.eclipse.osbp.jpa.services</groupId> + <artifactId>org.eclipse.osbp.jpa.services</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + +</project> diff --git a/org.eclipse.osbp.jpa.services.feature/src/main/javadoc/README.txt b/org.eclipse.osbp.jpa.services.feature/src/main/javadoc/README.txt new file mode 100644 index 0000000..831da7e --- /dev/null +++ b/org.eclipse.osbp.jpa.services.feature/src/main/javadoc/README.txt @@ -0,0 +1 @@ +Resource folder for javadoc resources.
\ No newline at end of file diff --git a/org.eclipse.osbp.jpa.services.feature/src/overview.html b/org.eclipse.osbp.jpa.services.feature/src/overview.html new file mode 100644 index 0000000..bf770dc --- /dev/null +++ b/org.eclipse.osbp.jpa.services.feature/src/overview.html @@ -0,0 +1,9 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<html> +<head> + <title>OSBP jpa.services</title> +</head> +<body> +<p>The <strong>OSBP jpa.services</strong> provides bundles for the OSBP jpa.services functionality.</p> +</body> +</html> diff --git a/org.eclipse.osbp.jpa.services/.classpath b/org.eclipse.osbp.jpa.services/.classpath new file mode 100644 index 0000000..cf36b56 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src/"/> + <classpathentry kind="output" path="target/classes"/> +</classpath> diff --git a/org.eclipse.osbp.jpa.services/.project b/org.eclipse.osbp.jpa.services/.project new file mode 100644 index 0000000..a0c74c9 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/.project @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.osbp.jpa.services</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.xtext.ui.shared.xtextBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ds.core.builder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.babel.editor.rbeBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.sonarlint.eclipse.core.sonarlintBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.m2e.core.maven2Builder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.xtext.ui.shared.xtextNature</nature> + <nature>org.eclipse.m2e.core.maven2Nature</nature> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + <nature>org.eclipse.babel.editor.rbeNature</nature> + </natures> +</projectDescription> diff --git a/org.eclipse.osbp.jpa.services/.settings/com.vaadin.integration.eclipse.prefs b/org.eclipse.osbp.jpa.services/.settings/com.vaadin.integration.eclipse.prefs new file mode 100644 index 0000000..e1173bc --- /dev/null +++ b/org.eclipse.osbp.jpa.services/.settings/com.vaadin.integration.eclipse.prefs @@ -0,0 +1,2 @@ +com.vaadin.integration.eclipse.previousCompileAction=widgetset +eclipse.preferences.version=1 diff --git a/org.eclipse.osbp.jpa.services/.settings/org.eclipse.bpmn2.modeler.core.prefs b/org.eclipse.osbp.jpa.services/.settings/org.eclipse.bpmn2.modeler.core.prefs new file mode 100644 index 0000000..4bffcea --- /dev/null +++ b/org.eclipse.osbp.jpa.services/.settings/org.eclipse.bpmn2.modeler.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +target.runtime=org.jboss.runtime.jbpm5 diff --git a/org.eclipse.osbp.jpa.services/.settings/org.eclipse.core.resources.prefs b/org.eclipse.osbp.jpa.services/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/<project>=UTF-8 diff --git a/org.eclipse.osbp.jpa.services/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.osbp.jpa.services/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..a698e59 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/org.eclipse.osbp.jpa.services/.settings/org.eclipse.m2e.core.prefs b/org.eclipse.osbp.jpa.services/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/org.eclipse.osbp.jpa.services/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/org.eclipse.osbp.jpa.services/.settings/org.eclipse.pde.core.prefs b/org.eclipse.osbp.jpa.services/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 0000000..f29e940 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +pluginProject.extensions=false +resolve.requirebundle=false diff --git a/org.eclipse.osbp.jpa.services/.settings/org.eclipse.xtend.core.Xtend.prefs b/org.eclipse.osbp.jpa.services/.settings/org.eclipse.xtend.core.Xtend.prefs new file mode 100644 index 0000000..19e3115 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/.settings/org.eclipse.xtend.core.Xtend.prefs @@ -0,0 +1,11 @@ +//outlet.DEFAULT_OUTPUT.sourceFolder.src/test/java.directory=src/test/generated-sources/xtend +BuilderConfiguration.is_project_specific=true +eclipse.preferences.version=1 +is_project_specific=true +outlet.DEFAULT_OUTPUT.hideLocalSyntheticVariables=true +outlet.DEFAULT_OUTPUT.installDslAsPrimarySource=false +outlet.DEFAULT_OUTPUT.sourceFolder.emf-gen.directory=xtend-gen +outlet.DEFAULT_OUTPUT.sourceFolder.src-gen.directory=xtend-gen +outlet.DEFAULT_OUTPUT.sourceFolder.src.directory=xtend-gen +outlet.DEFAULT_OUTPUT.sourceFolder.xtend-gen.directory=xtend-gen +outlet.DEFAULT_OUTPUT.userOutputPerSourceFolder=true diff --git a/org.eclipse.osbp.jpa.services/LICENSE.txt b/org.eclipse.osbp.jpa.services/LICENSE.txt new file mode 100644 index 0000000..ff42ad4 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/LICENSE.txt @@ -0,0 +1,161 @@ +Eclipse Public License -v 1.0 + +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION +OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + +a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and + +b) in the case of each subsequent Contributor: + +i) changes to the Program, and + +ii) additions to the Program; + +where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. +A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone +acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate +modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not +derivative works of the Program. + +"Contributor" means any person or entity that distributes the Program. + +"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of +its Contribution alone or when combined with the Program. + +"Program" means the Contributions distributed in accordance with this Agreement. + +"Recipient" means anyone who receives the Program under this Agreement, including all Contributors. + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, +royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute +and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code +form. + +b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, +royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the +Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the +combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such +addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not +apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. + +c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no +assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property +rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity +based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and +licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property +rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the +Program, it is Recipient's responsibility to acquire that license before distributing the Program. + +d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to +grant the copyright license set forth in this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that: + +a) it complies with the terms and conditions of this Agreement; and + +b) its license agreement: + +i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including +warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and +fitness for a particular purpose; + +ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, +incidental and consequential damages, such as lost profits; + +iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any +other party; and + +iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it +in a reasonable manner on or through a medium customarily used for software exchange. + +When the Program is made available in source code form: + +a) it must be made available under this Agreement; and + +b) a copy of this Agreement must be included with each copy of the Program. + +Contributors may not remove or alter any copyright notices contained within the Program. + +Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows +subsequent Recipients to identify the originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and +the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes +the Program in a commercial product offering should do so in a manner which does not create potential liability for +other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor +("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") +against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions +brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such +Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The +obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual +property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the +Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may + participate in any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is +then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties +related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. +Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to +those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, +the Commercial Contributor must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR +CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, +NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for +determining the appropriateness of using and distributing the Program and assumes all risks associated with its +exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance +with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED +HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or +enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such +provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. + +If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) +alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such +Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such +litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or +conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such +noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution +of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses + granted by Recipient relating to the Program shall continue and survive. + +Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement +is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish +new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the +right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may +assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the +Agreement will be given a distinguishing version number. The Program (including Contributions) may always be +distributed subject to the version of the Agreement under which it was received. In addition, after a new version of +the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the +new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to +the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or +otherwise. All rights in the Program not expressly granted under this Agreement are reserved. + +This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States +of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause +of action arose. Each party waives its rights to a jury trial in any resulting litigation.
\ No newline at end of file diff --git a/org.eclipse.osbp.jpa.services/META-INF/MANIFEST.MF b/org.eclipse.osbp.jpa.services/META-INF/MANIFEST.MF new file mode 100644 index 0000000..338fbbd --- /dev/null +++ b/org.eclipse.osbp.jpa.services/META-INF/MANIFEST.MF @@ -0,0 +1,31 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: org.eclipse.osbp.jpa.services +Bundle-Vendor: Eclipse OSBP +Bundle-Version: 0.9.0.qualifier +Bundle-SymbolicName: org.eclipse.osbp.jpa.services +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Import-Package: javax.persistence, + javax.persistence.criteria;version="2.1.0", + javax.transaction;version="1.1.0", + javax.validation;version="1.1.0", + javax.validation.metadata;version="1.1.0", + org.eclipse.emf.ecore, + org.osgi.dto;version="1.0.0", + org.osgi.framework;version="1.8.0", + org.osgi.service.component;version="1.2.2", + org.osgi.service.component.annotations;version="1.2.0", + org.osgi.util.tracker;version="1.5.1", + org.slf4j;version="1.7.0" +Service-Component: OSGI-INF/*.xml +Require-Bundle: org.slf4j.api;bundle-version="1.7.2", + org.eclipse.osbp.runtime.common;bundle-version="[0.9.0,0.10.0)";visibility:=reexport, + org.eclipse.persistence.core;bundle-version="2.6.0";resolution:=optional, + org.eclipse.persistence.jpa;bundle-version="2.6.0";resolution:=optional, + org.apache.commons.lang;bundle-version="2.6.0", + org.junit, + org.eclipse.e4.core.contexts +Export-Package: org.eclipse.osbp.jpa.services, + org.eclipse.osbp.jpa.services.filters, + org.eclipse.osbp.jpa.services.metadata diff --git a/org.eclipse.osbp.jpa.services/OSGI-INF/org.eclipse.osbp.jpa.services.filters.LFilterService.xml b/org.eclipse.osbp.jpa.services/OSGI-INF/org.eclipse.osbp.jpa.services.filters.LFilterService.xml new file mode 100644 index 0000000..ec17df3 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/OSGI-INF/org.eclipse.osbp.jpa.services.filters.LFilterService.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.osbp.jpa.services.filters.LFilterService"> + <service> + <provide interface="org.eclipse.osbp.runtime.common.filter.ILFilterService"/> + </service> + <implementation class="org.eclipse.osbp.jpa.services.filters.LFilterService"/> +</scr:component>
\ No newline at end of file diff --git a/org.eclipse.osbp.jpa.services/README.txt b/org.eclipse.osbp.jpa.services/README.txt new file mode 100644 index 0000000..e532c98 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/README.txt @@ -0,0 +1,16 @@ +Your code for jpa.services goes in here. + +Add all your sources as you usually do for plugin development. + +If you need more bundles to implement the feature, duplicate this folder and ad the new bundle code into the copy + +Do not forget to add your new bundle to the + - feature pom.xml + - feature feature.xml + - and the aggregator pom.xml +as it is done for this bundle. + +Have fun! + + +You can delete this file from the final project.
\ No newline at end of file diff --git a/org.eclipse.osbp.jpa.services/about.html b/org.eclipse.osbp.jpa.services/about.html new file mode 100644 index 0000000..64c0598 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/about.html @@ -0,0 +1,28 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> +<title>About</title> +</head> +<body lang="EN-US"> +<h2>About This Content</h2> + +<p>June 1, 2016</p> +<h3>License</h3> + +<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. +For purposes of the EPL, "Program" will mean the Content.</p> + +<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p> + +</body> +</html>
\ No newline at end of file diff --git a/org.eclipse.osbp.jpa.services/about.ini b/org.eclipse.osbp.jpa.services/about.ini new file mode 100644 index 0000000..7df671f --- /dev/null +++ b/org.eclipse.osbp.jpa.services/about.ini @@ -0,0 +1,17 @@ +# about.ini +# contains information about a feature +# java.io.Properties file (ISO 8859-1 with "\" escapes) +# "%key" are externalized strings defined in about.properties +# This file does not need to be translated. + +# Property "aboutText" contains blurb for "About" dialog (translated) +aboutText=%featureText + +# Property "featureImage" contains path to feature image (32x32) +featureImage= + +# Property "appName" contains name of the application (translated) +appName=%featureName + +# Property "welcomePage" contains path to welcome page (special XML-based format) +welcomePage= diff --git a/org.eclipse.osbp.jpa.services/about.mappings b/org.eclipse.osbp.jpa.services/about.mappings new file mode 100644 index 0000000..4511a0a --- /dev/null +++ b/org.eclipse.osbp.jpa.services/about.mappings @@ -0,0 +1,6 @@ +# about.mappings +# contains fill-ins for about.properties +# java.io.Properties file (ISO 8859-1 with "\" escapes) +# This file does not need to be translated. + +0=qualifier diff --git a/org.eclipse.osbp.jpa.services/about.properties b/org.eclipse.osbp.jpa.services/about.properties new file mode 100644 index 0000000..109df43 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/about.properties @@ -0,0 +1,26 @@ +# +# Copyright (c) 2017 - Loetz GmbH&Co.KG (Heidelberg) +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Loetz GmbH&Co - initial API and implementation +# + +# NLS_MESSAGEFORMAT_VAR + +featureName=jpa.services + +################ blurb property #################################### +featureText=\ +Copyright (c) 2012-2016 - Loetz GmbH&Co.KG \n\ +All rights reserved. This program and the accompanying materials\n\ +are made available under the terms of the Eclipse Public License v1.0\n\ +which accompanies this distribution, and is available at\n\ +http://www.eclipse.org/legal/epl-v10.html\n\ +\n\ +Contributors:\n\ + Loetz GmbH&Co - implementation\n +################ end of blurb property #################################### diff --git a/org.eclipse.osbp.jpa.services/about_files/README.txt b/org.eclipse.osbp.jpa.services/about_files/README.txt new file mode 100644 index 0000000..cc50489 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/about_files/README.txt @@ -0,0 +1 @@ +All external licenses referenced in about file go here
\ No newline at end of file diff --git a/org.eclipse.osbp.jpa.services/build.properties b/org.eclipse.osbp.jpa.services/build.properties new file mode 100644 index 0000000..3aaaf75 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/build.properties @@ -0,0 +1,21 @@ +output.. = target/classes/ +bin.includes = META-INF/,\ + .,\ + about.html,\ + about.ini,\ + about.mappings,\ + about.properties,\ + notice.html,\ + license.html,\ + LICENSE.txt,\ + epl-v10.html,\ + OSGI-INF/org.eclipse.osbp.jpa.services.filters.LFilterService.xml +src.includes = license.html,\ + LICENSE.txt,\ + about.html,\ + about.ini,\ + about.mappings,\ + about.properties,\ + notice.html,\ + epl-v10.html +source.. = src/ diff --git a/org.eclipse.osbp.jpa.services/epl-v10.html b/org.eclipse.osbp.jpa.services/epl-v10.html new file mode 100644 index 0000000..b398acc --- /dev/null +++ b/org.eclipse.osbp.jpa.services/epl-v10.html @@ -0,0 +1,259 @@ +<!--?xml version="1.0" encoding="ISO-8859-1" ?--> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"><head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> +<title>Eclipse Public License - Version 1.0</title> +<style type="text/css"> + body { + size: 8.5in 11.0in; + margin: 0.25in 0.5in 0.25in 0.5in; + tab-interval: 0.5in; + } + p { + margin-left: auto; + margin-top: 0.5em; + margin-bottom: 0.5em; + } + p.list { + margin-left: 0.5in; + margin-top: 0.05em; + margin-bottom: 0.05em; + } + </style> + +</head> + +<body lang="EN-US"> + +<h2>Eclipse Public License - v 1.0</h2> + +<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE +PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR +DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS +AGREEMENT.</p> + +<p><b>1. DEFINITIONS</b></p> + +<p>"Contribution" means:</p> + +<p class="list">a) in the case of the initial Contributor, the initial +code and documentation distributed under this Agreement, and</p> +<p class="list">b) in the case of each subsequent Contributor:</p> +<p class="list">i) changes to the Program, and</p> +<p class="list">ii) additions to the Program;</p> +<p class="list">where such changes and/or additions to the Program +originate from and are distributed by that particular Contributor. A +Contribution 'originates' from a Contributor if it was added to the +Program by such Contributor itself or anyone acting on such +Contributor's behalf. Contributions do not include additions to the +Program which: (i) are separate modules of software distributed in +conjunction with the Program under their own license agreement, and (ii) +are not derivative works of the Program.</p> + +<p>"Contributor" means any person or entity that distributes +the Program.</p> + +<p>"Licensed Patents" mean patent claims licensable by a +Contributor which are necessarily infringed by the use or sale of its +Contribution alone or when combined with the Program.</p> + +<p>"Program" means the Contributions distributed in accordance +with this Agreement.</p> + +<p>"Recipient" means anyone who receives the Program under +this Agreement, including all Contributors.</p> + +<p><b>2. GRANT OF RIGHTS</b></p> + +<p class="list">a) Subject to the terms of this Agreement, each +Contributor hereby grants Recipient a non-exclusive, worldwide, +royalty-free copyright license to reproduce, prepare derivative works +of, publicly display, publicly perform, distribute and sublicense the +Contribution of such Contributor, if any, and such derivative works, in +source code and object code form.</p> + +<p class="list">b) Subject to the terms of this Agreement, each +Contributor hereby grants Recipient a non-exclusive, worldwide, +royalty-free patent license under Licensed Patents to make, use, sell, +offer to sell, import and otherwise transfer the Contribution of such +Contributor, if any, in source code and object code form. This patent +license shall apply to the combination of the Contribution and the +Program if, at the time the Contribution is added by the Contributor, +such addition of the Contribution causes such combination to be covered +by the Licensed Patents. The patent license shall not apply to any other +combinations which include the Contribution. No hardware per se is +licensed hereunder.</p> + +<p class="list">c) Recipient understands that although each Contributor +grants the licenses to its Contributions set forth herein, no assurances +are provided by any Contributor that the Program does not infringe the +patent or other intellectual property rights of any other entity. Each +Contributor disclaims any liability to Recipient for claims brought by +any other entity based on infringement of intellectual property rights +or otherwise. As a condition to exercising the rights and licenses +granted hereunder, each Recipient hereby assumes sole responsibility to +secure any other intellectual property rights needed, if any. For +example, if a third party patent license is required to allow Recipient +to distribute the Program, it is Recipient's responsibility to acquire +that license before distributing the Program.</p> + +<p class="list">d) Each Contributor represents that to its knowledge it +has sufficient copyright rights in its Contribution, if any, to grant +the copyright license set forth in this Agreement.</p> + +<p><b>3. REQUIREMENTS</b></p> + +<p>A Contributor may choose to distribute the Program in object code +form under its own license agreement, provided that:</p> + +<p class="list">a) it complies with the terms and conditions of this +Agreement; and</p> + +<p class="list">b) its license agreement:</p> + +<p class="list">i) effectively disclaims on behalf of all Contributors +all warranties and conditions, express and implied, including warranties +or conditions of title and non-infringement, and implied warranties or +conditions of merchantability and fitness for a particular purpose;</p> + +<p class="list">ii) effectively excludes on behalf of all Contributors +all liability for damages, including direct, indirect, special, +incidental and consequential damages, such as lost profits;</p> + +<p class="list">iii) states that any provisions which differ from this +Agreement are offered by that Contributor alone and not by any other +party; and</p> + +<p class="list">iv) states that source code for the Program is available +from such Contributor, and informs licensees how to obtain it in a +reasonable manner on or through a medium customarily used for software +exchange.</p> + +<p>When the Program is made available in source code form:</p> + +<p class="list">a) it must be made available under this Agreement; and</p> + +<p class="list">b) a copy of this Agreement must be included with each +copy of the Program.</p> + +<p>Contributors may not remove or alter any copyright notices contained +within the Program.</p> + +<p>Each Contributor must identify itself as the originator of its +Contribution, if any, in a manner that reasonably allows subsequent +Recipients to identify the originator of the Contribution.</p> + +<p><b>4. COMMERCIAL DISTRIBUTION</b></p> + +<p>Commercial distributors of software may accept certain +responsibilities with respect to end users, business partners and the +like. While this license is intended to facilitate the commercial use of +the Program, the Contributor who includes the Program in a commercial +product offering should do so in a manner which does not create +potential liability for other Contributors. Therefore, if a Contributor +includes the Program in a commercial product offering, such Contributor +("Commercial Contributor") hereby agrees to defend and +indemnify every other Contributor ("Indemnified Contributor") +against any losses, damages and costs (collectively "Losses") +arising from claims, lawsuits and other legal actions brought by a third +party against the Indemnified Contributor to the extent caused by the +acts or omissions of such Commercial Contributor in connection with its +distribution of the Program in a commercial product offering. The +obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In +order to qualify, an Indemnified Contributor must: a) promptly notify +the Commercial Contributor in writing of such claim, and b) allow the +Commercial Contributor to control, and cooperate with the Commercial +Contributor in, the defense and any related settlement negotiations. The +Indemnified Contributor may participate in any such claim at its own +expense.</p> + +<p>For example, a Contributor might include the Program in a commercial +product offering, Product X. That Contributor is then a Commercial +Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance +claims and warranties are such Commercial Contributor's responsibility +alone. Under this section, the Commercial Contributor would have to +defend claims against the other Contributors related to those +performance claims and warranties, and if a court requires any other +Contributor to pay any damages as a result, the Commercial Contributor +must pay those damages.</p> + +<p><b>5. NO WARRANTY</b></p> + +<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS +PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS +OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, +ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY +OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely +responsible for determining the appropriateness of using and +distributing the Program and assumes all risks associated with its +exercise of rights under this Agreement , including but not limited to +the risks and costs of program errors, compliance with applicable laws, +damage to or loss of data, programs or equipment, and unavailability or +interruption of operations.</p> + +<p><b>6. DISCLAIMER OF LIABILITY</b></p> + +<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT +NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING +WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR +DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED +HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p> + +<p><b>7. GENERAL</b></p> + +<p>If any provision of this Agreement is invalid or unenforceable under +applicable law, it shall not affect the validity or enforceability of +the remainder of the terms of this Agreement, and without further action +by the parties hereto, such provision shall be reformed to the minimum +extent necessary to make such provision valid and enforceable.</p> + +<p>If Recipient institutes patent litigation against any entity +(including a cross-claim or counterclaim in a lawsuit) alleging that the +Program itself (excluding combinations of the Program with other +software or hardware) infringes such Recipient's patent(s), then such +Recipient's rights granted under Section 2(b) shall terminate as of the +date such litigation is filed.</p> + +<p>All Recipient's rights under this Agreement shall terminate if it +fails to comply with any of the material terms or conditions of this +Agreement and does not cure such failure in a reasonable period of time +after becoming aware of such noncompliance. If all Recipient's rights +under this Agreement terminate, Recipient agrees to cease use and +distribution of the Program as soon as reasonably practicable. However, +Recipient's obligations under this Agreement and any licenses granted by +Recipient relating to the Program shall continue and survive.</p> + +<p>Everyone is permitted to copy and distribute copies of this +Agreement, but in order to avoid inconsistency the Agreement is +copyrighted and may only be modified in the following manner. The +Agreement Steward reserves the right to publish new versions (including +revisions) of this Agreement from time to time. No one other than the +Agreement Steward has the right to modify this Agreement. The Eclipse +Foundation is the initial Agreement Steward. The Eclipse Foundation may +assign the responsibility to serve as the Agreement Steward to a +suitable separate entity. Each new version of the Agreement will be +given a distinguishing version number. The Program (including +Contributions) may always be distributed subject to the version of the +Agreement under which it was received. In addition, after a new version +of the Agreement is published, Contributor may elect to distribute the +Program (including its Contributions) under the new version. Except as +expressly stated in Sections 2(a) and 2(b) above, Recipient receives no +rights or licenses to the intellectual property of any Contributor under +this Agreement, whether expressly, by implication, estoppel or +otherwise. All rights in the Program not expressly granted under this +Agreement are reserved.</p> + +<p>This Agreement is governed by the laws of the State of New York and +the intellectual property laws of the United States of America. No party +to this Agreement will bring a legal action under this Agreement more +than one year after the cause of action arose. Each party waives its +rights to a jury trial in any resulting litigation.</p> + + + +</body></html>
\ No newline at end of file diff --git a/org.eclipse.osbp.jpa.services/license.html b/org.eclipse.osbp.jpa.services/license.html new file mode 100644 index 0000000..6e579a5 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/license.html @@ -0,0 +1,164 @@ +<!--?xml version="1.0" encoding="ISO-8859-1" ?--> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"><head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> +<title>Eclipse Foundation Software User Agreement</title> +</head> + +<body lang="EN-US"> +<h2>Eclipse Foundation Software User Agreement</h2> +<p>February 1, 2011</p> + +<h3>Usage Of Content</h3> + +<p>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS + (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND + CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE + OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR + NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND + CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.</p> + +<h3>Applicable Licenses</h3> + +<p>Unless otherwise indicated, all Content made available by the Eclipse + Foundation is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 + ("EPL"). A copy of the EPL is provided with this Content and is also + available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. + For purposes of the EPL, "Program" will mean the Content.</p> + +<p>Content includes, but is not limited to, source code, object code, +documentation and other files maintained in the Eclipse Foundation +source code + repository ("Repository") in software modules ("Modules") and made +available as downloadable archives ("Downloads").</p> + +<ul> + <li>Content may be structured and packaged into modules to +facilitate delivering, extending, and upgrading the Content. Typical +modules may include plug-ins ("Plug-ins"), plug-in fragments +("Fragments"), and features ("Features").</li> + <li>Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java™ ARchive) in a directory named "plugins".</li> + <li>A Feature is a bundle of one or more Plug-ins and/or +Fragments and associated material. Each Feature may be packaged as a +sub-directory in a directory named "features". Within a Feature, files +named "feature.xml" may contain a list of the names and version numbers +of the Plug-ins + and/or Fragments associated with that Feature.</li> + <li>Features may also include other Features ("Included +Features"). Within a Feature, files named "feature.xml" may contain a +list of the names and version numbers of Included Features.</li> +</ul> + +<p>The terms and conditions governing Plug-ins and Fragments should be +contained in files named "about.html" ("Abouts"). The terms and +conditions governing Features and +Included Features should be contained in files named "license.html" +("Feature Licenses"). Abouts and Feature Licenses may be located in any + directory of a Download or Module +including, but not limited to the following locations:</p> + +<ul> + <li>The top-level (root) directory</li> + <li>Plug-in and Fragment directories</li> + <li>Inside Plug-ins and Fragments packaged as JARs</li> + <li>Sub-directories of the directory named "src" of certain Plug-ins</li> + <li>Feature directories</li> +</ul> + +<p>Note: if a Feature made available by the Eclipse Foundation is +installed using the Provisioning Technology (as defined below), you must + agree to a license ("Feature Update License") during the +installation process. If the Feature contains Included Features, the +Feature Update License should either provide you with the terms and +conditions governing the Included Features or +inform you where you can locate them. Feature Update Licenses may be +found in the "license" property of files named "feature.properties" +found within a Feature. +Such Abouts, Feature Licenses, and Feature Update Licenses contain the +terms and conditions (or references to such terms and conditions) that +govern your use of the associated Content in +that directory.</p> + +<p>THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER +TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. + SOME OF THESE +OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</p> + +<ul> + <li>Eclipse Distribution License Version 1.0 (available at <a href="http://www.eclipse.org/licenses/edl-v10.html">http://www.eclipse.org/licenses/edl-v1.0.html</a>)</li> + <li>Common Public License Version 1.0 (available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>)</li> + <li>Apache Software License 1.1 (available at <a href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</a>)</li> + <li>Apache Software License 2.0 (available at <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>)</li> + <li>Metro Link Public License 1.00 (available at <a href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</a>)</li> + <li>Mozilla Public License Version 1.1 (available at <a href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</a>)</li> +</ul> + +<p>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND +CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, +or Feature Update License is provided, please +contact the Eclipse Foundation to determine what terms and conditions +govern that particular Content.</p> + + +<h3>Use of Provisioning Technology</h3> + +<p>The Eclipse Foundation makes available provisioning software, +examples of which include, but are not limited to, p2 and the Eclipse + Update Manager ("Provisioning Technology") for the purpose of +allowing users to install software, documentation, information and/or + other materials (collectively "Installable Software"). This +capability is provided with the intent of allowing such users to + install, extend and update Eclipse-based products. Information about +packaging Installable Software is available at <a href="http://eclipse.org/equinox/p2/repository_packaging.html">http://eclipse.org/equinox/p2/repository_packaging.html</a> + ("Specification").</p> + +<p>You may use Provisioning Technology to allow other parties to install + Installable Software. You shall be responsible for enabling the + applicable license agreements relating to the Installable Software to + be presented to, and accepted by, the users of the Provisioning +Technology + in accordance with the Specification. By using Provisioning +Technology in such a manner and making it available in accordance with +the + Specification, you further acknowledge your agreement to, and the +acquisition of all necessary rights to permit the following:</p> + +<ol> + <li>A series of actions may occur ("Provisioning Process") in +which a user may execute the Provisioning Technology + on a machine ("Target Machine") with the intent of installing, +extending or updating the functionality of an Eclipse-based + product.</li> + <li>During the Provisioning Process, the Provisioning Technology +may cause third party Installable Software or a portion thereof to be + accessed and copied to the Target Machine.</li> + <li>Pursuant to the Specification, you will provide to the user +the terms and conditions that govern the use of the Installable + Software ("Installable Software Agreement") and such Installable +Software Agreement shall be accessed from the Target + Machine in accordance with the Specification. Such Installable +Software Agreement must inform the user of the terms and conditions that + govern + the Installable Software and must solicit acceptance by the end +user in the manner prescribed in such Installable Software Agreement. +Upon such + indication of agreement by the user, the provisioning Technology +will complete installation of the Installable Software.</li> +</ol> + +<h3>Cryptography</h3> + +<p>Content may contain encryption software. The country in which you are + currently may have restrictions on the import, possession, and use, +and/or re-export to + another country, of encryption software. BEFORE using any encryption +software, please check the country's laws, regulations and policies +concerning the import, + possession, or use, and re-export of encryption software, to see if +this is permitted.</p> + +<p><small>Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.</small></p> + + +</body></html>
\ No newline at end of file diff --git a/org.eclipse.osbp.jpa.services/notice.html b/org.eclipse.osbp.jpa.services/notice.html new file mode 100644 index 0000000..c3d34c3 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/notice.html @@ -0,0 +1,107 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> +<title>Eclipse Foundation Software User Agreement</title> +</head> + +<body lang="EN-US"> +<h2>Eclipse Foundation Software User Agreement</h2> +<p>April 9, 2014</p> + +<h3>Usage Of Content</h3> + +<p>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS + (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND + CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE + OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR + NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND + CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.</p> + +<h3>Applicable Licenses</h3> + +<p>Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 + ("EPL"). A copy of the EPL is provided with this Content and is also available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. + For purposes of the EPL, "Program" will mean the Content.</p> + +<p>Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse Foundation source code + repository ("Repository") in software modules ("Modules") and made available as downloadable archives ("Downloads").</p> + +<ul> + <li>Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and features ("Features").</li> + <li>Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java™ ARchive) in a directory named "plugins".</li> + <li>A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Each Feature may be packaged as a sub-directory in a directory named "features". Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of the Plug-ins + and/or Fragments associated with that Feature.</li> + <li>Features may also include other Features ("Included Features"). Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of Included Features.</li> +</ul> + +<p>The terms and conditions governing Plug-ins and Fragments should be contained in files named "about.html" ("Abouts"). The terms and conditions governing Features and +Included Features should be contained in files named "license.html" ("Feature Licenses"). Abouts and Feature Licenses may be located in any directory of a Download or Module +including, but not limited to the following locations:</p> + +<ul> + <li>The top-level (root) directory</li> + <li>Plug-in and Fragment directories</li> + <li>Inside Plug-ins and Fragments packaged as JARs</li> + <li>Sub-directories of the directory named "src" of certain Plug-ins</li> + <li>Feature directories</li> +</ul> + +<p>Note: if a Feature made available by the Eclipse Foundation is installed using the Provisioning Technology (as defined below), you must agree to a license ("Feature Update License") during the +installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or +inform you where you can locate them. Feature Update Licenses may be found in the "license" property of files named "feature.properties" found within a Feature. +Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in +that directory.</p> + +<p>THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE +OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</p> + +<ul> + <li>Eclipse Distribution License Version 1.0 (available at <a href="http://www.eclipse.org/licenses/edl-v10.html">http://www.eclipse.org/licenses/edl-v1.0.html</a>)</li> + <li>Common Public License Version 1.0 (available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>)</li> + <li>Apache Software License 1.1 (available at <a href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</a>)</li> + <li>Apache Software License 2.0 (available at <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>)</li> + <li>Mozilla Public License Version 1.1 (available at <a href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</a>)</li> +</ul> + +<p>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please +contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.</p> + + +<h3>Use of Provisioning Technology</h3> + +<p>The Eclipse Foundation makes available provisioning software, examples of which include, but are not limited to, p2 and the Eclipse + Update Manager ("Provisioning Technology") for the purpose of allowing users to install software, documentation, information and/or + other materials (collectively "Installable Software"). This capability is provided with the intent of allowing such users to + install, extend and update Eclipse-based products. Information about packaging Installable Software is available at <a + href="http://eclipse.org/equinox/p2/repository_packaging.html">http://eclipse.org/equinox/p2/repository_packaging.html</a> + ("Specification").</p> + +<p>You may use Provisioning Technology to allow other parties to install Installable Software. You shall be responsible for enabling the + applicable license agreements relating to the Installable Software to be presented to, and accepted by, the users of the Provisioning Technology + in accordance with the Specification. By using Provisioning Technology in such a manner and making it available in accordance with the + Specification, you further acknowledge your agreement to, and the acquisition of all necessary rights to permit the following:</p> + +<ol> + <li>A series of actions may occur ("Provisioning Process") in which a user may execute the Provisioning Technology + on a machine ("Target Machine") with the intent of installing, extending or updating the functionality of an Eclipse-based + product.</li> + <li>During the Provisioning Process, the Provisioning Technology may cause third party Installable Software or a portion thereof to be + accessed and copied to the Target Machine.</li> + <li>Pursuant to the Specification, you will provide to the user the terms and conditions that govern the use of the Installable + Software ("Installable Software Agreement") and such Installable Software Agreement shall be accessed from the Target + Machine in accordance with the Specification. Such Installable Software Agreement must inform the user of the terms and conditions that govern + the Installable Software and must solicit acceptance by the end user in the manner prescribed in such Installable Software Agreement. Upon such + indication of agreement by the user, the provisioning Technology will complete installation of the Installable Software.</li> +</ol> + +<h3>Cryptography</h3> + +<p>Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to + another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import, + possession, or use, and re-export of encryption software, to see if this is permitted.</p> + +<p><small>Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.</small></p> +</body> +</html> diff --git a/org.eclipse.osbp.jpa.services/pom.xml b/org.eclipse.osbp.jpa.services/pom.xml new file mode 100644 index 0000000..8f6d5bc --- /dev/null +++ b/org.eclipse.osbp.jpa.services/pom.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +#======================================================================= +# Copyright (c) 2017 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany). +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Loetz GmbH&Co.KG - initial API and implementation +#======================================================================= +--> +<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.eclipse.osbp.jpa.services</groupId> + <artifactId>org.eclipse.osbp.jpa.services.aggregator</artifactId> + <version>0.9.0-SNAPSHOT</version> + <relativePath>..</relativePath> + </parent> + + <artifactId>org.eclipse.osbp.jpa.services</artifactId> + <packaging>eclipse-plugin</packaging> + + <build> + <sourceDirectory>src</sourceDirectory> + </build> + + </project> diff --git a/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/JPQL.java b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/JPQL.java new file mode 100644 index 0000000..8436118 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/JPQL.java @@ -0,0 +1,33 @@ +package org.eclipse.osbp.jpa.services; + +import java.util.Map; + +import org.eclipse.osbp.runtime.common.filter.IJPQL; + +@SuppressWarnings("serial") +public class JPQL implements IJPQL { + + private final String jpql; + private final Map<String, Object> params; + + public static JPQL create(String jpql, Map<String, Object> params) { + return new JPQL(jpql, params); + } + + public JPQL(String jpql, Map<String, Object> params) { + super(); + this.jpql = jpql; + this.params = params; + } + + @Override + public String getJPQL() { + return jpql; + } + + @Override + public Map<String, Object> getParameters() { + return params; + } + +} diff --git a/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/Query.java b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/Query.java new file mode 100644 index 0000000..6958179 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/Query.java @@ -0,0 +1,68 @@ +/** + * Copyright (c) 2011, 2015 - Lunifera GmbH (Gross Enzersdorf, Austria), Loetz GmbH&Co.KG (69115 Heidelberg, Germany) + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Florian Pirchner - Initial implementation + */ +package org.eclipse.osbp.jpa.services; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.osbp.runtime.common.filter.ILFilter; +import org.eclipse.osbp.runtime.common.filter.IQuery; +import org.eclipse.osbp.runtime.common.filter.SortOrder; + +@SuppressWarnings("serial") +public class Query implements IQuery { + + private ILFilter filter; + private final SortOrder sortOrder; + private final Map<String, Object> map; + public static final String ENTITY_CLASSES_KEY = "entityClassesKey"; + public static final String DATAMART_CLASSES_KEY = "datamartClassesKey"; + + public Query() { + this((ILFilter) null); + } + + public Query(ILFilter filter) { + this(filter, null); + } + + public Query(ILFilter filter, SortOrder sortOrder) { + this(filter, sortOrder, new HashMap<String, Object>()); + } + + public Query(ILFilter filter, SortOrder sortOrder, Map<String, Object> map) { + super(); + this.filter = filter; + this.sortOrder = sortOrder != null ? sortOrder : new SortOrder(); + this.map = map; + } + + @Override + public ILFilter getFilter() { + return filter; + } + + @Override + public SortOrder getSortOrder() { + return sortOrder; + } + + @Override + public void replaceFilter(ILFilter filter) { + this.filter = filter; + } + + @Override + public Map<String, Object> getMap() { + return map; + } + +} diff --git a/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LAbstractJunctionFilter.java b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LAbstractJunctionFilter.java new file mode 100644 index 0000000..26ee3d1 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LAbstractJunctionFilter.java @@ -0,0 +1,84 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + * + * Contributor: + * Florian Pirchner - Copied filter and fixed them for osbp usecase. + */ +package org.eclipse.osbp.jpa.services.filters; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; + +import org.eclipse.osbp.runtime.common.filter.ILFilter; + + +public class LAbstractJunctionFilter implements ILFilter { + + protected final Collection<ILFilter> filters; + + public LAbstractJunctionFilter(ILFilter... filters) { + this.filters = Collections.unmodifiableCollection(Arrays + .asList(filters)); + } + + /** + * Returns an unmodifiable collection of the sub-filters of this composite + * filter. + * + * @return + */ + public Collection<ILFilter> getFilters() { + return filters; + } + + /** + * Returns true if a change in the named property may affect the filtering + * result. If some of the sub-filters are not in-memory filters, true is + * returned. + * + * By default, all sub-filters are iterated to check if any of them applies. + * If there are no sub-filters, false is returned - override in subclasses + * to change this behavior. + */ + @Override + public boolean appliesToProperty(Object propertyId) { + for (ILFilter filter : getFilters()) { + if (filter.appliesToProperty(propertyId)) { + return true; + } + } + return false; + } + + @Override + public boolean equals(Object obj) { + if (obj == null || !getClass().equals(obj.getClass())) { + return false; + } + LAbstractJunctionFilter other = (LAbstractJunctionFilter) obj; + // contents comparison with equals() + return Arrays.equals(filters.toArray(), other.filters.toArray()); + } + + @Override + public int hashCode() { + int hash = getFilters().size(); + for (ILFilter filter : filters) { + hash = (hash << 1) ^ filter.hashCode(); + } + return hash; + } +} diff --git a/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LAdvancedFilterable.java b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LAdvancedFilterable.java new file mode 100644 index 0000000..7f19683 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LAdvancedFilterable.java @@ -0,0 +1,109 @@ +/** + * Copyright 2009-2013 Oy Vaadin Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.eclipse.osbp.jpa.services.filters; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.osbp.runtime.common.filter.ILFilter; + +/** + * Container that supports a bit more advanced filtering than <code>Filterable</code> + * . It has been designed to be used explicitly with JPA. + * + * @author Petter Holmström (Vaadin Ltd) + * @since 1.0 + */ +public interface LAdvancedFilterable { + + /** + * Gets the IDs of all the properties that are filterable. + * + * @return an unmodifiable collection of property IDs (never null). + */ + public Collection<Object> getFilterablePropertyIds(); + + /** + * Checks if <code>propertyId</code> is filterable. + * + * @param propertyId + * the property ID to check (must not be null). + * @return true if the property is filterable, false otherwise. + */ + public boolean isFilterable(Object propertyId); + + /** + * Gets the list of filters to apply. The filters will be applied as a + * conjunction (i.e. AND) in the order they appear in. + * + * @return an unmodifiable list of filters (never null). + */ + public List<ILFilter> getFilters(); + + /** + * Gets the list of filters that are currently applied. If + * {@link #isApplyFiltersImmediately() } returns true, this list will be the + * same as the one returned by {@link #getFilters() }. + * + * @return an unmodifiable list of filters (never null). + */ + public List<ILFilter> getAppliedFilters(); + + /** + * Sets whether the filters should be applied immediately when a filter is + * added or removed. + * + * @see #isApplyFiltersImmediately() + * @param applyFiltersImmediately + * true to apply filters immediately, false to apply when + * {@link #applyFilters() } is called. + */ + public void setApplyFiltersImmediately(boolean applyFiltersImmediately); + + /** + * Returns whether the filters should be applied immediately when a filter + * is added or removed. Default is true. If false, {@link #applyFilters() } + * has to be called to apply the filters and update the container. + * + * @see #setApplyFiltersImmediately(boolean) + * @return true if the filters are applied immediately, false otherwise. + */ + public boolean isApplyFiltersImmediately(); + + /** + * Applies the filters to the data, possibly causing the items in the + * container to change. + * + * see FiltersAppliedEvent + */ + public void applyFilters(); + + /** + * Checks if there are filters that have not yet been applied, or applied + * filters that have been removed using <code>removeAllFilters</code> or + * <code>removeFilter(org.eclipse.osbp.ILFilter.web.vaadin.components.fields.container.IFilter) </code> + * . + * <p> + * If {@link #isApplyFiltersImmediately() } is true, this method always + * returns false. + * + * @see #applyFilters() + * @return true if there are unapplied filters, false otherwise. + */ + public boolean hasUnappliedFilters(); + +} diff --git a/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LAdvancedFilterableSupport.java b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LAdvancedFilterableSupport.java new file mode 100644 index 0000000..a4264d4 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LAdvancedFilterableSupport.java @@ -0,0 +1,271 @@ +/** + * Copyright 2009-2013 Oy Vaadin Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.eclipse.osbp.jpa.services.filters; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; + +import javax.persistence.criteria.From; +import javax.persistence.criteria.Path; + +import org.eclipse.osbp.runtime.common.filter.ILFilter; + +/** + * Helper class that implements the filtering methods defined in + * {@link LAdvancedFilterable} and can be either extended or used as a delegate. + * + * @author Petter Holmström (Vaadin Ltd) + * @since 1.0 + */ +public class LAdvancedFilterableSupport implements LAdvancedFilterable, + Serializable { + + private static final long serialVersionUID = 398382431841547719L; + + /** + * ApplyFiltersListener interface to be implemented by classes that want to + * be notified when the filters are applied. + * + * @author Petter Holmström (Vaadin Ltd) + * @since 1.0 + */ + public static interface ApplyFiltersListener extends Serializable { + + /** + * Called when the filters have been applied. + * + * @param sender + * the sender of the event. + */ + public void filtersApplied(LAdvancedFilterableSupport sender); + } + + /** + * Adds <code>listener</code> to the list of listeners to be notified when + * the filters are applied. The listener will be notified as many times as + * it has been added. + * + * @param listener + * the listener to add (must not be null). + */ + public void addListener(ApplyFiltersListener listener) { + assert listener != null : "listener must not be null"; + listeners.add(listener); + } + + /** + * Removes <code>listener</code> from the list of listeners. If the listener + * has been added more than once, it will be notified one less time. If the + * listener has not been added at all, nothing happens. + * + * @param listener + * the listener to remove (must not be null). + */ + public void removeListener(ApplyFiltersListener listener) { + assert listener != null : "listener must not be null"; + listeners.remove(listener); + } + + @SuppressWarnings("unchecked") + protected void fireListeners() { + LinkedList<ApplyFiltersListener> listenerList = (LinkedList<ApplyFiltersListener>) listeners + .clone(); + for (ApplyFiltersListener l : listenerList) { + l.filtersApplied(this); + } + } + + private Collection<Object> filterablePropertyIds; + + private LinkedList<ApplyFiltersListener> listeners = new LinkedList<ApplyFiltersListener>(); + + private LinkedList<ILFilter> appliedFilters = new LinkedList<ILFilter>(); + + private LinkedList<ILFilter> filters = new LinkedList<ILFilter>(); + + private boolean applyFiltersImmediately = true; + + private boolean unappliedFilters = false; + + /** + * @see LAdvancedFilterable#getFilterablePropertyIds() + */ + public Collection<Object> getFilterablePropertyIds() { + if (filterablePropertyIds == null) { + return Collections.emptyList(); + } else { + return Collections.unmodifiableCollection(filterablePropertyIds); + } + } + + /** + * Sets the filterable property IDs. + * + * @param propertyIds + * the property IDs to set (must not be null). + */ + @SuppressWarnings("unchecked") + public void setFilterablePropertyIds(Collection<?> propertyIds) { + assert propertyIds != null : "propertyIds must not be null"; + filterablePropertyIds = (Collection<Object>) propertyIds; + } + + /** + * Sets the filterable property IDs. + * + * @param propertyIds + * the property IDs to set (must not be null). + */ + public void setFilterablePropertyIds(Object... propertyIds) { + assert propertyIds != null : "propertyIds must not be null"; + setFilterablePropertyIds(Arrays.asList(propertyIds)); + } + + /** + * @see LAdvancedFilterable#isFilterable(java.lang.Object) + */ + public boolean isFilterable(Object propertyId) { + return getFilterablePropertyIds().contains(propertyId); + } + + /** + * Checks if <code>filter</code> is a valid filter, i.e. that all the + * properties that the filter restricts are filterable. + * + * @param filter + * the filter to check (must not be null). + * @return true if the filter is valid, false if it is not. + */ + public boolean isValidFilter(ILFilter filter) { + assert filter != null : "filter must not be null"; + if (filter instanceof LBetween) { + return isFilterable(((LBetween) filter).getPropertyId()); + } else if (filter instanceof LCompare) { + return isFilterable(((LCompare) filter).getPropertyId()); + } else if (filter instanceof LIsNull) { + return isFilterable(((LIsNull) filter).getPropertyId()); + } else if (filter instanceof LLike) { + return isFilterable(((LLike) filter).getPropertyId()); + } else if (filter instanceof LSimpleStringFilter) { + return isFilterable(((LSimpleStringFilter) filter).getPropertyId()); + } else if (filter instanceof LAbstractJunctionFilter) { + for (ILFilter f : ((LAbstractJunctionFilter) filter).getFilters()) { + if (!isValidFilter(f)) { + return false; + } + } + } + return true; + } + + /** + * @see LAdvancedFilterable#getFilters() + */ + public List<ILFilter> getFilters() { + return Collections.unmodifiableList(filters); + } + + /** + * @see LAdvancedFilterable#getAppliedFilters() + */ + public List<ILFilter> getAppliedFilters() { + return isApplyFiltersImmediately() ? getFilters() : Collections + .unmodifiableList(appliedFilters); + } + + /** + * @see LAdvancedFilterable#setApplyFiltersImmediately(boolean) + */ + public void setApplyFiltersImmediately(boolean applyFiltersImmediately) { + this.applyFiltersImmediately = applyFiltersImmediately; + } + + /** + * @see LAdvancedFilterable#isApplyFiltersImmediately() + */ + public boolean isApplyFiltersImmediately() { + return applyFiltersImmediately; + } + + /** + * @see LAdvancedFilterable#applyFilters() + */ + public void applyFilters() { + unappliedFilters = false; + appliedFilters.clear(); + appliedFilters.addAll(filters); + fireListeners(); + } + + /** + * @see LAdvancedFilterable#hasUnappliedFilters() + */ + public boolean hasUnappliedFilters() { + return unappliedFilters; + } + + @SuppressWarnings("unchecked") + public static Path<String> getPropertyPath(From<?, ?> root, + Object propertyId) { + return (Path<String>) getPropertyPathTyped(root, propertyId); + } + + public static <X, Y> Path<X> getPropertyPathTyped(From<X, Y> root, + Object propertyId) { + String pid = propertyId.toString(); + String[] idStrings = pid.split("\\."); + Path<X> path = root.get(idStrings[0]); + for (int i = 1; i < idStrings.length; i++) { + path = path.get(idStrings[i]); + } + return path; + } + + /** + * @param filter + */ + public void addFilter(ILFilter filter) { + filters.add(filter); + unappliedFilters = true; + if (isApplyFiltersImmediately()) { + applyFilters(); + } + } + + /** + * @param filter + */ + public void removeFilter(ILFilter filter) { + filters.remove(filter); + unappliedFilters = true; + if (isApplyFiltersImmediately()) { + applyFilters(); + } + } + + public void removeAllFilters() { + filters.clear(); + unappliedFilters = true; + if (isApplyFiltersImmediately()) { + applyFilters(); + } + } +} diff --git a/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LAnd.java b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LAnd.java new file mode 100644 index 0000000..4389506 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LAnd.java @@ -0,0 +1,34 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + * + * Contributor: + * Florian Pirchner - Copied filter and fixed them for osbp usecase. + */ +package org.eclipse.osbp.jpa.services.filters; + +import org.eclipse.osbp.runtime.common.filter.ILFilter; + +public class LAnd extends LAbstractJunctionFilter { + + /** + * + * @param filters + * filters of which the And filter will be composed + */ + public LAnd(ILFilter... filters) { + super(filters); + } + +} diff --git a/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LBetween.java b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LBetween.java new file mode 100644 index 0000000..6a28ecd --- /dev/null +++ b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LBetween.java @@ -0,0 +1,80 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + * + * Contributor: + * Florian Pirchner - Copied filter and fixed them for osbp usecase. + */ +package org.eclipse.osbp.jpa.services.filters; + +import org.eclipse.osbp.runtime.common.filter.ILFilter; + +public class LBetween implements ILFilter { + + private final Object propertyId; + private final Comparable<?> startValue; + private final Comparable<?> endValue; + + public LBetween(Object propertyId, Comparable<?> startValue, Comparable<?> endValue) { + this.propertyId = propertyId; + this.startValue = startValue; + this.endValue = endValue; + } + + public Object getPropertyId() { + return propertyId; + } + + public Comparable<?> getStartValue() { + return startValue; + } + + public Comparable<?> getEndValue() { + return endValue; + } + + @Override + public boolean appliesToProperty(Object propertyId) { + return getPropertyId() != null && getPropertyId().equals(propertyId); + } + + @Override + public int hashCode() { + return getPropertyId().hashCode() + getStartValue().hashCode() + + getEndValue().hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + + // Only objects of the same class can be equal + if (!getClass().equals(obj.getClass())) { + return false; + } + final LBetween o = (LBetween) obj; + + // Checks the properties one by one + boolean propertyIdEqual = (null != getPropertyId()) ? getPropertyId() + .equals(o.getPropertyId()) : null == o.getPropertyId(); + boolean startValueEqual = (null != getStartValue()) ? getStartValue() + .equals(o.getStartValue()) : null == o.getStartValue(); + boolean endValueEqual = (null != getEndValue()) ? getEndValue().equals( + o.getEndValue()) : null == o.getEndValue(); + return propertyIdEqual && startValueEqual && endValueEqual; + + } +} diff --git a/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LCompare.java b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LCompare.java new file mode 100644 index 0000000..b9d7361 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LCompare.java @@ -0,0 +1,292 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + * + * Contributor: + * Florian Pirchner - Copied filter and fixed them for osbp usecase. + */ +package org.eclipse.osbp.jpa.services.filters; + +import org.eclipse.osbp.runtime.common.filter.ILFilter; + +public class LCompare implements ILFilter { + + public enum Operation { + EQUAL, GREATER, LESS, GREATER_OR_EQUAL, LESS_OR_EQUAL + } + + private final Object propertyId; + private final Operation operation; + private final Object value; + + /** + * A {@link LCompare} filter that accepts items for which the identified + * property value is equal to <code>value</code>. + * + * For in-memory filters, {@link Comparable#compareTo(Object)} or, if not + * Comparable, {@link #equals(Object)} is used for the comparison. For other + * containers, the comparison implementation is container dependent and may + * use e.g. database comparison operations. + * + * @since 6.6 + */ + public static final class Equal extends LCompare { + /** + * Construct a filter that accepts items for which the identified + * property value is equal to <code>value</code>. + * + * For in-memory filters, equals() is used for the comparison. For other + * containers, the comparison implementation is container dependent and + * may use e.g. database comparison operations. + * + * @param propertyId + * the identifier of the property whose value to compare + * against value, not null + * @param value + * the value to compare against - null values may or may not + * be supported depending on the container + */ + public Equal(Object propertyId, Object value) { + super(propertyId, value, Operation.EQUAL); + } + } + + /** + * A {@link LCompare} filter that accepts items for which the identified + * property value is greater than <code>value</code>. + * + * For in-memory filters, the values must implement {@link Comparable} and + * {@link Comparable#compareTo(Object)} is used for the comparison. For + * other containers, the comparison implementation is container dependent + * and may use e.g. database comparison operations. + * + * @since 6.6 + */ + public static final class Greater extends LCompare { + /** + * Construct a filter that accepts items for which the identified + * property value is greater than <code>value</code>. + * + * For in-memory filters, the values must implement {@link Comparable} + * and {@link Comparable#compareTo(Object)} is used for the comparison. + * For other containers, the comparison implementation is container + * dependent and may use e.g. database comparison operations. + * + * @param propertyId + * the identifier of the property whose value to compare + * against value, not null + * @param value + * the value to compare against - null values may or may not + * be supported depending on the container + */ + public Greater(Object propertyId, Object value) { + super(propertyId, value, Operation.GREATER); + } + } + + /** + * A {@link LCompare} filter that accepts items for which the identified + * property value is less than <code>value</code>. + * + * For in-memory filters, the values must implement {@link Comparable} and + * {@link Comparable#compareTo(Object)} is used for the comparison. For + * other containers, the comparison implementation is container dependent + * and may use e.g. database comparison operations. + * + * @since 6.6 + */ + public static final class Less extends LCompare { + /** + * Construct a filter that accepts items for which the identified + * property value is less than <code>value</code>. + * + * For in-memory filters, the values must implement {@link Comparable} + * and {@link Comparable#compareTo(Object)} is used for the comparison. + * For other containers, the comparison implementation is container + * dependent and may use e.g. database comparison operations. + * + * @param propertyId + * the identifier of the property whose value to compare + * against value, not null + * @param value + * the value to compare against - null values may or may not + * be supported depending on the container + */ + public Less(Object propertyId, Object value) { + super(propertyId, value, Operation.LESS); + } + } + + /** + * A {@link LCompare} filter that accepts items for which the identified + * property value is greater than or equal to <code>value</code>. + * + * For in-memory filters, the values must implement {@link Comparable} and + * {@link Comparable#compareTo(Object)} is used for the comparison. For + * other containers, the comparison implementation is container dependent + * and may use e.g. database comparison operations. + * + * @since 6.6 + */ + public static final class GreaterOrEqual extends LCompare { + /** + * Construct a filter that accepts items for which the identified + * property value is greater than or equal to <code>value</code>. + * + * For in-memory filters, the values must implement {@link Comparable} + * and {@link Comparable#compareTo(Object)} is used for the comparison. + * For other containers, the comparison implementation is container + * dependent and may use e.g. database comparison operations. + * + * @param propertyId + * the identifier of the property whose value to compare + * against value, not null + * @param value + * the value to compare against - null values may or may not + * be supported depending on the container + */ + public GreaterOrEqual(Object propertyId, Object value) { + super(propertyId, value, Operation.GREATER_OR_EQUAL); + } + } + + /** + * A {@link LCompare} filter that accepts items for which the identified + * property value is less than or equal to <code>value</code>. + * + * For in-memory filters, the values must implement {@link Comparable} and + * {@link Comparable#compareTo(Object)} is used for the comparison. For + * other containers, the comparison implementation is container dependent + * and may use e.g. database comparison operations. + * + * @since 6.6 + */ + public static final class LessOrEqual extends LCompare { + /** + * Construct a filter that accepts items for which the identified + * property value is less than or equal to <code>value</code>. + * + * For in-memory filters, the values must implement {@link Comparable} + * and {@link Comparable#compareTo(Object)} is used for the comparison. + * For other containers, the comparison implementation is container + * dependent and may use e.g. database comparison operations. + * + * @param propertyId + * the identifier of the property whose value to compare + * against value, not null + * @param value + * the value to compare against - null values may or may not + * be supported depending on the container + */ + public LessOrEqual(Object propertyId, Object value) { + super(propertyId, value, Operation.LESS_OR_EQUAL); + } + } + + /** + * Constructor for a {@link LCompare} filter that compares the value of an + * item property with the given constant <code>value</code>. + * + * This constructor is intended to be used by the nested static classes only + * ({@link Equal}, {@link Greater}, {@link Less}, {@link GreaterOrEqual}, + * {@link LessOrEqual}). + * + * For in-memory filtering, comparisons except EQUAL require that the values + * implement {@link Comparable} and {@link Comparable#compareTo(Object)} is + * used for the comparison. The equality comparison is performed using + * {@link Object#equals(Object)}. + * + * For other containers, the comparison implementation is container + * dependent and may use e.g. database comparison operations. Therefore, the + * behavior of comparisons might differ in some cases between in-memory and + * other containers. + * + * @param propertyId + * the identifier of the property whose value to compare against + * value, not null + * @param value + * the value to compare against - null values may or may not be + * supported depending on the container + * @param operation + * the comparison {@link Operation} to use + */ + LCompare(Object propertyId, Object value, Operation operation) { + this.propertyId = propertyId; + this.value = value; + this.operation = operation; + } + + @Override + public boolean appliesToProperty(Object propertyId) { + return getPropertyId().equals(propertyId); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + + // Only objects of the same class can be equal + if (!getClass().equals(obj.getClass())) { + return false; + } + final LCompare o = (LCompare) obj; + + // Checks the properties one by one + if (getPropertyId() != o.getPropertyId() && null != o.getPropertyId() + && !o.getPropertyId().equals(getPropertyId())) { + return false; + } + if (getOperation() != o.getOperation()) { + return false; + } + return (null == getValue()) ? null == o.getValue() : getValue().equals( + o.getValue()); + } + + @Override + public int hashCode() { + return (null != getPropertyId() ? getPropertyId().hashCode() : 0) + ^ (null != getValue() ? getValue().hashCode() : 0); + } + + /** + * Returns the property id of the property to compare against the fixed + * value. + * + * @return property id (not null) + */ + public Object getPropertyId() { + return propertyId; + } + + /** + * Returns the comparison operation. + * + * @return {@link Operation} + */ + public Operation getOperation() { + return operation; + } + + /** + * Returns the value to compare the property against. + * + * @return comparison reference value + */ + public Object getValue() { + return value; + } +} diff --git a/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LFilterService.java b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LFilterService.java new file mode 100644 index 0000000..2584e67 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LFilterService.java @@ -0,0 +1,28 @@ +package org.eclipse.osbp.jpa.services.filters; + +import org.eclipse.osbp.jpa.services.Query; +import org.eclipse.osbp.jpa.services.filters.LCompare.Equal; +import org.eclipse.osbp.runtime.common.filter.ILFilter; +import org.eclipse.osbp.runtime.common.filter.ILFilterService; +import org.eclipse.osbp.runtime.common.filter.IQuery; +import org.osgi.service.component.annotations.Component; + +@Component +public class LFilterService implements ILFilterService { + + @Override + public ILFilter createUniqueEntryFilter(Object value, String valueProperty, Object id, String idProperty) { + // where {idProperty} <> {id} and {valueProperty} = {value} + + LNot idNotEqual = new LNot(new LCompare.Equal(idProperty, id)); + Equal valueEqual = new LCompare.Equal(valueProperty, value); + + return new LAnd(idNotEqual, valueEqual); + } + + @Override + public IQuery createQuery(ILFilter filter) { + return new Query(filter); + } + +} diff --git a/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LIn.java b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LIn.java new file mode 100644 index 0000000..c00884d --- /dev/null +++ b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LIn.java @@ -0,0 +1,80 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + * + * Contributor: + * Florian Pirchner - Copied filter and fixed them for osbp usecase. + */ +package org.eclipse.osbp.jpa.services.filters; + +import java.util.List; + +import org.eclipse.osbp.runtime.common.filter.ILFilter; + +public class LIn implements ILFilter { + + private final String propertyId; + private final List<Comparable<?>> values; + + public LIn(String propertyId, List<Comparable<?>> values) { + this.propertyId = propertyId; + this.values = values; + } + + public String getPropertyId() { + return propertyId; + } + + public List<Comparable<?>> getValues() { + return values; + } + + @Override + public boolean appliesToProperty(Object propertyId) { + return getPropertyId() != null && getPropertyId().equals(propertyId); + } + + @Override + public int hashCode() { + int valuesHashCode = 0; + for (Comparable<?> value : getValues()) { + valuesHashCode = valuesHashCode + value.hashCode(); + } + return getPropertyId().hashCode() + valuesHashCode; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + + // Only objects of the same class can be equal + if (!getClass().equals(obj.getClass())) { + return false; + } + final LIn o = (LIn) obj; + + // Checks the properties one by one + boolean propertyIdEqual = (null != getPropertyId()) ? getPropertyId() + .equals(o.getPropertyId()) : null == o.getPropertyId(); +// boolean startValueEqual = (null != getStartValue()) ? getStartValue() +// .equals(o.getStartValue()) : null == o.getStartValue(); +// boolean endValueEqual = (null != getEndValue()) ? getEndValue().equals( +// o.getEndValue()) : null == o.getEndValue(); +// return propertyIdEqual && startValueEqual && endValueEqual; + return propertyIdEqual; + + } +} diff --git a/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LIsNull.java b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LIsNull.java new file mode 100644 index 0000000..57b3437 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LIsNull.java @@ -0,0 +1,79 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + * + * Contributor: + * Florian Pirchner - Copied filter and fixed them for osbp usecase. + */ +package org.eclipse.osbp.jpa.services.filters; + +import org.eclipse.osbp.runtime.common.filter.ILFilter; + +public class LIsNull implements ILFilter { + + private final Object propertyId; + + /** + * Constructor for a filter that compares the value of an item property with + * null. + * + * For in-memory filtering, a simple == check is performed. For other + * containers, the comparison implementation is container dependent but + * should correspond to the in-memory null check. + * + * @param propertyId + * the identifier (not null) of the property whose value to check + */ + public LIsNull(Object propertyId) { + this.propertyId = propertyId; + } + + @Override + public boolean appliesToProperty(Object propertyId) { + return getPropertyId().equals(propertyId); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + + // Only objects of the same class can be equal + if (!getClass().equals(obj.getClass())) { + return false; + } + final LIsNull o = (LIsNull) obj; + + // Checks the properties one by one + return (null != getPropertyId()) ? getPropertyId().equals( + o.getPropertyId()) : null == o.getPropertyId(); + } + + @Override + public int hashCode() { + return (null != getPropertyId() ? getPropertyId().hashCode() : 0); + } + + /** + * Returns the property id of the property tested by the filter, not null + * for valid filters. + * + * @return property id (not null) + */ + public Object getPropertyId() { + return propertyId; + } + +} diff --git a/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LJoinFilter.java b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LJoinFilter.java new file mode 100644 index 0000000..a601ccd --- /dev/null +++ b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LJoinFilter.java @@ -0,0 +1,52 @@ +/** + * Copyright 2009-2013 Oy Vaadin Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.eclipse.osbp.jpa.services.filters; + +import org.eclipse.osbp.runtime.common.filter.ILFilter; + +/** + * This filter allows you to implement filtering on joined tables using + * Hibernate, which lacks support for automatic joins. EclipseLink supports + * automatic joins, which allows you to filter by e.g. + * <code>new Equal("skills.skill", s)</code>, while Hibernate requires you to do + * the same using this filter e.g. + * <code>new JoinFilter("skills", new Equal("skill", s))</code> + */ +public class LJoinFilter extends LAbstractJunctionFilter { + + private final String joinProperty; + + /** + * Constructs a HibernateJoin filter. + * + * @param joinProperty + * the property that should be joined + * @param filters + * a set of filters filtering on the joined property. By default + * all filters much pass for the item to be matched. + */ + public LJoinFilter(String joinProperty, ILFilter... filters) { + super(filters); + this.joinProperty = joinProperty; + } + + /** + * @return the property that is joined on + */ + public String getJoinProperty() { + return joinProperty; + } +} diff --git a/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LLike.java b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LLike.java new file mode 100644 index 0000000..316b22f --- /dev/null +++ b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LLike.java @@ -0,0 +1,83 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + * + * Contributor: + * Florian Pirchner - Copied filter and fixed them for osbp usecase. + */ +package org.eclipse.osbp.jpa.services.filters; + +import org.eclipse.osbp.runtime.common.filter.ILFilter; + +public class LLike implements ILFilter { + private final Object propertyId; + private final String value; + private boolean caseSensitive; + + public LLike(Object propertyId, String value) { + this(propertyId, value, true); + } + + public LLike(Object propertyId, String value, boolean caseSensitive) { + this.propertyId = propertyId; + this.value = value; + setCaseSensitive(caseSensitive); + } + + public Object getPropertyId() { + return propertyId; + } + + public String getValue() { + return value; + } + + public void setCaseSensitive(boolean caseSensitive) { + this.caseSensitive = caseSensitive; + } + + public boolean isCaseSensitive() { + return caseSensitive; + } + + @Override + public boolean appliesToProperty(Object propertyId) { + return getPropertyId() != null && getPropertyId().equals(propertyId); + } + + @Override + public int hashCode() { + return getPropertyId().hashCode() + getValue().hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + + // Only objects of the same class can be equal + if (!getClass().equals(obj.getClass())) { + return false; + } + final LLike o = (LLike) obj; + + // Checks the properties one by one + boolean propertyIdEqual = (null != getPropertyId()) ? getPropertyId() + .equals(o.getPropertyId()) : null == o.getPropertyId(); + boolean valueEqual = (null != getValue()) ? getValue().equals( + o.getValue()) : null == o.getValue(); + return propertyIdEqual && valueEqual; + } +} diff --git a/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LNot.java b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LNot.java new file mode 100644 index 0000000..3827618 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LNot.java @@ -0,0 +1,70 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + * + * Contributor: + * Florian Pirchner - Copied filter and fixed them for osbp usecase. + */ +package org.eclipse.osbp.jpa.services.filters; + +import org.eclipse.osbp.runtime.common.filter.ILFilter; + +public class LNot implements ILFilter { + private final ILFilter filter; + + /** + * Constructs a filter that negates a filter. + * + * @param filter + * {@link ILFilter} to negate, not-null + */ + public LNot(ILFilter filter) { + this.filter = filter; + } + + /** + * Returns the negated filter. + * + * @return IFilter + */ + public ILFilter getFilter() { + return filter; + } + + /** + * Returns true if a change in the named property may affect the filtering + * result. Return value is the same as {@link #appliesToProperty(Object)} + * for the negated filter. + * + * @return boolean + */ + @Override + public boolean appliesToProperty(Object propertyId) { + return filter.appliesToProperty(propertyId); + } + + @Override + public boolean equals(Object obj) { + if (obj == null || !getClass().equals(obj.getClass())) { + return false; + } + return filter.equals(((LNot) obj).getFilter()); + } + + @Override + public int hashCode() { + return filter.hashCode(); + } + +} diff --git a/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LOr.java b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LOr.java new file mode 100644 index 0000000..65f0071 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LOr.java @@ -0,0 +1,53 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + * + * Contributor: + * Florian Pirchner - Copied filter and fixed them for osbp usecase. + */ +package org.eclipse.osbp.jpa.services.filters; + +import org.eclipse.osbp.runtime.common.filter.ILFilter; + +public class LOr extends LAbstractJunctionFilter { + + /** + * + * @param filters + * filters of which the Or filter will be composed + */ + public LOr(ILFilter... filters) { + super(filters); + } + + /** + * Returns true if a change in the named property may affect the filtering + * result. If some of the sub-filters are not in-memory filters, true is + * returned. + * + * By default, all sub-filters are iterated to check if any of them applies. + * If there are no sub-filters, true is returned as an empty Or rejects all + * items. + */ + @Override + public boolean appliesToProperty(Object propertyId) { + if (getFilters().isEmpty()) { + // empty Or filters out everything + return true; + } else { + return super.appliesToProperty(propertyId); + } + } + +} diff --git a/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LSimpleStringFilter.java b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LSimpleStringFilter.java new file mode 100644 index 0000000..77622a2 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/filters/LSimpleStringFilter.java @@ -0,0 +1,128 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + * + * Contributor: + * Florian Pirchner - Copied filter and fixed them for osbp usecase. + */ +package org.eclipse.osbp.jpa.services.filters; + +import org.eclipse.osbp.runtime.common.filter.ILFilter; + +public class LSimpleStringFilter implements ILFilter { + + final Object propertyId; + final String filterString; + final boolean ignoreCase; + final boolean onlyMatchPrefix; + + public LSimpleStringFilter(Object propertyId, String filterString, + boolean ignoreCase, boolean onlyMatchPrefix) { + this.propertyId = propertyId; + this.filterString = ignoreCase ? filterString.toLowerCase() + : filterString; + this.ignoreCase = ignoreCase; + this.onlyMatchPrefix = onlyMatchPrefix; + } + + @Override + public boolean appliesToProperty(Object propertyId) { + return this.propertyId.equals(propertyId); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + + // Only ones of the objects of the same class can be equal + if (!(obj instanceof LSimpleStringFilter)) { + return false; + } + final LSimpleStringFilter o = (LSimpleStringFilter) obj; + + // Checks the properties one by one + if (propertyId != o.propertyId && o.propertyId != null + && !o.propertyId.equals(propertyId)) { + return false; + } + if (filterString != o.filterString && o.filterString != null + && !o.filterString.equals(filterString)) { + return false; + } + if (ignoreCase != o.ignoreCase) { + return false; + } + if (onlyMatchPrefix != o.onlyMatchPrefix) { + return false; + } + + return true; + } + + @Override + public int hashCode() { + return (propertyId != null ? propertyId.hashCode() : 0) + ^ (filterString != null ? filterString.hashCode() : 0); + } + + /** + * Returns the property identifier to which this filter applies. + * + * @return property id + */ + public Object getPropertyId() { + return propertyId; + } + + /** + * Returns the filter string. + * + * Note: this method is intended only for implementations of lazy string + * filters and may change in the future. + * + * @return filter string given to the constructor + */ + public String getFilterString() { + return filterString; + } + + /** + * Returns whether the filter is case-insensitive or case-sensitive. + * + * Note: this method is intended only for implementations of lazy string + * filters and may change in the future. + * + * @return true if performing case-insensitive filtering, false for + * case-sensitive + */ + public boolean isIgnoreCase() { + return ignoreCase; + } + + /** + * Returns true if the filter only applies to the beginning of the value + * string, false for any location in the value. + * + * Note: this method is intended only for implementations of lazy string + * filters and may change in the future. + * + * @return true if checking for matches at the beginning of the value only, + * false if matching any part of value + */ + public boolean isOnlyMatchPrefix() { + return onlyMatchPrefix; + } +} diff --git a/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/ClassMetadata.java b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/ClassMetadata.java new file mode 100644 index 0000000..4418e08 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/ClassMetadata.java @@ -0,0 +1,488 @@ +/** + * Copyright 2009-2013 Oy Vaadin Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.eclipse.osbp.jpa.services.metadata; + +import java.io.Serializable; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.StringTokenizer; + +/** + * This class provides a way of accessing the JPA mapping metadata of + * <code>Entity</code> and <code>Embeddable</code> classes. This information may be used + * to construct queries or decide whether a property is sortable or not. + * + * see EntityClassMetadata + * @author Petter Holmström (Vaadin Ltd) + * @since 1.0 + */ +public class ClassMetadata<T> implements Serializable { + + private static final long serialVersionUID = 2569781449737488799L; + private final Class<T> mappedClass; + private final Map<String, PropertyMetadata> allProperties = new LinkedHashMap<String, PropertyMetadata>(); + private final Map<String, PersistentPropertyMetadata> persistentProperties = new LinkedHashMap<String, PersistentPropertyMetadata>(); + + /** + * Constructs a new <code>ClassMetadata</code> instance. Properties can be + * added using the + * {@link #addProperties(org.eclipse.osbp.jpa.services.metadata.vaadin.addons.jpacontainer.metadata.PropertyMetadata[]) } + * method. + * + * @param mappedClass + * the mapped class (must not be null). + */ + protected ClassMetadata(Class<T> mappedClass) { + assert mappedClass != null : "mappedClass must not be null"; + this.mappedClass = mappedClass; + } + + /** + * Adds the specified property metadata to the class. Any existing + * properties with the same names will be overwritten. + * + * @param properties + * an array of properties to add. + */ + final void addProperties(PropertyMetadata... properties) { + assert properties != null : "properties must not be null"; + for (PropertyMetadata pm : properties) { + allProperties.put(pm.getName(), pm); + if (pm instanceof PersistentPropertyMetadata) { + persistentProperties.put(pm.getName(), + (PersistentPropertyMetadata) pm); + } else { + // If we have a previous property and want to overwrite + // it with another that is not persistent + persistentProperties.remove(pm.getName()); + } + } + } + + /** + * Gets the mapped class. + * + * @return the class (never null). + */ + public Class<T> getMappedClass() { + return mappedClass; + } + + /** + * Gets all the persistent properties of the class. + * + * @return an unmodifiable collection of property metadata. + */ + public Collection<PersistentPropertyMetadata> getPersistentProperties() { + return Collections + .unmodifiableCollection(persistentProperties.values()); + } + + /** + * Gets the names of all persistent properties of this class. + * + * @see #getPersistentProperties() + * @return an unmodifiable collection of property names. + */ + public Collection<String> getPersistentPropertyNames() { + return Collections + .unmodifiableCollection(persistentProperties.keySet()); + } + + /** + * Gets all the properties of the class. In addition to the persistent + * properties, all public JavaBean properties are also included (even those + * who do not have setter methods). + * + * @return an unmodifiable collection of property metadata. + */ + public Collection<PropertyMetadata> getProperties() { + return Collections.unmodifiableCollection(allProperties.values()); + } + + /** + * Gets the names of all the properties of this class. + * + * @see #getProperties() + * @return an unmodifiable collection of property names. + */ + public Collection<String> getPropertyNames() { + return Collections.unmodifiableCollection(allProperties.keySet()); + } + + /** + * Gets the metadata of the named property. + * + * @param propertyName + * the name of the property (must not be null). + * @return the property metadata, or null if not found. + */ + public PropertyMetadata getProperty(String propertyName) { + return allProperties.get(propertyName); + } + + /** + * Gets the value of <code>property</code> from <code>object</code>. + * + * @param object + * the object from which the property will be retrieved (must not + * be null). + * @param property + * the metadata of the property (must not be null). + * @return the property value. + * @throws IllegalArgumentException + * if the property could not be retrieved. + */ + protected Object getPropertyValue(T object, PropertyMetadata property) + throws IllegalArgumentException { // NOSONAR + assert object != null : "object must not be null"; + assert property != null : "property must not be null"; + try { + if (property instanceof PersistentPropertyMetadata) { + PersistentPropertyMetadata ppmd = (PersistentPropertyMetadata) property; + if (ppmd.field != null) { + return getPropertyValueFromField(object, ppmd); + } + } + return property.getter.invoke(object); + } catch (IllegalAccessException e) { + throw new IllegalArgumentException( + "Cannot access the property value", e); + } catch (InvocationTargetException e) { + throw new IllegalArgumentException( + "Cannot access the property value", e); + } + } + + private Object getPropertyValueFromField(T object, + PersistentPropertyMetadata ppmd) throws IllegalAccessException, + IllegalArgumentException, InvocationTargetException { // NOSONAR + // First we try to find a getter for the field in order to + // make getter-based lazy loading work. + Class<?> clazz = ppmd.field.getDeclaringClass(); + Method getter = null; + try { + getter = clazz.getMethod("get" + capitalize(ppmd.fieldName)); + } catch (Exception e) { // NOSONAR + try { + getter = clazz.getMethod("is" + capitalize(ppmd.fieldName)); + } catch (Exception e1) { // NOSONAR + } + } + if (getter == null) { + try { + ppmd.field.setAccessible(true); + return ppmd.field.get(object); + } finally { + ppmd.field.setAccessible(false); + } + } + return getter.invoke(object); + } + + private String capitalize(String string) { + return string.substring(0, 1).toUpperCase() + string.substring(1); + } + + /** + * Sets the value of <code>property</code> to <code>value</code> on + * <code>object</code>. + * + * @param object + * the object to which the property will be set (must not be + * null). + * @param property + * the metadata of the property (must not be null). + * @param value + * the property value. + * @throws IllegalArgumentException + * if the property could not be set. + */ + protected void setPropertyValue(T object, PropertyMetadata property, + Object value) throws IllegalArgumentException { // NOSONAR + assert object != null : "object must not be null"; + assert property != null : "property must not be null"; + if (property != null && property.isWritable()) { + try { + if (property.setter == null + && property instanceof PersistentPropertyMetadata) { + // use direct field access of PersistentPropertyMetadata iff + // the setter method does not exist + PersistentPropertyMetadata ppmd = (PersistentPropertyMetadata) property; + if (ppmd.field != null) { + try { + ppmd.field.setAccessible(true); + ppmd.field.set(object, value); + return; + } finally { + ppmd.field.setAccessible(false); + } + } + } + property.setter.invoke(object, value); + } catch (IllegalAccessException e) { + throw new IllegalArgumentException( + "Cannot set the property value", e); + } catch (InvocationTargetException e) { + throw new IllegalArgumentException( + "Cannot set the property value", e); + } + } else { + throw new IllegalArgumentException("No such writable property: " + + (property != null?property.getName():"(property == null)") ); + } + } + + /** + * Gets the getter method for <code>propertyName</code> from + * <code>parent</code>. + * + * @param propertyName + * the JavaBean property name (must not be null). + * @param parent + * the class from which to get the getter method (must not be + * null). + * @return the getter method, or null if not found. + */ + protected Method getGetterMethod(String propertyName, Class<?> parent) { + String methodName = "get" + propertyName.substring(0, 1).toUpperCase() + + propertyName.substring(1); + try { + Method m = parent.getMethod(methodName); + if (m.getReturnType() != Void.TYPE) { + return m; + } else { + return null; + } + } catch (NoSuchMethodException e) { // NOSONAR + return null; + } + } + + /** + * Gets the setter method for <code>propertyName</code> from + * <code>parent</code>. + * + * @param propertyName + * the JavaBean property name (must not be null). + * @param parent + * the class from which to get the setter method (must not be + * null). + * @param propertyType + * the type of the property (must not be null). + * @return the setter method, or null if not found. + */ + protected Method getSetterMethod(String propertyName, Class<?> parent, + Class<?> propertyType) { + String methodName = "set" + propertyName.substring(0, 1).toUpperCase() + + propertyName.substring(1); + try { + Method m = parent.getMethod(methodName, propertyType); + if (m.getReturnType() == Void.TYPE) { + return m; + } else { + return null; + } + } catch (NoSuchMethodException e) { // NOSONAR + return null; + } + } + + /** + * Gets the value of <code>object.propertyName</code>. The property name may + * be nested. + * + * @param object + * the entity object from which the property value should be + * fetched (must not be null). + * @param propertyName + * the name of the property (must not be null). + * @return the property value. + * @throws IllegalArgumentException + * if the property value could not be fetched, e.g. due to + * <code>propertyName</code> being invalid. + */ + @SuppressWarnings("unchecked") + public Object getPropertyValue(T object, String propertyName) + throws IllegalArgumentException { // NOSONAR + assert object != null : "object must not be null"; + assert propertyName != null : "propertyName must not be null"; + + StringTokenizer st = new StringTokenizer(propertyName, "."); + ClassMetadata<Object> typeMetadata = (ClassMetadata<Object>) this; + Class<?> type = null; + Object currentObject = object; + while (st.hasMoreTokens()) { + String propName = st.nextToken(); + if (typeMetadata != null) { + PropertyMetadata pmd = typeMetadata.getProperty(propName); + if (pmd == null) { + throw new IllegalArgumentException("Invalid property name"); + } + currentObject = typeMetadata.getPropertyValue(currentObject, + pmd); + if (currentObject == null) { + return null; + } + if (pmd instanceof PersistentPropertyMetadata) { + typeMetadata = (ClassMetadata<Object>) ((PersistentPropertyMetadata) pmd) + .getTypeMetadata(); + } else { + typeMetadata = null; + } + if (typeMetadata == null) { + type = pmd.getType(); + } else { + type = null; + } + } else if (type != null) { + Method getter = getGetterMethod(propName, type); + if (getter == null) { + throw new IllegalArgumentException("Invalid property name"); + } + try { + currentObject = getter.invoke(currentObject); + if (currentObject == null) { + return null; + } + type = getter.getReturnType(); + } catch (Exception e) { + throw new IllegalArgumentException( + "Could not access a nested property", e); + } + } + } + return currentObject; + } + + /** + * Sets the value of <code>object.propertyName</code> to <code>value</code>. + * The property name may be nested. + * + * @param object + * the object whose property should be set (must not be null). + * @param propertyName + * the name of the property to set (must not be null). + * @param value + * the value to set. + * @throws IllegalArgumentException + * if the value could not be set, e.g. due to + * <code>propertyName</code> being invalid or the property being + * read only. + * @throws IllegalStateException + * if a nested property name is used and one of the nested + * properties (other than the last one) is null. + */ + @SuppressWarnings("unchecked") + public void setPropertyValue(T object, String propertyName, Object value) + throws IllegalArgumentException, IllegalStateException { // NOSONAR + assert object != null : "object must not be null"; + assert propertyName != null : "propertyName must not be null"; + + StringTokenizer st = new StringTokenizer(propertyName, "."); + ClassMetadata<Object> typeMetadata = (ClassMetadata<Object>) this; + Class<?> type = null; + Object currentObject = object; + while (st.hasMoreTokens()) { + String propName = st.nextToken(); + if (typeMetadata != null) { + PropertyMetadata pmd = typeMetadata.getProperty(propName); + if (pmd == null) { + throw new IllegalArgumentException("Invalid property name"); + } + if (!st.hasMoreTokens()) { + // We have reached the end of the chain + typeMetadata.setPropertyValue(currentObject, pmd, value); + } else { + currentObject = typeMetadata.getPropertyValue( + currentObject, pmd); + if (currentObject == null) { + throw new IllegalStateException( + "A null value was found in the chain of nested properties"); + } + if (pmd instanceof PersistentPropertyMetadata) { + typeMetadata = (ClassMetadata<Object>) ((PersistentPropertyMetadata) pmd) + .getTypeMetadata(); + } else { + typeMetadata = null; + } + if (typeMetadata == null) { + type = pmd.getType(); + } else { + type = null; + } + } + } else if (type != null) { + Method getter = getGetterMethod(propName, type); + if (getter == null) { + throw new IllegalArgumentException("Invalid property name"); + } + if (!st.hasMoreTokens()) { + // We have reached the end of the chain + Method setter = getSetterMethod(propName, type, + getter.getReturnType()); + if (setter == null) { + throw new IllegalArgumentException( + "Property is read only"); + } + try { + setter.invoke(currentObject, value); + } catch (Exception e) { + throw new IllegalArgumentException( + "Could not set the value"); + } + } else { + try { + currentObject = getter.invoke(currentObject); + if (currentObject == null) { + throw new IllegalStateException( + "A null value was found in the chain of nested properties"); + } + type = getter.getReturnType(); + } catch (Exception e) { + throw new IllegalArgumentException( + "Could not access a nested property", e); + } + } + } + } + } + + @Override + public boolean equals(Object obj) { + if (obj != null && obj.getClass() == getClass()) { + ClassMetadata<?> other = (ClassMetadata<?>) obj; + return mappedClass.equals(other.mappedClass) + && allProperties.equals(other.allProperties) + && persistentProperties.equals(other.persistentProperties); + } + return false; + } + + @Override + public int hashCode() { + int hash = 7; + hash = hash * 31 + mappedClass.hashCode(); + hash = hash * 31 + allProperties.hashCode(); + hash = hash * 31 + persistentProperties.hashCode(); + return hash; + } +} diff --git a/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/CollectionUtil.java b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/CollectionUtil.java new file mode 100644 index 0000000..69e3067 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/CollectionUtil.java @@ -0,0 +1,37 @@ +/** + * Copyright 2009-2013 Oy Vaadin Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.eclipse.osbp.jpa.services.metadata; + +import java.lang.reflect.Array; +import java.util.Collection; + +public class CollectionUtil { + + /** + * Converts a typed {@link Collection} to a typed array. + * + * @param type + * the type class + * @param collection + * the collection to convert to an array. + * @return the array. + */ + @SuppressWarnings("unchecked") + public static <T> T[] toArray(Class<T> type, Collection<T> collection) { + return collection.toArray((T[]) Array.newInstance(type, + collection.size())); + } +} diff --git a/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/EntityClassMetadata.java b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/EntityClassMetadata.java new file mode 100644 index 0000000..50e95c8 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/EntityClassMetadata.java @@ -0,0 +1,171 @@ +/** + * Copyright 2009-2013 Oy Vaadin Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.eclipse.osbp.jpa.services.metadata; + + +/** + * An extended version of {@link ClassMetadata} that provides additional + * information about classes annotated with the <code>Entity</code> annotation. + * + * @author Petter Holmström (Vaadin Ltd) + * @since 1.0 + */ +public class EntityClassMetadata<T> extends ClassMetadata<T> { + + private static final long serialVersionUID = -4870942071257502328L; + private final String entityName; + private String versionProperty; + private String identifierProperty; + + /** + * Creates a new instance of <code>EntityClassMetadata</code>. + * + * @param mappedClass + * the entity class (must not be null). + * @param entityName + * the entity name (must not be null). + */ + EntityClassMetadata(Class<T> mappedClass, String entityName) { + super(mappedClass); + assert entityName != null : "entityName must not be null"; + this.entityName = entityName; + } + + /** + * Sets the name of the property that contains the version, if any. + * + * @param propertyName + * the property name, may be null. + */ + void setVersionPropertyName(String propertyName) { + if (propertyName != null) { + PropertyMetadata pm = getProperty(propertyName); + if (pm == null || !(pm instanceof PersistentPropertyMetadata)) { + throw new IllegalArgumentException("Invalid property"); + } + } + this.versionProperty = propertyName; + } + + /** + * Sets the name of the property that contains the identifier, if any. + * + * @param propertyName + * the property name, may be null. + * @throws IllegalArgumentException + * if <code>propertyName</code> is invalid (i.e. the property + * does not exist or is transient). + */ + void setIdentifierPropertyName(String propertyName) + throws IllegalArgumentException { + if (propertyName != null) { + PropertyMetadata pm = getProperty(propertyName); + if (pm == null || !(pm instanceof PersistentPropertyMetadata)) { + throw new IllegalArgumentException("Invalid property"); + } + } + this.identifierProperty = propertyName; + } + + /** + * The name of the entity. If no explicit entity name has been given, this + * is the simple class name. + */ + public String getEntityName() { + return entityName; + } + + /** + * If the entity has a version property or not. + * + * @see #getVersionProperty() + */ + public boolean hasVersionProperty() { + return versionProperty != null; + } + + /** + * Gets the version property, if it exists. + * + * @see #hasVersionProperty() + * @return the version property metadata, or null if not available. + */ + public PersistentPropertyMetadata getVersionProperty() { + return versionProperty == null ? null + : (PersistentPropertyMetadata) getProperty(versionProperty); + } + + /** + * If the entity has an identifier property or not. + * + * @see #getIdentifierProperty() + * @see #hasEmbeddedIdentifier() + */ + public boolean hasIdentifierProperty() { + return identifierProperty != null; + } + + /** + * Gets the identifier property, if it exists. If + * {@link #hasEmbeddedIdentifier() } returns true, this property is the + * embedded identifier. + * + * @see #hasIdentifierProperty() + * @see #hasEmbeddedIdentifier() + * @return the identifier property metadata, or null if not available. + */ + public PersistentPropertyMetadata getIdentifierProperty() { + return identifierProperty == null ? null + : (PersistentPropertyMetadata) getProperty(identifierProperty); + } + + /** + * If the entity has an embedded identifier. This property cannot be true + * unless {@link #hasIdentifierProperty() } also returns true. + */ + public boolean hasEmbeddedIdentifier() { + return hasIdentifierProperty() + && getIdentifierProperty().getPropertyKind() == PropertyKind.EMBEDDED; + } + + @Override + public boolean equals(Object obj) { + if (super.equals(obj)) { // Includes a check of the parameter class + EntityClassMetadata<?> other = (EntityClassMetadata<?>) obj; + return ( other == null ? false : entityName.equals(other.entityName) ) + && (versionProperty == null ? other.versionProperty == null + : versionProperty.equals(other.versionProperty)) + && (identifierProperty == null ? other.identifierProperty == null + : identifierProperty + .equals(other.identifierProperty)); + } + return false; + } + + @Override + public int hashCode() { + int hash = super.hashCode(); + hash = hash * 31 + entityName.hashCode(); + if (versionProperty != null) { + hash = hash * 31 + versionProperty.hashCode(); + } + if (identifierProperty != null) { + hash = hash * 31 + identifierProperty.hashCode(); + } + return hash; + } +} diff --git a/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/EntityDelegate.java b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/EntityDelegate.java new file mode 100644 index 0000000..5368d5f --- /dev/null +++ b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/EntityDelegate.java @@ -0,0 +1,1163 @@ +/** + * Copyright 2009-2013 Oy Vaadin Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.eclipse.osbp.jpa.services.metadata; + +import java.io.ObjectStreamException; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.persistence.EntityManager; +import javax.persistence.EntityNotFoundException; +import javax.persistence.Query; +import javax.persistence.TransactionRequiredException; +import javax.persistence.TypedQuery; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Join; +import javax.persistence.criteria.JoinType; +import javax.persistence.criteria.Order; +import javax.persistence.criteria.Path; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; + +import org.eclipse.osbp.jpa.services.filters.LAdvancedFilterableSupport; +import org.eclipse.osbp.jpa.services.filters.LAnd; +import org.eclipse.osbp.jpa.services.filters.LCompare.Equal; +import org.eclipse.osbp.jpa.services.filters.LCompare.Greater; +import org.eclipse.osbp.jpa.services.filters.LCompare.Less; +import org.eclipse.osbp.jpa.services.filters.LOr; +import org.eclipse.osbp.runtime.common.filter.IJPQL; +import org.eclipse.osbp.runtime.common.filter.ILFilter; +import org.eclipse.osbp.runtime.common.filter.IQuery; +import org.eclipse.osbp.runtime.common.filter.SortBy; + +/** + * A read-only entity provider that works with a local {@link EntityManager}. + * Most important features and limitations: + * <ul> + * <li>Does not do any internal caching, all information is always accessed + * directly from the EntityManager</li> + * <li>Explicitly detaches entities by default (see + * {@link #isEntitiesDetached() }) + * <ul> + * <li>Performs a serialize-deserialize cycle to clone entities in order to + * explicitly detach them from the persistence context (<b>This is + * ugly!</b>).</li> + * </ul> + * </li> + * <li>Uses lazy-loading of entities (when using detached entities, references + * and collections within the entities should be configured to be fetched + * eagerly, though)</li> + * </ul> + * + * This entity provider does not perform very well, as every method call results + * in at least one query being sent to the entity manager. If speed is desired, + * <code>CachingLocalEntityProvider</code> should be used instead. However, this + * entity provider consumes less memory than the caching provider. + * + * @author Petter Holmstr��m (Vaadin Ltd) + * @since 1.0 + */ +public class EntityDelegate<T> implements Serializable { + + private static final long serialVersionUID = 1601796410565144708L; + private transient EntityManager entityManager; + private EntityClassMetadata<T> entityClassMetadata; + private boolean entitiesDetached = true; + private Serializable serializableEntityManager; + private QueryModifierDelegate queryModifierDelegate; + private int maxResults; + + /** + * Creates a new <code>LocalEntityProvider</code>. + * + * @param entityClass + * the entity class (must not be null). + * @param entityManager + * the entity manager to use (must not be null). + */ + public EntityDelegate(Class<T> entityClass, EntityManager entityManager, int maxResults) { + this(entityClass); + this.maxResults = maxResults; + assert entityManager != null : "entityManager must not be null"; + setEntityManager(entityManager); + } + + /** + * Creates a new <code>LocalEntityProvider</code>. The entity manager or an + * entity manager provider must be set using + * {@link #setEntityManager(javax.persistence.EntityManager)} or + * <code>setEntityManagerProvider(com.vaadin.addon.jpacontainer.EntityManagerProvider)</Code> + * respectively. + * + * @param entityClass + * the entity class (must not be null). + */ + public EntityDelegate(Class<T> entityClass) { + assert entityClass != null : "entityClass must not be null"; + this.entityClassMetadata = MetadataFactory.getInstance().getEntityClassMetadata(entityClass); + } + + // TODO Test serialization of entity manager + protected Object writeReplace() throws ObjectStreamException { + if (entityManager != null && entityManager instanceof Serializable) { + serializableEntityManager = (Serializable) entityManager; + } + return this; + } + + protected Object readResolve() throws ObjectStreamException { + if (serializableEntityManager != null) { + this.entityManager = (EntityManager) serializableEntityManager; + } + return this; + } + + /** + * Sets the entity manager. + * + * @param entityManager + * the entity manager to set. + */ + public void setEntityManager(EntityManager entityManager) { + this.entityManager = entityManager; + } + + /** + * Gets the metadata for the entity class. + * + * @return the metadata (never null). + */ + public EntityClassMetadata<T> getEntityClassMetadata() { + return this.entityClassMetadata; + } + + /** + * Gets the entity manager. If no entity manager has been set, the one + * returned by the registered entity manager provider is returned. + * + * @return the entity manager. + */ + public EntityManager getEntityManager() { + return entityManager; + } + + /** + * Gets the entity manager. + * + * @return the entity manager (never null). + * @throws IllegalStateException + * if no entity manager is set. + */ + protected EntityManager doGetEntityManager() throws IllegalStateException { + if (getEntityManager() == null) { + throw new IllegalStateException("No entity manager specified"); + } + return getEntityManager(); + } + + /** + * Creates a copy of <code>original</code> and adds an entry for the primary + * key to the end of the list. + * + * @param original + * the original list of sorting instructions (must not be null, + * but may be empty). + * @return a new list with the added entry for the primary key. + */ + protected List<SortBy> addPrimaryKeyToSortList(List<SortBy> original) { + if (sortByListContainsPrimaryKey(original)) { + return original; + } + ArrayList<SortBy> newList = new ArrayList<SortBy>(); + newList.addAll(original); + if (getEntityClassMetadata().hasEmbeddedIdentifier()) { + for (String p : getEntityClassMetadata().getIdentifierProperty().getTypeMetadata() + .getPersistentPropertyNames()) { + newList.add(new SortBy(getEntityClassMetadata().getIdentifierProperty().getName() + "." + p, true)); + } + } else { + newList.add(new SortBy(getEntityClassMetadata().getIdentifierProperty().getName(), true)); + } + return Collections.unmodifiableList(newList); + } + + /** + * @param original + * @return + */ + private boolean sortByListContainsPrimaryKey(List<SortBy> original) { + for (SortBy sb : original) { + EntityClassMetadata<T> metadata = getEntityClassMetadata(); + if (metadata.hasEmbeddedIdentifier()) { + if (sb.getPropertyId().equals(metadata.getIdentifierProperty().getTypeMetadata() + .getPersistentPropertyNames().iterator().next())) { + return true; + } + } else { + if (sb.getPropertyId().equals(metadata.getIdentifierProperty().getName())) { + return true; + } + } + } + return false; + } + + /** + * Translates SortBy instances, which possibly contain nested properties + * (e.g. name.firstName, name.lastName) into Order instances which can be + * used in a CriteriaQuery. + * + * @param sortBy + * the SortBy instance to translate + * @param swapSortOrder + * swaps the specified sort order if true. + * @param cb + * the {@link CriteriaBuilder} to use + * @param root + * the {@link CriteriaQuery} {@link Root} to be used. + * @return + */ + protected Order translateSortBy(SortBy sortBy, boolean swapSortOrder, CriteriaBuilder cb, Root<T> root) { + String sortedPropId = sortBy.getPropertyId().toString(); + // First split the id and build a Path. + String[] idStrings = sortedPropId.split("\\."); + Path<T> path = null; + if (idStrings.length > 1 && !isEmbedded(idStrings[0])) { + // This is a nested property, we need to LEFT JOIN + path = root.join(idStrings[0], JoinType.LEFT); + for (int i = 1; i < idStrings.length; i++) { + if (i < idStrings.length - 1) { + path = ((Join<?, ?>) path).join(idStrings[i], JoinType.LEFT); + } else { + path = path.get(idStrings[i]); + } + } + } else { + // non-nested or embedded, we can select as usual + path = LAdvancedFilterableSupport.getPropertyPathTyped(root, sortedPropId); + } + + // Make and return the Order instances. + if (sortBy.isAscending() != swapSortOrder) { + return cb.asc(path); + } else { + return cb.desc(path); + } + } + + /** + * @param propertyId + * @return + */ + private boolean isEmbedded(String propertyId) { + return entityClassMetadata.getProperty(propertyId).getPropertyKind() == PropertyKind.EMBEDDED; + } + + /** + * Creates a filtered query that does not do any sorting. + * + * see createFilteredQuery(com.vaadin.addon.jpacontainer.EntityContainer, + * java.util.List, + * org.eclipse.osbp.dsl.dto.lib.services.filters.ILFilter.data.Container.IFilter, + * java.util.List, boolean) + * + * @param fieldsToSelect + * the fields to select (must not be null). + * @param filter + * the filter to apply, or null if no filters should be applied. + * @return the query (never null). + */ + protected TypedQuery<Object> createUnsortedFilteredQuery(List<String> fieldsToSelect, ILFilter filter) { + return createFilteredPropertyQuery(fieldsToSelect, filter, null, false); + } + + /** + * Creates a filtered, optionally sorted, query. + * + * @param fieldsToSelect + * the fields to select (must not be null). + * @param filter + * the filter to apply, or null if no filters should be applied. + * @param sortBy + * the fields to sort by (must include at least one field), or + * null if the result should not be sorted at all. + * @param swapSortOrder + * true to swap the sort order, false to use the sort order + * specified in <code>sortBy</code>. Only applies if + * <code>sortBy</code> is not null. + * @return the query (never null). + */ + protected TypedQuery<Object> createFilteredPropertyQuery(List<String> fieldsToSelect, ILFilter filter, + List<SortBy> sortBy, boolean swapSortOrder) { + assert fieldsToSelect != null : "fieldsToSelect must not be null"; + assert sortBy == null || !sortBy.isEmpty() : "sortBy must be either null or non-empty"; + + CriteriaBuilder cb = doGetEntityManager().getCriteriaBuilder(); + CriteriaQuery<Object> query = cb.createQuery(); + Root<T> root = query.from(entityClassMetadata.getMappedClass()); + + tellDelegateQueryWillBeBuilt(cb, query); + + List<Predicate> predicates = new ArrayList<Predicate>(); + if (filter != null) { + predicates.add(FilterConverter.convertFilter(filter, cb, root)); + } + tellDelegateFiltersWillBeAdded(cb, query, predicates); + if (!predicates.isEmpty()) { + query.where(CollectionUtil.toArray(Predicate.class, predicates)); + } + tellDelegateFiltersWereAdded(cb, query); + + List<Order> orderBy = new ArrayList<Order>(); + if (sortBy != null && sortBy.size() > 0) { + for (SortBy sortedProperty : sortBy) { + orderBy.add(translateSortBy(sortedProperty, swapSortOrder, cb, root)); + } + } + tellDelegateOrderByWillBeAdded(cb, query, orderBy); + query.orderBy(orderBy); + tellDelegateOrderByWereAdded(cb, query); + + if (fieldsToSelect.size() > 1 || getEntityClassMetadata().hasEmbeddedIdentifier()) { + List<Path<?>> paths = new ArrayList<Path<?>>(); + for (String fieldPath : fieldsToSelect) { + paths.add(LAdvancedFilterableSupport.getPropertyPathTyped(root, fieldPath)); + } + query.multiselect(paths.toArray(new Path<?>[paths.size()])); + } else { + query.select(LAdvancedFilterableSupport.getPropertyPathTyped(root, fieldsToSelect.get(0))); + } + tellDelegateQueryHasBeenBuilt(cb, query); + return doGetEntityManager().createQuery(query); + } + + // /** + // * Creates a filtered, optionally sorted, query. + // * + // * @param filter + // * the filter to apply, or null if no filters should be applied. + // * @param sortBy + // * the fields to sort by (must include at least one field), or + // * null if the result should not be sorted at all. + // * @param swapSortOrder + // * true to swap the sort order, false to use the sort order + // * specified in <code>sortBy</code>. Only applies if + // * <code>sortBy</code> is not null. + // * @return the query (never null). + // */ + // protected TypedQuery<Long> createFilteredCountQuery(ILFilter filter, + // List<SortBy> sortBy, boolean swapSortOrder) { + // assert sortBy == null || !sortBy.isEmpty() : + // "sortBy must be either null or non-empty"; + // + // CriteriaBuilder cb = doGetEntityManager().getCriteriaBuilder(); + // CriteriaQuery<Long> query = cb.createQuery(Long.class); + // Root<T> root = query.from(entityClassMetadata.getMappedClass()); + // + // tellDelegateQueryWillBeBuilt(cb, query); + // + // List<Predicate> predicates = new ArrayList<Predicate>(); + // if (filter != null) { + // predicates.add(FilterConverter.convertFilter(filter, cb, root)); + // } + // tellDelegateFiltersWillBeAdded(cb, query, predicates); + // if (!predicates.isEmpty()) { + // query.where(CollectionUtil.toArray(Predicate.class, predicates)); + // } + // tellDelegateFiltersWereAdded(cb, query); + // + // // List<Order> orderBy = new ArrayList<Order>(); + // // if (sortBy != null && sortBy.size() > 0) { + // // for (SortBy sortedProperty : sortBy) { + // // orderBy.add(translateSortBy(sortedProperty, swapSortOrder, cb, + // // root)); + // // } + // // } + // // tellDelegateOrderByWillBeAdded(cb, query, orderBy); + // // query.orderBy(orderBy); + // // tellDelegateOrderByWereAdded(cb, query); + // + // String entityIdPropertyName = getEntityClassMetadata() + // .getIdentifierProperty().getName(); + // query.select(cb.count(root.get(entityIdPropertyName))); + // // query.groupBy(root.get(entityIdPropertyName)); + // + // tellDelegateQueryHasBeenBuilt(cb, query); + // return doGetEntityManager().createQuery(query); + // } + + /** + * Creates a filtered, optionally sorted, query. + * + * @param filter + * the filter to apply, or null if no filters should be applied. + * @param sortBy + * the fields to sort by (must include at least one field), or + * null if the result should not be sorted at all. + * @param swapSortOrder + * true to swap the sort order, false to use the sort order + * specified in <code>sortBy</code>. Only applies if + * <code>sortBy</code> is not null. + * @return the query (never null). + */ + @SuppressWarnings("unchecked") + protected TypedQuery<T> createFilteredEntityQuery(ILFilter filter, List<SortBy> sortBy, boolean swapSortOrder) { + assert sortBy == null || !sortBy.isEmpty() : "sortBy must be either null or non-empty"; + + CriteriaBuilder cb = doGetEntityManager().getCriteriaBuilder(); + CriteriaQuery<Object> query = cb.createQuery(); + Root<T> root = query.from(entityClassMetadata.getMappedClass()); + + tellDelegateQueryWillBeBuilt(cb, query); + + List<Predicate> predicates = new ArrayList<Predicate>(); + if (filter != null) { + predicates.add(FilterConverter.convertFilter(filter, cb, root)); + } + tellDelegateFiltersWillBeAdded(cb, query, predicates); + if (!predicates.isEmpty()) { + query.where(CollectionUtil.toArray(Predicate.class, predicates)); + } + tellDelegateFiltersWereAdded(cb, query); + + List<Order> orderBy = new ArrayList<Order>(); + if (sortBy != null && sortBy.size() > 0) { + for (SortBy sortedProperty : sortBy) { + orderBy.add(translateSortBy(sortedProperty, swapSortOrder, cb, root)); + } + } + tellDelegateOrderByWillBeAdded(cb, query, orderBy); + query.orderBy(orderBy); + tellDelegateOrderByWereAdded(cb, query); + + query.select(root); + + tellDelegateQueryHasBeenBuilt(cb, query); + return (TypedQuery<T>) doGetEntityManager().createQuery(query); + } + + protected boolean doContainsEntityIdentifier(Object entityId, ILFilter filter) { + assert entityId != null : "entityId must not be null"; + String entityIdPropertyName = getEntityClassMetadata().getIdentifierProperty().getName(); + + CriteriaBuilder cb = doGetEntityManager().getCriteriaBuilder(); + CriteriaQuery<Long> query = cb.createQuery(Long.class); + Root<T> root = query.from(getEntityClassMetadata().getMappedClass()); + + tellDelegateQueryWillBeBuilt(cb, query); + + List<Predicate> predicates = new ArrayList<Predicate>(); + predicates.add(cb.equal(root.get(entityIdPropertyName), cb.literal(entityId))); + if (filter != null) { + predicates.add(FilterConverter.convertFilter(filter, cb, root)); + } + tellDelegateFiltersWillBeAdded(cb, query, predicates); + if (!predicates.isEmpty()) { + query.where(CollectionUtil.toArray(Predicate.class, predicates)); + } + tellDelegateFiltersWereAdded(cb, query); + + if (getEntityClassMetadata().hasEmbeddedIdentifier()) { + /* + * Hibernate will generate SQL for "count(obj)" that does not run on + * HSQLDB. "count(*)" works fine, but then EclipseLink won't work. + * With this hack, this method should work with both Hibernate and + * EclipseLink. + */ + query.select(cb.count(root.get(entityIdPropertyName).get(getEntityClassMetadata().getIdentifierProperty() + .getTypeMetadata().getPersistentPropertyNames().iterator().next()))); + } else { + + query.select(cb.count(root.get(entityIdPropertyName))); + } + tellDelegateQueryHasBeenBuilt(cb, query); + TypedQuery<Long> tq = doGetEntityManager().createQuery(query); + return tq.getSingleResult() == 1; + } + + public boolean containsEntityIdentifier(Object entityId, IQuery query) { + return doContainsEntityIdentifier(entityId, query.getFilter()); + } + + protected T doGetEntity(Object entityId) { + assert entityId != null : "entityId must not be null"; + T entity = doGetEntityManager().find(getEntityClassMetadata().getMappedClass(), entityId); + return detachEntity(entity); + } + + public T getEntity(Object entityId) { + return doGetEntity(entityId); + } + + protected Object doGetEntityIdentifierAt(ILFilter filter, List<SortBy> sortBy, int index) { + if (sortBy == null) { + sortBy = Collections.emptyList(); + } + TypedQuery<Object> query = createFilteredPropertyQuery( + Arrays.asList(getEntityClassMetadata().getIdentifierProperty().getName()), filter, + addPrimaryKeyToSortList(sortBy), false); + query.setMaxResults(1); + query.setFirstResult(index); + List<?> result = query.getResultList(); + if (result.isEmpty()) { + return null; + } else { + return result.get(0); + } + } + + public Object getEntityIdentifierAt(IQuery query, int index) { + return doGetEntityIdentifierAt(query.getFilter(), query.getSortOrder().getSortBy(), index); + } + + protected int doGetEntityCount(ILFilter filter) { + String entityIdPropertyName = getEntityClassMetadata().getIdentifierProperty().getName(); + + CriteriaBuilder cb = doGetEntityManager().getCriteriaBuilder(); + CriteriaQuery<Long> query = cb.createQuery(Long.class); + Root<T> root = query.from(getEntityClassMetadata().getMappedClass()); + + tellDelegateQueryWillBeBuilt(cb, query); + + List<Predicate> predicates = new ArrayList<Predicate>(); + if (filter != null) { + predicates.add(FilterConverter.convertFilter(filter, cb, root)); + } + tellDelegateFiltersWillBeAdded(cb, query, predicates); + if (!predicates.isEmpty()) { + query.where(CollectionUtil.toArray(Predicate.class, predicates)); + } + tellDelegateFiltersWereAdded(cb, query); + + if (getEntityClassMetadata().hasEmbeddedIdentifier()) { + /* + * Hibernate will generate SQL for "count(obj)" that does not run on + * HSQLDB. "count(*)" works fine, but then EclipseLink won't work. + * With this hack, this method should work with both Hibernate and + * EclipseLink. + */ + + query.select(cb.count(root.get(entityIdPropertyName).get(getEntityClassMetadata().getIdentifierProperty() + .getTypeMetadata().getPersistentPropertyNames().iterator().next()))); + } else { + query.select(cb.count(root.get(entityIdPropertyName))); + } + tellDelegateQueryHasBeenBuilt(cb, query); + TypedQuery<Long> tq = doGetEntityManager().createQuery(query); + return tq.getSingleResult().intValue(); + } + + public int getEntityCount(IQuery query) { + return doGetEntityCount(query.getFilter()); + } + + // + // public int getEntityIndex(Object entityId, IQuery query) { + // TypedQuery<Long> tQuery = createSiblingIndexQuery(entityId, + // query.getFilter(), query.getSortOrder().getSortBy(), true); + // return tQuery.getSingleResult().intValue(); + // } + + protected Object doGetFirstEntityIdentifier(ILFilter filter, List<SortBy> sortBy) { + if (sortBy == null) { + sortBy = Collections.emptyList(); + } + + List<String> keyFields = Arrays.asList(getEntityClassMetadata().getIdentifierProperty().getName()); + // if (getEntityClassMetadata().hasEmbeddedIdentifier()) { + // keyFields = new ArrayList<String>(); + // for (String p : getEntityClassMetadata().getIdentifierProperty() + // .getTypeMetadata().getPersistentPropertyNames()) { + // keyFields.add(getEntityClassMetadata().getIdentifierProperty() + // .getName() + "." + p); + // } + // } + TypedQuery<Object> query = createFilteredPropertyQuery(keyFields, filter, addPrimaryKeyToSortList(sortBy), + false); + query.setMaxResults(1); + List<?> result = query.getResultList(); + if (result.isEmpty()) { + return null; + } else { + return result.get(0); + } + } + + public Object getFirstEntityIdentifier(IQuery query) { + return doGetFirstEntityIdentifier(query.getFilter(), query.getSortOrder().getSortBy()); + } + + protected T doGetFirstEntity(ILFilter filter, List<SortBy> sortBy) { + if (sortBy == null) { + sortBy = Collections.emptyList(); + } + + TypedQuery<T> query = createFilteredEntityQuery(filter, addPrimaryKeyToSortList(sortBy), false); + query.setMaxResults(1); + List<T> result = query.getResultList(); + if (result.isEmpty()) { + return null; + } else { + return result.get(0); + } + } + + public T getFirstEntity(IQuery query) { + return doGetFirstEntity(query.getFilter(), query.getSortOrder().getSortBy()); + } + + protected Object doGetLastEntityIdentifier(ILFilter filter, List<SortBy> sortBy) { + if (sortBy == null) { + sortBy = Collections.emptyList(); + } + // The last 'true' parameter switches the sort order -> the last row is + // the first result. + TypedQuery<Object> query = createFilteredPropertyQuery( + Arrays.asList(getEntityClassMetadata().getIdentifierProperty().getName()), filter, + addPrimaryKeyToSortList(sortBy), true); + query.setMaxResults(1); + List<?> result = query.getResultList(); + if (result.isEmpty()) { + return null; + } else { + return result.get(0); + } + } + + public Object getLastEntityIdentifier(IQuery query) { + return doGetLastEntityIdentifier(query.getFilter(), query.getSortOrder().getSortBy()); + } + + protected T doGetLastEntity(ILFilter filter, List<SortBy> sortBy) { + if (sortBy == null) { + sortBy = Collections.emptyList(); + } + // The last 'true' parameter switches the sort order -> the last row is + // the first result. + TypedQuery<T> query = createFilteredEntityQuery(filter, addPrimaryKeyToSortList(sortBy), true); + query.setMaxResults(1); + List<T> result = query.getResultList(); + if (result.isEmpty()) { + return null; + } else { + return result.get(0); + } + } + + public T getLastEntity(IQuery query) { + return doGetLastEntity(query.getFilter(), query.getSortOrder().getSortBy()); + } + + /** + * If <code>backwards</code> is false, this method will return the + * identifier of the entity next to the entity identified by + * <code>entityId</code>. If true, this method will return the identifier of + * the entity previous to the entity identified by <code>entityId</code>. + * <code>filter</code> and <code>sortBy</code> is used to define and limit + * the list of entities to be used for determining the sibling. + * + * @param entityId + * the identifier of the entity whose sibling to retrieve (must + * not be null). + * @param filter + * an optional filter to limit the entities (may be null). + * @param sortBy + * the order in which the list should be sorted (must not be + * null). + * @param backwards + * true to fetch the previous sibling, false to fetch the next + * sibling. + * @return the identifier of the "sibling". + */ + protected Object getSibling(Object entityId, ILFilter filter, List<SortBy> sortBy, boolean backwards) { + TypedQuery<Object> query = createSiblingQuery(entityId, filter, sortBy, backwards); + query.setMaxResults(1); + List<?> result = query.getResultList(); + if (result.size() != 1) { + return null; + } else { + return result.get(0); + } + } + + /** + * This method creates a query that can be used to fetch the siblings of a + * specific entity. If <code>backwards</code> is false, the query will begin + * with the entity next to the entity identified by <code>entityId</code>. + * If <code>backwards</code> is false, the query will begin with the entity + * prior to the entity identified by <code>entityId</code>. + * + * @param entityId + * the identifier of the entity whose sibling to retrieve (must + * not be null). + * @param filter + * an optional filter to limit the entities (may be null). + * @param sortBy + * the order in which the list should be sorted (must not be + * null). + * @param backwards + * true to fetch the previous sibling, false to fetch the next + * sibling. + * @return the query that will return the sibling and all the subsequent + * entities unless limited. + */ + protected TypedQuery<Object> createSiblingQuery(Object entityId, ILFilter filter, List<SortBy> sortBy, + boolean backwards) { + assert entityId != null : "entityId must not be null"; + assert sortBy != null : "sortBy must not be null"; + ILFilter limitingFilter; + sortBy = addPrimaryKeyToSortList(sortBy); + if (sortBy.size() == 1) { + // The list is sorted by primary key + if (backwards) { + limitingFilter = new Less(getEntityClassMetadata().getIdentifierProperty().getName(), entityId); + } else { + limitingFilter = new Greater(getEntityClassMetadata().getIdentifierProperty().getName(), entityId); + } + } else { + // We have to fetch the values of the sorted fields + T currentEntity = getEntity(entityId); + if (currentEntity == null) { + throw new EntityNotFoundException("No entity found with the ID " + entityId); + } + // Collect the values into a map for easy access + Map<Object, Object> filterValues = new HashMap<Object, Object>(); + for (SortBy sb : sortBy) { + filterValues.put(sb.getPropertyId(), + getEntityClassMetadata().getPropertyValue(currentEntity, sb.getPropertyId().toString())); + } + // Now we can build a filter that limits the query to the entities + // below entityId + List<ILFilter> orFilters = new ArrayList<ILFilter>(); + for (int i = sortBy.size() - 1; i >= 0; i--) { + // TODO Document this code snippet once it works + // TODO What happens with null values? + List<ILFilter> caseFilters = new ArrayList<ILFilter>(); + SortBy sb; + for (int j = 0; j < i; j++) { + sb = sortBy.get(j); + caseFilters.add(new Equal(sb.getPropertyId(), filterValues.get(sb.getPropertyId()))); + } + sb = sortBy.get(i); + if (sb.isAscending() ^ backwards) { + caseFilters.add(new Greater(sb.getPropertyId(), filterValues.get(sb.getPropertyId()))); + } else { + caseFilters.add(new Less(sb.getPropertyId(), filterValues.get(sb.getPropertyId()))); + } + orFilters.add(new LAnd(CollectionUtil.toArray(ILFilter.class, caseFilters))); + } + limitingFilter = new LOr(CollectionUtil.toArray(ILFilter.class, orFilters)); + } + // Now, we can create the query + ILFilter queryFilter; + if (filter == null) { + queryFilter = limitingFilter; + } else { + queryFilter = new LAnd(filter, limitingFilter); + } + TypedQuery<Object> query = createFilteredPropertyQuery( + Arrays.asList(getEntityClassMetadata().getIdentifierProperty().getName()), queryFilter, sortBy, + backwards); + return query; + } + + // /** + // * This method creates a query that can be used to fetch the siblings of a + // * specific entity. If <code>backwards</code> is false, the query will + // begin + // * with the entity next to the entity identified by <code>entityId</code>. + // * If <code>backwards</code> is false, the query will begin with the + // entity + // * prior to the entity identified by <code>entityId</code>. + // * + // * @param entityId + // * the identifier of the entity whose sibling to retrieve (must + // * not be null). + // * @param filter + // * an optional filter to limit the entities (may be null). + // * @param sortBy + // * the order in which the list should be sorted (must not be + // * null). + // * @param backwards + // * true to fetch the previous sibling, false to fetch the next + // * sibling. + // * @return the query that will return the sibling and all the subsequent + // * entities unless limited. + // */ + // protected TypedQuery<Long> createSiblingIndexQuery(Object entityId, + // ILFilter filter, List<SortBy> sortBy, boolean backwards) { + // assert entityId != null : "entityId must not be null"; + // assert sortBy != null : "sortBy must not be null"; + // ILFilter limitingFilter; + // sortBy = addPrimaryKeyToSortList(sortBy); + // if (sortBy.size() == 1) { + // // The list is sorted by primary key + // if (backwards) { + // limitingFilter = new Less(getEntityClassMetadata() + // .getIdentifierProperty().getName(), entityId); + // } else { + // limitingFilter = new Greater(getEntityClassMetadata() + // .getIdentifierProperty().getName(), entityId); + // } + // } else { + // // We have to fetch the values of the sorted fields + // T currentEntity = getEntity(entityId); + // if (currentEntity == null) { + // throw new EntityNotFoundException( + // "No entity found with the ID " + entityId); + // } + // // Collect the values into a map for easy access + // Map<Object, Object> filterValues = new HashMap<Object, Object>(); + // for (SortBy sb : sortBy) { + // filterValues.put( + // sb.getPropertyId(), + // getEntityClassMetadata().getPropertyValue( + // currentEntity, sb.getPropertyId().toString())); + // } + // // Now we can build a filter that limits the query to the entities + // // below entityId + // List<ILFilter> orFilters = new ArrayList<ILFilter>(); + // for (int i = sortBy.size() - 1; i >= 0; i--) { + // // TODO Document this code snippet once it works + // // TODO What happens with null values? + // List<ILFilter> caseFilters = new ArrayList<ILFilter>(); + // SortBy sb; + // for (int j = 0; j < i; j++) { + // sb = sortBy.get(j); + // caseFilters.add(new Equal(sb.getPropertyId(), filterValues + // .get(sb.getPropertyId()))); + // } + // sb = sortBy.get(i); + // if (sb.isAscending() ^ backwards) { + // caseFilters.add(new Greater(sb.getPropertyId(), + // filterValues.get(sb.getPropertyId()))); + // } else { + // caseFilters.add(new Less(sb.getPropertyId(), filterValues + // .get(sb.getPropertyId()))); + // } + // orFilters.add(new LAnd(CollectionUtil.toArray(ILFilter.class, + // caseFilters))); + // } + // limitingFilter = new LOr(CollectionUtil.toArray(ILFilter.class, + // orFilters)); + // } + // // Now, we can create the query + // ILFilter queryFilter; + // if (filter == null) { + // queryFilter = limitingFilter; + // } else { + // queryFilter = new LAnd(filter, limitingFilter); + // } + // TypedQuery<Long> query = createFilteredCountQuery(queryFilter, sortBy, + // backwards); + // return query; + // } + + protected Object doGetNextEntityIdentifier(Object entityId, ILFilter filter, List<SortBy> sortBy) { + if (sortBy == null) { + sortBy = Collections.emptyList(); + } + return getSibling(entityId, filter, sortBy, false); + } + + public Object getNextEntityIdentifier(Object entityId, IQuery query) { + return doGetNextEntityIdentifier(entityId, query.getFilter(), query.getSortOrder().getSortBy()); + } + + protected T doGetNextEntity(Object entityId, ILFilter filter, List<SortBy> sortBy) { + if (sortBy == null) { + sortBy = Collections.emptyList(); + } + Object resultId = getSibling(entityId, filter, sortBy, false); + if (resultId != null) { + return getEntity(resultId); + } + return null; + } + + public T getNextEntity(Object entityId, IQuery query) { + return doGetNextEntity(entityId, query.getFilter(), query.getSortOrder().getSortBy()); + } + + protected Object doGetPreviousEntityIdentifier(Object entityId, ILFilter filter, List<SortBy> sortBy) { + if (sortBy == null) { + sortBy = Collections.emptyList(); + } + return getSibling(entityId, filter, sortBy, true); + } + + public Object getPreviousEntityIdentifier(Object entityId, IQuery query) { + return doGetPreviousEntityIdentifier(entityId, query.getFilter(), query.getSortOrder().getSortBy()); + } + + protected T doGetPreviousEntity(Object entityId, ILFilter filter, List<SortBy> sortBy) { + if (sortBy == null) { + sortBy = Collections.emptyList(); + } + Object resultId = getSibling(entityId, filter, sortBy, true); + if (resultId != null) { + return getEntity(resultId); + } + return null; + } + + public T getPreviousEntity(Object entityId, IQuery query) { + return doGetPreviousEntity(entityId, query.getFilter(), query.getSortOrder().getSortBy()); + } + + /** + * Detaches <code>entity</code> from the entity manager. If + * <code>entity</code> is null, then null is returned. If + * {@link #isEntitiesDetached() } is false, <code>entity</code> is returned + * directly. + * + * @param entity + * the entity to detach. + * @return the detached entity. + */ + protected T detachEntity(T entity) { + if (entity == null) { + return null; + } + if (isEntitiesDetached()) { + getEntityManager().detach(entity); + } + return entity; + } + + public boolean isEntitiesDetached() { + return entitiesDetached; + } + + public void setEntitiesDetached(boolean detached) throws UnsupportedOperationException { + this.entitiesDetached = detached; + } + + protected List<Object> doGetAllEntityIdentifiers(ILFilter filter, List<SortBy> sortBy) { + if (sortBy == null) { + sortBy = Collections.emptyList(); + } + sortBy = addPrimaryKeyToSortList(sortBy); + TypedQuery<Object> query = createFilteredPropertyQuery( + Arrays.asList(getEntityClassMetadata().getIdentifierProperty().getName()), filter, sortBy, false); + return Collections.unmodifiableList(query.getResultList()); + } + + public List<Object> getAllEntityIdentifiers(IQuery query) { + return doGetAllEntityIdentifiers(query.getFilter(), query.getSortOrder().getSortBy()); + } + + protected List<T> doGetAllEntities(ILFilter filter, List<SortBy> sortBy) { + if (sortBy == null) { + sortBy = Collections.emptyList(); + } + sortBy = addPrimaryKeyToSortList(sortBy); + TypedQuery<T> query = createFilteredEntityQuery(filter, sortBy, false); + query.setMaxResults(maxResults); + return Collections.unmodifiableList(query.getResultList()); + } + + public List<T> getAllEntities(IJPQL jpql) { + EntityManager em = getEntityManager(); + + try { + em.getTransaction().begin(); + Query query = getEntityManager().createQuery(jpql.getJPQL()); + for (Map.Entry<String, Object> param : jpql.getParameters().entrySet()) { + query.setParameter(param.getKey(), param.getValue()); + } + + @SuppressWarnings("unchecked") + List<T> result = new ArrayList<>(query.getResultList()); + + return result; + } finally { + em.getTransaction().rollback(); + } + } + + public List<?> getAllValues(IJPQL jpql) { + EntityManager em = getEntityManager(); + + try { + em.getTransaction().begin(); + Query query = getEntityManager().createQuery(jpql.getJPQL()); + for (Map.Entry<String, Object> param : jpql.getParameters().entrySet()) { + query.setParameter(param.getKey(), param.getValue()); + } + + @SuppressWarnings("unchecked") + List<T> result = new ArrayList<>(query.getResultList()); + + return result; + } finally { + em.getTransaction().rollback(); + } + } + + public List<T> getAllEntities(IQuery query) { + return doGetAllEntities(query.getFilter(), query.getSortOrder().getSortBy()); + } + + protected List<T> doGetAllEntities(ILFilter filter, List<SortBy> sortBy, int startIndex) { + if (sortBy == null) { + sortBy = Collections.emptyList(); + } + sortBy = addPrimaryKeyToSortList(sortBy); + TypedQuery<T> query = createFilteredEntityQuery(filter, sortBy, false); + query.setFirstResult(startIndex); + query.setMaxResults(maxResults); + return Collections.unmodifiableList(query.getResultList()); + } + + public List<T> getAllEntities(IQuery query, int startIndex) { + return doGetAllEntities(query.getFilter(), query.getSortOrder().getSortBy(), startIndex); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.jpacontainer.EntityProvider#setQueryModifierDelegate + * (com.vaadin.addon.jpacontainer.EntityProvider.QueryModifierDelegate) + */ + public void setQueryModifierDelegate(QueryModifierDelegate delegate) { + this.queryModifierDelegate = delegate; + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.jpacontainer.EntityProvider#getQueryModifierDelegate() + */ + public QueryModifierDelegate getQueryModifierDelegate() { + return queryModifierDelegate; + } + + // QueryModifierDelegate helper methods + + private void tellDelegateQueryWillBeBuilt(CriteriaBuilder cb, CriteriaQuery<?> query) { + if (queryModifierDelegate != null) { + queryModifierDelegate.queryWillBeBuilt(cb, query); + } + } + + private void tellDelegateQueryHasBeenBuilt(CriteriaBuilder cb, CriteriaQuery<?> query) { + if (queryModifierDelegate != null) { + queryModifierDelegate.queryHasBeenBuilt(cb, query); + } + } + + private void tellDelegateFiltersWillBeAdded(CriteriaBuilder cb, CriteriaQuery<?> query, + List<Predicate> predicates) { + if (queryModifierDelegate != null) { + queryModifierDelegate.filtersWillBeAdded(cb, query, predicates); + } + } + + private void tellDelegateFiltersWereAdded(CriteriaBuilder cb, CriteriaQuery<?> query) { + if (queryModifierDelegate != null) { + queryModifierDelegate.filtersWereAdded(cb, query); + } + } + + private void tellDelegateOrderByWillBeAdded(CriteriaBuilder cb, CriteriaQuery<?> query, List<Order> orderBy) { + if (queryModifierDelegate != null) { + queryModifierDelegate.orderByWillBeAdded(cb, query, orderBy); + } + } + + private void tellDelegateOrderByWereAdded(CriteriaBuilder cb, CriteriaQuery<?> query) { + if (queryModifierDelegate != null) { + queryModifierDelegate.orderByWasAdded(cb, query); + } + } + + public Object getIdentifier(T entity) { + return entityClassMetadata.getPropertyValue(entity, entityClassMetadata.getIdentifierProperty().getName()); + } + + public T refreshEntity(T entity) { + if (getEntityManager().contains(entity)) { + try { + getEntityManager().refresh(entity); + } catch (IllegalArgumentException e) { + // detached, removed or something, get by id from em and refresh + // than non-detached object + entity = findAndRefresh(entity); + } catch (EntityNotFoundException e) { + return null; + } catch (TransactionRequiredException e) { + // TODO: handle exception, only in transactional? + } + } else { + entity = findAndRefresh(entity); + } + return entity; + } + + private T findAndRefresh(T entity) { + entity = getEntityManager().find(getEntityClassMetadata().getMappedClass(), getIdentifier(entity)); + if (entity != null) { + try { + // now try to refresh the attached entity + getEntityManager().refresh(entity); + entity = detachEntity(entity); + } catch (TransactionRequiredException e) { + // NOP + } catch (Exception e) { + throw new RuntimeException(e); + } + } + return entity; + } + + // /* + // * (non-Javadoc) + // * + // * @see + // * com.vaadin.addon.jpacontainer.EntityContainer#setLazyLoadingDelegate( + // * com.vaadin.addon.jpacontainer.EntityContainer.LazyLoadingDelegate) + // */ + // public void setLazyLoadingDelegate(LazyLoadingDelegate delegate) { + // lazyLoadingDelegate = delegate; + // if (lazyLoadingDelegate != null) { + // lazyLoadingDelegate.setEntityProvider(this); + // } + // } + // + // public LazyLoadingDelegate getLazyLoadingDelegate() { + // return lazyLoadingDelegate; + // } + + /* + * (non-Javadoc) + * + * @see com.vaadin.addon.jpacontainer.EntityProvider#refresh() + */ + public void refresh() { + // Nothing to do in this implementation, since we don't keep any + // items/entities cached. + } +} diff --git a/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/FilterConverter.java b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/FilterConverter.java new file mode 100644 index 0000000..f6f1774 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/FilterConverter.java @@ -0,0 +1,454 @@ +/** + * Copyright 2009-2013 Oy Vaadin Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.eclipse.osbp.jpa.services.metadata; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Expression; +import javax.persistence.criteria.From; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; + +import org.eclipse.osbp.jpa.services.filters.LAdvancedFilterableSupport; +import org.eclipse.osbp.jpa.services.filters.LAnd; +import org.eclipse.osbp.jpa.services.filters.LBetween; +import org.eclipse.osbp.jpa.services.filters.LCompare; +import org.eclipse.osbp.jpa.services.filters.LCompare.Equal; +import org.eclipse.osbp.jpa.services.filters.LCompare.Greater; +import org.eclipse.osbp.jpa.services.filters.LIn; +import org.eclipse.osbp.jpa.services.filters.LIsNull; +import org.eclipse.osbp.jpa.services.filters.LJoinFilter; +import org.eclipse.osbp.jpa.services.filters.LLike; +import org.eclipse.osbp.jpa.services.filters.LNot; +import org.eclipse.osbp.jpa.services.filters.LOr; +import org.eclipse.osbp.jpa.services.filters.LSimpleStringFilter; +import org.eclipse.osbp.runtime.common.filter.ILFilter; + +// TODO: Auto-generated Javadoc +/** + * Converts a Vaadin 6.6 container filter into a JPA criteria predicate. + * + * @since 2.0 + */ +public class FilterConverter { + + /** + * Interface for a converter that can convert a certain kind of + * {@link ILFilter} to a {@link Predicate}. + */ + private interface Converter { + + /** + * Can convert. + * + * @param filter + * the filter + * @return true, if successful + */ + public boolean canConvert(ILFilter filter); + + /** + * To predicate. + * + * @param <X> + * the generic type + * @param <Y> + * the generic type + * @param filter + * the filter + * @param cb + * the cb + * @param root + * the root + * @return the predicate + */ + public <X, Y> Predicate toPredicate(ILFilter filter, CriteriaBuilder cb, + From<X, Y> root); + } + + /** + * Converts {@link LAnd} filters. + */ + private static class AndConverter implements Converter { + + /* (non-Javadoc) + * @see org.eclipse.osbp.dsl.dto.lib.services.jpa.metadata.FilterConverter.Converter#canConvert(org.eclipse.osbp.dsl.dto.lib.services.filters.ILFilter) + */ + public boolean canConvert(ILFilter filter) { + return filter instanceof LAnd; + } + + /* (non-Javadoc) + * @see org.eclipse.osbp.dsl.dto.lib.services.jpa.metadata.FilterConverter.Converter#toPredicate(org.eclipse.osbp.dsl.dto.lib.services.filters.ILFilter, javax.persistence.criteria.CriteriaBuilder, javax.persistence.criteria.From) + */ + public <X, Y> Predicate toPredicate(ILFilter filter, CriteriaBuilder cb, + From<X, Y> root) { + return cb.and(convertFiltersToArray(((LAnd) filter).getFilters(), + cb, root)); + } + } + + /** + * Converts {@link LOr} filters. + */ + private static class OrConverter implements Converter { + + /* (non-Javadoc) + * @see org.eclipse.osbp.dsl.dto.lib.services.jpa.metadata.FilterConverter.Converter#canConvert(org.eclipse.osbp.dsl.dto.lib.services.filters.ILFilter) + */ + public boolean canConvert(ILFilter filter) { + return filter instanceof LOr; + } + + /* (non-Javadoc) + * @see org.eclipse.osbp.dsl.dto.lib.services.jpa.metadata.FilterConverter.Converter#toPredicate(org.eclipse.osbp.dsl.dto.lib.services.filters.ILFilter, javax.persistence.criteria.CriteriaBuilder, javax.persistence.criteria.From) + */ + public <X, Y> Predicate toPredicate(ILFilter filter, CriteriaBuilder cb, + From<X, Y> root) { + return cb.or(convertFiltersToArray(((LOr) filter).getFilters(), cb, + root)); + } + } + + /** + * Converts {@link LCompare} filters ({@link Equal}, {@link Greater}, etc). + */ + private static class CompareConverter implements Converter { + + /* (non-Javadoc) + * @see org.eclipse.osbp.dsl.dto.lib.services.jpa.metadata.FilterConverter.Converter#canConvert(org.eclipse.osbp.dsl.dto.lib.services.filters.ILFilter) + */ + public boolean canConvert(ILFilter filter) { + return filter instanceof LCompare; + } + + /* (non-Javadoc) + * @see org.eclipse.osbp.dsl.dto.lib.services.jpa.metadata.FilterConverter.Converter#toPredicate(org.eclipse.osbp.dsl.dto.lib.services.filters.ILFilter, javax.persistence.criteria.CriteriaBuilder, javax.persistence.criteria.From) + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + public <X, Y> Predicate toPredicate(ILFilter filter, CriteriaBuilder cb, + From<X, Y> root) { + LCompare compare = (LCompare) filter; + Expression propertyExpr = LAdvancedFilterableSupport + .getPropertyPath(root, compare.getPropertyId()); + if (LCompare.Operation.EQUAL == compare.getOperation() + && compare.getValue() == null) { + // Make an IS NULL instead if "= null" is passed + return convertFilter(new LIsNull(compare.getPropertyId()), cb, + root); + } + Expression valueExpr = cb.literal(compare.getValue()); + switch (compare.getOperation()) { + case EQUAL: + return cb.equal(propertyExpr, valueExpr); + case GREATER: + return cb.greaterThan(propertyExpr, valueExpr); + case GREATER_OR_EQUAL: + return cb.greaterThanOrEqualTo(propertyExpr, valueExpr); + case LESS: + return cb.lessThan(propertyExpr, valueExpr); + case LESS_OR_EQUAL: + return cb.lessThanOrEqualTo(propertyExpr, valueExpr); + default: // Shouldn't happen + return null; + } + } + } + + /** + * Converts {@link LIsNull} filters. + */ + private static class IsNullConverter implements Converter { + + /* (non-Javadoc) + * @see org.eclipse.osbp.dsl.dto.lib.services.jpa.metadata.FilterConverter.Converter#canConvert(org.eclipse.osbp.dsl.dto.lib.services.filters.ILFilter) + */ + public boolean canConvert(ILFilter filter) { + return filter instanceof LIsNull; + } + + /* (non-Javadoc) + * @see org.eclipse.osbp.dsl.dto.lib.services.jpa.metadata.FilterConverter.Converter#toPredicate(org.eclipse.osbp.dsl.dto.lib.services.filters.ILFilter, javax.persistence.criteria.CriteriaBuilder, javax.persistence.criteria.From) + */ + public <X, Y> Predicate toPredicate(ILFilter filter, CriteriaBuilder cb, + From<X, Y> root) { + return cb.isNull(LAdvancedFilterableSupport.getPropertyPath(root, + ((LIsNull) filter).getPropertyId())); + } + } + + /** + * Converts {@link LSimpleStringFilter} filters. + */ + private static class SimpleStringFilterConverter implements Converter { + + /* (non-Javadoc) + * @see org.eclipse.osbp.dsl.dto.lib.services.jpa.metadata.FilterConverter.Converter#canConvert(org.eclipse.osbp.dsl.dto.lib.services.filters.ILFilter) + */ + public boolean canConvert(ILFilter filter) { + return filter instanceof LSimpleStringFilter; + } + + /* (non-Javadoc) + * @see org.eclipse.osbp.dsl.dto.lib.services.jpa.metadata.FilterConverter.Converter#toPredicate(org.eclipse.osbp.dsl.dto.lib.services.filters.ILFilter, javax.persistence.criteria.CriteriaBuilder, javax.persistence.criteria.From) + */ + public <X, Y> Predicate toPredicate(ILFilter filter, CriteriaBuilder cb, + From<X, Y> root) { + LSimpleStringFilter stringFilter = (LSimpleStringFilter) filter; + String filterString = stringFilter.getFilterString(); + if (stringFilter.isOnlyMatchPrefix()) { + filterString = filterString + "%"; + } else { + filterString = "%" + filterString + "%"; + } + if (stringFilter.isIgnoreCase()) { + return cb.like(cb.upper(LAdvancedFilterableSupport + .getPropertyPath(root, stringFilter.getPropertyId() + .toString())), cb.upper(cb + .literal(filterString))); + } else { + return cb.like(LAdvancedFilterableSupport.getPropertyPath(root, + stringFilter.getPropertyId().toString()), cb + .literal(filterString)); + } + } + } + + /** + * Converts {@link LLike} filters. + */ + private static class LikeConverter implements Converter { + + /* (non-Javadoc) + * @see org.eclipse.osbp.dsl.dto.lib.services.jpa.metadata.FilterConverter.Converter#canConvert(org.eclipse.osbp.dsl.dto.lib.services.filters.ILFilter) + */ + public boolean canConvert(ILFilter filter) { + return filter instanceof LLike; + } + + /* (non-Javadoc) + * @see org.eclipse.osbp.dsl.dto.lib.services.jpa.metadata.FilterConverter.Converter#toPredicate(org.eclipse.osbp.dsl.dto.lib.services.filters.ILFilter, javax.persistence.criteria.CriteriaBuilder, javax.persistence.criteria.From) + */ + public <X, Y> Predicate toPredicate(ILFilter filter, CriteriaBuilder cb, + From<X, Y> root) { + LLike like = (LLike) filter; + if (like.isCaseSensitive()) { + return cb.like(LAdvancedFilterableSupport.getPropertyPath(root, + like.getPropertyId().toString()), cb.literal(like + .getValue())); + } else { + return cb.like( + cb.upper(LAdvancedFilterableSupport.getPropertyPath( + root, like.getPropertyId().toString())), cb + .upper(cb.literal(like.getValue()))); + } + } + } + + /** + * The Class BetweenConverter. + */ + private static class BetweenConverter implements Converter { + + /* (non-Javadoc) + * @see org.eclipse.osbp.dsl.dto.lib.services.jpa.metadata.FilterConverter.Converter#canConvert(org.eclipse.osbp.dsl.dto.lib.services.filters.ILFilter) + */ + public boolean canConvert(ILFilter filter) { + return filter instanceof LBetween; + } + + /* (non-Javadoc) + * @see org.eclipse.osbp.dsl.dto.lib.services.jpa.metadata.FilterConverter.Converter#toPredicate(org.eclipse.osbp.dsl.dto.lib.services.filters.ILFilter, javax.persistence.criteria.CriteriaBuilder, javax.persistence.criteria.From) + */ + @SuppressWarnings({ "unchecked", "rawtypes" }) + public <X, Y> Predicate toPredicate(ILFilter filter, CriteriaBuilder cb, + From<X, Y> root) { + LBetween between = (LBetween) filter; + Expression<? extends Comparable> field = LAdvancedFilterableSupport + .getPropertyPath(root, between.getPropertyId()); + Expression<? extends Comparable> from = cb.literal(between + .getStartValue()); + Expression<? extends Comparable> to = cb.literal(between + .getEndValue()); + return cb.between(field, from, to); + } + } + + /** + * The Class InConverter. + */ + private static class InConverter implements Converter { + + /* (non-Javadoc) + * @see org.eclipse.osbp.dsl.dto.lib.services.jpa.metadata.FilterConverter.Converter#canConvert(org.eclipse.osbp.dsl.dto.lib.services.filters.ILFilter) + */ + public boolean canConvert(ILFilter filter) { + return filter instanceof LIn; + } + + /* (non-Javadoc) + * @see org.eclipse.osbp.dsl.dto.lib.services.jpa.metadata.FilterConverter.Converter#toPredicate(org.eclipse.osbp.dsl.dto.lib.services.filters.ILFilter, javax.persistence.criteria.CriteriaBuilder, javax.persistence.criteria.From) + */ + public <X, Y> Predicate toPredicate(ILFilter filter, CriteriaBuilder cb, + From<X, Y> root) { + LIn in = (LIn) filter; + return root.get(in.getPropertyId()).in(in.getValues()); + } + } + + /** + * The Class JoinFilterConverter. + */ + private static class JoinFilterConverter implements Converter { + + /* (non-Javadoc) + * @see org.eclipse.osbp.dsl.dto.lib.services.jpa.metadata.FilterConverter.Converter#canConvert(org.eclipse.osbp.dsl.dto.lib.services.filters.ILFilter) + */ + public boolean canConvert(ILFilter filter) { + return filter instanceof LJoinFilter; + } + + /* (non-Javadoc) + * @see org.eclipse.osbp.dsl.dto.lib.services.jpa.metadata.FilterConverter.Converter#toPredicate(org.eclipse.osbp.dsl.dto.lib.services.filters.ILFilter, javax.persistence.criteria.CriteriaBuilder, javax.persistence.criteria.From) + */ + public <X, Y> Predicate toPredicate(ILFilter filter, CriteriaBuilder cb, + From<X, Y> root) { + LJoinFilter hibernateJoin = (LJoinFilter) filter; + From<X, Y> join = root.join(hibernateJoin.getJoinProperty()); + return cb.and(convertFiltersToArray(hibernateJoin.getFilters(), cb, + join)); + } + + } + + /** + * The Class NotFilterConverter. + */ + private static class NotFilterConverter implements Converter { + + /* (non-Javadoc) + * @see org.eclipse.osbp.dsl.dto.lib.services.jpa.metadata.FilterConverter.Converter#canConvert(org.eclipse.osbp.dsl.dto.lib.services.filters.ILFilter) + */ + public boolean canConvert(ILFilter filter) { + return filter instanceof LNot; + } + + /* (non-Javadoc) + * @see org.eclipse.osbp.dsl.dto.lib.services.jpa.metadata.FilterConverter.Converter#toPredicate(org.eclipse.osbp.dsl.dto.lib.services.filters.ILFilter, javax.persistence.criteria.CriteriaBuilder, javax.persistence.criteria.From) + */ + public <X, Y> Predicate toPredicate(ILFilter filter, CriteriaBuilder cb, + From<X, Y> root) { + LNot not = (LNot) filter; + return cb.not(convertFilter(not.getFilter(), cb, root)); + } + } + + /** The converters. */ + private static Collection<Converter> converters; + static { + converters = Collections.unmodifiableCollection(Arrays.asList( + new AndConverter(), new OrConverter(), new CompareConverter(), + new IsNullConverter(), new SimpleStringFilterConverter(), + new LikeConverter(), new BetweenConverter(), new InConverter(), + new JoinFilterConverter(), new NotFilterConverter())); + } + + /** + * Convert a single {@link ILFilter} to a criteria {@link Predicate}. + * + * @param <X> + * the generic type + * @param <Y> + * the generic type + * @param filter + * the {@link ILFilter} to convert + * @param criteriaBuilder + * the {@link CriteriaBuilder} to use when creating the + * {@link Predicate} + * @param root + * the {@link CriteriaQuery} {@link Root} to use for finding + * fields. + * @return a {@link Predicate} representing the {@link ILFilter} or null if + * conversion failed. + */ + public static <X, Y> Predicate convertFilter(ILFilter filter, + CriteriaBuilder criteriaBuilder, From<X, Y> root) { + assert filter != null : "filter must not be null"; + + for (Converter c : converters) { + if (c.canConvert(filter)) { + return c.toPredicate(filter, criteriaBuilder, root); + } + } + + throw new IllegalStateException("Cannot find any converters for " + + filter.getClass().getSimpleName() + " filters!"); + } + + /** + * Converts a collection of {@link ILFilter} into a list of + * {@link Predicate} . + * + * @param <X> + * the generic type + * @param <Y> + * the generic type + * @param filters + * Collection of {@link ILFilter} + * @param criteriaBuilder + * the criteria builder + * @param root + * the root + * @return List of {@link Predicate} + */ + public static <X, Y> List<Predicate> convertFilters( + Collection<ILFilter> filters, CriteriaBuilder criteriaBuilder, + From<X, Y> root) { + List<Predicate> result = new ArrayList<Predicate>(); + for (ILFilter filter : filters) { + result.add(convertFilter(filter, criteriaBuilder, root)); + } + return result; + } + + /** + * Convert filters to array. + * + * @param <X> + * the generic type + * @param <Y> + * the generic type + * @param filters + * the filters + * @param criteriaBuilder + * the criteria builder + * @param root + * the root + * @return the predicate[] + */ + private static <X, Y> Predicate[] convertFiltersToArray( + Collection<ILFilter> filters, CriteriaBuilder criteriaBuilder, + From<X, Y> root) { + return CollectionUtil.toArray(Predicate.class, + convertFilters(filters, criteriaBuilder, root)); + } +} diff --git a/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/MetadataFactory.java b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/MetadataFactory.java new file mode 100644 index 0000000..13acbaf --- /dev/null +++ b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/MetadataFactory.java @@ -0,0 +1,459 @@ +/** + * Copyright 2009-2013 Oy Vaadin Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.eclipse.osbp.jpa.services.metadata; + +import java.beans.Introspector; +import java.lang.reflect.AccessibleObject; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.HashMap; +import java.util.Map; + +import javax.persistence.ElementCollection; +import javax.persistence.Embeddable; +import javax.persistence.Embedded; +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.ManyToMany; +import javax.persistence.ManyToOne; +import javax.persistence.MappedSuperclass; +import javax.persistence.OneToMany; +import javax.persistence.OneToOne; +import javax.persistence.Transient; +import javax.persistence.Version; + +import org.eclipse.osbp.jpa.services.metadata.PersistentPropertyMetadata.AccessType; + +/** + * Factory for creating and populating {@link ClassMetadata} and + * {@link EntityClassMetadata} instances. + * + * @author Petter Holmström (Vaadin Ltd) + * @since 1.0 + */ +public class MetadataFactory { + + private static MetadataFactory INSTANCE; + private Map<Class<?>, ClassMetadata<?>> metadataMap = new HashMap<Class<?>, ClassMetadata<?>>(); + + protected MetadataFactory() { + // NOP + } + + /** + * Gets the singleton instance of this factory. + * + * @return the factory instance (never null). + */ + public static MetadataFactory getInstance() { + if (INSTANCE == null) { + INSTANCE = new MetadataFactory(); + } + return INSTANCE; + } + + /** + * Extracts the entity class metadata from <code>mappedClass</code>. The + * access type (field or method) will be determined from the location of the + * {@link Id} or {@link EmbeddedId} annotation. If both of these are + * missing, this method will fail. This method will also fail if + * <code>mappedClass</code> lacks the {@link Entity} annotation. + * + * @param mappedClass + * the mapped class (must not be null). + * @return the class metadata. + * @throws IllegalArgumentException + * if no metadata could be extracted. + */ + public <T> EntityClassMetadata<T> getEntityClassMetadata( + Class<T> mappedClass) throws IllegalArgumentException { + assert mappedClass != null : "mappedClass must not be null"; + if (mappedClass.getAnnotation(Entity.class) == null) { + throw new IllegalArgumentException("The class is not an entity"); + } + PersistentPropertyMetadata.AccessType accessType = determineAccessType(mappedClass); + if (accessType == null) { + throw new IllegalArgumentException( + "The access type could not be determined"); + } else { + return (EntityClassMetadata<T>) getClassMetadata(mappedClass, + accessType); + } + } + + /** + * Extracts the class metadata from <code>mappedClass</code>. If + * <code>mappedClass</code> is {@link Embeddable}, the result will be an + * instance of {@link ClassMetadata}. If <code>mappedClass</code> is an + * {@link Entity}, the result will be an instance of + * {@link EntityClassMetadata}. + * <p> + * <code>accessType</code> instructs the factory where to look for + * annotations and which defaults to assume if there are no annotations. + * + * @param mappedClass + * the mapped class (must not be null). + * @param accessType + * the location where to look for annotations (must not be null). + * @return the class metadata. + * @throws IllegalArgumentException + * if no metadata could be extracted. + */ + @SuppressWarnings("unchecked") + public <T> ClassMetadata<T> getClassMetadata(Class<T> mappedClass, + PersistentPropertyMetadata.AccessType accessType) + throws IllegalArgumentException { + assert mappedClass != null : "mappedClass must not be null"; + assert accessType != null : "accessType must not be null"; + + // Check if we already have the metadata in cache + ClassMetadata<T> metadata = (ClassMetadata<T>) metadataMap + .get(mappedClass); + if (metadata != null) { + return metadata; + } + + // Check if we are dealing with an entity class or an embeddable class + Entity entity = mappedClass.getAnnotation(Entity.class); + Embeddable embeddable = mappedClass.getAnnotation(Embeddable.class); + if (entity != null) { + // We have an entity class + String entityName = entity.name().length() == 0 ? mappedClass + .getSimpleName() : entity.name(); + metadata = new EntityClassMetadata<T>(mappedClass, entityName); + // Put the metadata instance in the cache in case it is referenced + // from loadProperties() + metadataMap.put(mappedClass, metadata); + loadProperties(mappedClass, metadata, accessType); + + // Locate the version and identifier properties + EntityClassMetadata<T> entityMetadata = (EntityClassMetadata<T>) metadata; + for (PersistentPropertyMetadata pm : entityMetadata + .getPersistentProperties()) { + + if (pm.getAnnotation(Version.class) != null) { + entityMetadata.setVersionPropertyName(pm.getName()); + } else if (pm.getAnnotation(Id.class) != null + || pm.getAnnotation(EmbeddedId.class) != null) { + entityMetadata.setIdentifierPropertyName(pm.getName()); + } + if (entityMetadata.hasIdentifierProperty() + && entityMetadata.hasVersionProperty()) { + // No use continuing the loop if both the version + // and the identifier property have already been found. + break; + } + } + } else if (embeddable != null) { + // We have an embeddable class + metadata = new ClassMetadata<T>(mappedClass); + // Put the metadata instance in the cache in case it is referenced + // from loadProperties() + metadataMap.put(mappedClass, metadata); + loadProperties(mappedClass, metadata, accessType); + } else { + throw new IllegalArgumentException("The class " + + mappedClass.getName() + + " is nether an entity nor embeddable"); + } + + return metadata; + } + + protected void loadProperties(Class<?> type, ClassMetadata<?> metadata, + PersistentPropertyMetadata.AccessType accessType) { + + // Also check superclass for metadata + Class<?> superclass = type.getSuperclass(); + if (superclass != null + && (superclass.getAnnotation(MappedSuperclass.class) != null + || superclass.getAnnotation(Entity.class) != null ) +//TODO: check the change made for SONAR !!! + || (superclass != null + && superclass.getAnnotation(Embeddable.class) != null) + ) { + loadProperties(superclass, metadata, accessType); + } + + if (accessType == PersistentPropertyMetadata.AccessType.FIELD) { + extractPropertiesFromFields(type, metadata); + } else { + extractPropertiesFromMethods(type, metadata); + } + } + + protected PersistentPropertyMetadata.AccessType determineAccessType( + Class<?> type) { + // Start by looking for annotated fields + for (Field f : type.getDeclaredFields()) { + if (f.getAnnotation(Id.class) != null + || f.getAnnotation(EmbeddedId.class) != null) { + return AccessType.FIELD; + } + } + + // Then look for annotated getter methods + for (Method m : type.getDeclaredMethods()) { + if (m.getAnnotation(Id.class) != null + || m.getAnnotation(EmbeddedId.class) != null) { + return AccessType.METHOD; + } + } + + // Nothing found? Try with the superclass! + Class<?> superclass = type.getSuperclass(); + if (superclass != null + && (superclass.getAnnotation(MappedSuperclass.class) != null || superclass + .getAnnotation(Entity.class) != null)) { + return determineAccessType(superclass); + } + + // The access type could not be determined; + return null; + } + + protected boolean isReference(AccessibleObject ab) { + return ab.getAnnotation(ManyToOne.class) != null; + } + + private boolean isOneToOne(AccessibleObject ab) { + return ab.getAnnotation(OneToOne.class) != null; + } + + protected boolean isCollection(AccessibleObject ab) { + return ab.getAnnotation(OneToMany.class) != null; + } + + private boolean isManyToMany(AccessibleObject ab) { + return ab.getAnnotation(ManyToMany.class) != null; + } + + protected boolean isEmbedded(AccessibleObject ab) { + return (ab.getAnnotation(Embedded.class) != null || ab + .getAnnotation(EmbeddedId.class) != null); + } + + protected void extractPropertiesFromFields(Class<?> type, + ClassMetadata<?> metadata) { + for (Field f : type.getDeclaredFields()) { + int mod = f.getModifiers(); + if (!Modifier.isFinal(mod) && !Modifier.isStatic(mod) + && !Modifier.isTransient(mod) + && f.getAnnotation(Transient.class) == null) { + Class<?> fieldType = getFieldType(f); + Method setterMethod = null; + try { + final String assumedSetterName = "set" + + f.getName().substring(0, 1).toUpperCase() + + f.getName().substring(1); + Method method = type + .getMethod(assumedSetterName, fieldType); + setterMethod = method; + } catch (Exception e) { + // Setter does not exist or is not accessible + } + + if (isEmbedded(f)) { + ClassMetadata<?> cm = getClassMetadata(fieldType, + AccessType.FIELD); + metadata.addProperties(new PersistentPropertyMetadata(f + .getName(), cm, PropertyKind.EMBEDDED, f, + setterMethod)); + } else if (isReference(f)) { + ClassMetadata<?> cm = getClassMetadata(fieldType, + AccessType.FIELD); + metadata.addProperties(new PersistentPropertyMetadata(f + .getName(), cm, PropertyKind.MANY_TO_ONE, f, + setterMethod)); + } else if (isOneToOne(f)) { + ClassMetadata<?> cm = getClassMetadata(fieldType, + AccessType.FIELD); + metadata.addProperties(new PersistentPropertyMetadata(f + .getName(), cm, PropertyKind.ONE_TO_ONE, f, + setterMethod)); + } else if (isCollection(f)) { + metadata.addProperties(new PersistentPropertyMetadata(f + .getName(), fieldType, PropertyKind.ONE_TO_MANY, f, + setterMethod)); + } else if (isManyToMany(f)) { + metadata.addProperties(new PersistentPropertyMetadata(f + .getName(), fieldType, PropertyKind.MANY_TO_MANY, + f, setterMethod)); + } else if (isElementCollection(f)) { + metadata.addProperties(new PersistentPropertyMetadata(f + .getName(), fieldType, + PropertyKind.ELEMENT_COLLECTION, f, setterMethod)); + } else { + metadata.addProperties(new PersistentPropertyMetadata(f + .getName(), convertPrimitiveType(fieldType), + PropertyKind.SIMPLE, f, setterMethod)); + } + } + } + // Find the transient properties + for (Method m : type.getDeclaredMethods()) { + int mod = m.getModifiers(); + // Synthetic methods are excluded (#4590). + // In theory, this could filter out too much in some special cases, + // in which case the subclass could re-declare the accessor methods + // with the correct annotations as a workaround. + if (m.getName().startsWith("get") && m.getName().length() > 3 + && !Modifier.isStatic(mod) && !m.isSynthetic() + && m.getReturnType() != Void.TYPE + && m.getParameterTypes().length == 0) { + Method setter = null; + try { + // Check if we have a setter + setter = type.getDeclaredMethod("set" + + m.getName().substring(3), m.getReturnType()); + } catch (NoSuchMethodException ignoreit) { + } + String name = Introspector.decapitalize(m.getName() + .substring(3)); + + if (metadata.getProperty(name) == null) { + // No previous property has been added with the same name + metadata.addProperties(new PropertyMetadata(name, m + .getReturnType(), m, setter)); + } + } + } + } + + protected boolean isElementCollection(AccessibleObject ab) { + return (ab.getAnnotation(ElementCollection.class) != null); + } + + /** + * Finds the actual pointed-to type of the field. The concrete type may be + * other than the declared type if the targetEntity parameter is specified + * in certain annotations. + * + * @param f + * the field. + * @return the type of the field. + */ + private Class<?> getFieldType(Field f) { + Class<?> targetEntity = void.class; + if (isReference(f)) { + targetEntity = f.getAnnotation(ManyToOne.class).targetEntity(); + } else if (isOneToOne(f)) { + targetEntity = f.getAnnotation(OneToOne.class).targetEntity(); + } + if (targetEntity != void.class) { + return targetEntity; + } + return f.getType(); + } + + private Class<?> convertPrimitiveType(Class<?> type) { + // Vaadin fields don't work with primitive values, use wrapper types for + // primitives + if (type.isPrimitive()) { + if (type.equals(Boolean.TYPE)) { + type = Boolean.class; + } else if (type.equals(Integer.TYPE)) { + type = Integer.class; + } else if (type.equals(Float.TYPE)) { + type = Float.class; + } else if (type.equals(Double.TYPE)) { + type = Double.class; + } else if (type.equals(Byte.TYPE)) { + type = Byte.class; + } else if (type.equals(Character.TYPE)) { + type = Character.class; + } else if (type.equals(Short.TYPE)) { + type = Short.class; + } else if (type.equals(Long.TYPE)) { + type = Long.class; + } + } + return type; + } + + protected void extractPropertiesFromMethods(Class<?> type, + ClassMetadata<?> metadata) { + for (Method m : type.getDeclaredMethods()) { + int mod = m.getModifiers(); + // Synthetic methods are excluded (#4590) - otherwise you could e.g. + // have a synthetic and a concrete id getter (with different + // declared return types) in TestClasses.Integer_ConcreteId_M, and + // the synthetic method could override the concrete one and its + // annotations. + // In theory, this could filter out too much in some special cases, + // in which case the subclass could re-declare the accessor methods + // with the correct annotations as a workaround. + if (m.getName().startsWith("get") && m.getName().length() > 3 + && !Modifier.isStatic(mod) && !m.isSynthetic() + && m.getReturnType() != Void.TYPE + && m.getParameterTypes().length == 0) { + Method setter = null; + try { + // Check if we have a setter + setter = type.getDeclaredMethod("set" + + m.getName().substring(3), m.getReturnType()); + } catch (NoSuchMethodException ignoreit) { + // No setter <=> transient property + } + String name = Introspector.decapitalize(m.getName() + .substring(3)); + + if (setter != null && m.getAnnotation(Transient.class) == null) { + // Persistent property + if (isEmbedded(m)) { + ClassMetadata<?> cm = getClassMetadata( + m.getReturnType(), AccessType.METHOD); + metadata.addProperties(new PersistentPropertyMetadata( + name, cm, PropertyKind.EMBEDDED, m, setter)); + } else if (isReference(m)) { + ClassMetadata<?> cm = getClassMetadata( + m.getReturnType(), AccessType.METHOD); + metadata.addProperties(new PersistentPropertyMetadata( + name, cm, PropertyKind.MANY_TO_ONE, m, setter)); + } else if (isOneToOne(m)) { + ClassMetadata<?> cm = getClassMetadata( + m.getReturnType(), AccessType.METHOD); + metadata.addProperties(new PersistentPropertyMetadata( + name, cm, PropertyKind.ONE_TO_ONE, m, setter)); + } else if (isCollection(m)) { + metadata.addProperties(new PersistentPropertyMetadata( + name, m.getReturnType(), + PropertyKind.ONE_TO_MANY, m, setter)); + } else if (isManyToMany(m)) { + metadata.addProperties(new PersistentPropertyMetadata( + name, m.getReturnType(), + PropertyKind.MANY_TO_MANY, m, setter)); + } else if (isElementCollection(m)) { + metadata.addProperties(new PersistentPropertyMetadata( + name, m.getReturnType(), + PropertyKind.ELEMENT_COLLECTION, m, setter)); + } else { + metadata.addProperties(new PersistentPropertyMetadata( + name, m.getReturnType(), PropertyKind.SIMPLE, + m, setter)); + } + } else { + // Transient property + metadata.addProperties(new PropertyMetadata(name, m + .getReturnType(), m, setter)); + } + } + } + } +} diff --git a/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/PersistentPropertyMetadata.java b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/PersistentPropertyMetadata.java new file mode 100644 index 0000000..5be3909 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/PersistentPropertyMetadata.java @@ -0,0 +1,331 @@ +/** + * Copyright 2009-2013 Oy Vaadin Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.eclipse.osbp.jpa.services.metadata; + +import java.io.InvalidObjectException; +import java.io.ObjectStreamException; +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +/** + * An extended version of {@link PropertyMetadata} that provides additional + * information about persistent properties. + * + * @author Petter Holmström (Vaadin Ltd) + * @since 1.0 + */ +public class PersistentPropertyMetadata extends PropertyMetadata { + + private static final long serialVersionUID = -4097189601179456814L; + + /** + * Enumeration defining the property access types. + * + * @author Petter Holmström (Vaadin Ltd) + */ + public enum AccessType { + + /** + * The property is accessed as a JavaBean property using getters and + * setters. + */ + METHOD, + /** + * The property is accessed directly as a field. + */ + FIELD + } + + private final PropertyKind propertyKind; + private final ClassMetadata<?> typeMetadata; + transient final Field field; + // Required for serialization + protected final String fieldName; + protected final Class<?> fieldDeclaringClass; + + /** + * Creates a new instance of <code>PersistentPropertyMetadata</code>. + * + * @param name + * the name of the property (must not be null). + * @param type + * the type of the property (must not be null). + * @param propertyKind + * the kind of the property, must be either + * {@link PropertyKind#ONE_TO_MANY}, + * {@link PropertyKind#MANY_TO_MANY}, + * {@link PropertyKind#ELEMENT_COLLECTION} or + * {@link PropertyKind#SIMPLE} . + * @param field + * the field that can be used to access the property (must not be + * null). + */ + PersistentPropertyMetadata(String name, Class<?> type, + PropertyKind propertyKind, Field field, Method setter) { + super(name, type, null, setter); + assert propertyKind == PropertyKind.ONE_TO_MANY + || propertyKind == PropertyKind.MANY_TO_MANY + || propertyKind == PropertyKind.ELEMENT_COLLECTION + || propertyKind == PropertyKind.SIMPLE : "propertyKind must be ONE_TO_MANY or SIMPLE"; + assert field != null : "field must not be null"; + this.propertyKind = propertyKind; + typeMetadata = null; + this.field = field; + fieldName = field.getName(); + fieldDeclaringClass = field.getDeclaringClass(); + } + + /** + * Creates a new instance of <code>PersistentPropertyMetadata</code>. + * + * @param name + * the name of the property (must not be null). + * @param type + * type type of the property (must not be null). + * @param propertyKind + * the kind of the property, must be either + * {@link PropertyKind#ONE_TO_MANY}, + * {@link PropertyKind#MANY_TO_MANY}, + * {@link PropertyKind#ELEMENT_COLLECTION} or + * {@link PropertyKind#SIMPLE} . + * @param getter + * the getter method that can be used to read the property value + * (must not be null). + * @param setter + * the setter method that can be used to set the property value + * (must not be null). + */ + PersistentPropertyMetadata(String name, Class<?> type, + PropertyKind propertyKind, Method getter, Method setter) { + super(name, type, getter, setter); + assert propertyKind == PropertyKind.ONE_TO_MANY + || propertyKind == PropertyKind.MANY_TO_MANY + || propertyKind == PropertyKind.ELEMENT_COLLECTION + || propertyKind == PropertyKind.SIMPLE : "propertyKind must be ONE_TO_MANY or SIMPLE"; + assert getter != null : "getter must not be null"; + assert setter != null : "setter must not be null"; + this.propertyKind = propertyKind; + typeMetadata = null; + field = null; + fieldName = null; + fieldDeclaringClass = null; + } + + /** + * Creates a new instance of <code>PersistentPropertyMetadata</code>. + * + * @param name + * the name of the property (must not be null). + * @param type + * the type metadata of the property (must not be null). + * @param propertyKind + * the kind of the property, must be either + * {@link PropertyKind#MANY_TO_ONE}, + * {@link PropertyKind#ONE_TO_ONE} or + * {@link PropertyKind#EMBEDDED}. + * @param field + * the field that can be used to access the property (must not be + * null). + */ + PersistentPropertyMetadata(String name, ClassMetadata<?> type, + PropertyKind propertyKind, Field field, Method setter) { + super(name, type.getMappedClass(), null, setter); + assert type != null : "type must not be null"; + assert propertyKind == PropertyKind.MANY_TO_ONE + || propertyKind == PropertyKind.ONE_TO_ONE + || propertyKind == PropertyKind.EMBEDDED : "propertyKind must be MANY_TO_ONE or EMBEDDED"; + assert field != null : "field must not be null"; + this.propertyKind = propertyKind; + typeMetadata = type; + this.field = field; + fieldName = field.getName(); + fieldDeclaringClass = field.getDeclaringClass(); + } + + /** + * Creates a new instance of <code>PersistentPropertyMetadata</code>. + * + * @param name + * the name of the property (must not be null). + * @param type + * the type metadata of the property (must not be null). + * @param propertyKind + * the kind of the property, must be either + * {@link PropertyKind#MANY_TO_ONE}, + * {@link PropertyKind#ONE_TO_ONE} or + * {@link PropertyKind#EMBEDDED}. + * @param getter + * the getter method that can be used to read the property value + * (must not be null). + * @param setter + * the setter method that can be used to set the property value + * (must not be null). + */ + PersistentPropertyMetadata(String name, ClassMetadata<?> type, + PropertyKind propertyKind, Method getter, Method setter) { + super(name, type.getMappedClass(), getter, setter); + assert type != null : "type must not be null"; + assert propertyKind == PropertyKind.MANY_TO_ONE + || propertyKind == PropertyKind.ONE_TO_ONE + || propertyKind == PropertyKind.EMBEDDED : "propertyKind must be MANY_TO_ONE or EMBEDDED"; + assert getter != null : "getter must not be null"; + assert setter != null : "setter must not be null"; + this.propertyKind = propertyKind; + typeMetadata = type; + field = null; + fieldName = null; + fieldDeclaringClass = null; + } + + /** + * This constructor is used when deserializing the object. + * + * @see #readResolve() + */ + private PersistentPropertyMetadata(String name, + ClassMetadata<?> typeMetadata, Class<?> type, + PropertyKind propertyKind, Method getter, Method setter, Field field) { + super(name, type, getter, setter); + this.propertyKind = propertyKind; + this.typeMetadata = typeMetadata; + this.field = field; + if (this.field == null) { + fieldName = null; + fieldDeclaringClass = null; + } else { + fieldName = field.getName(); + fieldDeclaringClass = field.getDeclaringClass(); + } + } + + /** + * The metadata of the property type, if it is embedded or a reference. + * Otherwise, this method returns null. + * + * @see #getPropertyKind() + */ + public ClassMetadata<?> getTypeMetadata() { + return typeMetadata; + } + + /** + * The kind of the property. + */ + @Override + public PropertyKind getPropertyKind() { + return propertyKind; + } + + /** + * The way the property value is accessed (as a JavaBean property or as a + * field). + */ + public AccessType getAccessType() { + return field != null ? AccessType.FIELD : AccessType.METHOD; + } + + @Override + public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { + if (field != null) { + return field.getAnnotation(annotationClass); + } else { + return super.getAnnotation(annotationClass); + } + } + + @Override + public Annotation[] getAnnotations() { + if (field != null) { + return field.getAnnotations(); + } else { + return super.getAnnotations(); + } + } + + @Override + public Object readResolve() throws ObjectStreamException { + try { + Field f = null; + if (fieldName != null) { + f = fieldDeclaringClass.getDeclaredField(fieldName); + } + Method getterM = null; + if (getterName != null) { + getterM = getterDeclaringClass.getDeclaredMethod(getterName); + } + Method setterM = null; + if (setterName != null) { + // use the type from field if possible. type is Vaadin property + // type, which means that for primitive types we convert it to + // wrapper type + Class<?> setterType = (f == null) ? getType() : f.getType(); + setterM = setterDeclaringClass.getDeclaredMethod(setterName, + setterType); + } + return new PersistentPropertyMetadata(getName(), typeMetadata, + getType(), propertyKind, getterM, setterM, f); + } catch (Exception e) { + e.printStackTrace(); + throw new InvalidObjectException(e.getMessage()); + } + } + + /** + * Persistent properties are always writable. + * <p> + * {@inheritDoc }. + */ + @Override + public boolean isWritable() { + return true; // field != null || super.isWritable(); + } + + /* + * Note, that we only compare the mapped classes of the typeMetadata fields. + * If we compared the typeMetadata fields themselves, we could run into an + * infinite loop if there are circular references (e.g. a parent-property of + * the same type) in the metadata. + */ + + @Override + public boolean equals(Object obj) { + if (super.equals(obj)) { // Includes check of parameter type + PersistentPropertyMetadata other = (PersistentPropertyMetadata) obj; + return ( other != null && propertyKind.equals(other.propertyKind) ) + && (typeMetadata == null ? other.typeMetadata == null + : typeMetadata.getMappedClass().equals( + other.typeMetadata.getMappedClass())) + && (field == null ? other.field == null : field + .equals(other.field)); + } + return false; + } + + @Override + public int hashCode() { + int hash = super.hashCode(); + hash = hash * 31 + propertyKind.hashCode(); + if (typeMetadata != null) { + hash = hash * 31 + typeMetadata.getMappedClass().hashCode(); + } + if (field != null) { + hash = hash * 31 + field.hashCode(); + } + return hash; + } +} diff --git a/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/PropertyKind.java b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/PropertyKind.java new file mode 100644 index 0000000..14044f2 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/PropertyKind.java @@ -0,0 +1,74 @@ +/** + * Copyright 2009-2013 Oy Vaadin Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.eclipse.osbp.jpa.services.metadata; + +import javax.persistence.Embeddable; + + +/** + * Enumeration defining the property kind. + * + * @author Petter Holmström (Vaadin Ltd) + */ +public enum PropertyKind { + + /** + * The property is embedded. + * + * @see javax.persistence.Embeddable + * @see javax.persistence.Embedded + */ + EMBEDDED, + /** + * The property is a reference. + * + * @see javax.persistence.OneToOne + * @see javax.persistence.ManyToOne + */ + MANY_TO_ONE, + /** + * The property is a reference. + * + * @see javax.persistence.ManyToOne + */ + ONE_TO_ONE, + /** + * The property is a collection. + * + * @see javax.persistence.OneToMany + */ + ONE_TO_MANY, + /** + * The property is a reference. + * + * @see javax.persistence.ManyToMany + */ + MANY_TO_MANY, + /** + * The property is a collection {@link Embeddable}s or basic data types. + * + * @see javax.persistence.ElementCollection + */ + ELEMENT_COLLECTION, + /** + * The property is of a simple datatype. + */ + SIMPLE, + /** + * The property is not persistent property. + */ + NONPERSISTENT +}
\ No newline at end of file diff --git a/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/PropertyMetadata.java b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/PropertyMetadata.java new file mode 100644 index 0000000..286f87f --- /dev/null +++ b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/PropertyMetadata.java @@ -0,0 +1,189 @@ +/** + * Copyright 2009-2013 Oy Vaadin Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.eclipse.osbp.jpa.services.metadata; + +import java.io.InvalidObjectException; +import java.io.ObjectStreamException; +import java.io.Serializable; +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; + +/** + * This class represents the metadata of a property. If the property is + * transient, this is an ordinary JavaBean property consisting of a getter + * method and optionally a setter method. If the property is persistent, + * additional information is provided by the {@link PersistentPropertyMetadata} + * interface. + * + * @see ClassMetadata + * @author Petter Holmström (Vaadin Ltd) + * @since 1.0 + */ +public class PropertyMetadata implements Serializable { + + private static final long serialVersionUID = -6500231861860229121L; + private final String name; + private final Class<?> type; + transient final Method getter; + transient final Method setter; + // Required for serialization: + protected final String getterName; + protected final String setterName; + protected final Class<?> getterDeclaringClass; + protected final Class<?> setterDeclaringClass; + + /** + * Creates a new instance of <code>PropertyMetadata</code>. + * + * @param name + * the name of the property (must not be null). + * @param type + * the type of the property (must not be null). + * @param getter + * the getter method that can be used to read the value of the + * property (must not be null). + * @param setter + * the setter method that can be used to set the value of the + * property (may be null). + */ + PropertyMetadata(String name, Class<?> type, Method getter, Method setter) { + assert name != null : "name must not be null"; + assert type != null : "type must not be null"; + /* + * If we assert that getter != null, PersistentPropertyMetadata will not + * work. + */ + this.name = name; + this.type = type; + this.getter = getter; + this.setter = setter; + /* + * The getter may also be null, e.g. if PersistentPropertyMetadata uses + * a field instead of a getter to access the property. + */ + if (getter != null) { + getterName = getter.getName(); + getterDeclaringClass = getter.getDeclaringClass(); + } else { + getterName = null; + getterDeclaringClass = null; + } + if (setter != null) { + setterName = setter.getName(); + setterDeclaringClass = setter.getDeclaringClass(); + } else { + setterName = null; + setterDeclaringClass = null; + } + } + + public Object readResolve() throws ObjectStreamException { + try { + Method getterM = null; + if (getterName != null) { + getterM = getterDeclaringClass.getDeclaredMethod(getterName); + } + Method setterM = null; + if (setterName != null) { + setterM = setterDeclaringClass.getDeclaredMethod(setterName, + type); + } + return new PropertyMetadata(name, type, getterM, setterM); + } catch (Exception e) { + throw new InvalidObjectException(e.getMessage()); + } + } + + /** + * The name of the property. + */ + public String getName() { + return name; + } + + /** + * The type of the property. + */ + public Class<?> getType() { + return type; + } + + /** + * The annotations of the property, if any. + * + * @see #getAnnotation(java.lang.Class) + */ + public Annotation[] getAnnotations() { + return getter.getAnnotations(); + } + + /** + * Gets the annotation of the specified annotation class, if available. + * + * @see #getAnnotations() + * @see Class#getAnnotation(java.lang.Class) + * @param annotationClass + * the annotation class. + * @return the annotation, or null if not found. + */ + public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { + return getter.getAnnotation(annotationClass); + } + + /** + * Returns whether the property is writable or not. Transient properties + * (i.e. JavaBean properties) are only writable if they have a setter + * method. + * + * @return true if the property is writable, false if it is not. + */ + public boolean isWritable() { + return setter != null; + } + + public PropertyKind getPropertyKind() { + return PropertyKind.NONPERSISTENT; + } + + @Override + public boolean equals(Object obj) { + if (obj != null && obj.getClass() == getClass()) { + PropertyMetadata other = (PropertyMetadata) obj; + return name.equals(other.name) + && type.equals(other.type) + && (getter == null ? other.getter == null : getter + .equals(other.getter)) + && (setter == null ? other.setter == null : setter + .equals(other.setter)); + } + return false; + } + + @Override + public int hashCode() { + int hash = 7; + hash = hash * 31 + name.hashCode(); + hash = hash * 31 + type.hashCode(); + if (getter != null) { + hash = hash * 31 + getter.hashCode(); + } + if (setter != null) { + hash = hash * 31 + setter.hashCode(); + } + return hash; + } +} diff --git a/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/QueryModifierDelegate.java b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/QueryModifierDelegate.java new file mode 100644 index 0000000..9f6b215 --- /dev/null +++ b/org.eclipse.osbp.jpa.services/src/org/eclipse/osbp/jpa/services/metadata/QueryModifierDelegate.java @@ -0,0 +1,132 @@ +/** + * Copyright 2009-2013 Oy Vaadin Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.eclipse.osbp.jpa.services.metadata; + +import java.io.Serializable; +import java.util.List; +import java.util.logging.Filter; + +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Order; +import javax.persistence.criteria.Predicate; + +import org.eclipse.osbp.runtime.common.filter.SortBy; + +/** + * The QueryModifierDelegate interface defines methods that will be called at + * the different stages of {@link CriteriaQuery} generation. Implement this + * interface and call + * {@link EntityDelegate#setQueryModifierDelegate(QueryModifierDelegate)} to + * receive calls while the {@link CriteriaQuery} is being built. The methods are + * allowed to modify the CriteriaQuery. + * + * @since 2.0 + */ +public interface QueryModifierDelegate extends Serializable { + /** + * This method is called after the {@link CriteriaQuery} instance ( + * <code>query</code>) has been instantiated, but before any state has been + * set. + * + * Operations and configuration may be performed on the query instance. + * + * @param criteriaBuilder + * the {@link CriteriaBuilder} used to build the query + * @param query + * the {@link CriteriaQuery} being built + */ + public void queryWillBeBuilt(CriteriaBuilder criteriaBuilder, + CriteriaQuery<?> query); + + /** + * This method is called after the {@link CriteriaQuery} instance has been + * completely built (configured). + * + * Any operations may be performed on the query instance. + * + * @param criteriaBuilder + * the {@link CriteriaBuilder} used to build the query + * @param query + * the {@link CriteriaQuery} being built + */ + public void queryHasBeenBuilt(CriteriaBuilder criteriaBuilder, + CriteriaQuery<?> query); + + /** + * This method is called after filters (in the form of {@link Filter}) have + * been translated into instances of {@link Predicate}, but before the + * resulting predicates have been added to <code>query</code>. + * + * The contents of the <code>predicates</code> list may be modified at this + * point. Any operations may be performed on the query instance. + * + * @param criteriaBuilder + * the {@link CriteriaBuilder} used to build the query + * @param query + * the {@link CriteriaQuery} being built + * @param predicates + * the list of predicates ({@link Predicate}) to be applied. The + * contents of this list may be modified. + */ + public void filtersWillBeAdded(CriteriaBuilder criteriaBuilder, + CriteriaQuery<?> query, List<Predicate> predicates); + + /** + * This method is called after all filters have been applied to the query. + * + * Any operations may be performed on the query instance. + * + * @param criteriaBuilder + * the {@link CriteriaBuilder} used to build the query + * @param query + * the {@link CriteriaQuery} being built + */ + public void filtersWereAdded(CriteriaBuilder criteriaBuilder, + CriteriaQuery<?> query); + + /** + * This method is called after all {@link SortBy} instances have been + * translated into {@link Order} instances, but before they have been + * applied to the query. + * + * The contents of the <code>orderBy</code> list may be modified at this + * point. Any operations may be performed on the query instance. + * + * @param criteriaBuilder + * the {@link CriteriaBuilder} used to build the query + * @param query + * the {@link CriteriaQuery} being built + * @param orderBy + * the list of order by rules ({@link Order}) to be applied. The + * contents of this list may be modified. + */ + public void orderByWillBeAdded(CriteriaBuilder criteriaBuilder, + CriteriaQuery<?> query, List<Order> orderBy); + + /** + * This method is called after the order by has been applied for the query. + * + * Any operations may be performed on the query instance. + * + * @param criteriaBuilder + * the {@link CriteriaBuilder} used to build the query + * @param query + * the {@link CriteriaQuery} being built + */ + public void orderByWasAdded(CriteriaBuilder criteriaBuilder, + CriteriaQuery<?> query); +} @@ -0,0 +1,103 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +#======================================================================= +# Copyright (c) 2017 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany). +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Loetz GmbH&Co.KG - initial API and implementation +#======================================================================= +--> +<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.eclipse.osbp.releng.maven</groupId> + <artifactId>org.eclipse.osbp.releng.maven.parent.tycho</artifactId> + <version>0.9.0-SNAPSHOT</version> + <relativePath/> + </parent> + + <groupId>org.eclipse.osbp.jpa.services</groupId> + <artifactId>org.eclipse.osbp.jpa.services.aggregator</artifactId> + <version>0.9.0-SNAPSHOT</version> + <packaging>pom</packaging> + + <url>${osbp.site.repository.url}</url> + <scm> + <url>${osbp.scm.url}</url> + <connection>${osbp.scm.connection}</connection> + <developerConnection>${osbp.scm.connection.dev}</developerConnection> + <tag>HEAD</tag> + </scm> + <distributionManagement> + <site> + <id>gh-pages</id> + <name>OSBP GitHub Pages</name> + <url>${distribution.site.url}</url> + </site> + </distributionManagement> + + <properties> + + <osbp.gitrepo.name>${project.groupId}</osbp.gitrepo.name> + </properties> + + <modules> + <module>org.eclipse.osbp.jpa.services</module> + <module>org.eclipse.osbp.jpa.services.feature</module> + </modules> + + <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + <plugin> + <groupId>org.eclipse.tycho</groupId> + <artifactId>target-platform-configuration</artifactId> + <version>${tycho-version}</version> + <configuration> + <resolver>p2</resolver> + <pomDependencies>consider</pomDependencies> + <environments> + <environment> + <os>win32</os> + <ws>win32</ws> + <arch>x86</arch> + </environment> + <environment> + <os>win32</os> + <ws>win32</ws> + <arch>x86_64</arch> + </environment> + <environment> + <os>linux</os> + <ws>gtk</ws> + <arch>x86</arch> + </environment> + <environment> + <os>linux</os> + <ws>gtk</ws> + <arch>x86_64</arch> + </environment> + <environment> + <os>macosx</os> + <ws>cocoa</ws> + <arch>x86_64</arch> + </environment> + </environments> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> +</project> |