Skip to content

WIP: Add Coffee management plugin for HackerBook training#1

Closed
Damans227 wants to merge 38 commits into
mainfrom
feature/coffee-api
Closed

WIP: Add Coffee management plugin for HackerBook training#1
Damans227 wants to merge 38 commits into
mainfrom
feature/coffee-api

Conversation

@Damans227
Copy link
Copy Markdown
Owner

Description

This PR implements a Coffee management plugin as part of the HackerBook training exercise, demonstrating CloudStack's plugin architecture from API layer to database persistence.

Features:

  • API Commands: CreateCoffee, ListCoffees, UpdateCoffee, RemoveCoffee
  • Service Layer: CoffeeManager interface and CoffeeManagerImpl with Spring DI
  • Database Layer: CoffeeVO entity, CoffeeDao, CoffeeDaoImpl with GenericDaoBase
  • Schema: coffee table with id, uuid, name, offering, size, state, account_id, created, removed

Supported Operations:

  • Create coffee orders with name, offering (Espresso/Cappuccino/Mocha/Latte), and size (SMALL/MEDIUM/LARGE)
  • List coffees with optional filtering by offering and size
  • Update coffee size
  • Remove coffee orders

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

image image

How Has This Been Tested?

  • Tested CRUD operations via direct API calls and using cmk
  • Verified database persistence using MySQL CLI
  • Tested filtering with various parameter combinations

How did you try to break this feature and the system with this change?

@Damans227 Damans227 changed the title Add Coffee management plugin for HackerBook training WIP: Add Coffee management plugin for HackerBook training Nov 26, 2025
@Damans227 Damans227 marked this pull request as draft November 26, 2025 23:10
Daman Arora added 28 commits November 26, 2025 19:24
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Daman Arora added 6 commits November 26, 2025 19:24
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Daman Arora added 4 commits November 26, 2025 19:28
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Signed-off-by: Daman Arora <daman.arora@shapeblue.com>
Copy link
Copy Markdown

@nvazquez nvazquez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Damans227 - looking good so far, please consider adding unit tests

</dependency>
</dependencies>
<properties>
<maven.compiler.source>11</maven.compiler.source>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you revisit these properties? We are currently using JDK 17


@Override
public void create() {
coffee = coffeeManager.createCoffee(this);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think coffee can be defined as a local variable to this method and not outside of it

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The coffee field needs to be an instance variable because it's set in create() and then accessed in execute(). If coffee were a local variable in create(), then execute() wouldn't have access to it.

} else if (ids != null && !ids.isEmpty()) {
response.setDisplayText("Successfully removed " + ids.size() + " coffee orders");
} else {
response.setDisplayText("Coffee removal completed");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these lines could be extracted into a method to set the display text based on the id and ids parameters

description = "the ID of the coffee order")
private Long id;

@Parameter(name = "size",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use ApiConstants here?

@Damans227 Damans227 closed this Nov 28, 2025
@Damans227 Damans227 deleted the feature/coffee-api branch November 28, 2025 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants