---
description: Spring OData Supported features
---

# Supported Features

| Supported feature               | Text                                                                                     | Customization limit |
| ------------------------------- | ---------------------------------------------------------------------------------------- | ------------------- |
| <p></p><p>Basic Search</p>      |                                                                                          |                     |
| Sort                            |                                                                                          |                     |
| Sort by property                |                                                                                          |                     |
| Group by more than one property |                                                                                          |                     |
| Property                        |                                                                                          |                     |
| Validation                      |                                                                                          |                     |
| Pagination                      |                                                                                          |                     |
| Entity type                     |                                                                                          |                     |
| Collection Type                 |                                                                                          |                     |
| OData data types                | Collection Type Enum Type Complex Type Navigation Property Reference Navigation Property |                     |
| CRUD                            |                                                                                          |                     |
| Nesting CRUD                    |                                                                                          |                     |

## Keys

### Primary Keys

* **Single Primary Key:** A unique identifier that consists of a single column in a table. This column ensures that each row in the table is uniquely identified by its values.
* **Composite Primary Key:** A primary key that consists of two or more columns in a table. The combination of values across these columns must be unique to ensure the uniqueness of each row.

## Inheritance

### Entity Type Inheritance

* **Entity Type:** In the context of entity types, inheritance refers to the ability of a subtype (child entity) to inherit attributes and relationships from a supertype (parent entity).

### Complex Type Inheritance

* **Complex Type:** Inheritance allows you to create a hierarchy of complex types, where a subtype can inherit the properties of a parent complex type.



## Query Capabilities

Here `{{host}}` is the IP Address and Port number of the deployed Application and `{{servletname}}` is the Service Name of the application.

### Basic Search

* **$filter:** Supports filtering records based on conditions.
  *   **Example:** To filter PetCareCenters whose name contains "John":

      ```plaintext
      {{host}}/{{servletname}}/PetCareCenters?$filter=contains(Name, 'John')
      ```

### Select Specific Fields

* **$select:** Allows you to GET only the required fields.
  *   **Example:** To get only the names and emails of PetCareCenters:

      ```plaintext
      {{host}}/{{servletname}}/PetCareCenters?$select=Name,Email
      ```

### Sorting

* **$orderby:** Supports sorting by a specific property.
  *   **Example:** To sort PetCareCenters by `Name` in ascending order:

      ```plaintext
      {{host}}/{{servletname}}/PetCareCenters?$orderby=Name
      ```
  *   **Example:** To sort PetCareCenters by `Name` in descending order:

      ```plaintext
      {{host}}/{{servletname}}/PetCareCenters?$orderby=Name desc
      ```

### Grouping

* **$apply:** Supports grouping by one or more properties using the `groupby` transformation.
  *   **Example:** To group PetCareCenters by `Name`:

      ```plaintext
      {{host}}/{{servletname}}/PetCareCenters?$apply=groupby((CustomerId))
      ```
  *   **Example:** To group PetCareCenters by `Name` and `BranchName`:

      ```plaintext
      {{host}}/{{servletname}}/PetCareCenters?$apply=groupby((Name, BranchName))
      ```

### Pagination

* **$top:** Retrieves only the top N records.
  *   **Example:** To get the top 2 PetCareCenters:

      ```plaintext
      {{host}}/{{servletname}}/PetCareCenters?$top=2
      ```
* **$skip:** Skips the first N records.
  *   **Example:** To skip the first PetCareCenters:

      ```plaintext
      {{host}}/{{servletname}}/PetCareCenters?$skip=1
      ```

### Expand Related Entities

* **$expand:** Retrieves related entities.
  *   **Example:** To get PetCareCenters with their PetService:

      ```plaintext
      {{host}}/{{servletname}}/PetCareCenters?$expand=Services
      ```

### Count Entities

* **$count:** Retrieves the number of entities.
  *   **Example:** To get the number of PetCareCenters:

      ```plaintext
      {{host}}/{{servletname}}/PetCareCenters/$count
      ```

### Single Column Value

* **$value:** Retrieves the raw value of a single property.
  *   **Example:** To get the PetCareCenters Name as a raw value:

      ```plaintext
      {{host}}/{{servletname}}/PetCareCenters(1)/Name/$value
      ```

## Data Model

### Entity Type

An entity type represents a specific type of entity in the data model. It corresponds to a table in an underlying database and defines the structure of the data, including properties and relationships.

### **Collection Type**

Code Wizard supports CRUD operations on collection navigation properties. This represents a one-to-many or many-to-many relationship between collections of associated objects. It allows you to navigate from one entity to a collection of related entities.

<figure><img src="https://2133491438-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSDKNr1jp5RbNsbYPXuKP%2Fuploads%2F0QcjzNqbkELcLHOEQyO1%2F111.png?alt=media&#x26;token=4f142154-00a7-47b0-91fd-44e3b7e6350f" alt=""><figcaption><p>Pet Care Model (MDJ)</p></figcaption></figure>

Let's consider this Pet Care model which includes several entities such as `PetCareCenter`, `Pet`, `PetService`, etc. This model encompasses various attributes and associations, providing a comprehensive structure for managing pet care services. Below are the detailed descriptions of the entities and their relationships:

### Entities and Attributes

1. **PetCareCenter**
   * **Attributes:**
     * `pcId` (Int): Unique identifier for the pet care center.
     * `name` (String): Name of the pet care center.
     * `location` (String): Location of the pet care center.
     * `businessHours` (List(String)): List of business hours.
     * `isOperational` (Boolean): Indicates whether the center is currently operational.
   * **Associations:**
     * One-to-One with `Manager`: Each `PetCareCenter` can be associated with one `Manager`. Here the association name is `Supervisor`.
     * One-to-One with `Document`: Each `PetCareCenter` can be associated with one `Document`. Here the association name is `Logo`.
     * One-to-Many with `Document`: Each `PetCareCenter` can be associated with multiple `Document`. Here the association name is `Images`.
     * One-to-Many with `Services`: Each `PetCareCenter` can be associated with multiple `PetServices`. Here the association name is `Services`.
     * One-to-Many with `Pet`: Each `PetCareCenter` can be associated with multiple `Pet`. Here the association name is `Pets`.
2. **Manager**
   * **Attributes:**
     * `mId` (Int): Unique identifier for the manager.
     * `fullName` (String): Full name of the manager.
     * `contactNumber` (String): Contact number of the manager.
     * `address` (String): Address of the manager.
   * **Associations:**
     * One-to-One with `PetCareCenter`: Each `Manager` is associated with one `PetCareCenter`.
3. **PetService**
   * **Attributes:**
     * `serviceId` (Int): Unique identifier for the pet service.
     * `durationInHours` (Int): Duration in hour of the pet service.
     * `serviceType` (PetServiceType): Type of the pet service (using an enum for predefined types).
     * `price` (Double): Price of the service.
   * **Associations:**
     * One-to-Many with `PetCareCenter`: Each `PetCareCenter` can offer multiple `PetServices`.
4. **Pet**
   * **Attributes:**
     * `petId` (Int): Unique identifier for the pet.
     * `petName` (String): Name of the pet.
     * `color` (String): Color of the pet.
     * `breed` (String): Breed of the pet.
     * `height` (Decimal): Height of the pet.
5. **PetOwner**
   * **Attributes:**
     * `ownerId` (Int): Unique identifier for the pet owner.
     * `ownerName` (String): Name of the pet owner.
     * `contactPrimary` (String): Primary contact number of the pet owner.
     * `address` (String): Address of the pet owner.
   * **Associations:**
     * One-to-Many with `Pet`: Each `PetOwner` can have multiple `Pet`s.
6. **Document**
   * **Attributes:**
     * `docId` (Int): Unique identifier for the document.
     * `docName` (String): Name of the document.
     * `fileType` (String): File name of the document.

### Enum Type

**PetServiceType is an Enum Type which has t**he types of pet services offered.

* Possible Values:
  * `PetGrooming = 1`
  * `PetBoarding = 2`
  * `PetTraining = 3`
  * `PetSitting = 4`
  * `PetTherapy = 5`

### **Enum Type**

Spring OData template supports Enum, or enumeration, is a data type that consists of a set of named constants. Enums provide a way to define a group of related constant values in a more expressive and readable way.&#x20;

### **Complex Type**

Code-Wizard template use/support complex type is a type that does not have a key and cannot exist independently. It is typically used as a component of another entity type or complex type. Complex types are often used to represent a group of associated object properties that can be treated as a single unit.

Since complex types do not have a standalone identity, their manipulation is directly tied to the operations performed on the parent entity.&#x20;

### **Navigation Property**

Navigation properties are used to define relationships between different entity types. These navigation properties allow you to navigate from one entity to related entities, making it easier to work with data of associated objects.

### **Reference Navigation Property**

A reference navigation property represents a one-to-one or many-to-one relationship between entities. It allows you to navigate from one entity to a related entity. For example, if you have a relationship between a "Customer" entity and an "Order" entity, the reference navigation property might allow you to access the customer associated with a particular order.

### **Nesting CRUD**

Nesting a "Create" operation typically means creating a new record or data entry within the context of a related parent record.

Template supports Spring Data JPA (Spring Data framework) for the ORM capabilities. It simplifies the implementation of JPA (Java Persistence API) based repositories. It provides a way to use JPA to store data in a relational database and can be seen as an abstraction layer over the JPA, making it easier to work with databases using JPA

**Example:**

```json
{
    "Address": "94332 Daiwik Garden",
    "Name": "PC Petcare Center",
    "Description": "Best in Town",
    "BranchName": "GT Road",
    "Latitude": 732281.51,
    "Longitude": 872929.37,
    "Pincode": 334455,
    "IsOperational": true,
    "BusinessHours": [
        "10 AM to 2 PM",
        "5 PM to 9PM"
    ],
    "NearbyLocation": "Netaji Statue",
    "Pets": [
        {
            "PetName": "Tom",
            "Breed": "German Shephard",
            "AnimalType": "Dog",
            "Gender": "Female",
            "Color": "Brown",
            "Weight": 91.58,
            "Height": 54.59
        },
        {
            "PetName": "Cherry",
            "Breed": "Persian",
            "AnimalType": "Cat",
            "Gender": "Male",
            "Color": "Black",
            "Weight": 36.52,
            "Height": 44.56
        }  
    ]
}
```

**This will create one pet care center and two pets ans associate them.**

## **Operations or queries Code-Wizard support**

Code-Wizard supports various operations on the entities defined in the model. Here are the details of the Create, Read, Update, and Delete (CRUD) operations using the `PetCareCenter` entity as an example.

**1. Create Operation**

To create a new `PetCareCenter`, you would use an HTTP POST request.

**Example:**

```json
{
    "Address": "94332 Daiwik Garden",
    "Name": "PC Petcare Center",
    "Description": "Best in Town",
    "BranchName": "GT Road",
    "Latitude": 732281.51,
    "Longitude": 872929.37,
    "Pincode": 334455,
    "IsOperational": true,
    "BusinessHours": [
        "10 AM to 2 PM",
        "5 PM to 9PM"
    ],
    "NearbyLocation": "Netaji Statue"
}
```

**2. Read Operation**

To read or retrieve data about a `PetCareCenter`, you would use an HTTP GET request.

**Example:**

* **Get all PetCareCenters:**

```http
GET {{host}}/{{servletname}}/PetCareCenters
```

* **Get a specific PetCareCenter by ID:**

```http
GET {{host}}/{{servletname}}/PetCareCenters(1)
```

**3. Update Operation**

To update an existing `PetCareCenter`, you would use an HTTP PATCH request.

**Example:**

```json
{
    "Address": "94332 Daiwiik Garden",
    "Name": "PC2 Petcare Center",
}
```

**4. Delete Operation**

To delete an existing `PetCareCenter`, you would use an HTTP DELETE request.

**Example:**

```http
DELETE {{host}}/{{servletname}}/PetCareCenters(1)
```

### Working with Enums

In your Pet Care model, you can use enums to represent predefined sets of values. This is particularly useful for properties like `ServiceType` in the `PetService` entity. Here's how you can work with enums. You can post petsevice with service type that is a enum property, you need to mention enum value of the respective enum options there like for `PetGrooming` it is 1.

**Example:**

```json
{
    "ServiceAt": "Bangalore",
    "ServiceType": 1,
    "Price": 49.99
}
```

### **Sorting and Filtering Based on Enum Type**

You can also sort and filter your data based on the enum property. For instance, to filter `PetServices` by `ServiceType`, you would use the enum value in your query.

**Example:**

* **Filter by `ServiceType`:**

```http
GET {{host}}/{{servletname}}/PetServices?$filter=ServiceType eq Model.PetServiceType'PetGrooming'
```

### Working with complex types

This model does not contain complex types but we support them, you can perform all the operations there.

**Example:**

* **Filter by `HomeAddress/Address`:**

```
GET {{host}}/{{servletname}}/Customers?$filter=contains(HomeAddress/Address, 'Marathali bangalore 520100')
```



&#x20;









