restructure overview mod
All checks were successful
CI/CD Pipeline / test (push) Successful in 38s

This commit is contained in:
philipp 2024-02-05 12:02:47 +01:00
parent 9454b89d8e
commit 727916cb3f
9 changed files with 3 additions and 30166 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,481 +0,0 @@
{
"OgdSearchResult": {
"OgdDocumentResults": {
"Hits": {
"@pageNumber": "1",
"@pageSize": "100",
"#text": "7"
},
"OgdDocumentReference": [
{
"Data": {
"Metadaten": {
"Technisch": {
"ID": "NOR11001922",
"Applikation": "BrKons",
"Organ": "BKA (Bundeskanzleramt)",
"ImportTimestamp": {
"@xsi:nil": "true",
"@xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance"
}
},
"Allgemein": {
"Geaendert": "2023-09-14",
"DokumentUrl": "https://www.ris.bka.gv.at/eli/bgbl/1949/271/P0/NOR11001922"
},
"Bundesrecht": {
"Kurztitel": "Wuchergesetz 1949",
"Titel": "Wuchergesetz 1949.<br/>StF: BGBl. Nr. 271/1949 (WV)",
"Eli": "https://ris.bka.gv.at/eli/bgbl/1949/271/P0/NOR11001922",
"BrKons": {
"Kundmachungsorgan": "BGBl. Nr. 271/1949",
"Typ": "BG",
"Dokumenttyp": "Norm",
"ArtikelParagraphAnlage": "§ 0",
"Paragraphnummer": "0",
"StammnormPublikationsorgan": "BGBl. Nr.",
"StammnormBgblnummer": "271/1949",
"Inkrafttretensdatum": "1949-12-17",
"Indizes": {
"item": "20/06 Konsumentenschutz"
},
"Aenderung": "BGBl. Nr. 160/1952 (NR: GP VI RV 609 AB 637 S. 95. BR: S. 77.)\r\nBGBl. Nr. 422/1974 (NR: GP XIII RV 850 AB 1236 S. 113. BR: S. 334.)\r\nBGBl. Nr. 140/1979 (NR: GP XIV RV 744 AB 1223 S. 122. BR: AB 2003 S. 385.)\r\nBGBl. I Nr. 191/1999 (BG) (1. BRBG) (NR: GP XX RV 1811 AB 2031 S. 179. BR: AB 6041 S. 657.)\r\nBGBl. I Nr. 98/2001 (NR: GP XXI RV 621 AB 704 S. 75. BR: 6398 AB 6424 S. 679.)",
"Schlagworte": "e-rk3<br/>II. Strafgesetznovelle 1952 (BGBl. Nr. 160/1952), Strafrechtsanpassungsgesetz (BGBl. Nr. 422/1974), Konsumentenschutzgesetz — KSchG (BGBl. Nr. 140/1979), Erstes Bundesrechtsbereinigungsgesetz 1. BRBG (BGBl. I Nr. 191/1999), 1. Euro-Umstellungsgesetz Bund, 2. Euro-Justiz-Begleitgesetz 2. Euro-JuBeG (BGBl. I Nr. 98/2001)",
"Gesetzesnummer": "10001899",
"AlteDokumentnummer": "N2194914885P",
"GesamteRechtsvorschriftUrl": "https://www.ris.bka.gv.at/GeltendeFassung.wxe?Abfrage=Bundesnormen&Gesetzesnummer=10001899"
}
}
},
"Dokumentliste": {
"ContentReference": {
"ContentType": "MainDocument",
"Name": "Hauptdokument",
"Urls": {
"ContentUrl": [
{
"DataType": "Xml",
"Url": "https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR11001922/NOR11001922.xml"
},
{
"DataType": "Html",
"Url": "https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR11001922/NOR11001922.html"
},
{
"DataType": "Pdf",
"Url": "https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR11001922/NOR11001922.pdf"
},
{
"DataType": "Rtf",
"Url": "https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR11001922/NOR11001922.rtf"
}
]
}
}
}
}
},
{
"Data": {
"Metadaten": {
"Technisch": {
"ID": "NOR12025172",
"Applikation": "BrKons",
"Organ": "BKA (Bundeskanzleramt)",
"ImportTimestamp": {
"@xsi:nil": "true",
"@xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance"
}
},
"Allgemein": {
"Geaendert": "2023-09-14",
"DokumentUrl": "https://www.ris.bka.gv.at/eli/bgbl/1949/271/P1/NOR12025172"
},
"Bundesrecht": {
"Kurztitel": "Wuchergesetz 1949",
"Eli": "https://ris.bka.gv.at/eli/bgbl/1949/271/P1/NOR12025172",
"BrKons": {
"Kundmachungsorgan": "BGBl. Nr. 271/1949",
"Typ": "BG",
"Dokumenttyp": "Paragraph",
"ArtikelParagraphAnlage": "§ 1",
"Paragraphnummer": "1",
"StammnormPublikationsorgan": "BGBl. Nr.",
"StammnormBgblnummer": "271/1949",
"Inkrafttretensdatum": "1949-12-17",
"Indizes": {
"item": "20/06 Konsumentenschutz"
},
"Aenderung": "",
"Gesetzesnummer": "10001899",
"AlteDokumentnummer": "N2194910332S",
"GesamteRechtsvorschriftUrl": "https://www.ris.bka.gv.at/GeltendeFassung.wxe?Abfrage=Bundesnormen&Gesetzesnummer=10001899"
}
}
},
"Dokumentliste": {
"ContentReference": {
"ContentType": "MainDocument",
"Name": "Hauptdokument",
"Urls": {
"ContentUrl": [
{
"DataType": "Xml",
"Url": "https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR12025172/NOR12025172.xml"
},
{
"DataType": "Html",
"Url": "https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR12025172/NOR12025172.html"
},
{
"DataType": "Pdf",
"Url": "https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR12025172/NOR12025172.pdf"
},
{
"DataType": "Rtf",
"Url": "https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR12025172/NOR12025172.rtf"
}
]
}
}
}
}
},
{
"Data": {
"Metadaten": {
"Technisch": {
"ID": "NOR40022184",
"Applikation": "BrKons",
"Organ": "BKA (Bundeskanzleramt)",
"ImportTimestamp": {
"@xsi:nil": "true",
"@xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance"
}
},
"Allgemein": {
"Geaendert": "2023-09-14",
"DokumentUrl": "https://www.ris.bka.gv.at/eli/bgbl/1949/271/P7/NOR40022184"
},
"Bundesrecht": {
"Kurztitel": "Wuchergesetz 1949",
"Eli": "https://ris.bka.gv.at/eli/bgbl/1949/271/P7/NOR40022184",
"BrKons": {
"Kundmachungsorgan": "BGBl. Nr. 271/1949 zuletzt geändert durch BGBl. I Nr. 98/2001 ",
"Typ": "BG",
"Dokumenttyp": "Paragraph",
"ArtikelParagraphAnlage": "§ 7",
"Paragraphnummer": "7",
"StammnormPublikationsorgan": "BGBl. Nr.",
"StammnormBgblnummer": "271/1949",
"NovellenPublikationsorgan": "BGBl. I Nr.",
"NovellenBgblnummer": "98/2001",
"NovellenBeziehung": "zuletzt geändert durch",
"Inkrafttretensdatum": "2002-01-01",
"Indizes": {
"item": "20/06 Konsumentenschutz"
},
"Aenderung": "",
"Gesetzesnummer": "10001899",
"GesamteRechtsvorschriftUrl": "https://www.ris.bka.gv.at/GeltendeFassung.wxe?Abfrage=Bundesnormen&Gesetzesnummer=10001899"
}
}
},
"Dokumentliste": {
"ContentReference": {
"ContentType": "MainDocument",
"Name": "Hauptdokument",
"Urls": {
"ContentUrl": [
{
"DataType": "Xml",
"Url": "https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR40022184/NOR40022184.xml"
},
{
"DataType": "Html",
"Url": "https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR40022184/NOR40022184.html"
},
{
"DataType": "Pdf",
"Url": "https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR40022184/NOR40022184.pdf"
},
{
"DataType": "Rtf",
"Url": "https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR40022184/NOR40022184.rtf"
}
]
}
}
}
}
},
{
"Data": {
"Metadaten": {
"Technisch": {
"ID": "NOR12025179",
"Applikation": "BrKons",
"Organ": "BKA (Bundeskanzleramt)",
"ImportTimestamp": {
"@xsi:nil": "true",
"@xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance"
}
},
"Allgemein": {
"Geaendert": "2023-09-14",
"DokumentUrl": "https://www.ris.bka.gv.at/eli/bgbl/1949/271/P8/NOR12025179"
},
"Bundesrecht": {
"Kurztitel": "Wuchergesetz 1949",
"Eli": "https://ris.bka.gv.at/eli/bgbl/1949/271/P8/NOR12025179",
"BrKons": {
"Kundmachungsorgan": "BGBl. Nr. 271/1949",
"Typ": "BG",
"Dokumenttyp": "Paragraph",
"ArtikelParagraphAnlage": "§ 8",
"Paragraphnummer": "8",
"StammnormPublikationsorgan": "BGBl. Nr.",
"StammnormBgblnummer": "271/1949",
"Inkrafttretensdatum": "1949-12-17",
"Indizes": {
"item": "20/06 Konsumentenschutz"
},
"Aenderung": "",
"Anmerkung": "Strafbarkeit nach §§ 154 und 155 StGB, BGBl. Nr. 60/1974.<br/>",
"Gesetzesnummer": "10001899",
"AlteDokumentnummer": "N2194910339S",
"GesamteRechtsvorschriftUrl": "https://www.ris.bka.gv.at/GeltendeFassung.wxe?Abfrage=Bundesnormen&Gesetzesnummer=10001899"
}
}
},
"Dokumentliste": {
"ContentReference": {
"ContentType": "MainDocument",
"Name": "Hauptdokument",
"Urls": {
"ContentUrl": [
{
"DataType": "Xml",
"Url": "https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR12025179/NOR12025179.xml"
},
{
"DataType": "Html",
"Url": "https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR12025179/NOR12025179.html"
},
{
"DataType": "Pdf",
"Url": "https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR12025179/NOR12025179.pdf"
},
{
"DataType": "Rtf",
"Url": "https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR12025179/NOR12025179.rtf"
}
]
}
}
}
}
},
{
"Data": {
"Metadaten": {
"Technisch": {
"ID": "NOR12025180",
"Applikation": "BrKons",
"Organ": "BKA (Bundeskanzleramt)",
"ImportTimestamp": {
"@xsi:nil": "true",
"@xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance"
}
},
"Allgemein": {
"Geaendert": "2023-09-14",
"DokumentUrl": "https://www.ris.bka.gv.at/eli/bgbl/1949/271/P9/NOR12025180"
},
"Bundesrecht": {
"Kurztitel": "Wuchergesetz 1949",
"Eli": "https://ris.bka.gv.at/eli/bgbl/1949/271/P9/NOR12025180",
"BrKons": {
"Kundmachungsorgan": "BGBl. Nr. 271/1949",
"Typ": "BG",
"Dokumenttyp": "Paragraph",
"ArtikelParagraphAnlage": "§ 9",
"Paragraphnummer": "9",
"StammnormPublikationsorgan": "BGBl. Nr.",
"StammnormBgblnummer": "271/1949",
"Inkrafttretensdatum": "1949-12-17",
"Indizes": {
"item": "20/06 Konsumentenschutz"
},
"Aenderung": "",
"Gesetzesnummer": "10001899",
"AlteDokumentnummer": "N2194910340S",
"GesamteRechtsvorschriftUrl": "https://www.ris.bka.gv.at/GeltendeFassung.wxe?Abfrage=Bundesnormen&Gesetzesnummer=10001899"
}
}
},
"Dokumentliste": {
"ContentReference": {
"ContentType": "MainDocument",
"Name": "Hauptdokument",
"Urls": {
"ContentUrl": [
{
"DataType": "Xml",
"Url": "https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR12025180/NOR12025180.xml"
},
{
"DataType": "Html",
"Url": "https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR12025180/NOR12025180.html"
},
{
"DataType": "Pdf",
"Url": "https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR12025180/NOR12025180.pdf"
},
{
"DataType": "Rtf",
"Url": "https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR12025180/NOR12025180.rtf"
}
]
}
}
}
}
},
{
"Data": {
"Metadaten": {
"Technisch": {
"ID": "NOR12025181",
"Applikation": "BrKons",
"Organ": "BKA (Bundeskanzleramt)",
"ImportTimestamp": {
"@xsi:nil": "true",
"@xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance"
}
},
"Allgemein": {
"Geaendert": "2023-09-14",
"DokumentUrl": "https://www.ris.bka.gv.at/eli/bgbl/1949/271/P10/NOR12025181"
},
"Bundesrecht": {
"Kurztitel": "Wuchergesetz 1949",
"Eli": "https://ris.bka.gv.at/eli/bgbl/1949/271/P10/NOR12025181",
"BrKons": {
"Kundmachungsorgan": "BGBl. Nr. 271/1949",
"Typ": "BG",
"Dokumenttyp": "Paragraph",
"ArtikelParagraphAnlage": "§ 10",
"Paragraphnummer": "10",
"StammnormPublikationsorgan": "BGBl. Nr.",
"StammnormBgblnummer": "271/1949",
"Inkrafttretensdatum": "1949-12-17",
"Indizes": {
"item": "20/06 Konsumentenschutz"
},
"Aenderung": "",
"Gesetzesnummer": "10001899",
"AlteDokumentnummer": "N2194910341S",
"GesamteRechtsvorschriftUrl": "https://www.ris.bka.gv.at/GeltendeFassung.wxe?Abfrage=Bundesnormen&Gesetzesnummer=10001899"
}
}
},
"Dokumentliste": {
"ContentReference": {
"ContentType": "MainDocument",
"Name": "Hauptdokument",
"Urls": {
"ContentUrl": [
{
"DataType": "Xml",
"Url": "https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR12025181/NOR12025181.xml"
},
{
"DataType": "Html",
"Url": "https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR12025181/NOR12025181.html"
},
{
"DataType": "Pdf",
"Url": "https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR12025181/NOR12025181.pdf"
},
{
"DataType": "Rtf",
"Url": "https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR12025181/NOR12025181.rtf"
}
]
}
}
}
}
},
{
"Data": {
"Metadaten": {
"Technisch": {
"ID": "NOR12025182",
"Applikation": "BrKons",
"Organ": "BKA (Bundeskanzleramt)",
"ImportTimestamp": {
"@xsi:nil": "true",
"@xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance"
}
},
"Allgemein": {
"Geaendert": "2023-09-14",
"DokumentUrl": "https://www.ris.bka.gv.at/eli/bgbl/1949/271/P11/NOR12025182"
},
"Bundesrecht": {
"Kurztitel": "Wuchergesetz 1949",
"Eli": "https://ris.bka.gv.at/eli/bgbl/1949/271/P11/NOR12025182",
"BrKons": {
"Kundmachungsorgan": "BGBl. Nr. 271/1949",
"Typ": "BG",
"Dokumenttyp": "Paragraph",
"ArtikelParagraphAnlage": "§ 11",
"Paragraphnummer": "11",
"StammnormPublikationsorgan": "BGBl. Nr.",
"StammnormBgblnummer": "271/1949",
"Inkrafttretensdatum": "1949-12-17",
"Indizes": {
"item": "20/06 Konsumentenschutz"
},
"Aenderung": "",
"Schlagworte": "dRGBl. I S 581/1941, StGBl. Nr. 235/1945, RGBl. Nr. 47/1881",
"Gesetzesnummer": "10001899",
"AlteDokumentnummer": "N2194910342S",
"GesamteRechtsvorschriftUrl": "https://www.ris.bka.gv.at/GeltendeFassung.wxe?Abfrage=Bundesnormen&Gesetzesnummer=10001899"
}
}
},
"Dokumentliste": {
"ContentReference": {
"ContentType": "MainDocument",
"Name": "Hauptdokument",
"Urls": {
"ContentUrl": [
{
"DataType": "Xml",
"Url": "https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR12025182/NOR12025182.xml"
},
{
"DataType": "Html",
"Url": "https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR12025182/NOR12025182.html"
},
{
"DataType": "Pdf",
"Url": "https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR12025182/NOR12025182.pdf"
},
{
"DataType": "Rtf",
"Url": "https://www.ris.bka.gv.at/Dokumente/Bundesnormen/NOR12025182/NOR12025182.rtf"
}
]
}
}
}
}
}
]
}
}
}

View File

@ -2,4 +2,3 @@
pub mod overview; pub mod overview;
pub mod paragraphs; pub mod paragraphs;
mod parser;

View File

@ -1,11 +1,13 @@
//! Deals with getting all paragraphs for a given law text //! Deals with getting all paragraphs for a given law text
mod ris_structure;
use log::info; use log::info;
use serde::Deserialize; use serde::Deserialize;
use crate::misc::{current_date, Error}; use crate::misc::{current_date, Error};
use super::parser::OgdSearchResult; use ris_structure::OgdSearchResult;
/// Parses a law text from the Austrian RIS (Rechtsinformationssystem) based on the given `law_id`. /// Parses a law text from the Austrian RIS (Rechtsinformationssystem) based on the given `law_id`.
/// ///
@ -60,15 +62,6 @@ struct Overview {
ogd_search_result: OgdSearchResult, ogd_search_result: OgdSearchResult,
} }
//TODO: Remove, as we don't want to test internals?
#[cfg(test)]
pub(crate) fn parse_from_str_test(
content: &str,
skip_first: bool,
) -> Result<(bool, Vec<String>), Error> {
parse_from_str(content, skip_first)
}
fn parse_from_str(content: &str, skip_first: bool) -> Result<(bool, Vec<String>), Error> { fn parse_from_str(content: &str, skip_first: bool) -> Result<(bool, Vec<String>), Error> {
let mut ret = Vec::new(); let mut ret = Vec::new();
let wrapper: Overview = serde_json::from_str(content)?; let wrapper: Overview = serde_json::from_str(content)?;

View File

@ -204,113 +204,3 @@ pub(crate) struct ContentUrlItem {
data_type: String, data_type: String,
url: String, url: String,
} }
#[cfg(test)]
mod tests {
use std::{
fs::{self, File},
io::{self, BufRead, Read},
path::Path,
};
use log::debug;
use crate::risparser::overview::parse_from_str_test;
use super::*;
fn read_lines<P>(filename: P) -> io::Result<Vec<String>>
where
P: AsRef<Path>,
{
let file = File::open(filename)?;
let buf_reader = io::BufReader::new(file);
buf_reader.lines().collect()
}
//TODO: remove, as we don't want to test interal stuff?
#[derive(Deserialize)]
#[allow(dead_code)]
#[serde(rename_all = "PascalCase")]
pub(crate) struct Wrapper {
ogd_search_result: OgdSearchResult,
}
#[test]
fn deserialize_teg_success() {
let mut file = File::open("data/teg.json").unwrap();
let mut json = String::new();
file.read_to_string(&mut json).unwrap();
let wrapper: serde_json::Result<Wrapper> = serde_json::from_str(&json);
if wrapper.is_err() {
let dbg = wrapper.as_ref().err().unwrap();
debug!("{dbg:#?}");
}
assert!(wrapper.is_ok());
}
#[test]
fn deserialize_abgb_success() {
let mut file = File::open("data/abgb.json").unwrap();
let mut json = String::new();
file.read_to_string(&mut json).unwrap();
let wrapper: serde_json::Result<Wrapper> = serde_json::from_str(&json);
if wrapper.is_err() {
let dbg = wrapper.as_ref().err().unwrap();
debug!("{dbg:#?}");
}
assert!(wrapper.is_ok());
}
#[test]
fn deserialize_urhg_success() {
let mut file = File::open("data/urhg.json").unwrap();
let mut json = String::new();
file.read_to_string(&mut json).unwrap();
let wrapper: serde_json::Result<Wrapper> = serde_json::from_str(&json);
if wrapper.is_err() {
let dbg = wrapper.as_ref().err().unwrap();
debug!("{dbg:#?}");
}
assert!(wrapper.is_ok());
}
#[test]
fn test_overview_full_urhg() {
let mut files = Vec::new();
let path = Path::new("./data/urhg/overview");
let mut entries: Vec<_> = fs::read_dir(path)
.unwrap()
.filter_map(|entry| entry.ok())
.collect();
entries.sort_by_key(|entry| entry.file_name());
let last_index = fs::read_dir(path).unwrap().count() - 1;
let mut skip = true;
for (idx, entry) in entries.into_iter().enumerate() {
let mut file = File::open(path.join(entry.file_name())).unwrap();
let mut json = String::new();
file.read_to_string(&mut json).unwrap();
let expected_continue = !(idx == last_index);
let (cont, cur_files) = parse_from_str_test(&json, skip).unwrap();
assert_eq!(cont, expected_continue);
for file in cur_files {
files.push(file);
}
skip = false;
}
let expected = read_lines(path.join("../overview.result")).unwrap();
assert_eq!(files, expected);
}
}