Search in sources :

Example 1 with PatchMapping

use of org.springframework.web.bind.annotation.PatchMapping in project incubator-servicecomb-java-chassis by apache.

the class PatchMappingMethodAnnotationProcessor method process.

@Override
public void process(Object annotation, OperationGenerator operationGenerator) {
    PatchMapping mappingAnnotation = (PatchMapping) annotation;
    Operation operation = operationGenerator.getOperation();
    // path/value是等同的
    this.processPath(mappingAnnotation.path(), operationGenerator);
    this.processPath(mappingAnnotation.value(), operationGenerator);
    this.processMethod(RequestMethod.PATCH, operationGenerator);
    this.processConsumes(mappingAnnotation.consumes(), operation);
    this.processProduces(mappingAnnotation.produces(), operation);
    if (StringUtils.isEmpty(operationGenerator.getHttpMethod()) && StringUtils.isEmpty(operationGenerator.getSwaggerGenerator().getHttpMethod())) {
        throw new Error("HttpMethod must not both be empty in class and method");
    }
}
Also used : Operation(io.swagger.models.Operation) PatchMapping(org.springframework.web.bind.annotation.PatchMapping)

Example 2 with PatchMapping

use of org.springframework.web.bind.annotation.PatchMapping in project metasfresh-webui-api by metasfresh.

the class ViewRowEditRestController method patchRow.

@PatchMapping
public JSONViewRow patchRow(@PathVariable(PARAM_WindowId) final String windowIdStr, @PathVariable(PARAM_ViewId) final String viewIdStr, @PathVariable(PARAM_RowId) final String rowIdStr, @RequestBody final List<JSONDocumentChangedEvent> fieldChangeRequests) {
    userSession.assertLoggedIn();
    final ViewId viewId = ViewId.of(windowIdStr, viewIdStr);
    final DocumentId rowId = DocumentId.of(rowIdStr);
    final IEditableView view = getEditableView(viewId);
    final RowEditingContext editingCtx = createRowEditingContext(rowId);
    view.patchViewRow(editingCtx, fieldChangeRequests);
    final IViewRow row = view.getById(rowId);
    final IViewRowOverrides rowOverrides = ViewRowOverridesHelper.getViewRowOverrides(view);
    return JSONViewRow.ofRow(row, rowOverrides, userSession.getAD_Language());
}
Also used : DocumentId(de.metas.ui.web.window.datatypes.DocumentId) RowEditingContext(de.metas.ui.web.view.IEditableView.RowEditingContext) PatchMapping(org.springframework.web.bind.annotation.PatchMapping)

Example 3 with PatchMapping

use of org.springframework.web.bind.annotation.PatchMapping in project metasfresh-webui-api by metasfresh.

the class BoardRestController method patchCard.

@PatchMapping("/{boardId}/card/{cardId}")
public JSONBoardCard patchCard(@PathVariable("boardId") final int boardId, @PathVariable("cardId") final int cardId, @RequestBody final List<JSONDocumentChangedEvent> changes) {
    userSession.assertLoggedIn();
    final BoardCard card = boardsRepo.changeCard(boardId, cardId, createBoardCardChangeRequest(changes));
    return JSONBoardCard.of(card, userSession.getAD_Language());
}
Also used : JSONBoardCard(de.metas.ui.web.board.json.JSONBoardCard) PatchMapping(org.springframework.web.bind.annotation.PatchMapping)

Example 4 with PatchMapping

use of org.springframework.web.bind.annotation.PatchMapping in project metasfresh-webui-api by metasfresh.

the class ASIRestController method processChanges.

@PatchMapping("/{asiDocId}")
public List<JSONDocument> processChanges(// 
@PathVariable("asiDocId") final String asiDocIdStr, // 
@RequestBody final List<JSONDocumentChangedEvent> events) {
    userSession.assertLoggedIn();
    final DocumentId asiDocId = DocumentId.of(asiDocIdStr);
    return Execution.callInNewExecution("processChanges", () -> {
        final IDocumentChangesCollector changesCollector = Execution.getCurrentDocumentChangesCollectorOrNull();
        asiRepo.processASIDocumentChanges(asiDocId, events, changesCollector);
        return JSONDocument.ofEvents(changesCollector, newJsonOpts());
    });
}
Also used : DocumentId(de.metas.ui.web.window.datatypes.DocumentId) IDocumentChangesCollector(de.metas.ui.web.window.model.IDocumentChangesCollector) PatchMapping(org.springframework.web.bind.annotation.PatchMapping)

Example 5 with PatchMapping

use of org.springframework.web.bind.annotation.PatchMapping in project metasfresh-webui-api by metasfresh.

the class MenuRestController method patchNode.

@PatchMapping("/node/{nodeId}")
public List<JSONMenuNode> patchNode(@PathVariable(PARAM_NodeId) final String nodeId, @RequestBody final List<JSONDocumentChangedEvent> events) {
    userSession.assertLoggedIn();
    final JSONPatchMenuNodeRequest request = JSONPatchMenuNodeRequest.ofChangeEvents(events);
    final MenuTree menuTree = getMenuTree();
    final MenuNode node = menuTree.getNodeById(nodeId);
    final LinkedHashMap<String, MenuNode> changedMenuNodesById = new LinkedHashMap<>();
    if (request.getFavorite() != null) {
        menuTreeRepository.setFavorite(node, request.getFavorite());
        menuTree.streamNodesByAD_Menu_ID(node.getAD_Menu_ID()).forEach(changedNode -> changedMenuNodesById.put(changedNode.getId(), changedNode));
    }
    return JSONMenuNode.ofList(changedMenuNodesById.values(), menuTreeRepository);
}
Also used : JSONMenuNode(de.metas.ui.web.menu.datatypes.json.JSONMenuNode) JSONPatchMenuNodeRequest(de.metas.ui.web.menu.datatypes.json.JSONPatchMenuNodeRequest) LinkedHashMap(java.util.LinkedHashMap) PatchMapping(org.springframework.web.bind.annotation.PatchMapping)

Aggregations

PatchMapping (org.springframework.web.bind.annotation.PatchMapping)18 List (java.util.List)5 ParaObject (com.erudika.para.core.ParaObject)4 MetadataImportParams (org.hisp.dhis.dxf2.metadata.MetadataImportParams)4 ImportReport (org.hisp.dhis.dxf2.metadata.feedback.ImportReport)4 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)3 Collections.singletonList (java.util.Collections.singletonList)3 BaseIdentifiableObject (org.hisp.dhis.common.BaseIdentifiableObject)3 IdentifiableObject (org.hisp.dhis.common.IdentifiableObject)3 UpdateAccessDeniedException (org.hisp.dhis.hibernate.exception.UpdateAccessDeniedException)3 BulkJsonPatch (org.hisp.dhis.jsonpatch.BulkJsonPatch)3 WebOptions (org.hisp.dhis.webapi.webdomain.WebOptions)3 ExtendedModelMap (org.springframework.ui.ExtendedModelMap)3 Model (org.springframework.ui.Model)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 Profile (com.erudika.scoold.core.Profile)2 IDocumentChangesCollector (de.metas.ui.web.window.model.IDocumentChangesCollector)2 JsonPatch (org.hisp.dhis.commons.jackson.jsonpatch.JsonPatch)2 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)2 BulkPatchParameters (org.hisp.dhis.jsonpatch.BulkPatchParameters)2