Search in sources :

Example 1 with UpdateAttributeCommand

use of org.openforis.collect.command.UpdateAttributeCommand in project collect by openforis.

the class CommandController method addOrUpdateAttributes.

@RequestMapping(value = "record/attributes", method = POST, consumes = APPLICATION_JSON_VALUE)
@Transactional
@ResponseBody
public List<RecordEventView> addOrUpdateAttributes(@RequestBody UpdateAttributesCommandWrapper commandsWrapper) {
    List<RecordEvent> events = new ArrayList<RecordEvent>();
    commandsWrapper.commands.forEach(c -> {
        UpdateAttributeCommand command = c.toCommand();
        events.addAll(commandDispatcher.submit(command));
    });
    return toView(events);
}
Also used : ArrayList(java.util.ArrayList) RecordEvent(org.openforis.collect.event.RecordEvent) UpdateAttributeCommand(org.openforis.collect.command.UpdateAttributeCommand) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) Transactional(org.springframework.transaction.annotation.Transactional) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with UpdateAttributeCommand

use of org.openforis.collect.command.UpdateAttributeCommand in project collect by openforis.

the class CommandController method updateAttribute.

@RequestMapping(value = "record/attribute", method = PATCH, consumes = APPLICATION_JSON_VALUE)
@Transactional
@ResponseBody
public List<RecordEventView> updateAttribute(@RequestBody UpdateAttributeCommandWrapper commandWrapper) {
    UpdateAttributeCommand command = commandWrapper.toCommand();
    List<RecordEvent> events = commandDispatcher.submit(command);
    return toView(events);
}
Also used : RecordEvent(org.openforis.collect.event.RecordEvent) UpdateAttributeCommand(org.openforis.collect.command.UpdateAttributeCommand) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) Transactional(org.springframework.transaction.annotation.Transactional) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

UpdateAttributeCommand (org.openforis.collect.command.UpdateAttributeCommand)2 RecordEvent (org.openforis.collect.event.RecordEvent)2 Transactional (org.springframework.transaction.annotation.Transactional)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 ArrayList (java.util.ArrayList)1