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));
}
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));
}
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;
}
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;
}
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);
}
Aggregations