Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimizing code repetitions in quickstart-generated folder by using Zontroy code generator #82

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# Celerio Angular Quickstart

[![Build Status](https://travis-ci.org/jaxio/celerio-angular-quickstart.svg?branch=master)](https://travis-ci.org/jaxio/celerio-angular-quickstart)
Expand Down Expand Up @@ -81,3 +82,16 @@ You may of course [report issues](https://github.com/jaxio/celerio-angular-quick
[Celerio]: https://github.com/jaxio/celerio
[Velocity]: http://velocity.apache.org/

# Code Generation
Zontroy Code Generator is used to add code generation templates to the project. By minimizing the parts prone to code repetition with Zontroy code generator, I reduced the complexity of the project and made it more user-friendly. I generated code using zsif, zref and ziref file types. When I wanted to produce more than one repeated folder, I used the ziref file type by taking entities from the mssql database. I used zsif to prevent code repetition in the same file, and zref to create different files suitable for code repetition. For more information you can visit https://zontroy.com/.
# Ziref:

![image](https://github.com/tolgahanipek/celerio-angular-quickstart/assets/69389540/0fd9577d-4deb-4982-a2ee-20950f3e5258)

# Zref:
![image](https://github.com/tolgahanipek/celerio-angular-quickstart/assets/69389540/6e6bbca5-62ce-42fc-bfad-f22ea9de79f7)

# Zsif:
![image](https://github.com/tolgahanipek/celerio-angular-quickstart/assets/69389540/0cd22459-c596-4260-90da-b5d1e63943a8)


Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Documentation: http://www.jaxio.com/documentation/celerio/
* Source code: https://github.com/jaxio/celerio/
* Follow us on twitter: @jaxiosoft
* This header can be customized in Celerio conf...
* This header can be customized in Celerio con
* Template pack-angular:src/main/java/repository/EntityRepository.java.e.vm
*/
package com.mycompany.myapp.repository;
Expand All @@ -23,14 +23,18 @@

public interface AuthorRepository extends JpaRepository<Author, Integer> {

default List<Author> complete(String query, int maxResults) {
default List<Author> complete(String query, int maxResults) {
Author probe = new Author();
probe.setLastName(query);

ExampleMatcher matcher = ExampleMatcher.matching() //
.withMatcher(Author_.lastName.getName(), match -> match.ignoreCase().startsWith());


probe.setLastName(query);
ExampleMatcher matcher = ExampleMatcher.matching() //
.withMatcher(Author_.lastname.getName(), match -> match.ignoreCase().startsWith());
Page<Author> page = findAll(Example.of(probe, matcher), new PageRequest(0, maxResults));
return page.getContent();


}


}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Documentation: http://www.jaxio.com/documentation/celerio/
* Source code: https://github.com/jaxio/celerio/
* Follow us on twitter: @jaxiosoft
* This header can be customized in Celerio conf...
* This header can be customized in Celerio con
* Template pack-angular:src/main/java/repository/EntityRepository.java.e.vm
*/
package com.mycompany.myapp.repository;
Expand All @@ -23,14 +23,18 @@

public interface BookRepository extends JpaRepository<Book, Integer> {

default List<Book> complete(String query, int maxResults) {
default List<Book> complete(String query, int maxResults) {
Book probe = new Book();
probe.setTitle(query);

ExampleMatcher matcher = ExampleMatcher.matching() //


probe.setTitle(query);
ExampleMatcher matcher = ExampleMatcher.matching() //
.withMatcher(Book_.title.getName(), match -> match.ignoreCase().startsWith());

Page<Book> page = findAll(Example.of(probe, matcher), new PageRequest(0, maxResults));
return page.getContent();


}


}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Documentation: http://www.jaxio.com/documentation/celerio/
* Source code: https://github.com/jaxio/celerio/
* Follow us on twitter: @jaxiosoft
* This header can be customized in Celerio conf...
* This header can be customized in Celerio con
* Template pack-angular:src/main/java/repository/EntityRepository.java.e.vm
*/
package com.mycompany.myapp.repository;
Expand All @@ -23,14 +23,18 @@

public interface PassportRepository extends JpaRepository<Passport, Integer> {

default List<Passport> complete(String query, int maxResults) {
default List<Passport> complete(String query, int maxResults) {
Passport probe = new Passport();
probe.setPassportNumber(query);

ExampleMatcher matcher = ExampleMatcher.matching() //
.withMatcher(Passport_.passportNumber.getName(), match -> match.ignoreCase().startsWith());


probe.setPassportNumber(query);
ExampleMatcher matcher = ExampleMatcher.matching() //
.withMatcher(Passport_.passportnumber.getName(), match -> match.ignoreCase().startsWith());
Page<Passport> page = findAll(Example.of(probe, matcher), new PageRequest(0, maxResults));
return page.getContent();


}


}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Documentation: http://www.jaxio.com/documentation/celerio/
* Source code: https://github.com/jaxio/celerio/
* Follow us on twitter: @jaxiosoft
* This header can be customized in Celerio conf...
* This header can be customized in Celerio con
* Template pack-angular:src/main/java/repository/EntityRepository.java.e.vm
*/
package com.mycompany.myapp.repository;
Expand All @@ -23,14 +23,18 @@

public interface ProjectRepository extends JpaRepository<Project, Integer> {

default List<Project> complete(String query, int maxResults) {
default List<Project> complete(String query, int maxResults) {
Project probe = new Project();
probe.setName(query);

ExampleMatcher matcher = ExampleMatcher.matching() //


probe.setName(query);
ExampleMatcher matcher = ExampleMatcher.matching() //
.withMatcher(Project_.name.getName(), match -> match.ignoreCase().startsWith());

Page<Project> page = findAll(Example.of(probe, matcher), new PageRequest(0, maxResults));
return page.getContent();


}


}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Documentation: http://www.jaxio.com/documentation/celerio/
* Source code: https://github.com/jaxio/celerio/
* Follow us on twitter: @jaxiosoft
* This header can be customized in Celerio conf...
* This header can be customized in Celerio con
* Template pack-angular:src/main/java/repository/EntityRepository.java.e.vm
*/
package com.mycompany.myapp.repository;
Expand All @@ -22,24 +22,21 @@
import com.mycompany.myapp.domain.Role_;

public interface RoleRepository extends JpaRepository<Role, Integer> {

Role getByRoleName(String roleName); // added

/**
* Return the persistent instance of {@link Role} with the given unique property value roleName,
* or null if there is no such persistent instance.
*
* @param roleName the unique value
* @return the corresponding {@link Role} persistent instance or null
*/
Role getByRoleName(String roleName);

default List<Role> complete(String query, int maxResults) {
default List<Role> complete(String query, int maxResults) {
Role probe = new Role();
probe.setRoleName(query);

ExampleMatcher matcher = ExampleMatcher.matching() //
.withMatcher(Role_.roleName.getName(), match -> match.ignoreCase().startsWith());


probe.setRoleName(query);
ExampleMatcher matcher = ExampleMatcher.matching() //
.withMatcher(Role_.rolename.getName(), match -> match.ignoreCase().startsWith());
Page<Role> page = findAll(Example.of(probe, matcher), new PageRequest(0, maxResults));
return page.getContent();


}


}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Documentation: http://www.jaxio.com/documentation/celerio/
* Source code: https://github.com/jaxio/celerio/
* Follow us on twitter: @jaxiosoft
* This header can be customized in Celerio conf...
* This header can be customized in Celerio con
* Template pack-angular:src/main/java/repository/EntityRepository.java.e.vm
*/
package com.mycompany.myapp.repository;
Expand Down Expand Up @@ -34,4 +34,4 @@ default List<UseCase1> complete(String query, int maxResults) {
Page<UseCase1> page = findAll(Example.of(probe, matcher), new PageRequest(0, maxResults));
return page.getContent();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Documentation: http://www.jaxio.com/documentation/celerio/
* Source code: https://github.com/jaxio/celerio/
* Follow us on twitter: @jaxiosoft
* This header can be customized in Celerio conf...
* This header can be customized in Celerio con
* Template pack-angular:src/main/java/repository/EntityRepository.java.e.vm
*/
package com.mycompany.myapp.repository;
Expand All @@ -21,7 +21,7 @@
import com.mycompany.myapp.domain.UseCase2;
import com.mycompany.myapp.domain.UseCase2_;

public interface UseCase2Repository extends JpaRepository<UseCase2, String> {
public interface UseCase2Repository extends JpaRepository<UseCase2, String // added string> {

default List<UseCase2> complete(String query, int maxResults) {
UseCase2 probe = new UseCase2();
Expand All @@ -33,4 +33,4 @@ default List<UseCase2> complete(String query, int maxResults) {
Page<UseCase2> page = findAll(Example.of(probe, matcher), new PageRequest(0, maxResults));
return page.getContent();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Documentation: http://www.jaxio.com/documentation/celerio/
* Source code: https://github.com/jaxio/celerio/
* Follow us on twitter: @jaxiosoft
* This header can be customized in Celerio conf...
* This header can be customized in Celerio con
* Template pack-angular:src/main/java/repository/EntityRepository.java.e.vm
*/
package com.mycompany.myapp.repository;
Expand Down Expand Up @@ -34,4 +34,4 @@ default List<UseCase3> complete(String query, int maxResults) {
Page<UseCase3> page = findAll(Example.of(probe, matcher), new PageRequest(0, maxResults));
return page.getContent();
}
}
}
Loading