use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class XmEntityResource method searchXmEntities.
/**
* SEARCH /_search/xm-entities?query=:query : search for the xmEntity corresponding to the query.
*
* @param query the query of the xmEntity search
* @param pageable the pagination information
* @return the result of the search
*/
@GetMapping("/_search/xm-entities")
@Timed
public ResponseEntity<List<XmEntity>> searchXmEntities(@RequestParam String query, @ApiParam Pageable pageable) {
Page<XmEntity> page = xmEntityService.search(query, pageable, null);
HttpHeaders headers = PaginationUtil.generateSearchPaginationHttpHeaders(query, page, "/api/_search/xm-entities");
return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class XmEntitySpecResource method generateXmEntity.
/**
* POST /xm-entity-specs/generate-xm-entity : Generate a new xmEntity.
*
* @return the ResponseEntity with status 201 (Created) and with body the new xmEntity
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/xm-entity-specs/generate-xm-entity")
@Timed
@PreAuthorize("hasPermission({'rootTypeKey': #rootTypeKey}, 'XMENTITY_SPEC.GENERATE')")
public ResponseEntity<XmEntity> generateXmEntity(@ApiParam String rootTypeKey) throws URISyntaxException {
log.debug("REST request to generate XmEntity");
XmEntity result = xmEntityGeneratorService.generateXmEntity(rootTypeKey != null ? rootTypeKey : "");
return ResponseEntity.created(new URI("/api/xm-entities/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class XmEntityUtils method getRequiredLinkedTarget.
public static XmEntity getRequiredLinkedTarget(XmEntity xmEntity, String targetTypeKey) {
Optional<Link> linkOpt = getLink(xmEntity, targetTypeKey);
XmEntity target = linkOpt.orElseThrow(() -> new BusinessException("Can't find linkOpt with target type key: " + targetTypeKey)).getTarget();
return Objects.requireNonNull(target, "Target in link with typeKey: " + targetTypeKey + " is null");
}
use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class FunctionServiceImpl method toFunctionContext.
private FunctionContext toFunctionContext(String functionKey, IdOrKey idOrKey, Map<String, Object> data) {
XmEntity xmEntity = (idOrKey != null) ? xmEntityService.findOne(idOrKey) : null;
FunctionContext functionResult = new FunctionContext();
// TODO review key & typeKey ...
functionResult.setKey(functionKey + "-" + UUID.randomUUID().toString());
functionResult.setTypeKey(functionKey);
functionResult.setData(data);
functionResult.setStartDate(Instant.now());
functionResult.setUpdateDate(functionResult.getStartDate());
functionResult.setXmEntity(xmEntity);
return functionResult;
}
use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class XmEntityServiceImpl method saveLinkTarget.
@LogicExtensionPoint("SaveLinkTarget")
@Override
public Link saveLinkTarget(IdOrKey idOrKey, Link link, MultipartFile file) {
// resolve source entity by idOrKey
XmEntity source = toSourceXmEntity(idOrKey);
// resolve target entity by key
XmEntity target = findOne(toIdOrKey(link.getTarget()));
// save link
link.setSource(source);
link.setTarget(target);
link.setStartDate(Instant.now());
Link savedLink = linkService.save(link);
log.debug("Link saved with id {}", link.getId());
// save file to storage and attachment
if (file != null) {
addFileAttachment(savedLink.getTarget(), file);
}
return savedLink;
}
Aggregations