├── .blade.properties
├── .gitignore
├── LICENSE
├── README.md
├── configs
├── common
│ └── .touch
├── dev
│ └── portal-ext.properties
├── docker
│ └── .touch
├── local
│ └── portal-ext.properties
├── prod
│ ├── osgi
│ │ └── configs
│ │ │ └── com.liferay.portal.search.elasticsearch.configuration.ElasticsearchConfiguration.config
│ └── portal-ext.properties
└── uat
│ ├── osgi
│ └── configs
│ │ └── com.liferay.portal.search.elasticsearch.configuration.ElasticsearchConfiguration.config
│ └── portal-ext.properties
├── modules
├── book
│ ├── .gitignore
│ ├── .mvn
│ │ └── wrapper
│ │ │ ├── maven-wrapper.jar
│ │ │ └── maven-wrapper.properties
│ ├── book-api
│ │ ├── bnd.bnd
│ │ ├── pom.xml
│ │ └── src
│ │ │ └── main
│ │ │ └── java
│ │ │ └── book
│ │ │ ├── exception
│ │ │ └── NoSuchBookException.java
│ │ │ ├── model
│ │ │ ├── Book.java
│ │ │ ├── BookModel.java
│ │ │ ├── BookSoap.java
│ │ │ └── BookWrapper.java
│ │ │ └── service
│ │ │ ├── BookLocalService.java
│ │ │ ├── BookLocalServiceUtil.java
│ │ │ ├── BookLocalServiceWrapper.java
│ │ │ └── persistence
│ │ │ ├── BookPersistence.java
│ │ │ └── BookUtil.java
│ ├── book-service
│ │ ├── bnd.bnd
│ │ ├── pom.xml
│ │ ├── service.xml
│ │ ├── src
│ │ │ └── main
│ │ │ │ ├── java
│ │ │ │ └── book
│ │ │ │ │ ├── model
│ │ │ │ │ └── impl
│ │ │ │ │ │ ├── BookBaseImpl.java
│ │ │ │ │ │ ├── BookCacheModel.java
│ │ │ │ │ │ ├── BookImpl.java
│ │ │ │ │ │ └── BookModelImpl.java
│ │ │ │ │ └── service
│ │ │ │ │ ├── base
│ │ │ │ │ └── BookLocalServiceBaseImpl.java
│ │ │ │ │ ├── impl
│ │ │ │ │ └── BookLocalServiceImpl.java
│ │ │ │ │ └── persistence
│ │ │ │ │ └── impl
│ │ │ │ │ ├── BookPersistenceImpl.java
│ │ │ │ │ └── constants
│ │ │ │ │ └── BOOKPersistenceConstants.java
│ │ │ │ └── resources
│ │ │ │ ├── META-INF
│ │ │ │ ├── module-hbm.xml
│ │ │ │ ├── portlet-model-hints.xml
│ │ │ │ └── sql
│ │ │ │ │ ├── indexes.sql
│ │ │ │ │ ├── sequences.sql
│ │ │ │ │ └── tables.sql
│ │ │ │ └── service.properties
│ │ └── test
│ │ │ └── integration
│ │ │ └── book
│ │ │ └── service
│ │ │ └── persistence
│ │ │ └── test
│ │ │ └── BookPersistenceTest.java
│ ├── mvnw
│ ├── mvnw.cmd
│ └── pom.xml
└── pom.xml
├── mvnw
├── mvnw.cmd
├── pom.xml
├── screenshots
└── authorized.png
└── wars
├── books-catalog-portlet
├── LICENSE
├── README.md
├── angular.json
├── browserslist
├── package-lock.json
├── package.json
├── pom.xml
├── portlet-build.js
├── src
│ └── main
│ │ ├── angular
│ │ ├── app
│ │ │ ├── Configuration.ts
│ │ │ ├── app.module.ts
│ │ │ ├── books-catalog
│ │ │ │ ├── Book.ts
│ │ │ │ ├── books-catalog.component.css
│ │ │ │ ├── books-catalog.component.html
│ │ │ │ ├── books-catalog.component.ts
│ │ │ │ └── books.service.ts
│ │ │ ├── configuration.service.ts
│ │ │ ├── demo-material.module.ts
│ │ │ ├── http-interceptors
│ │ │ │ ├── PortletInterceptor.ts
│ │ │ │ └── index.ts
│ │ │ ├── messages
│ │ │ │ ├── message.service.ts
│ │ │ │ ├── messages.component.html
│ │ │ │ └── messages.component.ts
│ │ │ └── test
│ │ │ │ ├── test.component.css
│ │ │ │ ├── test.component.html
│ │ │ │ └── test.component.ts
│ │ ├── assets
│ │ │ └── books.json
│ │ ├── environments
│ │ │ ├── environment.prod.ts
│ │ │ └── environment.ts
│ │ ├── favicon.ico
│ │ ├── index.html
│ │ ├── karma.conf.js
│ │ ├── main.ts
│ │ ├── polyfills.ts
│ │ ├── styles.css
│ │ ├── test.ts
│ │ ├── tsconfig.app.json
│ │ ├── tsconfig.spec.json
│ │ └── tslint.json
│ │ ├── java
│ │ └── com
│ │ │ └── wordpress
│ │ │ └── kkaravitis
│ │ │ └── modules
│ │ │ └── books
│ │ │ └── catalog
│ │ │ ├── AbstractAngularPortlet.java
│ │ │ ├── AngularPortletConfig.java
│ │ │ ├── BooksCatalogPortlet.java
│ │ │ ├── Constants.java
│ │ │ ├── exception
│ │ │ ├── ApplicationException.java
│ │ │ └── ErrorCode.java
│ │ │ ├── model
│ │ │ ├── BookDTO.java
│ │ │ ├── ErrorResponse.java
│ │ │ └── Success.java
│ │ │ ├── rest
│ │ │ ├── ApplicationExceptionControllerAdvice.java
│ │ │ ├── BookController.java
│ │ │ ├── RestFilter.java
│ │ │ └── SecureRequestHandlerInterceptor.java
│ │ │ └── service
│ │ │ ├── BookService.java
│ │ │ └── BookServiceImpl.java
│ │ ├── resources
│ │ ├── log4j2.properties
│ │ ├── messages.properties
│ │ ├── messages_es.properties
│ │ └── portletContext.xml
│ │ └── webapp
│ │ ├── WEB-INF
│ │ ├── liferay-display.xml
│ │ ├── liferay-plugin-package.properties
│ │ ├── liferay-portlet.xml
│ │ ├── portlet.xml
│ │ ├── restful-servlet.xml
│ │ └── web.xml
│ │ ├── css
│ │ ├── books-catalog.css
│ │ ├── deeppurple-amber.css
│ │ └── material-icons.css
│ │ ├── icon.png
│ │ ├── js
│ │ ├── books-catalog.js
│ │ └── runtime.js
│ │ └── view
│ │ └── books-catalog.jsp
├── tsconfig.json
└── tslint.json
└── pom.xml
/.blade.properties:
--------------------------------------------------------------------------------
1 | #Mon Sep 30 23:13:48 EEST 2019
2 | liferay.version.default=7.2
3 | profile.name=maven
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | **/*.iml
2 | **/.ivy
3 | **/.classpath
4 | **/.project
5 | **/.sass-cache
6 | **/.settings
7 | **/bin
8 | **/build
9 | **/build_gradle
10 | **/node_modules
11 | **/test-coverage
12 | **/tmp
13 | **/.web_bundle_build
14 | .gradle
15 | .idea
16 | **/bundles
17 | /gradle-*.properties
18 | /plugins-sdk/**/classes
19 | /plugins-sdk/**/ivy.xml.MD5
20 | /plugins-sdk/**/liferay-hook.xml.processed
21 | /plugins-sdk/build.*.properties
22 | /plugins-sdk/dependencies/**/*.jar
23 | /plugins-sdk/dist
24 | /plugins-sdk/lib
25 | test-results
26 | **/target
27 | **/.factorypath
28 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Konstantinos Karavitis
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Angular 8 with Spring boot 2 portlets on Liferay 7.2
2 | Examples for creating secure jsr286 or jsr362 portlets on liferay 7.2 with angular 8 and Spring boot 2.
3 | Every portlet is in wars folder and in modules folder there are the services apis produced by service builder.
4 |
5 | ## Books catalog example
6 | A basic crud application where only authenticated users of portal can view the stored books on database and can add, update or delete a book of them.
7 |
8 | This portlet leverages the power of angular custom elements and the powerful capabilities of Spring Boot with respect on liferay service builder as regards the persistence layer.
9 |
10 |
11 |
12 | ## Download and install the Liferay Portal 7.2 server.
13 | After you have cloned the project, open a terminal to the angular-spring-boot-portlets folder and run
14 |
15 | mvn bundle-support:init
16 |
17 | The above command downloads the Liferay Portal specified in pom.xml version (7.2) from the specified repository
18 |
19 | (https://releases-cdn.liferay.com/portal/7.2.0-ga1/liferay-ce-portal-tomcat-7.2.0-ga1-20190531153709761.tar.gz).
20 |
21 | Now you have a complete development environment to play with this project.
22 |
23 | For more information about setting up a liferay development environment refer to the following links
24 |
25 | https://portal.liferay.dev/docs/7-0/reference/-/knowledge_base/r/bundle-support-plugin
26 |
27 | https://portal.liferay.dev/docs/7-0/tutorials/-/knowledge_base/t/tooling
28 |
29 | ## How to build and deploy the modules
30 | 1) Install the npm dependencies to angular app by running
31 | npm install --prefix wars/books-catalog-portlet
32 |
33 | 2) Run npm run build:portlet --prefix wars/books-catalog-portlet
34 |
35 | 3) Run mvn install
36 |
37 | 4) Run mvn verify
38 |
--------------------------------------------------------------------------------
/configs/common/.touch:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kkaravitis/angular-spring-boot-portlets/596ece870bca43ae3713437d44456be8ed4484d0/configs/common/.touch
--------------------------------------------------------------------------------
/configs/dev/portal-ext.properties:
--------------------------------------------------------------------------------
1 | include-and-override=portal-developer.properties
2 |
3 | #
4 | # MySQL
5 | #
6 | #jdbc.default.driverClassName=com.mysql.cj.jdbc.Driver
7 | #jdbc.default.url=jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
8 | #jdbc.default.username=root
9 | #jdbc.default.password=
--------------------------------------------------------------------------------
/configs/docker/.touch:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kkaravitis/angular-spring-boot-portlets/596ece870bca43ae3713437d44456be8ed4484d0/configs/docker/.touch
--------------------------------------------------------------------------------
/configs/local/portal-ext.properties:
--------------------------------------------------------------------------------
1 | include-and-override=portal-developer.properties
2 |
3 | #
4 | # MySQL
5 | #
6 | #jdbc.default.driverClassName=com.mysql.cj.jdbc.Driver
7 | #jdbc.default.url=jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
8 | #jdbc.default.username=root
9 | #jdbc.default.password=
--------------------------------------------------------------------------------
/configs/prod/osgi/configs/com.liferay.portal.search.elasticsearch.configuration.ElasticsearchConfiguration.config:
--------------------------------------------------------------------------------
1 | operationMode="REMOTE"
2 | transportAddresses=["127.0.0.1:9300"]
--------------------------------------------------------------------------------
/configs/prod/portal-ext.properties:
--------------------------------------------------------------------------------
1 | #
2 | # MySQL
3 | #
4 | #jdbc.default.driverClassName=com.mysql.cj.jdbc.Driver
5 | #jdbc.default.url=jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
6 | #jdbc.default.username=root
7 | #jdbc.default.password=
--------------------------------------------------------------------------------
/configs/uat/osgi/configs/com.liferay.portal.search.elasticsearch.configuration.ElasticsearchConfiguration.config:
--------------------------------------------------------------------------------
1 | logExceptionsOnly=B"false"
2 | operationMode="REMOTE"
3 | transportAddresses=["127.0.0.1:9300"]
--------------------------------------------------------------------------------
/configs/uat/portal-ext.properties:
--------------------------------------------------------------------------------
1 | #
2 | # MySQL
3 | #
4 | #jdbc.default.driverClassName=com.mysql.cj.jdbc.Driver
5 | #jdbc.default.url=jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
6 | #jdbc.default.username=root
7 | #jdbc.default.password=
--------------------------------------------------------------------------------
/modules/book/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle/
2 | build/
3 | target/
--------------------------------------------------------------------------------
/modules/book/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kkaravitis/angular-spring-boot-portlets/596ece870bca43ae3713437d44456be8ed4484d0/modules/book/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/modules/book/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
--------------------------------------------------------------------------------
/modules/book/book-api/bnd.bnd:
--------------------------------------------------------------------------------
1 | Bundle-Name: book-api
2 | Bundle-SymbolicName: book.api
3 | Bundle-Version: 1.0.0
4 | Export-Package:\
5 | book.exception,\
6 | book.model,\
7 | book.service,\
8 | book.service.persistence
9 | -check: EXPORTS
10 | -includeresource: META-INF/service.xml=../book-service/service.xml
--------------------------------------------------------------------------------
/modules/book/book-api/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 | 4.0.0
9 | book-api
10 | 1.0.0
11 |
12 | book
13 | book
14 | 1.0.0
15 |
16 |
17 |
18 | com.liferay.portal
19 | com.liferay.portal.kernel
20 | 4.4.0
21 | provided
22 |
23 |
24 | org.osgi
25 | org.osgi.annotation.versioning
26 | 1.1.0
27 | provided
28 |
29 |
30 | org.osgi
31 | org.osgi.core
32 | 6.0.0
33 | provided
34 |
35 |
36 | org.osgi
37 | org.osgi.service.component.annotations
38 | 1.3.0
39 | provided
40 |
41 |
42 |
--------------------------------------------------------------------------------
/modules/book/book-api/src/main/java/book/exception/NoSuchBookException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU Lesser General Public License as published by the Free
6 | * Software Foundation; either version 2.1 of the License, or (at your option)
7 | * any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 | * details.
13 | */
14 | package book.exception;
15 |
16 | import org.osgi.annotation.versioning.ProviderType;
17 |
18 | import com.liferay.portal.kernel.exception.NoSuchModelException;
19 |
20 | /**
21 | * @author Brian Wing Shun Chan
22 | */
23 | @ProviderType
24 | public class NoSuchBookException extends NoSuchModelException {
25 |
26 | public NoSuchBookException() {
27 | }
28 |
29 | public NoSuchBookException(String msg) {
30 | super(msg);
31 | }
32 |
33 | public NoSuchBookException(String msg, Throwable cause) {
34 | super(msg, cause);
35 | }
36 |
37 | public NoSuchBookException(Throwable cause) {
38 | super(cause);
39 | }
40 |
41 | }
--------------------------------------------------------------------------------
/modules/book/book-api/src/main/java/book/model/Book.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU Lesser General Public License as published by the Free
6 | * Software Foundation; either version 2.1 of the License, or (at your option)
7 | * any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 | * details.
13 | */
14 |
15 | package book.model;
16 |
17 | import com.liferay.portal.kernel.annotation.ImplementationClassName;
18 | import com.liferay.portal.kernel.model.PersistedModel;
19 | import com.liferay.portal.kernel.util.Accessor;
20 |
21 | import org.osgi.annotation.versioning.ProviderType;
22 |
23 | /**
24 | * The extended model interface for the Book service. Represents a row in the "BOOK_Book" database table, with each column mapped to a property of this class.
25 | *
26 | * @author Brian Wing Shun Chan
27 | * @see BookModel
28 | * @generated
29 | */
30 | @ImplementationClassName("book.model.impl.BookImpl")
31 | @ProviderType
32 | public interface Book extends BookModel, PersistedModel {
33 |
34 | /*
35 | * NOTE FOR DEVELOPERS:
36 | *
37 | * Never modify this interface directly. Add methods to book.model.impl.BookImpl and rerun ServiceBuilder to automatically copy the method declarations to this interface.
38 | */
39 | public static final Accessor ISBN_ACCESSOR =
40 | new Accessor() {
41 |
42 | @Override
43 | public String get(Book book) {
44 | return book.getIsbn();
45 | }
46 |
47 | @Override
48 | public Class getAttributeClass() {
49 | return String.class;
50 | }
51 |
52 | @Override
53 | public Class getTypeClass() {
54 | return Book.class;
55 | }
56 |
57 | };
58 |
59 | }
--------------------------------------------------------------------------------
/modules/book/book-api/src/main/java/book/model/BookModel.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU Lesser General Public License as published by the Free
6 | * Software Foundation; either version 2.1 of the License, or (at your option)
7 | * any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 | * details.
13 | */
14 |
15 | package book.model;
16 |
17 | import com.liferay.portal.kernel.bean.AutoEscape;
18 | import com.liferay.portal.kernel.model.BaseModel;
19 |
20 | import org.osgi.annotation.versioning.ProviderType;
21 |
22 | /**
23 | * The base model interface for the Book service. Represents a row in the "BOOK_Book" database table, with each column mapped to a property of this class.
24 | *
25 | *
26 | * This interface and its corresponding implementation book.model.impl.BookModelImpl exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in book.model.impl.BookImpl.
27 | *
28 | *
29 | * @author Brian Wing Shun Chan
30 | * @see Book
31 | * @generated
32 | */
33 | @ProviderType
34 | public interface BookModel extends BaseModel {
35 |
36 | /*
37 | * NOTE FOR DEVELOPERS:
38 | *
39 | * Never modify or reference this interface directly. All methods that expect a book model instance should use the {@link Book} interface instead.
40 | */
41 |
42 | /**
43 | * Returns the primary key of this book.
44 | *
45 | * @return the primary key of this book
46 | */
47 | public String getPrimaryKey();
48 |
49 | /**
50 | * Sets the primary key of this book.
51 | *
52 | * @param primaryKey the primary key of this book
53 | */
54 | public void setPrimaryKey(String primaryKey);
55 |
56 | /**
57 | * Returns the uuid of this book.
58 | *
59 | * @return the uuid of this book
60 | */
61 | @AutoEscape
62 | public String getUuid();
63 |
64 | /**
65 | * Sets the uuid of this book.
66 | *
67 | * @param uuid the uuid of this book
68 | */
69 | public void setUuid(String uuid);
70 |
71 | /**
72 | * Returns the isbn of this book.
73 | *
74 | * @return the isbn of this book
75 | */
76 | @AutoEscape
77 | public String getIsbn();
78 |
79 | /**
80 | * Sets the isbn of this book.
81 | *
82 | * @param isbn the isbn of this book
83 | */
84 | public void setIsbn(String isbn);
85 |
86 | /**
87 | * Returns the title of this book.
88 | *
89 | * @return the title of this book
90 | */
91 | @AutoEscape
92 | public String getTitle();
93 |
94 | /**
95 | * Sets the title of this book.
96 | *
97 | * @param title the title of this book
98 | */
99 | public void setTitle(String title);
100 |
101 | /**
102 | * Returns the author of this book.
103 | *
104 | * @return the author of this book
105 | */
106 | @AutoEscape
107 | public String getAuthor();
108 |
109 | /**
110 | * Sets the author of this book.
111 | *
112 | * @param author the author of this book
113 | */
114 | public void setAuthor(String author);
115 |
116 | }
--------------------------------------------------------------------------------
/modules/book/book-api/src/main/java/book/model/BookSoap.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU Lesser General Public License as published by the Free
6 | * Software Foundation; either version 2.1 of the License, or (at your option)
7 | * any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 | * details.
13 | */
14 |
15 | package book.model;
16 |
17 | import java.io.Serializable;
18 |
19 | import java.util.ArrayList;
20 | import java.util.List;
21 |
22 | import org.osgi.annotation.versioning.ProviderType;
23 |
24 | /**
25 | * This class is used by SOAP remote services.
26 | *
27 | * @author Brian Wing Shun Chan
28 | * @generated
29 | */
30 | @ProviderType
31 | public class BookSoap implements Serializable {
32 |
33 | public static BookSoap toSoapModel(Book model) {
34 | BookSoap soapModel = new BookSoap();
35 |
36 | soapModel.setUuid(model.getUuid());
37 | soapModel.setIsbn(model.getIsbn());
38 | soapModel.setTitle(model.getTitle());
39 | soapModel.setAuthor(model.getAuthor());
40 |
41 | return soapModel;
42 | }
43 |
44 | public static BookSoap[] toSoapModels(Book[] models) {
45 | BookSoap[] soapModels = new BookSoap[models.length];
46 |
47 | for (int i = 0; i < models.length; i++) {
48 | soapModels[i] = toSoapModel(models[i]);
49 | }
50 |
51 | return soapModels;
52 | }
53 |
54 | public static BookSoap[][] toSoapModels(Book[][] models) {
55 | BookSoap[][] soapModels = null;
56 |
57 | if (models.length > 0) {
58 | soapModels = new BookSoap[models.length][models[0].length];
59 | }
60 | else {
61 | soapModels = new BookSoap[0][0];
62 | }
63 |
64 | for (int i = 0; i < models.length; i++) {
65 | soapModels[i] = toSoapModels(models[i]);
66 | }
67 |
68 | return soapModels;
69 | }
70 |
71 | public static BookSoap[] toSoapModels(List models) {
72 | List soapModels = new ArrayList(models.size());
73 |
74 | for (Book model : models) {
75 | soapModels.add(toSoapModel(model));
76 | }
77 |
78 | return soapModels.toArray(new BookSoap[soapModels.size()]);
79 | }
80 |
81 | public BookSoap() {
82 | }
83 |
84 | public String getPrimaryKey() {
85 | return _isbn;
86 | }
87 |
88 | public void setPrimaryKey(String pk) {
89 | setIsbn(pk);
90 | }
91 |
92 | public String getUuid() {
93 | return _uuid;
94 | }
95 |
96 | public void setUuid(String uuid) {
97 | _uuid = uuid;
98 | }
99 |
100 | public String getIsbn() {
101 | return _isbn;
102 | }
103 |
104 | public void setIsbn(String isbn) {
105 | _isbn = isbn;
106 | }
107 |
108 | public String getTitle() {
109 | return _title;
110 | }
111 |
112 | public void setTitle(String title) {
113 | _title = title;
114 | }
115 |
116 | public String getAuthor() {
117 | return _author;
118 | }
119 |
120 | public void setAuthor(String author) {
121 | _author = author;
122 | }
123 |
124 | private String _uuid;
125 | private String _isbn;
126 | private String _title;
127 | private String _author;
128 |
129 | }
--------------------------------------------------------------------------------
/modules/book/book-api/src/main/java/book/model/BookWrapper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU Lesser General Public License as published by the Free
6 | * Software Foundation; either version 2.1 of the License, or (at your option)
7 | * any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 | * details.
13 | */
14 |
15 | package book.model;
16 |
17 | import com.liferay.portal.kernel.model.ModelWrapper;
18 | import com.liferay.portal.kernel.model.wrapper.BaseModelWrapper;
19 |
20 | import java.util.HashMap;
21 | import java.util.Map;
22 |
23 | import org.osgi.annotation.versioning.ProviderType;
24 |
25 | /**
26 | *
27 | * This class is a wrapper for {@link Book}.
28 | *
29 | *
30 | * @author Brian Wing Shun Chan
31 | * @see Book
32 | * @generated
33 | */
34 | @ProviderType
35 | public class BookWrapper
36 | extends BaseModelWrapper implements Book, ModelWrapper {
37 |
38 | public BookWrapper(Book book) {
39 | super(book);
40 | }
41 |
42 | @Override
43 | public Map getModelAttributes() {
44 | Map attributes = new HashMap();
45 |
46 | attributes.put("uuid", getUuid());
47 | attributes.put("isbn", getIsbn());
48 | attributes.put("title", getTitle());
49 | attributes.put("author", getAuthor());
50 |
51 | return attributes;
52 | }
53 |
54 | @Override
55 | public void setModelAttributes(Map attributes) {
56 | String uuid = (String)attributes.get("uuid");
57 |
58 | if (uuid != null) {
59 | setUuid(uuid);
60 | }
61 |
62 | String isbn = (String)attributes.get("isbn");
63 |
64 | if (isbn != null) {
65 | setIsbn(isbn);
66 | }
67 |
68 | String title = (String)attributes.get("title");
69 |
70 | if (title != null) {
71 | setTitle(title);
72 | }
73 |
74 | String author = (String)attributes.get("author");
75 |
76 | if (author != null) {
77 | setAuthor(author);
78 | }
79 | }
80 |
81 | /**
82 | * Returns the author of this book.
83 | *
84 | * @return the author of this book
85 | */
86 | @Override
87 | public String getAuthor() {
88 | return model.getAuthor();
89 | }
90 |
91 | /**
92 | * Returns the isbn of this book.
93 | *
94 | * @return the isbn of this book
95 | */
96 | @Override
97 | public String getIsbn() {
98 | return model.getIsbn();
99 | }
100 |
101 | /**
102 | * Returns the primary key of this book.
103 | *
104 | * @return the primary key of this book
105 | */
106 | @Override
107 | public String getPrimaryKey() {
108 | return model.getPrimaryKey();
109 | }
110 |
111 | /**
112 | * Returns the title of this book.
113 | *
114 | * @return the title of this book
115 | */
116 | @Override
117 | public String getTitle() {
118 | return model.getTitle();
119 | }
120 |
121 | /**
122 | * Returns the uuid of this book.
123 | *
124 | * @return the uuid of this book
125 | */
126 | @Override
127 | public String getUuid() {
128 | return model.getUuid();
129 | }
130 |
131 | @Override
132 | public void persist() {
133 | model.persist();
134 | }
135 |
136 | /**
137 | * Sets the author of this book.
138 | *
139 | * @param author the author of this book
140 | */
141 | @Override
142 | public void setAuthor(String author) {
143 | model.setAuthor(author);
144 | }
145 |
146 | /**
147 | * Sets the isbn of this book.
148 | *
149 | * @param isbn the isbn of this book
150 | */
151 | @Override
152 | public void setIsbn(String isbn) {
153 | model.setIsbn(isbn);
154 | }
155 |
156 | /**
157 | * Sets the primary key of this book.
158 | *
159 | * @param primaryKey the primary key of this book
160 | */
161 | @Override
162 | public void setPrimaryKey(String primaryKey) {
163 | model.setPrimaryKey(primaryKey);
164 | }
165 |
166 | /**
167 | * Sets the title of this book.
168 | *
169 | * @param title the title of this book
170 | */
171 | @Override
172 | public void setTitle(String title) {
173 | model.setTitle(title);
174 | }
175 |
176 | /**
177 | * Sets the uuid of this book.
178 | *
179 | * @param uuid the uuid of this book
180 | */
181 | @Override
182 | public void setUuid(String uuid) {
183 | model.setUuid(uuid);
184 | }
185 |
186 | @Override
187 | protected BookWrapper wrap(Book book) {
188 | return new BookWrapper(book);
189 | }
190 |
191 | }
--------------------------------------------------------------------------------
/modules/book/book-api/src/main/java/book/service/BookLocalService.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU Lesser General Public License as published by the Free
6 | * Software Foundation; either version 2.1 of the License, or (at your option)
7 | * any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 | * details.
13 | */
14 |
15 | package book.service;
16 |
17 | import book.model.Book;
18 |
19 | import com.liferay.portal.kernel.dao.orm.DynamicQuery;
20 | import com.liferay.portal.kernel.dao.orm.Projection;
21 | import com.liferay.portal.kernel.exception.PortalException;
22 | import com.liferay.portal.kernel.exception.SystemException;
23 | import com.liferay.portal.kernel.model.PersistedModel;
24 | import com.liferay.portal.kernel.search.Indexable;
25 | import com.liferay.portal.kernel.search.IndexableType;
26 | import com.liferay.portal.kernel.service.BaseLocalService;
27 | import com.liferay.portal.kernel.service.PersistedModelLocalService;
28 | import com.liferay.portal.kernel.transaction.Isolation;
29 | import com.liferay.portal.kernel.transaction.Propagation;
30 | import com.liferay.portal.kernel.transaction.Transactional;
31 | import com.liferay.portal.kernel.util.OrderByComparator;
32 |
33 | import java.io.Serializable;
34 |
35 | import java.util.List;
36 |
37 | import org.osgi.annotation.versioning.ProviderType;
38 |
39 | /**
40 | * Provides the local service interface for Book. Methods of this
41 | * service will not have security checks based on the propagated JAAS
42 | * credentials because this service can only be accessed from within the same
43 | * VM.
44 | *
45 | * @author Brian Wing Shun Chan
46 | * @see BookLocalServiceUtil
47 | * @generated
48 | */
49 | @ProviderType
50 | @Transactional(
51 | isolation = Isolation.PORTAL,
52 | rollbackFor = {PortalException.class, SystemException.class}
53 | )
54 | public interface BookLocalService
55 | extends BaseLocalService, PersistedModelLocalService {
56 |
57 | /*
58 | * NOTE FOR DEVELOPERS:
59 | *
60 | * Never modify or reference this interface directly. Always use {@link BookLocalServiceUtil} to access the book local service. Add custom service methods to book.service.impl.BookLocalServiceImpl and rerun ServiceBuilder to automatically copy the method declarations to this interface.
61 | */
62 |
63 | /**
64 | * Adds the book to the database. Also notifies the appropriate model listeners.
65 | *
66 | * @param book the book
67 | * @return the book that was added
68 | */
69 | @Indexable(type = IndexableType.REINDEX)
70 | public Book addBook(Book book);
71 |
72 | /**
73 | * Creates a new book with the primary key. Does not add the book to the database.
74 | *
75 | * @param isbn the primary key for the new book
76 | * @return the new book
77 | */
78 | @Transactional(enabled = false)
79 | public Book createBook(String isbn);
80 |
81 | /**
82 | * Deletes the book from the database. Also notifies the appropriate model listeners.
83 | *
84 | * @param book the book
85 | * @return the book that was removed
86 | */
87 | @Indexable(type = IndexableType.DELETE)
88 | public Book deleteBook(Book book);
89 |
90 | /**
91 | * Deletes the book with the primary key from the database. Also notifies the appropriate model listeners.
92 | *
93 | * @param isbn the primary key of the book
94 | * @return the book that was removed
95 | * @throws PortalException if a book with the primary key could not be found
96 | */
97 | @Indexable(type = IndexableType.DELETE)
98 | public Book deleteBook(String isbn) throws PortalException;
99 |
100 | /**
101 | * @throws PortalException
102 | */
103 | @Override
104 | public PersistedModel deletePersistedModel(PersistedModel persistedModel)
105 | throws PortalException;
106 |
107 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
108 | public DynamicQuery dynamicQuery();
109 |
110 | /**
111 | * Performs a dynamic query on the database and returns the matching rows.
112 | *
113 | * @param dynamicQuery the dynamic query
114 | * @return the matching rows
115 | */
116 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
117 | public List dynamicQuery(DynamicQuery dynamicQuery);
118 |
119 | /**
120 | * Performs a dynamic query on the database and returns a range of the matching rows.
121 | *
122 | *
123 | * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from book.model.impl.BookModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
124 | *
125 | *
126 | * @param dynamicQuery the dynamic query
127 | * @param start the lower bound of the range of model instances
128 | * @param end the upper bound of the range of model instances (not inclusive)
129 | * @return the range of matching rows
130 | */
131 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
132 | public List dynamicQuery(
133 | DynamicQuery dynamicQuery, int start, int end);
134 |
135 | /**
136 | * Performs a dynamic query on the database and returns an ordered range of the matching rows.
137 | *
138 | *
139 | * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from book.model.impl.BookModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
140 | *
141 | *
142 | * @param dynamicQuery the dynamic query
143 | * @param start the lower bound of the range of model instances
144 | * @param end the upper bound of the range of model instances (not inclusive)
145 | * @param orderByComparator the comparator to order the results by (optionally null)
146 | * @return the ordered range of matching rows
147 | */
148 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
149 | public List dynamicQuery(
150 | DynamicQuery dynamicQuery, int start, int end,
151 | OrderByComparator orderByComparator);
152 |
153 | /**
154 | * Returns the number of rows matching the dynamic query.
155 | *
156 | * @param dynamicQuery the dynamic query
157 | * @return the number of rows matching the dynamic query
158 | */
159 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
160 | public long dynamicQueryCount(DynamicQuery dynamicQuery);
161 |
162 | /**
163 | * Returns the number of rows matching the dynamic query.
164 | *
165 | * @param dynamicQuery the dynamic query
166 | * @param projection the projection to apply to the query
167 | * @return the number of rows matching the dynamic query
168 | */
169 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
170 | public long dynamicQueryCount(
171 | DynamicQuery dynamicQuery, Projection projection);
172 |
173 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
174 | public Book fetchBook(String isbn);
175 |
176 | /**
177 | * Returns the book with the primary key.
178 | *
179 | * @param isbn the primary key of the book
180 | * @return the book
181 | * @throws PortalException if a book with the primary key could not be found
182 | */
183 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
184 | public Book getBook(String isbn) throws PortalException;
185 |
186 | /**
187 | * Returns a range of all the books.
188 | *
189 | *
190 | * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from book.model.impl.BookModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
191 | *
192 | *
193 | * @param start the lower bound of the range of books
194 | * @param end the upper bound of the range of books (not inclusive)
195 | * @return the range of books
196 | */
197 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
198 | public List getBooks(int start, int end);
199 |
200 | /**
201 | * Returns the number of books.
202 | *
203 | * @return the number of books
204 | */
205 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
206 | public int getBooksCount();
207 |
208 | /**
209 | * Returns the OSGi service identifier.
210 | *
211 | * @return the OSGi service identifier
212 | */
213 | public String getOSGiServiceIdentifier();
214 |
215 | @Override
216 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
217 | public PersistedModel getPersistedModel(Serializable primaryKeyObj)
218 | throws PortalException;
219 |
220 | /**
221 | * Updates the book in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
222 | *
223 | * @param book the book
224 | * @return the book that was updated
225 | */
226 | @Indexable(type = IndexableType.REINDEX)
227 | public Book updateBook(Book book);
228 |
229 | }
--------------------------------------------------------------------------------
/modules/book/book-api/src/main/java/book/service/BookLocalServiceUtil.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU Lesser General Public License as published by the Free
6 | * Software Foundation; either version 2.1 of the License, or (at your option)
7 | * any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 | * details.
13 | */
14 |
15 | package book.service;
16 |
17 | import org.osgi.annotation.versioning.ProviderType;
18 | import org.osgi.framework.Bundle;
19 | import org.osgi.framework.FrameworkUtil;
20 | import org.osgi.util.tracker.ServiceTracker;
21 |
22 | /**
23 | * Provides the local service utility for Book. This utility wraps
24 | * book.service.impl.BookLocalServiceImpl and
25 | * is an access point for service operations in application layer code running
26 | * on the local server. Methods of this service will not have security checks
27 | * based on the propagated JAAS credentials because this service can only be
28 | * accessed from within the same VM.
29 | *
30 | * @author Brian Wing Shun Chan
31 | * @see BookLocalService
32 | * @generated
33 | */
34 | @ProviderType
35 | public class BookLocalServiceUtil {
36 |
37 | /*
38 | * NOTE FOR DEVELOPERS:
39 | *
40 | * Never modify this class directly. Add custom service methods to book.service.impl.BookLocalServiceImpl and rerun ServiceBuilder to regenerate this class.
41 | */
42 |
43 | /**
44 | * Adds the book to the database. Also notifies the appropriate model listeners.
45 | *
46 | * @param book the book
47 | * @return the book that was added
48 | */
49 | public static book.model.Book addBook(book.model.Book book) {
50 | return getService().addBook(book);
51 | }
52 |
53 | /**
54 | * Creates a new book with the primary key. Does not add the book to the database.
55 | *
56 | * @param isbn the primary key for the new book
57 | * @return the new book
58 | */
59 | public static book.model.Book createBook(String isbn) {
60 | return getService().createBook(isbn);
61 | }
62 |
63 | /**
64 | * Deletes the book from the database. Also notifies the appropriate model listeners.
65 | *
66 | * @param book the book
67 | * @return the book that was removed
68 | */
69 | public static book.model.Book deleteBook(book.model.Book book) {
70 | return getService().deleteBook(book);
71 | }
72 |
73 | /**
74 | * Deletes the book with the primary key from the database. Also notifies the appropriate model listeners.
75 | *
76 | * @param isbn the primary key of the book
77 | * @return the book that was removed
78 | * @throws PortalException if a book with the primary key could not be found
79 | */
80 | public static book.model.Book deleteBook(String isbn)
81 | throws com.liferay.portal.kernel.exception.PortalException {
82 |
83 | return getService().deleteBook(isbn);
84 | }
85 |
86 | /**
87 | * @throws PortalException
88 | */
89 | public static com.liferay.portal.kernel.model.PersistedModel
90 | deletePersistedModel(
91 | com.liferay.portal.kernel.model.PersistedModel persistedModel)
92 | throws com.liferay.portal.kernel.exception.PortalException {
93 |
94 | return getService().deletePersistedModel(persistedModel);
95 | }
96 |
97 | public static com.liferay.portal.kernel.dao.orm.DynamicQuery
98 | dynamicQuery() {
99 |
100 | return getService().dynamicQuery();
101 | }
102 |
103 | /**
104 | * Performs a dynamic query on the database and returns the matching rows.
105 | *
106 | * @param dynamicQuery the dynamic query
107 | * @return the matching rows
108 | */
109 | public static java.util.List dynamicQuery(
110 | com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery) {
111 |
112 | return getService().dynamicQuery(dynamicQuery);
113 | }
114 |
115 | /**
116 | * Performs a dynamic query on the database and returns a range of the matching rows.
117 | *
118 | *
119 | * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from book.model.impl.BookModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
120 | *
121 | *
122 | * @param dynamicQuery the dynamic query
123 | * @param start the lower bound of the range of model instances
124 | * @param end the upper bound of the range of model instances (not inclusive)
125 | * @return the range of matching rows
126 | */
127 | public static java.util.List dynamicQuery(
128 | com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery, int start,
129 | int end) {
130 |
131 | return getService().dynamicQuery(dynamicQuery, start, end);
132 | }
133 |
134 | /**
135 | * Performs a dynamic query on the database and returns an ordered range of the matching rows.
136 | *
137 | *
138 | * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from book.model.impl.BookModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
139 | *
140 | *
141 | * @param dynamicQuery the dynamic query
142 | * @param start the lower bound of the range of model instances
143 | * @param end the upper bound of the range of model instances (not inclusive)
144 | * @param orderByComparator the comparator to order the results by (optionally null)
145 | * @return the ordered range of matching rows
146 | */
147 | public static java.util.List dynamicQuery(
148 | com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery, int start,
149 | int end,
150 | com.liferay.portal.kernel.util.OrderByComparator orderByComparator) {
151 |
152 | return getService().dynamicQuery(
153 | dynamicQuery, start, end, orderByComparator);
154 | }
155 |
156 | /**
157 | * Returns the number of rows matching the dynamic query.
158 | *
159 | * @param dynamicQuery the dynamic query
160 | * @return the number of rows matching the dynamic query
161 | */
162 | public static long dynamicQueryCount(
163 | com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery) {
164 |
165 | return getService().dynamicQueryCount(dynamicQuery);
166 | }
167 |
168 | /**
169 | * Returns the number of rows matching the dynamic query.
170 | *
171 | * @param dynamicQuery the dynamic query
172 | * @param projection the projection to apply to the query
173 | * @return the number of rows matching the dynamic query
174 | */
175 | public static long dynamicQueryCount(
176 | com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery,
177 | com.liferay.portal.kernel.dao.orm.Projection projection) {
178 |
179 | return getService().dynamicQueryCount(dynamicQuery, projection);
180 | }
181 |
182 | public static book.model.Book fetchBook(String isbn) {
183 | return getService().fetchBook(isbn);
184 | }
185 |
186 | /**
187 | * Returns the book with the primary key.
188 | *
189 | * @param isbn the primary key of the book
190 | * @return the book
191 | * @throws PortalException if a book with the primary key could not be found
192 | */
193 | public static book.model.Book getBook(String isbn)
194 | throws com.liferay.portal.kernel.exception.PortalException {
195 |
196 | return getService().getBook(isbn);
197 | }
198 |
199 | /**
200 | * Returns a range of all the books.
201 | *
202 | *
203 | * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from book.model.impl.BookModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
204 | *
205 | *
206 | * @param start the lower bound of the range of books
207 | * @param end the upper bound of the range of books (not inclusive)
208 | * @return the range of books
209 | */
210 | public static java.util.List getBooks(int start, int end) {
211 | return getService().getBooks(start, end);
212 | }
213 |
214 | /**
215 | * Returns the number of books.
216 | *
217 | * @return the number of books
218 | */
219 | public static int getBooksCount() {
220 | return getService().getBooksCount();
221 | }
222 |
223 | /**
224 | * Returns the OSGi service identifier.
225 | *
226 | * @return the OSGi service identifier
227 | */
228 | public static String getOSGiServiceIdentifier() {
229 | return getService().getOSGiServiceIdentifier();
230 | }
231 |
232 | public static com.liferay.portal.kernel.model.PersistedModel
233 | getPersistedModel(java.io.Serializable primaryKeyObj)
234 | throws com.liferay.portal.kernel.exception.PortalException {
235 |
236 | return getService().getPersistedModel(primaryKeyObj);
237 | }
238 |
239 | /**
240 | * Updates the book in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
241 | *
242 | * @param book the book
243 | * @return the book that was updated
244 | */
245 | public static book.model.Book updateBook(book.model.Book book) {
246 | return getService().updateBook(book);
247 | }
248 |
249 | public static BookLocalService getService() {
250 | return _serviceTracker.getService();
251 | }
252 |
253 | private static ServiceTracker
254 | _serviceTracker;
255 |
256 | static {
257 | Bundle bundle = FrameworkUtil.getBundle(BookLocalService.class);
258 |
259 | ServiceTracker serviceTracker =
260 | new ServiceTracker(
261 | bundle.getBundleContext(), BookLocalService.class, null);
262 |
263 | serviceTracker.open();
264 |
265 | _serviceTracker = serviceTracker;
266 | }
267 |
268 | }
--------------------------------------------------------------------------------
/modules/book/book-api/src/main/java/book/service/BookLocalServiceWrapper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU Lesser General Public License as published by the Free
6 | * Software Foundation; either version 2.1 of the License, or (at your option)
7 | * any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 | * details.
13 | */
14 |
15 | package book.service;
16 |
17 | import com.liferay.portal.kernel.service.ServiceWrapper;
18 |
19 | import org.osgi.annotation.versioning.ProviderType;
20 |
21 | /**
22 | * Provides a wrapper for {@link BookLocalService}.
23 | *
24 | * @author Brian Wing Shun Chan
25 | * @see BookLocalService
26 | * @generated
27 | */
28 | @ProviderType
29 | public class BookLocalServiceWrapper
30 | implements BookLocalService, ServiceWrapper {
31 |
32 | public BookLocalServiceWrapper(BookLocalService bookLocalService) {
33 | _bookLocalService = bookLocalService;
34 | }
35 |
36 | /**
37 | * Adds the book to the database. Also notifies the appropriate model listeners.
38 | *
39 | * @param book the book
40 | * @return the book that was added
41 | */
42 | @Override
43 | public book.model.Book addBook(book.model.Book book) {
44 | return _bookLocalService.addBook(book);
45 | }
46 |
47 | /**
48 | * Creates a new book with the primary key. Does not add the book to the database.
49 | *
50 | * @param isbn the primary key for the new book
51 | * @return the new book
52 | */
53 | @Override
54 | public book.model.Book createBook(String isbn) {
55 | return _bookLocalService.createBook(isbn);
56 | }
57 |
58 | /**
59 | * Deletes the book from the database. Also notifies the appropriate model listeners.
60 | *
61 | * @param book the book
62 | * @return the book that was removed
63 | */
64 | @Override
65 | public book.model.Book deleteBook(book.model.Book book) {
66 | return _bookLocalService.deleteBook(book);
67 | }
68 |
69 | /**
70 | * Deletes the book with the primary key from the database. Also notifies the appropriate model listeners.
71 | *
72 | * @param isbn the primary key of the book
73 | * @return the book that was removed
74 | * @throws PortalException if a book with the primary key could not be found
75 | */
76 | @Override
77 | public book.model.Book deleteBook(String isbn)
78 | throws com.liferay.portal.kernel.exception.PortalException {
79 |
80 | return _bookLocalService.deleteBook(isbn);
81 | }
82 |
83 | /**
84 | * @throws PortalException
85 | */
86 | @Override
87 | public com.liferay.portal.kernel.model.PersistedModel deletePersistedModel(
88 | com.liferay.portal.kernel.model.PersistedModel persistedModel)
89 | throws com.liferay.portal.kernel.exception.PortalException {
90 |
91 | return _bookLocalService.deletePersistedModel(persistedModel);
92 | }
93 |
94 | @Override
95 | public com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery() {
96 | return _bookLocalService.dynamicQuery();
97 | }
98 |
99 | /**
100 | * Performs a dynamic query on the database and returns the matching rows.
101 | *
102 | * @param dynamicQuery the dynamic query
103 | * @return the matching rows
104 | */
105 | @Override
106 | public java.util.List dynamicQuery(
107 | com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery) {
108 |
109 | return _bookLocalService.dynamicQuery(dynamicQuery);
110 | }
111 |
112 | /**
113 | * Performs a dynamic query on the database and returns a range of the matching rows.
114 | *
115 | *
116 | * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from book.model.impl.BookModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
117 | *
118 | *
119 | * @param dynamicQuery the dynamic query
120 | * @param start the lower bound of the range of model instances
121 | * @param end the upper bound of the range of model instances (not inclusive)
122 | * @return the range of matching rows
123 | */
124 | @Override
125 | public java.util.List dynamicQuery(
126 | com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery, int start,
127 | int end) {
128 |
129 | return _bookLocalService.dynamicQuery(dynamicQuery, start, end);
130 | }
131 |
132 | /**
133 | * Performs a dynamic query on the database and returns an ordered range of the matching rows.
134 | *
135 | *
136 | * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from book.model.impl.BookModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
137 | *
138 | *
139 | * @param dynamicQuery the dynamic query
140 | * @param start the lower bound of the range of model instances
141 | * @param end the upper bound of the range of model instances (not inclusive)
142 | * @param orderByComparator the comparator to order the results by (optionally null)
143 | * @return the ordered range of matching rows
144 | */
145 | @Override
146 | public java.util.List dynamicQuery(
147 | com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery, int start,
148 | int end,
149 | com.liferay.portal.kernel.util.OrderByComparator orderByComparator) {
150 |
151 | return _bookLocalService.dynamicQuery(
152 | dynamicQuery, start, end, orderByComparator);
153 | }
154 |
155 | /**
156 | * Returns the number of rows matching the dynamic query.
157 | *
158 | * @param dynamicQuery the dynamic query
159 | * @return the number of rows matching the dynamic query
160 | */
161 | @Override
162 | public long dynamicQueryCount(
163 | com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery) {
164 |
165 | return _bookLocalService.dynamicQueryCount(dynamicQuery);
166 | }
167 |
168 | /**
169 | * Returns the number of rows matching the dynamic query.
170 | *
171 | * @param dynamicQuery the dynamic query
172 | * @param projection the projection to apply to the query
173 | * @return the number of rows matching the dynamic query
174 | */
175 | @Override
176 | public long dynamicQueryCount(
177 | com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery,
178 | com.liferay.portal.kernel.dao.orm.Projection projection) {
179 |
180 | return _bookLocalService.dynamicQueryCount(dynamicQuery, projection);
181 | }
182 |
183 | @Override
184 | public book.model.Book fetchBook(String isbn) {
185 | return _bookLocalService.fetchBook(isbn);
186 | }
187 |
188 | /**
189 | * Returns the book with the primary key.
190 | *
191 | * @param isbn the primary key of the book
192 | * @return the book
193 | * @throws PortalException if a book with the primary key could not be found
194 | */
195 | @Override
196 | public book.model.Book getBook(String isbn)
197 | throws com.liferay.portal.kernel.exception.PortalException {
198 |
199 | return _bookLocalService.getBook(isbn);
200 | }
201 |
202 | /**
203 | * Returns a range of all the books.
204 | *
205 | *
206 | * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from book.model.impl.BookModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
207 | *
208 | *
209 | * @param start the lower bound of the range of books
210 | * @param end the upper bound of the range of books (not inclusive)
211 | * @return the range of books
212 | */
213 | @Override
214 | public java.util.List getBooks(int start, int end) {
215 | return _bookLocalService.getBooks(start, end);
216 | }
217 |
218 | /**
219 | * Returns the number of books.
220 | *
221 | * @return the number of books
222 | */
223 | @Override
224 | public int getBooksCount() {
225 | return _bookLocalService.getBooksCount();
226 | }
227 |
228 | /**
229 | * Returns the OSGi service identifier.
230 | *
231 | * @return the OSGi service identifier
232 | */
233 | @Override
234 | public String getOSGiServiceIdentifier() {
235 | return _bookLocalService.getOSGiServiceIdentifier();
236 | }
237 |
238 | @Override
239 | public com.liferay.portal.kernel.model.PersistedModel getPersistedModel(
240 | java.io.Serializable primaryKeyObj)
241 | throws com.liferay.portal.kernel.exception.PortalException {
242 |
243 | return _bookLocalService.getPersistedModel(primaryKeyObj);
244 | }
245 |
246 | /**
247 | * Updates the book in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
248 | *
249 | * @param book the book
250 | * @return the book that was updated
251 | */
252 | @Override
253 | public book.model.Book updateBook(book.model.Book book) {
254 | return _bookLocalService.updateBook(book);
255 | }
256 |
257 | @Override
258 | public BookLocalService getWrappedService() {
259 | return _bookLocalService;
260 | }
261 |
262 | @Override
263 | public void setWrappedService(BookLocalService bookLocalService) {
264 | _bookLocalService = bookLocalService;
265 | }
266 |
267 | private BookLocalService _bookLocalService;
268 |
269 | }
--------------------------------------------------------------------------------
/modules/book/book-service/bnd.bnd:
--------------------------------------------------------------------------------
1 | Bundle-Name: book-service
2 | Bundle-SymbolicName: book.service
3 | Bundle-Version: 1.0.0
4 | Liferay-Require-SchemaVersion: 1.0.0
5 | Liferay-Service: true
6 | -dsannotations-options: inherit
7 | -includeresource: META-INF/service.xml=service.xml
8 | -liferay-service-xml: META-INF/service.xml
9 | -plugin.service: com.liferay.ant.bnd.service.ServiceAnalyzerPlugin
10 |
--------------------------------------------------------------------------------
/modules/book/book-service/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 | 4.0.0
9 | book-service
10 | 1.0.0
11 |
12 | book
13 | book
14 | 1.0.0
15 |
16 |
17 |
18 | com.liferay
19 | com.liferay.petra.lang
20 | 3.0.0
21 | provided
22 |
23 |
24 | com.liferay
25 | com.liferay.petra.string
26 | 3.0.0
27 | provided
28 |
29 |
30 | com.liferay
31 | com.liferay.portal.aop.api
32 | 1.0.0
33 | provided
34 |
35 |
36 | com.liferay.portal
37 | com.liferay.portal.kernel
38 | 4.4.0
39 | provided
40 |
41 |
42 | org.osgi
43 | org.osgi.annotation.versioning
44 | 1.1.0
45 | provided
46 |
47 |
48 | org.osgi
49 | org.osgi.core
50 | 6.0.0
51 | provided
52 |
53 |
54 | org.osgi
55 | org.osgi.service.component.annotations
56 | 1.3.0
57 | provided
58 |
59 |
60 | book
61 | book-api
62 | 1.0.0
63 |
64 |
65 |
66 |
67 |
68 | com.liferay
69 | com.liferay.portal.tools.service.builder
70 | 1.0.290
71 |
72 | ../book-api/src/main/java
73 | true
74 | true
75 | src/main/resources/META-INF/module-hbm.xml
76 | src/main/java
77 | src/main/resources/META-INF/portlet-model-hints.xml
78 | src/main/resources/META-INF/portlet-model-hints.xml
79 | true
80 | book.service.util.ServiceProps
81 | src/main/resources
82 | src/main/resources/META-INF/sql
83 | tables.sql
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/modules/book/book-service/service.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | BOOK
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/modules/book/book-service/src/main/java/book/model/impl/BookBaseImpl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU Lesser General Public License as published by the Free
6 | * Software Foundation; either version 2.1 of the License, or (at your option)
7 | * any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 | * details.
13 | */
14 |
15 | package book.model.impl;
16 |
17 | import book.model.Book;
18 |
19 | import book.service.BookLocalServiceUtil;
20 |
21 | import org.osgi.annotation.versioning.ProviderType;
22 |
23 | /**
24 | * The extended model base implementation for the Book service. Represents a row in the "BOOK_Book" database table, with each column mapped to a property of this class.
25 | *
26 | *
27 | * This class exists only as a container for the default extended model level methods generated by ServiceBuilder. Helper methods and all application logic should be put in {@link BookImpl}.
28 | *
29 | *
30 | * @author Brian Wing Shun Chan
31 | * @see BookImpl
32 | * @see Book
33 | * @generated
34 | */
35 | @ProviderType
36 | public abstract class BookBaseImpl extends BookModelImpl implements Book {
37 |
38 | /*
39 | * NOTE FOR DEVELOPERS:
40 | *
41 | * Never modify or reference this class directly. All methods that expect a book model instance should use the Book interface instead.
42 | */
43 | @Override
44 | public void persist() {
45 | if (this.isNew()) {
46 | BookLocalServiceUtil.addBook(this);
47 | }
48 | else {
49 | BookLocalServiceUtil.updateBook(this);
50 | }
51 | }
52 |
53 | }
--------------------------------------------------------------------------------
/modules/book/book-service/src/main/java/book/model/impl/BookCacheModel.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU Lesser General Public License as published by the Free
6 | * Software Foundation; either version 2.1 of the License, or (at your option)
7 | * any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 | * details.
13 | */
14 |
15 | package book.model.impl;
16 |
17 | import book.model.Book;
18 |
19 | import com.liferay.petra.lang.HashUtil;
20 | import com.liferay.petra.string.StringBundler;
21 | import com.liferay.portal.kernel.model.CacheModel;
22 |
23 | import java.io.Externalizable;
24 | import java.io.IOException;
25 | import java.io.ObjectInput;
26 | import java.io.ObjectOutput;
27 |
28 | import org.osgi.annotation.versioning.ProviderType;
29 |
30 | /**
31 | * The cache model class for representing Book in entity cache.
32 | *
33 | * @author Brian Wing Shun Chan
34 | * @generated
35 | */
36 | @ProviderType
37 | public class BookCacheModel implements CacheModel, Externalizable {
38 |
39 | @Override
40 | public boolean equals(Object obj) {
41 | if (this == obj) {
42 | return true;
43 | }
44 |
45 | if (!(obj instanceof BookCacheModel)) {
46 | return false;
47 | }
48 |
49 | BookCacheModel bookCacheModel = (BookCacheModel)obj;
50 |
51 | if (isbn.equals(bookCacheModel.isbn)) {
52 | return true;
53 | }
54 |
55 | return false;
56 | }
57 |
58 | @Override
59 | public int hashCode() {
60 | return HashUtil.hash(0, isbn);
61 | }
62 |
63 | @Override
64 | public String toString() {
65 | StringBundler sb = new StringBundler(9);
66 |
67 | sb.append("{uuid=");
68 | sb.append(uuid);
69 | sb.append(", isbn=");
70 | sb.append(isbn);
71 | sb.append(", title=");
72 | sb.append(title);
73 | sb.append(", author=");
74 | sb.append(author);
75 | sb.append("}");
76 |
77 | return sb.toString();
78 | }
79 |
80 | @Override
81 | public Book toEntityModel() {
82 | BookImpl bookImpl = new BookImpl();
83 |
84 | if (uuid == null) {
85 | bookImpl.setUuid("");
86 | }
87 | else {
88 | bookImpl.setUuid(uuid);
89 | }
90 |
91 | if (isbn == null) {
92 | bookImpl.setIsbn("");
93 | }
94 | else {
95 | bookImpl.setIsbn(isbn);
96 | }
97 |
98 | if (title == null) {
99 | bookImpl.setTitle("");
100 | }
101 | else {
102 | bookImpl.setTitle(title);
103 | }
104 |
105 | if (author == null) {
106 | bookImpl.setAuthor("");
107 | }
108 | else {
109 | bookImpl.setAuthor(author);
110 | }
111 |
112 | bookImpl.resetOriginalValues();
113 |
114 | return bookImpl;
115 | }
116 |
117 | @Override
118 | public void readExternal(ObjectInput objectInput) throws IOException {
119 | uuid = objectInput.readUTF();
120 | isbn = objectInput.readUTF();
121 | title = objectInput.readUTF();
122 | author = objectInput.readUTF();
123 | }
124 |
125 | @Override
126 | public void writeExternal(ObjectOutput objectOutput) throws IOException {
127 | if (uuid == null) {
128 | objectOutput.writeUTF("");
129 | }
130 | else {
131 | objectOutput.writeUTF(uuid);
132 | }
133 |
134 | if (isbn == null) {
135 | objectOutput.writeUTF("");
136 | }
137 | else {
138 | objectOutput.writeUTF(isbn);
139 | }
140 |
141 | if (title == null) {
142 | objectOutput.writeUTF("");
143 | }
144 | else {
145 | objectOutput.writeUTF(title);
146 | }
147 |
148 | if (author == null) {
149 | objectOutput.writeUTF("");
150 | }
151 | else {
152 | objectOutput.writeUTF(author);
153 | }
154 | }
155 |
156 | public String uuid;
157 | public String isbn;
158 | public String title;
159 | public String author;
160 |
161 | }
--------------------------------------------------------------------------------
/modules/book/book-service/src/main/java/book/model/impl/BookImpl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU Lesser General Public License as published by the Free
6 | * Software Foundation; either version 2.1 of the License, or (at your option)
7 | * any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 | * details.
13 | */
14 |
15 | package book.model.impl;
16 |
17 | import org.osgi.annotation.versioning.ProviderType;
18 |
19 | /**
20 | * The extended model implementation for the Book service. Represents a row in the "BOOK_Book" database table, with each column mapped to a property of this class.
21 | *
22 | *
23 | * Helper methods and all application logic should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy their definitions into the book.model.Book interface.
24 | *
25 | *
26 | * @author Brian Wing Shun Chan
27 | */
28 | @ProviderType
29 | public class BookImpl extends BookBaseImpl {
30 |
31 | /*
32 | * NOTE FOR DEVELOPERS:
33 | *
34 | * Never reference this class directly. All methods that expect a book model instance should use the {@link book.model.Book} interface instead.
35 | */
36 | public BookImpl() {
37 | }
38 |
39 | }
--------------------------------------------------------------------------------
/modules/book/book-service/src/main/java/book/service/base/BookLocalServiceBaseImpl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU Lesser General Public License as published by the Free
6 | * Software Foundation; either version 2.1 of the License, or (at your option)
7 | * any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 | * details.
13 | */
14 |
15 | package book.service.base;
16 |
17 | import book.model.Book;
18 |
19 | import book.service.BookLocalService;
20 | import book.service.persistence.BookPersistence;
21 |
22 | import com.liferay.portal.aop.AopService;
23 | import com.liferay.portal.kernel.dao.db.DB;
24 | import com.liferay.portal.kernel.dao.db.DBManagerUtil;
25 | import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
26 | import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
27 | import com.liferay.portal.kernel.dao.orm.DynamicQuery;
28 | import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
29 | import com.liferay.portal.kernel.dao.orm.Projection;
30 | import com.liferay.portal.kernel.exception.PortalException;
31 | import com.liferay.portal.kernel.exception.SystemException;
32 | import com.liferay.portal.kernel.model.PersistedModel;
33 | import com.liferay.portal.kernel.module.framework.service.IdentifiableOSGiService;
34 | import com.liferay.portal.kernel.search.Indexable;
35 | import com.liferay.portal.kernel.search.IndexableType;
36 | import com.liferay.portal.kernel.service.BaseLocalServiceImpl;
37 | import com.liferay.portal.kernel.service.PersistedModelLocalService;
38 | import com.liferay.portal.kernel.transaction.Transactional;
39 | import com.liferay.portal.kernel.util.OrderByComparator;
40 | import com.liferay.portal.kernel.util.PortalUtil;
41 |
42 | import java.io.Serializable;
43 |
44 | import java.util.List;
45 |
46 | import javax.sql.DataSource;
47 |
48 | import org.osgi.annotation.versioning.ProviderType;
49 | import org.osgi.service.component.annotations.Reference;
50 |
51 | /**
52 | * Provides the base implementation for the book local service.
53 | *
54 | *
55 | * This implementation exists only as a container for the default service methods generated by ServiceBuilder. All custom service methods should be put in {@link book.service.impl.BookLocalServiceImpl}.
56 | *
57 | *
58 | * @author Brian Wing Shun Chan
59 | * @see book.service.impl.BookLocalServiceImpl
60 | * @generated
61 | */
62 | @ProviderType
63 | public abstract class BookLocalServiceBaseImpl
64 | extends BaseLocalServiceImpl
65 | implements BookLocalService, AopService, IdentifiableOSGiService {
66 |
67 | /*
68 | * NOTE FOR DEVELOPERS:
69 | *
70 | * Never modify or reference this class directly. Use BookLocalService via injection or a org.osgi.util.tracker.ServiceTracker or use book.service.BookLocalServiceUtil.
71 | */
72 |
73 | /**
74 | * Adds the book to the database. Also notifies the appropriate model listeners.
75 | *
76 | * @param book the book
77 | * @return the book that was added
78 | */
79 | @Indexable(type = IndexableType.REINDEX)
80 | @Override
81 | public Book addBook(Book book) {
82 | book.setNew(true);
83 |
84 | return bookPersistence.update(book);
85 | }
86 |
87 | /**
88 | * Creates a new book with the primary key. Does not add the book to the database.
89 | *
90 | * @param isbn the primary key for the new book
91 | * @return the new book
92 | */
93 | @Override
94 | @Transactional(enabled = false)
95 | public Book createBook(String isbn) {
96 | return bookPersistence.create(isbn);
97 | }
98 |
99 | /**
100 | * Deletes the book with the primary key from the database. Also notifies the appropriate model listeners.
101 | *
102 | * @param isbn the primary key of the book
103 | * @return the book that was removed
104 | * @throws PortalException if a book with the primary key could not be found
105 | */
106 | @Indexable(type = IndexableType.DELETE)
107 | @Override
108 | public Book deleteBook(String isbn) throws PortalException {
109 | return bookPersistence.remove(isbn);
110 | }
111 |
112 | /**
113 | * Deletes the book from the database. Also notifies the appropriate model listeners.
114 | *
115 | * @param book the book
116 | * @return the book that was removed
117 | */
118 | @Indexable(type = IndexableType.DELETE)
119 | @Override
120 | public Book deleteBook(Book book) {
121 | return bookPersistence.remove(book);
122 | }
123 |
124 | @Override
125 | public DynamicQuery dynamicQuery() {
126 | Class> clazz = getClass();
127 |
128 | return DynamicQueryFactoryUtil.forClass(
129 | Book.class, clazz.getClassLoader());
130 | }
131 |
132 | /**
133 | * Performs a dynamic query on the database and returns the matching rows.
134 | *
135 | * @param dynamicQuery the dynamic query
136 | * @return the matching rows
137 | */
138 | @Override
139 | public List dynamicQuery(DynamicQuery dynamicQuery) {
140 | return bookPersistence.findWithDynamicQuery(dynamicQuery);
141 | }
142 |
143 | /**
144 | * Performs a dynamic query on the database and returns a range of the matching rows.
145 | *
146 | *
147 | * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from book.model.impl.BookModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
148 | *
149 | *
150 | * @param dynamicQuery the dynamic query
151 | * @param start the lower bound of the range of model instances
152 | * @param end the upper bound of the range of model instances (not inclusive)
153 | * @return the range of matching rows
154 | */
155 | @Override
156 | public List dynamicQuery(
157 | DynamicQuery dynamicQuery, int start, int end) {
158 |
159 | return bookPersistence.findWithDynamicQuery(dynamicQuery, start, end);
160 | }
161 |
162 | /**
163 | * Performs a dynamic query on the database and returns an ordered range of the matching rows.
164 | *
165 | *
166 | * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from book.model.impl.BookModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
167 | *
168 | *
169 | * @param dynamicQuery the dynamic query
170 | * @param start the lower bound of the range of model instances
171 | * @param end the upper bound of the range of model instances (not inclusive)
172 | * @param orderByComparator the comparator to order the results by (optionally null)
173 | * @return the ordered range of matching rows
174 | */
175 | @Override
176 | public List dynamicQuery(
177 | DynamicQuery dynamicQuery, int start, int end,
178 | OrderByComparator orderByComparator) {
179 |
180 | return bookPersistence.findWithDynamicQuery(
181 | dynamicQuery, start, end, orderByComparator);
182 | }
183 |
184 | /**
185 | * Returns the number of rows matching the dynamic query.
186 | *
187 | * @param dynamicQuery the dynamic query
188 | * @return the number of rows matching the dynamic query
189 | */
190 | @Override
191 | public long dynamicQueryCount(DynamicQuery dynamicQuery) {
192 | return bookPersistence.countWithDynamicQuery(dynamicQuery);
193 | }
194 |
195 | /**
196 | * Returns the number of rows matching the dynamic query.
197 | *
198 | * @param dynamicQuery the dynamic query
199 | * @param projection the projection to apply to the query
200 | * @return the number of rows matching the dynamic query
201 | */
202 | @Override
203 | public long dynamicQueryCount(
204 | DynamicQuery dynamicQuery, Projection projection) {
205 |
206 | return bookPersistence.countWithDynamicQuery(dynamicQuery, projection);
207 | }
208 |
209 | @Override
210 | public Book fetchBook(String isbn) {
211 | return bookPersistence.fetchByPrimaryKey(isbn);
212 | }
213 |
214 | /**
215 | * Returns the book with the primary key.
216 | *
217 | * @param isbn the primary key of the book
218 | * @return the book
219 | * @throws PortalException if a book with the primary key could not be found
220 | */
221 | @Override
222 | public Book getBook(String isbn) throws PortalException {
223 | return bookPersistence.findByPrimaryKey(isbn);
224 | }
225 |
226 | /**
227 | * @throws PortalException
228 | */
229 | @Override
230 | public PersistedModel deletePersistedModel(PersistedModel persistedModel)
231 | throws PortalException {
232 |
233 | return bookLocalService.deleteBook((Book)persistedModel);
234 | }
235 |
236 | @Override
237 | public PersistedModel getPersistedModel(Serializable primaryKeyObj)
238 | throws PortalException {
239 |
240 | return bookPersistence.findByPrimaryKey(primaryKeyObj);
241 | }
242 |
243 | /**
244 | * Returns a range of all the books.
245 | *
246 | *
247 | * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from book.model.impl.BookModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
248 | *
249 | *
250 | * @param start the lower bound of the range of books
251 | * @param end the upper bound of the range of books (not inclusive)
252 | * @return the range of books
253 | */
254 | @Override
255 | public List getBooks(int start, int end) {
256 | return bookPersistence.findAll(start, end);
257 | }
258 |
259 | /**
260 | * Returns the number of books.
261 | *
262 | * @return the number of books
263 | */
264 | @Override
265 | public int getBooksCount() {
266 | return bookPersistence.countAll();
267 | }
268 |
269 | /**
270 | * Updates the book in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
271 | *
272 | * @param book the book
273 | * @return the book that was updated
274 | */
275 | @Indexable(type = IndexableType.REINDEX)
276 | @Override
277 | public Book updateBook(Book book) {
278 | return bookPersistence.update(book);
279 | }
280 |
281 | @Override
282 | public Class>[] getAopInterfaces() {
283 | return new Class>[] {
284 | BookLocalService.class, IdentifiableOSGiService.class,
285 | PersistedModelLocalService.class
286 | };
287 | }
288 |
289 | @Override
290 | public void setAopProxy(Object aopProxy) {
291 | bookLocalService = (BookLocalService)aopProxy;
292 | }
293 |
294 | /**
295 | * Returns the OSGi service identifier.
296 | *
297 | * @return the OSGi service identifier
298 | */
299 | @Override
300 | public String getOSGiServiceIdentifier() {
301 | return BookLocalService.class.getName();
302 | }
303 |
304 | protected Class> getModelClass() {
305 | return Book.class;
306 | }
307 |
308 | protected String getModelClassName() {
309 | return Book.class.getName();
310 | }
311 |
312 | /**
313 | * Performs a SQL query.
314 | *
315 | * @param sql the sql query
316 | */
317 | protected void runSQL(String sql) {
318 | try {
319 | DataSource dataSource = bookPersistence.getDataSource();
320 |
321 | DB db = DBManagerUtil.getDB();
322 |
323 | sql = db.buildSQL(sql);
324 | sql = PortalUtil.transformSQL(sql);
325 |
326 | SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(
327 | dataSource, sql);
328 |
329 | sqlUpdate.update();
330 | }
331 | catch (Exception e) {
332 | throw new SystemException(e);
333 | }
334 | }
335 |
336 | protected BookLocalService bookLocalService;
337 |
338 | @Reference
339 | protected BookPersistence bookPersistence;
340 |
341 | @Reference
342 | protected com.liferay.counter.kernel.service.CounterLocalService
343 | counterLocalService;
344 |
345 | @Reference
346 | protected com.liferay.portal.kernel.service.ClassNameLocalService
347 | classNameLocalService;
348 |
349 | @Reference
350 | protected com.liferay.portal.kernel.service.ResourceLocalService
351 | resourceLocalService;
352 |
353 | @Reference
354 | protected com.liferay.portal.kernel.service.UserLocalService
355 | userLocalService;
356 |
357 | }
--------------------------------------------------------------------------------
/modules/book/book-service/src/main/java/book/service/impl/BookLocalServiceImpl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU Lesser General Public License as published by the Free
6 | * Software Foundation; either version 2.1 of the License, or (at your option)
7 | * any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 | * details.
13 | */
14 |
15 | package book.service.impl;
16 |
17 | import book.service.base.BookLocalServiceBaseImpl;
18 |
19 | import com.liferay.portal.aop.AopService;
20 |
21 | import org.osgi.service.component.annotations.Component;
22 |
23 | /**
24 | * The implementation of the book local service.
25 | *
26 | *
27 | * All custom service methods should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy their definitions into the book.service.BookLocalService interface.
28 | *
29 | *
30 | * This is a local service. Methods of this service will not have security checks based on the propagated JAAS credentials because this service can only be accessed from within the same VM.
31 | *
32 | *
33 | * @author Brian Wing Shun Chan
34 | * @see BookLocalServiceBaseImpl
35 | */
36 | @Component(
37 | property = "model.class.name=book.model.Book", service = AopService.class
38 | )
39 | public class BookLocalServiceImpl extends BookLocalServiceBaseImpl {
40 |
41 | /*
42 | * NOTE FOR DEVELOPERS:
43 | *
44 | * Never reference this class directly. Use book.service.BookLocalService via injection or a org.osgi.util.tracker.ServiceTracker or use book.service.BookLocalServiceUtil.
45 | */
46 | }
--------------------------------------------------------------------------------
/modules/book/book-service/src/main/java/book/service/persistence/impl/constants/BOOKPersistenceConstants.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU Lesser General Public License as published by the Free
6 | * Software Foundation; either version 2.1 of the License, or (at your option)
7 | * any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 | * details.
13 | */
14 |
15 | package book.service.persistence.impl.constants;
16 |
17 | import com.liferay.petra.string.StringBundler;
18 |
19 | import org.osgi.framework.Bundle;
20 | import org.osgi.framework.BundleContext;
21 | import org.osgi.framework.Constants;
22 | import org.osgi.service.component.annotations.Activate;
23 | import org.osgi.service.component.annotations.Component;
24 |
25 | /**
26 | * @author Brian Wing Shun Chan
27 | * @generated
28 | */
29 | @Component(immediate = true, service = {})
30 | public class BOOKPersistenceConstants {
31 |
32 | public static final String BUNDLE_SYMBOLIC_NAME = "book.service";
33 |
34 | public static final String ORIGIN_BUNDLE_SYMBOLIC_NAME_FILTER =
35 | "(origin.bundle.symbolic.name=" + BUNDLE_SYMBOLIC_NAME + ")";
36 |
37 | @Activate
38 | protected void activate(BundleContext bundleContext) {
39 | Bundle bundle = bundleContext.getBundle();
40 |
41 | if (!BUNDLE_SYMBOLIC_NAME.equals(bundle.getSymbolicName())) {
42 | throw new IllegalStateException(
43 | StringBundler.concat(
44 | "Incorrect ", Constants.BUNDLE_SYMBOLICNAME, " for bundle ",
45 | bundle.getSymbolicName()));
46 | }
47 | }
48 |
49 | }
--------------------------------------------------------------------------------
/modules/book/book-service/src/main/resources/META-INF/module-hbm.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/modules/book/book-service/src/main/resources/META-INF/portlet-model-hints.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/modules/book/book-service/src/main/resources/META-INF/sql/indexes.sql:
--------------------------------------------------------------------------------
1 | create index IX_426B8FE4 on BOOK_Book (author[$COLUMN_LENGTH:75$]);
2 | create index IX_461D38C3 on BOOK_Book (title[$COLUMN_LENGTH:75$]);
3 | create index IX_8EDEDF6F on BOOK_Book (uuid_[$COLUMN_LENGTH:75$]);
--------------------------------------------------------------------------------
/modules/book/book-service/src/main/resources/META-INF/sql/sequences.sql:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kkaravitis/angular-spring-boot-portlets/596ece870bca43ae3713437d44456be8ed4484d0/modules/book/book-service/src/main/resources/META-INF/sql/sequences.sql
--------------------------------------------------------------------------------
/modules/book/book-service/src/main/resources/META-INF/sql/tables.sql:
--------------------------------------------------------------------------------
1 | create table BOOK_Book (
2 | uuid_ VARCHAR(750) null,
3 | isbn VARCHAR(750) not null primary key,
4 | title VARCHAR(750) null,
5 | author VARCHAR(750) null
6 | );
--------------------------------------------------------------------------------
/modules/book/book-service/src/main/resources/service.properties:
--------------------------------------------------------------------------------
1 | ##
2 | ## Properties Override
3 | ##
4 |
5 | #
6 | # Specify where to get the overridden properties. Updates should not be made
7 | # on this file but on the overridden version of this file.
8 | #
9 | include-and-override=service-ext.properties
10 |
11 | ##
12 | ## Build
13 | ##
14 |
15 | build.namespace=BOOK
16 | build.number=2
17 | build.date=1569885896232
--------------------------------------------------------------------------------
/modules/book/book-service/test/integration/book/service/persistence/test/BookPersistenceTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU Lesser General Public License as published by the Free
6 | * Software Foundation; either version 2.1 of the License, or (at your option)
7 | * any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 | * details.
13 | */
14 |
15 | package book.service.persistence.test;
16 |
17 | import book.exception.NoSuchBookException;
18 |
19 | import book.model.Book;
20 |
21 | import book.service.persistence.BookPersistence;
22 | import book.service.persistence.BookUtil;
23 |
24 | import com.liferay.arquillian.extension.junit.bridge.junit.Arquillian;
25 | import com.liferay.portal.kernel.dao.orm.DynamicQuery;
26 | import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
27 | import com.liferay.portal.kernel.dao.orm.ProjectionFactoryUtil;
28 | import com.liferay.portal.kernel.dao.orm.QueryUtil;
29 | import com.liferay.portal.kernel.dao.orm.RestrictionsFactoryUtil;
30 | import com.liferay.portal.kernel.test.rule.AggregateTestRule;
31 | import com.liferay.portal.kernel.test.util.RandomTestUtil;
32 | import com.liferay.portal.kernel.transaction.Propagation;
33 | import com.liferay.portal.kernel.util.OrderByComparator;
34 | import com.liferay.portal.kernel.util.OrderByComparatorFactoryUtil;
35 | import com.liferay.portal.test.rule.LiferayIntegrationTestRule;
36 | import com.liferay.portal.test.rule.PersistenceTestRule;
37 | import com.liferay.portal.test.rule.TransactionalTestRule;
38 |
39 | import java.io.Serializable;
40 |
41 | import java.util.ArrayList;
42 | import java.util.HashSet;
43 | import java.util.Iterator;
44 | import java.util.List;
45 | import java.util.Map;
46 | import java.util.Set;
47 |
48 | import org.junit.After;
49 | import org.junit.Assert;
50 | import org.junit.Before;
51 | import org.junit.ClassRule;
52 | import org.junit.Rule;
53 | import org.junit.Test;
54 | import org.junit.runner.RunWith;
55 |
56 | /**
57 | * @generated
58 | */
59 | @RunWith(Arquillian.class)
60 | public class BookPersistenceTest {
61 |
62 | @ClassRule
63 | @Rule
64 | public static final AggregateTestRule aggregateTestRule =
65 | new AggregateTestRule(
66 | new LiferayIntegrationTestRule(), PersistenceTestRule.INSTANCE,
67 | new TransactionalTestRule(Propagation.REQUIRED, "book.service"));
68 |
69 | @Before
70 | public void setUp() {
71 | _persistence = BookUtil.getPersistence();
72 |
73 | Class> clazz = _persistence.getClass();
74 |
75 | _dynamicQueryClassLoader = clazz.getClassLoader();
76 | }
77 |
78 | @After
79 | public void tearDown() throws Exception {
80 | Iterator iterator = _books.iterator();
81 |
82 | while (iterator.hasNext()) {
83 | _persistence.remove(iterator.next());
84 |
85 | iterator.remove();
86 | }
87 | }
88 |
89 | @Test
90 | public void testCreate() throws Exception {
91 | String pk = RandomTestUtil.randomString();
92 |
93 | Book book = _persistence.create(pk);
94 |
95 | Assert.assertNotNull(book);
96 |
97 | Assert.assertEquals(book.getPrimaryKey(), pk);
98 | }
99 |
100 | @Test
101 | public void testRemove() throws Exception {
102 | Book newBook = addBook();
103 |
104 | _persistence.remove(newBook);
105 |
106 | Book existingBook = _persistence.fetchByPrimaryKey(
107 | newBook.getPrimaryKey());
108 |
109 | Assert.assertNull(existingBook);
110 | }
111 |
112 | @Test
113 | public void testUpdateNew() throws Exception {
114 | addBook();
115 | }
116 |
117 | @Test
118 | public void testUpdateExisting() throws Exception {
119 | String pk = RandomTestUtil.randomString();
120 |
121 | Book newBook = _persistence.create(pk);
122 |
123 | newBook.setUuid(RandomTestUtil.randomString());
124 |
125 | newBook.setTitle(RandomTestUtil.randomString());
126 |
127 | newBook.setAuthor(RandomTestUtil.randomString());
128 |
129 | _books.add(_persistence.update(newBook));
130 |
131 | Book existingBook = _persistence.findByPrimaryKey(
132 | newBook.getPrimaryKey());
133 |
134 | Assert.assertEquals(existingBook.getUuid(), newBook.getUuid());
135 | Assert.assertEquals(existingBook.getIsbn(), newBook.getIsbn());
136 | Assert.assertEquals(existingBook.getTitle(), newBook.getTitle());
137 | Assert.assertEquals(existingBook.getAuthor(), newBook.getAuthor());
138 | }
139 |
140 | @Test
141 | public void testCountByUuid() throws Exception {
142 | _persistence.countByUuid("");
143 |
144 | _persistence.countByUuid("null");
145 |
146 | _persistence.countByUuid((String)null);
147 | }
148 |
149 | @Test
150 | public void testCountByAuthor() throws Exception {
151 | _persistence.countByAuthor("");
152 |
153 | _persistence.countByAuthor("null");
154 |
155 | _persistence.countByAuthor((String)null);
156 | }
157 |
158 | @Test
159 | public void testCountByTitle() throws Exception {
160 | _persistence.countByTitle("");
161 |
162 | _persistence.countByTitle("null");
163 |
164 | _persistence.countByTitle((String)null);
165 | }
166 |
167 | @Test
168 | public void testFindByPrimaryKeyExisting() throws Exception {
169 | Book newBook = addBook();
170 |
171 | Book existingBook = _persistence.findByPrimaryKey(
172 | newBook.getPrimaryKey());
173 |
174 | Assert.assertEquals(existingBook, newBook);
175 | }
176 |
177 | @Test(expected = NoSuchBookException.class)
178 | public void testFindByPrimaryKeyMissing() throws Exception {
179 | String pk = RandomTestUtil.randomString();
180 |
181 | _persistence.findByPrimaryKey(pk);
182 | }
183 |
184 | @Test
185 | public void testFindAll() throws Exception {
186 | _persistence.findAll(
187 | QueryUtil.ALL_POS, QueryUtil.ALL_POS, getOrderByComparator());
188 | }
189 |
190 | protected OrderByComparator getOrderByComparator() {
191 | return OrderByComparatorFactoryUtil.create(
192 | "BOOK_Book", "uuid", true, "isbn", true, "title", true, "author",
193 | true);
194 | }
195 |
196 | @Test
197 | public void testFetchByPrimaryKeyExisting() throws Exception {
198 | Book newBook = addBook();
199 |
200 | Book existingBook = _persistence.fetchByPrimaryKey(
201 | newBook.getPrimaryKey());
202 |
203 | Assert.assertEquals(existingBook, newBook);
204 | }
205 |
206 | @Test
207 | public void testFetchByPrimaryKeyMissing() throws Exception {
208 | String pk = RandomTestUtil.randomString();
209 |
210 | Book missingBook = _persistence.fetchByPrimaryKey(pk);
211 |
212 | Assert.assertNull(missingBook);
213 | }
214 |
215 | @Test
216 | public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereAllPrimaryKeysExist()
217 | throws Exception {
218 |
219 | Book newBook1 = addBook();
220 | Book newBook2 = addBook();
221 |
222 | Set primaryKeys = new HashSet();
223 |
224 | primaryKeys.add(newBook1.getPrimaryKey());
225 | primaryKeys.add(newBook2.getPrimaryKey());
226 |
227 | Map books = _persistence.fetchByPrimaryKeys(
228 | primaryKeys);
229 |
230 | Assert.assertEquals(2, books.size());
231 | Assert.assertEquals(newBook1, books.get(newBook1.getPrimaryKey()));
232 | Assert.assertEquals(newBook2, books.get(newBook2.getPrimaryKey()));
233 | }
234 |
235 | @Test
236 | public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereNoPrimaryKeysExist()
237 | throws Exception {
238 |
239 | String pk1 = RandomTestUtil.randomString();
240 |
241 | String pk2 = RandomTestUtil.randomString();
242 |
243 | Set primaryKeys = new HashSet();
244 |
245 | primaryKeys.add(pk1);
246 | primaryKeys.add(pk2);
247 |
248 | Map books = _persistence.fetchByPrimaryKeys(
249 | primaryKeys);
250 |
251 | Assert.assertTrue(books.isEmpty());
252 | }
253 |
254 | @Test
255 | public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist()
256 | throws Exception {
257 |
258 | Book newBook = addBook();
259 |
260 | String pk = RandomTestUtil.randomString();
261 |
262 | Set primaryKeys = new HashSet();
263 |
264 | primaryKeys.add(newBook.getPrimaryKey());
265 | primaryKeys.add(pk);
266 |
267 | Map books = _persistence.fetchByPrimaryKeys(
268 | primaryKeys);
269 |
270 | Assert.assertEquals(1, books.size());
271 | Assert.assertEquals(newBook, books.get(newBook.getPrimaryKey()));
272 | }
273 |
274 | @Test
275 | public void testFetchByPrimaryKeysWithNoPrimaryKeys() throws Exception {
276 | Set primaryKeys = new HashSet();
277 |
278 | Map books = _persistence.fetchByPrimaryKeys(
279 | primaryKeys);
280 |
281 | Assert.assertTrue(books.isEmpty());
282 | }
283 |
284 | @Test
285 | public void testFetchByPrimaryKeysWithOnePrimaryKey() throws Exception {
286 | Book newBook = addBook();
287 |
288 | Set primaryKeys = new HashSet();
289 |
290 | primaryKeys.add(newBook.getPrimaryKey());
291 |
292 | Map books = _persistence.fetchByPrimaryKeys(
293 | primaryKeys);
294 |
295 | Assert.assertEquals(1, books.size());
296 | Assert.assertEquals(newBook, books.get(newBook.getPrimaryKey()));
297 | }
298 |
299 | @Test
300 | public void testDynamicQueryByPrimaryKeyExisting() throws Exception {
301 | Book newBook = addBook();
302 |
303 | DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(
304 | Book.class, _dynamicQueryClassLoader);
305 |
306 | dynamicQuery.add(RestrictionsFactoryUtil.eq("isbn", newBook.getIsbn()));
307 |
308 | List result = _persistence.findWithDynamicQuery(dynamicQuery);
309 |
310 | Assert.assertEquals(1, result.size());
311 |
312 | Book existingBook = result.get(0);
313 |
314 | Assert.assertEquals(existingBook, newBook);
315 | }
316 |
317 | @Test
318 | public void testDynamicQueryByPrimaryKeyMissing() throws Exception {
319 | DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(
320 | Book.class, _dynamicQueryClassLoader);
321 |
322 | dynamicQuery.add(
323 | RestrictionsFactoryUtil.eq("isbn", RandomTestUtil.randomString()));
324 |
325 | List result = _persistence.findWithDynamicQuery(dynamicQuery);
326 |
327 | Assert.assertEquals(0, result.size());
328 | }
329 |
330 | @Test
331 | public void testDynamicQueryByProjectionExisting() throws Exception {
332 | Book newBook = addBook();
333 |
334 | DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(
335 | Book.class, _dynamicQueryClassLoader);
336 |
337 | dynamicQuery.setProjection(ProjectionFactoryUtil.property("isbn"));
338 |
339 | Object newIsbn = newBook.getIsbn();
340 |
341 | dynamicQuery.add(
342 | RestrictionsFactoryUtil.in("isbn", new Object[] {newIsbn}));
343 |
344 | List