Search in sources :

Example 46 with TypeReport

use of org.hisp.dhis.feedback.TypeReport in project dhis2-core by dhis2.

the class ObjectBundleServiceAttributesTest method testValidateMetadataAttributeValuesUnique.

@Test
void testValidateMetadataAttributeValuesUnique() throws IOException {
    defaultSetupWithAttributes();
    Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> metadata = renderService.fromMetadata(new ClassPathResource("dxf2/metadata_with_unique_attributes.json").getInputStream(), RenderFormat.JSON);
    ObjectBundleParams params = new ObjectBundleParams();
    params.setObjectBundleMode(ObjectBundleMode.VALIDATE);
    params.setObjects(metadata);
    ObjectBundle bundle = objectBundleService.create(params);
    ObjectBundleValidationReport validationReport = objectBundleValidationService.validate(bundle);
    TypeReport typeReport = validationReport.getTypeReport(DataElement.class);
    assertNotNull(typeReport);
    assertEquals(2, validationReport.getErrorReportsCountByCode(DataElement.class, ErrorCode.E4009));
}
Also used : DataElement(org.hisp.dhis.dataelement.DataElement) ObjectBundleValidationReport(org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport) TypeReport(org.hisp.dhis.feedback.TypeReport) List(java.util.List) ClassPathResource(org.springframework.core.io.ClassPathResource) IdentifiableObject(org.hisp.dhis.common.IdentifiableObject) Test(org.junit.jupiter.api.Test)

Example 47 with TypeReport

use of org.hisp.dhis.feedback.TypeReport in project dhis2-core by dhis2.

the class ValidatingEventCheckerTest method verifyValidationFactoryProcessValidationCheck.

@Test
void verifyValidationFactoryProcessValidationCheck() {
    ObjectBundle bundle = createObjectBundle();
    TypeReport typeReport = validationFactory.validateBundle(bundle, Attribute.class, bundle.getObjects(Attribute.class, true), bundle.getObjects(Attribute.class, false));
    // verify that object has been removed from bundle
    assertThat(bundle.getObjects(Attribute.class, false), hasSize(0));
    assertThat(bundle.getObjects(Attribute.class, true), hasSize(0));
    assertThat(typeReport.getStats().getCreated(), is(0));
    assertThat(typeReport.getStats().getUpdated(), is(0));
    assertThat(typeReport.getStats().getDeleted(), is(0));
    assertThat(typeReport.getStats().getIgnored(), is(1));
    assertThat(typeReport.getObjectReportsCount(), is(1));
}
Also used : ObjectBundle(org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle) TypeReport(org.hisp.dhis.feedback.TypeReport) Attribute(org.hisp.dhis.attribute.Attribute) Test(org.junit.jupiter.api.Test)

Example 48 with TypeReport

use of org.hisp.dhis.feedback.TypeReport in project dhis2-core by dhis2.

the class DefaultMetadataWorkflowService method createImportReportWithError.

private ImportReport createImportReportWithError(MetadataProposal proposal, ErrorCode errorCode, String property, Object... args) {
    Class<? extends IdentifiableObject> objType = proposal.getTarget().getType();
    ImportReport importReport = new ImportReport();
    importReport.setStatus(Status.ERROR);
    ObjectReport objectReport = new ObjectReport(objType, null);
    ErrorReport errorReport = new ErrorReport(MetadataProposal.class, errorCode, args);
    errorReport.setErrorProperty(property);
    errorReport.setErrorProperties(singletonList(property));
    objectReport.addErrorReport(errorReport);
    TypeReport typeReport = new TypeReport(objType);
    typeReport.addObjectReport(objectReport);
    importReport.addTypeReport(typeReport);
    return importReport;
}
Also used : ErrorReport(org.hisp.dhis.feedback.ErrorReport) TypeReport(org.hisp.dhis.feedback.TypeReport) ImportReport(org.hisp.dhis.dxf2.metadata.feedback.ImportReport) ObjectReport(org.hisp.dhis.feedback.ObjectReport)

Example 49 with TypeReport

use of org.hisp.dhis.feedback.TypeReport in project dhis2-core by dhis2.

the class BulkPatchValidatorService method createTypeReport.

private TypeReport createTypeReport(ErrorReport errorReport) {
    ObjectReport objectReport = new ObjectReport(JsonPatchException.class, 0);
    objectReport.addErrorReport(errorReport);
    TypeReport typeReport = new TypeReport(JsonPatchException.class);
    typeReport.addObjectReport(objectReport);
    return typeReport;
}
Also used : TypeReport(org.hisp.dhis.feedback.TypeReport) ObjectReport(org.hisp.dhis.feedback.ObjectReport)

Example 50 with TypeReport

use of org.hisp.dhis.feedback.TypeReport in project dhis2-core by dhis2.

the class AbstractCrudController method addCollectionItem.

@PostMapping(value = "/{uid}/{property}/{itemId}")
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public WebMessage addCollectionItem(@PathVariable("uid") String pvUid, @PathVariable("property") String pvProperty, @PathVariable("itemId") String pvItemId, HttpServletResponse response) throws Exception {
    List<T> objects = getEntity(pvUid);
    if (objects.isEmpty()) {
        throw new WebMessageException(notFound(getEntityClass(), pvUid));
    }
    T object = objects.get(0);
    IdentifiableObjects items = new IdentifiableObjects();
    items.setAdditions(singletonList(new BaseIdentifiableObject(pvItemId, "", "")));
    preUpdateItems(object, items);
    TypeReport report = collectionService.addCollectionItems(object, pvProperty, items.getIdentifiableObjects());
    postUpdateItems(object, items);
    return typeReport(report);
}
Also used : BaseIdentifiableObject(org.hisp.dhis.common.BaseIdentifiableObject) WebMessageException(org.hisp.dhis.dxf2.webmessage.WebMessageException) TypeReport(org.hisp.dhis.feedback.TypeReport) IdentifiableObjects(org.hisp.dhis.common.IdentifiableObjects) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

TypeReport (org.hisp.dhis.feedback.TypeReport)52 ObjectReport (org.hisp.dhis.feedback.ObjectReport)28 IdentifiableObject (org.hisp.dhis.common.IdentifiableObject)24 ErrorReport (org.hisp.dhis.feedback.ErrorReport)15 PreheatErrorReport (org.hisp.dhis.preheat.PreheatErrorReport)13 List (java.util.List)7 Test (org.junit.jupiter.api.Test)7 Transactional (org.springframework.transaction.annotation.Transactional)6 ArrayList (java.util.ArrayList)5 ObjectBundleCommitReport (org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleCommitReport)5 ObjectBundleValidationReport (org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport)5 User (org.hisp.dhis.user.User)5 HashMap (java.util.HashMap)4 IdentifiableObjectManager (org.hisp.dhis.common.IdentifiableObjectManager)4 DataElement (org.hisp.dhis.dataelement.DataElement)4 SchemaService (org.hisp.dhis.schema.SchemaService)4 Service (org.springframework.stereotype.Service)4 AllArgsConstructor (lombok.AllArgsConstructor)3 Session (org.hibernate.Session)3 MergeParams (org.hisp.dhis.schema.MergeParams)3