{"id":21430110,"url":"https://github.com/cuba-platform/sample-data-manipulation","last_synced_at":"2025-10-26T04:40:14.237Z","repository":{"id":85315551,"uuid":"55236314","full_name":"cuba-platform/sample-data-manipulation","owner":"cuba-platform","description":"DEPRECATED. See https://www.cuba-platform.com/guides/intro-working-with-data-in-cuba","archived":false,"fork":false,"pushed_at":"2018-10-11T09:47:35.000Z","size":182,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":29,"default_branch":"master","last_synced_at":"2025-07-14T12:47:05.215Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cuba-platform.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-04-01T13:57:52.000Z","updated_at":"2019-09-05T15:06:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"bee19bf3-ec95-4fb0-b384-4c59c6c17fa8","html_url":"https://github.com/cuba-platform/sample-data-manipulation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cuba-platform/sample-data-manipulation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuba-platform%2Fsample-data-manipulation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuba-platform%2Fsample-data-manipulation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuba-platform%2Fsample-data-manipulation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuba-platform%2Fsample-data-manipulation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cuba-platform","download_url":"https://codeload.github.com/cuba-platform/sample-data-manipulation/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuba-platform%2Fsample-data-manipulation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001949,"owners_count":26083226,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-22T22:20:47.249Z","updated_at":"2025-10-09T18:06:10.862Z","avatar_url":"https://github.com/cuba-platform.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Data Manipulation\n\nThis example project outlines various ways of programmatic data manipulation in CUBA applications.\n\n- Programmatic creation, updating and deletion of entities on the middleware and on the client tier. See the following methods of the [CustomerBrowse](https://github.com/cuba-platform/sample-data-manipulation/blob/master/modules/gui/src/com/company/sample/gui/customer/CustomerBrowse.java) screen controller:\n    - `onCreateInService()` - sends customer data to a middleware [service](https://github.com/cuba-platform/sample-data-manipulation/blob/master/modules/core/src/com/company/sample/service/CustomerServiceBean.java) method.\n    - `onCreateInController()` - replicates the logic of the midlleware service right in the screen controller.\n\n- Execution of queries on the middleware and on the client tier. See the following methods of the `CustomerBrowse` screen controller:\n    - `calculateDiscountInService()` - delegeates to a middleware [service](https://github.com/cuba-platform/sample-data-manipulation/blob/master/modules/core/src/com/company/sample/service/CustomerServiceBean.java) method.\n    - `calculateDiscountInScreen()` - executes query in the screen controller via [DataManager](https://doc.cuba-platform.com/manual-6.6/dataManager.html).\n    \n- Providing uniqueness by using database-level unique constraints. The `SAMPLE_CUSTOMER` table has the `IDX_SAMPLE_CUSTOMER_UNQ_EMAIL` constraint by `EMAIL` column, so the database throws an error on attempt to create two customers with the same email. The [main message pack](https://github.com/cuba-platform/sample-data-manipulation/blob/master/modules/web/src/com/company/sample/web/messages.properties) of the `web` module contains a message with the `IDX_SAMPLE_CUSTOMER_UNQ_EMAIL` key which will be automatically picked up by the platform to display a user-friendly message. See [cuba.uniqueConstraintViolationPattern](https://doc.cuba-platform.com/manual-6.6/app_properties_reference.html#cuba.uniqueConstraintViolationPattern) application property for how to adjust this mechanism for your database.\n\n- Enforcing complex rules using entity listeners. [OrderEntityListener](https://github.com/cuba-platform/sample-data-manipulation/blob/master/modules/core/src/com/company/sample/listener/OrderEntityListener.java) throws an exception on attempt to create an order if there are already two or more orders for the same customer on the same day.\n\n- Handling exceptions coming from the middleware. [TooManyOrdersExceptionHandler](https://github.com/cuba-platform/sample-data-manipulation/blob/master/modules/gui/src/com/company/sample/gui/exception/TooManyOrdersExceptionHandler.java) shows a notification on unhandled [TooManyOrdersException](https://github.com/cuba-platform/sample-data-manipulation/blob/master/modules/global/src/com/company/sample/exception/TooManyOrdersException.java). See [Client-Level Exception Handlers](https://doc.cuba-platform.com/manual-6.6/exceptionHandlers.html) for details.\n\n- Using the [REST API](https://doc.cuba-platform.com/manual-6.6/rest_api_v2.html) to control the application from an external tool. See the project in the `clients/rest-client` directory. To create IntelliJ IDEA project files, open the command line in this directory and run `gradle idea`.\n    - The `RestClient.createCustomer()` method creates an entity by sending JSON to the standard REST API CRUD method.\n    - The `RestClient.createCustomerViaService()` method creates an entity by sending its attributes to the middleware service.\n\nBased on CUBA Platform 6.10.1\n\n## Issues\nPlease use https://www.cuba-platform.com/discuss for discussion, support, and reporting problems coressponding to this sample.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcuba-platform%2Fsample-data-manipulation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcuba-platform%2Fsample-data-manipulation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcuba-platform%2Fsample-data-manipulation/lists"}