Search in sources :

Example 1 with MetadataProposal

use of org.hisp.dhis.metadata.MetadataProposal in project dhis2-core by dhis2.

the class MetadataWorkflowController method acceptProposal.

@PostMapping(value = { "/{uid}/", "/{uid}" }, produces = APPLICATION_JSON_VALUE)
@ResponseBody
public WebMessage acceptProposal(@PathVariable("uid") String uid) throws NotFoundException {
    MetadataProposal proposal = checkProposalExists(uid);
    ImportReport report = service.accept(proposal);
    if (report.getStatus() != Status.OK) {
        return importReport(report);
    }
    if (proposal.getType() == MetadataProposalType.ADD) {
        String objUid = report.getFirstObjectReport().getUid();
        Schema schema = schemaService.getSchema(proposal.getTarget().getType());
        return created(schema.getSingular() + " created").setLocation(schema.getRelativeApiEndpoint() + "/" + objUid);
    }
    return ok();
}
Also used : MetadataProposal(org.hisp.dhis.metadata.MetadataProposal) ImportReport(org.hisp.dhis.dxf2.metadata.feedback.ImportReport) Schema(org.hisp.dhis.schema.Schema) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

ImportReport (org.hisp.dhis.dxf2.metadata.feedback.ImportReport)1 MetadataProposal (org.hisp.dhis.metadata.MetadataProposal)1 Schema (org.hisp.dhis.schema.Schema)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1