org.opentripplanner.netex.validation.DSJServiceJourneyNotFound Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of otp Show documentation
Show all versions of otp Show documentation
The OpenTripPlanner multimodal journey planning system
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