staticFieldDefinitions property

List<FieldDefinition> staticFieldDefinitions
final

Implementation

static final List<FieldDefinition> staticFieldDefinitions = [
  FieldDefinition(
    'trip_id',
    (dataset, header, records) => true,
    type: const IdFieldType(displayName: 'Trip ID'),
    primaryKey: true,
  ),
  FieldDefinition(
    'arrival_time',
    (dataset, header, records) => null,
    type: const TimeFieldType(),
    shouldBeRequired: (dataset, header, record) {
      final timepoint = record.containsKey('timepoint')
          ? int.parse(record['timepoint']!)
          : null;
      if (timepoint == 1) {
        return true;
      }
      // TODO: Add first/last stop_sequence validation.
      if (record.containsKey('start_pickup_drop_off_window') ||
          record.containsKey('end_pickup_drop_off_window')) {
        return false;
      }

      return null;
    },
  ),
  FieldDefinition(
    'departure_time',
    (dataset, header, records) => null,
    type: const TimeFieldType(),
    shouldBeRequired: (dataset, header, record) {
      final timepoint = record.containsKey('timepoint')
          ? int.parse(record['timepoint']!)
          : null;
      if (timepoint == 1) {
        return true;
      }
      if (record.containsKey('start_pickup_drop_off_window') ||
          record.containsKey('end_pickup_drop_off_window')) {
        return false;
      }

      return null;
    },
  ),
  FieldDefinition(
    'stop_id',
    (dataset, header, records) => null,
    type: const IdFieldType(displayName: 'Stop ID'),
    shouldBeRequired: (dataset, header, record) =>
        !record.containsKey('location_group_id') &&
        !record.containsKey('location_id'),
  ),
  FieldDefinition(
    'location_group_id',
    (dataset, header, records) => null,
    type: const IdFieldType(displayName: 'Location group ID'),
    shouldBeRequired: (dataset, header, record) =>
        record.containsKey('stop_id') || record.containsKey('location_id')
        ? false
        : null,
  ),
  FieldDefinition(
    'location_id',
    (dataset, header, records) => null,
    type: const IdFieldType(displayName: 'Location ID'),
    shouldBeRequired: (dataset, header, record) =>
        record.containsKey('stop_id') ||
            record.containsKey('location_group_id')
        ? false
        : null,
  ),
  FieldDefinition(
    'stop_sequence',
    (dataset, header, records) => true,
    type: IntegerFieldType(NumberConstraint.nonNegative),
  ),
  FieldDefinition(
    'stop_headsign',
    (dataset, header, records) => null,
    type: TextFieldType(),
  ),
  FieldDefinition(
    'start_pickup_drop_off_window',
    (dataset, header, records) => null,
    type: const TimeFieldType(),
    shouldBeRequired: (dataset, header, record) {
      if (record.containsKey('location_group_id') ||
          record.containsKey('location_id')) {
        return true;
      }
      if (record.containsKey('end_pickup_drop_off_window')) {
        return true;
      }
      if (record.containsKey('arrival_time') ||
          record.containsKey('departure_time')) {
        return false;
      }
      return null;
    },
  ),
  FieldDefinition(
    'end_pickup_drop_off_window',
    (dataset, header, records) => null,
    type: const TimeFieldType(),
    shouldBeRequired: (dataset, header, record) {
      if (record.containsKey('location_group_id') ||
          record.containsKey('location_id')) {
        return true;
      }
      if (record.containsKey('start_pickup_drop_off_window')) {
        return true;
      }
      if (record.containsKey('arrival_time') ||
          record.containsKey('departure_time')) {
        return false;
      }
      return null;
    },
  ),
  FieldDefinition(
    'pickup_type',
    (dataset, header, records) => null,
    type: pickupType,
    shouldBeRequired: (dataset, header, record) {
      final dropOffWindowDefined =
          record.containsKey('start_pickup_drop_off_window') ||
          record.containsKey('end_pickup_drop_off_window');
      return dropOffWindowDefined &&
              ['', '0', '3'].contains(record['pickup_type'])
          ? false
          : null;
    },
    defaultValue: '0',
  ),
  FieldDefinition(
    'drop_off_type',
    (dataset, header, records) => null,
    type: dropOffType,
    shouldBeRequired: (dataset, header, record) {
      final dropOffWindowDefined =
          record.containsKey('start_pickup_drop_off_window') ||
          record.containsKey('end_pickup_drop_off_window');
      return dropOffWindowDefined &&
              ['', '0'].contains(record['drop_off_type'])
          ? false
          : null;
    },
    defaultValue: '0',
  ),
  FieldDefinition(
    'continuous_pickup',
    (dataset, header, records) => null,
    type: continuousPickup,
    shouldBeRequired: (dataset, header, record) {
      final dropOffWindowDefined =
          record.containsKey('start_pickup_drop_off_window') ||
          record.containsKey('end_pickup_drop_off_window');
      return dropOffWindowDefined ? false : null;
    },
    defaultValue: '1',
  ),
  FieldDefinition(
    'continuous_drop_off',
    (dataset, header, records) => null,
    type: continuousDropOff,
    shouldBeRequired: (dataset, header, record) {
      final dropOffWindowDefined =
          record.containsKey('start_pickup_drop_off_window') ||
          record.containsKey('end_pickup_drop_off_window');
      return dropOffWindowDefined ? false : null;
    },
    defaultValue: '1',
  ),
  FieldDefinition(
    'shape_dist_traveled',
    (dataset, header, records) => null,
    type: const FloatFieldType(NumberConstraint.nonNegative),
  ),
  FieldDefinition(
    'timepoint',
    (dataset, header, records) => null,
    type: timepoint,
  ),
  FieldDefinition(
    'pickup_booking_rule_id',
    (dataset, header, records) => null,
    type: const IdFieldType(displayName: 'Pickup booking rule ID'),
  ),
  FieldDefinition(
    'drop_off_booking_rule_id',
    (dataset, header, records) => null,
    type: const IdFieldType(displayName: 'Drop off booking rule ID'),
  ),
];