<commit_before>package org.hisp.dhis.android.core.trackedentity;

import org.hisp.dhis.android.core.arch.handlers.ObjectWithoutUidSyncHandlerImpl;
import org.hisp.dhis.android.core.data.database.DatabaseAdapter;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

@SuppressWarnings({"PMD.ClassWithOnlyPrivateConstructorsShouldBeFinal"})
public class TrackedEntityDataValueHandler extends ObjectWithoutUidSyncHandlerImpl<TrackedEntityDataValue> {
    private final TrackedEntityDataValueStore trackedEntityDataValueStore;

    private TrackedEntityDataValueHandler(TrackedEntityDataValueStore trackedEntityDataValueStore) {
        super(trackedEntityDataValueStore);
        this.trackedEntityDataValueStore = trackedEntityDataValueStore;
    }

    @Override
    protected void afterCollectionHandled(Collection<TrackedEntityDataValue> trackedEntityDataValues) {
        if (!trackedEntityDataValues.isEmpty()) {
            removeNotExistingDataValuesInServer(trackedEntityDataValues);
        }
    }

    private void removeNotExistingDataValuesInServer(Collection<TrackedEntityDataValue> trackedEntityDataValues) {
        String eventUid = trackedEntityDataValues.iterator().next().event();

        List<String> dataElementUids = new ArrayList<>();
        for (TrackedEntityDataValue dataValue : trackedEntityDataValues) {
            dataElementUids.add(dataValue.dataElement());
        }

        trackedEntityDataValueStore.deleteByEventAndNotInDataElements(eventUid, dataElementUids);
    }

    public static TrackedEntityDataValueHandler create(DatabaseAdapter databaseAdapter) {
        return new TrackedEntityDataValueHandler(TrackedEntityDataValueStoreImpl.create(databaseAdapter));
    }
}<commit_msg>Minor fix<commit_after>package org.hisp.dhis.android.core.trackedentity;

import org.hisp.dhis.android.core.arch.handlers.ObjectWithoutUidSyncHandlerImpl;
import org.hisp.dhis.android.core.data.database.DatabaseAdapter;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

@SuppressWarnings({"PMD.ClassWithOnlyPrivateConstructorsShouldBeFinal"})
public class TrackedEntityDataValueHandler extends ObjectWithoutUidSyncHandlerImpl<TrackedEntityDataValue> {
    private final TrackedEntityDataValueStore trackedEntityDataValueStore;

    private TrackedEntityDataValueHandler(TrackedEntityDataValueStore trackedEntityDataValueStore) {
        super(trackedEntityDataValueStore);
        this.trackedEntityDataValueStore = trackedEntityDataValueStore;
    }

    @Override
    protected void afterCollectionHandled(Collection<TrackedEntityDataValue> trackedEntityDataValues) {
        removeNotExistingDataValuesInServer(trackedEntityDataValues);
    }

    private void removeNotExistingDataValuesInServer(Collection<TrackedEntityDataValue> trackedEntityDataValues) {
        if (trackedEntityDataValues.isEmpty()) {
            return;
        }

        String eventUid = trackedEntityDataValues.iterator().next().event();

        List<String> dataElementUids = new ArrayList<>();
        for (TrackedEntityDataValue dataValue : trackedEntityDataValues) {
            dataElementUids.add(dataValue.dataElement());
        }

        trackedEntityDataValueStore.deleteByEventAndNotInDataElements(eventUid, dataElementUids);
    }

    public static TrackedEntityDataValueHandler create(DatabaseAdapter databaseAdapter) {
        return new TrackedEntityDataValueHandler(TrackedEntityDataValueStoreImpl.create(databaseAdapter));
    }
}
{'fraction_non_alphanumeric': 0.07228229937393284, 'fraction_numerical': 0.0, 'mean_word_length': 5.437728937728938, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5664880', 'n_tokens_mistral': 934, 'n_tokens_neox': 907, 'n_words': 126}