Skip to content

Rename deprecated CdsService to CqnService #23061

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

Merged
merged 5 commits into from
May 24, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import org.springframework.stereotype.Component;

import com.sap.cds.services.cds.CdsCreateEventContext;
import com.sap.cds.services.cds.CdsReadEventContext;
import com.sap.cds.services.cds.CdsService;
import com.sap.cds.services.cds.CqnService;
import com.sap.cds.services.handler.EventHandler;
import com.sap.cds.services.handler.annotations.On;
import com.sap.cds.services.handler.annotations.ServiceName;
Expand All @@ -50,13 +50,13 @@ public class AdminService implements EventHandler {

private Map<Object, Map<String, Object>> products = new HashMap<>();

@On(event = CdsService.EVENT_CREATE, entity = "AdminService.Products")
@On(event = CqnService.EVENT_CREATE, entity = "AdminService.Products")
public void onCreate(CdsCreateEventContext context) {
context.getCqn().entries().forEach(e -> products.put(e.get("ID"), e));
context.setResult(context.getCqn().entries());
}

@On(event = CdsService.EVENT_READ, entity = "AdminService.Products")
@On(event = CqnService.EVENT_READ, entity = "AdminService.Products")
public void onRead(CdsReadEventContext context) {
context.setResult(products.values());
}
Expand Down
16 changes: 8 additions & 8 deletions tutorials/cp-cap-java-custom-logic/cp-cap-java-custom-logic.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ You will now add a method to the `OrdersService` Java class to decrease the stoc
@Autowired
PersistenceService db;

@Before(event = CdsService.EVENT_CREATE, entity = OrderItems_.CDS_NAME)
@Before(event = CqnService.EVENT_CREATE, entity = OrderItems_.CDS_NAME)
public void validateBookAndDecreaseStock(List<OrderItems> items) {
for (OrderItems item : items) {
String bookId = item.getBookId();
Expand All @@ -92,7 +92,7 @@ You will now add a method to the `OrdersService` Java class to decrease the stoc
}
}

@Before(event = CdsService.EVENT_CREATE, entity = Orders_.CDS_NAME)
@Before(event = CqnService.EVENT_CREATE, entity = Orders_.CDS_NAME)
public void validateBookAndDecreaseStockViaOrders(List<Orders> orders) {
for (Orders order : orders) {
if (order.getItems() != null) {
Expand All @@ -114,7 +114,7 @@ You will now add a method to the `OrdersService` Java class to decrease the stoc
import com.sap.cds.ql.cqn.CqnUpdate;
import com.sap.cds.services.ErrorStatuses;
import com.sap.cds.services.ServiceException;
import com.sap.cds.services.cds.CdsService;
import com.sap.cds.services.cds.CqnService;
import com.sap.cds.services.handler.annotations.Before;
import com.sap.cds.services.persistence.PersistenceService;

Expand Down Expand Up @@ -160,7 +160,7 @@ import com.sap.cds.ql.cqn.CqnSelect;
import com.sap.cds.ql.cqn.CqnUpdate;
import com.sap.cds.services.ErrorStatuses;
import com.sap.cds.services.ServiceException;
import com.sap.cds.services.cds.CdsService;
import com.sap.cds.services.cds.CqnService;
import com.sap.cds.services.handler.annotations.Before;
import com.sap.cds.services.persistence.PersistenceService;

Expand All @@ -177,7 +177,7 @@ public class OrdersService implements EventHandler {
@Autowired
PersistenceService db;

@Before(event = CdsService.EVENT_CREATE, entity = OrderItems_.CDS_NAME)
@Before(event = CqnService.EVENT_CREATE, entity = OrderItems_.CDS_NAME)
public void validateBookAndDecreaseStock(List<OrderItems> items) {
for (OrderItems item : items) {
String bookId = item.getBookId();
Expand All @@ -201,7 +201,7 @@ public class OrdersService implements EventHandler {
}
}

@Before(event = CdsService.EVENT_CREATE, entity = Orders_.CDS_NAME)
@Before(event = CqnService.EVENT_CREATE, entity = Orders_.CDS_NAME)
public void validateBookAndDecreaseStockViaOrders(List<Orders> orders) {
for (Orders order : orders) {
if (order.getItems() != null) {
Expand Down Expand Up @@ -281,7 +281,7 @@ Next, let's add a method to the `OrdersService` Java class to calculate the `net
1. Add the following code to the class and make sure you **Save** the file:

```Java
@After(event = { CdsService.EVENT_READ, CdsService.EVENT_CREATE }, entity = OrderItems_.CDS_NAME)
@After(event = { CqnService.EVENT_READ, CqnService.EVENT_CREATE }, entity = OrderItems_.CDS_NAME)
public void calculateNetAmount(List<OrderItems> items) {
for (OrderItems item : items) {
String bookId = item.getBookId();
Expand Down Expand Up @@ -368,7 +368,7 @@ Finally, add a method to the `OrdersService` Java class to calculate the `total`
1. Add the following code to the class and make sure you **Save** the file:

```Java
@After(event = { CdsService.EVENT_READ, CdsService.EVENT_CREATE }, entity = Orders_.CDS_NAME)
@After(event = { CqnService.EVENT_READ, CqnService.EVENT_CREATE }, entity = Orders_.CDS_NAME)
public void calculateTotal(List<Orders> orders) {
for (Orders order : orders) {
// calculate net amount for expanded items
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ From the products service that you created in the previous tutorial, we just wan

```Shell/Bash
mvn -B archetype:generate -DarchetypeArtifactId=cds-services-archetype -DarchetypeGroupId=com.sap.cds \
-DarchetypeVersion=RELEASE \
-DarchetypeVersion=RELEASE -DjdkVersion=11 \
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch! Thank you :)

-DgroupId=com.sap.cap -DartifactId=bookstore
```

Expand Down