use of org.hisp.dhis.dxf2.events.importer.context.WorkContext in project dhis2-core by dhis2.
the class EventGeometryCheck method check.
@Override
public ImportSummary check(ImmutableEvent event, WorkContext ctx) {
IdScheme scheme = ctx.getImportOptions().getIdSchemes().getProgramStageIdScheme();
ProgramStage programStage = ctx.getProgramStage(scheme, event.getProgramStage());
if (Objects.nonNull(event.getGeometry()) && programStageFeatureCompatibleWithEventGeometry(event, programStage)) {
return new ImportSummary(ImportStatus.ERROR, "Geometry (" + event.getGeometry().getGeometryType() + ") does not conform to the feature type (" + programStage.getFeatureType().value() + ") specified for the program stage: " + programStage.getUid()).setReference(event.getEvent()).incrementIgnored();
}
return success();
}
use of org.hisp.dhis.dxf2.events.importer.context.WorkContext in project dhis2-core by dhis2.
the class ExpirationDaysCheck method check.
@Override
public ImportSummary check(ImmutableEvent event, WorkContext ctx) {
final ImportOptions importOptions = ctx.getImportOptions();
final Program program = ctx.getProgramsMap().get(event.getProgram());
final ProgramStageInstance programStageInstance = ctx.getProgramStageInstanceMap().get(event.getEvent());
if (importOptions == null || importOptions.getUser() == null || importOptions.getUser().isAuthorized(Authorities.F_EDIT_EXPIRED.getAuthority())) {
return success();
}
if (program != null) {
ImportSummary importSummary = checkEventOrPsiCompletedDate(program, event, programStageInstance);
if (importSummary.isStatus(ImportStatus.ERROR)) {
return importSummary;
}
return checkEventOrPsiExpirationDate(program, event, programStageInstance);
}
return success();
}
use of org.hisp.dhis.dxf2.events.importer.context.WorkContext in project dhis2-core by dhis2.
the class TrackedEntityInstanceCheck method check.
@Override
public ImportSummary check(ImmutableEvent event, WorkContext ctx) {
Program program = ctx.getProgramsMap().get(event.getProgram());
final Optional<TrackedEntityInstance> trackedEntityInstance = ctx.getTrackedEntityInstance(event.getUid());
if (program.isRegistration() && !trackedEntityInstance.isPresent()) {
return new ImportSummary(ImportStatus.ERROR, "Event.trackedEntityInstance does not point to a valid tracked entity instance: " + event.getTrackedEntityInstance()).setReference(event.getEvent()).incrementIgnored();
}
return success();
}
use of org.hisp.dhis.dxf2.events.importer.context.WorkContext in project dhis2-core by dhis2.
the class EventStoredByPreProcessor method process.
@Override
public void process(Event event, WorkContext ctx) {
final String storedBy = EventUtils.getValidUsername(event.getStoredBy(), ctx.getImportOptions());
event.setStoredBy(storedBy);
Set<DataValue> dataValues = event.getDataValues();
for (DataValue dataValue : dataValues) {
dataValue.setStoredBy(storedBy);
}
}
use of org.hisp.dhis.dxf2.events.importer.context.WorkContext in project dhis2-core by dhis2.
the class EventBaseCheck method check.
@Override
public ImportSummary check(ImmutableEvent event, WorkContext ctx) {
ImportSummary importSummary = new ImportSummary();
List<String> errors = validate(event, ctx);
if (!errors.isEmpty()) {
importSummary.setStatus(ERROR);
importSummary.setReference(event.getEvent());
errors.forEach(error -> importSummary.addConflict("Event", error));
importSummary.incrementIgnored();
}
return importSummary;
}
Aggregations