All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opentripplanner.netex.validation.DSJServiceJourneyNotFound Maven / Gradle / Ivy

There is a newer version: 2.6.0
Show newest version
package org.opentripplanner.netex.validation;

import java.util.List;
import javax.annotation.Nullable;
import javax.xml.bind.JAXBElement;
import org.opentripplanner.graph_builder.DataImportIssue;
import org.opentripplanner.netex.issues.ObjectNotFound;
import org.rutebanken.netex.model.DatedServiceJourney;
import org.rutebanken.netex.model.JourneyRefStructure;

class DSJServiceJourneyNotFound extends AbstractHMapValidationRule {

  @Override
  public Status validate(DatedServiceJourney dsj) {
    var ref = getServiceJourneyRef(dsj);
    var sj = index.getServiceJourneyById().lookup(ref);
    return sj == null ? Status.DISCARD : Status.OK;
  }

  @Override
  public DataImportIssue logMessage(String dsjId, DatedServiceJourney dsj) {
    String ref = getServiceJourneyRef(dsj);

    return new ObjectNotFound("DatedServiceJourney", dsj.getId(), "ServiceJourneyRef", ref);
  }

  @Nullable
  private String getServiceJourneyRef(DatedServiceJourney dsj) {
    List> journeyRef = dsj.getJourneyRef();

    if (journeyRef == null || journeyRef.isEmpty()) {
      return null;
    }
    JourneyRefStructure ref = journeyRef.get(0).getValue();
    return ref == null ? null : ref.getRef();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy