use of org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams in project dhis2-core by dhis2.
the class EnrollmentSecurityImportValidationTest method setUpTest.
@Override
protected void setUpTest() throws IOException {
renderService = _renderService;
userService = _userService;
Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> metadata = renderService.fromMetadata(new ClassPathResource("tracker/tracker_basic_metadata.json").getInputStream(), RenderFormat.JSON);
ObjectBundleParams params = new ObjectBundleParams();
params.setObjectBundleMode(ObjectBundleMode.COMMIT);
params.setImportStrategy(ImportStrategy.CREATE);
params.setObjects(metadata);
ObjectBundle bundle = objectBundleService.create(params);
ObjectBundleValidationReport validationReport = objectBundleValidationService.validate(bundle);
assertFalse(validationReport.hasErrorReports());
ObjectBundleCommitReport commit = objectBundleService.commit(bundle);
assertFalse(commit.hasErrorReports());
TrackerImportParams trackerBundleParams = createBundleFromJson("tracker/validations/enrollments_te_te-data.json");
User user = userService.getUser(ADMIN_USER_UID);
trackerBundleParams.setUserId(user.getUid());
injectSecurityContext(user);
TrackerImportReport trackerImportReport = trackerImportService.importTracker(trackerBundleParams);
assertEquals(0, trackerImportReport.getValidationReport().getErrors().size());
assertEquals(TrackerStatus.OK, trackerImportReport.getStatus());
}
use of org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams in project dhis2-core by dhis2.
the class EventImportValidationTest method setUpTest.
@Override
protected void setUpTest() throws IOException {
renderService = _renderService;
userService = _userService;
Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> metadata = renderService.fromMetadata(new ClassPathResource("tracker/tracker_basic_metadata.json").getInputStream(), RenderFormat.JSON);
ObjectBundleParams params = new ObjectBundleParams();
params.setObjectBundleMode(ObjectBundleMode.COMMIT);
params.setImportStrategy(ImportStrategy.CREATE);
params.setObjects(metadata);
ObjectBundle bundle = objectBundleService.create(params);
ObjectBundleValidationReport validationReport = objectBundleValidationService.validate(bundle);
assertFalse(validationReport.hasErrorReports());
ObjectBundleCommitReport commit = objectBundleService.commit(bundle);
assertFalse(commit.hasErrorReports());
TrackerImportParams trackerImportParams = createBundleFromJson("tracker/validations/enrollments_te_te-data.json");
User user = userService.getUser(ADMIN_USER_UID);
injectSecurityContext(user);
trackerImportParams.setUser(user);
TrackerImportReport trackerImportReport = trackerImportService.importTracker(trackerImportParams);
assertEquals(0, trackerImportReport.getValidationReport().getErrors().size());
assertEquals(TrackerStatus.OK, trackerImportReport.getStatus());
trackerImportParams = renderService.fromJson(new ClassPathResource("tracker/validations/enrollments_te_enrollments-data.json").getInputStream(), TrackerImportParams.class);
trackerImportParams.setUser(user);
trackerImportReport = trackerImportService.importTracker(trackerImportParams);
assertEquals(0, trackerImportReport.getValidationReport().getErrors().size());
assertEquals(TrackerStatus.OK, trackerImportReport.getStatus());
}
use of org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams in project dhis2-core by dhis2.
the class ProgramRuleVariableIntegrationTest method setUpTest.
@Override
public void setUpTest() throws Exception {
renderService = _renderService;
userService = _userService;
Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> metadata = renderService.fromMetadata(new ClassPathResource("tracker/tracker_metadata_with_program_rules_variables.json").getInputStream(), RenderFormat.JSON);
ObjectBundleParams params = new ObjectBundleParams();
params.setObjectBundleMode(ObjectBundleMode.COMMIT);
params.setImportStrategy(ImportStrategy.CREATE);
params.setObjects(metadata);
ObjectBundle bundle = objectBundleService.create(params);
ObjectBundleValidationReport validationReport = objectBundleValidationService.validate(bundle);
assertFalse(validationReport.hasErrorReports());
objectBundleService.commit(bundle);
}
use of org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams in project dhis2-core by dhis2.
the class MetadataImportParams method toObjectBundleParams.
public ObjectBundleParams toObjectBundleParams() {
ObjectBundleParams params = new ObjectBundleParams();
params.setUser(user);
params.setUserOverrideMode(userOverrideMode);
params.setOverrideUser(overrideUser);
params.setSkipSharing(skipSharing);
params.setSkipTranslation(skipTranslation);
params.setSkipValidation(skipValidation);
params.setJobId(id);
params.setImportStrategy(importStrategy);
params.setAtomicMode(atomicMode);
params.setObjects(objects);
params.setPreheatIdentifier(identifier);
params.setPreheatMode(preheatMode);
params.setObjectBundleMode(importMode);
params.setMergeMode(mergeMode);
params.setFlushMode(flushMode);
params.setImportReportMode(importReportMode);
params.setMetadataSyncImport(metadataSyncImport);
return params;
}
use of org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams in project dhis2-core by dhis2.
the class ObjectBundleServiceProgramTest method testProgramRuleUpdate.
@Test
void testProgramRuleUpdate() throws IOException {
createProgramRuleMetadata();
Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> metadata1 = renderService.fromMetadata(new ClassPathResource("dxf2/existing_program_rule.json").getInputStream(), RenderFormat.JSON);
ObjectBundleParams params1 = new ObjectBundleParams();
params1.setObjectBundleMode(ObjectBundleMode.COMMIT);
params1.setImportStrategy(ImportStrategy.UPDATE);
params1.setObjects(metadata1);
ObjectBundle bundle1 = objectBundleService.create(params1);
ObjectBundleValidationReport validate1 = objectBundleValidationService.validate(bundle1);
assertFalse(validate1.hasErrorReports());
}
Aggregations