Search in sources :

Example 6 with ObjectUtils.firstNonNull

use of org.apache.commons.lang3.ObjectUtils.firstNonNull in project dhis2-core by dhis2.

the class TrackedEntityInstanceController method getTrackedEntityInstances.

// -------------------------------------------------------------------------
// READ
// -------------------------------------------------------------------------
@RequestMapping(value = "", method = RequestMethod.GET)
@ResponseBody
public RootNode getTrackedEntityInstances(@RequestParam(required = false) String query, @RequestParam(required = false) Set<String> attribute, @RequestParam(required = false) Set<String> filter, @RequestParam(required = false) String ou, @RequestParam(required = false) OrganisationUnitSelectionMode ouMode, @RequestParam(required = false) String program, @RequestParam(required = false) ProgramStatus programStatus, @RequestParam(required = false) Boolean followUp, @RequestParam(required = false) Date lastUpdatedStartDate, @RequestParam(required = false) Date lastUpdatedEndDate, @RequestParam(required = false) Date programStartDate, @RequestParam(required = false) Date programEnrollmentStartDate, @RequestParam(required = false) Date programEndDate, @RequestParam(required = false) Date programEnrollmentEndDate, @RequestParam(required = false) Date programIncidentStartDate, @RequestParam(required = false) Date programIncidentEndDate, @RequestParam(required = false) String trackedEntity, @RequestParam(required = false) String trackedEntityInstance, @RequestParam(required = false) EventStatus eventStatus, @RequestParam(required = false) Date eventStartDate, @RequestParam(required = false) Date eventEndDate, @RequestParam(required = false) boolean skipMeta, @RequestParam(required = false) Integer page, @RequestParam(required = false) Integer pageSize, @RequestParam(required = false) boolean totalPages, @RequestParam(required = false) boolean skipPaging, @RequestParam(required = false) boolean includeDeleted, @RequestParam(required = false) String order) throws Exception {
    programEnrollmentStartDate = ObjectUtils.firstNonNull(programEnrollmentStartDate, programStartDate);
    programEnrollmentEndDate = ObjectUtils.firstNonNull(programEnrollmentEndDate, programEndDate);
    List<String> fields = Lists.newArrayList(contextService.getParameterValues("fields"));
    if (fields.isEmpty()) {
        fields.add(":all");
    }
    Set<String> orgUnits = TextUtils.splitToArray(ou, TextUtils.SEMICOLON);
    RootNode rootNode = NodeUtils.createMetadata();
    List<TrackedEntityInstance> trackedEntityInstances;
    TrackedEntityInstanceQueryParams queryParams = instanceService.getFromUrl(query, attribute, filter, orgUnits, ouMode, program, programStatus, followUp, lastUpdatedStartDate, lastUpdatedEndDate, programEnrollmentStartDate, programEnrollmentEndDate, programIncidentStartDate, programIncidentEndDate, trackedEntity, eventStatus, eventStartDate, eventEndDate, skipMeta, page, pageSize, totalPages, skipPaging, includeDeleted, getOrderParams(order));
    if (trackedEntityInstance == null) {
        trackedEntityInstances = trackedEntityInstanceService.getTrackedEntityInstances(queryParams, getTrackedEntityInstanceParams(fields));
    } else {
        Set<String> trackedEntityInstanceIds = TextUtils.splitToArray(trackedEntityInstance, TextUtils.SEMICOLON);
        trackedEntityInstances = trackedEntityInstanceIds != null ? trackedEntityInstanceIds.stream().map(id -> trackedEntityInstanceService.getTrackedEntityInstance(id, getTrackedEntityInstanceParams(fields))).collect(Collectors.toList()) : null;
    }
    if (queryParams.isPaging() && queryParams.isTotalPages()) {
        int count = trackedEntityInstanceService.getTrackedEntityInstanceCount(queryParams);
        Pager pager = new Pager(queryParams.getPageWithDefault(), count, queryParams.getPageSizeWithDefault());
        rootNode.addChild(NodeUtils.createPager(pager));
    }
    rootNode.addChild(fieldFilterService.filter(TrackedEntityInstance.class, trackedEntityInstances, fields));
    return rootNode;
}
Also used : ImportStrategy(org.hisp.dhis.importexport.ImportStrategy) PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) Arrays(java.util.Arrays) WebMessageException(org.hisp.dhis.dxf2.webmessage.WebMessageException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Date(java.util.Date) Autowired(org.springframework.beans.factory.annotation.Autowired) WebMessageService(org.hisp.dhis.webapi.service.WebMessageService) StringUtils(org.apache.commons.lang3.StringUtils) NodeUtils(org.hisp.dhis.node.NodeUtils) Model(org.springframework.ui.Model) ImportSummary(org.hisp.dhis.dxf2.importsummary.ImportSummary) GridUtils(org.hisp.dhis.system.grid.GridUtils) ContextService(org.hisp.dhis.webapi.service.ContextService) DxfNamespaces(org.hisp.dhis.common.DxfNamespaces) OrganisationUnitSelectionMode(org.hisp.dhis.common.OrganisationUnitSelectionMode) TrackedEntityInstanceQueryParams(org.hisp.dhis.trackedentity.TrackedEntityInstanceQueryParams) FieldFilterService(org.hisp.dhis.fieldfilter.FieldFilterService) MediaType(org.springframework.http.MediaType) CacheStrategy(org.hisp.dhis.common.cache.CacheStrategy) RequestMethod(org.springframework.web.bind.annotation.RequestMethod) Set(java.util.Set) EventStatus(org.hisp.dhis.event.EventStatus) TrackedEntityInstanceSchemaDescriptor(org.hisp.dhis.schema.descriptors.TrackedEntityInstanceSchemaDescriptor) Collectors(java.util.stream.Collectors) List(java.util.List) RootNode(org.hisp.dhis.node.types.RootNode) Joiner(com.google.common.base.Joiner) DhisApiVersion(org.hisp.dhis.common.DhisApiVersion) CollectionNode(org.hisp.dhis.node.types.CollectionNode) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) Controller(org.springframework.stereotype.Controller) StreamUtils(org.hisp.dhis.commons.util.StreamUtils) ApiVersion(org.hisp.dhis.webapi.mvc.annotation.ApiVersion) HttpServletRequest(javax.servlet.http.HttpServletRequest) Lists(com.google.common.collect.Lists) ObjectUtils(org.apache.commons.lang3.ObjectUtils) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ImportStatus(org.hisp.dhis.dxf2.importsummary.ImportStatus) WebMessageUtils(org.hisp.dhis.dxf2.webmessage.WebMessageUtils) TrackedEntityInstance(org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance) TrackedEntityInstanceService(org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstanceService) ContextUtils(org.hisp.dhis.webapi.utils.ContextUtils) NotFoundException(org.hisp.dhis.webapi.controller.exception.NotFoundException) Pager(org.hisp.dhis.common.Pager) TrackedEntityInstanceParams(org.hisp.dhis.dxf2.events.TrackedEntityInstanceParams) HttpServletResponse(javax.servlet.http.HttpServletResponse) IOException(java.io.IOException) Grid(org.hisp.dhis.common.Grid) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) ImportOptions(org.hisp.dhis.dxf2.common.ImportOptions) ImportSummaries(org.hisp.dhis.dxf2.importsummary.ImportSummaries) ProgramStatus(org.hisp.dhis.program.ProgramStatus) HttpStatus(org.springframework.http.HttpStatus) TextUtils(org.hisp.dhis.commons.util.TextUtils) InputStream(java.io.InputStream) RootNode(org.hisp.dhis.node.types.RootNode) Pager(org.hisp.dhis.common.Pager) TrackedEntityInstance(org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance) TrackedEntityInstanceQueryParams(org.hisp.dhis.trackedentity.TrackedEntityInstanceQueryParams) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 7 with ObjectUtils.firstNonNull

use of org.apache.commons.lang3.ObjectUtils.firstNonNull in project estatio by estatio.

the class LeaseTermForDeposit method calculateDepositBaseValue.

@Programmatic
BigDecimal calculateDepositBaseValue(final LocalDate verificationDate) {
    BigDecimal calculatedValue = BigDecimal.ZERO;
    for (LeaseItem leaseItem : this.getLeaseItem().getSourceItems().stream().map(i -> i.getSourceItem()).collect(Collectors.toList())) {
        LocalDate dateToUse = ObjectUtils.firstNonNull(getFixedDepositCalculationDate(), verificationDate);
        BigDecimal valueForDate = leaseItem.valueForDate(dateToUse);
        calculatedValue = calculatedValue.add(addVatIfNeeded(valueForDate, leaseItem, dateToUse));
    }
    return calculatedValue;
}
Also used : Optionality(org.apache.isis.applib.annotation.Optionality) ClockService(org.apache.isis.applib.services.clock.ClockService) Setter(lombok.Setter) MoneyType(org.incode.module.base.dom.types.MoneyType) Getter(lombok.Getter) Column(javax.jdo.annotations.Column) Collectors(java.util.stream.Collectors) InheritanceStrategy(javax.jdo.annotations.InheritanceStrategy) Programmatic(org.apache.isis.applib.annotation.Programmatic) Inject(javax.inject.Inject) LocalDate(org.joda.time.LocalDate) BigDecimal(java.math.BigDecimal) ObjectUtils(org.apache.commons.lang3.ObjectUtils) Parameter(org.apache.isis.applib.annotation.Parameter) LocalDate(org.joda.time.LocalDate) BigDecimal(java.math.BigDecimal) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 8 with ObjectUtils.firstNonNull

use of org.apache.commons.lang3.ObjectUtils.firstNonNull in project alf.io by alfio-event.

the class TicketReservationManager method reserveTicketsForCategory.

void reserveTicketsForCategory(Event event, String reservationId, TicketReservationWithOptionalCodeModification ticketReservation, Locale locale, boolean forWaitingQueue, PromoCodeDiscount accessCodeOrDiscount, PromoCodeDiscount dynamicDiscount) {
    List<SpecialPrice> specialPrices;
    if (accessCodeOrDiscount != null && accessCodeOrDiscount.getCodeType() == CodeType.ACCESS && ticketReservation.getTicketCategoryId().equals(accessCodeOrDiscount.getHiddenCategoryId()) && Boolean.TRUE.equals(ticketCategoryRepository.isAccessRestricted(accessCodeOrDiscount.getHiddenCategoryId()))) {
        specialPrices = reserveTokensForAccessCode(ticketReservation, accessCodeOrDiscount);
    } else {
        // first check if there is another pending special price token bound to the current sessionId
        Optional<SpecialPrice> specialPrice = fixToken(ticketReservation.getSpecialPrice(), ticketReservation.getTicketCategoryId(), event.getId(), ticketReservation);
        specialPrices = specialPrice.stream().collect(toList());
    }
    List<Integer> reservedForUpdate = reserveTickets(event.getId(), ticketReservation, forWaitingQueue ? asList(TicketStatus.RELEASED, TicketStatus.PRE_RESERVED) : singletonList(TicketStatus.FREE));
    int requested = ticketReservation.getQuantity();
    if (reservedForUpdate.size() != requested) {
        throw new NotEnoughTicketsException();
    }
    TicketCategory category = ticketCategoryRepository.getByIdAndActive(ticketReservation.getTicketCategoryId(), event.getId());
    List<Map<String, String>> ticketMetadata = requireNonNullElse(ticketReservation.getMetadata(), List.of());
    if (!specialPrices.isEmpty()) {
        if (specialPrices.size() != reservedForUpdate.size()) {
            throw new NotEnoughTicketsException();
        }
        AtomicInteger counter = new AtomicInteger(0);
        var ticketsAndSpecialPrices = specialPrices.stream().map(sp -> {
            int index = counter.getAndIncrement();
            return Triple.of(reservedForUpdate.get(index), sp, getAtIndexOrNull(ticketMetadata, index));
        }).collect(Collectors.toList());
        if (specialPrices.size() == 1) {
            var ticketId = reservedForUpdate.get(0);
            var sp = specialPrices.get(0);
            var accessCodeId = accessCodeOrDiscount != null && accessCodeOrDiscount.getHiddenCategoryId() != null ? accessCodeOrDiscount.getId() : null;
            TicketMetadata metadata = null;
            var attributes = getAtIndexOrNull(ticketMetadata, 0);
            if (attributes != null) {
                metadata = new TicketMetadata(null, null, attributes);
            }
            ticketRepository.reserveTicket(reservationId, ticketId, sp.getId(), locale.getLanguage(), category.getSrcPriceCts(), category.getCurrencyCode(), event.getVatStatus(), TicketMetadataContainer.fromMetadata(metadata));
            specialPriceRepository.updateStatus(sp.getId(), Status.PENDING.toString(), null, accessCodeId);
        } else {
            jdbcTemplate.batchUpdate(ticketRepository.batchReserveTicketsForSpecialPrice(), ticketsAndSpecialPrices.stream().map(triple -> {
                TicketMetadataContainer metadata = null;
                if (triple.getRight() != null) {
                    metadata = TicketMetadataContainer.fromMetadata(new TicketMetadata(null, null, triple.getRight()));
                }
                return new MapSqlParameterSource(RESERVATION_ID, reservationId).addValue("ticketId", triple.getLeft()).addValue("specialCodeId", triple.getMiddle().getId()).addValue("userLanguage", locale.getLanguage()).addValue("srcPriceCts", category.getSrcPriceCts()).addValue("currencyCode", category.getCurrencyCode()).addValue("ticketMetadata", json.asJsonString(metadata)).addValue("vatStatus", event.getVatStatus().toString());
            }).toArray(MapSqlParameterSource[]::new));
            specialPriceRepository.batchUpdateStatus(specialPrices.stream().map(SpecialPrice::getId).collect(toList()), Status.PENDING, Objects.requireNonNull(accessCodeOrDiscount).getId());
        }
    } else {
        int reserved = ticketRepository.reserveTickets(reservationId, reservedForUpdate, category, locale.getLanguage(), event.getVatStatus(), idx -> {
            var metadata = getAtIndexOrNull(ticketMetadata, idx);
            if (metadata != null) {
                return json.asJsonString(TicketMetadataContainer.fromMetadata(new TicketMetadata(null, null, metadata)));
            }
            return null;
        });
        Validate.isTrue(reserved == reservedForUpdate.size(), "Cannot reserve all tickets");
    }
    Ticket ticket = ticketRepository.findById(reservedForUpdate.get(0), category.getId());
    var discountToApply = ObjectUtils.firstNonNull(dynamicDiscount, accessCodeOrDiscount);
    TicketPriceContainer priceContainer = TicketPriceContainer.from(ticket, null, event.getVat(), event.getVatStatus(), discountToApply);
    var currencyCode = priceContainer.getCurrencyCode();
    ticketRepository.updateTicketPrice(reservedForUpdate, category.getId(), event.getId(), category.getSrcPriceCts(), MonetaryUtil.unitToCents(priceContainer.getFinalPrice(), currencyCode), MonetaryUtil.unitToCents(priceContainer.getVAT(), currencyCode), MonetaryUtil.unitToCents(priceContainer.getAppliedDiscount(), currencyCode), category.getCurrencyCode(), priceContainer.getVatStatus());
}
Also used : alfio.repository(alfio.repository) TicketMetadataContainer(alfio.model.metadata.TicketMetadataContainer) ZonedDateTime(java.time.ZonedDateTime) TicketCheckInUtil.ticketOnlineCheckInUrl(alfio.util.checkin.TicketCheckInUtil.ticketOnlineCheckInUrl) UncategorizedSQLException(org.springframework.jdbc.UncategorizedSQLException) StringUtils(org.apache.commons.lang3.StringUtils) TransactionSynchronizationManager(org.springframework.transaction.support.TransactionSynchronizationManager) Collections.singletonList(java.util.Collections.singletonList) BigDecimal(java.math.BigDecimal) DateUtils.truncate(org.apache.commons.lang3.time.DateUtils.truncate) ErrorCode(alfio.model.result.ErrorCode) Pair(org.apache.commons.lang3.tuple.Pair) Arrays.asList(java.util.Arrays.asList) ASReservationWithOptionalCodeModification(alfio.model.modification.ASReservationWithOptionalCodeModification) Triple(org.apache.commons.lang3.tuple.Triple) TICKET(alfio.model.Audit.EntityType.TICKET) Organization(alfio.model.user.Organization) UserIdAndOrganizationId(alfio.model.support.UserIdAndOrganizationId) ZoneId(java.time.ZoneId) SubscriptionTimeUnit(alfio.model.subscription.SubscriptionDescriptor.SubscriptionTimeUnit) EventType(alfio.model.Audit.EventType) Stream(java.util.stream.Stream) Type(alfio.model.BillingDocument.Type) PlatformTransactionManager(org.springframework.transaction.PlatformTransactionManager) alfio.model(alfio.model) UserRepository(alfio.repository.user.UserRepository) AdditionalServiceItemPriceContainer(alfio.model.decorator.AdditionalServiceItemPriceContainer) AdditionalServiceItemStatus(alfio.model.AdditionalServiceItem.AdditionalServiceItemStatus) AdditionalServiceReservationModification(alfio.model.modification.AdditionalServiceReservationModification) PromoCodeDiscount.categoriesOrNull(alfio.model.PromoCodeDiscount.categoriesOrNull) java.util(java.util) TicketHelper(alfio.controller.api.support.TicketHelper) ConfigurationLevel(alfio.manager.system.ConfigurationLevel) MessageSourceManager(alfio.manager.i18n.MessageSourceManager) SummaryType(alfio.model.SummaryRow.SummaryType) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) BindingResult(org.springframework.validation.BindingResult) ConfigurationManager(alfio.manager.system.ConfigurationManager) CollectionUtils(org.apache.commons.collections4.CollectionUtils) Objects.requireNonNullElse(java.util.Objects.requireNonNullElse) TicketReservationStatus(alfio.model.TicketReservation.TicketReservationStatus) RESERVATION(alfio.model.Audit.EntityType.RESERVATION) TicketReservationWithOptionalCodeModification(alfio.model.modification.TicketReservationWithOptionalCodeModification) WebhookHandler(alfio.model.transaction.capabilities.WebhookHandler) Status(alfio.model.SpecialPrice.Status) DateUtils(org.apache.commons.lang3.time.DateUtils) Result(alfio.model.result.Result) LinkedGroup(alfio.model.group.LinkedGroup) Validate(org.apache.commons.lang3.Validate) ChronoUnit(java.time.temporal.ChronoUnit) MonetaryUtil(alfio.util.MonetaryUtil) UserManager(alfio.manager.user.UserManager) WarningMessage(alfio.model.result.WarningMessage) Wrappers.optionally(alfio.util.Wrappers.optionally) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) ServerInitiatedTransaction(alfio.model.transaction.capabilities.ServerInitiatedTransaction) TemplateProcessor(alfio.controller.support.TemplateProcessor) DiscountType(alfio.model.PromoCodeDiscount.DiscountType) NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate) AdditionalServicePriceContainer(alfio.model.decorator.AdditionalServicePriceContainer) Mailer(alfio.manager.system.Mailer) TicketStatus(alfio.model.Ticket.TicketStatus) TicketCheckInUtil(alfio.util.checkin.TicketCheckInUtil) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) OfflineProcessor(alfio.model.transaction.capabilities.OfflineProcessor) OrganizationRepository(alfio.repository.user.OrganizationRepository) Predicate(java.util.function.Predicate) Collectors(java.util.stream.Collectors) Role(alfio.model.user.Role) Principal(java.security.Principal) Entry(java.util.Map.Entry) CodeType(alfio.model.PromoCodeDiscount.CodeType) OnlineCheckInFullInfo(alfio.model.checkin.OnlineCheckInFullInfo) IntStream(java.util.stream.IntStream) CustomEmailText(alfio.model.extension.CustomEmailText) ChronoField(java.time.temporal.ChronoField) TransactionDefinition(org.springframework.transaction.TransactionDefinition) PurchaseContextType(alfio.model.PurchaseContext.PurchaseContextType) Function(java.util.function.Function) alfio.util(alfio.util) ReservationPriceCalculator(alfio.manager.system.ReservationPriceCalculator) TicketPriceContainer(alfio.model.decorator.TicketPriceContainer) ObjectUtils(org.apache.commons.lang3.ObjectUtils) alfio.model.transaction(alfio.model.transaction) UserDetails(org.springframework.security.core.userdetails.UserDetails) alfio.model.subscription(alfio.model.subscription) Collections.singletonMap(java.util.Collections.singletonMap) VatStatus(alfio.model.PriceContainer.VatStatus) ONCE_PER_EVENT(alfio.model.subscription.SubscriptionDescriptor.SubscriptionUsageType.ONCE_PER_EVENT) alfio.manager.support(alfio.manager.support) BankTransferManager(alfio.manager.payment.BankTransferManager) UpdateTicketOwnerForm(alfio.controller.form.UpdateTicketOwnerForm) TicketMetadata(alfio.model.metadata.TicketMetadata) DateUtils.addHours(org.apache.commons.lang3.time.DateUtils.addHours) Component(org.springframework.stereotype.Component) PaymentSpecification(alfio.manager.payment.PaymentSpecification) TransactionTemplate(org.springframework.transaction.support.TransactionTemplate) Log4j2(lombok.extern.log4j.Log4j2) PaymentMethodStatus(alfio.manager.PaymentManager.PaymentMethodDTO.PaymentMethodStatus) Clock(java.time.Clock) ConfigurationKeys(alfio.model.system.ConfigurationKeys) Transactional(org.springframework.transaction.annotation.Transactional) Assert(org.springframework.util.Assert) TicketPriceContainer(alfio.model.decorator.TicketPriceContainer) TicketMetadata(alfio.model.metadata.TicketMetadata) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TicketMetadataContainer(alfio.model.metadata.TicketMetadataContainer) Collections.singletonMap(java.util.Collections.singletonMap)

Example 9 with ObjectUtils.firstNonNull

use of org.apache.commons.lang3.ObjectUtils.firstNonNull in project dhis2-core by dhis2.

the class JdbcEventStore method getEvents.

// -------------------------------------------------------------------------
// EventStore implementation
// -------------------------------------------------------------------------
@Override
public List<Event> getEvents(EventSearchParams params, List<OrganisationUnit> organisationUnits, Map<String, Set<String>> psdesWithSkipSyncTrue) {
    User user = currentUserService.getCurrentUser();
    setAccessiblePrograms(user, params);
    Map<String, Event> eventUidToEventMap = new HashMap<>(params.getPageSizeWithDefault());
    List<Event> events = new ArrayList<>();
    List<Long> relationshipIds = new ArrayList<>();
    final Gson gson = new Gson();
    String sql = buildSql(params, organisationUnits, user);
    SqlRowSet rowSet = jdbcTemplate.queryForRowSet(sql);
    log.debug("Event query SQL: " + sql);
    Set<String> notes = new HashSet<>();
    while (rowSet.next()) {
        if (rowSet.getString("psi_uid") == null || (params.getCategoryOptionCombo() == null && !isSuper(user) && !userHasAccess(rowSet))) {
            continue;
        }
        String psiUid = rowSet.getString("psi_uid");
        Event event;
        if (!eventUidToEventMap.containsKey(psiUid)) {
            validateIdentifiersPresence(rowSet, params.getIdSchemes(), true);
            event = new Event();
            eventUidToEventMap.put(psiUid, event);
            if (!params.isSkipEventId()) {
                event.setUid(psiUid);
                event.setEvent(psiUid);
            }
            event.setTrackedEntityInstance(rowSet.getString("tei_uid"));
            event.setStatus(EventStatus.valueOf(rowSet.getString("psi_status")));
            ProgramType programType = ProgramType.fromValue(rowSet.getString("p_type"));
            event.setProgram(rowSet.getString("p_identifier"));
            event.setProgramType(programType);
            event.setProgramStage(rowSet.getString("ps_identifier"));
            event.setOrgUnit(rowSet.getString("ou_identifier"));
            event.setDeleted(rowSet.getBoolean("psi_deleted"));
            if (programType != ProgramType.WITHOUT_REGISTRATION) {
                event.setEnrollment(rowSet.getString("pi_uid"));
                event.setEnrollmentStatus(EnrollmentStatus.fromProgramStatus(ProgramStatus.valueOf(rowSet.getString("pi_status"))));
                event.setFollowup(rowSet.getBoolean("pi_followup"));
            }
            if (params.getCategoryOptionCombo() == null && !isSuper(user)) {
                event.setOptionSize(rowSet.getInt("option_size"));
            }
            event.setAttributeOptionCombo(rowSet.getString("coc_identifier"));
            event.setAttributeCategoryOptions(rowSet.getString("deco_uid"));
            event.setTrackedEntityInstance(rowSet.getString("tei_uid"));
            event.setStoredBy(rowSet.getString("psi_storedby"));
            event.setOrgUnitName(rowSet.getString("ou_name"));
            event.setDueDate(DateUtils.getIso8601NoTz(rowSet.getDate("psi_duedate")));
            event.setEventDate(DateUtils.getIso8601NoTz(rowSet.getDate("psi_executiondate")));
            event.setCreated(DateUtils.getIso8601NoTz(rowSet.getDate("psi_created")));
            event.setCreatedByUserInfo(jsonToUserInfo(rowSet.getString("psi_createdbyuserinfo"), jsonMapper));
            event.setLastUpdated(DateUtils.getIso8601NoTz(rowSet.getDate("psi_lastupdated")));
            event.setLastUpdatedByUserInfo(jsonToUserInfo(rowSet.getString("psi_lastupdatedbyuserinfo"), jsonMapper));
            event.setCompletedBy(rowSet.getString("psi_completedby"));
            event.setCompletedDate(DateUtils.getIso8601NoTz(rowSet.getDate("psi_completeddate")));
            if (rowSet.getObject("psi_geometry") != null) {
                try {
                    Geometry geom = new WKTReader().read(rowSet.getString("psi_geometry"));
                    event.setGeometry(geom);
                } catch (ParseException e) {
                    log.error("Unable to read geometry for event '" + event.getUid() + "': ", e);
                }
            }
            if (rowSet.getObject("user_assigned") != null) {
                event.setAssignedUser(rowSet.getString("user_assigned"));
                event.setAssignedUserUsername(rowSet.getString("user_assigned_username"));
                event.setAssignedUserDisplayName(rowSet.getString("user_assigned_name"));
            }
            events.add(event);
        } else {
            event = eventUidToEventMap.get(psiUid);
            String attributeCategoryCombination = event.getAttributeCategoryOptions();
            String currentAttributeCategoryCombination = rowSet.getString("deco_uid");
            if (!attributeCategoryCombination.contains(currentAttributeCategoryCombination)) {
                event.setAttributeCategoryOptions(attributeCategoryCombination + ";" + currentAttributeCategoryCombination);
            }
        }
        if (!StringUtils.isEmpty(rowSet.getString("psi_eventdatavalues"))) {
            Set<EventDataValue> eventDataValues = convertEventDataValueJsonIntoSet(rowSet.getString("psi_eventdatavalues"));
            for (EventDataValue dv : eventDataValues) {
                DataValue dataValue = convertEventDataValueIntoDtoDataValue(dv);
                if (params.isSynchronizationQuery()) {
                    if (psdesWithSkipSyncTrue.containsKey(rowSet.getString("ps_uid")) && psdesWithSkipSyncTrue.get(rowSet.getString("ps_uid")).contains(dv.getDataElement())) {
                        dataValue.setSkipSynchronization(true);
                    } else {
                        dataValue.setSkipSynchronization(false);
                    }
                }
                event.getDataValues().add(dataValue);
            }
        }
        if (rowSet.getString("psinote_value") != null && !notes.contains(rowSet.getString("psinote_id"))) {
            Note note = new Note();
            note.setNote(rowSet.getString("psinote_uid"));
            note.setValue(rowSet.getString("psinote_value"));
            note.setStoredDate(DateUtils.getIso8601NoTz(rowSet.getDate("psinote_storeddate")));
            note.setStoredBy(rowSet.getString("psinote_storedby"));
            if (rowSet.getObject("usernote_id") != null) {
                note.setLastUpdatedBy(UserInfoSnapshot.of(rowSet.getLong("usernote_id"), rowSet.getString("usernote_code"), rowSet.getString("usernote_uid"), rowSet.getString("usernote_username"), rowSet.getString("userinfo_firstname"), rowSet.getString("userinfo_surname")));
            }
            note.setLastUpdated(rowSet.getDate("psinote_lastupdated"));
            event.getNotes().add(note);
            notes.add(rowSet.getString("psinote_id"));
        }
        if (params.isIncludeRelationships() && rowSet.getObject("psi_rl") != null) {
            PGobject pGobject = (PGobject) rowSet.getObject("psi_rl");
            if (pGobject != null) {
                String value = pGobject.getValue();
                relationshipIds.addAll(Lists.newArrayList(gson.fromJson(value, Long[].class)));
            }
        }
    }
    final Multimap<String, Relationship> map = eventStore.getRelationshipsByIds(relationshipIds);
    if (!map.isEmpty()) {
        events.forEach(e -> e.getRelationships().addAll(map.get(e.getEvent())));
    }
    IdSchemes idSchemes = ObjectUtils.firstNonNull(params.getIdSchemes(), new IdSchemes());
    IdScheme dataElementIdScheme = idSchemes.getDataElementIdScheme();
    if (dataElementIdScheme != IdScheme.ID && dataElementIdScheme != IdScheme.UID) {
        CachingMap<String, String> dataElementUidToIdentifierCache = new CachingMap<>();
        List<Collection<DataValue>> dataValuesList = events.stream().map(Event::getDataValues).collect(Collectors.toList());
        populateCache(dataElementIdScheme, dataValuesList, dataElementUidToIdentifierCache);
        convertDataValuesIdentifiers(dataElementIdScheme, dataValuesList, dataElementUidToIdentifierCache);
    }
    if (params.getCategoryOptionCombo() == null && !isSuper(user)) {
        return events.stream().filter(ev -> ev.getAttributeCategoryOptions() != null && splitToArray(ev.getAttributeCategoryOptions(), TextUtils.SEMICOLON).size() == ev.getOptionSize()).collect(Collectors.toList());
    }
    return events;
}
Also used : SqlRowSet(org.springframework.jdbc.support.rowset.SqlRowSet) EventUtils.userInfoToJson(org.hisp.dhis.dxf2.events.event.EventUtils.userInfoToJson) WKTReader(org.locationtech.jts.io.WKTReader) UID(org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.UID) CREATEDCLIENT(org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.CREATEDCLIENT) EventRow(org.hisp.dhis.dxf2.events.report.EventRow) DELETED(org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.DELETED) UPDATED(org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.UPDATED) StringUtils(org.apache.commons.lang3.StringUtils) EVENT_CREATED_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_CREATED_ID) EVENT_EXECUTION_DATE_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_EXECUTION_DATE_ID) Relationship(org.hisp.dhis.dxf2.events.trackedentity.Relationship) EnrollmentStatus(org.hisp.dhis.dxf2.events.enrollment.EnrollmentStatus) STATIC_EVENT_COLUMNS(org.hisp.dhis.dxf2.events.event.AbstractEventService.STATIC_EVENT_COLUMNS) CREATED(org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.CREATED) Map(java.util.Map) SqlUtils.castToNumber(org.hisp.dhis.system.util.SqlUtils.castToNumber) EventDataValue(org.hisp.dhis.eventdatavalue.EventDataValue) SqlUtils.lower(org.hisp.dhis.system.util.SqlUtils.lower) SqlRowSet(org.springframework.jdbc.support.rowset.SqlRowSet) Repository(org.springframework.stereotype.Repository) EVENT_STATUS_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_STATUS_ID) OrganisationUnitSelectionMode(org.hisp.dhis.common.OrganisationUnitSelectionMode) JpaQueryUtils(org.hisp.dhis.query.JpaQueryUtils) DateUtils.getMediumDateString(org.hisp.dhis.util.DateUtils.getMediumDateString) Set(java.util.Set) STATUS(org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.STATUS) EXECUTION_DATE(org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.EXECUTION_DATE) PreparedStatement(java.sql.PreparedStatement) Attribute(org.hisp.dhis.dxf2.events.trackedentity.Attribute) TextUtils.removeLastComma(org.hisp.dhis.commons.util.TextUtils.removeLastComma) Slf4j(lombok.extern.slf4j.Slf4j) ParseException(org.locationtech.jts.io.ParseException) ProgramType(org.hisp.dhis.program.ProgramType) QueryFilter(org.hisp.dhis.common.QueryFilter) EVENT_STORED_BY_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_STORED_BY_ID) Joiner(com.google.common.base.Joiner) QueryItem(org.hisp.dhis.common.QueryItem) ProgramStageInstance(org.hisp.dhis.program.ProgramStageInstance) EVENT_GEOMETRY(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_GEOMETRY) ArrayList(java.util.ArrayList) SQLException(java.sql.SQLException) Lists(com.google.common.collect.Lists) IdentifiableObjectManager(org.hisp.dhis.common.IdentifiableObjectManager) STOREDBY(org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.STOREDBY) SqlHelper(org.hisp.dhis.commons.util.SqlHelper) OrderParam(org.hisp.dhis.webapi.controller.event.mapper.OrderParam) EVENT_ENROLLMENT_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_ENROLLMENT_ID) IdSchemes(org.hisp.dhis.common.IdSchemes) QueryOperator(org.hisp.dhis.common.QueryOperator) ID(org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.ID) IOException(java.io.IOException) StatementBuilder(org.hisp.dhis.jdbc.StatementBuilder) ObjectUtils(org.hisp.dhis.util.ObjectUtils) GEOMETRY(org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.GEOMETRY) COMPLETEDBY(org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.COMPLETEDBY) DateUtils(org.hisp.dhis.util.DateUtils) TextUtils(org.hisp.dhis.commons.util.TextUtils) EVENT_PROGRAM_STAGE_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_PROGRAM_STAGE_ID) Date(java.util.Date) ValueType(org.hisp.dhis.common.ValueType) DateUtils.getDateAfterAddition(org.hisp.dhis.util.DateUtils.getDateAfterAddition) RequiredArgsConstructor(lombok.RequiredArgsConstructor) EVENT_LAST_UPDATED_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_LAST_UPDATED_ID) ObjectReader(com.fasterxml.jackson.databind.ObjectReader) Gson(com.google.gson.Gson) SqlUtils.escapeSql(org.hisp.dhis.system.util.SqlUtils.escapeSql) TextUtils.getQuotedCommaDelimitedString(org.hisp.dhis.commons.util.TextUtils.getQuotedCommaDelimitedString) TypeReference(com.fasterxml.jackson.core.type.TypeReference) EVENT_PROGRAM_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_PROGRAM_ID) EventUtils.eventDataValuesToJson(org.hisp.dhis.dxf2.events.event.EventUtils.eventDataValuesToJson) EVENT_DUE_DATE_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_DUE_DATE_ID) ImmutableMap(com.google.common.collect.ImmutableMap) DateUtils.getLongGmtDateString(org.hisp.dhis.util.DateUtils.getLongGmtDateString) BaseIdentifiableObject(org.hisp.dhis.common.BaseIdentifiableObject) Timestamp(java.sql.Timestamp) Collection(java.util.Collection) UserInfoSnapshot(org.hisp.dhis.program.UserInfoSnapshot) EventStatus(org.hisp.dhis.event.EventStatus) Collectors(java.util.stream.Collectors) TextUtils.splitToArray(org.hisp.dhis.commons.util.TextUtils.splitToArray) List(java.util.List) CollectionUtils.isNotEmpty(org.apache.commons.collections4.CollectionUtils.isNotEmpty) Environment(org.springframework.core.env.Environment) AclService(org.hisp.dhis.security.acl.AclService) Optional(java.util.Optional) Geometry(org.locationtech.jts.geom.Geometry) BatchPreparedStatementSetterWithKeyHolder(org.hisp.dhis.jdbc.BatchPreparedStatementSetterWithKeyHolder) EVENT_ORG_UNIT_NAME(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_ORG_UNIT_NAME) EVENT_CREATED_BY_USER_INFO_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_CREATED_BY_USER_INFO_ID) EVENT_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_ID) DataAccessException(org.springframework.dao.DataAccessException) HashMap(java.util.HashMap) Multimap(com.google.common.collect.Multimap) Program(org.hisp.dhis.program.Program) JdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) HashSet(java.util.HashSet) DataElement(org.hisp.dhis.dataelement.DataElement) PGobject(org.postgresql.util.PGobject) ImmutableList(com.google.common.collect.ImmutableList) UPDATEDCLIENT(org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.UPDATEDCLIENT) Qualifier(org.springframework.beans.factory.annotation.Qualifier) User(org.hisp.dhis.user.User) EVENT_ORG_UNIT_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_ORG_UNIT_ID) EVENT_LAST_UPDATED_BY_USER_INFO_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_LAST_UPDATED_BY_USER_INFO_ID) EVENT_DELETED(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_DELETED) JdbcUtils(org.hisp.dhis.jdbc.JdbcUtils) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) EventUtils.jsonToUserInfo(org.hisp.dhis.dxf2.events.event.EventUtils.jsonToUserInfo) ProgramStage(org.hisp.dhis.program.ProgramStage) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) ProgramStatus(org.hisp.dhis.program.ProgramStatus) Collectors.toList(java.util.stream.Collectors.toList) CollectionUtils(org.hisp.dhis.commons.collection.CollectionUtils) EVENT_ATTRIBUTE_OPTION_COMBO_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_ATTRIBUTE_OPTION_COMBO_ID) JsonEventDataValueSetBinaryType(org.hisp.dhis.hibernate.jsonb.type.JsonEventDataValueSetBinaryType) CurrentUserService(org.hisp.dhis.user.CurrentUserService) COMPLETEDDATE(org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.COMPLETEDDATE) CachingMap(org.hisp.dhis.commons.collection.CachingMap) DUE_DATE(org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.DUE_DATE) Comparator(java.util.Comparator) EVENT_COMPLETED_BY_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_COMPLETED_BY_ID) EVENT_COMPLETED_DATE_ID(org.hisp.dhis.dxf2.events.event.EventSearchParams.EVENT_COMPLETED_DATE_ID) IdScheme(org.hisp.dhis.common.IdScheme) User(org.hisp.dhis.user.User) IdSchemes(org.hisp.dhis.common.IdSchemes) HashMap(java.util.HashMap) EventDataValue(org.hisp.dhis.eventdatavalue.EventDataValue) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) DateUtils.getMediumDateString(org.hisp.dhis.util.DateUtils.getMediumDateString) TextUtils.getQuotedCommaDelimitedString(org.hisp.dhis.commons.util.TextUtils.getQuotedCommaDelimitedString) DateUtils.getLongGmtDateString(org.hisp.dhis.util.DateUtils.getLongGmtDateString) WKTReader(org.locationtech.jts.io.WKTReader) PGobject(org.postgresql.util.PGobject) CachingMap(org.hisp.dhis.commons.collection.CachingMap) ProgramType(org.hisp.dhis.program.ProgramType) EventDataValue(org.hisp.dhis.eventdatavalue.EventDataValue) HashSet(java.util.HashSet) IdScheme(org.hisp.dhis.common.IdScheme) Geometry(org.locationtech.jts.geom.Geometry) Relationship(org.hisp.dhis.dxf2.events.trackedentity.Relationship) Collection(java.util.Collection) ParseException(org.locationtech.jts.io.ParseException)

Example 10 with ObjectUtils.firstNonNull

use of org.apache.commons.lang3.ObjectUtils.firstNonNull in project dhis2-core by dhis2.

the class DefaultDataValueSetService method createDataValueSetImportContext.

private ImportContext createDataValueSetImportContext(ImportOptions options, DataValueSet data) {
    options = ObjectUtils.firstNonNull(options, ImportOptions.getDefaultImportOptions());
    final User currentUser = currentUserService.getCurrentUser();
    boolean auditEnabled = config.isEnabled(CHANGELOG_AGGREGATE);
    boolean hasSkipAuditAuth = currentUser != null && currentUser.isAuthorized(Authorities.F_SKIP_DATA_IMPORT_AUDIT);
    boolean skipAudit = (options.isSkipAudit() && hasSkipAuditAuth) || !auditEnabled;
    SystemSettingManager settings = systemSettingManager;
    IdScheme dataElementIdScheme = createIdScheme(data.getDataElementIdSchemeProperty(), options, IdSchemes::getDataElementIdScheme);
    IdScheme orgUnitIdScheme = createIdScheme(data.getOrgUnitIdSchemeProperty(), options, IdSchemes::getOrgUnitIdScheme);
    IdScheme categoryOptComboIdScheme = createIdScheme(data.getCategoryOptionComboIdSchemeProperty(), options, IdSchemes::getCategoryOptionComboIdScheme);
    IdScheme dataSetIdScheme = createIdScheme(data.getDataSetIdSchemeProperty(), options, IdSchemes::getDataSetIdScheme);
    return ImportContext.builder().importOptions(options).summary(new ImportSummary().setImportOptions(options)).isIso8601(calendarService.getSystemCalendar().isIso8601()).skipLockExceptionCheck(!lockExceptionStore.anyExists()).i18n(i18nManager.getI18n()).currentUser(currentUser).currentOrgUnits(currentUserService.getCurrentUserOrganisationUnits()).hasSkipAuditAuth(hasSkipAuditAuth).skipAudit(skipAudit).idScheme(createIdScheme(data.getIdSchemeProperty(), options, IdSchemes::getIdScheme)).dataElementIdScheme(dataElementIdScheme).orgUnitIdScheme(orgUnitIdScheme).categoryOptComboIdScheme(categoryOptComboIdScheme).dataSetIdScheme(dataSetIdScheme).strategy(data.getStrategy() != null ? ImportStrategy.valueOf(data.getStrategy()) : options.getImportStrategy()).dryRun(data.getDryRun() != null ? data.getDryRun() : options.isDryRun()).skipExistingCheck(options.isSkipExistingCheck()).strictPeriods(options.isStrictPeriods() || settings.getBoolSetting(SettingKey.DATA_IMPORT_STRICT_PERIODS)).strictDataElements(options.isStrictDataElements() || settings.getBoolSetting(SettingKey.DATA_IMPORT_STRICT_DATA_ELEMENTS)).strictCategoryOptionCombos(options.isStrictCategoryOptionCombos() || settings.getBoolSetting(SettingKey.DATA_IMPORT_STRICT_CATEGORY_OPTION_COMBOS)).strictAttrOptionCombos(options.isStrictAttributeOptionCombos() || settings.getBoolSetting(SettingKey.DATA_IMPORT_STRICT_ATTRIBUTE_OPTION_COMBOS)).strictOrgUnits(options.isStrictOrganisationUnits() || settings.getBoolSetting(SettingKey.DATA_IMPORT_STRICT_ORGANISATION_UNITS)).requireCategoryOptionCombo(options.isRequireCategoryOptionCombo() || settings.getBoolSetting(SettingKey.DATA_IMPORT_REQUIRE_CATEGORY_OPTION_COMBO)).requireAttrOptionCombo(options.isRequireAttributeOptionCombo() || settings.getBoolSetting(SettingKey.DATA_IMPORT_REQUIRE_ATTRIBUTE_OPTION_COMBO)).forceDataInput(inputUtils.canForceDataInput(currentUser, options.isForce())).dataElementCallable(new IdentifiableObjectCallable<>(identifiableObjectManager, DataElement.class, dataElementIdScheme, null)).orgUnitCallable(new IdentifiableObjectCallable<>(identifiableObjectManager, OrganisationUnit.class, orgUnitIdScheme, trimToNull(data.getOrgUnit()))).categoryOptionComboCallable(new CategoryOptionComboAclCallable(categoryService, categoryOptComboIdScheme, null)).attributeOptionComboCallable(new CategoryOptionComboAclCallable(categoryService, categoryOptComboIdScheme, null)).periodCallable(new PeriodCallable(periodService, null, trimToNull(data.getPeriod()))).dataValueBatchHandler(batchHandlerFactory.createBatchHandler(DataValueBatchHandler.class).init()).auditBatchHandler(skipAudit ? null : batchHandlerFactory.createBatchHandler(DataValueAuditBatchHandler.class).init()).singularNameForType(klass -> schemaService.getDynamicSchema(klass).getSingular()).build();
}
Also used : DataValueAuditBatchHandler(org.hisp.dhis.jdbc.batchhandler.DataValueAuditBatchHandler) ImportStrategy(org.hisp.dhis.importexport.ImportStrategy) CategoryService(org.hisp.dhis.category.CategoryService) Authorities(org.hisp.dhis.security.Authorities) ValidationUtils.dataValueIsZeroAndInsignificant(org.hisp.dhis.system.util.ValidationUtils.dataValueIsZeroAndInsignificant) Date(java.util.Date) PeriodService(org.hisp.dhis.period.PeriodService) ValidationUtils(org.hisp.dhis.system.util.ValidationUtils) CompleteDataSetRegistrationService(org.hisp.dhis.dataset.CompleteDataSetRegistrationService) OrganisationUnitService(org.hisp.dhis.organisationunit.OrganisationUnitService) ErrorMessage(org.hisp.dhis.feedback.ErrorMessage) ImportCount(org.hisp.dhis.dxf2.importsummary.ImportCount) ImportSummary(org.hisp.dhis.dxf2.importsummary.ImportSummary) CurrentUserServiceTarget(org.hisp.dhis.user.CurrentUserServiceTarget) FileResourceService(org.hisp.dhis.fileresource.FileResourceService) IdentifiableProperty(org.hisp.dhis.common.IdentifiableProperty) DataExportParams(org.hisp.dhis.datavalue.DataExportParams) XMLFactory(org.hisp.staxwax.factory.XMLFactory) InputUtils(org.hisp.dhis.dxf2.util.InputUtils) JobConfiguration(org.hisp.dhis.scheduling.JobConfiguration) Period(org.hisp.dhis.period.Period) StringUtils.trimToNull(org.apache.commons.lang3.StringUtils.trimToNull) CollectionUtils.isEmpty(org.hisp.dhis.commons.collection.CollectionUtils.isEmpty) DxfNamespaces(org.hisp.dhis.common.DxfNamespaces) CHANGELOG_AGGREGATE(org.hisp.dhis.external.conf.ConfigurationKey.CHANGELOG_AGGREGATE) OrganisationUnitGroup(org.hisp.dhis.organisationunit.OrganisationUnitGroup) StreamUtils.wrapAndCheckCompressionFormat(org.hisp.dhis.commons.util.StreamUtils.wrapAndCheckCompressionFormat) DataValueAudit(org.hisp.dhis.datavalue.DataValueAudit) WARN(org.hisp.dhis.system.notification.NotificationLevel.WARN) SchemaService(org.hisp.dhis.schema.SchemaService) Objects(java.util.Objects) SimpleNode(org.hisp.dhis.node.types.SimpleNode) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) Clock(org.hisp.dhis.system.util.Clock) ComplexNode(org.hisp.dhis.node.types.ComplexNode) CategoryOptionCombo(org.hisp.dhis.category.CategoryOptionCombo) Writer(java.io.Writer) AclService(org.hisp.dhis.security.acl.AclService) RootNode(org.hisp.dhis.node.types.RootNode) BatchHandlerFactory(org.hisp.quick.BatchHandlerFactory) CollectionNode(org.hisp.dhis.node.types.CollectionNode) BatchHandlerFactoryTarget(org.hisp.dhis.common.BatchHandlerFactoryTarget) DataSet(org.hisp.dhis.dataset.DataSet) DateUtils.parseDate(org.hisp.dhis.util.DateUtils.parseDate) Callable(java.util.concurrent.Callable) BooleanUtils(org.apache.commons.lang3.BooleanUtils) AuditType(org.hisp.dhis.common.AuditType) DataSetContext(org.hisp.dhis.dxf2.datavalueset.ImportContext.DataSetContext) IllegalQueryException(org.hisp.dhis.common.IllegalQueryException) Function(java.util.function.Function) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) DataElement(org.hisp.dhis.dataelement.DataElement) PeriodCallable(org.hisp.dhis.system.callable.PeriodCallable) Notifier(org.hisp.dhis.system.notification.Notifier) DataValueService(org.hisp.dhis.datavalue.DataValueService) DataValueBatchHandler(org.hisp.dhis.jdbc.batchhandler.DataValueBatchHandler) CategoryOptionComboAclCallable(org.hisp.dhis.system.callable.CategoryOptionComboAclCallable) IdentifiableObjectManager(org.hisp.dhis.common.IdentifiableObjectManager) Service(org.springframework.stereotype.Service) User(org.hisp.dhis.user.User) ErrorCode(org.hisp.dhis.feedback.ErrorCode) IdentifiableObjectCallable(org.hisp.dhis.system.callable.IdentifiableObjectCallable) ImportStatus(org.hisp.dhis.dxf2.importsummary.ImportStatus) I18nManager(org.hisp.dhis.i18n.I18nManager) DataValueAuditBatchHandler(org.hisp.dhis.jdbc.batchhandler.DataValueAuditBatchHandler) SystemSettingManager(org.hisp.dhis.setting.SystemSettingManager) OutputStream(java.io.OutputStream) CsvUtils(org.hisp.dhis.system.util.CsvUtils) CompleteDataSetRegistration(org.hisp.dhis.dataset.CompleteDataSetRegistration) DhisConfigurationProvider(org.hisp.dhis.external.conf.DhisConfigurationProvider) IdSchemes(org.hisp.dhis.common.IdSchemes) FileResource(org.hisp.dhis.fileresource.FileResource) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) CalendarService(org.hisp.dhis.calendar.CalendarService) INFO(org.hisp.dhis.system.notification.NotificationLevel.INFO) ImportOptions(org.hisp.dhis.dxf2.common.ImportOptions) DebugUtils(org.hisp.dhis.commons.util.DebugUtils) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) ObjectUtils(org.hisp.dhis.util.ObjectUtils) NotificationLevel(org.hisp.dhis.system.notification.NotificationLevel) LockExceptionStore(org.hisp.dhis.dataset.LockExceptionStore) CurrentUserService(org.hisp.dhis.user.CurrentUserService) ERROR(org.hisp.dhis.system.notification.NotificationLevel.ERROR) DataValue(org.hisp.dhis.datavalue.DataValue) SettingKey(org.hisp.dhis.setting.SettingKey) AllArgsConstructor(lombok.AllArgsConstructor) DataElementGroup(org.hisp.dhis.dataelement.DataElementGroup) IdScheme(org.hisp.dhis.common.IdScheme) DateUtils(org.hisp.dhis.util.DateUtils) InputStream(java.io.InputStream) Transactional(org.springframework.transaction.annotation.Transactional) User(org.hisp.dhis.user.User) DataValueBatchHandler(org.hisp.dhis.jdbc.batchhandler.DataValueBatchHandler) IdSchemes(org.hisp.dhis.common.IdSchemes) ImportSummary(org.hisp.dhis.dxf2.importsummary.ImportSummary) CategoryOptionComboAclCallable(org.hisp.dhis.system.callable.CategoryOptionComboAclCallable) PeriodCallable(org.hisp.dhis.system.callable.PeriodCallable) IdScheme(org.hisp.dhis.common.IdScheme) IdentifiableObjectCallable(org.hisp.dhis.system.callable.IdentifiableObjectCallable) DataElement(org.hisp.dhis.dataelement.DataElement) SystemSettingManager(org.hisp.dhis.setting.SystemSettingManager)

Aggregations

Collectors (java.util.stream.Collectors)9 List (java.util.List)8 ObjectUtils (org.apache.commons.lang3.ObjectUtils)8 Set (java.util.Set)6 StringUtils (org.apache.commons.lang3.StringUtils)6 HashSet (java.util.HashSet)5 Map (java.util.Map)5 Function (java.util.function.Function)5 Transactional (org.springframework.transaction.annotation.Transactional)5 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 TextUtils (org.hisp.dhis.commons.util.TextUtils)4 OrganisationUnitSelectionMode (org.hisp.dhis.common.OrganisationUnitSelectionMode)3 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)3 CurrentUserService (org.hisp.dhis.user.CurrentUserService)3 User (org.hisp.dhis.user.User)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Joiner (com.google.common.base.Joiner)2 Lists (com.google.common.collect.Lists)2 IOException (java.io.IOException)2