Skip to content

Commit

Permalink
added jayvee version
Browse files Browse the repository at this point in the history
  • Loading branch information
Srinivas Seema committed Nov 29, 2023
1 parent a73841a commit 5bc579a
Showing 1 changed file with 110 additions and 0 deletions.
110 changes: 110 additions & 0 deletions exercises/exercise2.jv
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
pipeline TrainStopsPipeline {
// Define the pipeline execution order
TrainStopsCSVExtractor -> TrainStopsTextFileInterpreter -> TrainStopsCSVInterpreter -> TrainStopsTableInterpreter -> SQLiteLoader;
//-> ConvertCommaToDecimal
//-> ValidateData
// -> SQLiteLoader
// Extract data from CSV file using semicolon separator
block TrainStopsCSVExtractor oftype HttpExtractor {
url: "https://download-data.deutschebahn.com/static/datasets/haltestellen/D_Bahnhof_2020_alle.CSV";
}

block TrainStopsTextFileInterpreter oftype TextFileInterpreter { }


block TrainStopsCSVInterpreter oftype CSVInterpreter {
delimiter: ";";
}


//Status column is ignored
block TrainStopsTableInterpreter oftype TableInterpreter {
header: true;
columns: [
"EVA_NR" oftype integer,
"DS100" oftype ValidTextType,
"IFOPT" oftype IFOPTType,
"NAME" oftype ValidTextType,
"Verkehr" oftype verkehrType,
"Laenge" oftype LaengeType,
"Breite" oftype BreiteType,
"Betreiber_Name" oftype ValidTextType,
"Betreiber_Nr" oftype integer
];
}



// Load data into SQLite database
block SQLiteLoader oftype SQLiteLoader {
table: "trainstops";
file: "./trainstops.sqlite";
}

valuetype verkehrType oftype text {
constraints: [
valid_verkehr, notEmpty
];
}

valuetype ValidTextType oftype text {
constraints: [
notEmpty
];
}


valuetype LaengeType oftype decimal {
constraints: [
validLaenge

];
}


valuetype BreiteType oftype decimal {
constraints: [
validBreite

];
}


valuetype IFOPTType oftype text {
constraints: [
validIFOPT,
notEmpty
];
}



//Constriants

constraint validIFOPT oftype RegexConstraint {
regex: /^[A-Za-z]{2}:\d+:\d+(:\d+)?$/;
}

constraint notEmpty oftype RegexConstraint {
regex: /^.+$/;
}


constraint valid_verkehr oftype AllowlistConstraint {
allowlist: ["FV", "RV", "nur DPN"];
}

//lowerBoundInclusive, upperBoundInclusive are true by default.
constraint validLaenge oftype RangeConstraint {
lowerBound: -90;
upperBound: 90;
}

//lowerBoundInclusive, upperBoundInclusive are true by default.
constraint validBreite oftype RangeConstraint {
lowerBound: -90;
upperBound: 90;
}


}

0 comments on commit 5bc579a

Please sign in to comment.