<commit_before>package au.gov.ga.geodesy.domain.model.equipment;

import java.lang.reflect.InvocationTargetException;
import java.util.Date;
import java.util.List;
import java.util.Optional;

import org.apache.commons.lang3.tuple.Pair;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import au.gov.ga.geodesy.domain.model.sitelog.EffectiveDates;
import au.gov.ga.geodesy.domain.model.sitelog.EquipmentLogItem;
import au.gov.ga.geodesy.domain.model.sitelog.FrequencyStandardLogItem;
import au.gov.ga.geodesy.domain.model.sitelog.GnssAntennaLogItem;
import au.gov.ga.geodesy.domain.model.sitelog.GnssReceiverLogItem;
import au.gov.ga.geodesy.domain.model.sitelog.HumiditySensorLogItem;
import au.gov.ga.geodesy.domain.model.sitelog.LogItemVisitor;
import au.gov.ga.geodesy.domain.model.sitelog.PressureSensorLogItem;
import au.gov.ga.geodesy.domain.model.sitelog.TemperatureSensorLogItem;
import au.gov.ga.geodesy.domain.model.sitelog.WaterVaporSensorLogItem;

@Component
public class EquipmentFactory {
    @SuppressWarnings("unused")
    private static final Log log = LogFactory.getLog(EquipmentFactory.class);

    @Autowired
    private EquipmentRepository equipment;

    @Autowired
    private EquipmentConfigurationRepository configurations;

    private EquipmentCreator creator = new EquipmentCreator();

    public Pair<? extends Equipment, ? extends EquipmentConfiguration> create(EquipmentLogItem logItem) {
        return logItem.accept(creator);
    }

    private class EquipmentCreator
            implements LogItemVisitor<Pair<? extends Equipment, ? extends EquipmentConfiguration>> {

        public Pair<? extends Equipment, ? extends EquipmentConfiguration> visit(GnssReceiverLogItem logItem) {
            GnssReceiver receiver = getEquipment(GnssReceiver.class, logItem);

            GnssReceiverConfiguration config = getConfiguration(GnssReceiverConfiguration.class,
                    receiver.getId(), logItem);

            config.setSatelliteSystem(logItem.getSatelliteSystem());
            config.setFirmwareVersion(logItem.getFirmwareVersion());
            config.setElevetionCutoffSetting(logItem.getElevationCutoffSetting());
            config.setTemperatureStabilization(logItem.getTemperatureStabilization());
            config.setNotes(logItem.getNotes());
            return Pair.of(receiver, config);
        }

        public Pair<? extends Equipment, ? extends EquipmentConfiguration> visit(GnssAntennaLogItem logItem) {
            GnssAntenna antenna = getEquipment(GnssAntenna.class, logItem);

            GnssAntennaConfiguration config =
                getConfiguration(GnssAntennaConfiguration.class, antenna.getId(), logItem);

            config.setAlignmentFromTrueNorth(logItem.getAlignmentFromTrueNorth());
            return Pair.of(antenna, config);
        }

        public Pair<? extends Equipment, ? extends EquipmentConfiguration> visit(HumiditySensorLogItem logItem) {
            HumiditySensor sensor = getEquipment(HumiditySensor.class, logItem);

            HumiditySensorConfiguration config =
                getConfiguration(HumiditySensorConfiguration.class, sensor.getId(), logItem);

            sensor.setAspiration(logItem.getAspiration());<commit_msg>Copy antenna delta values from site logs<commit_after>package au.gov.ga.geodesy.domain.model.equipment;

import java.lang.reflect.InvocationTargetException;
import java.util.Date;
import java.util.List;
import java.util.Optional;

import org.apache.commons.lang3.tuple.Pair;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import au.gov.ga.geodesy.domain.model.sitelog.EffectiveDates;
import au.gov.ga.geodesy.domain.model.sitelog.EquipmentLogItem;
import au.gov.ga.geodesy.domain.model.sitelog.FrequencyStandardLogItem;
import au.gov.ga.geodesy.domain.model.sitelog.GnssAntennaLogItem;
import au.gov.ga.geodesy.domain.model.sitelog.GnssReceiverLogItem;
import au.gov.ga.geodesy.domain.model.sitelog.HumiditySensorLogItem;
import au.gov.ga.geodesy.domain.model.sitelog.LogItemVisitor;
import au.gov.ga.geodesy.domain.model.sitelog.PressureSensorLogItem;
import au.gov.ga.geodesy.domain.model.sitelog.TemperatureSensorLogItem;
import au.gov.ga.geodesy.domain.model.sitelog.WaterVaporSensorLogItem;

@Component
public class EquipmentFactory {
    @SuppressWarnings("unused")
    private static final Log log = LogFactory.getLog(EquipmentFactory.class);

    @Autowired
    private EquipmentRepository equipment;

    @Autowired
    private EquipmentConfigurationRepository configurations;

    private EquipmentCreator creator = new EquipmentCreator();

    public Pair<? extends Equipment, ? extends EquipmentConfiguration> create(EquipmentLogItem logItem) {
        return logItem.accept(creator);
    }

    private class EquipmentCreator
            implements LogItemVisitor<Pair<? extends Equipment, ? extends EquipmentConfiguration>> {

        public Pair<? extends Equipment, ? extends EquipmentConfiguration> visit(GnssReceiverLogItem logItem) {
            GnssReceiver receiver = getEquipment(GnssReceiver.class, logItem);

            GnssReceiverConfiguration config = getConfiguration(GnssReceiverConfiguration.class,
                    receiver.getId(), logItem);

            config.setSatelliteSystem(logItem.getSatelliteSystem());
            config.setFirmwareVersion(logItem.getFirmwareVersion());
            config.setElevetionCutoffSetting(logItem.getElevationCutoffSetting());
            config.setTemperatureStabilization(logItem.getTemperatureStabilization());
            config.setNotes(logItem.getNotes());
            return Pair.of(receiver, config);
        }

        public Pair<? extends Equipment, ? extends EquipmentConfiguration> visit(GnssAntennaLogItem logItem) {
            GnssAntenna antenna = getEquipment(GnssAntenna.class, logItem);

            GnssAntennaConfiguration config =
                getConfiguration(GnssAntennaConfiguration.class, antenna.getId(), logItem);

            config.setAlignmentFromTrueNorth(logItem.getAlignmentFromTrueNorth());
            config.setMarkerArpUpEccentricity(logItem.getMarkerArpUpEcc());
            config.setMarkerArpNorthEccentricity(logItem.getMarkerArpNorthEcc());
            config.setMarkerArpEastEccentricity(logItem.getMarkerArpEastEcc());
            return Pair.of(antenna, config);
        }

        public Pair<? extends Equipment, ? extends EquipmentConfiguration> visit(HumiditySensorLogItem logItem) {
            HumiditySensor sensor = getEquipment(HumiditySensor.class, logItem);

            HumiditySensorConfiguration config =
                getConfiguration(HumiditySensorConfiguration.class, sensor.getId(), logItem);

            sensor.setAspiration(logItem.getAspiration());
{'fraction_non_alphanumeric': 0.08951188273801053, 'fraction_numerical': 0.00028461647929415115, 'mean_word_length': 4.182890855457227, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '7153239', 'n_tokens_mistral': 2015, 'n_tokens_neox': 1961, 'n_words': 302}