diff --git a/.travis.yml b/.travis.yml
index c9a025527c..3d0fbd5df1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -18,13 +18,14 @@ addons:
packages:
- g++-4.9
before_install:
+ - sudo rm -vf /etc/apt/sources.list.d/*riak*
- wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add -
- echo "deb http://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
- sudo apt-get update -qq
- sudo apt-get install cf-cli -y
# turn off travis default mvn install call and install a recent node version instead
install:
- - rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install 8.7.0
+ - rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install 8.8.1
- npm install -g bower
- npm install -g grunt-cli
# do not install into local maven repo to avoid polluting the cache
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000000..9cecc1d466
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ {one line to give the program's name and a brief idea of what it does.}
+ Copyright (C) {year} {name of author}
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ {project} Copyright (C) {year} {fullname}
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+.
diff --git a/bower.json b/bower.json
index 45586b6cd1..0b2613d4b0 100644
--- a/bower.json
+++ b/bower.json
@@ -17,7 +17,7 @@
"angular-translate": "2.15.2",
"angular-translate-interpolation-messageformat": "2.15.2",
"angular-translate-storage-cookie": "2.15.2",
- "angular-ui-router": "1.0.8",
+ "angular-ui-router": "1.0.10",
"bootstrap-sass": "3.3.7",
"json3": "3.3.2",
"ng-file-upload": "12.2.13",
@@ -27,28 +27,28 @@
"jszip-utils": "~0.0.2",
"angular-translate-handler-log": "2.15.2",
"angular-nvd3": "^1.0.9",
- "js-xlsx": "^0.11.5",
+ "js-xlsx": "^0.11.6",
"cheet.js": "^0.3.3",
"angular-material": "^1.1.5",
"angular-block-ui": "^0.2.2",
"lodash": "^4.17.4",
- "plotly.js": "^1.31.0",
+ "plotly.js": "^1.31.2",
"highlightjs": "^9.12.0",
"angular-highlightjs": "^0.7.1",
"js-beautify": "^1.7.4",
- "ngclipboard": "^1.1.1",
+ "ngclipboard": "^1.1.2",
"angular-katex": "^0.10.0",
"angular-animate": "1.6.6",
"angular-messages": "1.6.6",
- "bowser": "^1.8.0",
+ "bowser": "^1.8.1",
"angular-file-saver": "^1.1.3",
"clientjs": "^0.1.5",
"angular-scroll": "^1.0.2",
"sockjs-client": "^1.1.4",
"stomp-websocket": "^2.3.4",
- "hyphenator": "rreitmann/Hyphenator#master",
"es5-shim": "^4.5.9",
- "es6-shim": "^0.35.3"
+ "es6-shim": "^0.35.3",
+ "hyphenator": "Hyphenator#^5.3.0"
},
"overrides": {
"elasticsearch": {
diff --git a/package-lock.json b/package-lock.json
index 4aa71cb098..2bbb7d3bb5 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -5,9 +5,9 @@
"requires": true,
"dependencies": {
"@types/node": {
- "version": "6.0.78",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-6.0.78.tgz",
- "integrity": "sha512-+vD6E8ixntRzzZukoF3uP1iV+ZjVN3koTcaeK+BEoc/kSfGbLDIGC7RmCaUgVpUfN6cWvfczFRERCyKM9mkvXg==",
+ "version": "6.0.90",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-6.0.90.tgz",
+ "integrity": "sha512-tXoGRVdi7wZX7P1VWoV9Wfk0uYDOAHdEYXAttuWgSrN76Q32wQlSrMX0Rgyv3RTEaQY2ZLQrzYHVM2e8rfo8sA==",
"dev": true
},
"@types/q": {
@@ -39,9 +39,9 @@
}
},
"adm-zip": {
- "version": "0.4.7",
- "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.4.7.tgz",
- "integrity": "sha1-hgbCy/HEJs6MjsABdER/1Jtur8E=",
+ "version": "0.4.4",
+ "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.4.4.tgz",
+ "integrity": "sha1-ph7VrmkFw66lizplfSUDMJEFJzY=",
"dev": true
},
"after": {
@@ -3964,6 +3964,12 @@
"integrity": "sha1-T9qjs4rLwsAxsEXQ7c3+HsqxjI0=",
"dev": true
},
+ "immediate": {
+ "version": "3.0.6",
+ "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz",
+ "integrity": "sha1-nbHb0Pr43m++D13V5Wu2BigN5ps=",
+ "dev": true
+ },
"immutable": {
"version": "3.8.1",
"resolved": "https://registry.npmjs.org/immutable/-/immutable-3.8.1.tgz",
@@ -4342,22 +4348,14 @@
}
},
"jasmine": {
- "version": "2.6.0",
- "resolved": "https://registry.npmjs.org/jasmine/-/jasmine-2.6.0.tgz",
- "integrity": "sha1-ayLnCIPo5YnUVjRhU7TSBt2+IX8=",
+ "version": "2.8.0",
+ "resolved": "https://registry.npmjs.org/jasmine/-/jasmine-2.8.0.tgz",
+ "integrity": "sha1-awicChFXax8W3xG4AUbZHU6Lij4=",
"dev": true,
"requires": {
"exit": "0.1.2",
"glob": "7.0.6",
- "jasmine-core": "2.6.4"
- },
- "dependencies": {
- "jasmine-core": {
- "version": "2.6.4",
- "resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-2.6.4.tgz",
- "integrity": "sha1-3skmzQqfoof7bbXHVfpIfnTOysU=",
- "dev": true
- }
+ "jasmine-core": "2.8.0"
}
},
"jasmine-core": {
@@ -4367,9 +4365,9 @@
"dev": true
},
"jasminewd2": {
- "version": "2.1.0",
- "resolved": "https://registry.npmjs.org/jasminewd2/-/jasminewd2-2.1.0.tgz",
- "integrity": "sha1-2llSddGuYx3nNqwKfH2Fyfc+9lI=",
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/jasminewd2/-/jasminewd2-2.2.0.tgz",
+ "integrity": "sha1-43zwsX8ZnM4jvqcbIDk5Uka07E4=",
"dev": true
},
"jju": {
@@ -4643,6 +4641,59 @@
"integrity": "sha1-0Hf2glVx+CEy+d/67Vh7QCn+/1c=",
"dev": true
},
+ "jszip": {
+ "version": "3.1.4",
+ "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.1.4.tgz",
+ "integrity": "sha512-z6w8iYIxZ/fcgul0j/OerkYnkomH8BZigvzbxVmr2h5HkZUrPtk2kjYtLkqR9wwQxEP6ecKNoKLsbhd18jfnGA==",
+ "dev": true,
+ "requires": {
+ "core-js": "2.3.0",
+ "es6-promise": "3.0.2",
+ "lie": "3.1.1",
+ "pako": "1.0.6",
+ "readable-stream": "2.0.6"
+ },
+ "dependencies": {
+ "core-js": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.3.0.tgz",
+ "integrity": "sha1-+rg/uwstjchfpjbEudNMdUIMbWU=",
+ "dev": true
+ },
+ "es6-promise": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.0.2.tgz",
+ "integrity": "sha1-AQ1YWEI6XxGJeWZfRkhqlcbuK7Y=",
+ "dev": true
+ },
+ "pako": {
+ "version": "1.0.6",
+ "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz",
+ "integrity": "sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg==",
+ "dev": true
+ },
+ "readable-stream": {
+ "version": "2.0.6",
+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz",
+ "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=",
+ "dev": true,
+ "requires": {
+ "core-util-is": "1.0.2",
+ "inherits": "2.0.3",
+ "isarray": "1.0.0",
+ "process-nextick-args": "1.0.7",
+ "string_decoder": "0.10.31",
+ "util-deprecate": "1.0.2"
+ }
+ },
+ "string_decoder": {
+ "version": "0.10.31",
+ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
+ "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
+ "dev": true
+ }
+ }
+ },
"karma": {
"version": "1.7.1",
"resolved": "https://registry.npmjs.org/karma/-/karma-1.7.1.tgz",
@@ -5162,6 +5213,15 @@
"type-check": "0.3.2"
}
},
+ "lie": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/lie/-/lie-3.1.1.tgz",
+ "integrity": "sha1-mkNrLMd0bKWd56QfpGmz77dr2H4=",
+ "dev": true,
+ "requires": {
+ "immediate": "3.0.6"
+ }
+ },
"limiter": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/limiter/-/limiter-1.1.2.tgz",
@@ -6604,28 +6664,34 @@
"dev": true
},
"protractor": {
- "version": "5.1.2",
- "resolved": "https://registry.npmjs.org/protractor/-/protractor-5.1.2.tgz",
- "integrity": "sha1-myIXQXCaTGLVzVPGqt1UpxE36V8=",
+ "version": "5.2.0",
+ "resolved": "https://registry.npmjs.org/protractor/-/protractor-5.2.0.tgz",
+ "integrity": "sha1-0/ObGV6F81Oa2djLZWCp0rYyl8Q=",
"dev": true,
"requires": {
- "@types/node": "6.0.78",
+ "@types/node": "6.0.90",
"@types/q": "0.0.32",
"@types/selenium-webdriver": "2.53.42",
"blocking-proxy": "0.0.5",
"chalk": "1.1.3",
"glob": "7.0.6",
- "jasmine": "2.6.0",
- "jasminewd2": "2.1.0",
+ "jasmine": "2.8.0",
+ "jasminewd2": "2.2.0",
"optimist": "0.6.1",
"q": "1.4.1",
"saucelabs": "1.3.0",
- "selenium-webdriver": "3.0.1",
+ "selenium-webdriver": "3.6.0",
"source-map-support": "0.4.15",
"webdriver-js-extender": "1.0.0",
"webdriver-manager": "12.0.6"
},
"dependencies": {
+ "adm-zip": {
+ "version": "0.4.7",
+ "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.4.7.tgz",
+ "integrity": "sha1-hgbCy/HEJs6MjsABdER/1Jtur8E=",
+ "dev": true
+ },
"q": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/q/-/q-1.4.1.tgz",
@@ -6633,9 +6699,9 @@
"dev": true
},
"rimraf": {
- "version": "2.6.1",
- "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.1.tgz",
- "integrity": "sha1-wjOOxkPfeht/5cVPqG9XQopV8z0=",
+ "version": "2.6.2",
+ "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz",
+ "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==",
"dev": true,
"requires": {
"glob": "7.0.6"
@@ -6655,7 +6721,7 @@
"minimist": "1.2.0",
"q": "1.4.1",
"request": "2.78.0",
- "rimraf": "2.6.1",
+ "rimraf": "2.6.2",
"semver": "5.3.0",
"xml2js": "0.4.19"
}
@@ -7086,35 +7152,6 @@
"dev": true,
"requires": {
"https-proxy-agent": "1.0.0"
- },
- "dependencies": {
- "agent-base": {
- "version": "2.1.1",
- "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-2.1.1.tgz",
- "integrity": "sha1-1t4Q1a9hMtW9aSQn1G/FOFOQlMc=",
- "dev": true,
- "requires": {
- "extend": "3.0.1",
- "semver": "5.0.3"
- }
- },
- "https-proxy-agent": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-1.0.0.tgz",
- "integrity": "sha1-NffabEjOTdv6JkiRrFk+5f+GceY=",
- "dev": true,
- "requires": {
- "agent-base": "2.1.1",
- "debug": "2.2.0",
- "extend": "3.0.1"
- }
- },
- "semver": {
- "version": "5.0.3",
- "resolved": "https://registry.npmjs.org/semver/-/semver-5.0.3.tgz",
- "integrity": "sha1-d0Zt5YnNXTyV8TiqeLxWmjy10no=",
- "dev": true
- }
}
},
"sax": {
@@ -7134,21 +7171,21 @@
}
},
"selenium-webdriver": {
- "version": "3.0.1",
- "resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-3.0.1.tgz",
- "integrity": "sha1-ot6l2kqX9mcuiefKcnbO+jZRR6c=",
+ "version": "3.6.0",
+ "resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-3.6.0.tgz",
+ "integrity": "sha512-WH7Aldse+2P5bbFBO4Gle/nuQOdVwpHMTL6raL3uuBj/vPG07k6uzt3aiahu352ONBr5xXh0hDlM3LhtXPOC4Q==",
"dev": true,
"requires": {
- "adm-zip": "0.4.7",
- "rimraf": "2.6.1",
+ "jszip": "3.1.4",
+ "rimraf": "2.6.2",
"tmp": "0.0.30",
"xml2js": "0.4.19"
},
"dependencies": {
"rimraf": {
- "version": "2.6.1",
- "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.1.tgz",
- "integrity": "sha1-wjOOxkPfeht/5cVPqG9XQopV8z0=",
+ "version": "2.6.2",
+ "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz",
+ "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==",
"dev": true,
"requires": {
"glob": "7.0.6"
@@ -8217,12 +8254,6 @@
"selenium-webdriver": "2.53.3"
},
"dependencies": {
- "adm-zip": {
- "version": "0.4.4",
- "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.4.4.tgz",
- "integrity": "sha1-ph7VrmkFw66lizplfSUDMJEFJzY=",
- "dev": true
- },
"sax": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/sax/-/sax-0.6.1.tgz",
@@ -8255,7 +8286,7 @@
"dev": true,
"requires": {
"sax": "0.6.1",
- "xmlbuilder": "8.2.2"
+ "xmlbuilder": "9.0.4"
}
}
}
@@ -8445,9 +8476,9 @@
}
},
"xmlbuilder": {
- "version": "8.2.2",
- "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-8.2.2.tgz",
- "integrity": "sha1-aSSGc0ELS6QuGmE2VR0pIjNap3M=",
+ "version": "9.0.4",
+ "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.4.tgz",
+ "integrity": "sha1-UZy0ymhtAFqEINNJbz8MruzKWA8=",
"dev": true
},
"xmlhttprequest-ssl": {
diff --git a/package.json b/package.json
index 7efe834357..db0dc549e6 100644
--- a/package.json
+++ b/package.json
@@ -44,7 +44,7 @@
"load-grunt-tasks": "3.5.2",
"lodash": "4.17.4",
"phantomjs-prebuilt": "2.1.15",
- "protractor": "5.1.2",
+ "protractor": "5.2.0",
"requirejs": "2.3",
"time-grunt": "1.4.0",
"wiredep": "4.0.0",
diff --git a/pom.xml b/pom.xml
index d51830bac8..adbf4e14ef 100755
--- a/pom.xml
+++ b/pom.xml
@@ -5,13 +5,13 @@
spring-boot-starter-parentorg.springframework.boot
- 1.5.7.RELEASE
+ 1.5.8.RELEASEeu.dzhw.fdz.metadatamanagementmetadatamanagement
- 1.0.55
+ 1.0.56warmetadatamanagement
@@ -20,14 +20,14 @@
- 2.5
+ 2.62.63.2.55.5.20.7.91.82.0.4
- 1.1.0.Final
+ 1.2.0.Final2.8.0yyyyMMddHHmmss${java.version}
@@ -35,7 +35,6 @@
3.1.3${project.build.directory}/test-results
- 4.1.4false
@@ -62,10 +61,6 @@
test
-
- com.querydsl
- querydsl-mongodb
- com.ryantenney.metricsmetrics-spring
@@ -124,17 +119,10 @@
io.searchboxjest
-
- net.karneim
- pojobuilder
- 3.6.0
-
- provided
- org.apache.commonscommons-compress
- 1.14
+ 1.15org.apache.logging.log4j
@@ -166,6 +154,11 @@
mongeez0.9.6
+
+ org.projectlombok
+ lombok
+ provided
+ org.springframework.bootspring-boot-actuator
@@ -270,6 +263,11 @@
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.6.1
+ org.codehaus.mojobuild-helper-maven-plugin
@@ -352,31 +350,6 @@
false
-
- com.mysema.maven
- apt-maven-plugin
- 1.1.3
-
-
- generate-sources
-
- process
-
-
- target/generated-sources/annotations
- org.springframework.data.mongodb.repository.support.MongoAnnotationProcessor
- true
-
-
-
-
-
- com.querydsl
- querydsl-apt
- ${querydsl.version}
-
-
- org.apache.maven.plugins
@@ -407,7 +380,6 @@
${maven.compiler.target}
- -proc:none
@@ -472,23 +444,6 @@
alphabetical
-
- org.bsc.maven
- maven-processor-plugin
- 3.3.2
-
-
- process2
- process-sources
-
- process
-
-
- ${project.build.directory}/generated-test-sources
-
-
-
- org.codehaus.mojo
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/Application.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/Application.java
index 04dc65c0f9..33bb515b27 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/Application.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/Application.java
@@ -9,8 +9,6 @@
import javax.annotation.PostConstruct;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -21,16 +19,15 @@
import eu.dzhw.fdz.metadatamanagement.common.config.Constants;
import eu.dzhw.fdz.metadatamanagement.common.config.JHipsterProperties;
import eu.dzhw.fdz.metadatamanagement.common.config.MetadataManagementProperties;
+import lombok.extern.slf4j.Slf4j;
/**
* Main class boostrapping the application.
*/
@SpringBootApplication
@EnableConfigurationProperties({MetadataManagementProperties.class, JHipsterProperties.class})
+@Slf4j
public class Application {
-
- private static final Logger log = LoggerFactory.getLogger(Application.class);
-
@Autowired
private Environment env;
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/common/config/MongoDbConfiguration.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/common/config/MongoDbConfiguration.java
index 33a18138cf..86331ccb09 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/common/config/MongoDbConfiguration.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/common/config/MongoDbConfiguration.java
@@ -9,8 +9,6 @@
import javax.annotation.PreDestroy;
import org.mongeez.Mongeez;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@@ -35,6 +33,7 @@
import com.mongodb.MongoClientOptions;
import eu.dzhw.fdz.metadatamanagement.usermanagement.repository.OAuth2AuthenticationReadConverter;
+import lombok.extern.slf4j.Slf4j;
/**
* Configure the mongo db client instance.
@@ -43,10 +42,8 @@
@Configuration
@EnableMongoRepositories("eu.dzhw.fdz.metadatamanagement.**.repository")
@EnableMongoAuditing(auditorAwareRef = "springSecurityAuditorAware")
+@Slf4j
public class MongoDbConfiguration extends AbstractMongoConfiguration {
-
- private final Logger log = LoggerFactory.getLogger(MongoDbConfiguration.class);
-
private MongoProperties mongoProperties;
private Environment environment;
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/common/config/WebConfigurer.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/common/config/WebConfigurer.java
index e10f906060..47c15621e6 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/common/config/WebConfigurer.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/common/config/WebConfigurer.java
@@ -8,8 +8,6 @@
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
@@ -20,16 +18,15 @@
import eu.dzhw.fdz.metadatamanagement.common.rest.filter.CachingHttpHeadersFilter;
import eu.dzhw.fdz.metadatamanagement.common.rest.filter.StaticResourcesProductionFilter;
+import lombok.extern.slf4j.Slf4j;
/**
* Configuration of web application with Servlet 3.0 APIs.
*/
@Configuration
+@Slf4j
public class WebConfigurer
implements ServletContextInitializer, EmbeddedServletContainerCustomizer {
-
- private final Logger log = LoggerFactory.getLogger(WebConfigurer.class);
-
@Autowired
private Environment env;
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/common/domain/AbstractRdcDomainObject.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/common/domain/AbstractRdcDomainObject.java
index a4fd02c35a..c78a947043 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/common/domain/AbstractRdcDomainObject.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/common/domain/AbstractRdcDomainObject.java
@@ -1,7 +1,6 @@
package eu.dzhw.fdz.metadatamanagement.common.domain;
import java.time.LocalDateTime;
-import java.util.Objects;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
@@ -9,13 +8,14 @@
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.annotation.Version;
-import com.google.common.base.MoreObjects;
+import lombok.Data;
/**
* Base class for all fdz domain objects.
*
* @author René Reitmann
*/
+@Data
public abstract class AbstractRdcDomainObject {
@Version
private Long version;
@@ -33,73 +33,4 @@ public abstract class AbstractRdcDomainObject {
private String lastModifiedBy;
public abstract String getId();
-
- public Long getVersion() {
- return version;
- }
-
- public void setVersion(Long version) {
- this.version = version;
- }
-
- public LocalDateTime getCreatedDate() {
- return createdDate;
- }
-
- public void setCreatedDate(LocalDateTime createdDate) {
- this.createdDate = createdDate;
- }
-
- public String getCreatedBy() {
- return createdBy;
- }
-
- public void setCreatedBy(String createdBy) {
- this.createdBy = createdBy;
- }
-
- public LocalDateTime getLastModifiedDate() {
- return lastModifiedDate;
- }
-
- public void setLastModifiedDate(LocalDateTime lastModifiedDate) {
- this.lastModifiedDate = lastModifiedDate;
- }
-
- public String getLastModifiedBy() {
- return lastModifiedBy;
- }
-
- public void setLastModifiedBy(String lastModifiedBy) {
- this.lastModifiedBy = lastModifiedBy;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(this.getId());
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object == null || getClass() != object.getClass()) {
- return false;
- }
- AbstractRdcDomainObject domainObject = (AbstractRdcDomainObject) object;
- return Objects.equals(this.getId(), domainObject.getId());
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("id", this.getId())
- .add("version", version)
- .add("createdDate", createdDate)
- .add("createdBy", createdBy)
- .add("lastModifiedDate", lastModifiedDate)
- .add("lastModifiedBy", lastModifiedBy)
- .toString();
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/common/domain/I18nString.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/common/domain/I18nString.java
index 0e608b69b4..d1585379ad 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/common/domain/I18nString.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/common/domain/I18nString.java
@@ -1,8 +1,9 @@
package eu.dzhw.fdz.metadatamanagement.common.domain;
-import java.io.Serializable;
-
-import net.karneim.pojobuilder.GeneratePojoBuilder;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
/**
* Class representing Strings that can be internationalized.
@@ -10,96 +11,12 @@
* @author René Reitmann
* @author Daniel Katzberg
*/
-@GeneratePojoBuilder(intoPackage = "eu.dzhw.fdz.metadatamanagement.common.domain.builders")
-public class I18nString implements Serializable {
- private static final long serialVersionUID = 3035702867033098482L;
-
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class I18nString {
private String de;
private String en;
-
- /**
- * Default Constructor.
- */
- public I18nString() {}
-
- /**
- * A constructor with the possibility to set the german and english translation.
- *
- * @param de German translation
- * @param en English translation.
- */
- public I18nString(String de, String en) {
- this.de = de;
- this.en = en;
- }
-
- /**
- * German version of the string.
- *
- * @return the german version of the string.
- */
- public String getDe() {
- return de;
- }
-
- public void setDe(String de) {
- this.de = de;
- }
-
- /**
- * English version of the string.
- *
- * @return the english version of the string.
- */
- public String getEn() {
- return en;
- }
-
- public void setEn(String en) {
- this.en = en;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((de == null) ? 0 : de.hashCode());
- result = prime * result + ((en == null) ? 0 : en.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- I18nString other = (I18nString) obj;
- if (de == null) {
- if (other.de != null) {
- return false;
- }
- } else if (!de.equals(other.de)) {
- return false;
- }
- if (en == null) {
- if (other.en != null) {
- return false;
- }
- } else if (!en.equals(other.en)) {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- return "I18nString{de='" + de + "', en='" + en + "'}";
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/common/domain/Period.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/common/domain/Period.java
index 0acf84edf9..3f80992339 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/common/domain/Period.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/common/domain/Period.java
@@ -4,15 +4,21 @@
import java.time.LocalDate;
import eu.dzhw.fdz.metadatamanagement.common.domain.validation.ValidPeriod;
-import net.karneim.pojobuilder.GeneratePojoBuilder;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
/**
* Class representing period in time.
*
* @author René Reitmann
*/
-@GeneratePojoBuilder(intoPackage = "eu.dzhw.fdz.metadatamanagement.common.domain.builders")
@ValidPeriod(message = "global.error.period.valid-period")
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class Period implements Serializable {
private static final long serialVersionUID = -4040296722435163942L;
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/common/domain/Person.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/common/domain/Person.java
index d4c5aeaa60..68979a1a2e 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/common/domain/Person.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/common/domain/Person.java
@@ -2,9 +2,10 @@
import org.hibernate.validator.constraints.NotEmpty;
-import com.google.common.base.MoreObjects;
-
-import net.karneim.pojobuilder.GeneratePojoBuilder;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
/**
* A representation of a person.
@@ -12,7 +13,10 @@
* @author Daniel Katzberg
*
*/
-@GeneratePojoBuilder(intoPackage = "eu.dzhw.fdz.metadatamanagement.common.domain.builders")
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class Person {
@NotEmpty(message = "global.error.person.first-name.not-empty")
@@ -22,42 +26,4 @@ public class Person {
@NotEmpty(message = "global.error.person.last-name.not-empty")
private String lastName;
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("firstName", firstName)
- .add("middleName", middleName)
- .add("lastName", lastName)
- .toString();
- }
-
- /* GETTER / SETTER */
- public String getFirstName() {
- return firstName;
- }
-
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
-
- public String getMiddleName() {
- return middleName;
- }
-
- public void setMiddleName(String middleName) {
- this.middleName = middleName;
- }
-
- public String getLastName() {
- return lastName;
- }
-
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/common/repository/BaseRepository.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/common/repository/BaseRepository.java
index d5dc174fc2..38c20932d8 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/common/repository/BaseRepository.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/common/repository/BaseRepository.java
@@ -4,7 +4,6 @@
import java.util.List;
import org.springframework.data.mongodb.repository.MongoRepository;
-import org.springframework.data.querydsl.QueryDslPredicateExecutor;
import org.springframework.data.repository.NoRepositoryBean;
import org.springframework.security.access.annotation.Secured;
@@ -21,7 +20,7 @@
*/
@NoRepositoryBean
public interface BaseRepository
- extends MongoRepository, QueryDslPredicateExecutor {
+ extends MongoRepository {
@Override
@Secured(AuthoritiesConstants.PUBLISHER)
void delete(T entity);
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/common/rest/errors/ExceptionTranslator.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/common/rest/errors/ExceptionTranslator.java
index 8fa757c729..b56b3dbd29 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/common/rest/errors/ExceptionTranslator.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/common/rest/errors/ExceptionTranslator.java
@@ -27,18 +27,20 @@
import com.fasterxml.jackson.databind.node.TreeTraversingParser;
import eu.dzhw.fdz.metadatamanagement.datasetmanagement.exception.TemplateIncompleteException;
+import freemarker.core.InvalidReferenceException;
+import freemarker.core.ParseException;
import freemarker.template.TemplateException;
/**
* Controller advice to translate the server side exceptions to client-friendly json structures.
- *
+ *
* @author Daniel Katzberg
*/
@ControllerAdvice
public class ExceptionTranslator {
private MessageSourceAccessor messageSourceAccessor;
-
+
@Autowired
public ExceptionTranslator(MessageSource messageSource) {
this.messageSourceAccessor = new MessageSourceAccessor(messageSource);
@@ -56,27 +58,27 @@ public ErrorListDto processValidationError(MethodArgumentNotValidException ex) {
List fieldErrors = result.getFieldErrors();
return processFieldErrors(globalErrors, fieldErrors);
}
-
- private ErrorListDto processFieldErrors(List globalErrors,
+
+ private ErrorListDto processFieldErrors(List globalErrors,
List fieldErrors) {
-
+
ErrorListDto errorListDto = new ErrorListDto();
//handle global errors
for (ObjectError globalError: globalErrors) {
- errorListDto.add(new ErrorDto(globalError.getObjectName(),
+ errorListDto.add(new ErrorDto(globalError.getObjectName(),
globalError.getDefaultMessage(), null, null));
}
-
+
//handle field errors
for (FieldError fieldError : fieldErrors) {
String rejectedValue = null;
-
+
if (fieldError.getRejectedValue() != null) {
rejectedValue = fieldError.getRejectedValue().toString();
}
-
- errorListDto.add(new ErrorDto(fieldError.getObjectName(), fieldError.getDefaultMessage(),
+
+ errorListDto.add(new ErrorDto(fieldError.getObjectName(), fieldError.getDefaultMessage(),
rejectedValue, fieldError.getField()));
}
@@ -84,7 +86,48 @@ private ErrorListDto processFieldErrors(List globalErrors,
}
/**
- * Handler for wrapping exceptions which occur when an unparsable json or excel file
+ * Handle Freemarker parsing errors.
+ */
+ @ExceptionHandler(ParseException.class)
+ @ResponseStatus(HttpStatus.BAD_REQUEST)
+ @ResponseBody
+ public ErrorListDto processFreemarkerParseError(ParseException ex) {
+
+ //Build ErrorDto
+ String invalidValue = "(" + ex.getLineNumber()
+ + "," + ex.getColumnNumber() + "): " + ex.getEditorMessage();
+ ErrorDto errorDto = new ErrorDto(ex.getTemplateName(),
+ "global.error.server-error.freemarker.parsing-error", invalidValue, null);
+
+ //Build ErrorListDto
+ ErrorListDto errorListDto = new ErrorListDto();
+ errorListDto.add(errorDto);
+ return errorListDto;
+ }
+
+ /**
+ * Handle Freemarker invalid reference errors.
+ */
+ @ExceptionHandler(InvalidReferenceException.class)
+ @ResponseStatus(HttpStatus.BAD_REQUEST)
+ @ResponseBody
+ public ErrorListDto processFreemarkerParseError(InvalidReferenceException ex) {
+
+ //Build ErrorDto
+ String invalidValue = "(" + ex.getLineNumber() + ","
+ + ex.getColumnNumber() + "): " + ex.getBlamedExpressionString();
+ ErrorDto errorDto = new ErrorDto(ex.getTemplateSourceName(),
+ "global.error.server-error.freemarker.invalid-reference-error", invalidValue, null);
+
+ //Build ErrorListDto
+ ErrorListDto errorListDto = new ErrorListDto();
+ errorListDto.add(errorDto);
+ return errorListDto;
+ }
+
+
+ /**
+ * Handler for wrapping exceptions which occur when an unparsable json or excel file
* is send by the client.
*/
@ExceptionHandler(HttpMessageNotReadableException.class)
@@ -92,20 +135,20 @@ private ErrorListDto processFieldErrors(List globalErrors,
@ResponseStatus(HttpStatus.BAD_REQUEST)
public ErrorListDto processHttpMessageNotReadableException(
HttpMessageNotReadableException exception) {
-
- InvalidFormatException invalidFormatException =
+
+ InvalidFormatException invalidFormatException =
findInvalidFormatException(exception.getCause());
-
+
JsonMappingException jsonMappingException =
findJsonMappingException(exception.getCause());
-
+
if (invalidFormatException != null) {
return createParsingError(invalidFormatException);
- //Default message, if no other root cause was found
- } else if (jsonMappingException != null) {
+ //Default message, if no other root cause was found
+ } else if (jsonMappingException != null) {
return createJsonMappingError(jsonMappingException);
} else {
- String errorMessage;
+ String errorMessage;
if (exception.getRootCause() != null) {
errorMessage = exception.getRootCause()
.getLocalizedMessage();
@@ -113,10 +156,10 @@ public ErrorListDto processHttpMessageNotReadableException(
errorMessage = exception.getLocalizedMessage();
}
return new ErrorListDto(new ErrorDto(null, errorMessage, null, null));
-
+
}
}
-
+
private InvalidFormatException findInvalidFormatException(Throwable cause) {
if (cause == null || cause instanceof InvalidFormatException) {
return (InvalidFormatException) cause;
@@ -124,7 +167,7 @@ private InvalidFormatException findInvalidFormatException(Throwable cause) {
return findInvalidFormatException(cause.getCause());
}
}
-
+
private JsonMappingException findJsonMappingException(Throwable cause) {
if (cause == null || cause instanceof JsonMappingException) {
return (JsonMappingException) cause;
@@ -132,12 +175,12 @@ private JsonMappingException findJsonMappingException(Throwable cause) {
return findJsonMappingException(cause.getCause());
}
}
-
- private ErrorListDto createParsingError(InvalidFormatException invalidFormatException) {
-
+
+ private ErrorListDto createParsingError(InvalidFormatException invalidFormatException) {
+
//Get the Name of the Processor
String nameOfProcessor = invalidFormatException.getProcessor().getClass().getSimpleName();
-
+
//Decide between different input types like excel or json files
switch (nameOfProcessor) {
//Excel Parsing Error
@@ -150,32 +193,32 @@ private ErrorListDto createParsingError(InvalidFormatException invalidFormatExce
return new ErrorListDto();
}
}
-
+
private ErrorListDto createExcelParsingError(InvalidFormatException invalidFormatException) {
- TreeTraversingParser processor =
- (TreeTraversingParser) invalidFormatException.getProcessor();
-
- //Create Excel Parsing Error. Just the first will be returned
- String domainObject = invalidFormatException.getPath().get(0).getFrom()
- .getClass().getSimpleName();
+ TreeTraversingParser processor =
+ (TreeTraversingParser) invalidFormatException.getProcessor();
+
+ //Create Excel Parsing Error. Just the first will be returned
+ String domainObject = ((Class>) invalidFormatException.getPath().get(0).getFrom())
+ .getSimpleName();
String property = processor.getCurrentName();
if (property == null) {
property = invalidFormatException.getPath().get(0).getFieldName();
}
String invalidValue = (String)invalidFormatException.getValue();
String messageKey = "global.error.import.excel-parsing-error";
- return new ErrorListDto(new ErrorDto(domainObject, messageKey,invalidValue, property));
+ return new ErrorListDto(new ErrorDto(domainObject, messageKey,invalidValue, property));
}
-
+
private ErrorListDto createJsonParsingError(InvalidFormatException invalidFormatException) {
- UTF8StreamJsonParser processor =
- (UTF8StreamJsonParser) invalidFormatException.getProcessor();
-
+ UTF8StreamJsonParser processor =
+ (UTF8StreamJsonParser) invalidFormatException.getProcessor();
+
//Create Json Parsing Error. Just the first will be returned
try {
+ String domainObject = ((Class>) invalidFormatException.getPath().get(0).getFrom())
+ .getSimpleName();
- String domainObject = invalidFormatException.getPath().get(0).getFrom()
- .getClass().getSimpleName();
String property = processor.getCurrentName();
if (property == null) {
property = invalidFormatException.getPath().get(0).getFieldName();
@@ -188,22 +231,22 @@ private ErrorListDto createJsonParsingError(InvalidFormatException invalidFormat
new ErrorDto(null, "global.error.import.no-json-mapping", null, null));
}
}
-
+
private ErrorListDto createJsonMappingError(JsonMappingException jsonMappingException) {
-
+
String invalidField = jsonMappingException.getPath()
.stream()
.map(i -> i.getFieldName())
.collect(Collectors.joining("."));
-
+
return new ErrorListDto(
new ErrorDto(null, "global.error.import.json-not-readable", invalidField, null));
}
-
+
/**
* Handles {@link RepositoryConstraintViolationException}s by returning {@code 400 Bad Request}.
* Introduces a custom dto for validation errors of spring data rest repositories.
- * This is necessary due to issue #706.
+ * This is necessary due to issue #706.
* @param exception the exception to handle.
* @return 400 bad request
*/
@@ -212,14 +255,14 @@ private ErrorListDto createJsonMappingError(JsonMappingException jsonMappingExce
@ResponseStatus(HttpStatus.BAD_REQUEST)
ErrorListDto handleRepositoryConstraintViolationException(
RepositoryConstraintViolationException exception) {
-
+
ErrorListDto errorListDto = new ErrorListDto();
-
+
for (ObjectError globalError : exception.getErrors().getGlobalErrors()) {
String message = this.messageSourceAccessor.getMessage(globalError);
errorListDto.add(new ErrorDto(globalError.getObjectName(), message, null, null));
}
-
+
for (FieldError fieldError : exception.getErrors()
.getFieldErrors()) {
@@ -228,12 +271,12 @@ ErrorListDto handleRepositoryConstraintViolationException(
errorListDto.add(new ErrorDto(fieldError.getObjectName(), message,
String.format("%s", fieldError.getRejectedValue()), fieldError.getField()));
}
-
+
return errorListDto;
}
-
+
/**
- * Handles the Dataset Report Template exception. This exception will be thrown,
+ * Handles the Dataset Report Template exception. This exception will be thrown,
* if something gone wrong on creating latex code by the given freemarker code.
* @param exception The exception by the template handling.
* @return 400 Bad Request and the error message.
@@ -242,18 +285,18 @@ ErrorListDto handleRepositoryConstraintViolationException(
@ResponseBody
@ResponseStatus(HttpStatus.BAD_REQUEST)
ErrorListDto handleTemplateException(TemplateException exception) {
-
+
//The message of the exception is the error message of freemarker.
//The manually added message for the dto can be translated into i18n strings
String messageKey = "data-set-management.error.tex-template-error";
ErrorListDto errorListDto = new ErrorListDto(
new ErrorDto(null, messageKey, exception.getMessage(), null));
-
+
return errorListDto;
}
-
+
/**
- * Handles the Dataset Report Template incomplete exception. This exception will be thrown,
+ * Handles the Dataset Report Template incomplete exception. This exception will be thrown,
* if the uploaded tex template files are incomplete and files are missing.
* @param exception The incomplete tex template exception to handle.
* @return 400 Bad Request and a list of missing files within the exception.
@@ -263,30 +306,30 @@ ErrorListDto handleTemplateException(TemplateException exception) {
@ResponseStatus(HttpStatus.BAD_REQUEST)
ErrorListDto handleIncompleteTemplateException(TemplateIncompleteException exception) {
ErrorListDto errorListDto = new ErrorListDto();
-
+
//All missing files
for (String missingFile : exception.getMissingFiles()) {
errorListDto.add(new ErrorDto(null, exception.getMessage(), missingFile, null));
}
-
+
return errorListDto;
}
-
+
@ExceptionHandler
@ResponseBody
@ResponseStatus(HttpStatus.BAD_REQUEST)
ErrorListDto handleMultipartException(MultipartException exception) {
- FileSizeLimitExceededException fileSizeException =
+ FileSizeLimitExceededException fileSizeException =
findFileSizeLimitExceededException(exception);
if (fileSizeException != null) {
- return new ErrorListDto(new ErrorDto(fileSizeException.getFileName(),
+ return new ErrorListDto(new ErrorDto(fileSizeException.getFileName(),
"global.error.import.file-size-limit-exceeded",
String.valueOf(fileSizeException.getActualSize()), null));
}
- // return the message as it is
+ // return the message as it is
return new ErrorListDto(new ErrorDto(null, exception.getLocalizedMessage(), null, null));
}
-
+
private FileSizeLimitExceededException findFileSizeLimitExceededException(Throwable exception) {
if (exception == null || exception instanceof FileSizeLimitExceededException) {
return (FileSizeLimitExceededException) exception;
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/common/websocket/WebSocketConnectionListener.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/common/websocket/WebSocketConnectionListener.java
index d76cac48a4..4191cd2d5f 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/common/websocket/WebSocketConnectionListener.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/common/websocket/WebSocketConnectionListener.java
@@ -2,8 +2,6 @@
import java.time.LocalDateTime;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
@@ -15,6 +13,7 @@
import eu.dzhw.fdz.metadatamanagement.common.config.WebSocketConfig;
import eu.dzhw.fdz.metadatamanagement.common.websocket.domain.ActiveWebsocketSession;
import eu.dzhw.fdz.metadatamanagement.common.websocket.repository.ActiveWebSocketSessionRepository;
+import lombok.extern.slf4j.Slf4j;
/**
* Listener logging new and closed web socket connections.
@@ -22,6 +21,7 @@
* @author René Reitmann
*/
@Component
+@Slf4j
public class WebSocketConnectionListener {
private static final String BROWSER = "browser";
@@ -31,8 +31,6 @@ public class WebSocketConnectionListener {
@Autowired
private ActiveWebSocketSessionRepository activeWebSocketSessionRepository;
-
- private final Logger log = LoggerFactory.getLogger(WebSocketConnectionListener.class);
/**
* React on new web socket connections.
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/domain/DataSet.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/domain/DataSet.java
index c9ee4f7160..af0dfdfb79 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/domain/DataSet.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/domain/DataSet.java
@@ -14,8 +14,6 @@
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
-import com.google.common.base.MoreObjects;
-
import eu.dzhw.fdz.metadatamanagement.common.domain.AbstractRdcDomainObject;
import eu.dzhw.fdz.metadatamanagement.common.domain.I18nString;
import eu.dzhw.fdz.metadatamanagement.common.domain.util.Patterns;
@@ -27,7 +25,12 @@
import eu.dzhw.fdz.metadatamanagement.datasetmanagement.domain.validation.ValidDataSetType;
import eu.dzhw.fdz.metadatamanagement.datasetmanagement.domain.validation.ValidFormat;
import io.searchbox.annotations.JestId;
-import net.karneim.pojobuilder.GeneratePojoBuilder;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
/**
* Data Set.
@@ -36,12 +39,16 @@
*
*/
@Document(collection = "data_sets")
-@GeneratePojoBuilder(
- intoPackage = "eu.dzhw.fdz.metadatamanagement.datasetmanagement.domain.builders")
@ValidDataSetIdName(message = "data-set-management.error.data-set.id.valid-data-set-id-name")
@UniqueDatasetNumberInProject(
message = "data-set-management.error.data-set.unique-data-set-number-in-project")
@CompoundIndex(def = "{number: 1, dataAcquisitionProjectId: 1}", unique = true)
+@Data
+@EqualsAndHashCode(callSuper = false, of = "id")
+@ToString(callSuper = true)
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class DataSet extends AbstractRdcDomainObject {
@Id
@@ -93,123 +100,8 @@ public class DataSet extends AbstractRdcDomainObject {
+ "sub-data-sets.access-way-unique-within-data-set")
private List subDataSets;
- public DataSet() {
- super();
- }
-
public DataSet(DataSet dataSet) {
super();
BeanUtils.copyProperties(dataSet, this);
}
-
- @Override
- public String getId() {
- return this.id;
- }
-
- public String getDataAcquisitionProjectId() {
- return dataAcquisitionProjectId;
- }
-
- public void setDataAcquisitionProjectId(String dataAcquisitionProjectId) {
- this.dataAcquisitionProjectId = dataAcquisitionProjectId;
- }
-
- public I18nString getDescription() {
- return description;
- }
-
- public void setDescription(I18nString description) {
- this.description = description;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public Integer getNumber() {
- return number;
- }
-
- public void setNumber(Integer number) {
- this.number = number;
- }
-
- public I18nString getFormat() {
- return format;
- }
-
- public void setFormat(I18nString format) {
- this.format = format;
- }
-
- /*
- * (non-Javadoc)
- * @see eu.dzhw.fdz.metadatamanagement.common.domain.AbstractRdcDomainObject#toString()
- */
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("super", super.toString())
- .add("id", id)
- .add("description", description)
- .add("type", type)
- .add("surveyNumbers", surveyNumbers)
- .add("number", number)
- .add("format", format)
- .add("dataAcquisitionProjectId", dataAcquisitionProjectId)
- .add("studyId", studyId)
- .add("surveyIds", surveyIds)
- .add("subDataSets", subDataSets)
- .add("annotations", annotations)
- .toString();
- }
-
- public I18nString getType() {
- return type;
- }
-
- public void setType(I18nString type) {
- this.type = type;
- }
-
- public List getSurveyNumbers() {
- return surveyNumbers;
- }
-
- public void setSurveyNumbers(List surveyNumbers) {
- this.surveyNumbers = surveyNumbers;
- }
-
- public List getSurveyIds() {
- return surveyIds;
- }
-
- public void setSurveyIds(List surveyIds) {
- this.surveyIds = surveyIds;
- }
-
- public List getSubDataSets() {
- return subDataSets;
- }
-
- public void setSubDataSets(List subDataSets) {
- this.subDataSets = subDataSets;
- }
-
- public String getStudyId() {
- return studyId;
- }
-
- public void setStudyId(String studyId) {
- this.studyId = studyId;
- }
-
- public I18nString getAnnotations() {
- return annotations;
- }
-
- public void setAnnotations(I18nString annotations) {
- this.annotations = annotations;
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/domain/DataSetAttachmentMetadata.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/domain/DataSetAttachmentMetadata.java
index bf9b256327..22966475b1 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/domain/DataSetAttachmentMetadata.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/domain/DataSetAttachmentMetadata.java
@@ -11,14 +11,23 @@
import eu.dzhw.fdz.metadatamanagement.common.domain.validation.I18nStringSize;
import eu.dzhw.fdz.metadatamanagement.common.domain.validation.StringLengths;
import eu.dzhw.fdz.metadatamanagement.common.domain.validation.ValidIsoLanguage;
-import net.karneim.pojobuilder.GeneratePojoBuilder;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
/**
* Metadata which will be stored in GridFS with each attachment for data sets.
*
*/
-@GeneratePojoBuilder(
- intoPackage = "eu.dzhw.fdz.metadatamanagement.datasetmanagement.domain.builders")
+@Data
+@EqualsAndHashCode(callSuper = false, of = "id")
+@ToString(callSuper = true)
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class DataSetAttachmentMetadata extends AbstractRdcDomainObject {
@NotEmpty(message =
"data-set-management.error.data-set-attachment-metadata.data-set-id.not-empty")
@@ -64,69 +73,4 @@ public class DataSetAttachmentMetadata extends AbstractRdcDomainObject {
public String getId() {
return "/public/files/data-sets/" + dataSetId + "/attachments/" + fileName;
}
-
- /* GETTER / SETTER */
- public String getDataSetId() {
- return dataSetId;
- }
-
- public String getDataAcquisitionProjectId() {
- return dataAcquisitionProjectId;
- }
-
- public I18nString getDescription() {
- return description;
- }
-
- public String getTitle() {
- return title;
- }
-
- public String getLanguage() {
- return language;
- }
-
- public String getFileName() {
- return fileName;
- }
-
- public Integer getDataSetNumber() {
- return dataSetNumber;
- }
-
- public void setDataSetId(String dataSetId) {
- this.dataSetId = dataSetId;
- }
-
- public void setDataAcquisitionProjectId(String dataAcquisitionProjectId) {
- this.dataAcquisitionProjectId = dataAcquisitionProjectId;
- }
-
- public void setDescription(I18nString description) {
- this.description = description;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public void setLanguage(String language) {
- this.language = language;
- }
-
- public void setFileName(String fileName) {
- this.fileName = fileName;
- }
-
- public void setDataSetNumber(Integer dataSetNumber) {
- this.dataSetNumber = dataSetNumber;
- }
-
- public Integer getIndexInDataSet() {
- return indexInDataSet;
- }
-
- public void setIndexInDataSet(Integer indexInDataSet) {
- this.indexInDataSet = indexInDataSet;
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/domain/SubDataSet.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/domain/SubDataSet.java
index d38d1d0e20..e26075bb32 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/domain/SubDataSet.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/domain/SubDataSet.java
@@ -10,14 +10,19 @@
import eu.dzhw.fdz.metadatamanagement.common.domain.validation.I18nStringSize;
import eu.dzhw.fdz.metadatamanagement.common.domain.validation.StringLengths;
import eu.dzhw.fdz.metadatamanagement.datasetmanagement.domain.validation.ValidAccessWay;
-import net.karneim.pojobuilder.GeneratePojoBuilder;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
/**
* Domain object of the SubDataSet.
*
*/
-@GeneratePojoBuilder(
- intoPackage = "eu.dzhw.fdz.metadatamanagement.datasetmanagement.domain.builders")
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class SubDataSet {
@NotEmpty(message = "data-set-management.error.sub-data-set.name.not-empty")
@@ -41,54 +46,4 @@ public class SubDataSet {
@I18nStringSize(max = StringLengths.LARGE,
message = "data-set-management.error.sub-data-set.citation-hint.i18n-string-size")
private I18nString citationHint;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public int getNumberOfObservations() {
- return numberOfObservations;
- }
-
- public void setNumberOfObservations(int numberOfObservations) {
- this.numberOfObservations = numberOfObservations;
- }
-
- public String getAccessWay() {
- return accessWay;
- }
-
- public void setAccessWay(String accessWay) {
- this.accessWay = accessWay;
- }
-
- public I18nString getDescription() {
- return description;
- }
-
- public void setDescription(I18nString description) {
- this.description = description;
- }
-
- public I18nString getCitationHint() {
- return citationHint;
- }
-
- public void setCitationHint(I18nString citationHint) {
- this.citationHint = citationHint;
- }
-
- @Override
- public String toString() {
- return "SubDataSet [name=" + name + ", numberOfObservations=" + numberOfObservations
- + ", accessWay=" + accessWay + ", description=" + description + ", citationHint="
- + citationHint + "]";
- }
-
-
-
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/service/DataSetReportService.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/service/DataSetReportService.java
index 17bb21322b..ef812d248a 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/service/DataSetReportService.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/service/DataSetReportService.java
@@ -152,10 +152,12 @@ public String generateReport(MultipartFile multiPartFile,
// Load data for template only once
Map dataForTemplate = this.loadDataForTemplateFilling(dataSetId);
String variableListFilledStr =
- this.fillTemplate(texVariableListFileStr, templateConfiguration, dataForTemplate);
+ this.fillTemplate(texVariableListFileStr, templateConfiguration, dataForTemplate,
+ KEY_VARIABLELIST);
ZipUtil.writeFileToZip(pathToVariableListTexFile, variableListFilledStr);
String mainFilledStr =
- this.fillTemplate(texMainFileStr, templateConfiguration, dataForTemplate);
+ this.fillTemplate(texMainFileStr, templateConfiguration, dataForTemplate,
+ KEY_MAIN);
ZipUtil.writeFileToZip(pathToMainTexFile, mainFilledStr);
// Create Variables pages
@@ -167,7 +169,8 @@ public String generateReport(MultipartFile multiPartFile,
//filledTemplates.put("variables/" + variable.getName() + ".tex",
dataForTemplate.put("variable", variable);
String filledVariablesFile =
- fillTemplate(texVariableFileStr, templateConfiguration, dataForTemplate);
+ fillTemplate(texVariableFileStr, templateConfiguration, dataForTemplate,
+ KEY_VARIABLE);
Path pathOfVariable = Paths.get("variables/" + variable.getName() + ".tex");
final Path root = zipFileSystem.getPath("/");
final Path dest = zipFileSystem.getPath(root.toString(), pathOfVariable.toString());
@@ -220,16 +223,25 @@ private List validateDataSetReportStructure(FileSystem zipFileSystem) {
* @param templateConfiguration The configuration for freemarker.
* @param dataForTemplateThe data for a tex template. All variables, questions and dataset
* information.
+ * @param fileName filename of the script which will be filled in this method.
* @return The filled tex templates as byte array.
* @throws IOException Handles IO Exception.
* @throws TemplateException Handles template Exceptions.
*/
private String fillTemplate(String templateContent,
- Configuration templateConfiguration, Map dataForTemplate)
+ Configuration templateConfiguration, Map dataForTemplate,
+ String fileName)
throws IOException, TemplateException {
+
+ String templateName = "texTemplate";
+ if (fileName != null && fileName.trim().length() > 0 ) {
+ templateName = fileName;
+ }
+
// Read Template and escape elements
- Template texTemplate = new Template("texTemplate",
- (ESCAPE_PREFIX + templateContent + ESCAPE_SUFFIX), templateConfiguration);
+ Template texTemplate = new Template(templateName,
+ (ESCAPE_PREFIX + templateContent + ESCAPE_SUFFIX), templateConfiguration);
+
try (Writer stringWriter = new StringWriter()) {
texTemplate.process(dataForTemplate, stringWriter);
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/domain/Instrument.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/domain/Instrument.java
index fcc8bb87a9..416f5e75ae 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/domain/Instrument.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/domain/Instrument.java
@@ -13,8 +13,6 @@
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
-import com.google.common.base.MoreObjects;
-
import eu.dzhw.fdz.metadatamanagement.common.domain.AbstractRdcDomainObject;
import eu.dzhw.fdz.metadatamanagement.common.domain.I18nString;
import eu.dzhw.fdz.metadatamanagement.common.domain.util.Patterns;
@@ -25,7 +23,12 @@
import eu.dzhw.fdz.metadatamanagement.instrumentmanagement.domain.validation.ValidInstrumentType;
import eu.dzhw.fdz.metadatamanagement.instrumentmanagement.domain.validation.ValidUniqueInstrumentNumber;
import io.searchbox.annotations.JestId;
-import net.karneim.pojobuilder.GeneratePojoBuilder;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
/**
* A Instrument.
@@ -34,13 +37,17 @@
*
*/
@Document(collection = "instruments")
-@GeneratePojoBuilder(
- intoPackage = "eu.dzhw.fdz.metadatamanagement.instrumentmanagement.domain.builders")
@ValidInstrumentIdPattern(message = "instrument-management.error"
+ ".instrument.valid-instrument-id-pattern")
@ValidUniqueInstrumentNumber(message = "instrument-management.error"
+ ".instrument.unique-instrument-number")
@CompoundIndex(def = "{number: 1, dataAcquisitionProjectId: 1}", unique = true)
+@Data
+@EqualsAndHashCode(callSuper = false, of = "id")
+@ToString(callSuper = true)
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class Instrument extends AbstractRdcDomainObject {
@Id
@@ -95,124 +102,8 @@ public class Instrument extends AbstractRdcDomainObject {
@NotEmpty(message = "instrument-management.error.instrument.study-id.not-empty")
private String studyId;
- public Instrument() {
- super();
- }
-
public Instrument(Instrument instrument) {
super();
BeanUtils.copyProperties(instrument, this);
}
-
- @Override
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getDataAcquisitionProjectId() {
- return dataAcquisitionProjectId;
- }
-
- public void setDataAcquisitionProjectId(String dataAcquisitionProjectId) {
- this.dataAcquisitionProjectId = dataAcquisitionProjectId;
- }
-
- public I18nString getTitle() {
- return title;
- }
-
- public void setTitle(I18nString title) {
- this.title = title;
- }
-
- public I18nString getDescription() {
- return description;
- }
-
- public void setDescription(I18nString description) {
- this.description = description;
- }
-
- public Integer getNumber() {
- return number;
- }
-
- public void setNumber(Integer number) {
- this.number = number;
- }
-
- /*
- * (non-Javadoc)
- * @see eu.dzhw.fdz.metadatamanagement.common.domain.AbstractRdcDomainObject#toString()
- */
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("super", super.toString())
- .add("id", id)
- .add("title", title)
- .add("subtitle", subtitle)
- .add("description", description)
- .add("type", type)
- .add("dataAcquisitionProjectId", dataAcquisitionProjectId)
- .add("surveyIds", surveyIds)
- .add("surveyNumbers", surveyNumbers)
- .add("number", number)
- .add("annotations", annotations)
- .add("studyId", studyId)
- .toString();
- }
-
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public List getSurveyIds() {
- return surveyIds;
- }
-
- public void setSurveyIds(List surveyIds) {
- this.surveyIds = surveyIds;
- }
-
- public List getSurveyNumbers() {
- return surveyNumbers;
- }
-
- public void setSurveyNumbers(List surveyNumbers) {
- this.surveyNumbers = surveyNumbers;
- }
-
- public String getStudyId() {
- return studyId;
- }
-
- public void setStudyId(String studyId) {
- this.studyId = studyId;
- }
-
- public I18nString getAnnotations() {
- return annotations;
- }
-
- public void setAnnotations(I18nString annotations) {
- this.annotations = annotations;
- }
-
- public I18nString getSubtitle() {
- return subtitle;
- }
-
- public void setSubtitle(I18nString subtitle) {
- this.subtitle = subtitle;
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/domain/InstrumentAttachmentMetadata.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/domain/InstrumentAttachmentMetadata.java
index c408b98c5e..2e196bf9b0 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/domain/InstrumentAttachmentMetadata.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/domain/InstrumentAttachmentMetadata.java
@@ -11,15 +11,24 @@
import eu.dzhw.fdz.metadatamanagement.common.domain.validation.StringLengths;
import eu.dzhw.fdz.metadatamanagement.common.domain.validation.ValidIsoLanguage;
import eu.dzhw.fdz.metadatamanagement.instrumentmanagement.domain.validation.ValidInstrumentAttachmentType;
-import net.karneim.pojobuilder.GeneratePojoBuilder;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
/**
* Metadata which will be stored in GridFS with each attachment for instruments.
*
* @author René Reitmann
*/
-@GeneratePojoBuilder(
- intoPackage = "eu.dzhw.fdz.metadatamanagement.instrumentmanagement.domain.builders")
+@Data
+@EqualsAndHashCode(callSuper = false, of = "id")
+@ToString(callSuper = true)
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class InstrumentAttachmentMetadata extends AbstractRdcDomainObject {
@NotEmpty(message =
"instrument-management.error.instrument-attachment-metadata.instrument-id.not-empty")
@@ -63,72 +72,8 @@ public class InstrumentAttachmentMetadata extends AbstractRdcDomainObject {
"instrument-management.error.instrument-attachment-metadata.index-in-instrument.not-null")
private Integer indexInInstrument;
- public String getInstrumentId() {
- return instrumentId;
- }
-
- public void setInstrumentId(String instrumentId) {
- this.instrumentId = instrumentId;
- }
-
- public String getDataAcquisitionProjectId() {
- return dataAcquisitionProjectId;
- }
-
- public void setDataAcquisitionProjectId(String dataAcquisitionProjectId) {
- this.dataAcquisitionProjectId = dataAcquisitionProjectId;
- }
-
- public I18nString getType() {
- return type;
- }
-
- public void setType(I18nString type) {
- this.type = type;
- }
-
- public I18nString getDescription() {
- return description;
- }
-
- public void setDescription(I18nString description) {
- this.description = description;
- }
-
- public String getLanguage() {
- return language;
- }
-
- public void setLanguage(String language) {
- this.language = language;
- }
-
- public String getFileName() {
- return fileName;
- }
-
- public void setFileName(String fileName) {
- this.fileName = fileName;
- }
-
- public Integer getInstrumentNumber() {
- return instrumentNumber;
- }
-
- public void setInstrumentNumber(Integer instrumentNumber) {
- this.instrumentNumber = instrumentNumber;
- }
-
@Override
public String getId() {
return "/public/files/instruments/" + instrumentId + "/attachments/" + fileName;
}
-
- public Integer getIndexInInstrument() {
- return indexInInstrument;
- }
-
- public void setIndexInInstrument(Integer indexInInstrument) {
- this.indexInInstrument = indexInInstrument;
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/logmanagement/aop/LoggingAspect.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/logmanagement/aop/LoggingAspect.java
index 5e2cb6d272..9d5890abaf 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/logmanagement/aop/LoggingAspect.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/logmanagement/aop/LoggingAspect.java
@@ -8,17 +8,15 @@
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import lombok.extern.slf4j.Slf4j;
/**
* Aspect for logging execution of service and repository Spring components.
*/
@Aspect
+@Slf4j
public class LoggingAspect {
-
- private final Logger log = LoggerFactory.getLogger(this.getClass());
-
@Pointcut(
"within(eu.dzhw.fdz.metadatamanagement.repository..*)"
+ " || within(eu.dzhw.fdz.metadatamanagement.service..*)"
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/mailmanagement/service/MailService.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/mailmanagement/service/MailService.java
index 785c8220e1..53aabee9b7 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/mailmanagement/service/MailService.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/mailmanagement/service/MailService.java
@@ -10,8 +10,6 @@
import javax.mail.internet.MimeMessage;
import org.apache.commons.lang.CharEncoding;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.mail.javamail.JavaMailSenderImpl;
@@ -24,6 +22,7 @@
import eu.dzhw.fdz.metadatamanagement.common.config.JHipsterProperties;
import eu.dzhw.fdz.metadatamanagement.usermanagement.domain.User;
+import lombok.extern.slf4j.Slf4j;
/**
* Service for sending e-mails.
@@ -33,10 +32,8 @@
*
*/
@Service
+@Slf4j
public class MailService {
-
- private final Logger log = LoggerFactory.getLogger(MailService.class);
-
@Autowired
private JHipsterProperties jhipsterProperties;
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/domain/DataAcquisitionProject.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/domain/DataAcquisitionProject.java
index 6e2325f822..698ea8c4f8 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/domain/DataAcquisitionProject.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/domain/DataAcquisitionProject.java
@@ -9,12 +9,15 @@
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
-import com.google.common.base.MoreObjects;
-
import eu.dzhw.fdz.metadatamanagement.common.domain.AbstractRdcDomainObject;
import eu.dzhw.fdz.metadatamanagement.common.domain.validation.StringLengths;
import eu.dzhw.fdz.metadatamanagement.projectmanagement.domain.validation.SetHasBeenReleasedBeforeOnlyOnce;
-import net.karneim.pojobuilder.GeneratePojoBuilder;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
/**
* The Data Acquisition Project collects all data which are going to be published by our RDC.
@@ -25,8 +28,12 @@
@SetHasBeenReleasedBeforeOnlyOnce(message = "data-acquisition-project."
+ "error.data-acquisition-project."
+ "has-been-released-before.set-has-been-released-before-only-once")
-@GeneratePojoBuilder(
- intoPackage = "eu.dzhw.fdz.metadatamanagement.projectmanagement.domain.builders")
+@Data
+@EqualsAndHashCode(callSuper = false, of = "id")
+@ToString(callSuper = true)
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class DataAcquisitionProject extends AbstractRdcDomainObject {
/* Domain Object Attributes */
@@ -44,49 +51,4 @@ public class DataAcquisitionProject extends AbstractRdcDomainObject {
@Valid
private Release release;
-
- /*
- * (non-Javadoc)
- *
- * @see eu.dzhw.fdz.metadatamanagement.domain.AbstractRdcDomainObject#getId()
- */
- @Override
- public String getId() {
- return id;
- }
-
- /*
- * (non-Javadoc)
- * @see eu.dzhw.fdz.metadatamanagement.common.domain.AbstractRdcDomainObject#toString()
- */
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("super", super.toString())
- .add("id", id)
- .add("hasBeenReleasedBefore", hasBeenReleasedBefore)
- .add("release", release)
- .toString();
- }
-
- /* GETTER / SETTER */
- public void setId(String id) {
- this.id = id;
- }
-
- public Release getRelease() {
- return release;
- }
-
- public void setRelease(Release release) {
- this.release = release;
- }
-
- public Boolean getHasBeenReleasedBefore() {
- return hasBeenReleasedBefore;
- }
-
- public void setHasBeenReleasedBefore(Boolean hasBeenReleasedBefore) {
- this.hasBeenReleasedBefore = hasBeenReleasedBefore;
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/domain/Release.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/domain/Release.java
index 8e4dc0c93e..b8f77131e9 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/domain/Release.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/domain/Release.java
@@ -8,13 +8,14 @@
import org.hibernate.validator.constraints.NotEmpty;
-import com.google.common.base.MoreObjects;
-
import eu.dzhw.fdz.metadatamanagement.common.domain.I18nString;
import eu.dzhw.fdz.metadatamanagement.common.domain.util.Patterns;
import eu.dzhw.fdz.metadatamanagement.common.domain.validation.I18nStringSize;
import eu.dzhw.fdz.metadatamanagement.common.domain.validation.StringLengths;
-import net.karneim.pojobuilder.GeneratePojoBuilder;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
/**
* The release includes all additional information for a release of a data acquisition project. It
@@ -23,8 +24,10 @@
*
* @author Daniel Katzberg
*/
-@GeneratePojoBuilder(
- intoPackage = "eu.dzhw.fdz.metadatamanagement.projectmanagement.domain.builders")
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class Release {
@NotEmpty(message = "data-acquisition-project."
@@ -41,43 +44,4 @@ public class Release {
@I18nStringSize(max = StringLengths.LARGE,
message = "data-acquisition-project.error.release.notes.i18n-string-size")
private I18nString notes;
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("version", version)
- .add("date", date)
- .add("notes", notes)
- .toString();
- }
-
- /* GETTER / SETTER */
- public String getVersion() {
- return version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
- public LocalDateTime getDate() {
- return date;
- }
-
- public void setDate(LocalDateTime date) {
- this.date = date;
- }
-
- public I18nString getNotes() {
- return notes;
- }
-
- public void setNotes(I18nString notes) {
- this.notes = notes;
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectDeleteResource.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectDeleteResource.java
index 0bb643a50e..0f1c4fabd6 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectDeleteResource.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectDeleteResource.java
@@ -1,7 +1,5 @@
package eu.dzhw.fdz.metadatamanagement.projectmanagement.rest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.rest.webmvc.RepositoryRestController;
import org.springframework.http.ResponseEntity;
@@ -13,6 +11,7 @@
import eu.dzhw.fdz.metadatamanagement.projectmanagement.domain.DataAcquisitionProject;
import eu.dzhw.fdz.metadatamanagement.projectmanagement.service.DataAcquisitionProjectService;
+import lombok.extern.slf4j.Slf4j;
/**
* If a data acquisition project has been released before, it can not be deleted by anyone.
@@ -20,11 +19,8 @@
*
*/
@RepositoryRestController
+@Slf4j
public class DataAcquisitionProjectDeleteResource {
-
- private final Logger log =
- LoggerFactory.getLogger(DataAcquisitionProjectDeleteResource.class);
-
@Autowired
private DataAcquisitionProjectService dataAcquisitionProjectService;
@@ -43,16 +39,16 @@ public ResponseEntity> deleteDataAcquisitionProject(@PathVariable String id) {
//project could not be found
if (dataAcquisitionProject == null) {
- this.log.warn("Project could not be found and deleted!");
+ log.warn("Project could not be found and deleted!");
return ResponseEntity.badRequest().build();
}
//Check project, if it has been released before
if (this.dataAcquisitionProjectService.deleteDataAcquisitionProject(dataAcquisitionProject)) {
- this.log.info("Project has not been released before. Project is deleted.");
+ log.info("Project has not been released before. Project is deleted.");
return ResponseEntity.ok().build();
} else {
- this.log.warn("Project has been released before. It is forbidden to delete it!");
+ log.warn("Project has been released before. It is forbidden to delete it!");
return ResponseEntity.badRequest().build();
}
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectPostValidationResource.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectPostValidationResource.java
index 3243307f95..8d45007de6 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectPostValidationResource.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectPostValidationResource.java
@@ -1,7 +1,5 @@
package eu.dzhw.fdz.metadatamanagement.projectmanagement.rest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
@@ -17,6 +15,7 @@
import eu.dzhw.fdz.metadatamanagement.projectmanagement.rest.dto.PostValidationErrorsDto;
import eu.dzhw.fdz.metadatamanagement.projectmanagement.service.PostValidationService;
import eu.dzhw.fdz.metadatamanagement.usermanagement.security.AuthoritiesConstants;
+import lombok.extern.slf4j.Slf4j;
/**
* A Resource class for the post validation of data acquisition projects. It get the id of the
@@ -29,14 +28,11 @@
*/
@RestController
@RequestMapping("/api")
+@Slf4j
public class DataAcquisitionProjectPostValidationResource {
-
@Autowired
private PostValidationService postValidationService;
- private final Logger log =
- LoggerFactory.getLogger(DataAcquisitionProjectPostValidationResource.class);
-
/**
* POST /data-acquisition-projects/:id/post-validate -> Validate project by id.
*/
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/service/DaraService.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/service/DaraService.java
index 593301020b..46212c77b3 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/service/DaraService.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/service/DaraService.java
@@ -12,8 +12,6 @@
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
@@ -41,6 +39,7 @@
import freemarker.template.Template;
import freemarker.template.TemplateException;
import freemarker.template.TemplateExceptionHandler;
+import lombok.extern.slf4j.Slf4j;
/**
* Access component for getting health information or registration or updates for dara and the doi.
@@ -48,10 +47,8 @@
* @author Daniel Katzberg
*/
@Service
+@Slf4j
public class DaraService {
-
- private final Logger log = LoggerFactory.getLogger(DaraService.class);
-
public static final String IS_ALiVE_ENDPOINT = "api/isAlive";
public static final String REGISTRATION_ENDPOINT = "study/importXML";
@@ -72,6 +69,9 @@ public class DaraService {
private RestTemplate restTemplate;
+ //Key for Register XML Template
+ private static final String KEY_REGISTER_XML_TMPL = "register.xml.tmpl";
+
//Resource Type
private static final int RESOURCE_TYPE_DATASET = 2;
@@ -122,7 +122,8 @@ public HttpStatus registerOrUpdateProjectToDara(String projectId)
//Fill template
String filledTemplate = this.fillTemplate(registerXmlStr,
this.getTemplateConfiguration(),
- this.getDataForTemplate(projectId, AVAILABILITY_CONTROLLED_DELIVERY));
+ this.getDataForTemplate(projectId, AVAILABILITY_CONTROLLED_DELIVERY),
+ KEY_REGISTER_XML_TMPL);
//Send Rest Call for Registration
HttpStatus httpStatusFromDara =
@@ -138,7 +139,7 @@ public HttpStatus registerOrUpdateProjectToDara(String projectId)
*/
private HttpStatus postToDaraImportXml(String filledTemplate, boolean hasBeenReleasedBefore) {
- this.log.debug("XML Element to Dara: " + filledTemplate);
+ log.debug("XML Element to Dara: " + filledTemplate);
//Load Dara Information
final String daraEndpoint =
@@ -202,7 +203,8 @@ public HttpStatus unregisterProjectToDara(String projectId)
//Fill template
String filledTemplate = this.fillTemplate(registerXmlStr,
this.getTemplateConfiguration(),
- this.getDataForTemplate(projectId, AVAILABILITY_CONTROLLED_NOT_AVAILABLE));
+ this.getDataForTemplate(projectId, AVAILABILITY_CONTROLLED_NOT_AVAILABLE),
+ KEY_REGISTER_XML_TMPL);
//Send Rest Call for Registration
return this.postToDaraImportXml(filledTemplate, project.getHasBeenReleasedBefore());
@@ -263,15 +265,16 @@ private Configuration getTemplateConfiguration() {
* @param templateContent The content of a xml template.
* @param templateConfiguration The configuration for freemarker.
* @param dataForTemplateThe data for a xml template.
+ * @param fileName filename of the script which will be filled in this method.
* @return The filled xml templates as byte array.
* @throws IOException Handles IO Exception.
* @throws TemplateException Handles template Exceptions.
*/
private String fillTemplate(String templateContent,
- Configuration templateConfiguration, Map dataForTemplate)
+ Configuration templateConfiguration, Map dataForTemplate, String fileName)
throws IOException, TemplateException {
// Read Template and escape elements
- Template texTemplate = new Template("xmlTemplate", templateContent, templateConfiguration);
+ Template texTemplate = new Template(fileName, templateContent, templateConfiguration);
try (Writer stringWriter = new StringWriter()) {
texTemplate.process(dataForTemplate, stringWriter);
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/domain/Question.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/domain/Question.java
index 5ca593e6f0..abd04a214b 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/domain/Question.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/domain/Question.java
@@ -14,8 +14,6 @@
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
-import com.google.common.base.MoreObjects;
-
import eu.dzhw.fdz.metadatamanagement.common.domain.AbstractRdcDomainObject;
import eu.dzhw.fdz.metadatamanagement.common.domain.I18nString;
import eu.dzhw.fdz.metadatamanagement.common.domain.ImageType;
@@ -28,7 +26,12 @@
import eu.dzhw.fdz.metadatamanagement.questionmanagement.domain.validation.ValidQuestionType;
import eu.dzhw.fdz.metadatamanagement.questionmanagement.domain.validation.ValidUniqueQuestionNumber;
import io.searchbox.annotations.JestId;
-import net.karneim.pojobuilder.GeneratePojoBuilder;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
/**
* Question.
@@ -36,13 +39,17 @@
* @author Daniel Katzberg
*/
@Document(collection = "questions")
-@GeneratePojoBuilder(
- intoPackage = "eu.dzhw.fdz.metadatamanagement.questionmanagement.domain.builders")
@CompoundIndex(def = "{instrumentId: 1, number: 1}", unique = true)
@ValidUniqueQuestionNumber(message = "question-management.error"
+ ".question.unique-question-number")
@ValidQuestionIdName(message = "question-management.error"
+ ".question.valid-question-id-name")
+@Data
+@EqualsAndHashCode(callSuper = false, of = "id")
+@ToString(callSuper = true)
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class Question extends AbstractRdcDomainObject {
@Id
@@ -121,186 +128,8 @@ public class Question extends AbstractRdcDomainObject {
@NotEmpty(message = "question-management.error.question.study-id.not-empty")
private String studyId;
- public Question() {
- super();
- }
-
public Question(Question question) {
super();
BeanUtils.copyProperties(question, this);
}
-
- @Override
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getDataAcquisitionProjectId() {
- return dataAcquisitionProjectId;
- }
-
- public void setDataAcquisitionProjectId(String dataAcquisitionProjectId) {
- this.dataAcquisitionProjectId = dataAcquisitionProjectId;
- }
-
- public String getInstrumentId() {
- return instrumentId;
- }
-
- public void setInstrumentId(String instrumentId) {
- this.instrumentId = instrumentId;
- }
-
- public Integer getInstrumentNumber() {
- return instrumentNumber;
- }
-
- public void setInstrumentNumber(Integer instrumentNumber) {
- this.instrumentNumber = instrumentNumber;
- }
-
- public String getNumber() {
- return number;
- }
-
- public void setNumber(String number) {
- this.number = number;
- }
-
- public I18nString getQuestionText() {
- return questionText;
- }
-
- public void setQuestionText(I18nString questionText) {
- this.questionText = questionText;
- }
-
- public I18nString getTopic() {
- return topic;
- }
-
- public void setTopic(I18nString topic) {
- this.topic = topic;
- }
-
- /*
- * (non-Javadoc)
- * @see eu.dzhw.fdz.metadatamanagement.common.domain.AbstractRdcDomainObject#toString()
- */
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("super", super.toString())
- .add("id", id)
- .add("number", number)
- .add("questionText", questionText)
- .add("instruction", instruction)
- .add("introduction", introduction)
- .add("type", type)
- .add("additionalQuestionText", additionalQuestionText)
- .add("imageType", imageType)
- .add("topic", topic)
- .add("technicalRepresentation", technicalRepresentation)
- .add("successors", successors)
- .add("dataAcquisitionProjectId", dataAcquisitionProjectId)
- .add("instrumentId", instrumentId)
- .add("instrumentNumber", instrumentNumber)
- .add("successorNumbers", successorNumbers)
- .add("studyId", studyId)
- .add("annotations", annotations)
- .add("indexInInstrument", indexInInstrument)
- .toString();
- }
-
- public I18nString getInstruction() {
- return instruction;
- }
-
- public void setInstruction(I18nString instruction) {
- this.instruction = instruction;
- }
-
- public I18nString getIntroduction() {
- return introduction;
- }
-
- public void setIntroduction(I18nString introduction) {
- this.introduction = introduction;
- }
-
- public I18nString getType() {
- return type;
- }
-
- public void setType(I18nString type) {
- this.type = type;
- }
-
- public I18nString getAdditionalQuestionText() {
- return additionalQuestionText;
- }
-
- public void setAdditionalQuestionText(I18nString additionalQuestionText) {
- this.additionalQuestionText = additionalQuestionText;
- }
-
- public ImageType getImageType() {
- return imageType;
- }
-
- public void setImageType(ImageType imageType) {
- this.imageType = imageType;
- }
-
- public TechnicalRepresentation getTechnicalRepresentation() {
- return technicalRepresentation;
- }
-
- public void setTechnicalRepresentation(TechnicalRepresentation technicalRepresentation) {
- this.technicalRepresentation = technicalRepresentation;
- }
-
- public List getSuccessors() {
- return successors;
- }
-
- public void setSuccessors(List successors) {
- this.successors = successors;
- }
-
- public List getSuccessorNumbers() {
- return successorNumbers;
- }
-
- public void setSuccessorNumbers(List successorNumbers) {
- this.successorNumbers = successorNumbers;
- }
-
- public String getStudyId() {
- return studyId;
- }
-
- public void setStudyId(String studyId) {
- this.studyId = studyId;
- }
-
- public I18nString getAnnotations() {
- return annotations;
- }
-
- public void setAnnotations(I18nString annotations) {
- this.annotations = annotations;
- }
-
- public Integer getIndexInInstrument() {
- return indexInInstrument;
- }
-
- public void setIndexInInstrument(Integer indexInInstrument) {
- this.indexInInstrument = indexInInstrument;
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/domain/TechnicalRepresentation.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/domain/TechnicalRepresentation.java
index 312b931786..9f1b6a4963 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/domain/TechnicalRepresentation.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/domain/TechnicalRepresentation.java
@@ -4,10 +4,11 @@
import org.hibernate.validator.constraints.NotEmpty;
-import com.google.common.base.MoreObjects;
-
import eu.dzhw.fdz.metadatamanagement.common.domain.validation.StringLengths;
-import net.karneim.pojobuilder.GeneratePojoBuilder;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
/**
* Technical Representation of a Question. It contains the type,
@@ -15,8 +16,10 @@
* @author Daniel Katzberg
*
*/
-@GeneratePojoBuilder(
- intoPackage = "eu.dzhw.fdz.metadatamanagement.questionmanagement.domain.builders")
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class TechnicalRepresentation {
@NotEmpty(message = "question-management.error.technical-representation.type.not-empty")
@@ -33,42 +36,4 @@ public class TechnicalRepresentation {
@Size(max = StringLengths.X_LARGE,
message = "question-management.error.technical-representation.source.size")
private String source;
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("type", type)
- .add("language", language)
- .add("source", source)
- .toString();
- }
-
- /* GETTER / SETTER */
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getLanguage() {
- return language;
- }
-
- public void setLanguage(String language) {
- this.language = language;
- }
-
- public String getSource() {
- return source;
- }
-
- public void setSource(String source) {
- this.source = source;
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/relatedpublicationmanagement/domain/RelatedPublication.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/relatedpublicationmanagement/domain/RelatedPublication.java
index 8d92b7a686..443c595c99 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/relatedpublicationmanagement/domain/RelatedPublication.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/relatedpublicationmanagement/domain/RelatedPublication.java
@@ -1,6 +1,5 @@
package eu.dzhw.fdz.metadatamanagement.relatedpublicationmanagement.domain;
-import java.util.ArrayList;
import java.util.List;
import javax.validation.constraints.NotNull;
@@ -13,8 +12,6 @@
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
-import com.google.common.base.MoreObjects;
-
import eu.dzhw.fdz.metadatamanagement.common.domain.AbstractRdcDomainObject;
import eu.dzhw.fdz.metadatamanagement.common.domain.I18nString;
import eu.dzhw.fdz.metadatamanagement.common.domain.util.Patterns;
@@ -27,7 +24,12 @@
import eu.dzhw.fdz.metadatamanagement.relatedpublicationmanagement.domain.validation.ValidRelatedPublicationId;
import eu.dzhw.fdz.metadatamanagement.relatedpublicationmanagement.domain.validation.ValidUrl;
import io.searchbox.annotations.JestId;
-import net.karneim.pojobuilder.GeneratePojoBuilder;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
/**
* Domain Object for the Related Publications.
@@ -42,10 +44,14 @@
message = "related-publication-management.error.related-publication.one-study-is-used")
@ValidPublicationYear(message = "related-publication-management.error.related-publication."
+ "year.valid")
-@GeneratePojoBuilder(
- intoPackage = "eu.dzhw.fdz.metadatamanagement.relatedpublicationmanagement.domain.builders")
@ValidRelatedPublicationId(message =
"related-publication-management.error.related-publication.valid-related-publication-id")
+@Data
+@EqualsAndHashCode(callSuper = false, of = "id")
+@ToString(callSuper = true)
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class RelatedPublication extends AbstractRdcDomainObject {
@Id
@@ -103,182 +109,25 @@ public class RelatedPublication extends AbstractRdcDomainObject {
/* Foreign Keys */
@Indexed
- private List questionIds = new ArrayList();
+ private List questionIds;
@Indexed
- private List surveyIds = new ArrayList();
+ private List surveyIds;
@Indexed
- private List variableIds = new ArrayList();
+ private List variableIds;
@Indexed
- private List dataSetIds = new ArrayList();
+ private List dataSetIds;
@Indexed
- private List studyIds = new ArrayList();
+ private List studyIds;
@Indexed
- private List instrumentIds = new ArrayList();
-
- public RelatedPublication() {
- super();
- }
+ private List instrumentIds;
public RelatedPublication(RelatedPublication relatedPublication) {
super();
BeanUtils.copyProperties(relatedPublication, this);
}
-
- @Override
- public String getId() {
- return this.id;
- }
-
- public String getDoi() {
- return doi;
- }
-
- public void setDoi(String doi) {
- this.doi = doi;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getAuthors() {
- return authors;
- }
-
- public void setAuthors(String authors) {
- this.authors = authors;
- }
-
- /* GETTER / SETTER */
- public String getSourceReference() {
- return sourceReference;
- }
-
- public void setSourceReference(String sourceReference) {
- this.sourceReference = sourceReference;
- }
-
- public String getPublicationAbstract() {
- return publicationAbstract;
- }
-
- public void setPublicationAbstract(String publicationAbstract) {
- this.publicationAbstract = publicationAbstract;
- }
-
- public String getSourceLink() {
- return sourceLink;
- }
-
- public void setSourceLink(String sourceLink) {
- this.sourceLink = sourceLink;
- }
-
- public Integer getYear() {
- return year;
- }
-
- public void setYear(Integer year) {
- this.year = year;
- }
-
- public I18nString getAbstractSource() {
- return abstractSource;
- }
-
- public void setAbstractSource(I18nString abstractSource) {
- this.abstractSource = abstractSource;
- }
-
- public String getLanguage() {
- return language;
- }
-
- public void setLanguage(String language) {
- this.language = language;
- }
-
- public List getQuestionIds() {
- return questionIds;
- }
-
- public void setQuestionIds(List questionIds) {
- this.questionIds = questionIds;
- }
-
- public List getSurveyIds() {
- return surveyIds;
- }
-
- public void setSurveyIds(List surveyIds) {
- this.surveyIds = surveyIds;
- }
-
- public List getVariableIds() {
- return variableIds;
- }
-
- public void setVariableIds(List variableIds) {
- this.variableIds = variableIds;
- }
-
- public List getDataSetIds() {
- return dataSetIds;
- }
-
- public void setDataSetIds(List dataSetIds) {
- this.dataSetIds = dataSetIds;
- }
-
- public List getStudyIds() {
- return studyIds;
- }
-
- public void setStudyIds(List studyIds) {
- this.studyIds = studyIds;
- }
-
- public List getInstrumentIds() {
- return instrumentIds;
- }
-
- public void setInstrumentIds(List instrumentIds) {
- this.instrumentIds = instrumentIds;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("super", super.toString())
- .add("id", id)
- .add("doi", doi)
- .add("title", title)
- .add("authors", authors)
- .add("sourceReference", sourceReference)
- .add("publicationAbstract", publicationAbstract)
- .add("sourceLink", sourceLink)
- .add("year", year)
- .add("abstractSource", abstractSource)
- .add("language", language)
- .add("questionIds", questionIds)
- .add("surveyIds", surveyIds)
- .add("variableIds", variableIds)
- .add("dataSetIds", dataSetIds)
- .add("studyIds", studyIds)
- .add("instrumentIds", instrumentIds)
- .toString();
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/dao/ElasticsearchDao.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/dao/ElasticsearchDao.java
index 9bfcc921ee..f3eb5e10f5 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/dao/ElasticsearchDao.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/dao/ElasticsearchDao.java
@@ -3,8 +3,6 @@
import java.io.IOException;
import java.util.Collection;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -28,6 +26,7 @@
import io.searchbox.indices.mapping.GetMapping;
import io.searchbox.indices.mapping.PutMapping;
import io.searchbox.indices.settings.GetSettings;
+import lombok.extern.slf4j.Slf4j;
/**
* Data Access Object for accessing and manipulating elasticsearch.
@@ -35,10 +34,8 @@
* @author René Reitmann
*/
@Component
+@Slf4j
public class ElasticsearchDao {
-
- private final Logger log = LoggerFactory.getLogger(ElasticsearchDao.class);
-
@Autowired
private JestClient jestClient;
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/DataSetSearchDocument.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/DataSetSearchDocument.java
index e76e28852d..6192febe2e 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/DataSetSearchDocument.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/DataSetSearchDocument.java
@@ -13,12 +13,20 @@
import eu.dzhw.fdz.metadatamanagement.studymanagement.domain.projection.StudySubDocumentProjection;
import eu.dzhw.fdz.metadatamanagement.surveymanagement.domain.projections.SurveySubDocumentProjection;
import eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.projections.VariableSubDocumentProjection;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
/**
* Representation of a dataSet which is stored in elasticsearch.
*
* @author René Reitmann
*/
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Getter
+@Setter
public class DataSetSearchDocument extends DataSet implements SearchDocumentInterface {
private StudySubDocument study = null;
@@ -89,81 +97,4 @@ public DataSetSearchDocument(DataSet dataSet,
.map(subDataSet -> subDataSet.getAccessWay()).collect(Collectors.toList());
this.release = release;
}
-
- public StudySubDocument getStudy() {
- return study;
- }
-
- public void setStudy(StudySubDocument study) {
- this.study = study;
- }
-
- public List getVariables() {
- return variables;
- }
-
- public void setVariables(List variables) {
- this.variables = variables;
- }
-
- public List getRelatedPublications() {
- return relatedPublications;
- }
-
- public void setRelatedPublications(List relatedPublications) {
- this.relatedPublications = relatedPublications;
- }
-
- public List getSurveys() {
- return surveys;
- }
-
- public void setSurveys(List surveys) {
- this.surveys = surveys;
- }
-
- public List getInstruments() {
- return instruments;
- }
-
- public void setInstruments(List instruments) {
- this.instruments = instruments;
- }
-
- public List getQuestion() {
- return questions;
- }
-
- public void setQuestions(List questions) {
- this.questions = questions;
- }
-
- public Release getRelease() {
- return release;
- }
-
- public void setRelease(Release release) {
- this.release = release;
- }
-
- public Integer getMaxNumberOfObservations() {
- return maxNumberOfObservations;
- }
-
- public List getAccessWays() {
- return accessWays;
- }
-
- public List getQuestions() {
- return questions;
- }
-
- @Override
- public I18nString getGuiLabels() {
- return guiLabels;
- }
-
- public void setGuiLabels(I18nString guiLabels) {
- this.guiLabels = guiLabels;
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/InstrumentSearchDocument.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/InstrumentSearchDocument.java
index eac89902fa..980e7afdfd 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/InstrumentSearchDocument.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/InstrumentSearchDocument.java
@@ -13,12 +13,20 @@
import eu.dzhw.fdz.metadatamanagement.studymanagement.domain.projection.StudySubDocumentProjection;
import eu.dzhw.fdz.metadatamanagement.surveymanagement.domain.projections.SurveySubDocumentProjection;
import eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.projections.VariableSubDocumentProjection;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
/**
* Representation of an instrument which is stored in elasticsearch.
*
* @author René Reitmann
*/
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Getter
+@Setter
public class InstrumentSearchDocument extends Instrument implements SearchDocumentInterface {
private StudySubDocument study = null;
private List surveys =
@@ -79,69 +87,4 @@ public InstrumentSearchDocument(Instrument instrument,
}
this.release = release;
}
-
- public StudySubDocument getStudy() {
- return study;
- }
-
- public void setStudy(StudySubDocument study) {
- this.study = study;
- }
-
- public List getSurveys() {
- return surveys;
- }
-
- public void setSurveys(List surveys) {
- this.surveys = surveys;
- }
-
- public List getQuestions() {
- return questions;
- }
-
- public void setQuestions(List questions) {
- this.questions = questions;
- }
-
- public List getVariables() {
- return variables;
- }
-
- public void setVariables(List variables) {
- this.variables = variables;
- }
-
- public List getDataSets() {
- return dataSets;
- }
-
- public void setDataSets(List dataSets) {
- this.dataSets = dataSets;
- }
-
- public List getRelatedPublications() {
- return relatedPublications;
- }
-
- public void setRelatedPublications(List relatedPublications) {
- this.relatedPublications = relatedPublications;
- }
-
- public Release getRelease() {
- return release;
- }
-
- public void setRelease(Release release) {
- this.release = release;
- }
-
- @Override
- public I18nString getGuiLabels() {
- return guiLabels;
- }
-
- public void setGuiLabels(I18nString guiLabels) {
- this.guiLabels = guiLabels;
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QuestionSearchDocument.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QuestionSearchDocument.java
index 007af3d61d..d0721da504 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QuestionSearchDocument.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QuestionSearchDocument.java
@@ -13,10 +13,18 @@
import eu.dzhw.fdz.metadatamanagement.studymanagement.domain.projection.StudySubDocumentProjection;
import eu.dzhw.fdz.metadatamanagement.surveymanagement.domain.projections.SurveySubDocumentProjection;
import eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.projections.VariableSubDocumentProjection;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
/**
* Representation of an question which is stored in elasticsearch.
*/
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Getter
+@Setter
public class QuestionSearchDocument extends Question implements SearchDocumentInterface {
private StudySubDocument study = null;
private InstrumentSubDocument instrument = null;
@@ -74,69 +82,4 @@ public QuestionSearchDocument(Question question,
}
this.release = release;
}
-
- public StudySubDocument getStudy() {
- return study;
- }
-
- public void setStudy(StudySubDocument study) {
- this.study = study;
- }
-
- public InstrumentSubDocument getInstrument() {
- return instrument;
- }
-
- public void setInstrument(InstrumentSubDocument instrument) {
- this.instrument = instrument;
- }
-
- public List getSurveys() {
- return surveys;
- }
-
- public void setSurveys(List surveys) {
- this.surveys = surveys;
- }
-
- public List getVariables() {
- return variables;
- }
-
- public void setVariables(List variables) {
- this.variables = variables;
- }
-
- public List getDataSets() {
- return dataSets;
- }
-
- public void setDataSets(List dataSets) {
- this.dataSets = dataSets;
- }
-
- public List getRelatedPublications() {
- return relatedPublications;
- }
-
- public void setRelatedPublications(List relatedPublications) {
- this.relatedPublications = relatedPublications;
- }
-
- public Release getRelease() {
- return release;
- }
-
- public void setRelease(Release release) {
- this.release = release;
- }
-
- @Override
- public I18nString getGuiLabels() {
- return guiLabels;
- }
-
- public void setGuiLabels(I18nString guiLabels) {
- this.guiLabels = guiLabels;
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/RelatedPublicationSearchDocument.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/RelatedPublicationSearchDocument.java
index c57d507fa0..b9ba0a93ef 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/RelatedPublicationSearchDocument.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/RelatedPublicationSearchDocument.java
@@ -12,12 +12,20 @@
import eu.dzhw.fdz.metadatamanagement.studymanagement.domain.projection.StudySubDocumentProjection;
import eu.dzhw.fdz.metadatamanagement.surveymanagement.domain.projections.SurveySubDocumentProjection;
import eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.projections.VariableSubDocumentProjection;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
/**
* Representation of a related publication which is stored in elasticsearch.
*
* @author Daniel Katzberg
*/
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Getter
+@Setter
public class RelatedPublicationSearchDocument extends RelatedPublication
implements SearchDocumentInterface {
private List studies =
@@ -82,69 +90,4 @@ public RelatedPublicationSearchDocument(RelatedPublication relatedPublication,
.map(VariableSubDocument::new).collect(Collectors.toList());
}
}
-
- public List getStudies() {
- return studies;
- }
-
- public void setStudies(List studies) {
- this.studies = studies;
- }
-
- public List getQuestions() {
- return questions;
- }
-
- public void setQuestions(List questions) {
- this.questions = questions;
- }
-
- public List getInstruments() {
- return instruments;
- }
-
- public void setInstruments(List instruments) {
- this.instruments = instruments;
- }
-
- public List getSurveys() {
- return surveys;
- }
-
- public void setSurveys(List surveys) {
- this.surveys = surveys;
- }
-
- public List getDataSets() {
- return dataSets;
- }
-
- public void setDataSets(List dataSets) {
- this.dataSets = dataSets;
- }
-
- public List getVariables() {
- return variables;
- }
-
- public void setVariables(List variables) {
- this.variables = variables;
- }
-
- public String getRelease() {
- return release;
- }
-
- public void setRelease(String release) {
- this.release = release;
- }
-
- @Override
- public I18nString getGuiLabels() {
- return guiLabels;
- }
-
- public void setGuiLabels(I18nString guiLabels) {
- this.guiLabels = guiLabels;
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/StudySearchDocument.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/StudySearchDocument.java
index 506fbf345e..b656fe47e7 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/StudySearchDocument.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/StudySearchDocument.java
@@ -14,12 +14,20 @@
import eu.dzhw.fdz.metadatamanagement.studymanagement.domain.SurveyDataTypes;
import eu.dzhw.fdz.metadatamanagement.surveymanagement.domain.projections.SurveySubDocumentProjection;
import eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.projections.VariableSubDocumentProjection;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
/**
* Representation of a study which is stored in elasticsearch.
*
* @author René Reitmann
*/
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Getter
+@Setter
public class StudySearchDocument extends Study implements SearchDocumentInterface {
private List dataSets =
new ArrayList<>();
@@ -136,85 +144,4 @@ private I18nString generateSurveyDataType(List surv
return surveyDataType;
}
-
- public List getDataSets() {
- return dataSets;
- }
-
- public void setDataSets(List dataSets) {
- this.dataSets = dataSets;
- }
-
- public List getVariables() {
- return variables;
- }
-
- public void setVariables(List variables) {
- this.variables = variables;
- }
-
- public List getRelatedPublications() {
- return relatedPublications;
- }
-
- public void setRelatedPublications(List relatedPublications) {
- this.relatedPublications = relatedPublications;
- }
-
- public List getSurveys() {
- return surveys;
- }
-
- public void setSurveys(List surveys) {
- this.surveys = surveys;
- }
-
- public List getQuestions() {
- return questions;
- }
-
- public void setQuestions(List questions) {
- this.questions = questions;
- }
-
- public List getInstruments() {
- return instruments;
- }
-
- public void setInstruments(List instruments) {
- this.instruments = instruments;
- }
-
- public Release getRelease() {
- return release;
- }
-
- public void setRelease(Release release) {
- this.release = release;
- }
-
- public I18nString getSurveyDataType() {
- return surveyDataType;
- }
-
- public void setSurveyDataType(I18nString surveyDataType) {
- this.surveyDataType = surveyDataType;
- }
-
- public Integer getNumberOfWaves() {
- return numberOfWaves;
- }
-
- public void setNumberOfWaves(Integer numberOfWaves) {
- this.numberOfWaves = numberOfWaves;
- }
-
- @Override
- public I18nString getGuiLabels() {
- return guiLabels;
- }
-
- public void setGuiLabels(I18nString guiLabels) {
- this.guiLabels = guiLabels;
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/SurveySearchDocument.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/SurveySearchDocument.java
index 2c88b31a74..88b22b7774 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/SurveySearchDocument.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/SurveySearchDocument.java
@@ -13,6 +13,10 @@
import eu.dzhw.fdz.metadatamanagement.studymanagement.domain.projection.StudySubDocumentProjection;
import eu.dzhw.fdz.metadatamanagement.surveymanagement.domain.Survey;
import eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.projections.VariableSubDocumentProjection;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
/**
* Representation of a survey which is stored in elasticsearch.
@@ -20,6 +24,10 @@
* @author René Reitmann
* @author Daniel Katzberg
*/
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Getter
+@Setter
public class SurveySearchDocument extends Survey implements SearchDocumentInterface {
private StudySubDocument study = null;
private List dataSets =
@@ -81,69 +89,4 @@ public SurveySearchDocument(Survey survey,
}
this.release = release;
}
-
- public StudySubDocument getStudy() {
- return study;
- }
-
- public void setStudy(StudySubDocument study) {
- this.study = study;
- }
-
- public List getDataSets() {
- return dataSets;
- }
-
- public void setDataSets(List dataSets) {
- this.dataSets = dataSets;
- }
-
- public List getVariables() {
- return variables;
- }
-
- public void setVariables(List variables) {
- this.variables = variables;
- }
-
- public List getRelatedPublications() {
- return relatedPublications;
- }
-
- public void setRelatedPublications(List relatedPublications) {
- this.relatedPublications = relatedPublications;
- }
-
- public List getInstruments() {
- return instruments;
- }
-
- public void setInstruments(List instruments) {
- this.instruments = instruments;
- }
-
- public List getQuestions() {
- return questions;
- }
-
- public void setQuestions(List questions) {
- this.questions = questions;
- }
-
- public Release getRelease() {
- return release;
- }
-
- public void setRelease(Release release) {
- this.release = release;
- }
-
- @Override
- public I18nString getGuiLabels() {
- return guiLabels;
- }
-
- public void setGuiLabels(I18nString guiLabels) {
- this.guiLabels = guiLabels;
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/VariableSearchDocument.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/VariableSearchDocument.java
index c2cb0a3376..f8e4960ed1 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/VariableSearchDocument.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/VariableSearchDocument.java
@@ -12,6 +12,10 @@
import eu.dzhw.fdz.metadatamanagement.studymanagement.domain.projection.StudySubDocumentProjection;
import eu.dzhw.fdz.metadatamanagement.surveymanagement.domain.projections.SurveySubDocumentProjection;
import eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.Variable;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
/**
* Representation of a variable which is stored in elasticsearch.
@@ -19,6 +23,10 @@
* @author René Reitmann
* @author Daniel Katzberg
*/
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Getter
+@Setter
public class VariableSearchDocument extends Variable implements SearchDocumentInterface {
private DataSetSubDocument dataSet = null;
private StudySubDocument study = null;
@@ -70,61 +78,4 @@ public VariableSearchDocument(Variable variable,
}
this.release = release;
}
-
- public DataSetSubDocument getDataSet() {
- return dataSet;
- }
-
- public void setDataSet(DataSetSubDocument dataSet) {
- this.dataSet = dataSet;
- }
-
- public StudySubDocument getStudy() {
- return study;
- }
-
- public void setStudy(StudySubDocument study) {
- this.study = study;
- }
-
- public List getRelatedPublications() {
- return relatedPublications;
- }
-
- public void setRelatedPublications(List relatedPublications) {
- this.relatedPublications = relatedPublications;
- }
-
- public List getSurveys() {
- return surveys;
- }
-
- public void setSurveys(List surveys) {
- this.surveys = surveys;
- }
-
- public List getInstruments() {
- return instruments;
- }
-
- public void setInstruments(List instruments) {
- this.instruments = instruments;
- }
-
- public Release getRelease() {
- return release;
- }
-
- public void setRelease(Release release) {
- this.release = release;
- }
-
- @Override
- public I18nString getGuiLabels() {
- return guiLabels;
- }
-
- public void setGuiLabels(I18nString guiLabels) {
- this.guiLabels = guiLabels;
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/domain/ElasticsearchUpdateQueueItem.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/domain/ElasticsearchUpdateQueueItem.java
index 122d9e5fc6..bd736127a1 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/domain/ElasticsearchUpdateQueueItem.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/domain/ElasticsearchUpdateQueueItem.java
@@ -10,11 +10,14 @@
import org.springframework.data.mongodb.core.index.CompoundIndexes;
import org.springframework.data.mongodb.core.mapping.Document;
-import com.google.common.base.MoreObjects;
-
import eu.dzhw.fdz.metadatamanagement.common.domain.AbstractRdcDomainObject;
import eu.dzhw.fdz.metadatamanagement.searchmanagement.service.ElasticsearchType;
-import net.karneim.pojobuilder.GeneratePojoBuilder;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
/**
* Elasticsearch indices are updated asynchronously by processing these queue items.
@@ -22,14 +25,18 @@
* @author René Reitmann
*/
@Document(collection = "elasticsearch_update_queue_item")
-@GeneratePojoBuilder(
- intoPackage = "eu.dzhw.fdz.metadatamanagement.searchmanagement.domain.builders")
@CompoundIndexes({
@CompoundIndex(def = "{documentType: 1, documentId: 1, action: 1}",
unique = true),
@CompoundIndex(def = "{updateStartedAt: 1, updateStartedBy: 1, createdDate: 1}"),
@CompoundIndex(def = "{updateStartedAt: 1, updateStartedBy: 1, documentType: 1,"
+ " createdDate: 1}", name = "locked_items_per_type")})
+@Data
+@EqualsAndHashCode(callSuper = false, of = "id")
+@ToString(callSuper = true)
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class ElasticsearchUpdateQueueItem extends AbstractRdcDomainObject {
/* Domain Object Attributes */
@@ -48,10 +55,6 @@ public class ElasticsearchUpdateQueueItem extends AbstractRdcDomainObject {
@NotNull
private ElasticsearchUpdateQueueAction action;
-
- public ElasticsearchUpdateQueueItem() {
- // default constructor for spring data
- }
/**
* Construct a queue item with the mandatory params.
@@ -65,76 +68,4 @@ public ElasticsearchUpdateQueueItem(String documentId, ElasticsearchType documen
this.documentType = documentType;
this.action = action;
}
-
- /*
- * (non-Javadoc)
- *
- * @see eu.dzhw.fdz.metadatamanagement.domain.AbstractRdcDomainObject#getId()
- */
- @Override
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public ElasticsearchType getDocumentType() {
- return documentType;
- }
-
- public void setDocumentType(ElasticsearchType documentType) {
- this.documentType = documentType;
- }
-
- public String getDocumentId() {
- return documentId;
- }
-
- public void setDocumentId(String documentId) {
- this.documentId = documentId;
- }
-
- public LocalDateTime getUpdateStartedAt() {
- return updateStartedAt;
- }
-
- public void setUpdateStartedAt(LocalDateTime updateStartedAt) {
- this.updateStartedAt = updateStartedAt;
- }
-
- public ElasticsearchUpdateQueueAction getAction() {
- return action;
- }
-
- public void setAction(ElasticsearchUpdateQueueAction action) {
- this.action = action;
- }
-
- public String getUpdateStartedBy() {
- return updateStartedBy;
- }
-
- public void setUpdateStartedBy(String updateStartedBy) {
- this.updateStartedBy = updateStartedBy;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see eu.dzhw.fdz.metadatamanagement.domain.AbstractRdcDomainObject#toString()
- */
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("super", super.toString())
- .add("documentType", documentType)
- .add("documentId", documentId)
- .add("updateStartedAt", updateStartedAt)
- .add("action", action)
- .add("updateStartedBy", updateStartedBy)
- .toString();
- }
-
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/repository/ElasticsearchUpdateQueueItemRepository.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/repository/ElasticsearchUpdateQueueItemRepository.java
index 850847e29b..8791362d4c 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/repository/ElasticsearchUpdateQueueItemRepository.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/repository/ElasticsearchUpdateQueueItemRepository.java
@@ -1,7 +1,6 @@
package eu.dzhw.fdz.metadatamanagement.searchmanagement.repository;
import org.springframework.data.mongodb.repository.MongoRepository;
-import org.springframework.data.querydsl.QueryDslPredicateExecutor;
import org.springframework.stereotype.Repository;
import eu.dzhw.fdz.metadatamanagement.searchmanagement.domain.ElasticsearchUpdateQueueAction;
@@ -14,7 +13,6 @@
@Repository
public interface ElasticsearchUpdateQueueItemRepository
extends MongoRepository,
- QueryDslPredicateExecutor,
ElasticsearchUpdateQueueItemRepositoryCustom {
ElasticsearchUpdateQueueItem findOneByDocumentTypeAndDocumentIdAndAction(
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/rest/SearchResource.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/rest/SearchResource.java
index 1f4b6eb16c..33177dfa11 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/rest/SearchResource.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/rest/SearchResource.java
@@ -8,8 +8,6 @@
import javax.servlet.http.HttpServletRequest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
@@ -40,15 +38,14 @@
import eu.dzhw.fdz.metadatamanagement.searchmanagement.service.ElasticsearchType;
import eu.dzhw.fdz.metadatamanagement.searchmanagement.service.ElasticsearchUpdateQueueService;
import eu.dzhw.fdz.metadatamanagement.usermanagement.security.AuthoritiesConstants;
+import lombok.extern.slf4j.Slf4j;
/**
* REST controller for getting the search results.
*/
@RestController
+@Slf4j
public class SearchResource {
-
- private final Logger log = LoggerFactory.getLogger(SearchResource.class);
-
private RestTemplate restTemplate;
private String connectionUrl;
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/service/ElasticsearchIndicesInitializer.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/service/ElasticsearchIndicesInitializer.java
index 23fd9c7e4c..89da75b473 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/service/ElasticsearchIndicesInitializer.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/service/ElasticsearchIndicesInitializer.java
@@ -8,8 +8,6 @@
import javax.annotation.PostConstruct;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.core.io.ResourceLoader;
@@ -22,6 +20,7 @@
import eu.dzhw.fdz.metadatamanagement.common.config.MetadataManagementProperties;
import eu.dzhw.fdz.metadatamanagement.searchmanagement.domain.ElasticsearchIndicesVersion;
import eu.dzhw.fdz.metadatamanagement.searchmanagement.repository.ElasticsearchIndicesVersionRepository;
+import lombok.extern.slf4j.Slf4j;
/**
* Bean which recreates all elasticsearch indices on container start
@@ -31,10 +30,8 @@
*/
@Component
@Profile("!" + Constants.SPRING_PROFILE_UNITTEST)
+@Slf4j
public class ElasticsearchIndicesInitializer {
-
- private final Logger log = LoggerFactory.getLogger(ElasticsearchIndicesInitializer.class);
-
@Autowired
private ResourceLoader resourceLoader;
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/service/ElasticsearchUpdateQueueService.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/service/ElasticsearchUpdateQueueService.java
index 66e3b35bf0..b1a75c2204 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/service/ElasticsearchUpdateQueueService.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/service/ElasticsearchUpdateQueueService.java
@@ -9,8 +9,6 @@
import java.util.stream.Collectors;
import org.apache.commons.lang3.NotImplementedException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.scheduling.annotation.Scheduled;
@@ -57,6 +55,7 @@
import io.searchbox.core.Bulk.Builder;
import io.searchbox.core.Delete;
import io.searchbox.core.Index;
+import lombok.extern.slf4j.Slf4j;
/**
* Service which manages asynchronous Elasticsearch updates as a FIFO queue. Inserting an item into
@@ -67,10 +66,8 @@
* @author Daniel Katzberg
*/
@Service
+@Slf4j
public class ElasticsearchUpdateQueueService {
-
- private final Logger logger = LoggerFactory.getLogger(ElasticsearchUpdateQueueService.class);
-
// id used to synchronize multiple jvm instances
private String jvmId = ManagementFactory.getRuntimeMXBean().getName();
@@ -132,7 +129,7 @@ public void enqueue(String documentId, ElasticsearchType documentType,
queueItemRepository
.insert(new ElasticsearchUpdateQueueItem(documentId, documentType, action));
} catch (DuplicateKeyException ex) {
- logger.debug("Ignoring attempt to enqueue a duplicate action.");
+ log.debug("Ignoring attempt to enqueue a duplicate action.");
}
}
@@ -141,7 +138,7 @@ public void enqueue(String documentId, ElasticsearchType documentType,
*/
@Scheduled(fixedRate = 1000 * 60, initialDelay = 1000 * 60)
public void processAllQueueItems() {
- logger.info("Starting processing of ElasticsearchUpdateQueue...");
+ log.info("Starting processing of ElasticsearchUpdateQueue...");
LocalDateTime updateStart = LocalDateTime.now();
queueItemRepository.lockAllUnlockedOrExpiredItems(updateStart, jvmId);
@@ -155,7 +152,7 @@ public void processAllQueueItems() {
// check if there are more locked items to process
lockedItems = queueItemRepository.findOldestLockedItems(jvmId, updateStart);
}
- logger.info("Finished processing of ElasticsearchUpdateQueue...");
+ log.info("Finished processing of ElasticsearchUpdateQueue...");
}
/**
@@ -555,7 +552,7 @@ private void addUpsertActionForStudy(ElasticsearchUpdateQueueItem lockedItem,
* @param type the type of items to be processed.
*/
public void processQueueItems(ElasticsearchType type) {
- logger.info("Starting processing of ElasticsearchUpdateQueue for type: " + type.name());
+ log.info("Starting processing of ElasticsearchUpdateQueue for type: " + type.name());
LocalDateTime updateStart = LocalDateTime.now();
queueItemRepository.lockAllUnlockedOrExpiredItemsByType(updateStart, jvmId, type);
@@ -569,6 +566,6 @@ public void processQueueItems(ElasticsearchType type) {
// check if there are more locked items to process
lockedItems = queueItemRepository.findOldestLockedItemsByType(jvmId, updateStart, type);
}
- logger.info("Finished processing of ElasticsearchUpdateQueue for type: " + type.name());
+ log.info("Finished processing of ElasticsearchUpdateQueue for type: " + type.name());
}
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/studymanagement/domain/Study.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/studymanagement/domain/Study.java
index 3940e8ac7d..523b9c88d7 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/studymanagement/domain/Study.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/studymanagement/domain/Study.java
@@ -13,8 +13,6 @@
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
-import com.google.common.base.MoreObjects;
-
import eu.dzhw.fdz.metadatamanagement.common.domain.AbstractRdcDomainObject;
import eu.dzhw.fdz.metadatamanagement.common.domain.I18nString;
import eu.dzhw.fdz.metadatamanagement.common.domain.Person;
@@ -28,7 +26,12 @@
import eu.dzhw.fdz.metadatamanagement.studymanagement.domain.validation.ValidStudyId;
import eu.dzhw.fdz.metadatamanagement.studymanagement.domain.validation.ValidSurveyDesign;
import io.searchbox.annotations.JestId;
-import net.karneim.pojobuilder.GeneratePojoBuilder;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
/**
* The study domain object represents a study. A study can has more than one release.
@@ -38,9 +41,13 @@
*
*/
@Document(collection = "studies")
-@GeneratePojoBuilder(
- intoPackage = "eu.dzhw.fdz.metadatamanagement.studymanagement.domain.builders")
-@ValidStudyId(message = "study-management.error.study.id.not-valid-id")
+@ValidStudyId(message = "study-management.error.study.id.not-valid-id")
+@Data
+@EqualsAndHashCode(callSuper = false, of = "id")
+@ToString(callSuper = true)
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class Study extends AbstractRdcDomainObject {
@Id
@@ -102,132 +109,9 @@ public class Study extends AbstractRdcDomainObject {
@I18nStringSize(max = StringLengths.LARGE,
message = "study-management.error.variable.annotations.i18n-string-size")
private I18nString annotations;
-
- public Study() {
- super();
- }
public Study(Study study) {
super();
BeanUtils.copyProperties(study, this);
}
-
- @Override
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getDataAcquisitionProjectId() {
- return dataAcquisitionProjectId;
- }
-
- public void setDataAcquisitionProjectId(String dataAcquisitionProjectId) {
- this.dataAcquisitionProjectId = dataAcquisitionProjectId;
- }
-
- public I18nString getSurveySeries() {
- return surveySeries;
- }
-
- public void setSurveySeries(I18nString surveySeries) {
- this.surveySeries = surveySeries;
- }
-
- public I18nString getTitle() {
- return title;
- }
-
- public void setTitle(I18nString title) {
- this.title = title;
- }
-
- public I18nString getDescription() {
- return description;
- }
-
- public void setDescription(I18nString description) {
- this.description = description;
- }
-
- public I18nString getInstitution() {
- return institution;
- }
-
- public void setInstitution(I18nString institution) {
- this.institution = institution;
- }
-
- public I18nString getSponsor() {
- return sponsor;
- }
-
- public void setSponsor(I18nString sponsor) {
- this.sponsor = sponsor;
- }
-
- public List getAuthors() {
- return authors;
- }
-
- public void setAuthors(List authors) {
- this.authors = authors;
- }
-
- /*
- * (non-Javadoc)
- * @see eu.dzhw.fdz.metadatamanagement.common.domain.AbstractRdcDomainObject#toString()
- */
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("super", super.toString())
- .add("id", id)
- .add("title", title)
- .add("description", description)
- .add("institution", institution)
- .add("surveySeries", surveySeries)
- .add("sponsor", sponsor)
- .add("authors", authors)
- .add("dataAvailability", dataAvailability)
- .add("surveyDesign", surveyDesign)
- .add("dataAcquisitionProjectId", dataAcquisitionProjectId)
- .add("annotations", annotations)
- .toString();
- }
-
- public I18nString getDataAvailability() {
- return dataAvailability;
- }
-
- public void setDataAvailability(I18nString dataAvailability) {
- this.dataAvailability = dataAvailability;
- }
-
- public I18nString getSurveyDesign() {
- return surveyDesign;
- }
-
- public void setSurveyDesign(I18nString surveyDesign) {
- this.surveyDesign = surveyDesign;
- }
-
- public String getDoi() {
- return doi;
- }
-
- public void setDoi(String doi) {
- this.doi = doi;
- }
-
- public I18nString getAnnotations() {
- return annotations;
- }
-
- public void setAnnotations(I18nString annotations) {
- this.annotations = annotations;
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/studymanagement/domain/StudyAttachmentMetadata.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/studymanagement/domain/StudyAttachmentMetadata.java
index cfab49c0f0..22b431cc5b 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/studymanagement/domain/StudyAttachmentMetadata.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/studymanagement/domain/StudyAttachmentMetadata.java
@@ -12,13 +12,22 @@
import eu.dzhw.fdz.metadatamanagement.common.domain.validation.StringLengths;
import eu.dzhw.fdz.metadatamanagement.common.domain.validation.ValidIsoLanguage;
import eu.dzhw.fdz.metadatamanagement.studymanagement.domain.validation.ValidStudyAttachmentType;
-import net.karneim.pojobuilder.GeneratePojoBuilder;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
/**
* Metadata which will be stored in GridFS with each attachment for studies.
*/
-@GeneratePojoBuilder(
- intoPackage = "eu.dzhw.fdz.metadatamanagement.studymanagement.domain.builders")
+@Data
+@EqualsAndHashCode(callSuper = false, of = "id")
+@ToString(callSuper = true)
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class StudyAttachmentMetadata extends AbstractRdcDomainObject {
@NotEmpty(message =
"study-management.error.study-attachment-metadata.study-id.not-empty")
@@ -62,73 +71,8 @@ public class StudyAttachmentMetadata extends AbstractRdcDomainObject {
"study-management.error.study-attachment-metadata.language.not-supported")
private String language;
- public String getStudyId() {
- return studyId;
- }
-
- public void setStudyId(String studyId) {
- this.studyId = studyId;
- }
-
- public String getDataAcquisitionProjectId() {
- return dataAcquisitionProjectId;
- }
-
- public void setDataAcquisitionProjectId(String dataAcquisitionProjectId) {
- this.dataAcquisitionProjectId = dataAcquisitionProjectId;
- }
-
- public Integer getIndexInStudy() {
- return indexInStudy;
- }
-
- public void setIndexInStudy(Integer indexInStudy) {
- this.indexInStudy = indexInStudy;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public I18nString getDescription() {
- return description;
- }
-
- public void setDescription(I18nString description) {
- this.description = description;
- }
-
- public I18nString getType() {
- return type;
- }
-
- public void setType(I18nString type) {
- this.type = type;
- }
-
- public String getFileName() {
- return fileName;
- }
-
- public void setFileName(String fileName) {
- this.fileName = fileName;
- }
-
- public String getLanguage() {
- return language;
- }
-
- public void setLanguage(String language) {
- this.language = language;
- }
-
@Override
public String getId() {
return "/public/files/studies/" + studyId + "/attachments/" + fileName;
- }
-
+ }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/domain/Survey.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/domain/Survey.java
index b7ec5ff8e6..eca858b8c0 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/domain/Survey.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/domain/Survey.java
@@ -11,8 +11,6 @@
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
-import com.google.common.base.MoreObjects;
-
import eu.dzhw.fdz.metadatamanagement.common.domain.AbstractRdcDomainObject;
import eu.dzhw.fdz.metadatamanagement.common.domain.I18nString;
import eu.dzhw.fdz.metadatamanagement.common.domain.Period;
@@ -24,7 +22,12 @@
import eu.dzhw.fdz.metadatamanagement.surveymanagement.domain.validation.ValidSurveyIdName;
import eu.dzhw.fdz.metadatamanagement.surveymanagement.domain.validation.ValidUniqueSurveyNumber;
import io.searchbox.annotations.JestId;
-import net.karneim.pojobuilder.GeneratePojoBuilder;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
/**
* A Survey.
@@ -32,11 +35,15 @@
* @author Daniel Katzberg
*/
@Document(collection = "surveys")
-@GeneratePojoBuilder(
- intoPackage = "eu.dzhw.fdz.metadatamanagement.surveymanagement.domain.builders")
@ValidSurveyIdName(message = "survey-management.error.survey.id.valid-survey-id-name")
@ValidUniqueSurveyNumber(message = "survey-management.error"
+ ".survey.unique-survey-number")
+@Data
+@EqualsAndHashCode(callSuper = false, of = "id")
+@ToString(callSuper = true)
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class Survey extends AbstractRdcDomainObject {
@Id
@@ -104,166 +111,8 @@ public class Survey extends AbstractRdcDomainObject {
message = "variable-management.error.variable.annotations.i18n-string-size")
private I18nString annotations;
- public Survey() {
- super();
- }
-
public Survey(Survey survey) {
super();
BeanUtils.copyProperties(survey, this);
}
-
- @Override
- public String getId() {
- return id;
- }
-
- public String getDataAcquisitionProjectId() {
- return dataAcquisitionProjectId;
- }
-
- public void setDataAcquisitionProjectId(String dataAcquisitionProjectId) {
- this.dataAcquisitionProjectId = dataAcquisitionProjectId;
- }
-
- public I18nString getTitle() {
- return title;
- }
-
- public void setTitle(I18nString title) {
- this.title = title;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public I18nString getPopulation() {
- return population;
- }
-
- public void setPopulation(I18nString population) {
- this.population = population;
- }
-
- public I18nString getSurveyMethod() {
- return surveyMethod;
- }
-
- public void setSurveyMethod(I18nString surveyMethod) {
- this.surveyMethod = surveyMethod;
- }
-
- public Integer getNumber() {
- return number;
- }
-
- public void setNumber(Integer number) {
- this.number = number;
- }
-
- /*
- * (non-Javadoc)
- * @see eu.dzhw.fdz.metadatamanagement.common.domain.AbstractRdcDomainObject#toString()
- */
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("super", super.toString())
- .add("id", id)
- .add("title", title)
- .add("fieldPeriod", fieldPeriod)
- .add("dataAcquisitionProjectId", dataAcquisitionProjectId)
- .add("population", population)
- .add("sample", sample)
- .add("surveyMethod", surveyMethod)
- .add("grossSampleSize", grossSampleSize)
- .add("sampleSize", sampleSize)
- .add("responseRate", responseRate)
- .add("number", number)
- .add("studyId", studyId)
- .add("annotations", annotations)
- .add("wave", wave)
- .add("dataType", dataType)
- .toString();
- }
-
- public Period getFieldPeriod() {
- return fieldPeriod;
- }
-
- public void setFieldPeriod(Period fieldPeriod) {
- this.fieldPeriod = fieldPeriod;
- }
-
- public I18nString getSample() {
- return sample;
- }
-
- public void setSample(I18nString sample) {
- this.sample = sample;
- }
-
- public Integer getGrossSampleSize() {
- return grossSampleSize;
- }
-
-
- public void setGrossSampleSize(Integer grossSampleSize) {
- this.grossSampleSize = grossSampleSize;
- }
-
-
- public Integer getSampleSize() {
- return sampleSize;
- }
-
-
- public void setSampleSize(Integer sampleSize) {
- this.sampleSize = sampleSize;
- }
-
-
- public Double getResponseRate() {
- return responseRate;
- }
-
-
- public void setResponseRate(Double responseRate) {
- this.responseRate = responseRate;
- }
-
-
- public String getStudyId() {
- return studyId;
- }
-
-
- public void setStudyId(String studyId) {
- this.studyId = studyId;
- }
-
- public I18nString getAnnotations() {
- return annotations;
- }
-
- public void setAnnotations(I18nString annotations) {
- this.annotations = annotations;
- }
-
- public Integer getWave() {
- return wave;
- }
-
- public void setWave(Integer wave) {
- this.wave = wave;
- }
-
- public I18nString getDataType() {
- return dataType;
- }
-
- public void setDataType(I18nString dataType) {
- this.dataType = dataType;
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/domain/SurveyAttachmentMetadata.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/domain/SurveyAttachmentMetadata.java
index 360887a0a4..e4ff25bfac 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/domain/SurveyAttachmentMetadata.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/domain/SurveyAttachmentMetadata.java
@@ -11,14 +11,22 @@
import eu.dzhw.fdz.metadatamanagement.common.domain.validation.I18nStringSize;
import eu.dzhw.fdz.metadatamanagement.common.domain.validation.StringLengths;
import eu.dzhw.fdz.metadatamanagement.common.domain.validation.ValidIsoLanguage;
-import net.karneim.pojobuilder.GeneratePojoBuilder;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
/**
* Metadata which will be stored in GridFS with each attachment for surveys.
- *
*/
-@GeneratePojoBuilder(
- intoPackage = "eu.dzhw.fdz.metadatamanagement.surveymanagement.domain.builders")
+@Data
+@EqualsAndHashCode(callSuper = false, of = "id")
+@ToString(callSuper = true)
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class SurveyAttachmentMetadata extends AbstractRdcDomainObject {
@NotEmpty(message =
"survey-management.error.survey-attachment-metadata.survey-id.not-empty")
@@ -64,68 +72,4 @@ public class SurveyAttachmentMetadata extends AbstractRdcDomainObject {
public String getId() {
return "/public/files/surveys/" + surveyId + "/attachments/" + fileName;
}
-
- public String getSurveyId() {
- return surveyId;
- }
-
- public void setSurveyId(String surveyId) {
- this.surveyId = surveyId;
- }
-
- public String getDataAcquisitionProjectId() {
- return dataAcquisitionProjectId;
- }
-
- public void setDataAcquisitionProjectId(String dataAcquisitionProjectId) {
- this.dataAcquisitionProjectId = dataAcquisitionProjectId;
- }
-
- public I18nString getDescription() {
- return description;
- }
-
- public void setDescription(I18nString description) {
- this.description = description;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public String getLanguage() {
- return language;
- }
-
- public void setLanguage(String language) {
- this.language = language;
- }
-
- public String getFileName() {
- return fileName;
- }
-
- public void setFileName(String fileName) {
- this.fileName = fileName;
- }
-
- public Integer getSurveyNumber() {
- return surveyNumber;
- }
-
- public void setSurveyNumber(Integer surveyNumber) {
- this.surveyNumber = surveyNumber;
- }
-
- public Integer getIndexInSurvey() {
- return indexInSurvey;
- }
-
- public void setIndexInSurvey(Integer indexInSurvey) {
- this.indexInSurvey = indexInSurvey;
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/domain/User.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/domain/User.java
index 241e7bcb21..1cef589e39 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/domain/User.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/domain/User.java
@@ -2,7 +2,6 @@
import java.io.Serializable;
import java.time.LocalDateTime;
-import java.util.HashSet;
import java.util.Set;
import javax.validation.constraints.NotNull;
@@ -18,13 +17,23 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import eu.dzhw.fdz.metadatamanagement.common.domain.AbstractRdcDomainObject;
-import net.karneim.pojobuilder.GeneratePojoBuilder;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
/**
* A user.
*/
@Document(collection = "jhi_user")
-@GeneratePojoBuilder(intoPackage = "eu.dzhw.fdz.metadatamanagement.usermanagement.domain.builders")
+@Data
+@EqualsAndHashCode(callSuper = false, of = "login")
+@ToString(callSuper = true)
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class User extends AbstractRdcDomainObject implements Serializable {
private static final long serialVersionUID = 1L;
@@ -56,6 +65,7 @@ public class User extends AbstractRdcDomainObject implements Serializable {
@Indexed(unique = true)
private String email;
+ @Builder.Default
private boolean activated = false;
@Size(min = 2, max = 5)
@@ -72,140 +82,9 @@ public class User extends AbstractRdcDomainObject implements Serializable {
private String resetKey;
@Field("reset_date")
+ @Builder.Default
private LocalDateTime resetDate = null;
@JsonIgnore
- private Set authorities = new HashSet<>();
-
- @Override
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getLogin() {
- return login;
- }
-
- public void setLogin(String login) {
- this.login = login;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
- public String getFirstName() {
- return firstName;
- }
-
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
-
- public String getLastName() {
- return lastName;
- }
-
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
-
- public String getEmail() {
- return email;
- }
-
- public void setEmail(String email) {
- this.email = email;
- }
-
- public boolean getActivated() {
- return activated;
- }
-
- public void setActivated(boolean activated) {
- this.activated = activated;
- }
-
- public String getActivationKey() {
- return activationKey;
- }
-
- public void setActivationKey(String activationKey) {
- this.activationKey = activationKey;
- }
-
- public String getResetKey() {
- return resetKey;
- }
-
- public void setResetKey(String resetKey) {
- this.resetKey = resetKey;
- }
-
- public LocalDateTime getResetDate() {
- return resetDate;
- }
-
- public void setResetDate(LocalDateTime resetDate) {
- this.resetDate = resetDate;
- }
-
- public String getLangKey() {
- return langKey;
- }
-
- public void setLangKey(String langKey) {
- this.langKey = langKey;
- }
-
- public Set getAuthorities() {
- return authorities;
- }
-
- public void setAuthorities(Set authorities) {
- this.authorities = authorities;
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object == null || getClass() != object.getClass()) {
- return false;
- }
-
- User user = (User) object;
-
- if (login != null && !login.equals(user.login)) {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode() {
-
- if (login == null) {
- return 0;
- }
-
- return login.hashCode();
- }
-
- @Override
- public String toString() {
- return "User{" + "login='" + login + '\'' + ", firstName='" + firstName + '\'' + ", lastName='"
- + lastName + '\'' + ", email='" + email + '\'' + ", activated='" + activated + '\''
- + ", langKey='" + langKey + '\'' + ", activationKey='" + activationKey + '\'' + "}";
- }
+ private Set authorities;
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/rest/AccountResource.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/rest/AccountResource.java
index 6503c43571..58f09442f4 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/rest/AccountResource.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/rest/AccountResource.java
@@ -7,8 +7,6 @@
import javax.validation.Valid;
import org.apache.commons.lang.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
@@ -30,16 +28,15 @@
import eu.dzhw.fdz.metadatamanagement.usermanagement.security.AuthoritiesConstants;
import eu.dzhw.fdz.metadatamanagement.usermanagement.security.SecurityUtils;
import eu.dzhw.fdz.metadatamanagement.usermanagement.service.UserService;
+import lombok.extern.slf4j.Slf4j;
/**
* REST controller for managing the current user's account.
*/
@RestController
@RequestMapping("/api")
+@Slf4j
public class AccountResource {
-
- private final Logger log = LoggerFactory.getLogger(AccountResource.class);
-
@Autowired
private UserRepository userRepository;
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/rest/UserResource.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/rest/UserResource.java
index a0b0fd3136..1fec8c47a6 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/rest/UserResource.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/rest/UserResource.java
@@ -6,8 +6,6 @@
import java.util.Set;
import java.util.stream.Collectors;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -32,6 +30,7 @@
import eu.dzhw.fdz.metadatamanagement.usermanagement.rest.dto.ManagedUserDto;
import eu.dzhw.fdz.metadatamanagement.usermanagement.security.AuthoritiesConstants;
import eu.dzhw.fdz.metadatamanagement.usermanagement.service.UserService;
+import lombok.extern.slf4j.Slf4j;
/**
* REST controller for managing users.
@@ -64,10 +63,8 @@
*/
@RestController
@RequestMapping("/api")
+@Slf4j
public class UserResource {
-
- private final Logger log = LoggerFactory.getLogger(UserResource.class);
-
@Autowired
private UserRepository userRepository;
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/rest/dto/UserDto.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/rest/dto/UserDto.java
index 7d7a1635aa..fb5c95fe75 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/rest/dto/UserDto.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/rest/dto/UserDto.java
@@ -53,7 +53,7 @@ public UserDto() {}
*/
public UserDto(User user) {
this(user.getLogin(), null, user.getFirstName(), user.getLastName(), user.getEmail(),
- user.getActivated(), user.getLangKey(), user.getAuthorities()
+ user.isActivated(), user.getLangKey(), user.getAuthorities()
.stream()
.map(Authority::getName)
.collect(Collectors.toSet()));
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/security/Http401UnauthorizedEntryPoint.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/security/Http401UnauthorizedEntryPoint.java
index 212ff57ec0..bfc1294d09 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/security/Http401UnauthorizedEntryPoint.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/security/Http401UnauthorizedEntryPoint.java
@@ -6,20 +6,18 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;
+import lombok.extern.slf4j.Slf4j;
+
/**
* Returns a 401 error code (Unauthorized) to the client.
*/
@Component
+@Slf4j
public class Http401UnauthorizedEntryPoint implements AuthenticationEntryPoint {
-
- private final Logger log = LoggerFactory.getLogger(Http401UnauthorizedEntryPoint.class);
-
/**
* Always returns a 401 error code to the client.
*/
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/security/UserDetailsServiceImpl.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/security/UserDetailsServiceImpl.java
index 8df6578569..4a7615eef0 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/security/UserDetailsServiceImpl.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/security/UserDetailsServiceImpl.java
@@ -4,8 +4,6 @@
import java.util.Set;
import java.util.stream.Collectors;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.security.core.GrantedAuthority;
@@ -18,15 +16,14 @@
import eu.dzhw.fdz.metadatamanagement.usermanagement.domain.User;
import eu.dzhw.fdz.metadatamanagement.usermanagement.repository.UserRepository;
+import lombok.extern.slf4j.Slf4j;
/**
* Authenticate a user from the database.
*/
@Component("userDetailsService")
+@Slf4j
public class UserDetailsServiceImpl implements UserDetailsService {
-
- private final Logger log = LoggerFactory.getLogger(UserDetailsServiceImpl.class);
-
@Autowired
private UserRepository userRepository;
@@ -37,7 +34,7 @@ public UserDetails loadUserByUsername(final String login) {
String lowercaseLogin = login.toLowerCase(LocaleContextHolder.getLocale());
Optional userFromDatabase = userRepository.findOneByLogin(lowercaseLogin);
return userFromDatabase.map(user -> {
- if (!user.getActivated()) {
+ if (!user.isActivated()) {
throw new UserNotActivatedException("User " + lowercaseLogin + " was not activated");
}
Set grantedAuthorities = user.getAuthorities()
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/service/UserService.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/service/UserService.java
index 42cda79b49..18ebd4feca 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/service/UserService.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/service/UserService.java
@@ -6,8 +6,6 @@
import java.util.Optional;
import java.util.Set;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.security.crypto.password.PasswordEncoder;
@@ -20,15 +18,14 @@
import eu.dzhw.fdz.metadatamanagement.usermanagement.security.AuthoritiesConstants;
import eu.dzhw.fdz.metadatamanagement.usermanagement.security.SecurityUtils;
import eu.dzhw.fdz.metadatamanagement.usermanagement.service.util.RandomUtil;
+import lombok.extern.slf4j.Slf4j;
/**
* Service class for managing users.
*/
@Service
+@Slf4j
public class UserService {
-
- private final Logger log = LoggerFactory.getLogger(UserService.class);
-
@Autowired
private PasswordEncoder passwordEncoder;
@@ -81,7 +78,7 @@ public Optional completePasswordReset(String newPassword, String key) {
*/
public Optional requestPasswordReset(String mail) {
return userRepository.findOneByEmail(mail)
- .filter(user -> user.getActivated())
+ .filter(user -> user.isActivated())
.map(user -> {
user.setResetKey(RandomUtil.generateResetKey());
user.setResetDate(LocalDateTime.now());
@@ -167,7 +164,7 @@ public User getUserWithAuthorities(String id) {
User user = userRepository.findOne(id);
int size = user.getAuthorities()
.size(); // eagerly load the association
- this.log.debug("user.getAuthorities().size() = " + size);
+ log.debug("user.getAuthorities().size() = " + size);
return user;
}
@@ -180,7 +177,7 @@ public User getUserWithAuthorities() {
.get();
int size = user.getAuthorities()
.size(); // eagerly load the association
- this.log.debug("user.getAuthorities().size() = " + size);
+ log.debug("user.getAuthorities().size() = " + size);
return user;
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/websocket/UserMessagesController.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/websocket/UserMessagesController.java
index 6cc755da6c..1cc56448c3 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/websocket/UserMessagesController.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/usermanagement/websocket/UserMessagesController.java
@@ -1,7 +1,5 @@
package eu.dzhw.fdz.metadatamanagement.usermanagement.websocket;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.messaging.handler.annotation.MessageMapping;
@@ -14,6 +12,7 @@
import org.springframework.stereotype.Controller;
import eu.dzhw.fdz.metadatamanagement.usermanagement.websocket.dto.MessageDto;
+import lombok.extern.slf4j.Slf4j;
/**
* Controller for sending messages via websockets to users.
@@ -21,10 +20,8 @@
* @author René Reitmann
*/
@Controller
+@Slf4j
public class UserMessagesController {
-
- private final Logger log = LoggerFactory.getLogger(UserMessagesController.class);
-
@Autowired
private TokenStore tokenStore;
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/Distribution.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/Distribution.java
index f3f003ad25..e37a7fd1c2 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/Distribution.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/Distribution.java
@@ -5,11 +5,12 @@
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
-import com.google.common.base.MoreObjects;
-
import eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.validation.UniqueCode;
import eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.validation.UniqueValue;
-import net.karneim.pojobuilder.GeneratePojoBuilder;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
/**
* Domain object of the ValueSummary. Represent sums for all values of the variable.
@@ -17,8 +18,10 @@
* @author Daniel Katzberg
*
*/
-@GeneratePojoBuilder(
- intoPackage = "eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.builders")
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class Distribution {
@NotNull(message =
@@ -50,81 +53,4 @@ public class Distribution {
"variable-management.error.distribution.valid-responses.unique-value")
@Valid
private List validResponses;
-
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("totalAbsoluteFrequency", totalAbsoluteFrequency)
- .add("totalValidAbsoluteFrequency", totalValidAbsoluteFrequency)
- .add("totalValidRelativeFrequency", totalValidRelativeFrequency)
- .add("histogram", histogram)
- .add("statistics", statistics)
- .add("missings", missings)
- .add("validResponses", validResponses)
- .toString();
- }
-
- /*
- * GETTER / SETTER
- */
- public Integer getTotalAbsoluteFrequency() {
- return totalAbsoluteFrequency;
- }
-
- public void setTotalAbsoluteFrequency(Integer totalAbsoluteFrequency) {
- this.totalAbsoluteFrequency = totalAbsoluteFrequency;
- }
-
- public Integer getTotalValidAbsoluteFrequency() {
- return totalValidAbsoluteFrequency;
- }
-
- public void setTotalValidAbsoluteFrequency(Integer totalValidAbsoluteFrequency) {
- this.totalValidAbsoluteFrequency = totalValidAbsoluteFrequency;
- }
-
- public Double getTotalValidRelativeFrequency() {
- return totalValidRelativeFrequency;
- }
-
- public void setTotalValidRelativeFrequency(Double totalValidRelativeFrequency) {
- this.totalValidRelativeFrequency = totalValidRelativeFrequency;
- }
-
- public Statistics getStatistics() {
- return statistics;
- }
-
- public void setStatistics(Statistics statistics) {
- this.statistics = statistics;
- }
-
- public List getMissings() {
- return missings;
- }
-
- public void setMissings(List missings) {
- this.missings = missings;
- }
-
- public List getValidResponses() {
- return validResponses;
- }
-
- public void setValidResponses(List validResponses) {
- this.validResponses = validResponses;
- }
-
- public Histogram getHistogram() {
- return histogram;
- }
-
- public void setHistogram(Histogram histogram) {
- this.histogram = histogram;
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/FilterDetails.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/FilterDetails.java
index 11e59113e1..1545bd17d6 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/FilterDetails.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/FilterDetails.java
@@ -4,13 +4,14 @@
import org.hibernate.validator.constraints.NotEmpty;
-import com.google.common.base.MoreObjects;
-
import eu.dzhw.fdz.metadatamanagement.common.domain.I18nString;
import eu.dzhw.fdz.metadatamanagement.common.domain.validation.I18nStringSize;
import eu.dzhw.fdz.metadatamanagement.common.domain.validation.StringLengths;
import eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.validation.ValidFilterExpressionLanguage;
-import net.karneim.pojobuilder.GeneratePojoBuilder;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
/**
* FilterDetails of variable.
@@ -18,8 +19,10 @@
* @author Daniel Katzberg
*
*/
-@GeneratePojoBuilder(
- intoPackage = "eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.builders")
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class FilterDetails {
@NotEmpty(message = "variable-management.error.filter-details.expression.not-empty")
@@ -37,42 +40,4 @@ public class FilterDetails {
message = "variable-management.error.filter-details."
+ "expression-language.valid-filter-expression-language")
private String expressionLanguage;
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("expression", expression)
- .add("description", description)
- .add("expressionLanguage", expressionLanguage)
- .toString();
- }
-
- /* GETTER / SETTER */
- public String getExpression() {
- return expression;
- }
-
- public void setExpression(String expression) {
- this.expression = expression;
- }
-
- public I18nString getDescription() {
- return description;
- }
-
- public void setDescription(I18nString description) {
- this.description = description;
- }
-
- public String getExpressionLanguage() {
- return expressionLanguage;
- }
-
- public void setExpressionLanguage(String expressionLanguage) {
- this.expressionLanguage = expressionLanguage;
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/GenerationDetails.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/GenerationDetails.java
index c482613287..e44ed02e74 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/GenerationDetails.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/GenerationDetails.java
@@ -2,15 +2,16 @@
import javax.validation.constraints.Size;
-import com.google.common.base.MoreObjects;
-
import eu.dzhw.fdz.metadatamanagement.common.domain.I18nString;
import eu.dzhw.fdz.metadatamanagement.common.domain.validation.I18nStringSize;
import eu.dzhw.fdz.metadatamanagement.common.domain.validation.StringLengths;
import eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.validation.NotEmptyGenerationDetailsDescriptionOrRule;
import eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.validation.RuleExpressionLanguageAndRuleFilledOrEmpty;
import eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.validation.ValidRuleExpressionLanguage;
-import net.karneim.pojobuilder.GeneratePojoBuilder;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
/**
* Generation Details.
@@ -18,14 +19,16 @@
* @author Daniel Katzberg
*
*/
-@GeneratePojoBuilder(
- intoPackage = "eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.builders")
@NotEmptyGenerationDetailsDescriptionOrRule(
message = "variable-management.error.generation-details."
+ "not-empty-generation-details-description-or-rule")
@RuleExpressionLanguageAndRuleFilledOrEmpty(
message = "variable-management.error.generation-details."
+ "rule-expression-language-and-rule-filled-or-empty")
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class GenerationDetails {
@I18nStringSize(max = StringLengths.LARGE,
@@ -40,43 +43,4 @@ public class GenerationDetails {
message = "variable-management.error.generation-details."
+ "rule-expression-language.valid-rule-expression-language")
private String ruleExpressionLanguage;
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("description", description)
- .add("rule", rule)
- .add("ruleExpressionLanguage", ruleExpressionLanguage)
- .toString();
- }
-
- /* GETTER / SETTER */
- public I18nString getDescription() {
- return description;
- }
-
- public void setDescription(I18nString description) {
- this.description = description;
- }
-
- public String getRule() {
- return rule;
- }
-
- public void setRule(String rule) {
- this.rule = rule;
- }
-
- public String getRuleExpressionLanguage() {
- return ruleExpressionLanguage;
- }
-
- public void setRuleExpressionLanguage(String ruleExpressionLanguage) {
- this.ruleExpressionLanguage = ruleExpressionLanguage;
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/Histogram.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/Histogram.java
index b2e9f6ca91..899119f7c1 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/Histogram.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/Histogram.java
@@ -1,8 +1,9 @@
package eu.dzhw.fdz.metadatamanagement.variablemanagement.domain;
-import com.google.common.base.MoreObjects;
-
-import net.karneim.pojobuilder.GeneratePojoBuilder;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
/**
* Representation of data for a histogram.
@@ -10,8 +11,10 @@
* @author Daniel Katzberg
*
*/
-@GeneratePojoBuilder(
- intoPackage = "eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.builders")
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class Histogram {
private Integer numberOfBins;
@@ -19,43 +22,4 @@ public class Histogram {
private Double start;
private Double end;
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("numberOfBins", numberOfBins)
- .add("start", start)
- .add("end", end)
- .toString();
- }
-
- /* GETTER / SETTER */
- public Integer getNumberOfBins() {
- return numberOfBins;
- }
-
- public void setNumberOfBins(Integer numberOfBins) {
- this.numberOfBins = numberOfBins;
- }
-
- public Double getStart() {
- return start;
- }
-
- public void setStart(Double start) {
- this.start = start;
- }
-
- public Double getEnd() {
- return end;
- }
-
- public void setEnd(Double end) {
- this.end = end;
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/Missing.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/Missing.java
index d19b3a1f03..2894397473 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/Missing.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/Missing.java
@@ -5,12 +5,13 @@
import org.hibernate.validator.constraints.NotEmpty;
-import com.google.common.base.MoreObjects;
-
import eu.dzhw.fdz.metadatamanagement.common.domain.I18nString;
import eu.dzhw.fdz.metadatamanagement.common.domain.validation.I18nStringSize;
import eu.dzhw.fdz.metadatamanagement.common.domain.validation.StringLengths;
-import net.karneim.pojobuilder.GeneratePojoBuilder;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
/**
* The missing includes a code, a label and frequencies. There are no calculations of the
@@ -19,8 +20,10 @@
*
* @author Daniel Katzberg
*/
-@GeneratePojoBuilder(
- intoPackage = "eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.builders")
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class Missing {
@NotEmpty(message = "variable-management.error.missing.code.not-null")
@@ -35,52 +38,4 @@ public class Missing {
@NotNull(message = "variable-management.error.missing.relative-frequency.not-null")
private Double relativeFrequency;
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("code", code)
- .add("label", label)
- .add("absoluteFrequency", absoluteFrequency)
- .add("relativeFrequency", relativeFrequency)
- .toString();
- }
-
- /* GETTER / SETTER */
- public String getCode() {
- return code;
- }
-
- public void setCode(String code) {
- this.code = code;
- }
-
- public I18nString getLabel() {
- return label;
- }
-
- public void setLabel(I18nString label) {
- this.label = label;
- }
-
- public Integer getAbsoluteFrequency() {
- return absoluteFrequency;
- }
-
- public void setAbsoluteFrequency(Integer absoluteFrequency) {
- this.absoluteFrequency = absoluteFrequency;
- }
-
- public Double getRelativeFrequency() {
- return relativeFrequency;
- }
-
- public void setRelativeFrequency(Double relativeFrequency) {
- this.relativeFrequency = relativeFrequency;
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/RelatedQuestion.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/RelatedQuestion.java
index bf284adde1..e6134d8e70 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/RelatedQuestion.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/RelatedQuestion.java
@@ -5,12 +5,13 @@
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.data.mongodb.core.index.Indexed;
-import com.google.common.base.MoreObjects;
-
import eu.dzhw.fdz.metadatamanagement.common.domain.I18nString;
import eu.dzhw.fdz.metadatamanagement.common.domain.validation.I18nStringSize;
import eu.dzhw.fdz.metadatamanagement.common.domain.validation.StringLengths;
-import net.karneim.pojobuilder.GeneratePojoBuilder;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
/**
* The related Question includes the references to the question and instrument. This is a sub
@@ -19,8 +20,10 @@
* @author Daniel Katzberg
*
*/
-@GeneratePojoBuilder(
- intoPackage = "eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.builders")
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class RelatedQuestion {
/* Domain Object listed attributes */
@@ -47,61 +50,4 @@ public class RelatedQuestion {
@Indexed
private String instrumentId;
-
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("instrumentNumber", instrumentNumber)
- .add("questionNumber", questionNumber)
- .add("questionId", questionId)
- .add("instrumentId", instrumentId)
- .add("relatedQuestionStrings", relatedQuestionStrings)
- .toString();
- }
-
- /* GETTER / SETTER */
- public String getInstrumentNumber() {
- return instrumentNumber;
- }
-
- public void setInstrumentNumber(String instrumentNumber) {
- this.instrumentNumber = instrumentNumber;
- }
-
- public String getQuestionNumber() {
- return questionNumber;
- }
-
- public void setQuestionNumber(String questionNumber) {
- this.questionNumber = questionNumber;
- }
-
- public String getQuestionId() {
- return questionId;
- }
-
- public void setQuestionId(String questionId) {
- this.questionId = questionId;
- }
-
- public String getInstrumentId() {
- return instrumentId;
- }
-
- public void setInstrumentId(String instrumentId) {
- this.instrumentId = instrumentId;
- }
-
- public I18nString getRelatedQuestionStrings() {
- return relatedQuestionStrings;
- }
-
- public void setRelatedQuestionStrings(I18nString relatedQuestionStrings) {
- this.relatedQuestionStrings = relatedQuestionStrings;
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/Statistics.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/Statistics.java
index c9b27ee5f3..b7da1bf86d 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/Statistics.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/Statistics.java
@@ -2,10 +2,11 @@
import javax.validation.constraints.Size;
-import com.google.common.base.MoreObjects;
-
import eu.dzhw.fdz.metadatamanagement.common.domain.validation.StringLengths;
-import net.karneim.pojobuilder.GeneratePojoBuilder;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
/**
* This statics class has statistical information about a variable. The information of this class
@@ -14,8 +15,10 @@
* @author Daniel Katzberg
*
*/
-@GeneratePojoBuilder(
- intoPackage = "eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.builders")
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class Statistics {
private Double meanValue;
@@ -55,141 +58,4 @@ public class Statistics {
private Double deviance;
private Double meanDeviation;
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("meanValue", meanValue)
- .add("minimum", minimum)
- .add("maximum", maximum)
- .add("skewness", skewness)
- .add("kurtosis", kurtosis)
- .add("median", median)
- .add("standardDeviation", standardDeviation)
- .add("firstQuartile", firstQuartile)
- .add("thirdQuartile", thirdQuartile)
- .add("lowWhisker", lowWhisker)
- .add("highWhisker", highWhisker)
- .add("mode", mode)
- .add("deviance", deviance)
- .add("meanDeviation", meanDeviation)
- .toString();
- }
-
- /* GETTER / SETTER */
- public Double getMeanValue() {
- return meanValue;
- }
-
- public void setMeanValue(Double meanValue) {
- this.meanValue = meanValue;
- }
-
- public Double getSkewness() {
- return skewness;
- }
-
- public void setSkewness(Double skewness) {
- this.skewness = skewness;
- }
-
- public Double getKurtosis() {
- return kurtosis;
- }
-
- public void setKurtosis(Double kurtosis) {
- this.kurtosis = kurtosis;
- }
-
- public Double getStandardDeviation() {
- return standardDeviation;
- }
-
- public void setStandardDeviation(Double standardDeviation) {
- this.standardDeviation = standardDeviation;
- }
-
- public Double getLowWhisker() {
- return lowWhisker;
- }
-
- public void setLowWhisker(Double lowWhisker) {
- this.lowWhisker = lowWhisker;
- }
-
- public Double getHighWhisker() {
- return highWhisker;
- }
-
- public void setHighWhisker(Double highWhisker) {
- this.highWhisker = highWhisker;
- }
-
- public String getMode() {
- return mode;
- }
-
- public void setMode(String mode) {
- this.mode = mode;
- }
-
- public Double getDeviance() {
- return deviance;
- }
-
- public void setDeviance(Double deviance) {
- this.deviance = deviance;
- }
-
- public Double getMeanDeviation() {
- return meanDeviation;
- }
-
- public void setMeanDeviation(Double meanDeviation) {
- this.meanDeviation = meanDeviation;
- }
-
- public String getMinimum() {
- return minimum;
- }
-
- public void setMinimum(String minimum) {
- this.minimum = minimum;
- }
-
- public String getMaximum() {
- return maximum;
- }
-
- public void setMaximum(String maximum) {
- this.maximum = maximum;
- }
-
- public String getMedian() {
- return median;
- }
-
- public void setMedian(String median) {
- this.median = median;
- }
-
- public String getFirstQuartile() {
- return firstQuartile;
- }
-
- public void setFirstQuartile(String firstQuartile) {
- this.firstQuartile = firstQuartile;
- }
-
- public String getThirdQuartile() {
- return thirdQuartile;
- }
-
- public void setThirdQuartile(String thirdQuartile) {
- this.thirdQuartile = thirdQuartile;
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/StorageTypes.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/StorageTypes.java
new file mode 100644
index 0000000000..5c85ada0a9
--- /dev/null
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/StorageTypes.java
@@ -0,0 +1,43 @@
+package eu.dzhw.fdz.metadatamanagement.variablemanagement.domain;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * The DataType enumeration.
+ */
+public class StorageTypes {
+
+ public static final String LOGICAL = "logical";
+ public static final String INTEGER = "integer";
+ public static final String DOUBLE = "double";
+ public static final String COMPLEX = "complex";
+ public static final String CHARACTER = "character";
+ public static final String RAW = "raw";
+ public static final String LIST = "list";
+ public static final String NULL = "null";
+ public static final String CLOSURE = "closure";
+ public static final String SPECIAL = "special";
+ public static final String BUILTIN = "builtin";
+ public static final String ENVIRONMENT = "environment";
+ public static final String S4 = "S4";
+ public static final String SYMBOL = "symbol";
+ public static final String PROMISE = "promise";
+ public static final String PAIRLIST = "pairlist";
+ public static final String LANGUAGE = "language";
+ public static final String CHAR = "char";
+ public static final String DOTDOTDOT = "...";
+ public static final String ANY = "any";
+ public static final String EXPRESSION = "expression";
+ public static final String EXTERNALPTR = "externalptr";
+ public static final String BYTECODE = "bytecode";
+ public static final String WEAKREF = "weakref";
+ public static final Set ALL =
+ Collections.unmodifiableSet(new HashSet(Arrays.asList(
+ LOGICAL, INTEGER, DOUBLE, COMPLEX, CHARACTER, RAW, LIST, NULL,
+ CLOSURE, SPECIAL, BUILTIN, ENVIRONMENT, S4, SYMBOL, PROMISE, PAIRLIST,
+ LANGUAGE, CHAR, DOTDOTDOT, ANY, EXPRESSION, EXTERNALPTR, BYTECODE,
+ WEAKREF)));
+}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/ValidResponse.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/ValidResponse.java
index 701f3eff03..2716e10b52 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/ValidResponse.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/ValidResponse.java
@@ -6,12 +6,13 @@
import org.hibernate.validator.constraints.NotEmpty;
-import com.google.common.base.MoreObjects;
-
import eu.dzhw.fdz.metadatamanagement.common.domain.I18nString;
import eu.dzhw.fdz.metadatamanagement.common.domain.validation.I18nStringSize;
import eu.dzhw.fdz.metadatamanagement.common.domain.validation.StringLengths;
-import net.karneim.pojobuilder.GeneratePojoBuilder;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
/**
* The value includes the value itself, a label and frequencies. There are no calculations of the
@@ -19,8 +20,10 @@
*
* @author Daniel Katzberg
*/
-@GeneratePojoBuilder(
- intoPackage = "eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.builders")
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class ValidResponse {
@I18nStringSize(max = StringLengths.LARGE,
@@ -43,61 +46,4 @@ public class ValidResponse {
@NotNull(
message = "variable-management.error.valid-response.validRelativeFrequency.not-null")
private Double validRelativeFrequency;
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("label", label)
- .add("absoluteFrequency", absoluteFrequency)
- .add("relativeFrequency", relativeFrequency)
- .add("value", value)
- .add("validRelativeFrequency", validRelativeFrequency)
- .toString();
- }
-
- /* GETTER / SETTER */
- public I18nString getLabel() {
- return label;
- }
-
- public void setLabel(I18nString label) {
- this.label = label;
- }
-
- public Integer getAbsoluteFrequency() {
- return absoluteFrequency;
- }
-
- public void setAbsoluteFrequency(Integer absoluteFrequency) {
- this.absoluteFrequency = absoluteFrequency;
- }
-
- public Double getRelativeFrequency() {
- return relativeFrequency;
- }
-
- public void setRelativeFrequency(Double relativeFrequency) {
- this.relativeFrequency = relativeFrequency;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public Double getValidRelativeFrequency() {
- return validRelativeFrequency;
- }
-
- public void setValidRelativeFrequency(Double validRelativeFrequency) {
- this.validRelativeFrequency = validRelativeFrequency;
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/Variable.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/Variable.java
index 2136d804aa..84b4d784eb 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/Variable.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/Variable.java
@@ -15,8 +15,6 @@
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
-import com.google.common.base.MoreObjects;
-
import eu.dzhw.fdz.metadatamanagement.common.domain.AbstractRdcDomainObject;
import eu.dzhw.fdz.metadatamanagement.common.domain.I18nString;
import eu.dzhw.fdz.metadatamanagement.common.domain.util.Patterns;
@@ -42,9 +40,15 @@
import eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.validation.ValidResponseValueMustBeANumberOnNumericDataType;
import eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.validation.ValidResponseValueMustBeAnIsoDateOnDateDataType;
import eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.validation.ValidScaleLevel;
+import eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.validation.ValidStorageType;
import eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.validation.ValidVariableIdName;
import io.searchbox.annotations.JestId;
-import net.karneim.pojobuilder.GeneratePojoBuilder;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
//validation for scalelevel ration
//TODO DKatzberg delete late: @MandatoryHistogramOnRatioScaleLevel(
@@ -56,15 +60,13 @@
* @author Daniel Katzberg
*/
@Document(collection = "variables")
-@GeneratePojoBuilder(
- intoPackage = "eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.builders")
@CompoundIndexes({
@CompoundIndex(def = "{name: 1, dataSetId: 1}", unique = true),
@CompoundIndex(def = "{indexInDataSet: 1, dataSetId: 1}", unique = false)
})
@ValidVariableIdName(message = "variable-management.error.variable.valid-variable-name")
@ValidPanelIdentifier(message = "variable-management.error.variable.valid-panel-identifier")
-@ValidDerivedVariablesIdentifier(message =
+@ValidDerivedVariablesIdentifier(message =
"variable-management.error.variable.valid-derived-variables-identifier")
@UniqueVariableNameInDataSet(message = "variable-management.error."
+ "variable.unique-variable-name-in-data-set")
@@ -105,6 +107,12 @@
@StatisticsThirdQuartileMustBeANumberOnNumericDataType(
message = "variable-management.error.variable."
+ "statistics-third-quartile-must-be-a-number-on-numeric-data-type")
+@Data
+@EqualsAndHashCode(callSuper = false, of = "id")
+@ToString(callSuper = true)
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
public class Variable extends AbstractRdcDomainObject {
@Id
@JestId
@@ -114,31 +122,31 @@ public class Variable extends AbstractRdcDomainObject {
@Pattern(regexp = Patterns.GERMAN_ALPHANUMERIC_WITH_UNDERSCORE_AND_MINUS_AND_DOLLAR,
message = "variable-management.error.variable.id.pattern")
private String id;
-
+
@Indexed
@NotEmpty(message = "variable-management.error.variable.data-acquisition-project.id.not-empty")
private String dataAcquisitionProjectId;
-
+
@NotEmpty(message = "variable-management.error.variable.name.not-empty")
@Size(max = StringLengths.SMALL, message = "variable-management.error.variable.name.size")
@Pattern(regexp = Patterns.ALPHANUMERIC_WITH_UNDERSCORE_NO_NUMBER_AS_FIRST_SIGN,
message = "variable-management.error.variable.name.pattern")
private String name;
-
+
@NotNull(message = "variable-management.error.variable.label.not-null")
@I18nStringSize(max = StringLengths.MEDIUM,
message = "variable-management.error.variable.label.i18n-string-size")
@I18nStringNotEmpty(message = "variable-management.error.variable.label.i18n-string-not-empty")
private I18nString label;
-
+
@I18nStringSize(max = StringLengths.LARGE,
message = "variable-management.error.variable.annotations.i18n-string-size")
private I18nString annotations;
-
+
@Indexed
@NotEmpty(message = "variable-management.error.variable.data-set-id-not-empty")
private String dataSetId;
-
+
@NotNull(message = "variable-management.error.variable.data-set-number-not-null")
private Integer dataSetNumber;
@@ -146,6 +154,10 @@ public class Variable extends AbstractRdcDomainObject {
@ValidDataType(message = "variable-management.error.variable.data-type.valid-data-type")
private I18nString dataType;
+ @NotNull(message = "variable-management.error.variable.storage-type.not-null")
+ @ValidStorageType(message = "variable-management.error.variable.storage-type.valid-storage-type")
+ private String storageType;
+
@NotNull(message = "variable-management.error.variable.scaleLevel.not-null")
@ValidScaleLevel(
message = "variable-management.error.variable.scaleLevel.valid-scale-level")
@@ -158,19 +170,19 @@ public class Variable extends AbstractRdcDomainObject {
private List accessWays;
private List relatedVariables;
-
+
@NotNull(message = "variable-management.error.variable.data-set-index-not-null")
private Integer indexInDataSet;
-
+
@NotEmpty(message = "variable-management.error.variable.survey-numbers-not-empty")
private List surveyNumbers;
-
+
@Size(max = StringLengths.MEDIUM,
message = "variable-management.error.variable.panel-identifier-size")
@Pattern(regexp = Patterns.GERMAN_ALPHANUMERIC_WITH_UNDERSCORE_AND_MINUS,
message = "variable-management.error.variable.panel-identifier-pattern")
private String panelIdentifier;
-
+
@Size(max = StringLengths.MEDIUM,
message = "variable-management.error.variable.derived-variables-identifier-size")
@Pattern(regexp = Patterns.GERMAN_ALPHANUMERIC_WITH_UNDERSCORE_AND_MINUS,
@@ -186,10 +198,12 @@ public class Variable extends AbstractRdcDomainObject {
@Valid
private Distribution distribution;
-
+
@Valid
private List relatedQuestions;
+ private Boolean doNotDisplayThousandsSeparator = false;
+
/* Foreign Keys */
@Indexed
@NotEmpty(message = "variable-management.error.variable.study-id.not-empty")
@@ -198,220 +212,8 @@ public class Variable extends AbstractRdcDomainObject {
@Indexed
private List surveyIds;
- public Variable() {
- super();
- }
-
public Variable(Variable variable) {
super();
BeanUtils.copyProperties(variable, this);
}
-
- @Override
- public String getId() {
- return id;
- }
-
- public String getDataAcquisitionProjectId() {
- return dataAcquisitionProjectId;
- }
-
- public void setDataAcquisitionProjectId(String dataAcquisitionProjectId) {
- this.dataAcquisitionProjectId = dataAcquisitionProjectId;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public I18nString getLabel() {
- return label;
- }
-
- public void setLabel(I18nString label) {
- this.label = label;
- }
-
- public I18nString getAnnotations() {
- return annotations;
- }
-
- public void setAnnotations(I18nString annotations) {
- this.annotations = annotations;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getDataSetId() {
- return dataSetId;
- }
-
- public void setDataSetId(String dataSetId) {
- this.dataSetId = dataSetId;
- }
-
-
- public Integer getDataSetNumber() {
- return dataSetNumber;
- }
-
- public void setDataSetNumber(Integer dataSetNumber) {
- this.dataSetNumber = dataSetNumber;
- }
-
- /*
- * (non-Javadoc)
- * @see eu.dzhw.fdz.metadatamanagement.common.domain.AbstractRdcDomainObject#toString()
- */
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("super", super.toString())
- .add("id", id)
- .add("dataType", dataType)
- .add("scaleLevel", scaleLevel)
- .add("name", name)
- .add("label", label)
- .add("annotations", annotations)
- .add("accessWays", accessWays)
- .add("relatedVariables", relatedVariables)
- .add("dataSetId", dataSetId)
- .add("dataSetNumber", dataSetNumber)
- .add("indexInDataSet", indexInDataSet)
- .add("surveyNumbers", surveyNumbers)
- .add("filterDetails", filterDetails)
- .add("generationDetails", generationDetails)
- .add("distribution", distribution)
- .add("dataAcquisitionProjectId", dataAcquisitionProjectId)
- .add("studyId", studyId)
- .add("surveyIds", surveyIds)
- .add("relatedQuestions",relatedQuestions)
- .add("panelIdentifier", panelIdentifier)
- .add("derivedVariablesIdentifier", derivedVariablesIdentifier)
- .toString();
- }
-
- /* GETTER / SETTER */
- public I18nString getDataType() {
- return dataType;
- }
-
- public void setDataType(I18nString dataType) {
- this.dataType = dataType;
- }
-
- public I18nString getScaleLevel() {
- return scaleLevel;
- }
-
- public void setScaleLevel(I18nString scaleLevel) {
- this.scaleLevel = scaleLevel;
- }
-
- public List getAccessWays() {
- return accessWays;
- }
-
- public void setAccessWays(List accessWays) {
- this.accessWays = accessWays;
- }
-
- public GenerationDetails getGenerationDetails() {
- return generationDetails;
- }
-
- public void setGenerationDetails(GenerationDetails generationDetails) {
- this.generationDetails = generationDetails;
- }
-
- public FilterDetails getFilterDetails() {
- return filterDetails;
- }
-
- public void setFilterDetails(FilterDetails filterDetails) {
- this.filterDetails = filterDetails;
- }
-
- public List getSurveyIds() {
- return surveyIds;
- }
-
- public void setSurveyIds(List surveyIds) {
- this.surveyIds = surveyIds;
- }
-
- public Distribution getDistribution() {
- return distribution;
- }
-
- public void setDistribution(Distribution distribution) {
- this.distribution = distribution;
- }
-
- public List getRelatedVariables() {
- return relatedVariables;
- }
-
- public void setRelatedVariables(List relatedVariables) {
- this.relatedVariables = relatedVariables;
- }
-
- public Integer getIndexInDataSet() {
- return indexInDataSet;
- }
-
-
- public void setIndexInDataSet(Integer indexInDataSet) {
- this.indexInDataSet = indexInDataSet;
- }
-
-
- public List getSurveyNumbers() {
- return surveyNumbers;
- }
-
-
- public void setSurveyNumbers(List surveyNumbers) {
- this.surveyNumbers = surveyNumbers;
- }
-
- public List getRelatedQuestions() {
- return relatedQuestions;
- }
-
- public void setRelatedQuestions(List relatedQuestions) {
- this.relatedQuestions = relatedQuestions;
- }
-
-
- public String getPanelIdentifier() {
- return panelIdentifier;
- }
-
-
- public void setPanelIdentifier(String panelIdentifier) {
- this.panelIdentifier = panelIdentifier;
- }
-
- public String getStudyId() {
- return studyId;
- }
-
- public void setStudyId(String studyId) {
- this.studyId = studyId;
- }
-
- public String getDerivedVariablesIdentifier() {
- return derivedVariablesIdentifier;
- }
-
- public void setDerivedVariablesIdentifier(String derivedVariablesIdentifier) {
- this.derivedVariablesIdentifier = derivedVariablesIdentifier;
- }
}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/validation/UniqueValueValidator.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/validation/UniqueValueValidator.java
index 4334fdbf2e..340d1564cd 100644
--- a/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/validation/UniqueValueValidator.java
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/validation/UniqueValueValidator.java
@@ -6,21 +6,17 @@
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.ValidResponse;
+import lombok.extern.slf4j.Slf4j;
/**
* Ensure that value.valueClass is unique within the variable.
*
* @author René Reitmann
*/
+@Slf4j
public class UniqueValueValidator
implements ConstraintValidator> {
-
- private final Logger log = LoggerFactory.getLogger(UniqueValueValidator.class);
-
/*
* (non-Javadoc)
*
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/validation/ValidStorageType.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/validation/ValidStorageType.java
new file mode 100644
index 0000000000..83df66c61f
--- /dev/null
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/validation/ValidStorageType.java
@@ -0,0 +1,36 @@
+package eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.validation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+
+/**
+ * Annotation for the validation of storage types.
+ * Only values of the {@link StorageTypes} are allowed. *
+ */
+@Documented
+@Constraint(validatedBy = {ValidStorageTypeValidator.class})
+@Target({ElementType.FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ValidStorageType {
+ /**
+ * Defines the default error message.
+ */
+ String message() default "{eu.dzhw.fdz.metadatamanagement.domain.validation."
+ + "validstoragetype.message}";
+
+ /**
+ * This contains groups.
+ */
+ Class>[] groups() default {};
+
+ /**
+ * This method contains the payload.
+ */
+ Class extends Payload>[] payload() default {};
+}
diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/validation/ValidStorageTypeValidator.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/validation/ValidStorageTypeValidator.java
new file mode 100644
index 0000000000..a2c6b28a1b
--- /dev/null
+++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/validation/ValidStorageTypeValidator.java
@@ -0,0 +1,35 @@
+package eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.validation;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+import eu.dzhw.fdz.metadatamanagement.variablemanagement.domain.StorageTypes;
+
+/**
+ * Validator for the storage type of a variable. Only valued from the {@link StorageTypes} class are
+ * allowed.
+ */
+public class ValidStorageTypeValidator implements ConstraintValidator {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.validation.ConstraintValidator#initialize(java.lang.annotation.Annotation)
+ */
+ @Override
+ public void initialize(ValidStorageType constraintAnnotation) {}
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.validation.ConstraintValidator#isValid(java.lang.Object,
+ * javax.validation.ConstraintValidatorContext)
+ */
+ @Override
+ public boolean isValid(String storageType, ConstraintValidatorContext context) {
+
+ // check for storage types
+ return StorageTypes.ALL.contains(storageType);
+ }
+
+}
diff --git a/src/main/webapp/bower_components/angular-ui-router/.bower.json b/src/main/webapp/bower_components/angular-ui-router/.bower.json
index da5305f6fc..36d911a853 100644
--- a/src/main/webapp/bower_components/angular-ui-router/.bower.json
+++ b/src/main/webapp/bower_components/angular-ui-router/.bower.json
@@ -17,15 +17,15 @@
"test",
"src"
],
- "version": "1.0.8",
+ "version": "1.0.10",
"homepage": "https://github.com/angular-ui/angular-ui-router-bower",
- "_release": "1.0.8",
+ "_release": "1.0.10",
"_resolution": {
"type": "version",
- "tag": "1.0.8",
- "commit": "9fa30f901cf394dbd214f8cc8532c57366caabb7"
+ "tag": "1.0.10",
+ "commit": "50430a313fba39526de6031662acae0e254f7948"
},
"_source": "https://github.com/angular-ui/angular-ui-router-bower.git",
- "_target": "1.0.8",
+ "_target": "1.0.10",
"_originalSource": "angular-ui-router"
}
\ No newline at end of file
diff --git a/src/main/webapp/bower_components/angular-ui-router/CHANGELOG.md b/src/main/webapp/bower_components/angular-ui-router/CHANGELOG.md
index 65a280af5b..b529fd0a7f 100644
--- a/src/main/webapp/bower_components/angular-ui-router/CHANGELOG.md
+++ b/src/main/webapp/bower_components/angular-ui-router/CHANGELOG.md
@@ -1,3 +1,21 @@
+## 1.0.10 (2017-10-18)
+[Compare `@uirouter/angularjs` versions 1.0.9 and 1.0.10](https://github.com/angular-ui/ui-router/compare/1.0.9...1.0.10)
+
+### Bug Fixes
+
+* **artifactory:** Add trailing newline to package.json to work around artifactory issue ([#3551](https://github.com/angular-ui/ui-router/issues/3551)) ([d09a345](https://github.com/angular-ui/ui-router/commit/d09a345)), closes [#3550](https://github.com/angular-ui/ui-router/issues/3550)
+
+## 1.0.9 (2017-10-17)
+[Compare `@uirouter/angularjs` versions 1.0.8 and 1.0.9](https://github.com/angular-ui/ui-router/compare/1.0.8...1.0.9)
+
+
+### Updated `@uirouter/core` from 5.0.10 to 5.0.11
+[Compare `@uirouter/core` versions 5.0.10 and 5.0.11](https://github.com/ui-router/core/compare/5.0.10...5.0.11)
+
+### Bug Fixes
+
+* **ie9:** make console.bind work in ie9 ([#85](https://github.com/ui-router/core/issues/85)) ([318214b](https://github.com/ui-router/core/commit/318214b))
+
## 1.0.8 (2017-10-07)
[Compare `@uirouter/angularjs` versions 1.0.7 and 1.0.8](https://github.com/angular-ui/ui-router/compare/1.0.7...1.0.8)
diff --git a/src/main/webapp/bower_components/angular-ui-router/migrate/migrate.json b/src/main/webapp/bower_components/angular-ui-router/migrate/migrate.json
deleted file mode 100644
index d7183916ab..0000000000
--- a/src/main/webapp/bower_components/angular-ui-router/migrate/migrate.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "old": "angular-ui-router",
- "new": "@uirouter/angularjs"
-}
diff --git a/src/main/webapp/bower_components/angular-ui-router/migrate/migratewarn.js b/src/main/webapp/bower_components/angular-ui-router/migrate/migratewarn.js
deleted file mode 100755
index eb9afad9eb..0000000000
--- a/src/main/webapp/bower_components/angular-ui-router/migrate/migratewarn.js
+++ /dev/null
@@ -1,12 +0,0 @@
-#!env node
-"use strict";
-
-var pkg = require('../package.json');
-var migrate = require('./migrate.json');
-
-if (pkg.name === migrate.old) {
- var warning = 'WARNING! this npm package "' + migrate.old + '" has been renamed to "' + migrate.new + '". Please update your package.json';
- var warning2 = 'See https://ui-router.github.io/blog/uirouter-scoped-packages/ for details.';
- console.log("\x1b[1m\x1b[37m\x1b[41m%s\x1b[0m", warning);
- console.log("\x1b[1m\x1b[37m\x1b[41m%s\x1b[0m", warning2);
-}
diff --git a/src/main/webapp/bower_components/angular-ui-router/release/angular-ui-router.js b/src/main/webapp/bower_components/angular-ui-router/release/angular-ui-router.js
index 95e6dc5224..4e69b5e203 100644
--- a/src/main/webapp/bower_components/angular-ui-router/release/angular-ui-router.js
+++ b/src/main/webapp/bower_components/angular-ui-router/release/angular-ui-router.js
@@ -4,7 +4,7 @@
* This causes it to be incompatible with plugins that depend on @uirouter/core.
* We recommend switching to the ui-router-core.js and ui-router-angularjs.js bundles instead.
* For more information, see https://ui-router.github.io/blog/uirouter-for-angularjs-umd-bundles
- * @version v1.0.8
+ * @version v1.0.10
* @link https://ui-router.github.io
* @license MIT License, http://www.opensource.org/licenses/MIT
*/
@@ -1204,7 +1204,9 @@ function normalizedCat(input) {
return isNumber(input) ? exports.Category[input] : exports.Category[exports.Category[input]];
}
/** @hidden */
-var consoletable = isFunction(console.table) ? console.table.bind(console) : console.log.bind(console);
+var consoleLog = Function.prototype.bind.call(console.log, console);
+/** @hidden */
+var consoletable = isFunction(console.table) ? console.table.bind(console) : consoleLog.bind(console);
/**
* Trace categories Enum
*
diff --git a/src/main/webapp/bower_components/angular-ui-router/release/angular-ui-router.js.map b/src/main/webapp/bower_components/angular-ui-router/release/angular-ui-router.js.map
index 9de70e9f08..91ecc8a427 100644
--- a/src/main/webapp/bower_components/angular-ui-router/release/angular-ui-router.js.map
+++ b/src/main/webapp/bower_components/angular-ui-router/release/angular-ui-router.js.map
@@ -1 +1,193 @@
-{"version":3,"file":"angular-ui-router.js","sources":["@uirouter/angularjs/angular.ts","@uirouter/core/lib-esm/common/@uirouter/core/common/hof.ts","@uirouter/core/lib-esm/common/@uirouter/core/common/glob.ts","@uirouter/core/lib-esm/state/@uirouter/core/state/stateObject.ts","@uirouter/core/lib-esm/common/@uirouter/core/common/predicates.ts","@uirouter/core/lib-esm/common/@uirouter/core/common/coreservices.ts","@uirouter/core/lib-esm/common/@uirouter/core/common/common.ts","@uirouter/core/lib-esm/common/@uirouter/core/common/queue.ts","@uirouter/core/lib-esm/transition/@uirouter/core/transition/rejectFactory.ts","@uirouter/core/lib-esm/common/@uirouter/core/common/trace.ts","@uirouter/core/lib-esm/transition/@uirouter/core/transition/interface.ts","@uirouter/core/lib-esm/state/@uirouter/core/state/targetState.ts","@uirouter/core/lib-esm/transition/@uirouter/core/transition/transitionHook.ts","@uirouter/core/lib-esm/transition/@uirouter/core/transition/hookRegistry.ts","@uirouter/core/lib-esm/transition/@uirouter/core/transition/hookBuilder.ts","@uirouter/core/lib-esm/params/@uirouter/core/params/paramType.ts","@uirouter/core/lib-esm/params/@uirouter/core/params/param.ts","@uirouter/core/lib-esm/path/@uirouter/core/path/pathNode.ts","@uirouter/core/lib-esm/path/@uirouter/core/path/pathFactory.ts","@uirouter/core/lib-esm/resolve/@uirouter/core/resolve/resolvable.ts","@uirouter/core/lib-esm/resolve/@uirouter/core/resolve/interface.ts","@uirouter/core/lib-esm/resolve/@uirouter/core/resolve/resolveContext.ts","@uirouter/core/lib-esm/transition/@uirouter/core/transition/transition.ts","@uirouter/core/lib-esm/common/@uirouter/core/common/strings.ts","@uirouter/core/lib-esm/common/@uirouter/core/common/index.ts","@uirouter/core/lib-esm/params/@uirouter/core/params/paramTypes.ts","@uirouter/core/lib-esm/params/@uirouter/core/params/stateParams.ts","@uirouter/core/lib-esm/path/@uirouter/core/path/index.ts","@uirouter/core/lib-esm/resolve/@uirouter/core/resolve/index.ts","@uirouter/core/lib-esm/state/@uirouter/core/state/stateBuilder.ts","@uirouter/core/lib-esm/state/@uirouter/core/state/stateMatcher.ts","@uirouter/core/lib-esm/state/@uirouter/core/state/stateQueueManager.ts","@uirouter/core/lib-esm/state/@uirouter/core/state/stateRegistry.ts","@uirouter/core/lib-esm/url/@uirouter/core/url/urlMatcher.ts","@uirouter/core/lib-esm/url/@uirouter/core/url/urlMatcherFactory.ts","@uirouter/core/lib-esm/url/@uirouter/core/url/urlRule.ts","@uirouter/core/lib-esm/url/@uirouter/core/url/urlRouter.ts","@uirouter/core/lib-esm/view/@uirouter/core/view/view.ts","@uirouter/core/lib-esm/@uirouter/core/globals.ts","@uirouter/core/lib-esm/url/@uirouter/core/url/urlService.ts","@uirouter/core/lib-esm/@uirouter/core/router.ts","@uirouter/core/lib-esm/hooks/@uirouter/core/hooks/coreResolvables.ts","@uirouter/core/lib-esm/hooks/@uirouter/core/hooks/redirectTo.ts","@uirouter/core/lib-esm/hooks/@uirouter/core/hooks/onEnterExitRetain.ts","@uirouter/core/lib-esm/hooks/@uirouter/core/hooks/resolve.ts","@uirouter/core/lib-esm/hooks/@uirouter/core/hooks/views.ts","@uirouter/core/lib-esm/hooks/@uirouter/core/hooks/updateGlobals.ts","@uirouter/core/lib-esm/hooks/@uirouter/core/hooks/url.ts","@uirouter/core/lib-esm/hooks/@uirouter/core/hooks/lazyLoad.ts","@uirouter/core/lib-esm/transition/@uirouter/core/transition/transitionEventType.ts","@uirouter/core/lib-esm/hooks/@uirouter/core/hooks/ignoredTransition.ts","@uirouter/core/lib-esm/hooks/@uirouter/core/hooks/invalidTransition.ts","@uirouter/core/lib-esm/transition/@uirouter/core/transition/transitionService.ts","@uirouter/core/lib-esm/state/@uirouter/core/state/stateService.ts","@uirouter/core/lib-esm/transition/@uirouter/core/transition/index.ts","@uirouter/core/lib-esm/vanilla/@uirouter/core/vanilla/q.ts","@uirouter/core/lib-esm/vanilla/@uirouter/core/vanilla/injector.ts","@uirouter/core/lib-esm/vanilla/@uirouter/core/vanilla/utils.ts","@uirouter/core/lib-esm/vanilla/@uirouter/core/vanilla/baseLocationService.ts","@uirouter/core/lib-esm/vanilla/@uirouter/core/vanilla/hashLocationService.ts","@uirouter/core/lib-esm/vanilla/@uirouter/core/vanilla/memoryLocationService.ts","@uirouter/core/lib-esm/vanilla/@uirouter/core/vanilla/pushStateLocationService.ts","@uirouter/core/lib-esm/vanilla/@uirouter/core/vanilla/memoryLocationConfig.ts","@uirouter/core/lib-esm/vanilla/@uirouter/core/vanilla/browserLocationConfig.ts","@uirouter/core/lib-esm/vanilla/@uirouter/core/vanilla/plugins.ts","@uirouter/core/lib-esm/@uirouter/core/vanilla.ts","@uirouter/core/lib-esm/@uirouter/core/interface.ts","@uirouter/core/lib-esm/@uirouter/core/index.ts","@uirouter/angularjs/statebuilders/views.ts","@uirouter/angularjs/templateFactory.ts","@uirouter/angularjs/stateProvider.ts","@uirouter/angularjs/statebuilders/onEnterExitRetain.ts","@uirouter/angularjs/locationServices.ts","@uirouter/angularjs/urlRouterProvider.ts","@uirouter/angularjs/services.ts","@uirouter/angularjs/injectables.ts","@uirouter/angularjs/directives/stateDirectives.ts","@uirouter/angularjs/stateFilters.ts","@uirouter/angularjs/directives/viewDirective.ts","@uirouter/angularjs/viewScroll.ts","@uirouter/angularjs/index.ts"],"sourcesContent":["/**\n * @hidden\n * @module ng1\n */ /** */\ndeclare var angular;\nimport * as ng_from_import from \"angular\";\nlet ng_from_global = angular;\n\nexport const ng = (ng_from_import && ng_from_import.module) ? ng_from_import : ng_from_global;\n","/**\n * Higher order functions\n *\n * These utility functions are exported, but are subject to change without notice.\n *\n * @module common_hof\n */ /** */\n\nimport {Predicate} from \"./common\";\n/**\n * Returns a new function for [Partial Application](https://en.wikipedia.org/wiki/Partial_application) of the original function.\n *\n * Given a function with N parameters, returns a new function that supports partial application.\n * The new function accepts anywhere from 1 to N parameters. When that function is called with M parameters,\n * where M is less than N, it returns a new function that accepts the remaining parameters. It continues to\n * accept more parameters until all N parameters have been supplied.\n *\n *\n * This contrived example uses a partially applied function as an predicate, which returns true\n * if an object is found in both arrays.\n * @example\n * ```\n * // returns true if an object is in both of the two arrays\n * function inBoth(array1, array2, object) {\n * return array1.indexOf(object) !== -1 &&\n * array2.indexOf(object) !== 1;\n * }\n * let obj1, obj2, obj3, obj4, obj5, obj6, obj7\n * let foos = [obj1, obj3]\n * let bars = [obj3, obj4, obj5]\n *\n * // A curried \"copy\" of inBoth\n * let curriedInBoth = curry(inBoth);\n * // Partially apply both the array1 and array2\n * let inFoosAndBars = curriedInBoth(foos, bars);\n *\n * // Supply the final argument; since all arguments are\n * // supplied, the original inBoth function is then called.\n * let obj1InBoth = inFoosAndBars(obj1); // false\n *\n * // Use the inFoosAndBars as a predicate.\n * // Filter, on each iteration, supplies the final argument\n * let allObjs = [ obj1, obj2, obj3, obj4, obj5, obj6, obj7 ];\n * let foundInBoth = allObjs.filter(inFoosAndBars); // [ obj3 ]\n *\n * ```\n *\n * Stolen from: http://stackoverflow.com/questions/4394747/javascript-curry-function\n *\n * @param fn\n * @returns {*|function(): (*|any)}\n */\nexport function curry(fn: Function): Function {\n let initial_args = [].slice.apply(arguments, [1]);\n let func_args_length = fn.length;\n\n function curried(args: any[]) {\n if (args.length >= func_args_length)\n return fn.apply(null, args);\n return function () {\n return curried(args.concat([].slice.apply(arguments)));\n };\n }\n return curried(initial_args);\n}\n\n\n\n/**\n * Given a varargs list of functions, returns a function that composes the argument functions, right-to-left\n * given: f(x), g(x), h(x)\n * let composed = compose(f,g,h)\n * then, composed is: f(g(h(x)))\n */\nexport function compose() {\n let args = arguments;\n let start = args.length - 1;\n return function() {\n let i = start, result = args[start].apply(this, arguments);\n while (i--) result = args[i].call(this, result);\n return result;\n };\n}\n\n/**\n * Given a varargs list of functions, returns a function that is composes the argument functions, left-to-right\n * given: f(x), g(x), h(x)\n * let piped = pipe(f,g,h);\n * then, piped is: h(g(f(x)))\n */\nexport function pipe(...funcs: Function[]): (obj: any) => any {\n return compose.apply(null, [].slice.call(arguments).reverse());\n}\n\n/**\n * Given a property name, returns a function that returns that property from an object\n * let obj = { foo: 1, name: \"blarg\" };\n * let getName = prop(\"name\");\n * getName(obj) === \"blarg\"\n */\nexport const prop = (name: string) =>\n (obj: any) => obj && obj[name];\n\n/**\n * Given a property name and a value, returns a function that returns a boolean based on whether\n * the passed object has a property that matches the value\n * let obj = { foo: 1, name: \"blarg\" };\n * let getName = propEq(\"name\", \"blarg\");\n * getName(obj) === true\n */\nexport const propEq = curry((name: string, val: any, obj: any) => obj && obj[name] === val);\n\n/**\n * Given a dotted property name, returns a function that returns a nested property from an object, or undefined\n * let obj = { id: 1, nestedObj: { foo: 1, name: \"blarg\" }, };\n * let getName = prop(\"nestedObj.name\");\n * getName(obj) === \"blarg\"\n * let propNotFound = prop(\"this.property.doesnt.exist\");\n * propNotFound(obj) === undefined\n */\nexport const parse = (name: string) =>\n pipe.apply(null, name.split(\".\").map(prop));\n\n/**\n * Given a function that returns a truthy or falsey value, returns a\n * function that returns the opposite (falsey or truthy) value given the same inputs\n */\nexport const not: (fn: Predicate) => Predicate = (fn: Predicate) =>\n (...args: any[]) => !fn.apply(null, args);\n\n/**\n * Given two functions that return truthy or falsey values, returns a function that returns truthy\n * if both functions return truthy for the given arguments\n */\nexport function and(fn1: Predicate, fn2: Predicate): Predicate {\n return (...args: any[]) => fn1.apply(null, args) && fn2.apply(null, args);\n}\n\n/**\n * Given two functions that return truthy or falsey values, returns a function that returns truthy\n * if at least one of the functions returns truthy for the given arguments\n */\nexport function or(fn1: Predicate, fn2: Predicate): Predicate {\n return (...args: any[]) => fn1.apply(null, args) || fn2.apply(null, args);\n}\n\n/**\n * Check if all the elements of an array match a predicate function\n *\n * @param fn1 a predicate function `fn1`\n * @returns a function which takes an array and returns true if `fn1` is true for all elements of the array\n */\nexport const all = (fn1: Predicate) =>\n (arr: any[]) => arr.reduce((b, x) => b && !!fn1(x), true) as boolean;\nexport const any = (fn1: Predicate) =>\n (arr: any[]) => arr.reduce((b, x) => b || !!fn1(x), false) as boolean;\n\n/** Given a class, returns a Predicate function that returns true if the object is of that class */\nexport const is = (ctor: { new(...args): T }) =>\n (obj: any): obj is T =>\n (obj != null && obj.constructor === ctor || obj instanceof ctor);\n\n/** Given a value, returns a Predicate function that returns true if another value is === equal to the original value */\nexport const eq: (comp: any) => Predicate = (val: any) => (other: any) =>\n val === other;\n\n/** Given a value, returns a function which returns the value */\nexport const val = (v: T) => () => v;\n\n\n\nexport function invoke(fnName: string): Function;\nexport function invoke(fnName: string, args: any[]): Function;\nexport function invoke(fnName: string, args?: any[]): Function {\n return (obj: any) =>\n obj[fnName].apply(obj, args);\n}\n\n/**\n * Sorta like Pattern Matching (a functional programming conditional construct)\n *\n * See http://c2.com/cgi/wiki?PatternMatching\n *\n * This is a conditional construct which allows a series of predicates and output functions\n * to be checked and then applied. Each predicate receives the input. If the predicate\n * returns truthy, then its matching output function (mapping function) is provided with\n * the input and, then the result is returned.\n *\n * Each combination (2-tuple) of predicate + output function should be placed in an array\n * of size 2: [ predicate, mapFn ]\n *\n * These 2-tuples should be put in an outer array.\n *\n * @example\n * ```\n *\n * // Here's a 2-tuple where the first element is the isString predicate\n * // and the second element is a function that returns a description of the input\n * let firstTuple = [ angular.isString, (input) => `Heres your string ${input}` ];\n *\n * // Second tuple: predicate \"isNumber\", mapfn returns a description\n * let secondTuple = [ angular.isNumber, (input) => `(${input}) That's a number!` ];\n *\n * let third = [ (input) => input === null, (input) => `Oh, null...` ];\n *\n * let fourth = [ (input) => input === undefined, (input) => `notdefined` ];\n *\n * let descriptionOf = pattern([ firstTuple, secondTuple, third, fourth ]);\n *\n * console.log(descriptionOf(undefined)); // 'notdefined'\n * console.log(descriptionOf(55)); // '(55) That's a number!'\n * console.log(descriptionOf(\"foo\")); // 'Here's your string foo'\n * ```\n *\n * @param struct A 2D array. Each element of the array should be an array, a 2-tuple,\n * with a Predicate and a mapping/output function\n * @returns {function(any): *}\n */\nexport function pattern(struct: Function[][]): Function {\n return function(x: any) {\n for (var i = 0; i < struct.length; i++) {\n if (struct[i][0](x)) return struct[i][1](x);\n }\n };\n}\n\n","/**\n * @coreapi\n * @module core\n */\n/** \n * Matches state names using glob-like pattern strings.\n *\n * Globs can be used in specific APIs including:\n *\n * - [[StateService.is]]\n * - [[StateService.includes]]\n * - The first argument to Hook Registration functions like [[TransitionService.onStart]]\n * - [[HookMatchCriteria]] and [[HookMatchCriterion]]\n *\n * A `Glob` string is a pattern which matches state names.\n * Nested state names are split into segments (separated by a dot) when processing.\n * The state named `foo.bar.baz` is split into three segments ['foo', 'bar', 'baz']\n *\n * Globs work according to the following rules:\n *\n * ### Exact match:\n *\n * The glob `'A.B'` matches the state named exactly `'A.B'`.\n *\n * | Glob |Matches states named|Does not match state named|\n * |:------------|:--------------------|:---------------------|\n * | `'A'` | `'A'` | `'B'` , `'A.C'` |\n * | `'A.B'` | `'A.B'` | `'A'` , `'A.B.C'` |\n * | `'foo'` | `'foo'` | `'FOO'` , `'foo.bar'`|\n *\n * ### Single star (`*`)\n *\n * A single star (`*`) is a wildcard that matches exactly one segment.\n *\n * | Glob |Matches states named |Does not match state named |\n * |:------------|:---------------------|:--------------------------|\n * | `'*'` | `'A'` , `'Z'` | `'A.B'` , `'Z.Y.X'` |\n * | `'A.*'` | `'A.B'` , `'A.C'` | `'A'` , `'A.B.C'` |\n * | `'A.*.*'` | `'A.B.C'` , `'A.X.Y'`| `'A'`, `'A.B'` , `'Z.Y.X'`|\n *\n * ### Double star (`**`)\n *\n * A double star (`'**'`) is a wildcard that matches *zero or more segments*\n *\n * | Glob |Matches states named |Does not match state named |\n * |:------------|:----------------------------------------------|:----------------------------------|\n * | `'**'` | `'A'` , `'A.B'`, `'Z.Y.X'` | (matches all states) |\n * | `'A.**'` | `'A'` , `'A.B'` , `'A.C.X'` | `'Z.Y.X'` |\n * | `'**.X'` | `'X'` , `'A.X'` , `'Z.Y.X'` | `'A'` , `'A.login.Z'` |\n * | `'A.**.X'` | `'A.X'` , `'A.B.X'` , `'A.B.C.X'` | `'A'` , `'A.B.C'` |\n *\n */\nexport class Glob {\n text: string;\n glob: Array;\n regexp: RegExp;\n\n constructor(text: string) {\n this.text = text;\n this.glob = text.split('.');\n\n let regexpString = this.text.split('.')\n .map(seg => {\n if (seg === '**') return '(?:|(?:\\\\.[^.]*)*)';\n if (seg === '*') return '\\\\.[^.]*';\n return '\\\\.' + seg;\n }).join('');\n\n this.regexp = new RegExp(\"^\" + regexpString + \"$\");\n }\n\n matches(name: string) {\n return this.regexp.test('.' + name);\n }\n\n /** Returns true if the string has glob-like characters in it */\n static is(text: string) {\n return !!/[!,*]+/.exec(text);\n }\n\n /** Returns a glob from the string, or null if the string isn't Glob-like */\n static fromString(text: string) {\n return Glob.is(text) ? new Glob(text) : null;\n }\n}\n","/**\n * @coreapi\n * @module state\n */\n/** for typedoc */\nimport { StateDeclaration, _ViewDeclaration, _StateDeclaration, LazyLoadResult } from \"./interface\";\nimport { defaults, values, find, inherit } from \"../common/common\";\nimport { propEq } from \"../common/hof\";\nimport { Param } from \"../params/param\";\nimport { UrlMatcher } from \"../url/urlMatcher\";\nimport { Resolvable } from \"../resolve/resolvable\";\nimport { TransitionStateHookFn } from \"../transition/interface\";\nimport { TargetState } from \"./targetState\";\nimport { Transition } from \"../transition/transition\";\nimport { Glob } from \"../common/glob\";\nimport { isObject, isFunction } from \"../common/predicates\";\n\n/**\n * Internal representation of a UI-Router state.\n *\n * Instances of this class are created when a [[StateDeclaration]] is registered with the [[StateRegistry]].\n *\n * A registered [[StateDeclaration]] is augmented with a getter ([[StateDeclaration.$$state]]) which returns the corresponding [[StateObject]] object.\n *\n * This class prototypally inherits from the corresponding [[StateDeclaration]].\n * Each of its own properties (i.e., `hasOwnProperty`) are built using builders from the [[StateBuilder]].\n */\nexport class StateObject {\n /** The parent [[StateObject]] */\n public parent: StateObject;\n\n /** The name used to register the state */\n public name: string;\n\n /** Prototypally inherits from [[StateDeclaration.abstract]] */\n public abstract: boolean;\n\n /** Prototypally inherits from [[StateDeclaration.resolve]] */\n public resolve: ({ [key: string]: (string|any[]|Function) }|any[]);\n\n /** A list of [[Resolvable]] objects. The internal representation of [[resolve]]. */\n public resolvables: Resolvable[];\n\n /** Prototypally inherits from [[StateDeclaration.resolvePolicy]] */\n public resolvePolicy: any;\n\n /** A compiled URLMatcher which detects when the state's URL is matched */\n public url: UrlMatcher;\n\n /** The parameters for the state, built from the URL and [[StateDeclaration.params]] */\n public params: { [key: string]: Param };\n\n /**\n * The views for the state.\n * Note: `@uirouter/core` does not register a builder for views.\n * The framework specific code should register a `views` builder.\n */\n public views: { [key: string]: _ViewDeclaration; };\n\n /**\n * The original [[StateDeclaration]] used to build this [[StateObject]].\n * Note: `this` object also prototypally inherits from the `self` declaration object.\n */\n public self: StateDeclaration;\n\n /** The nearest parent [[StateObject]] which has a URL */\n public navigable: StateObject;\n\n /** The parent [[StateObject]] objects from this state up to the root */\n public path: StateObject[];\n\n /**\n * Prototypally inherits from [[StateDeclaration.data]]\n * Note: This is the only field on the [[StateDeclaration]] which is mutated.\n * The definition object's `data` field is replaced with a new object\n * which prototypally inherits from the parent state definition's `data` field.\n */\n public data: any;\n\n /** \n * An object containing the parent States' names as keys and \n * true as their values.\n */\n public includes: { [name: string]: boolean };\n\n /** Prototypally inherits from [[StateDeclaration.onExit]] */\n public onExit: TransitionStateHookFn;\n /** Prototypally inherits from [[StateDeclaration.onRetain]] */\n public onRetain: TransitionStateHookFn;\n /** Prototypally inherits from [[StateDeclaration.onEnter]] */\n public onEnter: TransitionStateHookFn;\n\n /** Prototypally inherits from [[StateDeclaration.lazyLoad]] */\n public lazyLoad: (transition: Transition, state: StateDeclaration) => Promise;\n\n /** Prototypally inherits from [[StateDeclaration.redirectTo]] */\n redirectTo: (\n string |\n (($transition$: Transition) => TargetState) |\n { state: (string|StateDeclaration), params: { [key: string]: any }}\n );\n\n /** @hidden */\n __stateObjectCache: {\n /** Might be null */\n nameGlob?: Glob\n };\n\n\n /** @deprecated use State.create() */\n constructor(config?: StateDeclaration) {\n return StateObject.create(config || {});\n }\n\n /**\n * Create a state object to put the private/internal implementation details onto.\n * The object's prototype chain looks like:\n * (Internal State Object) -> (Copy of State.prototype) -> (State Declaration object) -> (State Declaration's prototype...)\n *\n * @param stateDecl the user-supplied State Declaration\n * @returns {StateObject} an internal State object\n */\n static create(stateDecl: _StateDeclaration): StateObject {\n stateDecl = StateObject.isStateClass(stateDecl) ? new stateDecl() : stateDecl;\n\n let state = inherit(inherit(stateDecl, StateObject.prototype)) as StateObject;\n stateDecl.$$state = () => state;\n state.self = stateDecl;\n state.__stateObjectCache = {\n nameGlob: Glob.fromString(state.name) // might return null\n };\n return state;\n }\n\n /** Predicate which returns true if the object is an class with @State() decorator */\n static isStateClass = (stateDecl: _StateDeclaration): stateDecl is ({ new (): StateDeclaration }) =>\n isFunction(stateDecl) && stateDecl['__uiRouterState'] === true;\n\n /** Predicate which returns true if the object is an internal [[StateObject]] object */\n static isState = (obj: any): obj is StateObject =>\n isObject(obj['__stateObjectCache']);\n\n /**\n * Returns true if the provided parameter is the same state.\n *\n * Compares the identity of the state against the passed value, which is either an object\n * reference to the actual `State` instance, the original definition object passed to\n * `$stateProvider.state()`, or the fully-qualified name.\n *\n * @param ref Can be one of (a) a `State` instance, (b) an object that was passed\n * into `$stateProvider.state()`, (c) the fully-qualified name of a state as a string.\n * @returns Returns `true` if `ref` matches the current `State` instance.\n */\n is(ref: StateObject|StateDeclaration|string): boolean {\n return this === ref || this.self === ref || this.fqn() === ref;\n }\n\n /**\n * @deprecated this does not properly handle dot notation\n * @returns Returns a dot-separated name of the state.\n */\n fqn(): string {\n if (!this.parent || !(this.parent instanceof this.constructor)) return this.name;\n let name = this.parent.fqn();\n return name ? name + \".\" + this.name : this.name;\n }\n\n /**\n * Returns the root node of this state's tree.\n *\n * @returns The root of this state's tree.\n */\n root(): StateObject {\n return this.parent && this.parent.root() || this;\n }\n\n /**\n * Gets the state's `Param` objects\n *\n * Gets the list of [[Param]] objects owned by the state.\n * If `opts.inherit` is true, it also includes the ancestor states' [[Param]] objects.\n * If `opts.matchingKeys` exists, returns only `Param`s whose `id` is a key on the `matchingKeys` object\n *\n * @param opts options\n */\n parameters(opts?: { inherit?: boolean, matchingKeys?: any }): Param[] {\n opts = defaults(opts, { inherit: true, matchingKeys: null });\n let inherited = opts.inherit && this.parent && this.parent.parameters() || [];\n return inherited.concat(values(this.params))\n .filter(param => !opts.matchingKeys || opts.matchingKeys.hasOwnProperty(param.id));\n }\n\n /**\n * Returns a single [[Param]] that is owned by the state\n *\n * If `opts.inherit` is true, it also searches the ancestor states` [[Param]]s.\n * @param id the name of the [[Param]] to return\n * @param opts options\n */\n parameter(id: string, opts: { inherit?: boolean } = {}): Param {\n return (\n this.url && this.url.parameter(id, opts) ||\n find(values(this.params), propEq('id', id)) ||\n opts.inherit && this.parent && this.parent.parameter(id)\n );\n }\n\n toString() {\n return this.fqn();\n }\n}\n","/** Predicates\n *\n * These predicates return true/false based on the input.\n * Although these functions are exported, they are subject to change without notice.\n *\n * @module common_predicates\n */\n/** */\nimport { and, not, pipe, prop, or } from \"./hof\";\nimport { Predicate } from \"./common\"; // has or is using\nimport { StateObject } from \"../state/stateObject\";\n\nconst toStr = Object.prototype.toString;\nconst tis = (t: string) => (x: any) => typeof(x) === t;\nexport const isUndefined = tis('undefined');\nexport const isDefined = not(isUndefined);\nexport const isNull = (o: any) => o === null;\nexport const isNullOrUndefined = or(isNull, isUndefined);\nexport const isFunction: (x: any) => x is Function = tis('function');\nexport const isNumber: (x: any) => x is number = tis('number');\nexport const isString = <(x: any) => x is string> tis('string');\nexport const isObject = (x: any) => x !== null && typeof x === 'object';\nexport const isArray = Array.isArray;\nexport const isDate: (x: any) => x is Date = ((x: any) => toStr.call(x) === '[object Date]');\nexport const isRegExp: (x: any) => x is RegExp = ((x: any) => toStr.call(x) === '[object RegExp]');\nexport const isState: (x: any) => x is StateObject = StateObject.isState;\n\n/**\n * Predicate which checks if a value is injectable\n *\n * A value is \"injectable\" if it is a function, or if it is an ng1 array-notation-style array\n * where all the elements in the array are Strings, except the last one, which is a Function\n */\nexport function isInjectable(val: any) {\n if (isArray(val) && val.length) {\n let head = val.slice(0, -1), tail = val.slice(-1);\n return !(head.filter(not(isString)).length || tail.filter(not(isFunction)).length);\n }\n return isFunction(val);\n}\n\n/**\n * Predicate which checks if a value looks like a Promise\n *\n * It is probably a Promise if it's an object, and it has a `then` property which is a Function\n */\nexport const isPromise = <(x: any) => x is Promise> and(isObject, pipe(prop('then'), isFunction));\n\n","/**\n * This module is a stub for core services such as Dependency Injection or Browser Location.\n * Core services may be implemented by a specific framework, such as ng1 or ng2, or be pure javascript.\n *\n * @module common\n */\n/** for typedoc */\nimport {IInjectable, Obj} from \"./common\";\nimport { Disposable } from \"../interface\";\nimport { UrlParts } from \"../url/interface\";\n\nexport let notImplemented = (fnname: string) => () => {\n throw new Error(`${fnname}(): No coreservices implementation for UI-Router is loaded.`);\n};\n\nlet services: CoreServices = {\n $q: undefined,\n $injector: undefined,\n};\n\nexport interface $QLikeDeferred {\n resolve: (val?: any) => void;\n reject: (reason?: any) => void;\n promise: Promise;\n}\n\nexport interface $QLike {\n when(value?: T | PromiseLike): Promise;\n reject(reason: any): Promise;\n defer(): $QLikeDeferred;\n all(promises: { [key: string]: Promise }): Promise;\n all(promises: Promise[]): Promise;\n}\n\nexport interface $InjectorLike {\n get(token: any): any;\n get(token: any): T;\n has(token: any): boolean;\n invoke(fn: IInjectable, context?: any, locals?: Obj): any;\n annotate(fn: IInjectable, strictDi?: boolean): any[];\n strictDi?: boolean;\n}\n\nexport interface CoreServices {\n $q: $QLike;\n $injector: $InjectorLike;\n}\n\nexport interface LocationServices extends Disposable {\n /**\n * Gets the current url string\n *\n * The URL is normalized using the internal [[path]]/[[search]]/[[hash]] values.\n *\n * For example, the URL may be stored in the hash ([[HashLocationServices]]) or\n * have a base HREF prepended ([[PushStateLocationServices]]).\n *\n * The raw URL in the browser might be:\n *\n * ```\n * http://mysite.com/somepath/index.html#/internal/path/123?param1=foo#anchor\n * ```\n *\n * or\n *\n * ```\n * http://mysite.com/basepath/internal/path/123?param1=foo#anchor\n * ```\n *\n * then this method returns:\n *\n * ```\n * /internal/path/123?param1=foo#anchor\n * ```\n *\n *\n * #### Example:\n * ```js\n * locationServices.url(); // \"/some/path?query=value#anchor\"\n * ```\n *\n * @returns the current value of the url, as a string.\n */\n url(): string;\n\n /**\n * Updates the url, or gets the current url\n *\n * Updates the url, changing it to the value in `newurl`\n *\n * #### Example:\n * ```js\n * locationServices.url(\"/some/path?query=value#anchor\", true);\n * ```\n *\n * @param newurl The new value for the URL.\n * This url should reflect only the new internal [[path]], [[search]], and [[hash]] values.\n * It should not include the protocol, site, port, or base path of an absolute HREF.\n * @param replace When true, replaces the current history entry (instead of appending it) with this new url\n * @param state The history's state object, i.e., pushState (if the LocationServices implementation supports it)\n * @return the url (after potentially being processed)\n */\n url(newurl: string, replace?: boolean, state?: any): string;\n\n /**\n * Gets the path part of the current url\n *\n * If the current URL is `/some/path?query=value#anchor`, this returns `/some/path`\n *\n * @return the path portion of the url\n */\n path(): string;\n\n /**\n * Gets the search part of the current url as an object\n *\n * If the current URL is `/some/path?query=value#anchor`, this returns `{ query: 'value' }`\n *\n * @return the search (querystring) portion of the url, as an object\n */\n search(): { [key: string]: any };\n\n /**\n * Gets the hash part of the current url\n *\n * If the current URL is `/some/path?query=value#anchor`, this returns `anchor`\n *\n * @return the hash (anchor) portion of the url\n */\n hash(): string;\n\n /**\n * Registers a url change handler\n *\n * #### Example:\n * ```js\n * let deregisterFn = locationServices.onChange((evt) => console.log(\"url change\", evt));\n * ```\n *\n * @param callback a function that will be called when the url is changing\n * @return a function that de-registers the callback\n */\n onChange(callback: Function): Function;\n}\n\n/**\n * This service returns the location configuration\n *\n * This service returns information about the location configuration.\n * This service is primarily used when building URLs (e.g., for `hrefs`)\n */\nexport interface LocationConfig extends Disposable {\n /**\n * Gets the port, e.g., `80`\n *\n * @return the port number\n */\n port(): number;\n /**\n * Gets the protocol, e.g., `http`\n *\n * @return the protocol\n */\n protocol(): string;\n /**\n * Gets the host, e.g., `localhost`\n *\n * @return the protocol\n */\n host(): string;\n /**\n * Gets the base Href, e.g., `http://localhost/approot/`\n *\n * @return the application's base href\n */\n baseHref(): string;\n /**\n * Returns true when running in pushstate mode\n *\n * @return true when running in pushstate mode\n */\n html5Mode(): boolean;\n /**\n * Gets the hashPrefix (when not running in pushstate mode)\n *\n * If the current url is `http://localhost/app#!/uirouter/path/#anchor`, it returns `!` which is the prefix for the \"hashbang\" portion.\n *\n * @return the hash prefix\n */\n hashPrefix(): string;\n /**\n * Sets the hashPrefix (when not running in pushstate mode)\n *\n * @return the new hash prefix\n */\n hashPrefix(newprefix: string): string;\n}\n\nexport {services};\n","/**\n * Random utility functions used in the UI-Router code\n *\n * These functions are exported, but are subject to change without notice.\n *\n * @preferred\n * @module common\n */\n/** for typedoc */\nimport { isFunction, isString, isArray, isRegExp, isDate } from \"./predicates\";\nimport { all, any, prop, curry, not } from \"./hof\";\nimport { services } from \"./coreservices\";\nimport { StateObject } from \"../state/stateObject\";\n\ndeclare const global;\nexport const root: any = (typeof self === 'object' && self.self === self && self) ||\n (typeof global === 'object' && global.global === global && global) || this;\nconst angular = root.angular || {};\n\nexport const fromJson = angular.fromJson || JSON.parse.bind(JSON);\nexport const toJson = angular.toJson || JSON.stringify.bind(JSON);\nexport const forEach = angular.forEach || _forEach;\nexport const extend = Object.assign || _extend;\nexport const equals = angular.equals || _equals;\nexport function identity(x: any) { return x; }\nexport function noop(): any {}\n\nexport type Mapper = (x: X, key?: (string|number)) => T;\nexport interface TypedMap { [key: string]: T; }\nexport type Predicate = (x?: X) => boolean;\n/**\n * An ng1-style injectable\n *\n * This could be a (non-minified) function such as:\n * ```js\n * function injectableFunction(SomeDependency) {\n *\n * }\n * ```\n *\n * or an explicitly annotated function (minify safe)\n * ```js\n * injectableFunction.$inject = [ 'SomeDependency' ];\n * function injectableFunction(SomeDependency) {\n *\n * }\n * ```\n *\n * or an array style annotated function (minify safe)\n * ```js\n * ['SomeDependency', function injectableFunction(SomeDependency) {\n *\n * }];\n * ```\n *\n * @publicapi\n */\nexport type IInjectable = (Function|any[]);\n\nexport interface Obj extends Object {\n [key: string]: any;\n}\n\n/**\n * Builds proxy functions on the `to` object which pass through to the `from` object.\n *\n * For each key in `fnNames`, creates a proxy function on the `to` object.\n * The proxy function calls the real function on the `from` object.\n *\n *\n * #### Example:\n * This example creates an new class instance whose functions are prebound to the new'd object.\n * ```js\n * class Foo {\n * constructor(data) {\n * // Binds all functions from Foo.prototype to 'this',\n * // then copies them to 'this'\n * bindFunctions(Foo.prototype, this, this);\n * this.data = data;\n * }\n *\n * log() {\n * console.log(this.data);\n * }\n * }\n *\n * let myFoo = new Foo([1,2,3]);\n * var logit = myFoo.log;\n * logit(); // logs [1, 2, 3] from the myFoo 'this' instance\n * ```\n *\n * #### Example:\n * This example creates a bound version of a service function, and copies it to another object\n * ```\n *\n * var SomeService = {\n * this.data = [3, 4, 5];\n * this.log = function() {\n * console.log(this.data);\n * }\n * }\n *\n * // Constructor fn\n * function OtherThing() {\n * // Binds all functions from SomeService to SomeService,\n * // then copies them to 'this'\n * bindFunctions(SomeService, this, SomeService);\n * }\n *\n * let myOtherThing = new OtherThing();\n * myOtherThing.log(); // logs [3, 4, 5] from SomeService's 'this'\n * ```\n *\n * @param source A function that returns the source object which contains the original functions to be bound\n * @param target A function that returns the target object which will receive the bound functions\n * @param bind A function that returns the object which the functions will be bound to\n * @param fnNames The function names which will be bound (Defaults to all the functions found on the 'from' object)\n * @param latebind If true, the binding of the function is delayed until the first time it's invoked\n */\nexport function createProxyFunctions(source: Function, target: Obj, bind: Function, fnNames?: string[], latebind = false): Obj {\n const bindFunction = (fnName) =>\n source()[fnName].bind(bind());\n\n const makeLateRebindFn = fnName => function lateRebindFunction() {\n target[fnName] = bindFunction(fnName);\n return target[fnName].apply(null, arguments);\n };\n\n fnNames = fnNames || Object.keys(source());\n\n return fnNames.reduce((acc, name) => {\n acc[name] = latebind ? makeLateRebindFn(name) : bindFunction(name);\n return acc;\n }, target);\n}\n\n\n/**\n * prototypal inheritance helper.\n * Creates a new object which has `parent` object as its prototype, and then copies the properties from `extra` onto it\n */\nexport const inherit = (parent: Obj, extra?: Obj) =>\n extend(Object.create(parent), extra);\n\n/** Given an array, returns true if the object is found in the array, (using indexOf) */\nexport const inArray: typeof _inArray = curry(_inArray) as any;\nexport function _inArray(array: any[], obj: any): boolean;\nexport function _inArray(array: any[]): (obj: any) => boolean;\nexport function _inArray(array, obj?): any {\n return array.indexOf(obj) !== -1;\n}\n\n/**\n * Given an array, and an item, if the item is found in the array, it removes it (in-place).\n * The same array is returned\n */\nexport const removeFrom: typeof _removeFrom = curry(_removeFrom) as any;\nexport function _removeFrom(array: T[], obj: T): T[];\nexport function _removeFrom(array: T[]): (obj: T) => T[];\nexport function _removeFrom(array, obj?) {\n let idx = array.indexOf(obj);\n if (idx >= 0) array.splice(idx, 1);\n return array;\n}\n\n/** pushes a values to an array and returns the value */\nexport const pushTo: typeof _pushTo = curry(_pushTo) as any;\nexport function _pushTo(arr: T[], val: T): T ;\nexport function _pushTo(arr: T[]): (val: T) => T ;\nexport function _pushTo(arr, val?): any {\n return (arr.push(val), val);\n}\n\n/** Given an array of (deregistration) functions, calls all functions and removes each one from the source array */\nexport const deregAll = (functions: Function[]) =>\n functions.slice().forEach(fn => {\n typeof fn === 'function' && fn();\n removeFrom(functions, fn);\n });\n/**\n * Applies a set of defaults to an options object. The options object is filtered\n * to only those properties of the objects in the defaultsList.\n * Earlier objects in the defaultsList take precedence when applying defaults.\n */\nexport function defaults(opts, ...defaultsList: Obj[]) {\n let _defaultsList = defaultsList.concat({}).reverse();\n let defaultVals = extend.apply(null, _defaultsList);\n return extend({}, defaultVals, pick(opts || {}, Object.keys(defaultVals)));\n}\n\n/** Reduce function that merges each element of the list into a single object, using extend */\nexport const mergeR = (memo: Obj, item: Obj) => extend(memo, item);\n\n/**\n * Finds the common ancestor path between two states.\n *\n * @param {Object} first The first state.\n * @param {Object} second The second state.\n * @return {Array} Returns an array of state names in descending order, not including the root.\n */\nexport function ancestors(first: StateObject, second: StateObject) {\n let path: StateObject[] = [];\n\n for (let n in first.path) {\n if (first.path[n] !== second.path[n]) break;\n path.push(first.path[n]);\n }\n return path;\n}\n\n/**\n * Return a copy of the object only containing the whitelisted properties.\n *\n * #### Example:\n * ```\n * var foo = { a: 1, b: 2, c: 3 };\n * var ab = pick(foo, ['a', 'b']); // { a: 1, b: 2 }\n * ```\n * @param obj the source object\n * @param propNames an Array of strings, which are the whitelisted property names\n */\nexport function pick(obj: Obj, propNames: string[]): Obj {\n let objCopy = {};\n for (let prop in obj) {\n if (propNames.indexOf(prop) !== -1) {\n objCopy[prop] = obj[prop];\n }\n }\n return objCopy;\n}\n\n/**\n * Return a copy of the object omitting the blacklisted properties.\n *\n * @example\n * ```\n *\n * var foo = { a: 1, b: 2, c: 3 };\n * var ab = omit(foo, ['a', 'b']); // { c: 3 }\n * ```\n * @param obj the source object\n * @param propNames an Array of strings, which are the blacklisted property names\n */\nexport function omit(obj: Obj, propNames: string[]): Obj {\n return Object.keys(obj)\n .filter(not(inArray(propNames)))\n .reduce((acc, key) => (acc[key] = obj[key], acc), {});\n}\n\n\n/** Given an array of objects, maps each element to a named property of the element. */\nexport function pluck(collection: Obj[], propName: string): T[];\n/** Given an object, maps each property of the object to a named property of the property. */\nexport function pluck(collection: { [key: string]: any }, propName: string): { [key: string]: any };\n/**\n * Maps an array, or object to a property (by name)\n */\nexport function pluck(collection: any, propName: string): any {\n return map(collection, > prop(propName));\n}\n\n\n/** Given an array of objects, returns a new array containing only the elements which passed the callback predicate */\nexport function filter(collection: T[], callback: (t: T, key?: number) => boolean): T[];\n/** Given an object, returns a new object with only those properties that passed the callback predicate */\nexport function filter(collection: TypedMap, callback: (t: T, key?: string) => boolean): TypedMap;\n/** Filters an Array or an Object's properties based on a predicate */\nexport function filter(collection: any, callback: Function): T {\n let arr = isArray(collection), result: any = arr ? [] : {};\n let accept = arr ? x => result.push(x) : (x, key) => result[key] = x;\n forEach(collection, function(item, i) {\n if (callback(item, i)) accept(item, i);\n });\n return result;\n}\n\n\n/** Given an object, return the first property of that object which passed the callback predicate */\nexport function find(collection: TypedMap, callback: Predicate): T;\n/** Given an array of objects, returns the first object which passed the callback predicate */\nexport function find(collection: T[], callback: Predicate): T;\n/** Finds an object from an array, or a property of an object, that matches a predicate */\nexport function find(collection: any, callback: any) {\n let result;\n\n forEach(collection, function(item, i) {\n if (result) return;\n if (callback(item, i)) result = item;\n });\n\n return result;\n}\n\n/** Given an object, returns a new object, where each property is transformed by the callback function */\nexport let mapObj: (collection: { [key: string]: T }, callback: Mapper) => { [key: string]: U } = map;\n/** Given an array, returns a new array, where each element is transformed by the callback function */\nexport function map(collection: T[], callback: Mapper): U[];\nexport function map(collection: { [key: string]: T }, callback: Mapper): { [key: string]: U };\n/** Maps an array or object properties using a callback function */\nexport function map(collection: any, callback: any): any {\n let result = isArray(collection) ? [] : {};\n forEach(collection, (item, i) => result[i] = callback(item, i));\n return result;\n}\n\n/**\n * Given an object, return its enumerable property values\n *\n * @example\n * ```\n *\n * let foo = { a: 1, b: 2, c: 3 }\n * let vals = values(foo); // [ 1, 2, 3 ]\n * ```\n */\nexport const values: ( (obj: TypedMap) => T[]) = (obj: Obj) =>\n Object.keys(obj).map(key => obj[key]);\n\n/**\n * Reduce function that returns true if all of the values are truthy.\n *\n * @example\n * ```\n *\n * let vals = [ 1, true, {}, \"hello world\"];\n * vals.reduce(allTrueR, true); // true\n *\n * vals.push(0);\n * vals.reduce(allTrueR, true); // false\n * ```\n */\nexport const allTrueR = (memo: boolean, elem: any) => memo && elem;\n\n/**\n * Reduce function that returns true if any of the values are truthy.\n *\n * * @example\n * ```\n *\n * let vals = [ 0, null, undefined ];\n * vals.reduce(anyTrueR, true); // false\n *\n * vals.push(\"hello world\");\n * vals.reduce(anyTrueR, true); // true\n * ```\n */\nexport const anyTrueR = (memo: boolean, elem: any) => memo || elem;\n\n/**\n * Reduce function which un-nests a single level of arrays\n * @example\n * ```\n *\n * let input = [ [ \"a\", \"b\" ], [ \"c\", \"d\" ], [ [ \"double\", \"nested\" ] ] ];\n * input.reduce(unnestR, []) // [ \"a\", \"b\", \"c\", \"d\", [ \"double, \"nested\" ] ]\n * ```\n */\nexport const unnestR = (memo: any[], elem: any[]) => memo.concat(elem);\n\n/**\n * Reduce function which recursively un-nests all arrays\n *\n * @example\n * ```\n *\n * let input = [ [ \"a\", \"b\" ], [ \"c\", \"d\" ], [ [ \"double\", \"nested\" ] ] ];\n * input.reduce(unnestR, []) // [ \"a\", \"b\", \"c\", \"d\", \"double, \"nested\" ]\n * ```\n */\nexport const flattenR = (memo: any[], elem: any) =>\n isArray(elem) ? memo.concat(elem.reduce(flattenR, [])) : pushR(memo, elem);\n\n/**\n * Reduce function that pushes an object to an array, then returns the array.\n * Mostly just for [[flattenR]] and [[uniqR]]\n */\nexport function pushR(arr: any[], obj: any) {\n arr.push(obj);\n return arr;\n}\n\n/** Reduce function that filters out duplicates */\nexport const uniqR = (acc: T[], token: T): T[] =>\n inArray(acc, token) ? acc : pushR(acc, token);\n\n/**\n * Return a new array with a single level of arrays unnested.\n *\n * @example\n * ```\n *\n * let input = [ [ \"a\", \"b\" ], [ \"c\", \"d\" ], [ [ \"double\", \"nested\" ] ] ];\n * unnest(input) // [ \"a\", \"b\", \"c\", \"d\", [ \"double, \"nested\" ] ]\n * ```\n */\nexport const unnest = (arr: any[]) => arr.reduce(unnestR, []);\n/**\n * Return a completely flattened version of an array.\n *\n * @example\n * ```\n *\n * let input = [ [ \"a\", \"b\" ], [ \"c\", \"d\" ], [ [ \"double\", \"nested\" ] ] ];\n * flatten(input) // [ \"a\", \"b\", \"c\", \"d\", \"double, \"nested\" ]\n * ```\n */\nexport const flatten = (arr: any[]) => arr.reduce(flattenR, []);\n\n/**\n * Given a .filter Predicate, builds a .filter Predicate which throws an error if any elements do not pass.\n * @example\n * ```\n *\n * let isNumber = (obj) => typeof(obj) === 'number';\n * let allNumbers = [ 1, 2, 3, 4, 5 ];\n * allNumbers.filter(assertPredicate(isNumber)); //OK\n *\n * let oneString = [ 1, 2, 3, 4, \"5\" ];\n * oneString.filter(assertPredicate(isNumber, \"Not all numbers\")); // throws Error(\"\"Not all numbers\"\");\n * ```\n */\nexport const assertPredicate: (predicate: Predicate, errMsg: (string|Function)) => Predicate = assertFn;\n/**\n * Given a .map function, builds a .map function which throws an error if any mapped elements do not pass a truthyness test.\n * @example\n * ```\n *\n * var data = { foo: 1, bar: 2 };\n *\n * let keys = [ 'foo', 'bar' ]\n * let values = keys.map(assertMap(key => data[key], \"Key not found\"));\n * // values is [1, 2]\n *\n * let keys = [ 'foo', 'bar', 'baz' ]\n * let values = keys.map(assertMap(key => data[key], \"Key not found\"));\n * // throws Error(\"Key not found\")\n * ```\n */\nexport const assertMap: (mapFn: (t: T) => U, errMsg: (string|Function)) => (t: T) => U = assertFn;\nexport function assertFn(predicateOrMap: Function, errMsg: (string|Function) = \"assert failure\"): any {\n return (obj) => {\n let result = predicateOrMap(obj);\n if (!result) {\n throw new Error(isFunction(errMsg) ? ( errMsg)(obj) : errMsg);\n }\n return result;\n };\n}\n\n/**\n * Like _.pairs: Given an object, returns an array of key/value pairs\n *\n * @example\n * ```\n *\n * pairs({ foo: \"FOO\", bar: \"BAR }) // [ [ \"foo\", \"FOO\" ], [ \"bar\": \"BAR\" ] ]\n * ```\n */\nexport const pairs = (obj: Obj) =>\n Object.keys(obj).map(key => [ key, obj[key]] );\n\n/**\n * Given two or more parallel arrays, returns an array of tuples where\n * each tuple is composed of [ a[i], b[i], ... z[i] ]\n *\n * @example\n * ```\n *\n * let foo = [ 0, 2, 4, 6 ];\n * let bar = [ 1, 3, 5, 7 ];\n * let baz = [ 10, 30, 50, 70 ];\n * arrayTuples(foo, bar); // [ [0, 1], [2, 3], [4, 5], [6, 7] ]\n * arrayTuples(foo, bar, baz); // [ [0, 1, 10], [2, 3, 30], [4, 5, 50], [6, 7, 70] ]\n * ```\n */\nexport function arrayTuples(...args: any[]): any[] {\n if (args.length === 0) return [];\n let maxArrayLen = args.reduce((min, arr) => Math.min(arr.length, min), 9007199254740991); // aka 2^53 − 1 aka Number.MAX_SAFE_INTEGER\n\n let i, result = [];\n\n for (i = 0; i < maxArrayLen; i++) {\n // This is a hot function\n // Unroll when there are 1-4 arguments\n switch (args.length) {\n case 1: result.push([args[0][i]]); break;\n case 2: result.push([args[0][i], args[1][i]]); break;\n case 3: result.push([args[0][i], args[1][i], args[2][i]]); break;\n case 4: result.push([args[0][i], args[1][i], args[2][i], args[3][i]]); break;\n default:\n result.push(args.map(array => array[i])); break;\n }\n }\n\n return result;\n}\n\n/**\n * Reduce function which builds an object from an array of [key, value] pairs.\n *\n * Each iteration sets the key/val pair on the memo object, then returns the memo for the next iteration.\n *\n * Each keyValueTuple should be an array with values [ key: string, value: any ]\n *\n * @example\n * ```\n *\n * var pairs = [ [\"fookey\", \"fooval\"], [\"barkey\", \"barval\"] ]\n *\n * var pairsToObj = pairs.reduce((memo, pair) => applyPairs(memo, pair), {})\n * // pairsToObj == { fookey: \"fooval\", barkey: \"barval\" }\n *\n * // Or, more simply:\n * var pairsToObj = pairs.reduce(applyPairs, {})\n * // pairsToObj == { fookey: \"fooval\", barkey: \"barval\" }\n * ```\n */\nexport function applyPairs(memo: TypedMap, keyValTuple: any[]) {\n let key: string, value: any;\n if (isArray(keyValTuple)) [key, value] = keyValTuple;\n if (!isString(key)) throw new Error(\"invalid parameters to applyPairs\");\n memo[key] = value;\n return memo;\n}\n\n/** Get the last element of an array */\nexport function tail(arr: T[]): T {\n return arr.length && arr[arr.length - 1] || undefined;\n}\n\n/**\n * shallow copy from src to dest\n */\nexport function copy(src: Obj, dest?: Obj) {\n if (dest) Object.keys(dest).forEach(key => delete dest[key]);\n if (!dest) dest = {};\n return extend(dest, src);\n}\n\n/** Naive forEach implementation works with Objects or Arrays */\nfunction _forEach(obj: (any[]|any), cb: (el, idx?) => void, _this: Obj) {\n if (isArray(obj)) return obj.forEach(cb, _this);\n Object.keys(obj).forEach(key => cb(obj[key], key));\n}\n\n/** Like Object.assign() */\nexport function _extend(toObj: Obj, ...fromObjs: Obj[]): any;\nexport function _extend(toObj: Obj): any {\n for (let i = 1; i < arguments.length; i++) {\n let obj = arguments[i];\n if (!obj) continue;\n let keys = Object.keys(obj);\n\n for (let j = 0; j < keys.length; j++) {\n toObj[keys[j]] = obj[keys[j]];\n }\n }\n\n return toObj;\n}\n\nfunction _equals(o1: any, o2: any): boolean {\n if (o1 === o2) return true;\n if (o1 === null || o2 === null) return false;\n if (o1 !== o1 && o2 !== o2) return true; // NaN === NaN\n let t1 = typeof o1, t2 = typeof o2;\n if (t1 !== t2 || t1 !== 'object') return false;\n\n const tup = [o1, o2];\n if (all(isArray)(tup)) return _arraysEq(o1, o2);\n if (all(isDate)(tup)) return o1.getTime() === o2.getTime();\n if (all(isRegExp)(tup)) return o1.toString() === o2.toString();\n if (all(isFunction)(tup)) return true; // meh\n\n let predicates = [isFunction, isArray, isDate, isRegExp];\n if (predicates.map(any).reduce((b, fn) => b || !!fn(tup), false)) return false;\n\n let key: string, keys: { [i: string]: boolean } = {};\n for (key in o1) {\n if (!_equals(o1[key], o2[key])) return false;\n keys[key] = true;\n }\n for (key in o2) {\n if (!keys[key]) return false;\n }\n\n return true;\n}\n\nfunction _arraysEq(a1: any[], a2: any[]) {\n if (a1.length !== a2.length) return false;\n return arrayTuples(a1, a2).reduce((b, t) => b && _equals(t[0], t[1]), true);\n}\n\n// issue #2676\nexport const silenceUncaughtInPromise = (promise: Promise) =>\n promise.catch(e => 0) && promise;\nexport const silentRejection = (error: any) =>\n silenceUncaughtInPromise(services.$q.reject(error));\n","/**\n * @module common\n */ /** for typedoc */\n\nexport class Queue {\n constructor(private _items: T[] = [], private _limit: number = null) { }\n\n enqueue(item: T) {\n let items = this._items;\n items.push(item);\n if (this._limit && items.length > this._limit) items.shift();\n return item;\n }\n\n dequeue(): T {\n if (this.size())\n return this._items.splice(0, 1)[0];\n }\n\n clear(): Array {\n let current = this._items;\n this._items = [];\n return current;\n }\n\n size(): number {\n return this._items.length;\n }\n\n remove(item: T) {\n let idx = this._items.indexOf(item);\n return idx > -1 && this._items.splice(idx, 1)[0];\n }\n\n peekTail(): T {\n return this._items[this._items.length - 1];\n }\n\n peekHead(): T {\n if (this.size())\n return this._items[0];\n }\n}\n","/**\n * @coreapi\n * @module transition\n */ /** for typedoc */\n\"use strict\";\nimport {extend, silentRejection} from \"../common/common\";\nimport {stringify} from \"../common/strings\";\nimport { is } from '../common/hof';\n\nexport enum RejectType {\n SUPERSEDED = 2, ABORTED = 3, INVALID = 4, IGNORED = 5, ERROR = 6\n}\n\n/** @hidden */ let id = 0;\n\nexport class Rejection {\n $id = id++;\n type: number;\n message: string;\n detail: any;\n redirected: boolean;\n\n constructor(type: number, message?: string, detail?: any) {\n this.type = type;\n this.message = message;\n this.detail = detail;\n }\n\n toString() {\n const detailString = (d: any) => \n d && d.toString !== Object.prototype.toString ? d.toString() : stringify(d);\n let detail = detailString(this.detail);\n let { $id, type, message } = this;\n return `Transition Rejection($id: ${$id} type: ${type}, message: ${message}, detail: ${detail})`;\n }\n\n toPromise(): Promise {\n return extend(silentRejection(this), { _transitionRejection: this });\n }\n\n /** Returns true if the obj is a rejected promise created from the `asPromise` factory */\n static isRejectionPromise(obj: any): boolean {\n return obj && (typeof obj.then === 'function') && is(Rejection)(obj._transitionRejection);\n }\n\n /** Returns a Rejection due to transition superseded */\n static superseded(detail?: any, options?: any): Rejection {\n let message = \"The transition has been superseded by a different transition\";\n let rejection = new Rejection(RejectType.SUPERSEDED, message, detail);\n if (options && options.redirected) {\n rejection.redirected = true;\n }\n return rejection;\n }\n\n /** Returns a Rejection due to redirected transition */\n static redirected(detail?: any): Rejection {\n return Rejection.superseded(detail, { redirected: true });\n }\n\n /** Returns a Rejection due to invalid transition */\n static invalid(detail?: any): Rejection {\n let message = \"This transition is invalid\";\n return new Rejection(RejectType.INVALID, message, detail);\n }\n\n /** Returns a Rejection due to ignored transition */\n static ignored(detail?: any): Rejection {\n let message = \"The transition was ignored\";\n return new Rejection(RejectType.IGNORED, message, detail);\n }\n\n /** Returns a Rejection due to aborted transition */\n static aborted(detail?: any): Rejection {\n let message = \"The transition has been aborted\";\n return new Rejection(RejectType.ABORTED, message, detail);\n }\n\n /** Returns a Rejection due to aborted transition */\n static errored(detail?: any): Rejection {\n let message = \"The transition errored\";\n return new Rejection(RejectType.ERROR, message, detail);\n }\n \n /**\n * Returns a Rejection\n *\n * Normalizes a value as a Rejection.\n * If the value is already a Rejection, returns it.\n * Otherwise, wraps and returns the value as a Rejection (Rejection type: ERROR).\n *\n * @returns `detail` if it is already a `Rejection`, else returns an ERROR Rejection.\n */\n static normalize(detail?: Rejection | Error | any): Rejection {\n return is(Rejection)(detail) ? detail : Rejection.errored(detail);\n }\n}\n","/**\n * # Transition tracing (debug)\n *\n * Enable transition tracing to print transition information to the console,\n * in order to help debug your application.\n * Tracing logs detailed information about each Transition to your console.\n *\n * To enable tracing, import the [[Trace]] singleton and enable one or more categories.\n *\n * ### ES6\n * ```js\n * import {trace} from \"ui-router-ng2\"; // or \"angular-ui-router\"\n * trace.enable(1, 5); // TRANSITION and VIEWCONFIG\n * ```\n *\n * ### CJS\n * ```js\n * let trace = require(\"angular-ui-router\").trace; // or \"ui-router-ng2\"\n * trace.enable(\"TRANSITION\", \"VIEWCONFIG\");\n * ```\n *\n * ### Globals\n * ```js\n * let trace = window[\"angular-ui-router\"].trace; // or \"ui-router-ng2\"\n * trace.enable(); // Trace everything (very verbose)\n * ```\n *\n * ### Angular 1:\n * ```js\n * app.run($trace => $trace.enable());\n * ```\n *\n * @coreapi\n * @module trace\n */ /** for typedoc */\nimport {parse} from \"../common/hof\";\nimport {isFunction, isNumber} from \"../common/predicates\";\nimport {Transition} from \"../transition/transition\";\nimport {ActiveUIView, ViewConfig, ViewContext} from \"../view/interface\";\nimport {stringify, functionToString, maxLength, padString} from \"./strings\";\nimport {Resolvable} from \"../resolve/resolvable\";\nimport {PathNode} from \"../path/pathNode\";\nimport {PolicyWhen} from \"../resolve/interface\";\nimport {TransitionHook} from \"../transition/transitionHook\";\nimport {HookResult} from \"../transition/interface\";\nimport {StateObject} from \"../state/stateObject\";\n\n/** @hidden */\nfunction uiViewString (uiview: ActiveUIView) {\n if (!uiview) return 'ui-view (defunct)';\n const state = uiview.creationContext ? uiview.creationContext.name || '(root)' : '(none)';\n return `[ui-view#${uiview.id} ${uiview.$type}:${uiview.fqn} (${uiview.name}@${state})]`;\n}\n\n/** @hidden */\nconst viewConfigString = (viewConfig: ViewConfig) => {\n let view = viewConfig.viewDecl;\n const state = view.$context.name || '(root)';\n return `[View#${viewConfig.$id} from '${state}' state]: target ui-view: '${view.$uiViewName}@${view.$uiViewContextAnchor}'`;\n};\n\n/** @hidden */\nfunction normalizedCat(input: Category|string): string {\n return isNumber(input) ? Category[input] : Category[Category[input]];\n}\n\n/** @hidden */\nconst consoletable = isFunction(console.table) ? console.table.bind(console) : console.log.bind(console);\n\n/**\n * Trace categories Enum\n *\n * Enable or disable a category using [[Trace.enable]] or [[Trace.disable]]\n *\n * `trace.enable(Category.TRANSITION)`\n *\n * These can also be provided using a matching string, or position ordinal\n *\n * `trace.enable(\"TRANSITION\")`\n *\n * `trace.enable(1)`\n */\nexport enum Category {\n RESOLVE, TRANSITION, HOOK, UIVIEW, VIEWCONFIG,\n}\n\n/** @hidden */ const _tid = parse(\"$id\");\n/** @hidden */ const _rid = parse(\"router.$id\");\n/** @hidden */ const transLbl = (trans) => `Transition #${_tid(trans)}-${_rid(trans)}`;\n\n/**\n * Prints UI-Router Transition trace information to the console.\n */\nexport class Trace {\n /** @hidden */\n approximateDigests: number;\n\n /** @hidden */\n constructor() {\n this.approximateDigests = 0;\n }\n\n /** @hidden */\n private _enabled: { [key: string]: boolean } = {};\n\n /** @hidden */\n private _set(enabled: boolean, categories: Category[]) {\n if (!categories.length) {\n categories = Object.keys(Category)\n .map(k => parseInt(k, 10))\n .filter(k => !isNaN(k))\n .map(key => Category[key]);\n }\n categories.map(normalizedCat).forEach(category => this._enabled[category] = enabled);\n }\n\n /**\n * Enables a trace [[Category]]\n *\n * ```js\n * trace.enable(\"TRANSITION\");\n * ```\n *\n * @param categories categories to enable. If `categories` is omitted, all categories are enabled.\n * Also takes strings (category name) or ordinal (category position)\n */\n enable(...categories: (Category|string|number)[]);\n enable(...categories: any[]) { this._set(true, categories); }\n /**\n * Disables a trace [[Category]]\n *\n * ```js\n * trace.disable(\"VIEWCONFIG\");\n * ```\n *\n * @param categories categories to disable. If `categories` is omitted, all categories are disabled.\n * Also takes strings (category name) or ordinal (category position)\n */\n disable(...categories: (Category|string|number)[]);\n disable(...categories: any[]) { this._set(false, categories); }\n\n /**\n * Retrieves the enabled stateus of a [[Category]]\n *\n * ```js\n * trace.enabled(\"VIEWCONFIG\"); // true or false\n * ```\n *\n * @returns boolean true if the category is enabled\n */\n enabled(category: (Category|string|number)): boolean {\n return !!this._enabled[normalizedCat(category)];\n }\n\n /** @internalapi called by ui-router code */\n traceTransitionStart(trans: Transition) {\n if (!this.enabled(Category.TRANSITION)) return;\n console.log(`${transLbl(trans)}: Started -> ${stringify(trans)}`);\n }\n\n /** @internalapi called by ui-router code */\n traceTransitionIgnored(trans: Transition) {\n if (!this.enabled(Category.TRANSITION)) return;\n console.log(`${transLbl(trans)}: Ignored <> ${stringify(trans)}`);\n }\n\n /** @internalapi called by ui-router code */\n traceHookInvocation(step: TransitionHook, trans: Transition, options: any) {\n if (!this.enabled(Category.HOOK)) return;\n let event = parse(\"traceData.hookType\")(options) || \"internal\",\n context = parse(\"traceData.context.state.name\")(options) || parse(\"traceData.context\")(options) || \"unknown\",\n name = functionToString((step as any).registeredHook.callback);\n console.log(`${transLbl(trans)}: Hook -> ${event} context: ${context}, ${maxLength(200, name)}`);\n }\n\n /** @internalapi called by ui-router code */\n traceHookResult(hookResult: HookResult, trans: Transition, transitionOptions: any) {\n if (!this.enabled(Category.HOOK)) return;\n console.log(`${transLbl(trans)}: <- Hook returned: ${maxLength(200, stringify(hookResult))}`);\n }\n\n /** @internalapi called by ui-router code */\n traceResolvePath(path: PathNode[], when: PolicyWhen, trans?: Transition) {\n if (!this.enabled(Category.RESOLVE)) return;\n console.log(`${transLbl(trans)}: Resolving ${path} (${when})`);\n }\n\n /** @internalapi called by ui-router code */\n traceResolvableResolved(resolvable: Resolvable, trans?: Transition) {\n if (!this.enabled(Category.RESOLVE)) return;\n console.log(`${transLbl(trans)}: <- Resolved ${resolvable} to: ${maxLength(200, stringify(resolvable.data))}`);\n }\n\n /** @internalapi called by ui-router code */\n traceError(reason: any, trans: Transition) {\n if (!this.enabled(Category.TRANSITION)) return;\n console.log(`${transLbl(trans)}: <- Rejected ${stringify(trans)}, reason: ${reason}`);\n }\n\n /** @internalapi called by ui-router code */\n traceSuccess(finalState: StateObject, trans: Transition) {\n if (!this.enabled(Category.TRANSITION)) return;\n console.log(`${transLbl(trans)}: <- Success ${stringify(trans)}, final state: ${finalState.name}`);\n }\n\n /** @internalapi called by ui-router code */\n traceUIViewEvent(event: string, viewData: ActiveUIView, extra = \"\") {\n if (!this.enabled(Category.UIVIEW)) return;\n console.log(`ui-view: ${padString(30, event)} ${uiViewString(viewData)}${extra}`);\n }\n\n /** @internalapi called by ui-router code */\n traceUIViewConfigUpdated(viewData: ActiveUIView, context: ViewContext) {\n if (!this.enabled(Category.UIVIEW)) return;\n this.traceUIViewEvent(\"Updating\", viewData, ` with ViewConfig from context='${context}'`);\n }\n\n /** @internalapi called by ui-router code */\n traceUIViewFill(viewData: ActiveUIView, html: string) {\n if (!this.enabled(Category.UIVIEW)) return;\n this.traceUIViewEvent(\"Fill\", viewData, ` with: ${maxLength(200, html)}`);\n }\n\n /** @internalapi called by ui-router code */\n traceViewSync(pairs: any[]) {\n if (!this.enabled(Category.VIEWCONFIG)) return;\n const mapping = pairs.map(([ uiViewData, config ]) => {\n const uiView = `${uiViewData.$type}:${uiViewData.fqn}`;\n const view = config && `${config.viewDecl.$context.name}: ${config.viewDecl.$name} (${config.viewDecl.$type})`;\n\n return { 'ui-view fqn': uiView, 'state: view name': view };\n }).sort((a, b) => a['ui-view fqn'].localeCompare(b['ui-view fqn']));\n\n consoletable(mapping);\n }\n\n /** @internalapi called by ui-router code */\n traceViewServiceEvent(event: string, viewConfig: ViewConfig) {\n if (!this.enabled(Category.VIEWCONFIG)) return;\n console.log(`VIEWCONFIG: ${event} ${viewConfigString(viewConfig)}`);\n }\n\n /** @internalapi called by ui-router code */\n traceViewServiceUIViewEvent(event: string, viewData: ActiveUIView) {\n if (!this.enabled(Category.VIEWCONFIG)) return;\n console.log(`VIEWCONFIG: ${event} ${uiViewString(viewData)}`);\n }\n}\n\n/**\n * The [[Trace]] singleton\n *\n * #### Example:\n * ```js\n * import {trace} from \"angular-ui-router\";\n * trace.enable(1, 5);\n * ```\n */\nlet trace = new Trace();\nexport {trace};\n","/**\n * @coreapi\n * @module transition\n */ /** for typedoc */\nimport {StateDeclaration} from \"../state/interface\";\nimport {Predicate} from \"../common/common\";\n\nimport {Transition} from \"./transition\";\nimport {StateObject} from \"../state/stateObject\";\nimport {PathNode} from \"../path/pathNode\";\nimport {TargetState} from \"../state/targetState\";\nimport {RegisteredHook} from \"./hookRegistry\";\n\n/**\n * The TransitionOptions object can be used to change the behavior of a transition.\n *\n * It is passed as the third argument to [[StateService.go]], [[StateService.transitionTo]].\n * It can also be used with a `uiSref`.\n */\nexport interface TransitionOptions {\n /**\n * This option changes how the Transition interacts with the browser's location bar (URL).\n *\n * - If `true`, it will update the url in the location bar.\n * - If `false`, it will not update the url in the location bar.\n * - If it is the string `\"replace\"`, it will update the url and also replace the last history record.\n *\n * @default `true`\n */\n location ?: (boolean|string);\n\n /**\n * When transitioning to relative path (e.g '`^`'), this option defines which state to be relative from.\n * @default `$state.current`\n */\n relative ?: (string|StateDeclaration|StateObject);\n\n /**\n * This option sets whether or not the transition's parameter values should be inherited from\n * the current parameter values.\n *\n * - If `true`, it will inherit parameter values from the current parameter values.\n * - If `false`, only the parameters which are provided to `transitionTo` will be used.\n *\n * @default `false`\n */\n inherit ?: boolean;\n\n /**\n * @deprecated\n */\n notify ?: boolean;\n\n /**\n * This option may be used to force states which are currently active to reload.\n *\n * During a normal transition, a state is \"retained\" if:\n * - It was previously active\n * - The state's parameter values have not changed\n * - All the parent states' parameter values have not changed\n *\n * Forcing a reload of a state will cause it to be exited and entered, which will:\n * - Refetch that state's resolve data\n * - Exit the state (onExit hook)\n * - Re-enter the state (onEnter hook)\n * - Re-render the views (controllers and templates)\n *\n * - When `true`, the destination state (and all parent states) will be reloaded.\n * - When it is a string and is the name of a state, or when it is a State object,\n * that state and any children states will be reloaded.\n *\n * @default `false`\n */\n reload ?: (boolean|string|StateDeclaration|StateObject);\n /**\n * You can define your own Transition Options inside this property and use them, e.g., from a Transition Hook\n */\n custom ?: any;\n /** @internalapi */\n reloadState ?: (StateObject);\n /** @internalapi\n * If this transition is a redirect, this property should be the original Transition (which was redirected to this one)\n */\n redirectedFrom?: Transition;\n /** @internalapi */\n current ?: () => Transition;\n /** @internalapi */\n source ?: \"sref\" | \"url\" | \"redirect\" | \"otherwise\" | \"unknown\";\n}\n\n/** @internalapi */\nexport interface TransitionHookOptions {\n current ?: () => Transition; //path?\n transition ?: Transition;\n hookType ?: string;\n target ?: any;\n traceData ?: any;\n bind ?: any;\n stateHook ?: boolean;\n}\n\n/**\n * TreeChanges encapsulates the various Paths that are involved in a Transition.\n *\n * Get a TreeChanges object using [[Transition.treeChanges]]\n *\n * A UI-Router Transition is from one Path in a State Tree to another Path. For a given Transition,\n * this object stores the \"to\" and \"from\" paths, as well as subsets of those: the \"retained\",\n * \"exiting\" and \"entering\" paths.\n *\n * Each path in TreeChanges is an array of [[PathNode]] objects. Each PathNode in the array corresponds to a portion\n * of a nested state.\n *\n * For example, if you had a nested state named `foo.bar.baz`, it would have three\n * portions, `foo, bar, baz`. If you transitioned **to** `foo.bar.baz` and inspected the [[TreeChanges.to]]\n * Path, you would find a node in the array for each portion: `foo`, `bar`, and `baz`.\n *\n * ---\n *\n * @todo show visual state tree\n */\nexport interface TreeChanges {\n /** @nodoc */\n [key: string]: PathNode[];\n\n /** The path of nodes in the state tree that the transition is coming *from* */\n from: PathNode[];\n\n /** The path of nodes in the state tree that the transition is going *to* */\n to: PathNode[];\n\n /**\n * The path of active nodes that the transition is retaining.\n *\n * These nodes are neither exited, nor entered.\n * Before and after the transition is successful, these nodes are active.\n */\n retained: PathNode[];\n\n /**\n * The path of previously active nodes that the transition is exiting.\n *\n * After the Transition is successful, these nodes are no longer active.\n *\n * Note that a state that is being reloaded (due to parameter values changing, or `reload: true`) may be in both the\n * `exiting` and `entering` paths.\n */\n exiting: PathNode[];\n\n /**\n * The path of nodes that the transition is entering.\n *\n * After the Transition is successful, these nodes will be active.\n * Because they are entering, they have their resolves fetched, `onEnter` hooks run, and their views\n * (component(s) or controller(s)+template(s)) refreshed.\n *\n * Note that a state that is reloaded (due to parameter values changing, or `reload: true`) may be in both the\n * `exiting` and `entering` paths.\n */\n entering: PathNode[];\n}\n\nexport type IHookRegistration = (matchCriteria: HookMatchCriteria, callback: HookFn, options?: HookRegOptions) => Function;\n\n/**\n * The signature for Transition Hooks.\n *\n * Transition hooks are callback functions that hook into the lifecycle of transitions.\n * As a transition runs, it reaches certain lifecycle events.\n * As each event occurs, the hooks which are registered for the event are called (in priority order).\n *\n * A transition hook may alter a Transition by returning a [[HookResult]].\n *\n * #### See:\n *\n * - [[IHookRegistry.onBefore]]\n * - [[IHookRegistry.onStart]]\n * - [[IHookRegistry.onFinish]]\n * - [[IHookRegistry.onSuccess]]\n * - [[IHookRegistry.onError]]\n *\n * @param transition the current [[Transition]]\n * @param injector (for ng1 or ng2 only) the injector service\n *\n * @returns a [[HookResult]] which may alter the transition\n *\n */\nexport interface TransitionHookFn {\n (transition: Transition) : HookResult;\n}\n\n/**\n * The signature for Transition State Hooks.\n *\n * A function which hooks into a lifecycle event for a specific state.\n *\n * Transition State Hooks are callback functions that hook into the lifecycle events of specific states during a transition.\n * As a transition runs, it may exit some states, retain (keep) states, and enter states.\n * As each lifecycle event occurs, the hooks which are registered for the event and that state are called (in priority order).\n *\n * #### See:\n *\n * - [[IHookRegistry.onExit]]\n * - [[IHookRegistry.onRetain]]\n * - [[IHookRegistry.onEnter]]\n *\n * @param transition the current [[Transition]]\n * @param state the [[StateObject]] that the hook is bound to\n * @param injector (for ng1 or ng2 only) the injector service\n *\n * @returns a [[HookResult]] which may alter the transition\n */\nexport interface TransitionStateHookFn {\n (transition: Transition, state: StateDeclaration) : HookResult;\n}\n\n/**\n * The signature for Transition onCreate Hooks.\n *\n * Transition onCreate Hooks are callbacks that allow customization or preprocessing of\n * a Transition before it is returned from [[TransitionService.create]]\n *\n * @param transition the [[Transition]] that was just created\n * @return a [[Transition]] which will then be returned from [[TransitionService.create]]\n */\nexport interface TransitionCreateHookFn {\n (transition: Transition): void;\n}\n\nexport type HookFn = (TransitionHookFn|TransitionStateHookFn|TransitionCreateHookFn);\n\n/**\n * The return value of a [[TransitionHookFn]] or [[TransitionStateHookFn]]\n *\n * When returned from a [[TransitionHookFn]] or [[TransitionStateHookFn]], these values alter the running [[Transition]]:\n *\n * - `false`: the transition will be cancelled.\n * - [[TargetState]]: the transition will be redirected to the new target state (see: [[StateService.target]])\n * - `Promise`: the transition will wait for the promise to resolve or reject\n * - If the promise is rejected (or resolves to `false`), the transition will be cancelled\n * - If the promise resolves to a [[TargetState]], the transition will be redirected\n * - If the promise resolves to anything else, the transition will resume\n * - Anything else: the transition will resume\n */\nexport type HookResult = (boolean | TargetState | void | Promise);\n\n/**\n * These options may be provided when registering a Transition Hook (such as `onStart`)\n */\nexport interface HookRegOptions {\n /**\n * Sets the priority of the registered hook\n *\n * Hooks of the same type (onBefore, onStart, etc) are invoked in priority order. A hook with a higher priority\n * is invoked before a hook with a lower priority.\n *\n * The default hook priority is 0\n */\n priority?: number;\n\n /**\n * Specifies what `this` is bound to during hook invocation.\n */\n bind?: any;\n\n /**\n * Limits the number of times that the hook will be invoked.\n * Once the hook has been invoked this many times, it is automatically deregistered.\n */\n invokeLimit?: number;\n}\n\n/**\n * This interface specifies the api for registering Transition Hooks. Both the\n * [[TransitionService]] and also the [[Transition]] object itself implement this interface.\n * Note: the Transition object only allows hooks to be registered before the Transition is started.\n */\nexport interface IHookRegistry {\n /**\n * Registers a [[TransitionHookFn]], called *before a transition starts*.\n *\n * Registers a transition lifecycle hook, which is invoked before a transition even begins.\n * This hook can be useful to implement logic which prevents a transition from even starting, such\n * as authentication, redirection\n *\n * See [[TransitionHookFn]] for the signature of the function.\n *\n * The [[HookMatchCriteria]] is used to determine which Transitions the hook should be invoked for.\n * To match all Transitions, use an empty criteria object `{}`.\n *\n * ### Lifecycle\n *\n * `onBefore` hooks are invoked *before a Transition starts*.\n * No resolves have been fetched yet.\n * Each `onBefore` hook is invoked synchronously, in the same call stack as [[StateService.transitionTo]].\n * The registered `onBefore` hooks are invoked in priority order.\n *\n * Note: during the `onBefore` phase, additional hooks can be added to the specific [[Transition]] instance.\n * These \"on-the-fly\" hooks only affect the currently running transition..\n *\n * ### Return value\n *\n * The hook's return value can be used to pause, cancel, or redirect the current Transition.\n * See [[HookResult]] for more information.\n *\n * If any hook modifies the transition *synchronously* (by throwing, returning `false`, or returning\n * a [[TargetState]]), the remainder of the hooks are skipped.\n * If a hook returns a promise, the remainder of the `onBefore` hooks are still invoked synchronously.\n * All promises are resolved, and processed asynchronously before the `onStart` phase of the Transition.\n *\n * ### Examples\n *\n * #### Default Substate\n *\n * This example redirects any transition from 'home' to 'home.dashboard'. This is commonly referred to as a\n * \"default substate\".\n *\n * @example\n * ```js\n * // ng2\n * transitionService.onBefore({ to: 'home' }, (trans: Transition) =>\n * trans.router.stateService.target(\"home.dashboard\"));\n * ```\n *\n * #### Data Driven Default Substate\n *\n * This example provides data-driven default substate functionality. It matches on a transition to any state\n * which has `defaultSubstate: \"some.sub.state\"` defined. See: [[Transition.to]] which returns the \"to state\"\n * definition.\n *\n * @example\n * ```js\n * // ng1\n * // state declaration\n * {\n * name: 'home',\n * template: '',\n * defaultSubstate: 'home.dashboard'\n * }\n *\n * var criteria = {\n * to: function(state) {\n * return state.defaultSubstate != null;\n * }\n * }\n *\n * $transitions.onBefore(criteria, function(trans: Transition) {\n * var substate = trans.to().defaultSubstate;\n * return trans.router.stateService.target(substate);\n * });\n * ```\n *\n *\n * #### Require authentication\n *\n * This example cancels a transition to a state which requires authentication, if the user is not currently authenticated.\n *\n * This example assumes a state tree where all states which require authentication are children of a parent `'requireauth'` state.\n * This example assumes `MyAuthService` synchronously returns a boolean from `isAuthenticated()`.\n *\n * #### Example:\n * ```js\n * // ng1\n * $transitions.onBefore( { to: 'requireauth.**' }, function(trans) {\n * var myAuthService = trans.injector().get('MyAuthService');\n * // If isAuthenticated returns false, the transition is cancelled.\n * return myAuthService.isAuthenticated();\n * });\n * ```\n *\n * @param matchCriteria defines which Transitions the Hook should be invoked for.\n * @param callback the hook function which will be invoked.\n * @returns a function which deregisters the hook.\n */\n onBefore(matchCriteria: HookMatchCriteria, callback: TransitionHookFn, options?: HookRegOptions): Function;\n\n /**\n * Registers a [[TransitionHookFn]], called when a transition starts.\n *\n * Registers a transition lifecycle hook, which is invoked as a transition starts running.\n * This hook can be useful to perform some asynchronous action before completing a transition.\n *\n * See [[TransitionHookFn]] for the signature of the function.\n *\n * The [[HookMatchCriteria]] is used to determine which Transitions the hook should be invoked for.\n * To match all Transitions, use an empty criteria object `{}`.\n *\n * ### Lifecycle\n *\n * `onStart` hooks are invoked asynchronously when the Transition starts running.\n * This happens after the `onBefore` phase is complete.\n * At this point, the Transition has not yet exited nor entered any states.\n * The registered `onStart` hooks are invoked in priority order.\n *\n * Note: A built-in `onStart` hook with high priority is used to fetch any eager resolve data.\n *\n * ### Return value\n *\n * The hook's return value can be used to pause, cancel, or redirect the current Transition.\n * See [[HookResult]] for more information.\n *\n * ### Example\n *\n * #### Login during transition\n *\n * This example intercepts any transition to a state which requires authentication, when the user is\n * not currently authenticated. It allows the user to authenticate asynchronously, then resumes the\n * transition. If the user did not authenticate successfully, it redirects to the \"guest\" state, which\n * does not require authentication.\n *\n * This example assumes:\n * - a state tree where all states which require authentication are children of a parent `'auth'` state.\n * - `MyAuthService.isAuthenticated()` synchronously returns a boolean.\n * - `MyAuthService.authenticate()` presents a login dialog, and returns a promise which is resolved\n * or rejected, whether or not the login attempt was successful.\n *\n * #### Example:\n * ```js\n * // ng1\n * $transitions.onStart( { to: 'auth.**' }, function(trans) {\n * var $state = trans.router.stateService;\n * var MyAuthService = trans.injector().get('MyAuthService');\n *\n * // If the user is not authenticated\n * if (!MyAuthService.isAuthenticated()) {\n *\n * // Then return a promise for a successful login.\n * // The transition will wait for this promise to settle\n *\n * return MyAuthService.authenticate().catch(function() {\n *\n * // If the authenticate() method failed for whatever reason,\n * // redirect to a 'guest' state which doesn't require auth.\n * return $state.target(\"guest\");\n * });\n * }\n * });\n * ```\n *\n * @param matchCriteria defines which Transitions the Hook should be invoked for.\n * @param callback the hook function which will be injected and invoked.\n * @returns a function which deregisters the hook.\n */\n onStart(matchCriteria: HookMatchCriteria, callback: TransitionHookFn, options?: HookRegOptions): Function;\n\n /**\n * Registers a [[TransitionStateHookFn]], called when a specific state is entered.\n *\n * Registers a lifecycle hook, which is invoked (during a transition) when a specific state is being entered.\n *\n * Since this hook is run only when the specific state is being *entered*, it can be useful for\n * performing tasks when entering a submodule/feature area such as initializing a stateful service,\n * or for guarding access to a submodule/feature area.\n *\n * See [[TransitionStateHookFn]] for the signature of the function.\n *\n * The [[HookMatchCriteria]] is used to determine which Transitions the hook should be invoked for.\n * `onEnter` hooks generally specify `{ entering: 'somestate' }`.\n * To match all Transitions, use an empty criteria object `{}`.\n *\n * ### Lifecycle\n *\n * `onEnter` hooks are invoked when the Transition is entering a state.\n * States are entered after the `onRetain` phase is complete.\n * If more than one state is being entered, the parent state is entered first.\n * The registered `onEnter` hooks for a state are invoked in priority order.\n *\n * Note: A built-in `onEnter` hook with high priority is used to fetch lazy resolve data for states being entered.\n *\n * ### Return value\n *\n * The hook's return value can be used to pause, cancel, or redirect the current Transition.\n * See [[HookResult]] for more information.\n *\n * ### Inside a state declaration\n *\n * Instead of registering `onEnter` hooks using the [[TransitionService]], you may define an `onEnter` hook\n * directly on a state declaration (see: [[StateDeclaration.onEnter]]).\n *\n *\n * ### Examples\n *\n * #### Audit Log\n *\n * This example uses a service to log that a user has entered the admin section of an app.\n * This assumes that there are substates of the \"admin\" state, such as \"admin.users\", \"admin.pages\", etc.\n * @example\n * ```\n *\n * $transitions.onEnter({ entering: 'admin' }, function(transition, state) {\n * var AuditService = trans.injector().get('AuditService');\n * AuditService.log(\"Entered \" + state.name + \" module while transitioning to \" + transition.to().name);\n * }\n * ```\n *\n * #### Audit Log (inside a state declaration)\n *\n * The `onEnter` inside this state declaration is syntactic sugar for the previous Audit Log example.\n * ```\n * {\n * name: 'admin',\n * component: 'admin',\n * onEnter: function($transition$, $state$) {\n * var AuditService = $transition$.injector().get('AuditService');\n * AuditService.log(\"Entered \" + state.name + \" module while transitioning to \" + transition.to().name);\n * }\n * }\n * ```\n *\n * Note: A state declaration's `onEnter` function is injected for Angular 1 only.\n *\n * @param matchCriteria defines which Transitions the Hook should be invoked for.\n * @param callback the hook function which will be injected and invoked.\n * @returns a function which deregisters the hook.\n */\n onEnter(matchCriteria: HookMatchCriteria, callback: TransitionStateHookFn, options?: HookRegOptions): Function;\n\n /**\n * Registers a [[TransitionStateHookFn]], called when a specific state is retained/kept.\n *\n * Registers a lifecycle hook, which is invoked (during a transition) for\n * a specific state that was previously active will remain active (is not being entered nor exited).\n *\n * This hook is invoked when a state is \"retained\" or \"kept\".\n * It means the transition is coming *from* a substate of the retained state *to* a substate of the retained state.\n * This hook can be used to perform actions when the user moves from one substate to another, such as between steps in a wizard.\n *\n * The [[HookMatchCriteria]] is used to determine which Transitions the hook should be invoked for.\n * `onRetain` hooks generally specify `{ retained: 'somestate' }`.\n * To match all Transitions, use an empty criteria object `{}`.\n *\n * ### Lifecycle\n *\n * `onRetain` hooks are invoked after any `onExit` hooks have been fired.\n * If more than one state is retained, the child states' `onRetain` hooks are invoked first.\n * The registered `onRetain` hooks for a state are invoked in priority order.\n *\n * ### Return value\n *\n * The hook's return value can be used to pause, cancel, or redirect the current Transition.\n * See [[HookResult]] for more information.\n *\n * ### Inside a state declaration\n *\n * Instead of registering `onRetain` hooks using the [[TransitionService]], you may define an `onRetain` hook\n * directly on a state declaration (see: [[StateDeclaration.onRetain]]).\n *\n * Note: A state declaration's `onRetain` function is injected for Angular 1 only.\n *\n * @param matchCriteria defines which Transitions the Hook should be invoked for.\n * @param callback the hook function which will be injected and invoked.\n * @returns a function which deregisters the hook.\n */\n onRetain(matchCriteria: HookMatchCriteria, callback: TransitionStateHookFn, options?: HookRegOptions): Function;\n\n /**\n * Registers a [[TransitionStateHookFn]], called when a specific state is exited.\n *\n * Registers a lifecycle hook, which is invoked (during a transition) when a specific state is being exited.\n *\n * Since this hook is run only when the specific state is being *exited*, it can be useful for\n * performing tasks when leaving a submodule/feature area such as cleaning up a stateful service,\n * or for preventing the user from leaving a state or submodule until some criteria is satisfied.\n *\n * See [[TransitionStateHookFn]] for the signature of the function.\n *\n * The [[HookMatchCriteria]] is used to determine which Transitions the hook should be invoked for.\n * `onExit` hooks generally specify `{ exiting: 'somestate' }`.\n * To match all Transitions, use an empty criteria object `{}`.\n *\n * ### Lifecycle\n *\n * `onExit` hooks are invoked when the Transition is exiting a state.\n * States are exited after any `onStart` phase is complete.\n * If more than one state is being exited, the child states are exited first.\n * The registered `onExit` hooks for a state are invoked in priority order.\n *\n * ### Return value\n *\n * The hook's return value can be used to pause, cancel, or redirect the current Transition.\n * See [[HookResult]] for more information.\n *\n * ### Inside a state declaration\n *\n * Instead of registering `onExit` hooks using the [[TransitionService]], you may define an `onExit` hook\n * directly on a state declaration (see: [[StateDeclaration.onExit]]).\n *\n * Note: A state declaration's `onExit` function is injected for Angular 1 only.\n *\n * @param matchCriteria defines which Transitions the Hook should be invoked for.\n * @param callback the hook function which will be injected and invoked.\n * @returns a function which deregisters the hook.\n */\n onExit(matchCriteria: HookMatchCriteria, callback: TransitionStateHookFn, options?: HookRegOptions): Function;\n\n /**\n * Registers a [[TransitionHookFn]], called *just before a transition finishes*.\n *\n * Registers a transition lifecycle hook, which is invoked just before a transition finishes.\n * This hook is a last chance to cancel or redirect a transition.\n *\n * See [[TransitionHookFn]] for the signature of the function.\n *\n * The [[HookMatchCriteria]] is used to determine which Transitions the hook should be invoked for.\n * To match all Transitions, use an empty criteria object `{}`.\n *\n * ### Lifecycle\n *\n * `onFinish` hooks are invoked after the `onEnter` phase is complete.\n * These hooks are invoked just before the transition is \"committed\".\n * Each hook is invoked in priority order.\n *\n * ### Return value\n *\n * The hook's return value can be used to pause, cancel, or redirect the current Transition.\n * See [[HookResult]] for more information.\n *\n * @param matchCriteria defines which Transitions the Hook should be invoked for.\n * @param callback the hook function which will be injected and invoked.\n * @returns a function which deregisters the hook.\n */\n onFinish(matchCriteria: HookMatchCriteria, callback: TransitionHookFn, options?: HookRegOptions): Function;\n\n /**\n * Registers a [[TransitionHookFn]], called after a successful transition completed.\n *\n * Registers a transition lifecycle hook, which is invoked after a transition successfully completes.\n *\n * See [[TransitionHookFn]] for the signature of the function.\n *\n * The [[HookMatchCriteria]] is used to determine which Transitions the hook should be invoked for.\n * To match all Transitions, use an empty criteria object `{}`.\n *\n * ### Lifecycle\n *\n * `onSuccess` hooks are chained off the Transition's promise (see [[Transition.promise]]).\n * If the Transition is successful and its promise is resolved, then the `onSuccess` hooks are invoked.\n * Since these hooks are run after the transition is over, their return value is ignored.\n * The `onSuccess` hooks are invoked in priority order.\n *\n * ### Return value\n *\n * Since the Transition is already completed, the hook's return value is ignored\n *\n * @param matchCriteria defines which Transitions the Hook should be invoked for.\n * @param callback the hook function which will be injected and invoked.\n * @returns a function which deregisters the hook.\n */\n onSuccess(matchCriteria: HookMatchCriteria, callback: TransitionHookFn, options?: HookRegOptions): Function;\n\n /**\n * Registers a [[TransitionHookFn]], called after a transition has errored.\n *\n * Registers a transition lifecycle hook, which is invoked after a transition has been rejected for any reason.\n *\n * See [[TransitionHookFn]] for the signature of the function.\n *\n * The [[HookMatchCriteria]] is used to determine which Transitions the hook should be invoked for.\n * To match all Transitions, use an empty criteria object `{}`.\n *\n * ### Lifecycle\n *\n * The `onError` hooks are chained off the Transition's promise (see [[Transition.promise]]).\n * If a Transition fails, its promise is rejected and the `onError` hooks are invoked.\n * The `onError` hooks are invoked in priority order.\n *\n * Since these hooks are run after the transition is over, their return value is ignored.\n *\n * A transition \"errors\" if it was started, but failed to complete (for any reason).\n * A *non-exhaustive list* of reasons a transition can error:\n *\n * - A transition was cancelled because a new transition started while it was still running (`Transition superseded`)\n * - A transition was cancelled by a Transition Hook returning false\n * - A transition was redirected by a Transition Hook returning a [[TargetState]]\n * - A Transition Hook or resolve function threw an error\n * - A Transition Hook returned a rejected promise\n * - A resolve function returned a rejected promise\n *\n * To check the failure reason, inspect the return value of [[Transition.error]].\n *\n * Note: `onError` should be used for targeted error handling, or error recovery.\n * For simple catch-all error reporting, use [[StateService.defaultErrorHandler]].\n *\n * ### Return value\n *\n * Since the Transition is already completed, the hook's return value is ignored\n *\n * @param matchCriteria defines which Transitions the Hook should be invoked for.\n * @param callback the hook function which will be injected and invoked.\n * @returns a function which deregisters the hook.\n */\n onError(matchCriteria: HookMatchCriteria, callback: TransitionHookFn, options?: HookRegOptions): Function;\n\n /**\n * Returns all the registered hooks of a given `hookName` type\n *\n * #### Example:\n * ```\n * $transitions.getHooks(\"onEnter\")\n * ```\n */\n getHooks(hookName: string): RegisteredHook[];\n\n /** @hidden place to store the hooks */\n _registeredHooks: { [key: string]: RegisteredHook[] };\n}\n\n/** A predicate type which tests if a [[StateObject]] passes some test. Returns a boolean. */\nexport type IStateMatch = Predicate;\n\n/**\n * This object is used to configure whether or not a Transition Hook is invoked for a particular transition,\n * based on the Transition's \"to state\" and \"from state\".\n *\n * Each property (`to`, `from`, `exiting`, `retained`, and `entering`) can be a state [[Glob]] string,\n * a boolean, or a function that takes a state and returns a boolean (see [[HookMatchCriterion]])\n *\n * All properties are optional. If any property is omitted, it is replaced with the value `true`, and always matches.\n * To match any transition, use an empty criteria object `{}`.\n *\n * #### Example:\n * ```js\n * // This matches a transition coming from the `parent` state and going to the `parent.child` state.\n * var match = {\n * to: 'parent',\n * from: 'parent.child'\n * }\n * ```\n *\n * #### Example:\n * ```js\n * // This matches a transition coming from any substate of `parent` and going directly to the `parent` state.\n * var match = {\n * to: 'parent',\n * from: 'parent.**'\n * }\n * ```\n *\n * #### Example:\n * ```js\n * // This matches a transition coming from any state and going to any substate of `mymodule`\n * var match = {\n * to: 'mymodule.**'\n * }\n * ```\n *\n * #### Example:\n * ```js\n * // This matches a transition coming from any state and going to any state that has `data.authRequired`\n * // set to a truthy value.\n * var match = {\n * to: function(state) {\n * return state.data != null && state.data.authRequired === true;\n * }\n * }\n * ```\n *\n * #### Example:\n * ```js\n * // This matches a transition that is exiting `parent.child`\n * var match = {\n * exiting: 'parent.child'\n * }\n * ```\n */\nexport interface HookMatchCriteria {\n [key: string]: HookMatchCriterion | undefined;\n\n /** A [[HookMatchCriterion]] to match the destination state */\n to?: HookMatchCriterion;\n /** A [[HookMatchCriterion]] to match the original (from) state */\n from?: HookMatchCriterion;\n /** A [[HookMatchCriterion]] to match any state that would be exiting */\n exiting?: HookMatchCriterion;\n /** A [[HookMatchCriterion]] to match any state that would be retained */\n retained?: HookMatchCriterion;\n /** A [[HookMatchCriterion]] to match any state that would be entering */\n entering?: HookMatchCriterion;\n}\n\nexport interface IMatchingNodes {\n [key: string]: PathNode[];\n\n to: PathNode[];\n from: PathNode[];\n exiting: PathNode[];\n retained: PathNode[];\n entering: PathNode[];\n}\n\n/** @hidden */\nexport interface RegisteredHooks {\n [key: string]: RegisteredHook[];\n}\n\n/** @hidden */\nexport interface PathTypes {\n [key: string]: PathType;\n\n to: PathType;\n from: PathType;\n exiting: PathType;\n retained: PathType;\n entering: PathType;\n}\n\n/** @hidden */\nexport interface PathType {\n name: string;\n scope: TransitionHookScope;\n}\n\n/**\n * Hook Criterion used to match a transition.\n *\n * A [[Glob]] string that matches the name of a state.\n *\n * Or, a function with the signature `function(state) { return matches; }`\n * which should return a boolean to indicate if a state matches.\n *\n * Or, `true` to always match\n */\nexport type HookMatchCriterion = (string|IStateMatch|boolean)\n\nexport enum TransitionHookPhase { CREATE, BEFORE, RUN, SUCCESS, ERROR }\nexport enum TransitionHookScope { TRANSITION, STATE }\n","/**\n * @coreapi\n * @module state\n */ /** for typedoc */\n\nimport { StateDeclaration, StateOrName, TargetStateDef } from \"./interface\";\nimport { TransitionOptions } from \"../transition/interface\";\nimport { StateObject } from \"./stateObject\";\nimport { isString } from \"../common/predicates\";\nimport { stringify } from '../common/strings';\nimport { extend } from '../common';\nimport { StateRegistry } from './stateRegistry';\nimport { RawParams } from '../params';\n\n/**\n * Encapsulate the target (destination) state/params/options of a [[Transition]].\n *\n * This class is frequently used to redirect a transition to a new destination.\n *\n * See:\n *\n * - [[HookResult]]\n * - [[TransitionHookFn]]\n * - [[TransitionService.onStart]]\n *\n * To create a `TargetState`, use [[StateService.target]].\n *\n * ---\n *\n * This class wraps:\n *\n * 1) an identifier for a state\n * 2) a set of parameters\n * 3) and transition options\n * 4) the registered state object (the [[StateDeclaration]])\n *\n * Many UI-Router APIs such as [[StateService.go]] take a [[StateOrName]] argument which can\n * either be a *state object* (a [[StateDeclaration]] or [[StateObject]]) or a *state name* (a string).\n * The `TargetState` class normalizes those options.\n *\n * A `TargetState` may be valid (the state being targeted exists in the registry)\n * or invalid (the state being targeted is not registered).\n */\nexport class TargetState {\n private _definition: StateObject;\n private _params: RawParams;\n private _options: TransitionOptions;\n\n /**\n * The TargetState constructor\n *\n * Note: Do not construct a `TargetState` manually.\n * To create a `TargetState`, use the [[StateService.target]] factory method.\n *\n * @param _stateRegistry The StateRegistry to use to look up the _definition\n * @param _identifier An identifier for a state.\n * Either a fully-qualified state name, or the object used to define the state.\n * @param _params Parameters for the target state\n * @param _options Transition options.\n *\n * @internalapi\n */\n constructor(\n private _stateRegistry: StateRegistry,\n private _identifier: StateOrName,\n _params?: RawParams,\n _options?: TransitionOptions,\n ) {\n this._identifier = _identifier;\n this._params = extend({}, _params || {});\n this._options = extend({}, _options || {});\n this._definition = _stateRegistry.matcher.find(_identifier, this._options.relative);\n }\n\n /** The name of the state this object targets */\n name(): string {\n return this._definition && this._definition.name || this._identifier;\n }\n\n /** The identifier used when creating this TargetState */\n identifier(): StateOrName {\n return this._identifier;\n }\n\n /** The target parameter values */\n params(): RawParams {\n return this._params;\n }\n\n /** The internal state object (if it was found) */\n $state(): StateObject {\n return this._definition;\n }\n\n /** The internal state declaration (if it was found) */\n state(): StateDeclaration {\n return this._definition && this._definition.self;\n }\n\n /** The target options */\n options() {\n return this._options;\n }\n\n /** True if the target state was found */\n exists(): boolean {\n return !!(this._definition && this._definition.self);\n }\n\n /** True if the object is valid */\n valid(): boolean {\n return !this.error();\n }\n\n /** If the object is invalid, returns the reason why */\n error(): string {\n let base = this.options().relative;\n if (!this._definition && !!base) {\n let stateName = base.name ? base.name : base;\n return `Could not resolve '${this.name()}' from state '${stateName}'`;\n }\n if (!this._definition)\n return `No such state '${this.name()}'`;\n if (!this._definition.self)\n return `State '${this.name()}' has an invalid definition`;\n }\n\n toString() {\n return `'${this.name()}'${stringify(this.params())}`;\n }\n\n /** Returns true if the object has a state property that might be a state or state name */\n static isDef = (obj): obj is TargetStateDef =>\n obj && obj.state && (isString(obj.state) || isString(obj.state.name));\n\n /**\n * Returns a copy of this TargetState which targets a different state.\n * The new TargetState has the same parameter values and transition options.\n *\n * @param state The new state that should be targeted\n */\n withState(state: StateOrName): TargetState {\n return new TargetState(this._stateRegistry, state, this._params, this._options);\n }\n\n /**\n * Returns a copy of this TargetState, using the specified parameter values.\n *\n * @param params the new parameter values to use\n * @param replace When false (default) the new parameter values will be merged with the current values.\n * When true the parameter values will be used instead of the current values.\n */\n withParams(params: RawParams, replace = false): TargetState {\n const newParams: RawParams = replace ? params : extend({}, this._params, params);\n return new TargetState(this._stateRegistry, this._identifier, newParams, this._options);\n }\n\n /**\n * Returns a copy of this TargetState, using the specified Transition Options.\n *\n * @param options the new options to use\n * @param replace When false (default) the new options will be merged with the current options.\n * When true the options will be used instead of the current options.\n */\n withOptions(options: TransitionOptions, replace = false): TargetState {\n const newOpts = replace ? options : extend({}, this._options, options);\n return new TargetState(this._stateRegistry, this._identifier, this._params, newOpts);\n }\n}\n","/**\n * @coreapi\n * @module transition\n */\n/** for typedoc */\nimport { TransitionHookOptions, HookResult, TransitionHookPhase } from './interface';\nimport { defaults, noop, silentRejection } from '../common/common';\nimport { fnToString, maxLength } from '../common/strings';\nimport { isPromise } from '../common/predicates';\nimport { is, parse } from '../common/hof';\nimport { trace } from '../common/trace';\nimport { services } from '../common/coreservices';\nimport { Rejection } from './rejectFactory';\nimport { TargetState } from '../state/targetState';\nimport { Transition } from './transition';\nimport { TransitionEventType } from './transitionEventType';\nimport { RegisteredHook } from './hookRegistry';\nimport { StateDeclaration } from '../state/interface';\n\nlet defaultOptions: TransitionHookOptions = {\n current: noop,\n transition: null,\n traceData: {},\n bind: null,\n};\n\nexport type GetResultHandler = (hook: TransitionHook) => ResultHandler;\nexport type GetErrorHandler = (hook: TransitionHook) => ErrorHandler;\n\nexport type ResultHandler = (result: HookResult) => Promise;\nexport type ErrorHandler = (error: any) => Promise;\n\n/** @hidden */\nexport class TransitionHook {\n type: TransitionEventType;\n constructor(private transition: Transition,\n private stateContext: StateDeclaration,\n private registeredHook: RegisteredHook,\n private options: TransitionHookOptions) {\n this.options = defaults(options, defaultOptions);\n this.type = registeredHook.eventType;\n }\n\n /**\n * These GetResultHandler(s) are used by [[invokeHook]] below\n * Each HookType chooses a GetResultHandler (See: [[TransitionService._defineCoreEvents]])\n */\n static HANDLE_RESULT: GetResultHandler = (hook: TransitionHook) => (result: HookResult) =>\n hook.handleHookResult(result);\n\n /**\n * If the result is a promise rejection, log it.\n * Otherwise, ignore the result.\n */\n static LOG_REJECTED_RESULT: GetResultHandler = (hook: TransitionHook) => (result: HookResult) => {\n isPromise(result) && result.catch(err =>\n hook.logError(Rejection.normalize(err)));\n return undefined;\n }\n\n /**\n * These GetErrorHandler(s) are used by [[invokeHook]] below\n * Each HookType chooses a GetErrorHandler (See: [[TransitionService._defineCoreEvents]])\n */\n static LOG_ERROR: GetErrorHandler = (hook: TransitionHook) => (error: any) =>\n hook.logError(error);\n\n static REJECT_ERROR: GetErrorHandler = (hook: TransitionHook) => (error: any) =>\n silentRejection(error);\n\n static THROW_ERROR: GetErrorHandler = (hook: TransitionHook) => (error: any) => {\n throw error;\n }\n\n private isSuperseded = () =>\n this.type.hookPhase === TransitionHookPhase.RUN && !this.options.transition.isActive();\n\n logError(err): any {\n this.transition.router.stateService.defaultErrorHandler()(err);\n }\n\n invokeHook(): Promise | void {\n let hook = this.registeredHook;\n if (hook._deregistered) return;\n\n let notCurrent = this.getNotCurrentRejection();\n if (notCurrent) return notCurrent;\n\n let options = this.options;\n trace.traceHookInvocation(this, this.transition, options);\n\n const invokeCallback = () =>\n hook.callback.call(options.bind, this.transition, this.stateContext);\n\n const normalizeErr = err =>\n Rejection.normalize(err).toPromise();\n\n const handleError = err =>\n hook.eventType.getErrorHandler(this)(err);\n\n const handleResult = result =>\n hook.eventType.getResultHandler(this)(result);\n\n try {\n let result = invokeCallback();\n\n if (!this.type.synchronous && isPromise(result)) {\n return result.catch(normalizeErr)\n .then(handleResult, handleError);\n } else {\n return handleResult(result);\n }\n } catch (err) {\n // If callback throws (synchronously)\n return handleError(Rejection.normalize(err));\n } finally {\n if (hook.invokeLimit && ++hook.invokeCount >= hook.invokeLimit) {\n hook.deregister();\n }\n }\n }\n\n /**\n * This method handles the return value of a Transition Hook.\n *\n * A hook can return false (cancel), a TargetState (redirect),\n * or a promise (which may later resolve to false or a redirect)\n *\n * This also handles \"transition superseded\" -- when a new transition\n * was started while the hook was still running\n */\n handleHookResult(result: HookResult): Promise {\n let notCurrent = this.getNotCurrentRejection();\n if (notCurrent) return notCurrent;\n\n // Hook returned a promise\n if (isPromise(result)) {\n // Wait for the promise, then reprocess with the resulting value\n return result.then(val => this.handleHookResult(val));\n }\n\n trace.traceHookResult(result, this.transition, this.options);\n\n // Hook returned false\n if (result === false) {\n // Abort this Transition\n return Rejection.aborted(\"Hook aborted transition\").toPromise();\n }\n\n const isTargetState = is(TargetState);\n // hook returned a TargetState\n if (isTargetState(result)) {\n // Halt the current Transition and redirect (a new Transition) to the TargetState.\n return Rejection.redirected(result).toPromise();\n }\n }\n\n\n /**\n * Return a Rejection promise if the transition is no longer current due\n * to a stopped router (disposed), or a new transition has started and superseded this one.\n */\n private getNotCurrentRejection() {\n let router = this.transition.router;\n\n // The router is stopped\n if (router._disposed) {\n return Rejection.aborted(`UIRouter instance #${router.$id} has been stopped (disposed)`).toPromise();\n }\n\n if (this.transition._aborted) {\n return Rejection.aborted().toPromise();\n }\n\n // This transition is no longer current.\n // Another transition started while this hook was still running.\n if (this.isSuperseded()) {\n // Abort this transition\n return Rejection.superseded(this.options.current()).toPromise();\n }\n }\n\n toString() {\n let { options, registeredHook } = this;\n let event = parse(\"traceData.hookType\")(options) || \"internal\",\n context = parse(\"traceData.context.state.name\")(options) || parse(\"traceData.context\")(options) || \"unknown\",\n name = fnToString(registeredHook.callback);\n return `${event} context: ${context}, ${maxLength(200, name)}`;\n }\n\n /**\n * Chains together an array of TransitionHooks.\n *\n * Given a list of [[TransitionHook]] objects, chains them together.\n * Each hook is invoked after the previous one completes.\n *\n * #### Example:\n * ```js\n * var hooks: TransitionHook[] = getHooks();\n * let promise: Promise = TransitionHook.chain(hooks);\n *\n * promise.then(handleSuccess, handleError);\n * ```\n *\n * @param hooks the list of hooks to chain together\n * @param waitFor if provided, the chain is `.then()`'ed off this promise\n * @returns a `Promise` for sequentially invoking the hooks (in order)\n */\n static chain(hooks: TransitionHook[], waitFor?: Promise): Promise {\n // Chain the next hook off the previous\n const createHookChainR = (prev: Promise, nextHook: TransitionHook) =>\n prev.then(() => nextHook.invokeHook());\n return hooks.reduce(createHookChainR, waitFor || services.$q.when());\n }\n\n\n /**\n * Invokes all the provided TransitionHooks, in order.\n * Each hook's return value is checked.\n * If any hook returns a promise, then the rest of the hooks are chained off that promise, and the promise is returned.\n * If no hook returns a promise, then all hooks are processed synchronously.\n *\n * @param hooks the list of TransitionHooks to invoke\n * @param doneCallback a callback that is invoked after all the hooks have successfully completed\n *\n * @returns a promise for the async result, or the result of the callback\n */\n static invokeHooks(hooks: TransitionHook[], doneCallback: (result?: HookResult) => T): Promise | T {\n for (let idx = 0; idx < hooks.length; idx++) {\n let hookResult = hooks[idx].invokeHook();\n\n if (isPromise(hookResult)) {\n let remainingHooks = hooks.slice(idx + 1);\n\n return TransitionHook.chain(remainingHooks, hookResult)\n .then(doneCallback);\n }\n }\n\n return doneCallback();\n }\n\n /**\n * Run all TransitionHooks, ignoring their return value.\n */\n static runAllHooks(hooks: TransitionHook[]): void {\n hooks.forEach(hook => hook.invokeHook());\n }\n\n}\n","/**\n * @coreapi\n * @module transition\n */ /** for typedoc */\nimport { extend, removeFrom, tail, values, identity, map } from \"../common/common\";\nimport {isString, isFunction} from \"../common/predicates\";\nimport {PathNode} from \"../path/pathNode\";\nimport {\n TransitionStateHookFn, TransitionHookFn, TransitionHookPhase, TransitionHookScope, IHookRegistry, PathType,\n} from \"./interface\"; // has or is using\n\nimport {\n HookRegOptions, HookMatchCriteria, TreeChanges,\n HookMatchCriterion, IMatchingNodes, HookFn,\n} from \"./interface\";\nimport {Glob} from \"../common/glob\";\nimport {StateObject} from \"../state/stateObject\";\nimport {TransitionEventType} from \"./transitionEventType\";\nimport { TransitionService } from \"./transitionService\";\n\n/**\n * Determines if the given state matches the matchCriteria\n *\n * @hidden\n *\n * @param state a State Object to test against\n * @param criterion\n * - If a string, matchState uses the string as a glob-matcher against the state name\n * - If an array (of strings), matchState uses each string in the array as a glob-matchers against the state name\n * and returns a positive match if any of the globs match.\n * - If a function, matchState calls the function with the state and returns true if the function's result is truthy.\n * @returns {boolean}\n */\nexport function matchState(state: StateObject, criterion: HookMatchCriterion) {\n let toMatch = isString(criterion) ? [criterion] : criterion;\n\n function matchGlobs(_state: StateObject) {\n let globStrings = toMatch;\n for (let i = 0; i < globStrings.length; i++) {\n let glob = new Glob(globStrings[i]);\n\n if ((glob && glob.matches(_state.name)) || (!glob && globStrings[i] === _state.name)) {\n return true;\n }\n }\n return false;\n }\n\n let matchFn = (isFunction(toMatch) ? toMatch : matchGlobs);\n return !!matchFn(state);\n}\n\n/**\n * @internalapi\n * The registration data for a registered transition hook\n */\nexport class RegisteredHook {\n priority: number;\n bind: any;\n invokeCount = 0;\n invokeLimit: number;\n _deregistered = false;\n\n constructor(public tranSvc: TransitionService,\n public eventType: TransitionEventType,\n public callback: HookFn,\n public matchCriteria: HookMatchCriteria,\n public removeHookFromRegistry: (hook: RegisteredHook) => void,\n options: HookRegOptions = {} as any) {\n this.priority = options.priority || 0;\n this.bind = options.bind || null;\n this.invokeLimit = options.invokeLimit;\n }\n\n /**\n * Gets the matching [[PathNode]]s\n *\n * Given an array of [[PathNode]]s, and a [[HookMatchCriterion]], returns an array containing\n * the [[PathNode]]s that the criteria matches, or `null` if there were no matching nodes.\n *\n * Returning `null` is significant to distinguish between the default\n * \"match-all criterion value\" of `true` compared to a `() => true` function,\n * when the nodes is an empty array.\n *\n * This is useful to allow a transition match criteria of `entering: true`\n * to still match a transition, even when `entering === []`. Contrast that\n * with `entering: (state) => true` which only matches when a state is actually\n * being entered.\n */\n private _matchingNodes(nodes: PathNode[], criterion: HookMatchCriterion): PathNode[] {\n if (criterion === true) return nodes;\n let matching = nodes.filter(node => matchState(node.state, criterion));\n return matching.length ? matching : null;\n }\n\n /**\n * Gets the default match criteria (all `true`)\n *\n * Returns an object which has all the criteria match paths as keys and `true` as values, i.e.:\n *\n * ```js\n * {\n * to: true,\n * from: true,\n * entering: true,\n * exiting: true,\n * retained: true,\n * }\n */\n private _getDefaultMatchCriteria(): HookMatchCriteria {\n return map(this.tranSvc._pluginapi._getPathTypes(), () => true);\n }\n\n /**\n * Gets matching nodes as [[IMatchingNodes]]\n *\n * Create a IMatchingNodes object from the TransitionHookTypes that is roughly equivalent to:\n *\n * ```js\n * let matches: IMatchingNodes = {\n * to: _matchingNodes([tail(treeChanges.to)], mc.to),\n * from: _matchingNodes([tail(treeChanges.from)], mc.from),\n * exiting: _matchingNodes(treeChanges.exiting, mc.exiting),\n * retained: _matchingNodes(treeChanges.retained, mc.retained),\n * entering: _matchingNodes(treeChanges.entering, mc.entering),\n * };\n * ```\n */\n private _getMatchingNodes(treeChanges: TreeChanges): IMatchingNodes {\n let criteria = extend(this._getDefaultMatchCriteria(), this.matchCriteria);\n let paths: PathType[] = values(this.tranSvc._pluginapi._getPathTypes());\n\n return paths.reduce((mn: IMatchingNodes, pathtype: PathType) => {\n // STATE scope criteria matches against every node in the path.\n // TRANSITION scope criteria matches against only the last node in the path\n let isStateHook = pathtype.scope === TransitionHookScope.STATE;\n let path = treeChanges[pathtype.name] || [];\n let nodes: PathNode[] = isStateHook ? path : [tail(path)];\n\n mn[pathtype.name] = this._matchingNodes(nodes, criteria[pathtype.name]);\n return mn;\n }, {} as IMatchingNodes);\n }\n\n /**\n * Determines if this hook's [[matchCriteria]] match the given [[TreeChanges]]\n *\n * @returns an IMatchingNodes object, or null. If an IMatchingNodes object is returned, its values\n * are the matching [[PathNode]]s for each [[HookMatchCriterion]] (to, from, exiting, retained, entering)\n */\n matches(treeChanges: TreeChanges): IMatchingNodes {\n let matches = this._getMatchingNodes(treeChanges);\n\n // Check if all the criteria matched the TreeChanges object\n let allMatched = values(matches).every(identity);\n return allMatched ? matches : null;\n }\n\n deregister() {\n this.removeHookFromRegistry(this);\n this._deregistered = true;\n }\n}\n\n/** @hidden Return a registration function of the requested type. */\nexport function makeEvent(registry: IHookRegistry, transitionService: TransitionService, eventType: TransitionEventType) {\n // Create the object which holds the registered transition hooks.\n const _registeredHooks = registry._registeredHooks = (registry._registeredHooks || {});\n const hooks = _registeredHooks[eventType.name] = [];\n const removeHookFn: (hook: RegisteredHook) => void = removeFrom(hooks);\n\n // Create hook registration function on the IHookRegistry for the event\n registry[eventType.name] = hookRegistrationFn;\n\n function hookRegistrationFn(matchObject, callback, options = {}) {\n const registeredHook = new RegisteredHook(transitionService, eventType, callback, matchObject, removeHookFn, options);\n hooks.push(registeredHook);\n return registeredHook.deregister.bind(registeredHook);\n }\n\n return hookRegistrationFn;\n}\n","/**\n * @coreapi\n * @module transition\n */ /** for typedoc */\n\nimport {extend, tail, assertPredicate, unnestR, identity} from \"../common/common\";\nimport {isArray} from \"../common/predicates\";\n\nimport {\n TransitionOptions, TransitionHookOptions, IHookRegistry, TreeChanges, IMatchingNodes,\n TransitionHookPhase, TransitionHookScope\n} from \"./interface\";\n\nimport {Transition} from \"./transition\";\nimport {TransitionHook} from \"./transitionHook\";\nimport {StateObject} from \"../state/stateObject\";\nimport {PathNode} from \"../path/pathNode\";\nimport {TransitionService} from \"./transitionService\";\nimport {TransitionEventType} from \"./transitionEventType\";\nimport {RegisteredHook} from \"./hookRegistry\";\n\n/**\n * This class returns applicable TransitionHooks for a specific Transition instance.\n *\n * Hooks ([[RegisteredHook]]) may be registered globally, e.g., $transitions.onEnter(...), or locally, e.g.\n * myTransition.onEnter(...). The HookBuilder finds matching RegisteredHooks (where the match criteria is\n * determined by the type of hook)\n *\n * The HookBuilder also converts RegisteredHooks objects to TransitionHook objects, which are used to run a Transition.\n *\n * The HookBuilder constructor is given the $transitions service and a Transition instance. Thus, a HookBuilder\n * instance may only be used for one specific Transition object. (side note: the _treeChanges accessor is private\n * in the Transition class, so we must also provide the Transition's _treeChanges)\n *\n */\nexport class HookBuilder {\n constructor(private transition: Transition) { }\n\n buildHooksForPhase(phase: TransitionHookPhase): TransitionHook[] {\n let $transitions = this.transition.router.transitionService;\n return $transitions._pluginapi._getEvents(phase)\n .map(type => this.buildHooks(type))\n .reduce(unnestR, [])\n .filter(identity);\n }\n\n /**\n * Returns an array of newly built TransitionHook objects.\n *\n * - Finds all RegisteredHooks registered for the given `hookType` which matched the transition's [[TreeChanges]].\n * - Finds [[PathNode]] (or `PathNode[]`) to use as the TransitionHook context(s)\n * - For each of the [[PathNode]]s, creates a TransitionHook\n *\n * @param hookType the type of the hook registration function, e.g., 'onEnter', 'onFinish'.\n */\n buildHooks(hookType: TransitionEventType): TransitionHook[] {\n let transition = this.transition;\n let treeChanges = transition.treeChanges();\n\n // Find all the matching registered hooks for a given hook type\n let matchingHooks = this.getMatchingHooks(hookType, treeChanges);\n if (!matchingHooks) return [];\n\n let baseHookOptions = {\n transition: transition,\n current: transition.options().current\n };\n\n const makeTransitionHooks = (hook: RegisteredHook) => {\n // Fetch the Nodes that caused this hook to match.\n let matches: IMatchingNodes = hook.matches(treeChanges);\n // Select the PathNode[] that will be used as TransitionHook context objects\n let matchingNodes: PathNode[] = matches[hookType.criteriaMatchPath.name];\n\n // Return an array of HookTuples\n return matchingNodes.map(node => {\n let _options = extend({\n bind: hook.bind,\n traceData: { hookType: hookType.name, context: node }\n }, baseHookOptions);\n\n let state = hookType.criteriaMatchPath.scope === TransitionHookScope.STATE ? node.state.self : null;\n let transitionHook = new TransitionHook(transition, state, hook, _options);\n return { hook, node, transitionHook };\n });\n };\n\n return matchingHooks.map(makeTransitionHooks)\n .reduce(unnestR, [])\n .sort(tupleSort(hookType.reverseSort))\n .map(tuple => tuple.transitionHook);\n }\n\n /**\n * Finds all RegisteredHooks from:\n * - The Transition object instance hook registry\n * - The TransitionService ($transitions) global hook registry\n *\n * which matched:\n * - the eventType\n * - the matchCriteria (to, from, exiting, retained, entering)\n *\n * @returns an array of matched [[RegisteredHook]]s\n */\n public getMatchingHooks(hookType: TransitionEventType, treeChanges: TreeChanges): RegisteredHook[] {\n let isCreate = hookType.hookPhase === TransitionHookPhase.CREATE;\n\n // Instance and Global hook registries\n let $transitions = this.transition.router.transitionService;\n let registries = isCreate ? [ $transitions ] : [ this.transition, $transitions ];\n\n return registries.map((reg: IHookRegistry) => reg.getHooks(hookType.name)) // Get named hooks from registries\n .filter(assertPredicate(isArray, `broken event named: ${hookType.name}`)) // Sanity check\n .reduce(unnestR, []) // Un-nest RegisteredHook[][] to RegisteredHook[] array\n .filter(hook => hook.matches(treeChanges)); // Only those satisfying matchCriteria\n }\n}\n\ninterface HookTuple { hook: RegisteredHook, node: PathNode, transitionHook: TransitionHook }\n\n/**\n * A factory for a sort function for HookTuples.\n *\n * The sort function first compares the PathNode depth (how deep in the state tree a node is), then compares\n * the EventHook priority.\n *\n * @param reverseDepthSort a boolean, when true, reverses the sort order for the node depth\n * @returns a tuple sort function\n */\nfunction tupleSort(reverseDepthSort = false) {\n return function nodeDepthThenPriority(l: HookTuple, r: HookTuple): number {\n let factor = reverseDepthSort ? -1 : 1;\n let depthDelta = (l.node.state.path.length - r.node.state.path.length) * factor;\n return depthDelta !== 0 ? depthDelta : r.hook.priority - l.hook.priority;\n }\n}","/**\n * @coreapi\n * @module params\n */\n/** */\nimport {extend, filter, map} from \"../common/common\";\nimport {isArray, isDefined} from \"../common/predicates\";\nimport {ParamTypeDefinition} from \"./interface\";\n\n/**\n * An internal class which implements [[ParamTypeDefinition]].\n *\n * A [[ParamTypeDefinition]] is a plain javascript object used to register custom parameter types.\n * When a param type definition is registered, an instance of this class is created internally.\n *\n * This class has naive implementations for all the [[ParamTypeDefinition]] methods.\n *\n * Used by [[UrlMatcher]] when matching or formatting URLs, or comparing and validating parameter values.\n *\n * #### Example:\n * ```js\n * var paramTypeDef = {\n * decode: function(val) { return parseInt(val, 10); },\n * encode: function(val) { return val && val.toString(); },\n * equals: function(a, b) { return this.is(a) && a === b; },\n * is: function(val) { return angular.isNumber(val) && isFinite(val) && val % 1 === 0; },\n * pattern: /\\d+/\n * }\n *\n * var paramType = new ParamType(paramTypeDef);\n * ```\n * @internalapi\n */\nexport class ParamType implements ParamTypeDefinition {\n /** @inheritdoc */\n pattern: RegExp = /.*/;\n /** The name/id of the parameter type */\n name: string;\n /** @inheritdoc */\n raw: boolean;\n /** @inheritdoc */\n dynamic: boolean;\n /** @inheritdoc */\n inherit = true;\n\n /**\n * @param def A configuration object which contains the custom type definition. The object's\n * properties will override the default methods and/or pattern in `ParamType`'s public interface.\n * @returns a new ParamType object\n */\n constructor(def: ParamTypeDefinition) {\n extend(this, def);\n }\n\n\n // consider these four methods to be \"abstract methods\" that should be overridden\n /** @inheritdoc */\n is(val: any, key?: string): boolean { return true; }\n /** @inheritdoc */\n encode(val: any, key?: string): (string|string[]) { return val; }\n /** @inheritdoc */\n decode(val: string, key?: string): any { return val; }\n /** @inheritdoc */\n equals(a: any, b: any): boolean { return a == b; }\n\n\n $subPattern() {\n let sub = this.pattern.toString();\n return sub.substr(1, sub.length - 2);\n }\n\n toString() {\n return `{ParamType:${this.name}}`;\n }\n\n /** Given an encoded string, or a decoded object, returns a decoded object */\n $normalize(val: any) {\n return this.is(val) ? val : this.decode(val);\n }\n\n /**\n * Wraps an existing custom ParamType as an array of ParamType, depending on 'mode'.\n * e.g.:\n * - urlmatcher pattern \"/path?{queryParam[]:int}\"\n * - url: \"/path?queryParam=1&queryParam=2\n * - $stateParams.queryParam will be [1, 2]\n * if `mode` is \"auto\", then\n * - url: \"/path?queryParam=1 will create $stateParams.queryParam: 1\n * - url: \"/path?queryParam=1&queryParam=2 will create $stateParams.queryParam: [1, 2]\n */\n $asArray(mode: (boolean|\"auto\"), isSearch: boolean) {\n if (!mode) return this;\n if (mode === \"auto\" && !isSearch) throw new Error(\"'auto' array mode is for query parameters only\");\n return new ( ArrayType)(this, mode);\n }\n}\n\n/**\n * Wraps up a `ParamType` object to handle array values.\n * @internalapi\n */\nfunction ArrayType(type: ParamType, mode: (boolean|\"auto\")) {\n // Wrap non-array value as array\n function arrayWrap(val: any): any[] {\n return isArray(val) ? val : (isDefined(val) ? [ val ] : []);\n }\n\n // Unwrap array value for \"auto\" mode. Return undefined for empty array.\n function arrayUnwrap(val: any) {\n switch (val.length) {\n case 0: return undefined;\n case 1: return mode === \"auto\" ? val[0] : val;\n default: return val;\n }\n }\n\n // Wraps type (.is/.encode/.decode) functions to operate on each value of an array\n function arrayHandler(callback: (x: any) => any, allTruthyMode?: boolean) {\n return function handleArray(val: any) {\n if (isArray(val) && val.length === 0) return val;\n let arr = arrayWrap(val);\n let result = map(arr, callback);\n return (allTruthyMode === true) ? filter(result, x => !x).length === 0 : arrayUnwrap(result);\n };\n }\n\n // Wraps type (.equals) functions to operate on each value of an array\n function arrayEqualsHandler(callback: (l: any, r: any) => boolean) {\n return function handleArray(val1: any, val2: any) {\n let left = arrayWrap(val1), right = arrayWrap(val2);\n if (left.length !== right.length) return false;\n for (let i = 0; i < left.length; i++) {\n if (!callback(left[i], right[i])) return false;\n }\n return true;\n };\n }\n\n ['encode', 'decode', 'equals', '$normalize'].forEach(name => {\n var paramTypeFn = type[name].bind(type);\n var wrapperFn: Function = name === 'equals' ? arrayEqualsHandler : arrayHandler;\n this[name] = wrapperFn(paramTypeFn);\n });\n\n extend(this, {\n dynamic: type.dynamic,\n name: type.name,\n pattern: type.pattern,\n inherit: type.inherit,\n is: arrayHandler(type.is.bind(type), true),\n $arrayMode: mode\n });\n}\n","/**\n * @coreapi\n * @module params\n */ /** for typedoc */\nimport { extend, filter, map, allTrueR } from \"../common/common\";\nimport { prop } from \"../common/hof\";\nimport { isInjectable, isDefined, isString, isArray, isUndefined } from \"../common/predicates\";\nimport { RawParams, ParamDeclaration } from \"../params/interface\";\nimport { services } from \"../common/coreservices\";\nimport { ParamType } from \"./paramType\";\nimport { ParamTypes } from \"./paramTypes\";\nimport { UrlMatcherFactory } from \"../url/urlMatcherFactory\";\n\n/** @hidden */ let hasOwn = Object.prototype.hasOwnProperty;\n/** @hidden */ let isShorthand = (cfg: ParamDeclaration) =>\n [\"value\", \"type\", \"squash\", \"array\", \"dynamic\"].filter(hasOwn.bind(cfg || {})).length === 0;\n\n/** @internalapi */\nexport enum DefType {\n PATH,\n SEARCH,\n CONFIG,\n}\n\n/** @hidden */\nfunction unwrapShorthand(cfg: ParamDeclaration): ParamDeclaration {\n cfg = isShorthand(cfg) && { value: cfg } as any || cfg;\n\n getStaticDefaultValue['__cacheable'] = true;\n function getStaticDefaultValue() {\n return cfg.value;\n }\n\n return extend(cfg, {\n $$fn: isInjectable(cfg.value) ? cfg.value : getStaticDefaultValue,\n });\n}\n\n/** @hidden */\nfunction getType(cfg: ParamDeclaration, urlType: ParamType, location: DefType, id: string, paramTypes: ParamTypes) {\n if (cfg.type && urlType && urlType.name !== 'string') throw new Error(`Param '${id}' has two type configurations.`);\n if (cfg.type && urlType && urlType.name === 'string' && paramTypes.type(cfg.type as string)) return paramTypes.type(cfg.type as string);\n if (urlType) return urlType;\n if (!cfg.type) {\n let type = location === DefType.CONFIG ? \"any\" :\n location === DefType.PATH ? \"path\" :\n location === DefType.SEARCH ? \"query\" : \"string\";\n return paramTypes.type(type);\n }\n return cfg.type instanceof ParamType ? cfg.type : paramTypes.type(cfg.type as string);\n}\n\n/**\n * @internalapi\n * returns false, true, or the squash value to indicate the \"default parameter url squash policy\".\n */\nfunction getSquashPolicy(config: ParamDeclaration, isOptional: boolean, defaultPolicy: (boolean|string)) {\n let squash = config.squash;\n if (!isOptional || squash === false) return false;\n if (!isDefined(squash) || squash == null) return defaultPolicy;\n if (squash === true || isString(squash)) return squash;\n throw new Error(`Invalid squash policy: '${squash}'. Valid policies: false, true, or arbitrary string`);\n}\n\n/** @internalapi */\nfunction getReplace(config: ParamDeclaration, arrayMode: boolean, isOptional: boolean, squash: (string|boolean)) {\n let replace: any, configuredKeys: string[], defaultPolicy = [\n {from: \"\", to: (isOptional || arrayMode ? undefined : \"\")},\n {from: null, to: (isOptional || arrayMode ? undefined : \"\")},\n ];\n replace = isArray(config.replace) ? config.replace : [];\n if (isString(squash)) replace.push({ from: squash, to: undefined });\n configuredKeys = map(replace, prop(\"from\"));\n return filter(defaultPolicy, item => configuredKeys.indexOf(item.from) === -1).concat(replace);\n}\n\n\n/** @internalapi */\nexport class Param {\n id: string;\n type: ParamType;\n location: DefType;\n isOptional: boolean;\n dynamic: boolean;\n raw: boolean;\n squash: (boolean|string);\n replace: [{ to: any, from: any }];\n inherit: boolean;\n array: boolean;\n config: any;\n /** Cache the default value if it is a static value */\n _defaultValueCache: {\n defaultValue: any,\n };\n\n constructor(id: string, type: ParamType, config: ParamDeclaration, location: DefType, urlMatcherFactory: UrlMatcherFactory) {\n config = unwrapShorthand(config);\n type = getType(config, type, location, id, urlMatcherFactory.paramTypes);\n let arrayMode = getArrayMode();\n type = arrayMode ? type.$asArray(arrayMode, location === DefType.SEARCH) : type;\n let isOptional = config.value !== undefined || location === DefType.SEARCH;\n let dynamic = isDefined(config.dynamic) ? !!config.dynamic : !!type.dynamic;\n let raw = isDefined(config.raw) ? !!config.raw : !!type.raw;\n let squash = getSquashPolicy(config, isOptional, urlMatcherFactory.defaultSquashPolicy());\n let replace = getReplace(config, arrayMode, isOptional, squash);\n let inherit = isDefined(config.inherit) ? !!config.inherit : !!type.inherit;\n\n // array config: param name (param[]) overrides default settings. explicit config overrides param name.\n function getArrayMode() {\n let arrayDefaults = { array: (location === DefType.SEARCH ? \"auto\" : false) };\n let arrayParamNomenclature = id.match(/\\[\\]$/) ? { array: true } : {};\n return extend(arrayDefaults, arrayParamNomenclature, config).array;\n }\n\n extend(this, {id, type, location, isOptional, dynamic, raw, squash, replace, inherit, array: arrayMode, config });\n }\n\n isDefaultValue(value: any): boolean {\n return this.isOptional && this.type.equals(this.value(), value);\n }\n\n /**\n * [Internal] Gets the decoded representation of a value if the value is defined, otherwise, returns the\n * default value, which may be the result of an injectable function.\n */\n value(value?: any): any {\n /**\n * [Internal] Get the default value of a parameter, which may be an injectable function.\n */\n const getDefaultValue = () => {\n if (this._defaultValueCache) return this._defaultValueCache.defaultValue;\n\n if (!services.$injector) throw new Error(\"Injectable functions cannot be called at configuration time\");\n\n let defaultValue = services.$injector.invoke(this.config.$$fn);\n\n if (defaultValue !== null && defaultValue !== undefined && !this.type.is(defaultValue))\n throw new Error(`Default value (${defaultValue}) for parameter '${this.id}' is not an instance of ParamType (${this.type.name})`);\n\n if (this.config.$$fn['__cacheable']) {\n this._defaultValueCache = { defaultValue };\n }\n\n return defaultValue;\n };\n\n const replaceSpecialValues = (val: any) => {\n for (let tuple of this.replace) {\n if (tuple.from === val) return tuple.to;\n }\n return val;\n };\n\n value = replaceSpecialValues(value);\n\n return isUndefined(value) ? getDefaultValue() : this.type.$normalize(value);\n }\n\n isSearch(): boolean {\n return this.location === DefType.SEARCH;\n }\n\n validates(value: any): boolean {\n // There was no parameter value, but the param is optional\n if ((isUndefined(value) || value === null) && this.isOptional) return true;\n\n // The value was not of the correct ParamType, and could not be decoded to the correct ParamType\n const normalized = this.type.$normalize(value);\n if (!this.type.is(normalized)) return false;\n\n // The value was of the correct type, but when encoded, did not match the ParamType's regexp\n const encoded = this.type.encode(normalized);\n return !(isString(encoded) && !this.type.pattern.exec( encoded));\n }\n\n toString() {\n return `{Param:${this.id} ${this.type} squash: '${this.squash}' optional: ${this.isOptional}}`;\n }\n\n static values(params: Param[], values: RawParams = {}): RawParams {\n const paramValues = {} as RawParams;\n for (let param of params) {\n paramValues[param.id] = param.value(values[param.id]);\n }\n return paramValues;\n }\n\n /**\n * Finds [[Param]] objects which have different param values\n *\n * Filters a list of [[Param]] objects to only those whose parameter values differ in two param value objects\n *\n * @param params: The list of Param objects to filter\n * @param values1: The first set of parameter values\n * @param values2: the second set of parameter values\n *\n * @returns any Param objects whose values were different between values1 and values2\n */\n static changed(params: Param[], values1: RawParams = {}, values2: RawParams = {}): Param[] {\n return params.filter(param => !param.type.equals(values1[param.id], values2[param.id]));\n }\n\n /**\n * Checks if two param value objects are equal (for a set of [[Param]] objects)\n *\n * @param params The list of [[Param]] objects to check\n * @param values1 The first set of param values\n * @param values2 The second set of param values\n *\n * @returns true if the param values in values1 and values2 are equal\n */\n static equals(params: Param[], values1 = {}, values2 = {}): boolean {\n return Param.changed(params, values1, values2).length === 0;\n }\n\n /** Returns true if a the parameter values are valid, according to the Param definitions */\n static validates(params: Param[], values: RawParams = {}): boolean {\n return params.map(param => param.validates(values[param.id])).reduce(allTrueR, true);\n }\n}","/** @module path */ /** for typedoc */\nimport {extend, applyPairs, find, allTrueR, pairs, arrayTuples} from \"../common/common\";\nimport {propEq} from \"../common/hof\";\nimport {StateObject} from \"../state/stateObject\";\nimport {RawParams} from \"../params/interface\";\nimport {Param} from \"../params/param\";\nimport {Resolvable} from \"../resolve/resolvable\";\nimport {ViewConfig} from \"../view/interface\";\n\n/**\n * @internalapi\n *\n * A node in a [[TreeChanges]] path\n *\n * For a [[TreeChanges]] path, this class holds the stateful information for a single node in the path.\n * Each PathNode corresponds to a state being entered, exited, or retained.\n * The stateful information includes parameter values and resolve data.\n */\nexport class PathNode {\n /** The state being entered, exited, or retained */\n public state: StateObject;\n /** The parameters declared on the state */\n public paramSchema: Param[];\n /** The parameter values that belong to the state */\n public paramValues: { [key: string]: any };\n /** The individual (stateful) resolvable objects that belong to the state */\n public resolvables: Resolvable[];\n /** The state's declared view configuration objects */\n public views: ViewConfig[];\n\n /** Creates a copy of a PathNode */\n constructor(node: PathNode);\n /** Creates a new (empty) PathNode for a State */\n constructor(state: StateObject);\n constructor(stateOrNode: any) {\n if (stateOrNode instanceof PathNode) {\n let node: PathNode = stateOrNode;\n this.state = node.state;\n this.paramSchema = node.paramSchema.slice();\n this.paramValues = extend({}, node.paramValues);\n this.resolvables = node.resolvables.slice();\n this.views = node.views && node.views.slice();\n } else {\n let state: StateObject = stateOrNode;\n this.state = state;\n this.paramSchema = state.parameters({ inherit: false });\n this.paramValues = {};\n this.resolvables = state.resolvables.map(res => res.clone());\n }\n }\n\n /** Sets [[paramValues]] for the node, from the values of an object hash */\n applyRawParams(params: RawParams): PathNode {\n const getParamVal = (paramDef: Param) => [ paramDef.id, paramDef.value(params[paramDef.id]) ];\n this.paramValues = this.paramSchema.reduce((memo, pDef) => applyPairs(memo, getParamVal(pDef)), {});\n return this;\n }\n\n /** Gets a specific [[Param]] metadata that belongs to the node */\n parameter(name: string): Param {\n return find(this.paramSchema, propEq(\"id\", name));\n }\n\n /**\n * @returns true if the state and parameter values for another PathNode are\n * equal to the state and param values for this PathNode\n */\n equals(node: PathNode, paramsFn?: GetParamsFn): boolean {\n const diff = this.diff(node, paramsFn);\n return diff && diff.length === 0;\n }\n\n /**\n * Finds Params with different parameter values on another PathNode.\n *\n * Given another node (of the same state), finds the parameter values which differ.\n * Returns the [[Param]] (schema objects) whose parameter values differ.\n *\n * Given another node for a different state, returns `false`\n *\n * @param node The node to compare to\n * @param paramsFn A function that returns which parameters should be compared.\n * @returns The [[Param]]s which differ, or null if the two nodes are for different states\n */\n diff(node: PathNode, paramsFn?: GetParamsFn): Param[] | false {\n if (this.state !== node.state) return false;\n\n const params: Param[] = paramsFn ? paramsFn(this) : this.paramSchema;\n return Param.changed(params, this.paramValues, node.paramValues);\n }\n\n /** Returns a clone of the PathNode */\n static clone(node: PathNode) {\n return new PathNode(node);\n }\n}\n\n/** @hidden */\nexport type GetParamsFn = (pathNode: PathNode) => Param[];","/** @module path */ /** for typedoc */\n\nimport {\n extend, find, pick, omit, tail, mergeR, values, unnestR, Predicate, inArray, arrayTuples,\n} from \"../common/common\";\nimport {prop, propEq, not} from \"../common/hof\";\n\nimport {RawParams} from \"../params/interface\";\nimport {TreeChanges} from \"../transition/interface\";\nimport {ViewConfig} from \"../view/interface\";\nimport {_ViewDeclaration} from \"../state/interface\";\n\nimport {StateObject} from \"../state/stateObject\";\nimport {TargetState} from \"../state/targetState\";\nimport {GetParamsFn, PathNode} from \"./pathNode\";\nimport {ViewService} from \"../view/view\";\nimport { Param } from '../params/param';\nimport { StateRegistry } from '../state';\n\n/**\n * This class contains functions which convert TargetStates, Nodes and paths from one type to another.\n */\nexport class PathUtils {\n\n constructor() { }\n\n /** Given a PathNode[], create an TargetState */\n static makeTargetState(registry: StateRegistry, path: PathNode[]): TargetState {\n let state = tail(path).state;\n return new TargetState(registry, state, path.map(prop(\"paramValues\")).reduce(mergeR, {}), {});\n }\n\n static buildPath(targetState: TargetState) {\n let toParams = targetState.params();\n return targetState.$state().path.map(state => new PathNode(state).applyRawParams(toParams));\n }\n\n /** Given a fromPath: PathNode[] and a TargetState, builds a toPath: PathNode[] */\n static buildToPath(fromPath: PathNode[], targetState: TargetState): PathNode[] {\n let toPath: PathNode[] = PathUtils.buildPath(targetState);\n if (targetState.options().inherit) {\n return PathUtils.inheritParams(fromPath, toPath, Object.keys(targetState.params()));\n }\n return toPath;\n }\n\n /**\n * Creates ViewConfig objects and adds to nodes.\n *\n * On each [[PathNode]], creates ViewConfig objects from the views: property of the node's state\n */\n static applyViewConfigs($view: ViewService, path: PathNode[], states: StateObject[]) {\n // Only apply the viewConfigs to the nodes for the given states\n path.filter(node => inArray(states, node.state)).forEach(node => {\n let viewDecls: _ViewDeclaration[] = values(node.state.views || {});\n let subPath = PathUtils.subPath(path, n => n === node);\n let viewConfigs: ViewConfig[][] = viewDecls.map(view => $view.createViewConfig(subPath, view));\n node.views = viewConfigs.reduce(unnestR, []);\n });\n }\n\n /**\n * Given a fromPath and a toPath, returns a new to path which inherits parameters from the fromPath\n *\n * For a parameter in a node to be inherited from the from path:\n * - The toPath's node must have a matching node in the fromPath (by state).\n * - The parameter name must not be found in the toKeys parameter array.\n *\n * Note: the keys provided in toKeys are intended to be those param keys explicitly specified by some\n * caller, for instance, $state.transitionTo(..., toParams). If a key was found in toParams,\n * it is not inherited from the fromPath.\n */\n static inheritParams(fromPath: PathNode[], toPath: PathNode[], toKeys: string[] = []): PathNode[] {\n function nodeParamVals(path: PathNode[], state: StateObject): RawParams {\n let node: PathNode = find(path, propEq('state', state));\n return extend({}, node && node.paramValues);\n }\n\n let noInherit = fromPath.map(node => node.paramSchema)\n .reduce(unnestR, [])\n .filter(param => !param.inherit)\n .map(prop('id'));\n\n /**\n * Given an [[PathNode]] \"toNode\", return a new [[PathNode]] with param values inherited from the\n * matching node in fromPath. Only inherit keys that aren't found in \"toKeys\" from the node in \"fromPath\"\"\n */\n function makeInheritedParamsNode(toNode: PathNode): PathNode {\n // All param values for the node (may include default key/vals, when key was not found in toParams)\n let toParamVals = extend({}, toNode && toNode.paramValues);\n // limited to only those keys found in toParams\n let incomingParamVals = pick(toParamVals, toKeys);\n toParamVals = omit(toParamVals, toKeys);\n let fromParamVals = omit(nodeParamVals(fromPath, toNode.state) || {}, noInherit);\n // extend toParamVals with any fromParamVals, then override any of those those with incomingParamVals\n let ownParamVals: RawParams = extend(toParamVals, fromParamVals, incomingParamVals);\n return new PathNode(toNode.state).applyRawParams(ownParamVals);\n }\n\n // The param keys specified by the incoming toParams\n return toPath.map(makeInheritedParamsNode);\n }\n\n static nonDynamicParams = (node: PathNode): Param[] =>\n node.state.parameters({ inherit: false })\n .filter(param => !param.dynamic);\n\n /**\n * Computes the tree changes (entering, exiting) between a fromPath and toPath.\n */\n static treeChanges(fromPath: PathNode[], toPath: PathNode[], reloadState: StateObject): TreeChanges {\n let keep = 0, max = Math.min(fromPath.length, toPath.length);\n\n const nodesMatch = (node1: PathNode, node2: PathNode) =>\n node1.equals(node2, PathUtils.nonDynamicParams);\n\n while (keep < max && fromPath[keep].state !== reloadState && nodesMatch(fromPath[keep], toPath[keep])) {\n keep++;\n }\n\n /** Given a retained node, return a new node which uses the to node's param values */\n function applyToParams(retainedNode: PathNode, idx: number): PathNode {\n let cloned = PathNode.clone(retainedNode);\n cloned.paramValues = toPath[idx].paramValues;\n return cloned;\n }\n\n let from: PathNode[], retained: PathNode[], exiting: PathNode[], entering: PathNode[], to: PathNode[];\n\n from = fromPath;\n retained = from.slice(0, keep);\n exiting = from.slice(keep);\n\n // Create a new retained path (with shallow copies of nodes) which have the params of the toPath mapped\n let retainedWithToParams = retained.map(applyToParams);\n entering = toPath.slice(keep);\n to = (retainedWithToParams).concat(entering);\n\n return { from, to, retained, exiting, entering };\n }\n\n /**\n * Returns a new path which is: the subpath of the first path which matches the second path.\n *\n * The new path starts from root and contains any nodes that match the nodes in the second path.\n * It stops before the first non-matching node.\n *\n * Nodes are compared using their state property and their parameter values.\n * If a `paramsFn` is provided, only the [[Param]] returned by the function will be considered when comparing nodes.\n *\n * @param pathA the first path\n * @param pathB the second path\n * @param paramsFn a function which returns the parameters to consider when comparing\n *\n * @returns an array of PathNodes from the first path which match the nodes in the second path\n */\n static matching(pathA: PathNode[], pathB: PathNode[], paramsFn?: GetParamsFn): PathNode[] {\n let done = false;\n let tuples: PathNode[][] = arrayTuples(pathA, pathB);\n return tuples.reduce((matching, [nodeA, nodeB]) => {\n done = done || !nodeA.equals(nodeB, paramsFn);\n return done ? matching : matching.concat(nodeA);\n }, []);\n }\n\n /**\n * Returns true if two paths are identical.\n *\n * @param pathA\n * @param pathB\n * @param paramsFn a function which returns the parameters to consider when comparing\n * @returns true if the the states and parameter values for both paths are identical\n */\n static equals(pathA: PathNode[], pathB: PathNode[], paramsFn?: GetParamsFn): boolean {\n return pathA.length === pathB.length &&\n PathUtils.matching(pathA, pathB, paramsFn).length === pathA.length;\n }\n\n /**\n * Return a subpath of a path, which stops at the first matching node\n *\n * Given an array of nodes, returns a subset of the array starting from the first node,\n * stopping when the first node matches the predicate.\n *\n * @param path a path of [[PathNode]]s\n * @param predicate a [[Predicate]] fn that matches [[PathNode]]s\n * @returns a subpath up to the matching node, or undefined if no match is found\n */\n static subPath(path: PathNode[], predicate: Predicate): PathNode[] {\n let node = find(path, predicate);\n let elementIdx = path.indexOf(node);\n return elementIdx === -1 ? undefined : path.slice(0, elementIdx + 1);\n }\n\n /** Gets the raw parameter values from a path */\n static paramValues = (path: PathNode[]) =>\n path.reduce((acc, node) => extend(acc, node.paramValues), {});\n}\n","/**\n * @coreapi\n * @module resolve\n */ /** for typedoc */\nimport {extend, equals, inArray, identity} from \"../common/common\";\nimport {services} from \"../common/coreservices\";\nimport {trace} from \"../common/trace\";\nimport {ResolvePolicy, ResolvableLiteral, resolvePolicies} from \"./interface\";\n\nimport {ResolveContext} from \"./resolveContext\";\nimport {stringify} from \"../common/strings\";\nimport {isFunction, isObject} from \"../common/predicates\";\nimport {Transition} from \"../transition/transition\";\nimport {StateObject} from \"../state/stateObject\";\nimport {PathNode} from \"../path/pathNode\";\nimport { isNullOrUndefined } from '../common';\n\n\n// TODO: explicitly make this user configurable\nexport let defaultResolvePolicy: ResolvePolicy = {\n when: \"LAZY\",\n async: \"WAIT\"\n};\n\n/**\n * The basic building block for the resolve system.\n *\n * Resolvables encapsulate a state's resolve's resolveFn, the resolveFn's declared dependencies, the wrapped (.promise),\n * and the unwrapped-when-complete (.data) result of the resolveFn.\n *\n * Resolvable.get() either retrieves the Resolvable's existing promise, or else invokes resolve() (which invokes the\n * resolveFn) and returns the resulting promise.\n *\n * Resolvable.get() and Resolvable.resolve() both execute within a context path, which is passed as the first\n * parameter to those fns.\n */\nexport class Resolvable implements ResolvableLiteral {\n token: any;\n policy: ResolvePolicy;\n resolveFn: Function;\n deps: any[];\n\n data: any;\n resolved: boolean = false;\n promise: Promise = undefined;\n\n /** This constructor creates a Resolvable copy */\n constructor(resolvable: Resolvable)\n\n /** This constructor creates a new Resolvable from the plain old [[ResolvableLiteral]] javascript object */\n constructor(resolvable: ResolvableLiteral)\n\n /**\n * This constructor creates a new `Resolvable`\n *\n * #### Example:\n * ```js\n * var resolvable1 = new Resolvable('mytoken', http => http.get('foo.json').toPromise(), [Http]);\n *\n * var resolvable2 = new Resolvable(UserService, dep => new UserService(dep.data), [SomeDependency]);\n *\n * var resolvable1Clone = new Resolvable(resolvable1);\n * ```\n *\n * @param token The new resolvable's injection token, such as `\"userList\"` (a string) or `UserService` (a class).\n * When this token is used during injection, the resolved value will be injected.\n * @param resolveFn The function that returns the resolved value, or a promise for the resolved value\n * @param deps An array of dependencies, which will be injected into the `resolveFn`\n * @param policy the [[ResolvePolicy]] defines when and how the Resolvable is processed\n * @param data Pre-resolved data. If the resolve value is already known, it may be provided here.\n */\n constructor(token: any, resolveFn: Function, deps?: any[], policy?: ResolvePolicy, data?: any)\n constructor(arg1: any, resolveFn?: Function, deps?: any[], policy?: ResolvePolicy, data?: any) {\n if (arg1 instanceof Resolvable) {\n extend(this, arg1);\n } else if (isFunction(resolveFn)) {\n if (isNullOrUndefined(arg1)) throw new Error(\"new Resolvable(): token argument is required\");\n if (!isFunction(resolveFn)) throw new Error(\"new Resolvable(): resolveFn argument must be a function\");\n\n this.token = arg1;\n this.policy = policy;\n this.resolveFn = resolveFn;\n this.deps = deps || [];\n\n this.data = data;\n this.resolved = data !== undefined;\n this.promise = this.resolved ? services.$q.when(this.data) : undefined;\n } else if (isObject(arg1) && arg1.token && isFunction(arg1.resolveFn)) {\n let literal = arg1;\n return new Resolvable(literal.token, literal.resolveFn, literal.deps, literal.policy, literal.data);\n }\n }\n\n getPolicy(state: StateObject): ResolvePolicy {\n let thisPolicy = this.policy || {};\n let statePolicy = state && state.resolvePolicy || {};\n return {\n when: thisPolicy.when || statePolicy.when || defaultResolvePolicy.when,\n async: thisPolicy.async || statePolicy.async || defaultResolvePolicy.async,\n };\n }\n\n /**\n * Asynchronously resolve this Resolvable's data\n *\n * Given a ResolveContext that this Resolvable is found in:\n * Wait for this Resolvable's dependencies, then invoke this Resolvable's function\n * and update the Resolvable's state\n */\n resolve(resolveContext: ResolveContext, trans?: Transition) {\n let $q = services.$q;\n\n // Gets all dependencies from ResolveContext and wait for them to be resolved\n const getResolvableDependencies = () =>\n $q.all(resolveContext.getDependencies(this).map(resolvable =>\n resolvable.get(resolveContext, trans))) as Promise;\n\n // Invokes the resolve function passing the resolved dependencies as arguments\n const invokeResolveFn = (resolvedDeps: any[]) =>\n this.resolveFn.apply(null, resolvedDeps);\n\n /**\n * For RXWAIT policy:\n *\n * Given an observable returned from a resolve function:\n * - enables .cache() mode (this allows multicast subscribers)\n * - then calls toPromise() (this triggers subscribe() and thus fetches)\n * - Waits for the promise, then return the cached observable (not the first emitted value).\n */\n const waitForRx = (observable$: any) => {\n let cached = observable$.cache(1);\n return cached.take(1).toPromise().then(() => cached);\n };\n\n // If the resolve policy is RXWAIT, wait for the observable to emit something. otherwise pass through.\n let node: PathNode = resolveContext.findNode(this);\n let state: StateObject = node && node.state;\n let maybeWaitForRx = this.getPolicy(state).async === \"RXWAIT\" ? waitForRx : identity;\n\n // After the final value has been resolved, update the state of the Resolvable\n const applyResolvedValue = (resolvedValue: any) => {\n this.data = resolvedValue;\n this.resolved = true;\n trace.traceResolvableResolved(this, trans);\n return this.data;\n };\n\n // Sets the promise property first, then getsResolvableDependencies in the context of the promise chain. Always waits one tick.\n return this.promise = $q.when()\n .then(getResolvableDependencies)\n .then(invokeResolveFn)\n .then(maybeWaitForRx)\n .then(applyResolvedValue);\n }\n\n /**\n * Gets a promise for this Resolvable's data.\n *\n * Fetches the data and returns a promise.\n * Returns the existing promise if it has already been fetched once.\n */\n get(resolveContext: ResolveContext, trans?: Transition): Promise {\n return this.promise || this.resolve(resolveContext, trans);\n }\n\n toString() {\n return `Resolvable(token: ${stringify(this.token)}, requires: [${this.deps.map(stringify)}])`;\n }\n\n clone(): Resolvable {\n return new Resolvable(this);\n }\n \n static fromData = (token: any, data: any) => \n new Resolvable(token, () => data, null, null, data);\n}\n","/**\n * # The Resolve subsystem\n *\n * This subsystem is an asynchronous, hierarchical Dependency Injection system.\n *\n * Typically, resolve is configured on a state using a [[StateDeclaration.resolve]] declaration.\n *\n * @coreapi\n * @module resolve\n */ /** for typedoc */\nimport {Resolvable} from \"./resolvable\";\n\n/**\n * An interface which is similar to an Angular 2 `Provider`\n */\nexport interface ProviderLike {\n provide: any,\n useClass?: any,\n useFactory?: Function,\n useValue?: any,\n useExisting?: any,\n deps?: any[]\n}\n\n/**\n * A plain object used to describe a [[Resolvable]]\n *\n * These objects may be used in the [[StateDeclaration.resolve]] array to declare\n * async data that the state or substates require.\n *\n * #### Example:\n * ```js\n *\n * var state = {\n * name: 'main',\n * resolve: [\n * { token: 'myData', deps: [MyDataApi], resolveFn: (myDataApi) => myDataApi.getData() },\n * ],\n * }\n * ```\n */\nexport interface ResolvableLiteral {\n /**\n * A Dependency Injection token\n *\n * This Resolvable's DI token.\n * The Resolvable will be injectable elsewhere using the token.\n */\n token: any;\n\n /**\n * A function which fetches the Resolvable's data\n *\n * A function which returns one of:\n *\n * - The resolved value (synchronously)\n * - A promise for the resolved value\n * - An Observable of the resolved value(s)\n *\n * This function will be provided the dependencies listed in [[deps]] as its arguments.\n * The resolve system will asynchronously fetch the dependencies before invoking this function.\n */\n resolveFn: Function;\n\n /**\n * Defines the Resolve Policy\n *\n * A policy that defines when to invoke the resolve,\n * and whether to wait for async and unwrap the data\n */\n policy?: ResolvePolicy;\n\n /**\n * The Dependency Injection tokens\n *\n * This is an array of Dependency Injection tokens for the dependencies of the [[resolveFn]].\n *\n * The DI tokens are references to other `Resolvables`, or to other\n * services from the native DI system.\n */\n deps?: any[];\n\n /** Pre-resolved data. */\n data?: any\n}\n\n/**\n * Defines how a resolve is processed during a transition\n *\n * This object is the [[StateDeclaration.resolvePolicy]] property.\n *\n * #### Example:\n * ```js\n * // Fetched when the resolve's state is being entered.\n * // Wait for the promise to resolve.\n * var policy1 = { when: \"LAZY\", async: \"WAIT\" }\n *\n * // Fetched when the Transition is starting.\n * // Do not wait for the returned promise to resolve.\n * // Inject the raw promise/value\n * var policy2 = { when: \"EAGER\", async: \"NOWAIT\" }\n * ```\n *\n * The policy for a given Resolvable is merged from three sources (highest priority first):\n *\n * - 1) Individual resolve definition\n * - 2) State definition\n * - 3) Global default\n *\n * #### Example:\n * ```js\n * // Wait for an Observable to emit one item.\n * // Since `wait` is not specified, it uses the `wait`\n * // policy defined on the state, or the global default\n * // if no `wait` policy is defined on the state\n * var myResolvablePolicy = { async: \"RXWAIT\" }\n * ```\n */\nexport interface ResolvePolicy {\n /**\n * Defines when a Resolvable is resolved (fetched) during a transition\n *\n * - `LAZY` (default)\n * - Resolved as the resolve's state is being entered\n * - `EAGER`\n * - Resolved as the transition is starting\n *\n * #### Example:\n * Resolves for `main` and `main.home` are fetched when each state is entered.\n * All of `main` resolves are processed before fetching `main.home` resolves.\n * ```js\n * var state = {\n * name: 'main',\n * resolve: mainResolves, // defined elsewhere\n * resolvePolicy: { when: 'LAZY' }, // default\n * }\n *\n * var state = {\n * name: 'main.home',\n * resolve: homeResolves, // defined elsewhere\n * resolvePolicy: { when: 'LAZY' }, // default\n * }\n * ```\n *\n * #### Example:\n * Resolves for `main` and `main.home` are fetched at the same time when the transition starts.\n * This happens earlier in the lifecycle than when states are entered.\n * All of the `main` and `main.home` resolves are fetched as soon as possible.\n * ```js\n * var mainState = {\n * name: 'main',\n * resolve: mainResolves, // defined elsewhere\n * resolvePolicy: { when: 'EAGER' },\n * }\n *\n * var homeState = {\n * name: 'main.home',\n * resolve: homeResolves, // defined elsewhere\n * resolvePolicy: { when: 'EAGER' },\n * }\n * ```\n */\n when?: PolicyWhen;\n\n /**\n * Determines the unwrapping behavior of asynchronous resolve values.\n *\n * - `WAIT` (default)\n * - If a promise is returned from the resolveFn, wait for the promise before proceeding\n * - The unwrapped value from the promise\n * - `NOWAIT`\n * - If a promise is returned from the resolve, do not wait for the promise.\n * - Any other value returned is wrapped in a promise.\n * - The promise will not be unwrapped.\n * - The promise itself will be provided when the resolve is injected or bound elsewhere.\n * - `RXWAIT`\n * - When an Observable is returned from the resolveFn, wait until the Observable emits at least one item.\n * - The Observable item will not be unwrapped.\n * - The Observable stream itself will be provided when the resolve is injected or bound elsewhere.\n *\n * #### Example:\n * The `Transition` will not wait for the resolve promise(s) from `main` to settle before continuing.\n * Resolves for `main` will be provided to components wrapped in a `Promise`.\n *\n * The `Transition` will wait for the `main.home` resolve promises.\n * Resolved values will be unwrapped before being provided to components.\n * ```js\n * var mainState = {\n * name: 'main',\n * resolve: mainResolves, // defined elsewhere\n * resolvePolicy: { async: 'NOWAIT' },\n * }\n * var homeState = {\n * name: 'main.home',\n * resolve: homeResolves, // defined elsewhere\n * resolvePolicy: { async: 'WAIT' }, // default\n * }\n * ```\n */\n async?: PolicyAsync;\n}\n\nexport type PolicyWhen = \"LAZY\" | \"EAGER\" ;\nexport type PolicyAsync = \"WAIT\" | \"NOWAIT\" | \"RXWAIT\" ;\n\n/** @internalapi */\nexport let resolvePolicies = {\n when: {\n LAZY: \"LAZY\",\n EAGER: \"EAGER\"\n },\n async: {\n WAIT: \"WAIT\",\n NOWAIT: \"NOWAIT\",\n RXWAIT: \"RXWAIT\"\n }\n};\n","/** @module resolve */\n/** for typedoc */\nimport { find, tail, uniqR, unnestR, inArray } from \"../common/common\";\nimport { propEq, not } from \"../common/hof\";\nimport { trace } from \"../common/trace\";\nimport { services, $InjectorLike } from \"../common/coreservices\";\nimport { resolvePolicies, PolicyWhen, ResolvePolicy } from \"./interface\";\nimport { PathNode } from \"../path/pathNode\";\nimport { Resolvable } from \"./resolvable\";\nimport { StateObject } from \"../state/stateObject\";\nimport { PathUtils } from \"../path/pathFactory\";\nimport { stringify } from \"../common/strings\";\nimport { Transition } from \"../transition/transition\";\nimport { UIInjector } from \"../interface\";\nimport { isUndefined } from '../common';\n\nconst whens = resolvePolicies.when;\nconst ALL_WHENS = [whens.EAGER, whens.LAZY];\nconst EAGER_WHENS = [whens.EAGER];\n\nexport const NATIVE_INJECTOR_TOKEN: string = \"Native Injector\";\n\n/**\n * Encapsulates Dependency Injection for a path of nodes\n *\n * UI-Router states are organized as a tree.\n * A nested state has a path of ancestors to the root of the tree.\n * When a state is being activated, each element in the path is wrapped as a [[PathNode]].\n * A `PathNode` is a stateful object that holds things like parameters and resolvables for the state being activated.\n *\n * The ResolveContext closes over the [[PathNode]]s, and provides DI for the last node in the path.\n */\nexport class ResolveContext {\n _injector: UIInjector;\n\n constructor(private _path: PathNode[]) { }\n\n /** Gets all the tokens found in the resolve context, de-duplicated */\n getTokens(): any[] {\n return this._path.reduce((acc, node) => acc.concat(node.resolvables.map(r => r.token)), []).reduce(uniqR, []);\n }\n\n /**\n * Gets the Resolvable that matches the token\n *\n * Gets the last Resolvable that matches the token in this context, or undefined.\n * Throws an error if it doesn't exist in the ResolveContext\n */\n getResolvable(token: any): Resolvable {\n let matching = this._path.map(node => node.resolvables)\n .reduce(unnestR, [])\n .filter((r: Resolvable) => r.token === token);\n return tail(matching);\n }\n\n /** Returns the [[ResolvePolicy]] for the given [[Resolvable]] */\n getPolicy(resolvable: Resolvable): ResolvePolicy {\n let node = this.findNode(resolvable);\n return resolvable.getPolicy(node.state);\n }\n\n /**\n * Returns a ResolveContext that includes a portion of this one\n *\n * Given a state, this method creates a new ResolveContext from this one.\n * The new context starts at the first node (root) and stops at the node for the `state` parameter.\n *\n * #### Why\n *\n * When a transition is created, the nodes in the \"To Path\" are injected from a ResolveContext.\n * A ResolveContext closes over a path of [[PathNode]]s and processes the resolvables.\n * The \"To State\" can inject values from its own resolvables, as well as those from all its ancestor state's (node's).\n * This method is used to create a narrower context when injecting ancestor nodes.\n *\n * @example\n * `let ABCD = new ResolveContext([A, B, C, D]);`\n *\n * Given a path `[A, B, C, D]`, where `A`, `B`, `C` and `D` are nodes for states `a`, `b`, `c`, `d`:\n * When injecting `D`, `D` should have access to all resolvables from `A`, `B`, `C`, `D`.\n * However, `B` should only be able to access resolvables from `A`, `B`.\n *\n * When resolving for the `B` node, first take the full \"To Path\" Context `[A,B,C,D]` and limit to the subpath `[A,B]`.\n * `let AB = ABCD.subcontext(a)`\n */\n subContext(state: StateObject): ResolveContext {\n return new ResolveContext(PathUtils.subPath(this._path, node => node.state === state));\n }\n\n /**\n * Adds Resolvables to the node that matches the state\n *\n * This adds a [[Resolvable]] (generally one created on the fly; not declared on a [[StateDeclaration.resolve]] block).\n * The resolvable is added to the node matching the `state` parameter.\n *\n * These new resolvables are not automatically fetched.\n * The calling code should either fetch them, fetch something that depends on them,\n * or rely on [[resolvePath]] being called when some state is being entered.\n *\n * Note: each resolvable's [[ResolvePolicy]] is merged with the state's policy, and the global default.\n *\n * @param newResolvables the new Resolvables\n * @param state Used to find the node to put the resolvable on\n */\n addResolvables(newResolvables: Resolvable[], state: StateObject) {\n let node = find(this._path, propEq('state', state));\n let keys = newResolvables.map(r => r.token);\n node.resolvables = node.resolvables.filter(r => keys.indexOf(r.token) === -1).concat(newResolvables);\n }\n\n /**\n * Returns a promise for an array of resolved path Element promises\n *\n * @param when\n * @param trans\n * @returns {Promise|any}\n */\n resolvePath(when: PolicyWhen = \"LAZY\", trans?: Transition): Promise<{ token: any, value: any }[]> {\n // This option determines which 'when' policy Resolvables we are about to fetch.\n let whenOption: string = inArray(ALL_WHENS, when) ? when : \"LAZY\";\n // If the caller specified EAGER, only the EAGER Resolvables are fetched.\n // if the caller specified LAZY, both EAGER and LAZY Resolvables are fetched.`\n let matchedWhens = whenOption === resolvePolicies.when.EAGER ? EAGER_WHENS : ALL_WHENS;\n\n // get the subpath to the state argument, if provided\n trace.traceResolvePath(this._path, when, trans);\n\n const matchesPolicy = (acceptedVals: string[], whenOrAsync: \"when\"|\"async\") =>\n (resolvable: Resolvable) =>\n inArray(acceptedVals, this.getPolicy(resolvable)[whenOrAsync]);\n\n // Trigger all the (matching) Resolvables in the path\n // Reduce all the \"WAIT\" Resolvables into an array\n let promises: Promise[] = this._path.reduce((acc, node) => {\n let nodeResolvables = node.resolvables.filter(matchesPolicy(matchedWhens, 'when'));\n let nowait = nodeResolvables.filter(matchesPolicy(['NOWAIT'], 'async'));\n let wait = nodeResolvables.filter(not(matchesPolicy(['NOWAIT'], 'async')));\n\n // For the matching Resolvables, start their async fetch process.\n let subContext = this.subContext(node.state);\n let getResult = (r: Resolvable) => r.get(subContext, trans)\n // Return a tuple that includes the Resolvable's token\n .then(value => ({ token: r.token, value: value }));\n nowait.forEach(getResult);\n return acc.concat(wait.map(getResult));\n }, []);\n\n // Wait for all the \"WAIT\" resolvables\n return services.$q.all(promises);\n }\n\n injector(): UIInjector {\n return this._injector || (this._injector = new UIInjectorImpl(this));\n }\n\n findNode(resolvable: Resolvable): PathNode {\n return find(this._path, (node: PathNode) => inArray(node.resolvables, resolvable));\n }\n\n /**\n * Gets the async dependencies of a Resolvable\n *\n * Given a Resolvable, returns its dependencies as a Resolvable[]\n */\n getDependencies(resolvable: Resolvable): Resolvable[] {\n let node = this.findNode(resolvable);\n // Find which other resolvables are \"visible\" to the `resolvable` argument\n // subpath stopping at resolvable's node, or the whole path (if the resolvable isn't in the path)\n let subPath: PathNode[] = PathUtils.subPath(this._path, x => x === node) || this._path;\n let availableResolvables: Resolvable[] = subPath\n .reduce((acc, _node) => acc.concat(_node.resolvables), []) //all of subpath's resolvables\n .filter(res => res !== resolvable); // filter out the `resolvable` argument\n\n const getDependency = (token: any) => {\n let matching = availableResolvables.filter(r => r.token === token);\n if (matching.length) return tail(matching);\n\n let fromInjector = this.injector().getNative(token);\n if (isUndefined(fromInjector)) {\n throw new Error(\"Could not find Dependency Injection token: \" + stringify(token));\n }\n\n return new Resolvable(token, () => fromInjector, [], fromInjector);\n };\n\n return resolvable.deps.map(getDependency);\n }\n}\n\nclass UIInjectorImpl implements UIInjector {\n native: $InjectorLike;\n\n constructor(public context: ResolveContext) {\n this.native = this.get(NATIVE_INJECTOR_TOKEN) || services.$injector;\n }\n\n get(token: any) {\n let resolvable = this.context.getResolvable(token);\n if (resolvable) {\n if (this.context.getPolicy(resolvable).async === 'NOWAIT') {\n return resolvable.get(this.context);\n }\n\n if (!resolvable.resolved) {\n throw new Error(\"Resolvable async .get() not complete:\" + stringify(resolvable.token))\n }\n return resolvable.data;\n }\n\n return this.getNative(token);\n }\n\n getAsync(token: any) {\n let resolvable = this.context.getResolvable(token);\n if (resolvable) return resolvable.get(this.context);\n return services.$q.when(this.native.get(token));\n }\n\n getNative(token: any) {\n return this.native && this.native.get(token);\n }\n}\n","/**\n * @coreapi\n * @module transition\n */\n/** for typedoc */\nimport { trace } from '../common/trace';\nimport { services } from '../common/coreservices';\nimport { stringify } from '../common/strings';\nimport { map, find, extend, mergeR, tail, omit, arrayTuples, unnestR, identity, anyTrueR } from '../common/common';\nimport {isObject, isUndefined} from '../common/predicates';\nimport { prop, propEq, val, not, is } from '../common/hof';\nimport { StateDeclaration, StateOrName } from '../state/interface';\nimport {\n TransitionOptions, TreeChanges, IHookRegistry, TransitionHookPhase, RegisteredHooks, HookRegOptions,\n HookMatchCriteria, TransitionStateHookFn, TransitionHookFn,\n} from './interface'; // has or is using\nimport { TransitionHook } from './transitionHook';\nimport { matchState, makeEvent, RegisteredHook } from './hookRegistry';\nimport { HookBuilder } from './hookBuilder';\nimport { PathNode } from '../path/pathNode';\nimport { PathUtils } from '../path/pathFactory';\nimport { StateObject } from '../state/stateObject';\nimport { TargetState } from '../state/targetState';\nimport { Param } from '../params/param';\nimport { Resolvable } from '../resolve/resolvable';\nimport { ViewConfig } from '../view/interface';\nimport { ResolveContext } from '../resolve/resolveContext';\nimport { UIRouter } from '../router';\nimport { UIInjector } from '../interface';\nimport { RawParams } from '../params/interface';\nimport { ResolvableLiteral } from '../resolve/interface';\n\n/** @hidden */\nconst stateSelf: (_state: StateObject) => StateDeclaration = prop(\"self\");\n\n/**\n * Represents a transition between two states.\n *\n * When navigating to a state, we are transitioning **from** the current state **to** the new state.\n *\n * This object contains all contextual information about the to/from states, parameters, resolves.\n * It has information about all states being entered and exited as a result of the transition.\n */\nexport class Transition implements IHookRegistry {\n\n /** @hidden */\n static diToken = Transition;\n\n /**\n * A unique identifier for the transition.\n *\n * This is an auto incrementing integer, starting from `0`.\n */\n $id: number;\n\n /**\n * A reference to the [[UIRouter]] instance\n *\n * This reference can be used to access the router services, such as the [[StateService]]\n */\n router: UIRouter;\n\n /** @hidden */\n private _deferred = services.$q.defer();\n /**\n * This promise is resolved or rejected based on the outcome of the Transition.\n *\n * When the transition is successful, the promise is resolved\n * When the transition is unsuccessful, the promise is rejected with the [[Rejection]] or javascript error\n */\n promise: Promise = this._deferred.promise;\n /**\n * A boolean which indicates if the transition was successful\n *\n * After a successful transition, this value is set to true.\n * After an unsuccessful transition, this value is set to false.\n *\n * The value will be undefined if the transition is not complete\n */\n success: boolean;\n /** @hidden */\n _aborted: boolean;\n /** @hidden */\n private _error: any;\n\n /** @hidden Holds the hook registration functions such as those passed to Transition.onStart() */\n _registeredHooks: RegisteredHooks = { };\n\n /** @hidden */\n private _options: TransitionOptions;\n /** @hidden */\n private _treeChanges: TreeChanges;\n /** @hidden */\n private _targetState: TargetState;\n /** @hidden */\n private _hookBuilder = new HookBuilder(this);\n\n\n /** @hidden */\n onBefore(criteria: HookMatchCriteria, callback: TransitionHookFn, options?: HookRegOptions): Function { return; }\n /** @inheritdoc */\n onStart(criteria: HookMatchCriteria, callback: TransitionHookFn, options?: HookRegOptions): Function { return; }\n /** @inheritdoc */\n onExit(criteria: HookMatchCriteria, callback: TransitionStateHookFn, options?: HookRegOptions): Function { return; }\n /** @inheritdoc */\n onRetain(criteria: HookMatchCriteria, callback: TransitionStateHookFn, options?: HookRegOptions): Function { return; }\n /** @inheritdoc */\n onEnter(criteria: HookMatchCriteria, callback: TransitionStateHookFn, options?: HookRegOptions): Function { return; }\n /** @inheritdoc */\n onFinish(criteria: HookMatchCriteria, callback: TransitionHookFn, options?: HookRegOptions): Function { return; }\n /** @inheritdoc */\n onSuccess(criteria: HookMatchCriteria, callback: TransitionHookFn, options?: HookRegOptions): Function { return; }\n /** @inheritdoc */\n onError(criteria: HookMatchCriteria, callback: TransitionHookFn, options?: HookRegOptions): Function { return; }\n\n /** @hidden\n * Creates the transition-level hook registration functions\n * (which can then be used to register hooks)\n */\n private createTransitionHookRegFns() {\n this.router.transitionService._pluginapi._getEvents()\n .filter(type => type.hookPhase !== TransitionHookPhase.CREATE)\n .forEach(type => makeEvent(this, this.router.transitionService, type));\n }\n\n /** @internalapi */\n getHooks(hookName: string): RegisteredHook[] {\n return this._registeredHooks[hookName];\n }\n\n /**\n * Creates a new Transition object.\n *\n * If the target state is not valid, an error is thrown.\n *\n * @internalapi\n *\n * @param fromPath The path of [[PathNode]]s from which the transition is leaving. The last node in the `fromPath`\n * encapsulates the \"from state\".\n * @param targetState The target state and parameters being transitioned to (also, the transition options)\n * @param router The [[UIRouter]] instance\n */\n constructor(fromPath: PathNode[], targetState: TargetState, router: UIRouter) {\n this.router = router;\n this._targetState = targetState;\n\n if (!targetState.valid()) {\n throw new Error(targetState.error());\n }\n\n // current() is assumed to come from targetState.options, but provide a naive implementation otherwise.\n this._options = extend({ current: val(this) }, targetState.options());\n this.$id = router.transitionService._transitionCount++;\n let toPath = PathUtils.buildToPath(fromPath, targetState);\n this._treeChanges = PathUtils.treeChanges(fromPath, toPath, this._options.reloadState);\n this.createTransitionHookRegFns();\n\n let onCreateHooks = this._hookBuilder.buildHooksForPhase(TransitionHookPhase.CREATE);\n TransitionHook.invokeHooks(onCreateHooks, () => null);\n\n this.applyViewConfigs(router);\n }\n\n private applyViewConfigs(router: UIRouter) {\n let enteringStates = this._treeChanges.entering.map(node => node.state);\n PathUtils.applyViewConfigs(router.transitionService.$view, this._treeChanges.to, enteringStates);\n }\n\n /**\n * @internalapi\n *\n * @returns the internal from [State] object\n */\n $from() {\n return tail(this._treeChanges.from).state;\n }\n\n /**\n * @internalapi\n *\n * @returns the internal to [State] object\n */\n $to() {\n return tail(this._treeChanges.to).state;\n }\n\n /**\n * Returns the \"from state\"\n *\n * Returns the state that the transition is coming *from*.\n *\n * @returns The state declaration object for the Transition's (\"from state\").\n */\n from(): StateDeclaration {\n return this.$from().self;\n }\n\n /**\n * Returns the \"to state\"\n *\n * Returns the state that the transition is going *to*.\n *\n * @returns The state declaration object for the Transition's target state (\"to state\").\n */\n to(): StateDeclaration {\n return this.$to().self;\n }\n\n /**\n * Gets the Target State\n *\n * A transition's [[TargetState]] encapsulates the [[to]] state, the [[params]], and the [[options]] as a single object.\n *\n * @returns the [[TargetState]] of this Transition\n */\n targetState() {\n return this._targetState;\n }\n\n /**\n * Determines whether two transitions are equivalent.\n * @deprecated\n */\n is(compare: (Transition|{to?: any, from?: any})): boolean {\n if (compare instanceof Transition) {\n // TODO: Also compare parameters\n return this.is({ to: compare.$to().name, from: compare.$from().name });\n }\n return !(\n (compare.to && !matchState(this.$to(), compare.to)) ||\n (compare.from && !matchState(this.$from(), compare.from))\n );\n }\n\n /**\n * Gets transition parameter values\n *\n * Returns the parameter values for a transition as key/value pairs.\n * This object is immutable.\n *\n * By default, returns the new parameter values (for the \"to state\").\n * To return the previous parameter values, supply `'from'` as the `pathname` argument.\n *\n * @param pathname the name of the treeChanges path to get parameter values for:\n * (`'to'`, `'from'`, `'entering'`, `'exiting'`, `'retained'`)\n *\n * @returns transition parameter values for the desired path.\n */\n params(pathname?: string): any;\n params(pathname?: string): T;\n params(pathname: string = \"to\") {\n return Object.freeze(this._treeChanges[pathname].map(prop(\"paramValues\")).reduce(mergeR, {}));\n }\n\n\n /**\n * Creates a [[UIInjector]] Dependency Injector\n *\n * Returns a Dependency Injector for the Transition's target state (to state).\n * The injector provides resolve values which the target state has access to.\n *\n * The `UIInjector` can also provide values from the native root/global injector (ng1/ng2).\n *\n * #### Example:\n * ```js\n * .onEnter({ entering: 'myState' }, trans => {\n * var myResolveValue = trans.injector().get('myResolve');\n * // Inject a global service from the global/native injector (if it exists)\n * var MyService = trans.injector().get('MyService');\n * })\n * ```\n *\n * In some cases (such as `onBefore`), you may need access to some resolve data but it has not yet been fetched.\n * You can use [[UIInjector.getAsync]] to get a promise for the data.\n * #### Example:\n * ```js\n * .onBefore({}, trans => {\n * return trans.injector().getAsync('myResolve').then(myResolveValue =>\n * return myResolveValue !== 'ABORT';\n * });\n * });\n * ```\n *\n * If a `state` is provided, the injector that is returned will be limited to resolve values that the provided state has access to.\n * This can be useful if both a parent state `foo` and a child state `foo.bar` have both defined a resolve such as `data`.\n * #### Example:\n * ```js\n * .onEnter({ to: 'foo.bar' }, trans => {\n * // returns result of `foo` state's `data` resolve\n * // even though `foo.bar` also has a `data` resolve\n * var fooData = trans.injector('foo').get('data');\n * });\n * ```\n *\n * If you need resolve data from the exiting states, pass `'from'` as `pathName`.\n * The resolve data from the `from` path will be returned.\n * #### Example:\n * ```js\n * .onExit({ exiting: 'foo.bar' }, trans => {\n * // Gets the resolve value of `data` from the exiting state.\n * var fooData = trans.injector(null, 'foo.bar').get('data');\n * });\n * ```\n *\n *\n * @param state Limits the resolves provided to only the resolves the provided state has access to.\n * @param pathName Default: `'to'`: Chooses the path for which to create the injector. Use this to access resolves for `exiting` states.\n *\n * @returns a [[UIInjector]]\n */\n injector(state?: StateOrName, pathName = \"to\"): UIInjector {\n let path: PathNode[] = this._treeChanges[pathName];\n if (state) path = PathUtils.subPath(path, node => node.state === state || node.state.name === state);\n return new ResolveContext(path).injector();\n }\n\n /**\n * Gets all available resolve tokens (keys)\n *\n * This method can be used in conjunction with [[injector]] to inspect the resolve values\n * available to the Transition.\n *\n * This returns all the tokens defined on [[StateDeclaration.resolve]] blocks, for the states\n * in the Transition's [[TreeChanges.to]] path.\n *\n * #### Example:\n * This example logs all resolve values\n * ```js\n * let tokens = trans.getResolveTokens();\n * tokens.forEach(token => console.log(token + \" = \" + trans.injector().get(token)));\n * ```\n *\n * #### Example:\n * This example creates promises for each resolve value.\n * This triggers fetches of resolves (if any have not yet been fetched).\n * When all promises have all settled, it logs the resolve values.\n * ```js\n * let tokens = trans.getResolveTokens();\n * let promise = tokens.map(token => trans.injector().getAsync(token));\n * Promise.all(promises).then(values => console.log(\"Resolved values: \" + values));\n * ```\n *\n * Note: Angular 1 users whould use `$q.all()`\n *\n * @param pathname resolve context's path name (e.g., `to` or `from`)\n *\n * @returns an array of resolve tokens (keys)\n */\n getResolveTokens(pathname: string = \"to\"): any[] {\n return new ResolveContext(this._treeChanges[pathname]).getTokens();\n }\n\n /**\n * Dynamically adds a new [[Resolvable]] (i.e., [[StateDeclaration.resolve]]) to this transition.\n *\n * #### Example:\n * ```js\n * transitionService.onBefore({}, transition => {\n * transition.addResolvable({\n * token: 'myResolve',\n * deps: ['MyService'],\n * resolveFn: myService => myService.getData()\n * });\n * });\n * ```\n *\n * @param resolvable a [[ResolvableLiteral]] object (or a [[Resolvable]])\n * @param state the state in the \"to path\" which should receive the new resolve (otherwise, the root state)\n */\n addResolvable(resolvable: Resolvable|ResolvableLiteral, state: StateOrName = \"\"): void {\n resolvable = is(Resolvable)(resolvable) ? resolvable : new Resolvable(resolvable);\n\n let stateName: string = (typeof state === \"string\") ? state : state.name;\n let topath = this._treeChanges.to;\n let targetNode = find(topath, node => node.state.name === stateName);\n let resolveContext: ResolveContext = new ResolveContext(topath);\n resolveContext.addResolvables([resolvable as Resolvable], targetNode.state);\n }\n\n /**\n * Gets the transition from which this transition was redirected.\n *\n * If the current transition is a redirect, this method returns the transition that was redirected.\n *\n * #### Example:\n * ```js\n * let transitionA = $state.go('A').transition\n * transitionA.onStart({}, () => $state.target('B'));\n * $transitions.onSuccess({ to: 'B' }, (trans) => {\n * trans.to().name === 'B'; // true\n * trans.redirectedFrom() === transitionA; // true\n * });\n * ```\n *\n * @returns The previous Transition, or null if this Transition is not the result of a redirection\n */\n redirectedFrom(): Transition {\n return this._options.redirectedFrom || null;\n }\n\n /**\n * Gets the original transition in a redirect chain\n *\n * A transition might belong to a long chain of multiple redirects.\n * This method walks the [[redirectedFrom]] chain back to the original (first) transition in the chain.\n *\n * #### Example:\n * ```js\n * // states\n * registry.register({ name: 'A', redirectTo: 'B' });\n * registry.register({ name: 'B', redirectTo: 'C' });\n * registry.register({ name: 'C', redirectTo: 'D' });\n * registry.register({ name: 'D' });\n *\n * let transitionA = $state.go('A').transition\n *\n * $transitions.onSuccess({ to: 'D' }, (trans) => {\n * trans.to().name === 'D'; // true\n * trans.redirectedFrom().to().name === 'C'; // true\n * trans.originalTransition() === transitionA; // true\n * trans.originalTransition().to().name === 'A'; // true\n * });\n * ```\n *\n * @returns The original Transition that started a redirect chain\n */\n originalTransition(): Transition {\n let rf = this.redirectedFrom();\n return (rf && rf.originalTransition()) || this;\n }\n\n /**\n * Get the transition options\n *\n * @returns the options for this Transition.\n */\n options(): TransitionOptions {\n return this._options;\n }\n\n /**\n * Gets the states being entered.\n *\n * @returns an array of states that will be entered during this transition.\n */\n entering(): StateDeclaration[] {\n return map(this._treeChanges.entering, prop('state')).map(stateSelf);\n }\n\n /**\n * Gets the states being exited.\n *\n * @returns an array of states that will be exited during this transition.\n */\n exiting(): StateDeclaration[] {\n return map(this._treeChanges.exiting, prop('state')).map(stateSelf).reverse();\n }\n\n /**\n * Gets the states being retained.\n *\n * @returns an array of states that are already entered from a previous Transition, that will not be\n * exited during this Transition\n */\n retained(): StateDeclaration[] {\n return map(this._treeChanges.retained, prop('state')).map(stateSelf);\n }\n\n /**\n * Get the [[ViewConfig]]s associated with this Transition\n *\n * Each state can define one or more views (template/controller), which are encapsulated as `ViewConfig` objects.\n * This method fetches the `ViewConfigs` for a given path in the Transition (e.g., \"to\" or \"entering\").\n *\n * @param pathname the name of the path to fetch views for:\n * (`'to'`, `'from'`, `'entering'`, `'exiting'`, `'retained'`)\n * @param state If provided, only returns the `ViewConfig`s for a single state in the path\n *\n * @returns a list of ViewConfig objects for the given path.\n */\n views(pathname: string = \"entering\", state?: StateObject): ViewConfig[] {\n let path = this._treeChanges[pathname];\n path = !state ? path : path.filter(propEq('state', state));\n return path.map(prop(\"views\")).filter(identity).reduce(unnestR, []);\n }\n\n /**\n * Return the transition's tree changes\n *\n * A transition goes from one state/parameters to another state/parameters.\n * During a transition, states are entered and/or exited.\n *\n * This function returns various branches (paths) which represent the changes to the\n * active state tree that are caused by the transition.\n *\n * @param pathname The name of the tree changes path to get:\n * (`'to'`, `'from'`, `'entering'`, `'exiting'`, `'retained'`)\n */\n treeChanges(pathname: string): PathNode[];\n treeChanges(): TreeChanges;\n treeChanges(pathname?: string) {\n return pathname ? this._treeChanges[pathname] : this._treeChanges;\n }\n\n /**\n * Creates a new transition that is a redirection of the current one.\n *\n * This transition can be returned from a [[TransitionService]] hook to\n * redirect a transition to a new state and/or set of parameters.\n *\n * @internalapi\n *\n * @returns Returns a new [[Transition]] instance.\n */\n redirect(targetState: TargetState): Transition {\n let redirects = 1, trans: Transition = this;\n while ((trans = trans.redirectedFrom()) != null) {\n if (++redirects > 20) throw new Error(`Too many consecutive Transition redirects (20+)`);\n }\n\n let redirectOpts: TransitionOptions = { redirectedFrom: this, source: \"redirect\" };\n // If the original transition was caused by URL sync, then use { location: 'replace' }\n // on the new transition (unless the target state explicitly specifies location: false).\n // This causes the original url to be replaced with the url for the redirect target\n // so the original url disappears from the browser history.\n if (this.options().source === 'url' && targetState.options().location !== false) {\n redirectOpts.location = 'replace';\n }\n\n let newOptions = extend({}, this.options(), targetState.options(), redirectOpts);\n targetState = targetState.withOptions(newOptions, true);\n\n let newTransition = this.router.transitionService.create(this._treeChanges.from, targetState);\n let originalEnteringNodes = this._treeChanges.entering;\n let redirectEnteringNodes = newTransition._treeChanges.entering;\n\n // --- Re-use resolve data from original transition ---\n // When redirecting from a parent state to a child state where the parent parameter values haven't changed\n // (because of the redirect), the resolves fetched by the original transition are still valid in the\n // redirected transition.\n //\n // This allows you to define a redirect on a parent state which depends on an async resolve value.\n // You can wait for the resolve, then redirect to a child state based on the result.\n // The redirected transition does not have to re-fetch the resolve.\n // ---------------------------------------------------------\n\n const nodeIsReloading = (reloadState: StateObject) => (node: PathNode) => {\n return reloadState && node.state.includes[reloadState.name];\n };\n\n // Find any \"entering\" nodes in the redirect path that match the original path and aren't being reloaded\n let matchingEnteringNodes: PathNode[] = PathUtils.matching(redirectEnteringNodes, originalEnteringNodes, PathUtils.nonDynamicParams)\n .filter(not(nodeIsReloading(targetState.options().reloadState)));\n\n // Use the existing (possibly pre-resolved) resolvables for the matching entering nodes.\n matchingEnteringNodes.forEach((node, idx) => {\n node.resolvables = originalEnteringNodes[idx].resolvables;\n });\n\n return newTransition;\n }\n\n /** @hidden If a transition doesn't exit/enter any states, returns any [[Param]] whose value changed */\n private _changedParams(): Param[] {\n let tc = this._treeChanges;\n\n /** Return undefined if it's not a \"dynamic\" transition, for the following reasons */\n // If user explicitly wants a reload\n if (this._options.reload) return undefined;\n // If any states are exiting or entering\n if (tc.exiting.length || tc.entering.length) return undefined;\n // If to/from path lengths differ\n if (tc.to.length !== tc.from.length) return undefined;\n // If the to/from paths are different\n let pathsDiffer: boolean = arrayTuples(tc.to, tc.from)\n .map(tuple => tuple[0].state !== tuple[1].state)\n .reduce(anyTrueR, false);\n if (pathsDiffer) return undefined;\n\n // Find any parameter values that differ\n let nodeSchemas: Param[][] = tc.to.map((node: PathNode) => node.paramSchema);\n let [toValues, fromValues] = [tc.to, tc.from].map(path => path.map(x => x.paramValues));\n let tuples = arrayTuples(nodeSchemas, toValues, fromValues);\n\n return tuples.map(([schema, toVals, fromVals]) => Param.changed(schema, toVals, fromVals)).reduce(unnestR, []);\n }\n\n /**\n * Returns true if the transition is dynamic.\n *\n * A transition is dynamic if no states are entered nor exited, but at least one dynamic parameter has changed.\n *\n * @returns true if the Transition is dynamic\n */\n dynamic(): boolean {\n let changes = this._changedParams();\n return !changes ? false : changes.map(x => x.dynamic).reduce(anyTrueR, false);\n }\n\n /**\n * Returns true if the transition is ignored.\n *\n * A transition is ignored if no states are entered nor exited, and no parameter values have changed.\n *\n * @returns true if the Transition is ignored.\n */\n ignored(): boolean {\n return !!this._ignoredReason();\n }\n\n /** @hidden */\n _ignoredReason(): \"SameAsCurrent\"|\"SameAsPending\"|undefined {\n const pending = this.router.globals.transition;\n const reloadState = this._options.reloadState;\n\n const same = (pathA, pathB) => {\n if (pathA.length !== pathB.length) return false;\n const matching = PathUtils.matching(pathA, pathB);\n return pathA.length === matching.filter(node => !reloadState || !node.state.includes[reloadState.name]).length;\n };\n\n let newTC = this.treeChanges();\n let pendTC = pending && pending.treeChanges();\n\n if (pendTC && same(pendTC.to, newTC.to) && same(pendTC.exiting, newTC.exiting)) return \"SameAsPending\";\n if (newTC.exiting.length === 0 && newTC.entering.length === 0 && same(newTC.from, newTC.to)) return \"SameAsCurrent\";\n }\n\n /**\n * Runs the transition\n *\n * This method is generally called from the [[StateService.transitionTo]]\n *\n * @internalapi\n *\n * @returns a promise for a successful transition.\n */\n run(): Promise {\n let runAllHooks = TransitionHook.runAllHooks;\n\n // Gets transition hooks array for the given phase\n const getHooksFor = (phase: TransitionHookPhase) =>\n this._hookBuilder.buildHooksForPhase(phase);\n\n // When the chain is complete, then resolve or reject the deferred\n const transitionSuccess = () => {\n trace.traceSuccess(this.$to(), this);\n this.success = true;\n this._deferred.resolve(this.to());\n runAllHooks(getHooksFor(TransitionHookPhase.SUCCESS));\n };\n\n const transitionError = (reason: any) => {\n trace.traceError(reason, this);\n this.success = false;\n this._deferred.reject(reason);\n this._error = reason;\n runAllHooks(getHooksFor(TransitionHookPhase.ERROR));\n };\n\n const runTransition = () => {\n // Wait to build the RUN hook chain until the BEFORE hooks are done\n // This allows a BEFORE hook to dynamically add additional RUN hooks via the Transition object.\n let allRunHooks = getHooksFor(TransitionHookPhase.RUN);\n let done = () => services.$q.when(undefined);\n return TransitionHook.invokeHooks(allRunHooks, done);\n };\n\n const startTransition = () => {\n let globals = this.router.globals;\n\n globals.lastStartedTransitionId = this.$id;\n globals.transition = this;\n globals.transitionHistory.enqueue(this);\n\n trace.traceTransitionStart(this);\n\n return services.$q.when(undefined);\n };\n\n let allBeforeHooks = getHooksFor(TransitionHookPhase.BEFORE);\n TransitionHook.invokeHooks(allBeforeHooks, startTransition)\n .then(runTransition)\n .then(transitionSuccess, transitionError);\n\n return this.promise;\n }\n\n /** Checks if this transition is currently active/running. */\n isActive = () =>\n this.router.globals.transition === this;\n\n /**\n * Checks if the Transition is valid\n *\n * @returns true if the Transition is valid\n */\n valid() {\n return !this.error() || this.success !== undefined;\n }\n\n /**\n * Aborts this transition\n *\n * Imperative API to abort a Transition.\n * This only applies to Transitions that are not yet complete.\n */\n abort() {\n // Do not set flag if the transition is already complete\n if (isUndefined(this.success)) {\n this._aborted = true;\n }\n }\n\n /**\n * The Transition error reason.\n *\n * If the transition is invalid (and could not be run), returns the reason the transition is invalid.\n * If the transition was valid and ran, but was not successful, returns the reason the transition failed.\n *\n * @returns an error message explaining why the transition is invalid, or the reason the transition failed.\n */\n error() {\n let state: StateObject = this.$to();\n\n if (state.self.abstract)\n return `Cannot transition to abstract state '${state.name}'`;\n\n const paramDefs = state.parameters(), values = this.params();\n const invalidParams = paramDefs.filter(param => !param.validates(values[param.id]));\n if (invalidParams.length) {\n return `Param values not valid for state '${state.name}'. Invalid params: [ ${invalidParams.map(param => param.id).join(', ')} ]`;\n }\n\n if (this.success === false)\n return this._error;\n }\n\n /**\n * A string representation of the Transition\n *\n * @returns A string representation of the Transition\n */\n toString () {\n let fromStateOrName = this.from();\n let toStateOrName = this.to();\n\n const avoidEmptyHash = (params: RawParams) =>\n (params[\"#\"] !== null && params[\"#\"] !== undefined) ? params : omit(params, [\"#\"]);\n\n // (X) means the to state is invalid.\n let id = this.$id,\n from = isObject(fromStateOrName) ? fromStateOrName.name : fromStateOrName,\n fromParams = stringify(avoidEmptyHash(this._treeChanges.from.map(prop('paramValues')).reduce(mergeR, {}))),\n toValid = this.valid() ? \"\" : \"(X) \",\n to = isObject(toStateOrName) ? toStateOrName.name : toStateOrName,\n toParams = stringify(avoidEmptyHash(this.params()));\n\n return `Transition#${id}( '${from}'${fromParams} -> ${toValid}'${to}'${toParams} )`;\n }\n}\n","/**\n * Functions that manipulate strings\n *\n * Although these functions are exported, they are subject to change without notice.\n *\n * @module common_strings\n */ /** */\n\nimport { isString, isArray, isDefined, isNull, isPromise, isInjectable, isObject } from \"./predicates\";\nimport { Rejection } from \"../transition/rejectFactory\";\nimport { IInjectable, identity, Obj, tail, pushR } from \"./common\";\nimport { pattern, is, not, val, invoke } from \"./hof\";\nimport { Transition } from \"../transition/transition\";\nimport { Resolvable } from \"../resolve/resolvable\";\n\n/**\n * Returns a string shortened to a maximum length\n *\n * If the string is already less than the `max` length, return the string.\n * Else return the string, shortened to `max - 3` and append three dots (\"...\").\n *\n * @param max the maximum length of the string to return\n * @param str the input string\n */\nexport function maxLength(max: number, str: string) {\n if (str.length <= max) return str;\n return str.substr(0, max - 3) + \"...\";\n}\n\n/**\n * Returns a string, with spaces added to the end, up to a desired str length\n *\n * If the string is already longer than the desired length, return the string.\n * Else returns the string, with extra spaces on the end, such that it reaches `length` characters.\n *\n * @param length the desired length of the string to return\n * @param str the input string\n */\nexport function padString(length: number, str: string) {\n while (str.length < length) str += \" \";\n return str;\n}\n\nexport function kebobString(camelCase: string) {\n return camelCase\n .replace(/^([A-Z])/, $1 => $1.toLowerCase()) // replace first char\n .replace(/([A-Z])/g, $1 => \"-\" + $1.toLowerCase()); // replace rest\n}\n\nfunction _toJson(obj: Obj) {\n return JSON.stringify(obj);\n}\n\nfunction _fromJson(json: string) {\n return isString(json) ? JSON.parse(json) : json;\n}\n\n\nfunction promiseToString(p: Promise) {\n return `Promise(${JSON.stringify(p)})`;\n}\n\nexport function functionToString(fn: Function) {\n let fnStr = fnToString(fn);\n let namedFunctionMatch = fnStr.match(/^(function [^ ]+\\([^)]*\\))/);\n let toStr = namedFunctionMatch ? namedFunctionMatch[1] : fnStr;\n\n let fnName = fn['name'] || \"\";\n if (fnName && toStr.match(/function \\(/)) {\n return 'function ' + fnName + toStr.substr(9);\n }\n return toStr;\n}\n\nexport function fnToString(fn: IInjectable) {\n let _fn = isArray(fn) ? fn.slice(-1)[0] : fn;\n return _fn && _fn.toString() || \"undefined\";\n}\n\nlet stringifyPatternFn: (val: any) => string = null;\nlet stringifyPattern = function(value: any) {\n let isRejection = Rejection.isRejectionPromise;\n\n stringifyPatternFn = stringifyPatternFn || pattern([\n [not(isDefined), val(\"undefined\")],\n [isNull, val(\"null\")],\n [isPromise, val(\"[Promise]\")],\n [isRejection, (x: any) => x._transitionRejection.toString()],\n [is(Rejection), invoke(\"toString\")],\n [is(Transition), invoke(\"toString\")],\n [is(Resolvable), invoke(\"toString\")],\n [isInjectable, functionToString],\n [val(true), identity]\n ]);\n\n return stringifyPatternFn(value);\n};\n\nexport function stringify(o: any) {\n var seen: any[] = [];\n\n function format(val: any) {\n if (isObject(val)) {\n if (seen.indexOf(val) !== -1) return '[circular ref]';\n seen.push(val);\n }\n return stringifyPattern(val);\n }\n\n return JSON.stringify(o, (key, val) => format(val)).replace(/\\\\\"/g, '\"');\n}\n\n/** Returns a function that splits a string on a character or substring */\nexport const beforeAfterSubstr = (char: string) => (str: string): string[] => {\n if (!str) return [\"\", \"\"];\n let idx = str.indexOf(char);\n if (idx === -1) return [str, \"\"];\n return [str.substr(0, idx), str.substr(idx + 1)];\n};\n\nexport const hostRegex = new RegExp('^(?:[a-z]+:)?//[^/]+/');\nexport const stripFile = (str: string) => str.replace(/\\/[^/]*$/, '');\nexport const splitHash = beforeAfterSubstr(\"#\");\nexport const splitQuery = beforeAfterSubstr(\"?\");\nexport const splitEqual = beforeAfterSubstr(\"=\");\nexport const trimHashVal = (str: string) => str ? str.replace(/^#/, \"\") : \"\";\n\n/**\n * Splits on a delimiter, but returns the delimiters in the array\n *\n * #### Example:\n * ```js\n * var splitOnSlashes = splitOnDelim('/');\n * splitOnSlashes(\"/foo\"); // [\"/\", \"foo\"]\n * splitOnSlashes(\"/foo/\"); // [\"/\", \"foo\", \"/\"]\n * ```\n */\nexport function splitOnDelim(delim: string) {\n let re = new RegExp(\"(\" + delim + \")\", \"g\");\n return (str: string) =>\n str.split(re).filter(identity);\n};\n\n\n/**\n * Reduce fn that joins neighboring strings\n *\n * Given an array of strings, returns a new array\n * where all neighboring strings have been joined.\n *\n * #### Example:\n * ```js\n * let arr = [\"foo\", \"bar\", 1, \"baz\", \"\", \"qux\" ];\n * arr.reduce(joinNeighborsR, []) // [\"foobar\", 1, \"bazqux\" ]\n * ```\n */\nexport function joinNeighborsR(acc: any[], x: any) {\n if (isString(tail(acc)) && isString(x))\n return acc.slice(0, -1).concat(tail(acc)+ x);\n return pushR(acc, x);\n};\n\n","/** @module common */ /** for typedoc */\nexport * from \"./common\";\nexport * from \"./coreservices\";\nexport * from \"./glob\";\nexport * from \"./hof\";\nexport * from \"./predicates\";\nexport * from \"./queue\";\nexport * from \"./strings\";\nexport * from \"./trace\";\n","/**\n * @coreapi\n * @module params\n */\n/** */\nimport { fromJson, toJson, identity, equals, inherit, map, extend, pick } from \"../common/common\";\nimport { isDefined, isNullOrUndefined } from \"../common/predicates\";\nimport { is } from \"../common/hof\";\nimport { services } from \"../common/coreservices\";\nimport { ParamType } from \"./paramType\";\nimport { ParamTypeDefinition } from \"./interface\";\n\n/**\n * A registry for parameter types.\n *\n * This registry manages the built-in (and custom) parameter types.\n *\n * The built-in parameter types are:\n *\n * - [[string]]\n * - [[path]]\n * - [[query]]\n * - [[hash]]\n * - [[int]]\n * - [[bool]]\n * - [[date]]\n * - [[json]]\n * - [[any]]\n */\nexport class ParamTypes {\n /** @hidden */\n types: any;\n /** @hidden */\n enqueue: boolean = true;\n /** @hidden */\n typeQueue: any[] = [];\n\n /**\n * Built-in parameter type: `string`\n *\n * This parameter type coerces values to strings.\n * It matches anything (`new RegExp(\".*\")`) in the URL\n */\n static string: ParamTypeDefinition;\n\n /**\n * Built-in parameter type: `path`\n *\n * This parameter type is the default type for path parameters.\n * A path parameter is any parameter declared in the path portion of a url\n *\n * - `/foo/:param1/:param2`: two path parameters\n *\n * This parameter type behaves exactly like the [[string]] type with one exception.\n * When matching parameter values in the URL, the `path` type does not match forward slashes `/`.\n *\n * #### Angular 1 note:\n * In ng1, this type is overridden with one that pre-encodes slashes as `~2F` instead of `%2F`.\n * For more details about this angular 1 behavior, see: https://github.com/angular-ui/ui-router/issues/2598\n */\n static path: ParamTypeDefinition;\n\n /**\n * Built-in parameter type: `query`\n *\n * This parameter type is the default type for query/search parameters.\n * It behaves the same as the [[string]] parameter type.\n *\n * A query parameter is any parameter declared in the query/search portion of a url\n *\n * - `/bar?param2`: a query parameter\n */\n static query: ParamTypeDefinition;\n\n /**\n * Built-in parameter type: `hash`\n *\n * This parameter type is used for the `#` parameter (the hash)\n * It behaves the same as the [[string]] parameter type.\n * @coreapi\n */\n static hash: ParamTypeDefinition;\n\n /**\n * Built-in parameter type: `int`\n *\n * This parameter type serializes javascript integers (`number`s which represent an integer) to the URL.\n *\n * #### Example:\n * ```js\n * .state({\n * name: 'user',\n * url: '/user/{id:int}'\n * });\n * ```\n * ```js\n * $state.go('user', { id: 1298547 });\n * ```\n *\n * The URL will serialize to: `/user/1298547`.\n *\n * When the parameter value is read, it will be the `number` `1298547`, not the string `\"1298547\"`.\n */\n static int: ParamTypeDefinition;\n\n /**\n * Built-in parameter type: `bool`\n *\n * This parameter type serializes `true`/`false` as `1`/`0`\n *\n * #### Example:\n * ```js\n * .state({\n * name: 'inbox',\n * url: '/inbox?{unread:bool}'\n * });\n * ```\n * ```js\n * $state.go('inbox', { unread: true });\n * ```\n *\n * The URL will serialize to: `/inbox?unread=1`.\n *\n * Conversely, if the url is `/inbox?unread=0`, the value of the `unread` parameter will be a `false`.\n */\n static bool: ParamTypeDefinition;\n\n /**\n * Built-in parameter type: `date`\n *\n * This parameter type can be used to serialize Javascript dates as parameter values.\n *\n * #### Example:\n * ```js\n * .state({\n * name: 'search',\n * url: '/search?{start:date}'\n * });\n * ```\n * ```js\n * $state.go('search', { start: new Date(2000, 0, 1) });\n * ```\n *\n * The URL will serialize to: `/search?start=2000-01-01`.\n *\n * Conversely, if the url is `/search?start=2016-12-25`, the value of the `start` parameter will be a `Date` object where:\n *\n * - `date.getFullYear() === 2016`\n * - `date.getMonth() === 11` (month is 0-based)\n * - `date.getDate() === 25`\n */\n static date: ParamTypeDefinition;\n\n /**\n * Built-in parameter type: `json`\n *\n * This parameter type can be used to serialize javascript objects into the URL using JSON serialization.\n *\n * #### Example:\n * This example serializes an plain javascript object to the URL\n * ```js\n * .state({\n * name: 'map',\n * url: '/map/{coords:json}'\n * });\n * ```\n * ```js\n * $state.go('map', { coords: { x: 10399.2, y: 49071 });\n * ```\n *\n * The URL will serialize to: `/map/%7B%22x%22%3A10399.2%2C%22y%22%3A49071%7D`\n */\n static json: ParamTypeDefinition;\n\n /**\n * Built-in parameter type: `any`\n *\n * This parameter type is used by default for url-less parameters (parameters that do not appear in the URL).\n * This type does not encode or decode.\n * It is compared using a deep `equals` comparison.\n *\n * #### Example:\n * This example defines a non-url parameter on a [[StateDeclaration]].\n * ```js\n * .state({\n * name: 'new',\n * url: '/new',\n * params: {\n * inrepyto: null\n * }\n * });\n * ```\n * ```js\n * $state.go('new', { inreplyto: currentMessage });\n * ```\n */\n static any: ParamTypeDefinition;\n\n\n /** @internalapi */\n private defaultTypes: any = pick(ParamTypes.prototype, [\"hash\", \"string\", \"query\", \"path\", \"int\", \"bool\", \"date\", \"json\", \"any\"]);\n\n /** @internalapi */\n constructor() {\n // Register default types. Store them in the prototype of this.types.\n const makeType = (definition: ParamTypeDefinition, name: string) =>\n new ParamType(extend({ name }, definition));\n this.types = inherit(map(this.defaultTypes, makeType), {});\n }\n\n /** @internalapi */\n dispose() {\n this.types = {};\n }\n\n /**\n * Registers a parameter type\n *\n * End users should call [[UrlMatcherFactory.type]], which delegates to this method.\n */\n type(name: string, definition?: ParamTypeDefinition, definitionFn?: () => ParamTypeDefinition) {\n if (!isDefined(definition)) return this.types[name];\n if (this.types.hasOwnProperty(name)) throw new Error(`A type named '${name}' has already been defined.`);\n\n this.types[name] = new ParamType(extend({ name }, definition));\n\n if (definitionFn) {\n this.typeQueue.push({ name, def: definitionFn });\n if (!this.enqueue) this._flushTypeQueue();\n }\n\n return this;\n }\n\n /** @internalapi */\n _flushTypeQueue() {\n while (this.typeQueue.length) {\n let type = this.typeQueue.shift();\n if (type.pattern) throw new Error(\"You cannot override a type's .pattern at runtime.\");\n extend(this.types[type.name], services.$injector.invoke(type.def));\n }\n }\n}\n\n/** @hidden */\nfunction initDefaultTypes() {\n\n const makeDefaultType = (def) => {\n const valToString = (val: any) =>\n val != null ? val.toString() : val;\n\n const defaultTypeBase = {\n encode: valToString,\n decode: valToString,\n is: is(String),\n pattern: /.*/,\n equals: (a: any, b: any) => a == b, // allow coersion for null/undefined/\"\"\n };\n\n return extend({}, defaultTypeBase, def) as ParamTypeDefinition;\n };\n\n // Default Parameter Type Definitions\n extend(ParamTypes.prototype, {\n string: makeDefaultType({}),\n\n path: makeDefaultType({\n pattern: /[^/]*/,\n }),\n\n query: makeDefaultType({}),\n\n hash: makeDefaultType({\n inherit: false,\n }),\n\n int: makeDefaultType({\n decode: (val: string) => parseInt(val, 10),\n is: function(val: any) {\n return !isNullOrUndefined(val) && this.decode(val.toString()) === val;\n },\n pattern: /-?\\d+/,\n }),\n\n bool: makeDefaultType({\n encode: (val: any) => val && 1 || 0,\n decode: (val: string) => parseInt(val, 10) !== 0,\n is: is(Boolean),\n pattern: /0|1/,\n }),\n\n date: makeDefaultType({\n encode: function(val: any) {\n return !this.is(val) ? undefined : [\n val.getFullYear(),\n ('0' + (val.getMonth() + 1)).slice(-2),\n ('0' + val.getDate()).slice(-2),\n ].join(\"-\");\n },\n decode: function(val: string) {\n if (this.is(val)) return val as Date;\n let match = this.capture.exec(val);\n return match ? new Date(match[1], match[2] - 1, match[3]) : undefined;\n },\n is: (val: any) => val instanceof Date && !isNaN(val.valueOf()),\n equals(l: any, r: any) {\n return ['getFullYear', 'getMonth', 'getDate']\n .reduce((acc, fn) => acc && l[fn]() === r[fn](), true);\n },\n pattern: /[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])/,\n capture: /([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/,\n }),\n\n json: makeDefaultType({\n encode: toJson,\n decode: fromJson,\n is: is(Object),\n equals: equals,\n pattern: /[^/]*/,\n }),\n\n // does not encode/decode\n any: makeDefaultType({\n encode: identity,\n decode: identity,\n is: () => true,\n equals: equals,\n }),\n });\n}\n\ninitDefaultTypes();\n\n","/**\n * @coreapi\n * @module params\n */\n/** */\nimport {extend, ancestors, Obj} from \"../common/common\";\nimport {StateObject} from \"../state/stateObject\";\n\n/** @internalapi */\nexport class StateParams {\n [key: string]: any;\n\n constructor(params: Obj = {}) {\n extend(this, params);\n }\n\n /**\n * Merges a set of parameters with all parameters inherited between the common parents of the\n * current state and a given destination state.\n *\n * @param {Object} newParams The set of parameters which will be composited with inherited params.\n * @param {Object} $current Internal definition of object representing the current state.\n * @param {Object} $to Internal definition of object representing state to transition to.\n */\n $inherit(newParams: Obj, $current: StateObject, $to: StateObject) {\n let parents = ancestors($current, $to),\n parentParams: string[],\n inherited: Obj = {},\n inheritList: string[] = [];\n\n for (let i in parents) {\n if (!parents[i] || !parents[i].params) continue;\n parentParams = Object.keys(parents[i].params);\n if (!parentParams.length) continue;\n\n for (let j in parentParams) {\n if (inheritList.indexOf(parentParams[j]) >= 0) continue;\n inheritList.push(parentParams[j]);\n inherited[parentParams[j]] = this[parentParams[j]];\n }\n }\n return extend({}, inherited, newParams);\n };\n}\n\n","/** @module path */ /** for typedoc */\nexport * from \"./pathNode\";\nexport * from \"./pathFactory\";","/** @module resolve */ /** for typedoc */\nexport * from \"./interface\";\nexport * from \"./resolvable\";\nexport * from \"./resolveContext\";\n","/** @module state */ /** for typedoc */\nimport {Obj, omit, noop, extend, inherit, values, applyPairs, tail, mapObj, identity} from \"../common/common\";\nimport {isDefined, isFunction, isString, isArray} from \"../common/predicates\";\nimport {stringify} from \"../common/strings\";\nimport {prop, pattern, is, pipe, val} from \"../common/hof\";\nimport {StateDeclaration} from \"./interface\";\n\nimport {StateObject} from \"./stateObject\";\nimport {StateMatcher} from \"./stateMatcher\";\nimport {Param} from \"../params/param\";\nimport {UrlMatcherFactory} from \"../url/urlMatcherFactory\";\nimport {UrlMatcher} from \"../url/urlMatcher\";\nimport {Resolvable} from \"../resolve/resolvable\";\nimport {services} from \"../common/coreservices\";\nimport {ResolvePolicy} from \"../resolve/interface\";\nimport { ParamFactory } from \"../url/interface\";\n\nconst parseUrl = (url: string): any => {\n if (!isString(url)) return false;\n let root = url.charAt(0) === '^';\n return { val: root ? url.substring(1) : url, root };\n};\n\nexport type BuilderFunction = (state: StateObject, parent?: BuilderFunction) => any;\n\ninterface Builders {\n [key: string]: BuilderFunction[];\n\n name: BuilderFunction[];\n parent: BuilderFunction[];\n data: BuilderFunction[];\n url: BuilderFunction[];\n navigable: BuilderFunction[];\n params: BuilderFunction[];\n views: BuilderFunction[];\n path: BuilderFunction[];\n includes: BuilderFunction[];\n resolvables: BuilderFunction[];\n}\n\n\nfunction nameBuilder(state: StateObject) {\n return state.name;\n}\n\nfunction selfBuilder(state: StateObject) {\n state.self.$$state = () => state;\n return state.self;\n}\n\nfunction dataBuilder(state: StateObject) {\n if (state.parent && state.parent.data) {\n state.data = state.self.data = inherit(state.parent.data, state.data);\n }\n return state.data;\n}\n\nconst getUrlBuilder = ($urlMatcherFactoryProvider: UrlMatcherFactory, root: () => StateObject) =>\nfunction urlBuilder(state: StateObject) {\n let stateDec: StateDeclaration =