Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: additional annotation for notice export #922

Merged
merged 3 commits into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.mobilitydata.gtfsvalidator.annotation;

/**
* Annotation to be used on notice constructor. This specifies the constructor to be considered
* while exporting notice information.
*/
public @interface NoticeExport {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lionel-nj One comment here - I would suggest renaming this annotation and providing a more detailed description regarding the exact use case for which it exists.

For example, I think SchemaExport may be a better name here, or NoticeSchema, or something with schema in it, to distinguish it from the export of the notices themselves. It's not clear by the name or description of the annotation what exactly the annotation is used for - I'd link to the class that processes it too when that exists.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.univocity.parsers.common.TextParsingException;
import org.mobilitydata.gtfsvalidator.annotation.NoticeExport;

/**
* Parsing of a CSV file failed.
Expand All @@ -35,6 +36,7 @@ public class CsvParsingFailedNotice extends ValidationNotice {
* @param filename the name of the file
* @param exception the exception thrown
*/
@NoticeExport
public CsvParsingFailedNotice(String filename, TextParsingException exception) {
this(
filename,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.mobilitydata.gtfsvalidator.notice;

import com.google.common.collect.ImmutableMap;
import org.mobilitydata.gtfsvalidator.annotation.NoticeExport;

/**
* The values of the given key and rows are duplicates.
Expand Down Expand Up @@ -45,6 +46,7 @@ public DuplicateKeyNotice(
SeverityLevel.ERROR);
}

@NoticeExport
public DuplicateKeyNotice(
String filename,
long oldCsvRowNumber,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.mobilitydata.gtfsvalidator.notice;

import com.google.common.collect.ImmutableMap;
import org.mobilitydata.gtfsvalidator.annotation.NoticeExport;

/**
* The input file CSV header has the same column name repeated.
Expand All @@ -25,6 +26,7 @@
*/
public class DuplicatedColumnNotice extends ValidationNotice {
// Indices should start from 1.
@NoticeExport
public DuplicatedColumnNotice(
String filename, String fieldName, int firstIndex, int secondIndex) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
package org.mobilitydata.gtfsvalidator.notice;

import com.google.common.collect.ImmutableMap;
import org.mobilitydata.gtfsvalidator.annotation.NoticeExport;

/**
* A column name is empty. Such columns are skipped by the validator.
*
* <p>Severity: {@code SeverityLevel.WARNING}
*/
public class EmptyColumnNameNotice extends ValidationNotice {
@NoticeExport
public EmptyColumnNameNotice(String filename, int index) {
super(
ImmutableMap.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.mobilitydata.gtfsvalidator.notice;

import com.google.common.collect.ImmutableMap;
import org.mobilitydata.gtfsvalidator.annotation.NoticeExport;

/**
* A CSV file is empty.
Expand All @@ -25,6 +26,7 @@
*/
public class EmptyFileNotice extends ValidationNotice {

@NoticeExport
public EmptyFileNotice(String filename) {
super(ImmutableMap.of("filename", filename), SeverityLevel.ERROR);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.mobilitydata.gtfsvalidator.notice;

import com.google.common.collect.ImmutableMap;
import org.mobilitydata.gtfsvalidator.annotation.NoticeExport;

/**
* A row in the input file has only spaces.
Expand All @@ -28,6 +29,7 @@
*/
public class EmptyRowNotice extends ValidationNotice {

@NoticeExport
public EmptyRowNotice(String filename, long csvRowNumber) {
super(
ImmutableMap.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.mobilitydata.gtfsvalidator.notice;

import com.google.common.collect.ImmutableMap;
import org.mobilitydata.gtfsvalidator.annotation.NoticeExport;

/**
* The values of the given key and rows of one table cannot be found a values of the given key in
Expand All @@ -28,6 +29,7 @@
* <p>Severity: {@code SeverityLevel.ERROR}
*/
public class ForeignKeyViolationNotice extends ValidationNotice {
@NoticeExport
public ForeignKeyViolationNotice(
String childFilename,
String childFieldName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.mobilitydata.gtfsvalidator.notice;

import com.google.common.collect.ImmutableMap;
import org.mobilitydata.gtfsvalidator.annotation.NoticeExport;

/**
* A field contains an invalid color value.
Expand All @@ -30,6 +31,7 @@
*/
public class InvalidColorNotice extends ValidationNotice {

@NoticeExport
public InvalidColorNotice(
String filename, long csvRowNumber, String fieldName, String fieldValue) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.mobilitydata.gtfsvalidator.notice;

import com.google.common.collect.ImmutableMap;
import org.mobilitydata.gtfsvalidator.annotation.NoticeExport;

/**
* A field contains a wrong currency code.
Expand All @@ -31,6 +32,7 @@
*/
public class InvalidCurrencyNotice extends ValidationNotice {

@NoticeExport
public InvalidCurrencyNotice(
String filename, long csvRowNumber, String fieldName, String fieldValue) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.mobilitydata.gtfsvalidator.notice;

import com.google.common.collect.ImmutableMap;
import org.mobilitydata.gtfsvalidator.annotation.NoticeExport;

/**
* A field cannot be parsed as date.
Expand All @@ -29,6 +30,7 @@
*/
public class InvalidDateNotice extends ValidationNotice {

@NoticeExport
public InvalidDateNotice(
String filename, long csvRowNumber, String fieldName, String fieldValue) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.mobilitydata.gtfsvalidator.notice;

import com.google.common.collect.ImmutableMap;
import org.mobilitydata.gtfsvalidator.annotation.NoticeExport;

/**
* A field contains a malformed email address.
Expand All @@ -33,6 +34,7 @@ public class InvalidEmailNotice extends ValidationNotice {
* Constructs a notice with given severity. This constructor may be used by users that want to
* lower the priority to {@code WARNING}.
*/
@NoticeExport
public InvalidEmailNotice(
String filename,
long csvRowNumber,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.mobilitydata.gtfsvalidator.notice;

import com.google.common.collect.ImmutableMap;
import org.mobilitydata.gtfsvalidator.annotation.NoticeExport;

/**
* A field cannot be parsed as a floating point number.
Expand All @@ -25,6 +26,7 @@
*/
public class InvalidFloatNotice extends ValidationNotice {

@NoticeExport
public InvalidFloatNotice(
String filename, long csvRowNumber, String fieldName, String fieldValue) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.mobilitydata.gtfsvalidator.notice;

import com.google.common.collect.ImmutableMap;
import org.mobilitydata.gtfsvalidator.annotation.NoticeExport;

/**
* A field cannot be parsed as an integer.
Expand All @@ -25,6 +26,7 @@
*/
public class InvalidIntegerNotice extends ValidationNotice {

@NoticeExport
public InvalidIntegerNotice(
String filename, long csvRowNumber, String fieldName, String fieldValue) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.mobilitydata.gtfsvalidator.notice;

import com.google.common.collect.ImmutableMap;
import org.mobilitydata.gtfsvalidator.annotation.NoticeExport;

/**
* A field contains a wrong language code.
Expand All @@ -30,6 +31,7 @@
*/
public class InvalidLanguageCodeNotice extends ValidationNotice {

@NoticeExport
public InvalidLanguageCodeNotice(
String filename, long csvRowNumber, String fieldName, String fieldValue) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.mobilitydata.gtfsvalidator.notice;

import com.google.common.collect.ImmutableMap;
import org.mobilitydata.gtfsvalidator.annotation.NoticeExport;

/**
* A field contains a malformed phone number.
Expand All @@ -33,6 +34,7 @@ public class InvalidPhoneNumberNotice extends ValidationNotice {
* Constructs a notice with given severity. This constructor may be used by users that want to
* lower the priority to {@code WARNING}.
*/
@NoticeExport
public InvalidPhoneNumberNotice(
String filename,
long csvRowNumber,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
package org.mobilitydata.gtfsvalidator.notice;

import com.google.common.collect.ImmutableMap;
import org.mobilitydata.gtfsvalidator.annotation.NoticeExport;

/**
* A row in the input file has a different number of values than specified by the CSV header.
*
* <p>Severity: {@code SeverityLevel.ERROR}
*/
public class InvalidRowLengthNotice extends ValidationNotice {
@NoticeExport
public InvalidRowLengthNotice(
String filename, long csvRowNumber, int rowLength, int headerCount) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.mobilitydata.gtfsvalidator.notice;

import com.google.common.collect.ImmutableMap;
import org.mobilitydata.gtfsvalidator.annotation.NoticeExport;

/**
* A field cannot be parsed as time.
Expand All @@ -28,7 +29,7 @@
* <p>Severity: {@code SeverityLevel.ERROR}
*/
public class InvalidTimeNotice extends ValidationNotice {

@NoticeExport
public InvalidTimeNotice(
String filename, long csvRowNumber, String fieldName, String fieldValue) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.mobilitydata.gtfsvalidator.notice;

import com.google.common.collect.ImmutableMap;
import org.mobilitydata.gtfsvalidator.annotation.NoticeExport;

/**
* A field cannot be parsed as a timezone.
Expand All @@ -31,6 +32,7 @@
*/
public class InvalidTimezoneNotice extends ValidationNotice {

@NoticeExport
public InvalidTimezoneNotice(
String filename, long csvRowNumber, String fieldName, String fieldValue) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.mobilitydata.gtfsvalidator.notice;

import com.google.common.collect.ImmutableMap;
import org.mobilitydata.gtfsvalidator.annotation.NoticeExport;

/**
* A field contains a malformed URL.
Expand All @@ -41,6 +42,7 @@ public class InvalidUrlNotice extends ValidationNotice {
* Constructs a notice with given severity. This constructor may be used by users that want to
* lower the priority to {@code WARNING}.
*/
@NoticeExport
public InvalidUrlNotice(
String filename,
long csvRowNumber,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.mobilitydata.gtfsvalidator.notice;

import com.google.common.collect.ImmutableMap;
import org.mobilitydata.gtfsvalidator.annotation.NoticeExport;

/**
* The value in CSV file has leading or trailing whitespaces.
Expand All @@ -39,6 +40,7 @@ public class LeadingOrTrailingWhitespacesNotice extends ValidationNotice {
* Constructs a notice with given severity. This constructor may be used by users that want to
* lower the priority to {@code WARNING}.
*/
@NoticeExport
public LeadingOrTrailingWhitespacesNotice(
String filename,
long csvRowNumber,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
package org.mobilitydata.gtfsvalidator.notice;

import com.google.common.collect.ImmutableMap;
import org.mobilitydata.gtfsvalidator.annotation.NoticeExport;

/**
* A required column is missing in the input file.
*
* <p>Severity: {@code SeverityLevel.ERROR}
*/
public class MissingRequiredColumnNotice extends ValidationNotice {
@NoticeExport
public MissingRequiredColumnNotice(String filename, String fieldName) {
super(ImmutableMap.of("filename", filename, "fieldName", fieldName), SeverityLevel.ERROR);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
package org.mobilitydata.gtfsvalidator.notice;

import com.google.common.collect.ImmutableMap;
import org.mobilitydata.gtfsvalidator.annotation.NoticeExport;

/**
* The given field has no value in some input row, even though values are required.
*
* <p>Severity: {@code SeverityLevel.ERROR}
*/
public class MissingRequiredFieldNotice extends ValidationNotice {
@NoticeExport
public MissingRequiredFieldNotice(String filename, long csvRowNumber, String fieldName) {
super(
ImmutableMap.of("filename", filename, "csvRowNumber", csvRowNumber, "fieldName", fieldName),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
package org.mobilitydata.gtfsvalidator.notice;

import com.google.common.collect.ImmutableMap;
import org.mobilitydata.gtfsvalidator.annotation.NoticeExport;

/**
* A required file is missing.
*
* <p>Severity: {@code SeverityLevel.ERROR}
*/
public class MissingRequiredFileNotice extends ValidationNotice {
@NoticeExport
public MissingRequiredFileNotice(String filename) {
super(ImmutableMap.of("filename", filename), SeverityLevel.ERROR);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
package org.mobilitydata.gtfsvalidator.notice;

import com.google.common.collect.ImmutableMap;
import org.mobilitydata.gtfsvalidator.annotation.NoticeExport;

/**
* A notice that the file is expected to have a single entity but has more (e.g., "feed_info.txt").
*
* <p>Severity: {@code SeverityLevel.WARNING}
*/
public class MoreThanOneEntityNotice extends ValidationNotice {
@NoticeExport
public MoreThanOneEntityNotice(String filename, long entityCount) {
super(ImmutableMap.of("filename", filename, "entityCount", entityCount), SeverityLevel.WARNING);
}
Expand Down
Loading