use of io.github.jhipster.sample.domain.Operation in project jhipster-sample-app-hazelcast by jhipster.
the class OperationResourceIntTest method createEntity.
/**
* Create an entity for this test.
*
* This is a static method, as tests for other entities might also need it,
* if they test an entity which requires the current entity.
*/
public static Operation createEntity(EntityManager em) {
Operation operation = new Operation();
operation.setDate(DEFAULT_DATE);
operation.setDescription(DEFAULT_DESCRIPTION);
operation.setAmount(DEFAULT_AMOUNT);
return operation;
}
use of io.github.jhipster.sample.domain.Operation in project jhipster-sample-app-elasticsearch by jhipster.
the class OperationResource method createOperation.
/**
* POST /operations : Create a new operation.
*
* @param operation the operation to create
* @return the ResponseEntity with status 201 (Created) and with body the new operation, or with status 400 (Bad Request) if the operation has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/operations")
@Timed
public ResponseEntity<Operation> createOperation(@Valid @RequestBody Operation operation) throws URISyntaxException {
log.debug("REST request to save Operation : {}", operation);
if (operation.getId() != null) {
throw new BadRequestAlertException("A new operation cannot already have an ID", ENTITY_NAME, "idexists");
}
Operation result = operationRepository.save(operation);
operationSearchRepository.save(result);
return ResponseEntity.created(new URI("/api/operations/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
use of io.github.jhipster.sample.domain.Operation in project jhipster-sample-app-elasticsearch by jhipster.
the class OperationResource method getAllOperations.
/**
* GET /operations : get all the operations.
*
* @param pageable the pagination information
* @param eagerload flag to eager load entities from relationships (This is applicable for many-to-many)
* @return the ResponseEntity with status 200 (OK) and the list of operations in body
*/
@GetMapping("/operations")
@Timed
public ResponseEntity<List<Operation>> getAllOperations(Pageable pageable, @RequestParam(required = false, defaultValue = "false") boolean eagerload) {
log.debug("REST request to get a page of Operations");
Page<Operation> page;
if (eagerload) {
page = operationRepository.findAllWithEagerRelationships(pageable);
} else {
page = operationRepository.findAll(pageable);
}
HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, String.format("/api/operations?eagerload=%b", eagerload));
return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
use of io.github.jhipster.sample.domain.Operation in project jhipster-sample-app-elasticsearch by jhipster.
the class OperationResource method searchOperations.
/**
* SEARCH /_search/operations?query=:query : search for the operation corresponding
* to the query.
*
* @param query the query of the operation search
* @param pageable the pagination information
* @return the result of the search
*/
@GetMapping("/_search/operations")
@Timed
public ResponseEntity<List<Operation>> searchOperations(@RequestParam String query, Pageable pageable) {
log.debug("REST request to search for a page of Operations for query {}", query);
Page<Operation> page = operationSearchRepository.search(queryStringQuery(query), pageable);
HttpHeaders headers = PaginationUtil.generateSearchPaginationHttpHeaders(query, page, "/api/_search/operations");
return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
use of io.github.jhipster.sample.domain.Operation in project jhipster-sample-app-hazelcast by jhipster.
the class OperationResource method updateOperation.
/**
* PUT /operations : Updates an existing operation.
*
* @param operation the operation to update
* @return the ResponseEntity with status 200 (OK) and with body the updated operation,
* or with status 400 (Bad Request) if the operation is not valid,
* or with status 500 (Internal Server Error) if the operation couldn't be updated
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PutMapping("/operations")
@Timed
public ResponseEntity<Operation> updateOperation(@Valid @RequestBody Operation operation) throws URISyntaxException {
log.debug("REST request to update Operation : {}", operation);
if (operation.getId() == null) {
return createOperation(operation);
}
Operation result = operationRepository.save(operation);
return ResponseEntity.ok().headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, operation.getId().toString())).body(result);
}
Aggregations