|
@@ -30,15 +30,35 @@ $db = SQLite3::Database.open 'database/stations.db'
|
|
|
|
|
|
|
|
|
|
|
|
+class GetJsonFiles < Riddl::Implementation
|
|
|
+ def response
|
|
|
+ Dir.chdir( __dir__ + '/json')
|
|
|
+ ret = [];
|
|
|
+ Dir.glob('*').select{ |e|
|
|
|
+ ret.append(e)
|
|
|
+ }
|
|
|
+ Riddl::Parameter::Complex.new('list','application/json',JSON::pretty_generate(ret))
|
|
|
+ end
|
|
|
+end
|
|
|
+
|
|
|
|
|
|
-class CutImage < Riddl::Implementation
|
|
|
+class GetJson < Riddl::Implementation
|
|
|
def response
|
|
|
- puts "Cutting"
|
|
|
- "Cutting"
|
|
|
+ Dir.chdir( __dir__ + '/json')
|
|
|
+ Riddl::Parameter::Complex.new('list','application/json',File.open(@r[1]).read) rescue Riddl::Parameter::Complex.new('list','application/json', '{"error":"No such file"}')
|
|
|
end
|
|
|
end
|
|
|
|
|
|
|
|
|
+class SaveJson < Riddl::Implementation
|
|
|
+ def response
|
|
|
+ Dir.chdir( __dir__ + '/json')
|
|
|
+ File.write(@r.last,(@p[0].value.read))
|
|
|
+ end
|
|
|
+end
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
class GetStations < Riddl::Implementation
|
|
|
def response
|
|
|
result = $db.execute "SELECT * FROM stations"
|
|
@@ -47,9 +67,22 @@ class GetStations < Riddl::Implementation
|
|
|
xml.stations {
|
|
|
result.each do |row|
|
|
|
xml.station(:id => row[0]){
|
|
|
- resultstation = $db.execute "SELECT * FROM station WHERE station = #{row[0]}"
|
|
|
+ resultstation = $db.execute "SELECT * FROM stationpattern WHERE station = #{row[0]}"
|
|
|
resultstation.each do |row|
|
|
|
- xml.pattern(:id => row[1], :value => row[2], :description => row[3], :changed => row[4])
|
|
|
+ xml.pattern(:id => row[1], :description => row[2], :changed => row[3]){
|
|
|
+ xml.parts{
|
|
|
+ resultpattern = $db.execute "SELECT * FROM pattern WHERE internalID = #{row[1]}"
|
|
|
+ resultpattern.each do |row2|
|
|
|
+ xml.send(row2[1], row2[2])
|
|
|
+ end
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ #$db.execute "CREATE TABLE IF NOT EXISTS pattern(internalID INT, type CHARACTER(20), value CHARACTER(20), FOREIGN KEY(internalID) REFERENCES stationpattern(internalID) ON DELETE CASCADE)"
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
end
|
|
|
}
|
|
|
end
|
|
@@ -83,14 +116,24 @@ end
|
|
|
|
|
|
class GetStation < Riddl::Implementation
|
|
|
def self::prepare(id)
|
|
|
- result = $db.execute "SELECT * FROM station WHERE station = #{id}"
|
|
|
+
|
|
|
+ resultstation = $db.execute "SELECT * FROM stationpattern WHERE station = #{id}"
|
|
|
+
|
|
|
Nokogiri::XML::Builder.new do |xml|
|
|
|
xml.station(:id => id){
|
|
|
- result.each do |row|
|
|
|
- xml.pattern(:id => row[1], :value => row[2], :description => row[3], :changed => row[4])
|
|
|
+ resultstation.each do |row|
|
|
|
+ xml.pattern(:id => row[1], :description => row[2], :changed => row[3]){
|
|
|
+ xml.parts{
|
|
|
+ resultpattern = $db.execute "SELECT * FROM pattern WHERE internalID = #{row[1]}"
|
|
|
+ resultpattern.each do |row2|
|
|
|
+ xml.send(row2[1], row2[2])
|
|
|
+ end
|
|
|
+ }
|
|
|
+ }
|
|
|
end
|
|
|
}
|
|
|
end
|
|
|
+
|
|
|
end
|
|
|
|
|
|
def response
|
|
@@ -101,17 +144,22 @@ end
|
|
|
|
|
|
class CreatePattern < Riddl::Implementation
|
|
|
def response
|
|
|
-
|
|
|
doc = Nokogiri::XML(@p[0].value)
|
|
|
- result = $db.execute "SELECT MAX(patternID) FROM station"
|
|
|
+ result = $db.execute "SELECT MAX(internalID) FROM stationpattern"
|
|
|
if(result[0][0] == nil)
|
|
|
id = 0
|
|
|
else
|
|
|
id = result[0][0] +1
|
|
|
end
|
|
|
|
|
|
- values = doc.xpath("/*/@value")[0].value.split(".")
|
|
|
- $db.execute("INSERT INTO station (station, patternID, pattern, description, date, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", [@r.last, id, doc.xpath("/*/@value")[0].value, doc.xpath("/*/@description")[0].value, doc.xpath("/*/@changed")[0].value, values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], values[8], values[9], values[10]])
|
|
|
+
|
|
|
+ $db.execute("INSERT INTO stationpattern (station, internalID, description, date) VALUES (?,?,?,?)", [@r.last, id, doc.xpath("/*/@description")[0].value, doc.xpath("/*/@changed")[0].value])
|
|
|
+
|
|
|
+ doc.xpath(".//parts/*").each do |node|
|
|
|
+ if(node.text != "")
|
|
|
+ $db.execute("INSERT INTO pattern (internalID, type, value) VALUES (?,?,?)", [id, node.name, node.text])
|
|
|
+ end
|
|
|
+ end
|
|
|
|
|
|
|
|
|
ret = {:id => id}
|
|
@@ -124,9 +172,18 @@ end
|
|
|
|
|
|
class GetPattern < Riddl::Implementation
|
|
|
def response
|
|
|
- result = $db.execute "SELECT * FROM station WHERE station = #{@r[0]} and patternID = #{@r[1]}"
|
|
|
+ resultstation = $db.execute "SELECT * FROM stationpattern WHERE station = #{@r[0]} AND internalID = #{@r[1]}"
|
|
|
builder = Nokogiri::XML::Builder.new do |xml|
|
|
|
- xml.pattern(:id => result[0][1], :value => result[0][2], :description => result[0][3], :changed => result[0][4])
|
|
|
+ resultstation.each do |row|
|
|
|
+ xml.pattern(:id => row[1], :description => row[2], :changed => row[3]){
|
|
|
+ xml.parts{
|
|
|
+ resultpattern = $db.execute "SELECT * FROM pattern WHERE internalID = #{row[1]}"
|
|
|
+ resultpattern.each do |row2|
|
|
|
+ xml.send(row2[1], row2[2])
|
|
|
+ end
|
|
|
+ }
|
|
|
+ }
|
|
|
+ end
|
|
|
end
|
|
|
Riddl::Parameter::Complex.new('pattern','application/xml',builder.to_xml)
|
|
|
end
|
|
@@ -134,28 +191,22 @@ end
|
|
|
|
|
|
class UpdatePattern < Riddl::Implementation
|
|
|
def response
|
|
|
-
|
|
|
doc = Nokogiri::XML(@p[0].value)
|
|
|
- #puts "UPdate Pattern" + @r[0] + @r[1] + " value " + doc.xpath("/*/@value")[0].value
|
|
|
- #$db.execute("DELETE FROM station WHERE station = ? AND patternID = ?", [@r[0], @r[1]])
|
|
|
-
|
|
|
-
|
|
|
- values = doc.xpath("/*/@value")[0].value.split(".")
|
|
|
- #$db.execute("INSERT INTO station (station, patternID, pattern, description, date, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", [@r[0], @r[1], doc.xpath("/*/@value")[0].value, doc.xpath("/*/@description")[0].value, doc.xpath("/*/@changed")[0].value, values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], values[8], values[9], values[10]])
|
|
|
-
|
|
|
- #$db.execute("UPDATE image SET imageID = ? WHERE station = ? AND patternID = ? AND imageID = ? AND language = ?", [999999, @r[0], @r[1], i, @r[4]])
|
|
|
+ $db.execute("Update stationpattern SET description = ?, date = ? WHERE internalID = ?", [doc.xpath("/*/@description")[0].value, doc.xpath("/*/@changed")[0].value, @r[1]])
|
|
|
|
|
|
- $db.execute("Update station SET pattern = ?, description = ?, date = ?, P0 = ?, P1 = ?, P2 = ?, P3 = ?, P4 = ?, P5 = ?, P6 = ?, P7 = ?, P8 = ?, P9 = ?, P10 = ? WHERE station = ? AND patternID = ?", [doc.xpath("/*/@value")[0].value, doc.xpath("/*/@description")[0].value, doc.xpath("/*/@changed")[0].value, values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], values[8], values[9], values[10], @r[0], @r[1]])
|
|
|
-
|
|
|
- #$db.execute("INSERT INTO station (station, patternID, pattern, description, date) VALUES (?,?,?,?,?)", [@r[0], @r[1]], doc.xpath("/*/@value")[0].value, doc.xpath("/*/@description")[0].value, doc.xpath("/*/@changed")[0].value)
|
|
|
-
|
|
|
- #$db.execute("UPDATE station SET pattern = ? and description = ? and date = ? WHERE station = ? and patternID = ?", [doc.xpath("/*/@value")[0].value, doc.xpath("/*/@description")[0].value, doc.xpath("/*/@changed")[0].value, @r[0], @r[1]])
|
|
|
+ $db.execute("DELETE FROM pattern WHERE internalID = ?", [@r[1]])
|
|
|
+
|
|
|
+ doc.xpath(".//parts/*").each do |node|
|
|
|
+ if(node.text != "")
|
|
|
+ $db.execute("INSERT INTO pattern (internalID, type, value) VALUES (?,?,?)", [@r[1], node.name, node.text])
|
|
|
+ end
|
|
|
+ end
|
|
|
end
|
|
|
end
|
|
|
|
|
|
class DeletePattern < Riddl::Implementation
|
|
|
def response
|
|
|
- $db.execute("DELETE FROM station WHERE station = ? AND patternID = ?", [@r[0], @r[1]])
|
|
|
+ $db.execute("DELETE FROM stationpattern WHERE internalID = ?", [@r[1]])
|
|
|
end
|
|
|
end
|
|
|
|
|
@@ -164,27 +215,41 @@ class DuplicatePattern < Riddl::Implementation
|
|
|
|
|
|
|
|
|
#duplicate db etwas mühsam da der eintrag kopiert werden muss und dabei die unique ID verändert werden muss daher geht insert into select nicht so ganz.
|
|
|
- result = $db.execute "SELECT MAX(patternID) FROM station"
|
|
|
+ result = $db.execute "SELECT MAX(internalID) FROM stationpattern"
|
|
|
if(result[0][0] == nil)
|
|
|
id = 0
|
|
|
else
|
|
|
id = result[0][0] +1
|
|
|
end
|
|
|
|
|
|
- result = $db.execute "SELECT * FROM station WHERE station = #{@r[0]} and patternID = #{@r[1]}"
|
|
|
+ result = $db.execute "SELECT * FROM stationpattern WHERE internalID = #{@r[1]}"
|
|
|
result[0][1] = id;
|
|
|
- questionmarks = ""
|
|
|
- result[0].length().times{questionmarks = questionmarks + ",?"}
|
|
|
- questionmarks[0] = ""
|
|
|
+ $db.execute( "INSERT INTO stationpattern values (?,?,?,?)", result[0])
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ result = $db.execute "SELECT * FROM pattern WHERE internalID = #{@r[1]}"
|
|
|
+ result.each do |row|
|
|
|
+ row[0] = id;
|
|
|
+ $db.execute( "INSERT INTO pattern values (?,?,?)", row)
|
|
|
+ end
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
- $db.execute( "INSERT INTO station values (#{questionmarks})", result[0])
|
|
|
#duplicate error
|
|
|
- result = $db.execute "SELECT * FROM error WHERE station = #{@r[0]} and patternID = #{@r[1]}"
|
|
|
+
|
|
|
+ #$db.execute "CREATE TABLE IF NOT EXISTS error(internalID INT, error TEXT, FOREIGN KEY(internalID) REFERENCES stationpattern(internalID) ON DELETE CASCADE)"
|
|
|
+
|
|
|
+ result = $db.execute "SELECT * FROM error WHERE internalID = #{@r[1]}"
|
|
|
|
|
|
if(result[0] != nil)
|
|
|
result.each do |row|
|
|
|
- row[1] = id;
|
|
|
+ row[0] = id;
|
|
|
questionmarks = ""
|
|
|
row.length().times{questionmarks = questionmarks + ",?"}
|
|
|
questionmarks[0] = ""
|
|
@@ -193,10 +258,13 @@ class DuplicatePattern < Riddl::Implementation
|
|
|
end
|
|
|
|
|
|
#duplicate image db
|
|
|
- result = $db.execute "SELECT * FROM image WHERE station = #{@r[0]} and patternID = #{@r[1]}"
|
|
|
+
|
|
|
+ #$db.execute "CREATE TABLE IF NOT EXISTS image(internalID INT, imageID INT, language CHARACTER(20), label TEXT, FOREIGN KEY(internalID) REFERENCES stationpattern(internalID) ON DELETE CASCADE)"
|
|
|
+
|
|
|
+ result = $db.execute "SELECT * FROM image WHERE internalID = #{@r[1]}"
|
|
|
if(result[0] != nil)
|
|
|
result.each do |row|
|
|
|
- row[1] = id;
|
|
|
+ row[0] = id;
|
|
|
questionmarks = ""
|
|
|
row.length().times{questionmarks = questionmarks + ",?"}
|
|
|
questionmarks[0] = ""
|
|
@@ -207,15 +275,18 @@ class DuplicatePattern < Riddl::Implementation
|
|
|
#duplicate images
|
|
|
pathorigin = File.join(File.dirname(__dir__),'images/uploads', @r[0], @r[1])
|
|
|
pathdestination = File.join(File.dirname(__dir__),'images/uploads', @r[0], id.to_s)
|
|
|
- FileUtils.mkdir_p(pathdestination)
|
|
|
-
|
|
|
- FileUtils.copy_entry pathorigin, pathdestination
|
|
|
+ if (Dir.exist?(pathorigin))
|
|
|
+ FileUtils.mkdir_p(pathdestination)
|
|
|
+ FileUtils.copy_entry pathorigin, pathdestination
|
|
|
+ end
|
|
|
|
|
|
#duplicate Replacement db
|
|
|
- result = $db.execute "SELECT * FROM replacements WHERE station = #{@r[0]} and patternID = #{@r[1]}"
|
|
|
+
|
|
|
+ #$db.execute "CREATE TABLE IF NOT EXISTS replacements(internalID INT, abbreviation TEXT, url TEXT, ordering INT, FOREIGN KEY(internalID) REFERENCES stationpattern(internalID) ON DELETE CASCADE)"
|
|
|
+ result = $db.execute "SELECT * FROM replacements WHERE internalID = #{@r[1]}"
|
|
|
if(result[0] != nil)
|
|
|
result.each do |row|
|
|
|
- row[1] = id;
|
|
|
+ row[0] = id;
|
|
|
questionmarks = ""
|
|
|
row.length().times{questionmarks = questionmarks + ",?"}
|
|
|
questionmarks[0] = ""
|
|
@@ -232,27 +303,27 @@ end
|
|
|
|
|
|
class SaveError < Riddl::Implementation
|
|
|
def response
|
|
|
- $db.execute "CREATE TABLE IF NOT EXISTS error(station INT, patternID INT, error TEXT, FOREIGN KEY(station) REFERENCES station(station), FOREIGN KEY(patternID) REFERENCES station(patternID))"
|
|
|
-
|
|
|
+
|
|
|
+ $db.execute "CREATE TABLE IF NOT EXISTS error(internalID INT, error TEXT, FOREIGN KEY(internalID) REFERENCES stationpattern(internalID) ON DELETE CASCADE)"
|
|
|
+
|
|
|
+
|
|
|
#Delete all, afterwards insert
|
|
|
- $db.execute("DELETE FROM error WHERE station = ? AND patternID = ?", [@r[0], @r[1]])
|
|
|
+ $db.execute("DELETE FROM error WHERE internalID = ?", [@r[1]])
|
|
|
|
|
|
doc = Nokogiri::XML(@p[0].value)
|
|
|
doc.xpath(".//reason").each do |node|
|
|
|
- $db.execute("INSERT INTO error (station, patternID, error) VALUES (?,?,?)", [@r[0], @r[1], node.text])
|
|
|
+ $db.execute("INSERT INTO error (internalID, error) VALUES (?,?)", [@r[1], node.text])
|
|
|
end
|
|
|
end
|
|
|
end
|
|
|
|
|
|
class GetError < Riddl::Implementation
|
|
|
- def response
|
|
|
- $db.execute "CREATE TABLE IF NOT EXISTS error(station INT, patternID INT, error TEXT, FOREIGN KEY(station) REFERENCES station(station), FOREIGN KEY(patternID) REFERENCES station(patternID))"
|
|
|
-
|
|
|
- result = $db.execute "SELECT * FROM error WHERE station = #{@r[0]} and patternID = #{@r[1]}"
|
|
|
+ def response
|
|
|
+ result = $db.execute "SELECT * FROM error WHERE internalID = #{@r[1]}"
|
|
|
builder = Nokogiri::XML::Builder.new do |xml|
|
|
|
xml.error(){
|
|
|
result.each do |row|
|
|
|
- xml.reason row[2]
|
|
|
+ xml.reason row[1]
|
|
|
end
|
|
|
}
|
|
|
end
|
|
@@ -263,30 +334,33 @@ end
|
|
|
|
|
|
|
|
|
class SaveReplacement < Riddl::Implementation
|
|
|
- def response
|
|
|
+ def response
|
|
|
+
|
|
|
+ # $db.execute "CREATE TABLE IF NOT EXISTS replacements(internalID INT, abbreviation TEXT, url TEXT, ordering INT, FOREIGN KEY(internalID) REFERENCES stationpattern(internalID) ON DELETE CASCADE)"
|
|
|
+
|
|
|
#Delete all, afterwards insert
|
|
|
- $db.execute("DELETE FROM replacements WHERE station = ? AND patternID = ?", [@r[0], @r[1]])
|
|
|
+ $db.execute("DELETE FROM replacements WHERE internalID = ?", [@r[1]])
|
|
|
|
|
|
order = 0;
|
|
|
|
|
|
doc = Nokogiri::XML(@p[0].value)
|
|
|
doc.xpath(".//item").each do |node|
|
|
|
- $db.execute("INSERT INTO replacements (station, patternID, abbreviation, url, ordering) VALUES (?,?,?,?,?)", [@r[0], @r[1], node.xpath(".//abbreviation").text, node.xpath(".//url").text, order])
|
|
|
+ $db.execute("INSERT INTO replacements (internalID, abbreviation, url, ordering) VALUES (?,?,?,?)", [@r[1], node.xpath(".//abbreviation").text, node.xpath(".//url").text, order])
|
|
|
order += 1
|
|
|
end
|
|
|
end
|
|
|
end
|
|
|
|
|
|
class GetReplacement < Riddl::Implementation
|
|
|
- def response
|
|
|
- result = $db.execute "SELECT * FROM replacements WHERE station = #{@r[0]} and patternID = #{@r[1]} ORDER BY ordering ASC"
|
|
|
+ def response
|
|
|
+ result = $db.execute "SELECT * FROM replacements WHERE internalID = #{@r[1]} ORDER BY ordering ASC"
|
|
|
|
|
|
builder = Nokogiri::XML::Builder.new do |xml|
|
|
|
xml.replacement(){
|
|
|
result.each do |row|
|
|
|
xml.item(){
|
|
|
- xml.abbreviation row[2]
|
|
|
- xml.url row[3]
|
|
|
+ xml.abbreviation row[1]
|
|
|
+ xml.url row[2]
|
|
|
}
|
|
|
end
|
|
|
}
|
|
@@ -304,11 +378,16 @@ class GetImages < Riddl::Implementation
|
|
|
formatted_no_decl = Nokogiri::XML::Node::SaveOptions::FORMAT +
|
|
|
Nokogiri::XML::Node::SaveOptions::NO_DECLARATION
|
|
|
|
|
|
- result = $db.execute "SELECT DISTINCT station, patternID, imageID FROM image WHERE station = #{@r[0]} and patternID = #{@r[1]}"
|
|
|
+
|
|
|
+#$db.execute "CREATE TABLE IF NOT EXISTS image(internalID INT, imageID INT, language CHARACTER(20), label TEXT, FOREIGN KEY(internalID) REFERENCES stationpattern(internalID) ON DELETE CASCADE)"
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ result = $db.execute "SELECT DISTINCT imageID FROM image WHERE internalID = #{@r[1]}"
|
|
|
builder = Nokogiri::XML::Builder.new do |xml|
|
|
|
xml.images(){
|
|
|
result.each do |row|
|
|
|
- xml<< GetImage::prepare(@r[0], @r[1], row[2]).to_xml( save_with:formatted_no_decl )
|
|
|
+ xml<< GetImage::prepare(@r[0], @r[1], row[0]).to_xml( save_with:formatted_no_decl )
|
|
|
end
|
|
|
}
|
|
|
end
|
|
@@ -1003,24 +1082,26 @@ def createDB(opts)
|
|
|
CreateStation::createDB(n)
|
|
|
}
|
|
|
|
|
|
- # Unique pattern
|
|
|
- # $db.execute "CREATE TABLE IF NOT EXISTS station(station INT, patternID INT, pattern CHARACTER(20), description TEXT, date TEXT, P0 VARCHAR(2), P1 VARCHAR(2), P2 VARCHAR(2), P3 VARCHAR(2), P4 VARCHAR(2), P5 VARCHAR(2), P6 VARCHAR(2), P7 VARCHAR(2), P8 VARCHAR(2), P9 VARCHAR(2), P10 VARCHAR(2), PRIMARY KEY(station,patternID), UNIQUE(station, pattern))"
|
|
|
- $db.execute "CREATE TABLE IF NOT EXISTS station(station INT, patternID INT, pattern CHARACTER(256), description TEXT, date TEXT, P0 VARCHAR(10), P1 VARCHAR(10), P2 VARCHAR(10), P3 VARCHAR(10), P4 VARCHAR(10), P5 VARCHAR(10), P6 VARCHAR(10), P7 VARCHAR(10), P8 VARCHAR(10), P9 VARCHAR(10), P10 VARCHAR(10), PRIMARY KEY(station,patternID), UNIQUE(station, patternID))"
|
|
|
-
|
|
|
-
|
|
|
+ #vor DB struktur umstellung
|
|
|
+ #$db.execute "CREATE TABLE IF NOT EXISTS station(station INT, patternID INT, pattern CHARACTER(256), description TEXT, date TEXT, P0 VARCHAR(10), P1 VARCHAR(10), P2 VARCHAR(10), P3 VARCHAR(10), P4 VARCHAR(10), P5 VARCHAR(10), P6 VARCHAR(10), P7 VARCHAR(10), P8 VARCHAR(10), P9 VARCHAR(10), P10 VARCHAR(10), PRIMARY KEY(station,patternID), UNIQUE(station, patternID))"
|
|
|
|
|
|
- $db.execute "CREATE TABLE IF NOT EXISTS error(station INT, patternID INT, error TEXT, FOREIGN KEY(station, patternID) REFERENCES station(station, patternID) ON DELETE CASCADE)"
|
|
|
+
|
|
|
+ #$db.execute "CREATE TABLE IF NOT EXISTS error(station INT, patternID INT, error TEXT, FOREIGN KEY(station, patternID) REFERENCES station(station, patternID) ON DELETE CASCADE)"
|
|
|
|
|
|
|
|
|
- $db.execute "CREATE TABLE IF NOT EXISTS replacements(station INT, patternID INT, abbreviation TEXT, url TEXT, ordering INT, FOREIGN KEY(station, patternID) REFERENCES station(station, patternID) ON DELETE CASCADE)"
|
|
|
-
|
|
|
- $db.execute "CREATE TABLE IF NOT EXISTS image(station INT, patternID INT, imageID INT, language CHARACTER(20), label TEXT, FOREIGN KEY(station, patternID) REFERENCES station(station, patternID) ON DELETE CASCADE,PRIMARY KEY(station,patternID,imageID,language))"
|
|
|
+ #$db.execute "CREATE TABLE IF NOT EXISTS replacements(station INT, patternID INT, abbreviation TEXT, url TEXT, ordering INT, FOREIGN KEY(station, patternID) REFERENCES station(station, patternID) ON DELETE CASCADE)"
|
|
|
+
|
|
|
+ #$db.execute "CREATE TABLE IF NOT EXISTS image(station INT, patternID INT, imageID INT, language CHARACTER(20), label TEXT, FOREIGN KEY(station, patternID) REFERENCES station(station, patternID) ON DELETE CASCADE,PRIMARY KEY(station,patternID,imageID,language))"
|
|
|
|
|
|
- # $db.execute "CREATE TABLE IF NOT EXISTS error(station INT, patternID INT, error TEXT, FOREIGN KEY(station) REFERENCES station(station), FOREIGN KEY(patternID) REFERENCES station(patternID) ON DELETE CASCADE)"
|
|
|
+
|
|
|
|
|
|
- # $db.execute "CREATE TABLE IF NOT EXISTS image(station INT, patternID INT, imageID INT, language CHARACTER(20), label TEXT, FOREIGN KEY(station) REFERENCES station(station), FOREIGN KEY(patternID) REFERENCES station(patternID) ON DELETE CASCADE,PRIMARY KEY(station,patternID,imageID,language))"
|
|
|
|
|
|
|
|
|
+ $db.execute "CREATE TABLE IF NOT EXISTS stationpattern(station INT, internalID INT, description TEXT, date TEXT, PRIMARY KEY(internalID), UNIQUE(internalID))"
|
|
|
+ $db.execute "CREATE TABLE IF NOT EXISTS pattern(internalID INT, type CHARACTER(20), value CHARACTER(20), FOREIGN KEY(internalID) REFERENCES stationpattern(internalID) ON DELETE CASCADE)"
|
|
|
+ $db.execute "CREATE TABLE IF NOT EXISTS error(internalID INT, error TEXT, FOREIGN KEY(internalID) REFERENCES stationpattern(internalID) ON DELETE CASCADE)"
|
|
|
+ $db.execute "CREATE TABLE IF NOT EXISTS replacements(internalID INT, abbreviation TEXT, url TEXT, ordering INT, FOREIGN KEY(internalID) REFERENCES stationpattern(internalID) ON DELETE CASCADE)"
|
|
|
+ $db.execute "CREATE TABLE IF NOT EXISTS image(internalID INT, imageID INT, language CHARACTER(20), label TEXT, FOREIGN KEY(internalID) REFERENCES stationpattern(internalID) ON DELETE CASCADE)"
|
|
|
|
|
|
end
|
|
|
|
|
@@ -1041,6 +1122,15 @@ server = Riddl::Server.new(File.join(__dir__,'/was.xml'), :host => 'localhost')
|
|
|
#should add deleteReplacement
|
|
|
end
|
|
|
|
|
|
+ on resource 'json' do
|
|
|
+ run GetJsonFiles if get
|
|
|
+ on resource '.*' do
|
|
|
+ run SaveJson if put 'list'
|
|
|
+ run GetJson if get
|
|
|
+ end
|
|
|
+ #should add deleteReplacement
|
|
|
+ end
|
|
|
+
|
|
|
on resource '\d+' do
|
|
|
run GetStation if get
|
|
|
run CreatePattern if post 'pattern'
|