|
@@ -24,6 +24,7 @@ require 'fileutils'
|
|
|
require 'nokogiri'
|
|
|
require 'sqlite3'
|
|
|
require 'net/http'
|
|
|
+require 'uri'
|
|
|
|
|
|
|
|
|
$db = SQLite3::Database.open 'database/stations.db'
|
|
@@ -62,7 +63,6 @@ end
|
|
|
class GetStations < Riddl::Implementation
|
|
|
def response
|
|
|
result = $db.execute "SELECT * FROM stations"
|
|
|
-
|
|
|
builder = Nokogiri::XML::Builder.new do |xml|
|
|
|
xml.stations {
|
|
|
result.each do |row|
|
|
@@ -70,18 +70,12 @@ class GetStations < Riddl::Implementation
|
|
|
resultstation = $db.execute "SELECT * FROM stationpattern WHERE station = #{row[0]}"
|
|
|
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
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- #$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)"
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
+ xml.parts{
|
|
|
+ resultpattern = $db.execute "SELECT * FROM pattern WHERE internalID = #{row[1]}"
|
|
|
+ resultpattern.each do |row2|
|
|
|
+ xml.send(row2[1], row2[2])
|
|
|
+ end
|
|
|
+ }
|
|
|
}
|
|
|
end
|
|
|
}
|
|
@@ -118,7 +112,6 @@ class GetStation < Riddl::Implementation
|
|
|
def self::prepare(id)
|
|
|
|
|
|
resultstation = $db.execute "SELECT * FROM stationpattern WHERE station = #{id}"
|
|
|
-
|
|
|
Nokogiri::XML::Builder.new do |xml|
|
|
|
xml.station(:id => id){
|
|
|
resultstation.each do |row|
|
|
@@ -148,7 +141,7 @@ class CreatePattern < Riddl::Implementation
|
|
|
result = $db.execute "SELECT MAX(internalID) FROM stationpattern"
|
|
|
if(result[0][0] == nil)
|
|
|
id = 0
|
|
|
- else
|
|
|
+ else
|
|
|
id = result[0][0] +1
|
|
|
end
|
|
|
|
|
@@ -161,10 +154,8 @@ class CreatePattern < Riddl::Implementation
|
|
|
end
|
|
|
end
|
|
|
|
|
|
-
|
|
|
ret = {:id => id}
|
|
|
Riddl::Parameter::Complex.new('list','application/json',JSON::pretty_generate(ret))
|
|
|
-
|
|
|
end
|
|
|
end
|
|
|
|
|
@@ -175,7 +166,7 @@ class GetPattern < Riddl::Implementation
|
|
|
resultstation = $db.execute "SELECT * FROM stationpattern WHERE station = #{@r[0]} AND internalID = #{@r[1]}"
|
|
|
builder = Nokogiri::XML::Builder.new do |xml|
|
|
|
resultstation.each do |row|
|
|
|
- xml.pattern(:id => row[1], :description => row[2], :changed => row[3]){
|
|
|
+ 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|
|
|
@@ -296,7 +287,6 @@ class DuplicatePattern < Riddl::Implementation
|
|
|
|
|
|
ret = {:id => id}
|
|
|
Riddl::Parameter::Complex.new('list','application/json',JSON::pretty_generate(ret))
|
|
|
-
|
|
|
end
|
|
|
end
|
|
|
|
|
@@ -306,7 +296,6 @@ class SaveError < Riddl::Implementation
|
|
|
|
|
|
$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 internalID = ?", [@r[1]])
|
|
|
|
|
@@ -383,7 +372,7 @@ class GetImages < Riddl::Implementation
|
|
|
|
|
|
|
|
|
|
|
|
- result = $db.execute "SELECT DISTINCT imageID FROM image WHERE internalID = #{@r[1]}"
|
|
|
+ result = $db.execute "SELECT DISTINCT imageID FROM image WHERE internalID = #{@r[1]} ORDER BY imageID ASC"
|
|
|
builder = Nokogiri::XML::Builder.new do |xml|
|
|
|
xml.images(){
|
|
|
result.each do |row|
|
|
@@ -400,7 +389,9 @@ class UploadImage < Riddl::Implementation
|
|
|
|
|
|
lang = @p[@p.length-1].value
|
|
|
|
|
|
- result = $db.execute "SELECT MAX(imageID) FROM image WHERE station = #{@r[0]} and patternID = #{@r[1]} and language = '#{lang}'"
|
|
|
+
|
|
|
+ #$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 MAX(imageID) FROM image WHERE internalID = #{@r[1]} and language = '#{lang}'"
|
|
|
if(result[0][0] == nil)
|
|
|
id = 0
|
|
|
else
|
|
@@ -421,7 +412,7 @@ class UploadImage < Riddl::Implementation
|
|
|
file.write(readFile.to_s)
|
|
|
end
|
|
|
|
|
|
- $db.execute("INSERT INTO image (station, patternID, imageID, language, label) VALUES (?,?,?,?,?)", [@r[0], @r[1], id, lang, "Label"])
|
|
|
+ $db.execute("INSERT INTO image (internalID, imageID, language, label) VALUES (?,?,?,?)", [@r[1], id, lang, "Label"])
|
|
|
|
|
|
id += 1
|
|
|
end
|
|
@@ -439,7 +430,7 @@ class AddExternalImage < Riddl::Implementation
|
|
|
url = doc.xpath("/externalImage/url").text
|
|
|
lang = doc.xpath("/externalImage/lang").text
|
|
|
|
|
|
- result = $db.execute "SELECT MAX(imageID) FROM image WHERE station = #{@r[0]} and patternID = #{@r[1]} and language = '#{lang}'"
|
|
|
+ result = $db.execute "SELECT MAX(imageID) FROM image WHERE internalID = #{@r[1]} and language = '#{lang}'"
|
|
|
if(result[0][0] == nil)
|
|
|
id = 0
|
|
|
else
|
|
@@ -457,7 +448,7 @@ class AddExternalImage < Riddl::Implementation
|
|
|
end
|
|
|
|
|
|
#Create DB entry as usual
|
|
|
- $db.execute("INSERT INTO image (station, patternID, imageID, language, label) VALUES (?,?,?,?,?)", [@r[0], @r[1], id, lang, url])
|
|
|
+ $db.execute("INSERT INTO image (internalID, imageID, language, label) VALUES (?,?,?,?)", [@r[1], id, lang, url])
|
|
|
|
|
|
end
|
|
|
end
|
|
@@ -496,18 +487,19 @@ class ReorderImages < Riddl::Implementation
|
|
|
maxImgId = result[0][0] +1
|
|
|
end
|
|
|
|
|
|
+
|
|
|
#Wegen 999999 fragen
|
|
|
#nutze max ID+1 zum tauschen
|
|
|
- $db.execute("UPDATE image SET imageID = ? WHERE station = ? AND patternID = ? AND imageID = ? AND language = ?", [maxImgId, @r[0], @r[1], i, @r[4]])
|
|
|
+ $db.execute("UPDATE image SET imageID = ? WHERE internalID = ? AND imageID = ? AND language = ?", [maxImgId, @r[1], i, @r[4]])
|
|
|
|
|
|
- $db.execute("UPDATE image SET imageID = ? WHERE station = ? AND patternID = ? AND imageID = ? AND language = ?", [i, @r[0], @r[1], iter[i], @r[4]])
|
|
|
+ $db.execute("UPDATE image SET imageID = ? WHERE internalID = ? AND imageID = ? AND language = ?", [i, @r[1], iter[i], @r[4]])
|
|
|
|
|
|
- $db.execute("UPDATE image SET imageID = ? WHERE station = ? AND patternID = ? AND imageID = ? AND language = ?", [iter[i], @r[0], @r[1], maxImgId, @r[4]])
|
|
|
+ $db.execute("UPDATE image SET imageID = ? WHERE internalID = ? AND imageID = ? AND language = ?", [iter[i], @r[1], maxImgId, @r[4]])
|
|
|
|
|
|
iter.map! do |item|
|
|
|
if(item == i)
|
|
|
iter[i]
|
|
|
- else
|
|
|
+ else
|
|
|
item
|
|
|
end
|
|
|
end
|
|
@@ -522,11 +514,11 @@ end
|
|
|
|
|
|
class GetImage < Riddl::Implementation
|
|
|
def self::prepare(station, pattern, imageID)
|
|
|
- result = $db.execute "SELECT * FROM image WHERE station = #{station} and patternID = #{pattern} and imageID = #{imageID}"
|
|
|
+ result = $db.execute "SELECT * FROM image WHERE internalID = #{pattern} and imageID = #{imageID}"
|
|
|
Nokogiri::XML::Builder.new do |xml|
|
|
|
xml.image(:id => imageID){
|
|
|
result.each do |row|
|
|
|
- xml.variant(:lang => row[3], :label => row[4]){
|
|
|
+ xml.variant(:lang => row[2], :label => row[3]){
|
|
|
xml.text("https://centurio.work/customers/evva/was/images/uploads/#{station}/#{pattern}/#{imageID}/#{row[3]}.svg")
|
|
|
}
|
|
|
end
|
|
@@ -544,18 +536,17 @@ end
|
|
|
|
|
|
class UpdateImageLabel < Riddl::Implementation
|
|
|
def response
|
|
|
- $db.execute("UPDATE image SET label = ? WHERE station = ? AND patternID = ? AND imageID = ? AND language = ?", [@p[0].value, @r[0], @r[1], @r[3], @r[4]])
|
|
|
+ $db.execute("UPDATE image SET label = ? WHERE internalID = ? AND imageID = ? AND language = ?", [@p[0].value, @r[1], @r[3], @r[4]])
|
|
|
end
|
|
|
end
|
|
|
|
|
|
+#Not used, prototype for replacing image serverside
|
|
|
class GetRealImage < Riddl::Implementation
|
|
|
def response
|
|
|
|
|
|
#split on "." and tacke [0] to allow for e.g. de-at.svg
|
|
|
#would lead to error on de.at.svg //should this be fixed? would also lead to error if everything after last "." would be removed in case of only having de.at
|
|
|
-
|
|
|
#https://centurio.work/customers/evva/was/server/0/0/images/3/de-at?video=xyz
|
|
|
-
|
|
|
img = File.read(File.join(File.dirname(__dir__),'images/uploads', @r[0], @r[1], @r[3], @r[4].split(".")[0] + ".svg"))
|
|
|
|
|
|
if false #Currently replacements are done on the client side
|
|
@@ -565,22 +556,13 @@ class GetRealImage < Riddl::Implementation
|
|
|
if(@p[0].name == "video" && @p[0].value)
|
|
|
|
|
|
xml = Nokogiri.parse img
|
|
|
-
|
|
|
puts "Width " + xml.xpath("string(//xmlns:image/@width)")
|
|
|
puts "Height " + xml.xpath("string(//xmlns:image/@height)")
|
|
|
#puts "Posi " + xml.xpath("string(//xmlns:clipPath/path/@height)")
|
|
|
-
|
|
|
puts "Posi " + xml.xpath("string(//xmlns:image/following-sibling::clipPath/@id)")
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
puts xml.xpath("string(//xmlns:text[starts-with(text(), 'url')])").sub("url=", "")
|
|
|
|
|
|
-
|
|
|
# text
|
|
|
-
|
|
|
-
|
|
|
img = img.sub! "</svg>", '
|
|
|
<g><g transform="translate(562,288),scale(1.35185 1.35185)">
|
|
|
<foreignObject width="480" height="270">
|
|
@@ -605,16 +587,12 @@ end
|
|
|
|
|
|
|
|
|
class DeleteImage < Riddl::Implementation
|
|
|
- def response
|
|
|
- #puts "Delete Image"
|
|
|
- #puts File.join(File.dirname(__dir__),'images/uploads', @r[0], @r[1], @r[3] , @r[4] + ".svg")
|
|
|
-
|
|
|
+ def response
|
|
|
File.delete(File.join(File.dirname(__dir__),'images/uploads', @r[0], @r[1], @r[3] , @r[4] + ".svg")) if File.exist?(File.join(File.dirname(__dir__),'images/uploads', @r[0], @r[1], @r[3] , @r[4] + ".svg"))
|
|
|
|
|
|
+ $db.execute("DELETE FROM image WHERE internalID = ? AND imageID = ? AND language = ?", [@r[1], @r[3], @r[4]])
|
|
|
|
|
|
- $db.execute("DELETE FROM image WHERE station = ? AND patternID = ? AND imageID = ? AND language = ?", [@r[0], @r[1], @r[3], @r[4]])
|
|
|
-
|
|
|
- result = $db.execute "SELECT MAX(imageID) FROM image WHERE station = #{@r[0]} and patternID = #{@r[1]} and language = '#{@r[4]}'"
|
|
|
+ result = $db.execute "SELECT MAX(imageID) FROM image WHERE internalID = #{@r[1]} and language = '#{@r[4]}'"
|
|
|
if(result[0][0] == nil)
|
|
|
id = 0
|
|
|
else
|
|
@@ -624,11 +602,11 @@ class DeleteImage < Riddl::Implementation
|
|
|
#reorder if !end gets deleted
|
|
|
if(id == @r[3])
|
|
|
return
|
|
|
- else
|
|
|
+ else
|
|
|
cur = @r[3].to_i + 1
|
|
|
prev = @r[3].to_i
|
|
|
while cur < id.to_i do
|
|
|
- $db.execute("UPDATE image SET imageID = ? WHERE station = ? AND patternID = ? AND imageID = ? AND language = ?", [prev, @r[0], @r[1], cur, @r[4]])
|
|
|
+ $db.execute("UPDATE image SET imageID = ? WHERE internalID = ? AND imageID = ? AND language = ?", [prev, @r[1], cur, @r[4]])
|
|
|
|
|
|
src = File.join(File.dirname(__dir__),'images/uploads', @r[0], @r[1], cur.to_s, @r[4] + ".svg")
|
|
|
target = File.join(File.dirname(__dir__),'images/uploads', @r[0], @r[1], prev.to_s, @r[4] + ".svg")
|
|
@@ -644,9 +622,9 @@ class ListSearch < Riddl::Implementation
|
|
|
def response
|
|
|
|
|
|
ret = {
|
|
|
- :patternID => "/patternID",
|
|
|
- :multi => "/multi",
|
|
|
- :juergen => "/juergen"
|
|
|
+ :imagesWIZAll => "/imagesWIZ?pattern=...",
|
|
|
+ :imagesWIZSingle => "/imagesWIZ/0..*/?pattern=...",
|
|
|
+ :errorsWIZ => "/errorsWIZ/"
|
|
|
}
|
|
|
|
|
|
Riddl::Parameter::Complex.new('list','application/json',JSON::pretty_generate(ret))
|
|
@@ -654,53 +632,23 @@ class ListSearch < Riddl::Implementation
|
|
|
end
|
|
|
|
|
|
|
|
|
-class SearchPattern < Riddl::Implementation
|
|
|
+class SearchImages < Riddl::Implementation
|
|
|
def response
|
|
|
+
|
|
|
|
|
|
+ #https://centurio.work/customers/evva/was/ui/TransformProductCode.php?ProductCode=E.A.PZ.DZ-S.31.31.MP.SEP
|
|
|
|
|
|
-
|
|
|
- iter = @p[0].value.split(".")
|
|
|
- searchstring = ""
|
|
|
- count = 0
|
|
|
-
|
|
|
- iter.each do |item|
|
|
|
- if !item.nil?
|
|
|
- if item.to_s != "*"
|
|
|
- searchstring = searchstring + " and (P" + count.to_s + "='*' or P" + count.to_s + " = '" + item.to_s + "')"
|
|
|
- end
|
|
|
- count += 1
|
|
|
- end
|
|
|
- end
|
|
|
-
|
|
|
- result = $db.execute "SELECT patternID FROM station WHERE station = " + @r[0] + searchstring
|
|
|
-
|
|
|
-
|
|
|
- if result.length > 0
|
|
|
- ret = {
|
|
|
- :amount => result.length.to_s,
|
|
|
- :ids => result
|
|
|
- }
|
|
|
- end
|
|
|
-
|
|
|
- Riddl::Parameter::Complex.new('list','application/json',JSON::pretty_generate(ret))
|
|
|
-
|
|
|
- #puts the first found string
|
|
|
- #result = $db.execute "SELECT P0,P1,P2,P3,P4,P5,P6,P7,P8,P9,P10 FROM station WHERE station = 0" + searchstring
|
|
|
- #puts "found" + result.length.to_s
|
|
|
- #result[0].each do |item|
|
|
|
- # if !item.nil?
|
|
|
- # puts item + "."
|
|
|
- # end
|
|
|
- #end
|
|
|
- end
|
|
|
-end
|
|
|
-
|
|
|
+ #path = File.join(File.dirname(__FILE__), + '../ui/')
|
|
|
+ #args = ['arg1', 'arg2']
|
|
|
+ #puts `php -f #{ path + 'TransformProductCode.php'}`
|
|
|
|
|
|
+
|
|
|
+ pattern = JSON.parse(Net::HTTP.get URI("https://centurio.work/customers/evva/was/ui/TransformProductCode.php?ProductCode=" + @p[0].value))
|
|
|
+ puts pattern.keys[0]
|
|
|
|
|
|
-class SearchImages < Riddl::Implementation
|
|
|
- def response
|
|
|
- iter = @p[0].value.split(".")
|
|
|
- searchstring = ""
|
|
|
+
|
|
|
+
|
|
|
+ #iter = @p[0].value.split(".")
|
|
|
count = 0
|
|
|
|
|
|
#search = K.*.9.*
|
|
@@ -710,181 +658,72 @@ class SearchImages < Riddl::Implementation
|
|
|
#match: = K.*.*.*
|
|
|
|
|
|
#no match: = K.*.8.*
|
|
|
+ #puts iter;
|
|
|
|
|
|
- iter.each do |item|
|
|
|
- if !item.nil?
|
|
|
- if item.to_s != "*"
|
|
|
- searchstring = searchstring + " and (P" + count.to_s + "='*' or P" + count.to_s + " = '" + item.to_s + "')"
|
|
|
- else
|
|
|
- searchstring = searchstring + " and (P" + count.to_s + "!=''" + ")"
|
|
|
- end
|
|
|
- count += 1
|
|
|
- end
|
|
|
- end
|
|
|
-
|
|
|
- result = $db.execute "SELECT patternID FROM station WHERE station = " + @r[0] + searchstring
|
|
|
|
|
|
|
|
|
- ret = []
|
|
|
- if result.length > 0
|
|
|
- result.each do |item|
|
|
|
- result2 = $db.execute "SELECT DISTINCT station, patternID, imageID FROM image WHERE station = #{@r[0]} and patternID = #{item[0]}"
|
|
|
- result2.each do |item2|
|
|
|
- ret << item2[0].to_s + "/" + item2[1].to_s + "/" + item2[2].to_s
|
|
|
- end
|
|
|
- end
|
|
|
- end
|
|
|
|
|
|
- Riddl::Parameter::Complex.new('list','application/json',JSON::pretty_generate(ret))
|
|
|
- end
|
|
|
-end
|
|
|
-
|
|
|
-class SearchImagesSingle < Riddl::Implementation
|
|
|
- def response
|
|
|
+ #$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)"
|
|
|
|
|
|
+ #Get first key dynamicly
|
|
|
+ searchstring = "SELECT " + pattern.keys[0] + ".internalID AS ID From"
|
|
|
|
|
|
- iter = @p[0].value.split(".")
|
|
|
- searchstring = ""
|
|
|
- count = 0
|
|
|
-
|
|
|
- iter.each do |item|
|
|
|
- if !item.nil?
|
|
|
- if item.to_s != "*"
|
|
|
- searchstring = searchstring + " and (P" + count.to_s + "='*' or P" + count.to_s + " = '" + item.to_s + "')"
|
|
|
- else
|
|
|
- searchstring = searchstring + " and (P" + count.to_s + "!=''" + ")"
|
|
|
- end
|
|
|
- count += 1
|
|
|
- end
|
|
|
+ pattern.each do |key, val|
|
|
|
+ puts key
|
|
|
+
|
|
|
+ #searchstring = searchstring + "pattern " + key
|
|
|
end
|
|
|
|
|
|
- result = $db.execute "SELECT patternID FROM station WHERE station = " + @r[0] + searchstring
|
|
|
+ #Search for pattern
|
|
|
+ searchstring = "SELECT A.internalID AS ID, A.value AS Pb, B.value AS Sy, C.value AS Pk, D.value AS BA, E.value AS ZA
|
|
|
+ FROM pattern A, pattern B, pattern C, pattern D, pattern E
|
|
|
+ WHERE A.internalID == B.internalID AND A.internalID == C.internalID AND A.internalID == D.internalID AND A.internalID == E.internalID
|
|
|
+ AND A.type == 'Pb' AND (A.value == '#{pattern["Pb"]}' or A.value == '*')
|
|
|
+ AND B.type == 'Sy' AND (B.value == '#{pattern["Sy"]}' or B.value == '*')
|
|
|
+ AND C.type == 'Pk' AND (C.value == '#{pattern["Pk"]}' or C.value == '*')
|
|
|
+ AND D.type == 'Ba' AND (D.value == '#{pattern["Ba"]}' or D.value == '*')
|
|
|
+ AND E.type == 'Za' AND (E.value == '#{pattern["Za"]}' or E.value == '*');"
|
|
|
|
|
|
-
|
|
|
- count = 0
|
|
|
- pattern = 0
|
|
|
- image = 0
|
|
|
+ result = $db.execute searchstring;
|
|
|
|
|
|
if result.length > 0
|
|
|
+
|
|
|
result.each do |item|
|
|
|
- result2 = $db.execute "SELECT DISTINCT station, patternID, imageID FROM image WHERE station = #{@r[0]} and patternID = #{item[0]}"
|
|
|
- result2.each do |item2|
|
|
|
- if(count == @r[3].to_i)
|
|
|
- puts "Found "
|
|
|
- pattern = item2[1]
|
|
|
- image = item2[2]
|
|
|
- end
|
|
|
- count += 1
|
|
|
- end
|
|
|
+ puts "ID: " +item[0].to_s + " Pattern:" + item[1] + "." + item[2]+ "." + item[3]+ "." + item[4] + "." + item[5]
|
|
|
end
|
|
|
- end
|
|
|
- img = File.read(File.join(File.dirname(__dir__),'images/uploads', @r[0].to_s, pattern.to_s, image.to_s, "de-at.svg"))
|
|
|
- Riddl::Parameter::Complex.new('theRealImage','image/svg+xml',img)
|
|
|
-
|
|
|
- end
|
|
|
-end
|
|
|
-
|
|
|
-class SearchImages2 < Riddl::Implementation
|
|
|
- def response
|
|
|
-
|
|
|
- iter = @p[0].value.split(".")
|
|
|
- searchstring = ""
|
|
|
- count = 0
|
|
|
-
|
|
|
- #search = K.*.9.*
|
|
|
-
|
|
|
- #match: = K.5.9.7
|
|
|
- #match: = K.5.9.*
|
|
|
- #match: = K.*.*.*
|
|
|
-
|
|
|
- #no match: = K.*.8.*
|
|
|
|
|
|
- iter.each do |item|
|
|
|
- if !item.nil?
|
|
|
- if item.to_s != "*"
|
|
|
- item.to_s.gsub! '_empty_', '/'
|
|
|
- searchstring = searchstring + " and (P" + count.to_s + "='*' or P" + count.to_s + " = '" + item.to_s + "')"
|
|
|
- else
|
|
|
- searchstring = searchstring + " and (P" + count.to_s + "!=''" + ")"
|
|
|
- end
|
|
|
- count += 1
|
|
|
- end
|
|
|
end
|
|
|
+ #iter.each do |item|
|
|
|
+ # if !item.nil?
|
|
|
+ # if item.to_s != "*"
|
|
|
+ # item.to_s.gsub! '_empty_', '/'
|
|
|
+ # searchstring = searchstring + " and (P" + count.to_s + "='*' or P" + count.to_s + " = '" + item.to_s + "')"
|
|
|
+ # else
|
|
|
+ # searchstring = searchstring + " and (P" + count.to_s + "!=''" + ")"
|
|
|
+ # end
|
|
|
+ # count += 1
|
|
|
+ # end
|
|
|
+ #end
|
|
|
|
|
|
- result = $db.execute "SELECT patternID FROM station WHERE station = " + @r[0] + searchstring
|
|
|
-
|
|
|
+ #result = $db.execute "SELECT patternID FROM station WHERE station = " + @r[0] + searchstring
|
|
|
|
|
|
+ #Search for images with one or multiple found patternIDs
|
|
|
ret = []
|
|
|
- if result.length > 0
|
|
|
- result.each do |item|
|
|
|
- result2 = $db.execute "SELECT DISTINCT station, patternID, imageID FROM image WHERE station = #{@r[0]} and patternID = #{item[0]}"
|
|
|
- result2.each do |item2|
|
|
|
- ret << item2[0].to_s + "/" + item2[1].to_s + "/" + item2[2].to_s
|
|
|
- end
|
|
|
- end
|
|
|
- end
|
|
|
+ #if result.length > 0
|
|
|
+ # result.each do |item|
|
|
|
+ # result2 = $db.execute "SELECT DISTINCT station, patternID, imageID FROM image WHERE station = #{@r[0]} and patternID = #{item[0]}"
|
|
|
+ # result2.each do |item2|
|
|
|
+ # ret << item2[0].to_s + "/" + item2[1].to_s + "/" + item2[2].to_s
|
|
|
+ # end
|
|
|
+ # end
|
|
|
+ #end
|
|
|
|
|
|
Riddl::Parameter::Complex.new('list','application/json',JSON::pretty_generate(ret))
|
|
|
end
|
|
|
end
|
|
|
|
|
|
|
|
|
-
|
|
|
-class SearchImages2Single < Riddl::Implementation
|
|
|
- def response
|
|
|
- iter = @p[0].value.split(".")
|
|
|
- searchstring = ""
|
|
|
- count = 0
|
|
|
-
|
|
|
- iter.each do |item|
|
|
|
- if !item.nil?
|
|
|
- if item.to_s != "*"
|
|
|
- searchstring = searchstring + " and (P" + count.to_s + "='*' or P" + count.to_s + " = '" + item.to_s + "')"
|
|
|
- else
|
|
|
- searchstring = searchstring + " and (P" + count.to_s + "!=''" + ")"
|
|
|
- end
|
|
|
- count += 1
|
|
|
- end
|
|
|
- end
|
|
|
-
|
|
|
- result = $db.execute "SELECT patternID FROM station WHERE station = " + @r[0] + searchstring
|
|
|
-
|
|
|
- count = 0
|
|
|
- pattern = 0
|
|
|
- image = 0
|
|
|
-
|
|
|
- if result.length > 0
|
|
|
- result.each do |item|
|
|
|
- result2 = $db.execute "SELECT DISTINCT station, patternID, imageID FROM image WHERE station = #{@r[0]} and patternID = #{item[0]}"
|
|
|
- result2.each do |item2|
|
|
|
- if(count == @r[3].to_i)
|
|
|
- puts "Found "
|
|
|
- pattern = item2[1]
|
|
|
- image = item2[2]
|
|
|
- end
|
|
|
- count += 1
|
|
|
- end
|
|
|
- end
|
|
|
- end
|
|
|
-
|
|
|
- #https://centurio.work/customers/evva/was/ui/imageReplacement.php?___image___=8/23/0/de-at.svg
|
|
|
-
|
|
|
- img = File.read(File.join(File.dirname(__dir__),'images/uploads', @r[0].to_s, pattern.to_s, image.to_s, "de-at.svg"))
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- uri = "https://centurio.work/customers/evva/was/ui/imageReplacement.php?___image___=" + @r[0].to_s + "/" + pattern.to_s + "/" + image.to_s + "/de-at.svg"
|
|
|
-
|
|
|
- string = '<html><body style="margin: 0"><iframe style="position: absolute; height: 100%; width: 100%; border: none" src="' + uri +'" title="description"></body></html>'
|
|
|
-
|
|
|
-
|
|
|
- Riddl::Parameter::Complex.new('html','text/html',string)
|
|
|
-
|
|
|
- end
|
|
|
-end
|
|
|
-
|
|
|
-
|
|
|
-class SearchImages3Single < Riddl::Implementation
|
|
|
+class SearchImagesSingle < Riddl::Implementation
|
|
|
def response
|
|
|
iter = @p[0].value.split(".")
|
|
|
searchstring = ""
|
|
@@ -1028,51 +867,6 @@ class SearchErrors < Riddl::Implementation
|
|
|
end
|
|
|
end
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-class SearchImagesReverse < Riddl::Implementation
|
|
|
- def response
|
|
|
- iter = @p[0].value.split(".")
|
|
|
- searchstring = ""
|
|
|
- count = 0
|
|
|
-
|
|
|
- #search = K.*.9.*
|
|
|
-
|
|
|
- #match: = K.5.9.7
|
|
|
- #match: = K.5.9.*
|
|
|
- #match: = K.*.*.*
|
|
|
-
|
|
|
- #no match: = K.*.8.*
|
|
|
-
|
|
|
- iter.each do |item|
|
|
|
- if !item.nil?
|
|
|
- if item.to_s != "*"
|
|
|
- searchstring = searchstring + " and (P" + count.to_s + "='*' or P" + count.to_s + " = '" + item.to_s + "')"
|
|
|
- else
|
|
|
- searchstring = searchstring + " and (P" + count.to_s + "!=''" + ")"
|
|
|
- end
|
|
|
- count += 1
|
|
|
- end
|
|
|
- end
|
|
|
-
|
|
|
- result = $db.execute "SELECT patternID FROM station WHERE station = " + @r[0] + searchstring
|
|
|
-
|
|
|
-
|
|
|
- ret = []
|
|
|
- if result.length > 0
|
|
|
- result.each do |item|
|
|
|
- result2 = $db.execute "SELECT DISTINCT station, patternID, imageID FROM image WHERE station = #{@r[0]} and patternID = #{item[0]}"
|
|
|
- result2.each do |item2|
|
|
|
- ret << item2[0].to_s + "/" + item2[1].to_s + "/" + item2[2].to_s
|
|
|
- end
|
|
|
- end
|
|
|
- end
|
|
|
-
|
|
|
- Riddl::Parameter::Complex.new('list','application/json',JSON::pretty_generate(ret))
|
|
|
- end
|
|
|
-end
|
|
|
-
|
|
|
def createDB(opts)
|
|
|
$db.execute("PRAGMA foreign_keys=ON");
|
|
|
|
|
@@ -1111,6 +905,7 @@ server = Riddl::Server.new(File.join(__dir__,'/was.xml'), :host => 'localhost')
|
|
|
|
|
|
createDB(opts)
|
|
|
|
|
|
+
|
|
|
# opts[:appconf]
|
|
|
|
|
|
on resource do
|
|
@@ -1171,33 +966,15 @@ server = Riddl::Server.new(File.join(__dir__,'/was.xml'), :host => 'localhost')
|
|
|
end
|
|
|
on resource 'search' do
|
|
|
run ListSearch if get
|
|
|
- on resource 'patternID' do
|
|
|
- run SearchPattern if get
|
|
|
- end
|
|
|
- on resource 'images' do
|
|
|
+ on resource 'imagesWIZ' do
|
|
|
run SearchImages if get
|
|
|
on resource '\d+' do
|
|
|
run SearchImagesSingle if get
|
|
|
end
|
|
|
end
|
|
|
- on resource 'imagesServerSide' do
|
|
|
- run SearchImages2 if get
|
|
|
- on resource '\d+' do
|
|
|
- run SearchImages2Single if get
|
|
|
- end
|
|
|
- end
|
|
|
- on resource 'imagesWIZ' do
|
|
|
- run SearchImages2 if get
|
|
|
- on resource '\d+' do
|
|
|
- run SearchImages3Single if get
|
|
|
- end
|
|
|
- end
|
|
|
on resource 'errorsWIZ' do
|
|
|
run SearchErrors if get
|
|
|
end
|
|
|
- on resource 'imagesReverse' do
|
|
|
- run SearchImagesReverse if get
|
|
|
- end
|
|
|
end
|
|
|
end
|
|
|
end
|