<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: fastcode-inc</title>
    <description>The latest articles on DEV Community by fastcode-inc (@fastcodeinc).</description>
    <link>https://dev.to/fastcodeinc</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F450019%2F5a45961d-5bcc-4d04-83ec-99215557087e.png</url>
      <title>DEV Community: fastcode-inc</title>
      <link>https://dev.to/fastcodeinc</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/fastcodeinc"/>
    <language>en</language>
    <item>
      <title>Angular Material UI/Theme Builder</title>
      <dc:creator>fastcode-inc</dc:creator>
      <pubDate>Sat, 12 Feb 2022 16:29:28 +0000</pubDate>
      <link>https://dev.to/fastcodeinc/angular-material-uitheme-builder-45</link>
      <guid>https://dev.to/fastcodeinc/angular-material-uitheme-builder-45</guid>
      <description>&lt;p&gt;Over the past year, we have been developing a  drag-and-drop Angular Material UI/Theme Builder. The target audience is angular developers who already have experience with Google's Angular and Angular Material Components.&lt;/p&gt;

&lt;p&gt;The Angular Material UI/Theme builder is a What-You-See-Is-What-You-Get (WYSIWYG) drag-and-drop builder that allows angular developers to build reactive forms and views by dragging and dropping Google's Angular Material Components onto an Angular Flex layout. The properties, styles, and events of each component can be configured through panels and the builder generates all the code.&lt;/p&gt;

&lt;p&gt;The code that is being generated can be viewed through three tabs: (i) Markup tab for the HTML, (ii) Script tab for TypeScript and (iii) Styles tab for the CSS.&lt;/p&gt;

&lt;p&gt;The UI Builder also incorporates Angular Material Theme Builder that can be used to build a theme and apply the theme to the views you have built using the UI Builder.&lt;/p&gt;

&lt;p&gt;You can also bind the views/forms to static data or ReST-API based data sources.&lt;/p&gt;

&lt;p&gt;The Table UI Component in the Angular Material library is very basic and not sufficient for most applications. Therefore, in addition to the Angular Material Components, the builder also integrates ag-grid (&lt;a href="https://www.ag-grid.com"&gt;https://www.ag-grid.com&lt;/a&gt;) for Grid Control. &lt;/p&gt;

&lt;p&gt;The goal of this UI/Theme Builder is to reduce the time to develop a view by over 50%. Again, this UI/Theme Builder is targeted towards developers who already have experience with Angular and Angular Material.&lt;/p&gt;

&lt;p&gt;I am looking for the community feedback on whether or not you would use such a UI/Theme Builder. Secondly, would you be interested in trying the UI/Theme Builder and providing us feedback?&lt;/p&gt;

</description>
      <category>angular</category>
    </item>
    <item>
      <title>Build a Spring Boot ReST API</title>
      <dc:creator>fastcode-inc</dc:creator>
      <pubDate>Tue, 13 Apr 2021 20:30:59 +0000</pubDate>
      <link>https://dev.to/fastcodeinc/build-a-spring-boot-rest-api-1p8c</link>
      <guid>https://dev.to/fastcodeinc/build-a-spring-boot-rest-api-1p8c</guid>
      <description>&lt;p&gt;Welcome back! In the first blog article, we developed a simple Spring Boot application that prints “Hello World” to the console. In this article, we will build a ReST API that can be called by the API clients. &lt;/p&gt;

&lt;p&gt;In a typical Spring Boot application, you will have a relational database with a number of tables that are related to each other. In this article, to keep things simple, we will focus on an application with a single table. In the next article, we will extend this example to include multiple tables and their relationships.&lt;/p&gt;

&lt;p&gt;Let’s imagine that we are building a simple Timesheet application. &lt;br&gt;
This application allows employees to enter the hours they worked daily on different tasks and submit the timesheet every two weeks. &lt;/p&gt;

&lt;p&gt;In this article, we will focus on building a ReST API for just the Customer table.&lt;/p&gt;

&lt;p&gt;Let’s assume that the Customer table in the database includes the following fields:&lt;/p&gt;

&lt;p&gt;*customerid&lt;br&gt;
*name&lt;br&gt;
*description&lt;br&gt;
*isActive&lt;/p&gt;

&lt;p&gt;Our goal is to develop a ReST API that can be called to perform the following operations:&lt;/p&gt;

&lt;p&gt;*Create a new customer&lt;br&gt;
*Get a list of all the customers&lt;br&gt;
*Update an existing customer&lt;br&gt;
*Delete an existing customer&lt;/p&gt;

&lt;p&gt;The above operations are known as C.R.U.D (Create, Read, Update, Delete) operations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step-1&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;First, we need to understand some basic concepts on how we can manipulate the data in a database from a Java/Spring Boot application. This can be done either through JDBC (Java Database Connectivity) API that is a part of the Java Standard Edition or through JPA (Java Persistence API; now renamed to Jakarta Persistence) that is a part of the Java Enterprise Edition.&lt;/p&gt;

&lt;p&gt;The Spring framework provides further abstractions on these APIs to make it easier for developers to use these APIs.  In this article, we will focus on using JPA.&lt;/p&gt;

&lt;p&gt;JPA describes the management of relational data in enterprise Java applications. The &lt;a href="http://hibernate.org/orm/"&gt;Hibernate Object Relational Mapper (ORM)&lt;/a&gt; is one of the implementers of the Java Persistence API. In this application, we will be using Hibernate ORM and it’s JPA implementation.&lt;/p&gt;

&lt;p&gt;In JPA, a database table is represented as a Java Class. JPA provides a mechanism to persist objects of this Java class to the database table and the rows of the database table back to objects of this Java class. There are a number of rules that are defined by JPA on how an entity needs to be defined. According to the JPA 2.0 specification, these rules are as follows:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The class must be annotated with the @Entity (javax.persistence.Entity) annotation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Every entity class must have a primary key that uniquely identifies the entity. The primary key is annotated with &lt;a class="mentioned-user" href="https://dev.to/id"&gt;@id&lt;/a&gt;
 annotation&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The entity class must have a no-arg constructor. It may have other constructors as well. The no-arg constructor must be public or protected.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The entity class must be a top-level class. An enum or interface must not be designated as an entity.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The entity class must not be final. No methods or persistent instance variables of the entity class may be final.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Persistent instance variables must be declared private, protected, or package-private and can be accessed directly only by the entity class’s methods. Clients must access the entity’s state through accessor or business methods.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If an entity instance is to be passed by value as a detached object (e.g., through a remote interface), the entity class must implement the Serializable interface.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Both abstract and concrete classes can be entities. Entities may extend non-entity classes as well as entity classes, and non-entity classes may extend entity classes.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Using the rules above, let’s define our Customer entity as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.example.demo;

import javax.persistence.*;
import java.io.Serializable;

@Entity
@Table(name = "customer")
public class CustomerEntity implements Serializable {

   public CustomerEntity() {}

 @Id
 @GeneratedValue(strategy = GenerationType.IDENTITY)
 @Column(name = "customerid", nullable = false)
 private Long customerid;

 @Basic
 @Column(name = "name", nullable = true)
 private String name;

 @Basic
 @Column(name = "description", nullable = true)
 private String description;

 @Basic
 @Column(name = "isactive", nullable = true)
 private Boolean isActive;

 public Long getCustomerid() {
   return customerid;
 }

 public void setCustomerid(Long customerid) {
   this.customerid = customerid;
 }

 public String getName() {
   return name;
 }

 public void setName(String name) {
   this.name = name;
 }

 public String getDescription() {
   return description;
 }

 public void setDescription(String description) {
   this.description = description;
 }

 public Boolean getIsActive() {
   return isactive;
 }

 public void setIsActive(Boolean isactive) {
   this.isActive = isActive;
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Points to note&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The &lt;a class="mentioned-user" href="https://dev.to/id"&gt;@id&lt;/a&gt;
 annotation defines the primary key. We can generate the identifiers in different ways which are specified by the @GeneratedValue annotation. We can choose from the following Id generation strategies: AUTO, TABLE, SEQUENCE, or IDENTITY. If we don't specify a value explicitly, the generation type defaults to AUTO. When we use the IDENTITY generation type, the database auto-increments the Id values&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It is also important to understand the different access types in JPA. &lt;a href="https://howtodoinjava.com/jpa/field-vs-property-vs-mixed-access-modes-jpa-tutorial/"&gt;This article&lt;/a&gt; provides more information on the access types. In the customer entity above, we are using Field access type because we are declaring the &lt;a class="mentioned-user" href="https://dev.to/id"&gt;@id&lt;/a&gt;
 annotation on a field rather than on the get access method.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If we do not use the @Table annotation, the name of the entity will be considered the name of the table. In such cases, we can omit the @Table annotation. In most cases, the name of the table in the database and the name of the entity will not be the same. In these cases, we can specify the table name using the @Table annotation&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The attributes of the @Column annotation include it’s name, length, nullable, and unique. The name attribute specifies the name of the table column. The length attribute specifies the column length. The nullable attribute specifies whether or not the column is nullable, and the unique attribute specifies whether or not the column is unique. If we don't specify this annotation, the name of the field will be considered the name of the column in the table.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;JPA supports Java data types as persistable fields of an entity, often known as the basic types. A field or property can be marked with &lt;a class="mentioned-user" href="https://dev.to/basic"&gt;@basic&lt;/a&gt;
 annotation, which is optional. The &lt;a class="mentioned-user" href="https://dev.to/basic"&gt;@basic&lt;/a&gt;
 annotation has two attributes - optional (true, false) and fetch (EAGER, LAZY). By default, optional is set to true and fetch is set to EAGER loading. When optional is set to true, the field/property will accept null values. Lazy loading will only make sense when we have a large Serializable object mapped as a basic type. The JPA specification strictly limits the Java types that can be marked as basic to the following:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;Java primitive types (boolean, int, etc)&lt;br&gt;
wrappers for the primitive types (java.lang.Boolean, java.lang.Integer, etc)&lt;br&gt;
java.lang.String&lt;br&gt;
java.math.BigInteger&lt;br&gt;
java.math.BigDecimal&lt;br&gt;
java.util.Date&lt;br&gt;
java.util.Calendar&lt;br&gt;
java.sql.Date&lt;br&gt;
java.sql.Time&lt;br&gt;
java.sql.Timestamp&lt;br&gt;
byte[]&lt;br&gt;
Byte[]&lt;br&gt;
char[]&lt;br&gt;
Character[]&lt;br&gt;
enums&lt;br&gt;
any other type that implements Serializabl&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;N-layered Architecture&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To build a CRUD API for the Customer database table, we will be using a n-layered architecture. This architecture is not necessary for an application with a single database table, but becomes necessary as the number of tables increase and more business logic is added to the application.&lt;/p&gt;

&lt;p&gt;The diagram below shows the layers of this architecture:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0TtLB5bF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gtlywk96i4eearh763ao.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0TtLB5bF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gtlywk96i4eearh763ao.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Domain layer&lt;/strong&gt;: The domain layer consists of domain classes. In our sample CRUD application, these domain classes are equivalent to the JPA entity classes, which is a single class named CustomerEntity.java that we previously described.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Repository layer&lt;/strong&gt;: The repository layer in a Spring Boot application consists of &lt;a href="https://spring.io/projects/spring-data-jpa"&gt;Spring Data JPA&lt;/a&gt; repositories. Spring Boot makes it very simple to develop these repositories that can enable you to perform basic CRUD operations on an entity. Here’s the JPA repository for the customer entity:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Repository("customerRepository")
public interface ICustomerRepository extends JpaRepository&amp;lt;CustomerEntity, Long&amp;gt;{}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All we need to do to create a repository is to define an interface that extends the JpaRepository interface, passing in the name of the entity and the data type for the primary key of the entity.&lt;/p&gt;

&lt;p&gt;Spring Boot automatically provides an implementation class for this interface. All the methods specified in the JpaRepository interface &lt;a href="https://docs.spring.io/spring-data/jpa/docs/current/api/org/springframework/data/jpa/repository/JpaRepository.html"&gt;at this link&lt;/a&gt; are therefore available for us to use. Also note that this interface is annotated with @Repository interface. More details on this and other commonly used annotations can be found in &lt;a href="https://www.baeldung.com/spring-component-repository-service"&gt;this&lt;/a&gt; article.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Application Services layer&lt;/strong&gt;: This layer is used for two purposes: (a) provide transactional support and (b) convert from an entity to a Data Transfer Object (DTO) and vice-versa.&lt;/p&gt;

&lt;p&gt;An application transaction is a sequence of application actions that are considered a single logical unit by the application. For a more detailed explanation of Spring transactions, please refer to these &lt;a href="https://dzone.com/articles/spring-boot-transaction-management-hello-world-exa"&gt;series&lt;/a&gt; of posts and &lt;a href="https://www.nurkiewicz.com/2011/10/spring-pitfalls-proxying.html"&gt;this&lt;/a&gt; other post for an in-depth look at the pitfalls. &lt;/p&gt;

&lt;p&gt;DTOs are important for separation of concerns - separating what’s stored in the database from what’s returned to the client of the API. An entity stores what’s stored in the database, whereas a DTO stores what is returned back to the API client. For a more detailed explanation on why DTOs are necessary, please refer to &lt;a href="https://softwareengineering.stackexchange.com/questions/373284/what-is-the-use-of-dto-instead-of-entity"&gt;this&lt;/a&gt; post.&lt;/p&gt;

&lt;p&gt;Again sticking with the separation of concerns principle, we define both an interface and an implementation class in the Application Services layer for the customer entity. This layer will call the JPA repository layer we previously defined.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ICustomerAppService.java&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public interface ICustomerAppService {

//CRUD Operations
CreateCustomerOutput create(CreateCustomerInput customer);

void delete(Long id);

UpdateCustomerOutput update(Long id, UpdateCustomerInput input);

FindCustomerByIdOutput findById(Long id);

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;CustomerAppService.java&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Service("customerAppService")
public class CustomerAppService implements ICustomerAppService {

 @Qualifier("customerRepository")
 @NonNull
 protected final ICustomerRepository _customerRepository;

 @Qualifier("ICustomerMapperImpl")
 @NonNull
 protected final ICustomerMapper mapper;

 @NonNull
 protected final LoggingHelper logHelper;

 public CustomerAppService(@NonNull ICustomerRepository 
 _customerRepository, @NonNull ICustomerMapper mapper, 
 @NonNull LoggingHelper logHelper) {
 this._customerRepository = _customerRepository;
 this.mapper = mapper;
 this.logHelper = logHelper;
 }

 @Transactional(propagation = Propagation.REQUIRED)
 public CreateCustomerOutput create(CreateCustomerInput input) {

 CustomerEntity customer = mapper.createCustomerInputToCustomerEntity(input);
 CustomerEntity createdCustomer = _customerRepository.save(customer);
 return mapper.customerEntityToCreateCustomerOutput(createdCustomer);
 }

 @Transactional(propagation = Propagation.REQUIRED)
 public UpdateCustomerOutput update(Long customerId, 
 UpdateCustomerInput input) {

 CustomerEntity customer = mapper.updateCustomerInputToCustomerEntity(input);
 CustomerEntity updatedCustomer = _customerRepository.save(customer);
 return mapper.customerEntityToUpdateCustomerOutput(updatedCustomer);
 }

 @Transactional(propagation = Propagation.REQUIRED)
 public void delete(Long customerId) {

 CustomerEntity existing = _customerRepository.findById(customerId).orElse(null);
 _customerRepository.delete(existing);
 }

 @Transactional(propagation = Propagation.NOT_SUPPORTED)
 public FindCustomerByIdOutput findById(Long customerId) {

 CustomerEntity foundCustomer = _customerRepository.findById(customerId).orElse(null);
 if (foundCustomer == null) return null;
 return mapper.customerEntityToFindCustomerByIdOutput(foundCustomer);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Points to Note&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;CRUD methods are defined in the application service class&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The class is annotated with @Service annotation. To understand this annotation, please refer to &lt;a href="https://www.baeldung.com/spring-component-repository-service"&gt;this&lt;/a&gt; article.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The application service class depends on three other classes - Customer Repository, Customer Mapper, and Logging Helper. These dependencies are injected into the Application Service class using Spring Dependency Injection mechanism. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Spring allows us to inject dependencies using three methods - constructor-based injection, setter-based injection, or field-based injection. As explained in &lt;a href="https://reflectoring.io/constructor-injection/"&gt;this&lt;/a&gt; article, Constructor-based injection is the preferred way of injecting dependencies. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;In constructor-based injection, the dependencies required for the class are provided as arguments to the constructor as seen in the Application Service above.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;@Transactional annotation is used at a method-level on public methods&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We define and use the following DTOs. Every method, where appropriate, takes an input DTO and returns an output DTO&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;*CreateCustomerInput&lt;br&gt;
*CreateCustomerOutput&lt;br&gt;
*UpdateCustomerInput&lt;br&gt;
*UpdateCustomerOutput&lt;br&gt;
*FindCustomerByIdOutput&lt;/p&gt;

&lt;p&gt;We use a mapping library, &lt;a href="https://mapstruct.org/"&gt;MapStruct&lt;/a&gt;, to automatically map an entity to a DTO and vice-versa.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ReST Controller layer&lt;/strong&gt;: This layer is used to present an interface for clients that want to perform CRUD operations on the data on the database tables using http protocol. In our sample application, we have a single ReSTController because we have a single entity/table.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@RestController
@RequestMapping("/customer")
public class CustomerController {

 @Qualifier("customerAppService")
 @NonNull
 protected final ICustomerAppService _customerAppService;

 @Qualifier("projectAppService")
 @NonNull
 protected final IProjectAppService _projectAppService;

 @NonNull
 protected final LoggingHelper logHelper;

 @NonNull
 protected final Environment env;

 public CustomerController(@NonNull ICustomerAppService _customerAppService, @NonNull IProjectAppService 
 _projectAppService, @NonNull LoggingHelper logHelper, @NonNull Environment env) {
 this._customerAppService = _customerAppService;
 this._projectAppService = _projectAppService;
 this.logHelper = logHelper;
 this.env = env;
 }

 @RequestMapping(method = RequestMethod.POST, consumes = { "application/json" }, produces = { "application/json" })
 public ResponseEntity&amp;lt;CreateCustomerOutput&amp;gt; create(@RequestBody @Valid CreateCustomerInput customer) {
 CreateCustomerOutput output = _customerAppService.create(customer);
 return new ResponseEntity(output, HttpStatus.OK);
 }

 // ------------ Delete customer ------------
 @ResponseStatus(value = HttpStatus.NO_CONTENT)
 @RequestMapping(value = "/{id}", method = RequestMethod.DELETE, 
 consumes = { "application/json" })
 public void delete(@PathVariable String id) {
 FindCustomerByIdOutput output = _customerAppService.findById(Long.valueOf(id));
 Optional
 .ofNullable(output)
 .orElseThrow(
 () -&amp;gt; new EntityNotFoundException(String.format("There does not exist a customer with a id=%s", id))
 );

 _customerAppService.delete(Long.valueOf(id));
 }

 // ------------ Update customer ------------
 @RequestMapping(
 value = "/{id}",
 method = RequestMethod.PUT,
 consumes = { "application/json" },
 produces = { "application/json" }
 )

 public ResponseEntity&amp;lt;UpdateCustomerOutput&amp;gt; update(
 @PathVariable String id,
 @RequestBody @Valid UpdateCustomerInput customer
 ) {
 FindCustomerByIdOutput currentCustomer = _customerAppService.findById(Long.valueOf(id));
 Optional
 .ofNullable(currentCustomer)
 .orElseThrow(
 () -&amp;gt; new EntityNotFoundException(String.format("Unable to update. Customer with id=%s not found.", id))
 );

 customer.setVersiono(currentCustomer.getVersiono());
 UpdateCustomerOutput output = _customerAppService.update(Long.valueOf(id), customer);
 return new ResponseEntity(output, HttpStatus.OK);
 }

 @RequestMapping(
 value = "/{id}",
 method = RequestMethod.GET,
 consumes = { "application/json" },
 produces = { "application/json" }
 )
 public ResponseEntity&amp;lt;FindCustomerByIdOutput&amp;gt; findById(@PathVariable String id) {
 FindCustomerByIdOutput output = _customerAppService.findById(Long.valueOf(id));
 Optional.ofNullable(output).orElseThrow(() -&amp;gt; new EntityNotFoundException(String.format("Not found")));

 return new ResponseEntity(output, HttpStatus.OK);
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Points to Note&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;We are passing in the dependencies using Spring Constructor dependency injection&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Every ReST controller method has a @RequestMapping annotation, a method type, and the content-type the method consumes and produces. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Where we return back a response, we are using a ResponseEntity&lt;br&gt;
Although it’s not apparent from the code above, the incoming JSON content is translated into a Java object using the Jackson Mapping library&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this blog article, we have seen how to build a Spring Boot ReST API for a single table. However, in the real-world, an API will be built using multiple tables that are related to each other. In the next (third) blog article, we will discuss how we can handle multiple tables.&lt;/p&gt;

</description>
      <category>spring</category>
      <category>api</category>
      <category>java</category>
      <category>jpa</category>
    </item>
    <item>
      <title>Build a Spring Boot ReST API</title>
      <dc:creator>fastcode-inc</dc:creator>
      <pubDate>Tue, 13 Apr 2021 20:30:43 +0000</pubDate>
      <link>https://dev.to/fastcodeinc/build-a-spring-boot-rest-api-44c3</link>
      <guid>https://dev.to/fastcodeinc/build-a-spring-boot-rest-api-44c3</guid>
      <description>&lt;p&gt;In this blog article series, we will incrementally build a Spring Boot ReST API. We will start from scratch so that readers who are new to Spring Boot can easily follow along with us.&lt;/p&gt;

&lt;p&gt;In this first article, we will develop a simple Spring Boot application that prints “Hello World” to the console.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step-1&lt;/strong&gt;: &lt;/p&gt;

&lt;p&gt;Go to the Spring Initializr website (&lt;a href="https://start.spring.io/"&gt;https://start.spring.io/&lt;/a&gt;) and create/download a Spring Boot project.  Use the settings shown in the image below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step-2&lt;/strong&gt;: &lt;/p&gt;

&lt;p&gt;Unzip the zip file. The zip file will be unzipped into demo directory&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step-3&lt;/strong&gt;: &lt;/p&gt;

&lt;p&gt;Ensure that you have Maven and JDK 1.8 installed on your computer. Also ensure that you add them to your PATH so that you can access the commands &lt;strong&gt;java&lt;/strong&gt; and &lt;strong&gt;mvn&lt;/strong&gt; from your command window. &lt;/p&gt;

&lt;p&gt;You can get them from the following location:&lt;/p&gt;

&lt;p&gt;JDK 1.8: &lt;a href="https://adoptopenjdk.net/variant=openjdk8&amp;amp;jvmVariant=hotspot"&gt;https://adoptopenjdk.net/variant=openjdk8&amp;amp;jvmVariant=hotspot&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Maven: &lt;a href="https://maven.apache.org/download.cgi"&gt;https://maven.apache.org/download.cgi&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step-4&lt;/strong&gt;: &lt;/p&gt;

&lt;p&gt;From a command window, go to the directory demo, and compile and package the application using the following command:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;mvn clean package&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You will see that the application is compiled and a jar file named demo-0.0.1-SNAPSHOT.jar is created in a new directory named target.&lt;/p&gt;

&lt;p&gt;When you do a maven clean, this target directory (along with all the artifacts in this directory) is deleted. The maven package step both compiles the application and packages it in a jar file. To further understand the different maven lifecycle steps, please refer to this webpage.&lt;/p&gt;

&lt;p&gt;To run this application, execute the following command from the command line:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;java -jar target\demo-0.0.1-SNAPSHOT.jar&lt;/strong&gt; (if you are using windows) or &lt;strong&gt;java -jar target/demo-0.0.1-SNAPSHOT.jar&lt;/strong&gt; (if you are using Mac or Linux)&lt;/p&gt;

&lt;p&gt;This will run the application. However, this application does not do anything and therefore runs and exits.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step-5&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;Now let’s look at the only source file (*.java) we have in this application - DemoApplication.java which is located at demo/src/main/java/com/example/demo/DemoApplication.java.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class DemoApplication {

 public static void main(String[] args) {
     SpringApplication.run(DemoApplication.class, args);
  }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First, notice that there is a main method. This method doesn’t do anything except to run the application. Also, notice the @SpringBootApplication annotation on the class. This annotation is equivalent to three separate Spring Boot annotations:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;@SpringBootApplication = @Configuration + @ComponentScan + @EnableAutoConfiguration&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can learn what these annotations mean at the Spring website.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step-6&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;Now, let’s write a method that will print “Hello World!” to the console. Here we go:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class DemoApplication {

 public static void main(String[] args) {
     SpringApplication.run(DemoApplication.class, args);
 HelloWorld();
  }

 private static void HelloWorld() {
     System.out.println("Hello World!");
  }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice the method Hello() defined in the DemoApplication class. It’s defined as &lt;strong&gt;static&lt;/strong&gt; - otherwise, you will get the error “Non-static method 'HelloWorld()' cannot be referenced from a static context”.&lt;/p&gt;

&lt;p&gt;Now, you can re-run the maven command, &lt;strong&gt;mvn clean package&lt;/strong&gt;, and then run the program using &lt;strong&gt;java -jar target\demo-0.0.1-SNAPSHOT.jar&lt;/strong&gt; (if you are using windows) or &lt;strong&gt;java -jar target/demo-0.0.1-SNAPSHOT.jar&lt;/strong&gt; (if you are using Mac or Linux).&lt;/p&gt;

&lt;p&gt;You will see a message “Hello World!” printed to the console window.&lt;/p&gt;

&lt;p&gt;That’s all for this article. In the next article, we will extend this application and build an API that can be called from external systems.&lt;/p&gt;

</description>
      <category>springboot</category>
      <category>api</category>
      <category>java</category>
      <category>jpa</category>
    </item>
    <item>
      <title>Angular Low-code platform</title>
      <dc:creator>fastcode-inc</dc:creator>
      <pubDate>Sun, 16 Aug 2020 18:54:29 +0000</pubDate>
      <link>https://dev.to/fastcodeinc/angular-low-code-platform-62p</link>
      <guid>https://dev.to/fastcodeinc/angular-low-code-platform-62p</guid>
      <description>&lt;p&gt;A platform to reduce the time to develop enterprise-grade Angular &amp;amp; Spring Boot web apps by more than 50% - &lt;a href="https://www.getfastcode.com"&gt;https://www.getfastcode.com&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>angular</category>
    </item>
    <item>
      <title>Spring Boot Low-code platform</title>
      <dc:creator>fastcode-inc</dc:creator>
      <pubDate>Sun, 16 Aug 2020 18:24:36 +0000</pubDate>
      <link>https://dev.to/fastcodeinc/spring-boot-low-code-platform-252k</link>
      <guid>https://dev.to/fastcodeinc/spring-boot-low-code-platform-252k</guid>
      <description>&lt;p&gt;A platform to reduce the time to develop Spring Boot &amp;amp; Angular web apps by more than 50% - &lt;a href="https://www.getfastcode.com"&gt;https://www.getfastcode.com&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>spring</category>
    </item>
    <item>
      <title>Low-code platform startup - Request for feedback</title>
      <dc:creator>fastcode-inc</dc:creator>
      <pubDate>Sun, 16 Aug 2020 12:31:45 +0000</pubDate>
      <link>https://dev.to/fastcodeinc/low-code-platform-startup-request-for-feedback-261i</link>
      <guid>https://dev.to/fastcodeinc/low-code-platform-startup-request-for-feedback-261i</guid>
      <description>&lt;p&gt;Hello friends,&lt;/p&gt;

&lt;p&gt;We will be launching our startup &lt;a href="https://getfastCode.com"&gt;https://getfastCode.com&lt;/a&gt; in a couple of months. &lt;/p&gt;

&lt;p&gt;fastCode helps professional web app developers significantly reduce the time it takes to develop a web app. We are currently supporting Spring Boot on the back-end and Angular (and Angular Material) on the front-end. It's a free platform.&lt;/p&gt;

&lt;p&gt;I would love to get your feedback on whether you think that fastCode will be useful to you and for what use cases.&lt;/p&gt;

&lt;p&gt;Thank you very much for any feedback you can provide us.&lt;/p&gt;

</description>
      <category>showdev</category>
    </item>
    <item>
      <title>Low-code platforms &amp; Full-code developers - a match made in hell?</title>
      <dc:creator>fastcode-inc</dc:creator>
      <pubDate>Sun, 16 Aug 2020 12:08:32 +0000</pubDate>
      <link>https://dev.to/fastcodeinc/low-code-platforms-full-code-developers-a-match-made-in-hell-32ie</link>
      <guid>https://dev.to/fastcodeinc/low-code-platforms-full-code-developers-a-match-made-in-hell-32ie</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jod6etSl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/30f60vmjbqsvoxirxc2a.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jod6etSl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/30f60vmjbqsvoxirxc2a.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Developing enterprise-grade web apps from scratch using open-source front-end and backend frameworks takes a long time. Nowadays, customers are looking for quick and cost-effective solutions and are gravitating towards using no-code and low-code app development platforms. How can full-stack developers thrive in this new world of no-code and low-code platforms?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No-code and Low-code Platforms&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One purpose of these platforms is to increase the pool of available web app developers by tapping into the broader workforce of non-technical and semi-technical employees. Vendors have developed no-code platforms to be used by non-technical employees to build simple applications, and low-code platforms to be used by employees with basic technical skills (ex: SQL, JavaScript) to develop more complex enterprise applications. Secondly, these platforms can reduce web app development time by over 50% compared to the traditional web app development approach.&lt;/p&gt;

&lt;p&gt;Currently, there are a large number of vendors competing in the no-code and low-code market segments. No-code platform vendors include AppSheet (Google), Betty Blocks, QuickBase, Airtable, Bubble, and Microsoft PowerApps. Low-code platform vendors include Microsoft PowerApps, OutSystems, Mendix, Salesforce Lightning Platform, Nintex, Appian, and Pegasystems.&lt;/p&gt;

&lt;p&gt;We won’t discuss no-code platforms because they cater to non-technical users for developing simple apps. It’s unlikely that you, as a professional web app developer, will be asked to work on a no-code platform.&lt;/p&gt;

&lt;p&gt;Low-code platforms, on the other hand, are used to develop more complex apps. Building a web app using these low-code platforms has several disadvantages for a professional web developer who is used to developing apps using open-source front-end and back-end frameworks. Here is a blog post from a professional web app developer about his experiences working on one of these low-code platforms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem-1&lt;/strong&gt;: No control over source code&lt;/p&gt;

&lt;p&gt;Low-code platforms provide a visual metaphor to develop web apps. Even the app’s business logic is implemented by dragging and dropping code control statements such as if/then/else. Therefore, developers working on these platforms have little control over source code. Not having control over source code creates at least two issues: (a) It’s challenging to develop domain-driven apps with complex business logic, (b) debugging problems can be very difficult and frustrating.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem-2&lt;/strong&gt;: Limits career mobility&lt;/p&gt;

&lt;p&gt;Working full-time on a low-code platform can limit the career mobility of professional web app developers. They would lose their current technical skills in open programming languages and frameworks and gain skills in a proprietary low-code platform. Suppose this proprietary low-code platform is not widely adopted across employers, which is currently the case for any specific low-code platform. In that case, the developer’s low-code platform skills can only be used at another employer who has also adopted the same low-code platform. This severely limits the career mobility of the developer.&lt;/p&gt;

&lt;p&gt;Is there a better option? Yes. Why not build a low-code platform for professional web app developers that satisfies both the employers’ need for speed and developers’ needs for control and career mobility? We are calling such platforms as "open" low-code platforms. How do these platforms work? Read on …&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Generate Boilerplate Code&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When developing web applications, there is quite a bit of cut/paste/modify work.&lt;/p&gt;

&lt;p&gt;Most of the applications use an N-layered architecture. In this architecture, to provide a ReST API for the CRUD operations on a database table (entity), we need to develop code for the entity, the DAO (Data Access Object) layer, the services layer, and the ReST controller layer. Similarly, to create UI screens to allow end-users to perform CRUD operations, we need to develop UI components and a front-end services layer that interacts with the back-end ReST API. Once this work is completed for a single database table (entity), similar work must be repeated for each table of the database schema. &lt;/p&gt;

&lt;p&gt;Imagine having to do this for 50 database tables – this is tedious and error-prone work.&lt;/p&gt;

&lt;p&gt;A better approach would be to automate the generation of this boilerplate code. To automate, we can develop an application generator that reads the database schema and generates the back-end and front-end code to allow end-users to perform CRUD operations on database tables (entities).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Provide Add-ons for Common App Functionality&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Web applications have common functionality that repeats across applications. Examples of such common functionality include Authentication &amp;amp; Authorization, Document management, Transactional Emails, Jobs Scheduler, User Registration, and Embedded Reporting. Almost every web application I have been involved in developing required each of these capabilities. In each case, my development team reinvented the wheel and built these cross-cutting concerns from scratch because we never thought about building generic and customizable common functionality that can be used across web apps- what a waste of effort &amp;amp; time!&lt;/p&gt;

&lt;p&gt;If the base code for such common functionality was already built and available, we can re-use it and customized it as needed for each web application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Provide Visual Development Tools&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Developing enterprise applications involves developing custom functionality such as designing a database schema or domain model, building custom screens for non-CRUD operations, building enterprise-specific themes (colors, fonts), and developing integrations with external systems.&lt;/p&gt;

&lt;p&gt;Professional development teams can further reduce the application development time &amp;amp; cost by using visual development tools that accelerate the development of these custom functionality artifacts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Support Development Team’s Preferred Stack&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When developing enterprise applications, professional development teams have specific preferences over open technologies used, such as front-end and back-end frameworks, object-relational mapping tools, UI component frameworks, and dependency management systems. Specific technologies are preferred by teams either because they are the enterprise architecture standard or because most team members have experience using these technologies.&lt;/p&gt;

&lt;p&gt;By supporting the specific technologies chosen by development teams, open low-code platforms for professional developers can help and not reduce the acceleration of application development.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The approach mentioned above allows development teams to reduce the time to develop a web app by over 50%, similar to proprietary low-code platforms. Additionally, developers have full control over the source code, eliminating their inability to easily debug problems and develop domain-driven apps with complex business. Finally, developers use open technologies when developing web apps, eliminating the problem of limited career mobility.&lt;/p&gt;

&lt;p&gt;In summary, a low-code platform built for professional web app developers eliminates the disadvantages of proprietary low-code platforms while preserving their advantage of rapid app development.&lt;/p&gt;

</description>
      <category>lowcode</category>
      <category>angular</category>
      <category>java</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
