<commit_before><?php

$pageTitle = "Blog: Building a CRUD Application with ag-Grid Part 2";
$pageDescription = "Building a CRUD Application with ag-Grid Part 2";
$pageKeyboards = "ag-grid datagrid crud enterprise";

include('../includes/mediaHeader.php');
?>

<div class="row">
    <div class="col-sm-2" style="padding-top: 20px;">
        <img style="vertical-align: baseline;" src="../images/logo/SVG_ag_grid_bright-bg.svg" width="120px"/>
    </div>
    <div class="col-sm-10" style="padding-top: 40px;">
        <h1 style="margin-top: 0;">Building a CRUD Application with ag-Grid - Part 2</h1>
    </div>
    <div class="row" ng-app="documentation">
        <div class="col-md-9">

            <h2>Summary</h2>

            <p>In Part 2 of this Series, we go into more detail into the Middle Tier, exposing our data via a REST
                service.</p>

            <h2>Series Chapters</h2>

            <ul>
                <li><a href="../ag-grid-datagrid-crud-part-1/">Part 1</a>: Introduction & Initial Setup: Maven, Spring
                    and JPA/Backend (Database)
                </li>
                <li class="bold-roboto">Part 2: Middle Tier: Exposing our data with a REST Service</li>
                <li>Part 3: Front End - Initial Implementation</li>
                <li>Part 4: Front End - Grid Features & CRUD (Creation, Updates and Deletion)</li>
                <li>Part 5: Front End - Aggregation & Pivoting</li>
                <li>Part 6: Front End - Enterprise Row Model</li>
                <li>Part 7: Packaging (Optional)</li>
                <li>Part 8: Back End (Optional) - Using Oracle DB</li>
            </ul>

            <h2>Introduction</h2>

            <note>The completed code for this blog series can be found <a
                        href="https://github.com/seanlandsman/ag-grid-crud">here (once the series is complete)</a>,
                with this particular section being under <a
                        href="https://github.com/seanlandsman/ag-grid-crud/tree/part-2">Part
                    2</a></note>

            <p>
                In order for our data to be useful we need to make it available to users. One of hte easiest ways to do
                that
                is to expose it as a <a href="https://en.wikipedia.org/wiki/Representational_state_transfer">REST
                    Service</a>,
                which ties in nicely with CRUD operations - there is a one to one mapping with each of the Create,
                Retrieve, Update and Delete
                operations that CRUD specifies.
            </p>

            <p>We'll again make use of Spring to expose the data via a REST service. Again we do this using Spring as
                doing so by hand would be tedious and involve a great deal of boilerplate.</p>

            <h3>Rest Controllers</h3>

            <p>We can provide REST services via Rest Controllers. In most of the services we'll expose we'll generally
                just
                pass through to one of the methods provided by our <code>Repositories</code>. In a real world
                application you'd
                want to provide authentication of user requests and so on. </p>

            <p>To define a <code>RestController</code> all we need to do is annotate a class as follows:</p>

<snippet language="java">@RestController
public class AthleteController {
</snippet>

            <p>We want to return all the Olympic Data we have in the first pass and in order to do that we need to use
                our </code>AthleteRepository</p>. Let's create a constructor that will take this repository (Spring will
            automatically inject it for us) and create a method that uses it:<commit_msg>Changed blog<commit_after><?php

$pageTitle = "Blog: Building a CRUD Application with ag-Grid Part 2";
$pageDescription = "Building a CRUD Application with ag-Grid Part 2";
$pageKeyboards = "ag-grid datagrid crud enterprise";

include('../includes/mediaHeader.php');
?>

<div class="row">
    <div class="col-sm-2" style="padding-top: 20px;">
        <img style="vertical-align: baseline;" src="../images/logo/SVG_ag_grid_bright-bg.svg" width="120px"/>
    </div>
    <div class="col-sm-10" style="padding-top: 40px;">
        <h1 style="margin-top: 0;">Building a CRUD Application with ag-Grid - Part 2</h1>
    </div>
    <div class="row" ng-app="documentation">
        <div class="col-md-9">

            <h2>Summary</h2>

            <p>In Part 2 of this Series, we go into more detail into the Middle Tier, exposing our data via a REST
                service.</p>

            <h2>Series Chapters</h2>

            <ul>
                <li><a href="../ag-grid-datagrid-crud-part-1/">Part 1</a>: Introduction & Initial Setup: Maven, Spring
                    and JPA/Backend (Database)
                </li>
                <li class="bold-roboto">Part 2: Middle Tier: Exposing our data with a REST Service</li>
                <li>Part 3: Front End - Initial Implementation</li>
                <li>Part 4: Front End - Grid Features & CRUD (Creation, Updates and Deletion)</li>
                <li>Part 5: Front End - Aggregation & Pivoting</li>
                <li>Part 6: Front End - Enterprise Row Model</li>
                <li>Part 7: Packaging (Optional)</li>
                <li>Part 8: Back End (Optional) - Using Oracle DB</li>
            </ul>

            <h2>Introduction</h2>

            <note>The completed code for this blog series can be found <a
                        href="https://github.com/seanlandsman/ag-grid-crud">here (once the series is complete)</a>,
                with this particular section being under <a
                        href="https://github.com/seanlandsman/ag-grid-crud/tree/part-2">Part
                    2</a></note>

            <p>
                In order for our data to be useful we need to make it available to users. One of the easiest ways to do
                that
                is to expose it as a <a href="https://en.wikipedia.org/wiki/Representational_state_transfer">REST
                    Service</a>,
                which ties in nicely with CRUD operations - there is a one to one mapping with each of the Create,
                Retrieve, Update and Delete
                operations that CRUD specifies.
            </p>

            <p>We'll again make use of Spring to expose the data via a REST service. We do this using Spring, 
            doing so by hand would be tedious and involve a great deal of boilerplate.</p>

            <h3>Rest Controllers</h3>

            <p>We can provide REST services via Rest Controllers. In most of the services we'll expose we'll generally
                just
                pass through to one of the methods provided by our <code>Repositories</code>. In a real world
                application you'd
                want to provide authentication of user requests and so on. </p>

            <p>To define a <code>RestController</code> all we need to do is annotate a class as follows:</p>

<snippet language="java">@RestController
public class AthleteController {
</snippet>

            <p>We want to return all the Olympic Data we have in the first pass and in order to do that we need to use
                our </code>AthleteRepository</p>. Let's create a constructor that will take this repository (Spring will
            automatically inject it for us) and create a method that uses it:
{'fraction_non_alphanumeric': 0.10037523452157598, 'fraction_numerical': 0.009916912355936747, 'mean_word_length': 2.032507110930516, 'pattern_counts': {'":': 0, '<': 135, '<?xml version=': 0, '>': 135, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7546926', 'n_tokens_mistral': 2140, 'n_tokens_neox': 1963, 'n_words': 784}