|
@@ -634,89 +634,29 @@ end
|
|
|
|
|
|
class SearchImages < Riddl::Implementation
|
|
class SearchImages < Riddl::Implementation
|
|
def response
|
|
def response
|
|
-
|
|
|
|
-
|
|
|
|
#https://centurio.work/customers/evva/was/ui/TransformProductCode.php?ProductCode=E.A.PZ.DZ-S.31.31.MP.SEP
|
|
#https://centurio.work/customers/evva/was/ui/TransformProductCode.php?ProductCode=E.A.PZ.DZ-S.31.31.MP.SEP
|
|
-
|
|
|
|
- #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))
|
|
pattern = JSON.parse(Net::HTTP.get URI("https://centurio.work/customers/evva/was/ui/TransformProductCode.php?ProductCode=" + @p[0].value))
|
|
- puts pattern.keys[0]
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
- #iter = @p[0].value.split(".")
|
|
|
|
- count = 0
|
|
|
|
-
|
|
|
|
- #search = K.*.9.*
|
|
|
|
-
|
|
|
|
- #match: = K.5.9.7
|
|
|
|
- #match: = K.5.9.*
|
|
|
|
- #match: = K.*.*.*
|
|
|
|
-
|
|
|
|
- #no match: = K.*.8.*
|
|
|
|
- #puts iter;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- #$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"
|
|
|
|
-
|
|
|
|
- pattern.each do |key, val|
|
|
|
|
- puts key
|
|
|
|
-
|
|
|
|
- #searchstring = searchstring + "pattern " + key
|
|
|
|
- end
|
|
|
|
-
|
|
|
|
- #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 == '*');"
|
|
|
|
-
|
|
|
|
|
|
+ #Get first key dynamicly and then build sql query
|
|
|
|
+ searchstring = "SELECT " + pattern.keys[0] + ".internalID AS ID"
|
|
|
|
+ searchstring = searchstring + " FROM " + pattern.map{ |key, val| "pattern " + key}.join(', ')
|
|
|
|
+ searchstring = searchstring + " WHERE " + pattern.map{ |key, val| pattern.keys[0] + ".internalID == " + key + ".internalID"}.join(' AND ')
|
|
|
|
+ searchstring = searchstring + " AND " + pattern.map{ |key, val| key + ".type == '" + key + "' AND (" + key + ".value == '"+ val +"' or " + key + ".value == '*')"}.join(' AND ') + " ORDER BY ID ASC"
|
|
result = $db.execute searchstring;
|
|
result = $db.execute searchstring;
|
|
|
|
|
|
- if result.length > 0
|
|
|
|
-
|
|
|
|
- result.each do |item|
|
|
|
|
- puts "ID: " +item[0].to_s + " Pattern:" + item[1] + "." + item[2]+ "." + item[3]+ "." + item[4] + "." + item[5]
|
|
|
|
- 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
|
|
|
|
|
|
|
|
#Search for images with one or multiple found patternIDs
|
|
#Search for images with one or multiple found patternIDs
|
|
ret = []
|
|
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 internalID, imageID FROM image WHERE internalID = #{item[0]} ORDER BY imageID ASC"
|
|
|
|
+ result2.each do |item2|
|
|
|
|
+ ret << @r[0] + "/" + item2[0].to_s + "/" + item2[1].to_s
|
|
|
|
+ end
|
|
|
|
+ end
|
|
|
|
+ end
|
|
|
|
|
|
Riddl::Parameter::Complex.new('list','application/json',JSON::pretty_generate(ret))
|
|
Riddl::Parameter::Complex.new('list','application/json',JSON::pretty_generate(ret))
|
|
end
|
|
end
|
|
@@ -725,51 +665,29 @@ end
|
|
|
|
|
|
class SearchImagesSingle < Riddl::Implementation
|
|
class SearchImagesSingle < Riddl::Implementation
|
|
def response
|
|
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
|
|
|
|
|
|
+ pattern = JSON.parse(Net::HTTP.get URI("https://centurio.work/customers/evva/was/ui/TransformProductCode.php?ProductCode=" + @p[0].value))
|
|
|
|
+
|
|
|
|
+ searchstring = "SELECT " + pattern.keys[0] + ".internalID AS ID"
|
|
|
|
+ searchstring = searchstring + " FROM " + pattern.map{ |key, val| "pattern " + key}.join(', ')
|
|
|
|
+ searchstring = searchstring + " WHERE " + pattern.map{ |key, val| pattern.keys[0] + ".internalID == " + key + ".internalID"}.join(' AND ')
|
|
|
|
+ searchstring = searchstring + " AND " + pattern.map{ |key, val| key + ".type == '" + key + "' AND (" + key + ".value == '"+ val +"' or " + key + ".value == '*')"}.join(' AND ') + " ORDER BY ID ASC"
|
|
|
|
+ result = $db.execute searchstring;
|
|
|
|
|
|
count = 0
|
|
count = 0
|
|
pattern = 0
|
|
pattern = 0
|
|
image = 0
|
|
image = 0
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
builder = Nokogiri::XML::Builder.new do |xml|
|
|
builder = Nokogiri::XML::Builder.new do |xml|
|
|
xml.image(:id => @r[3].to_s){
|
|
xml.image(:id => @r[3].to_s){
|
|
if result.length > 0
|
|
if result.length > 0
|
|
result.each do |item|
|
|
result.each do |item|
|
|
- result2 = $db.execute "SELECT DISTINCT station, patternID, imageID FROM image WHERE station = #{@r[0]} and patternID = #{item[0]}"
|
|
|
|
|
|
+ result2 = $db.execute "SELECT DISTINCT internalID, imageID FROM image WHERE internalID = #{item[0]} ORDER BY imageID ASC"
|
|
result2.each do |item2|
|
|
result2.each do |item2|
|
|
if(count == @r[3].to_i)
|
|
if(count == @r[3].to_i)
|
|
-
|
|
|
|
-
|
|
|
|
- result3 = $db.execute "SELECT DISTINCT station, patternID, imageID, language, label FROM image WHERE station = #{@r[0]} and patternID = #{item[0]} and imageID =#{item2[2]}"
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ result3 = $db.execute "SELECT DISTINCT internalID, imageID, language, label FROM image WHERE internalID = #{item[0]} and imageID =#{item2[1]}"
|
|
|
|
|
|
result3.each do |item3|
|
|
result3.each do |item3|
|
|
- uri = "https://centurio.work/customers/evva/was/ui/imageReplacement.php?___image___=" + @r[0].to_s + "/" + item3[1].to_s + "/" + item3[2].to_s + "/" + item3[3].to_s + ".svg"
|
|
|
|
|
|
+ uri = "https://centurio.work/customers/evva/was/ui/imageReplacement.php?___image___=" + @r[0].to_s + "/" + item3[0].to_s + "/" + item3[1].to_s + "/" + item3[2].to_s + ".svg"
|
|
|
|
|
|
@p.each_with_index do |item, index|
|
|
@p.each_with_index do |item, index|
|
|
if index != 0
|
|
if index != 0
|
|
@@ -778,7 +696,7 @@ class SearchImagesSingle < Riddl::Implementation
|
|
|
|
|
|
end
|
|
end
|
|
|
|
|
|
- xml.variant(:lang => item3[3].to_s, :label => item3[4].to_s){
|
|
|
|
|
|
+ xml.variant(:lang => item3[2].to_s, :label => item3[3].to_s){
|
|
xml.text(uri)
|
|
xml.text(uri)
|
|
}
|
|
}
|
|
end
|
|
end
|
|
@@ -791,57 +709,28 @@ class SearchImagesSingle < Riddl::Implementation
|
|
end
|
|
end
|
|
|
|
|
|
#https://centurio.work/customers/evva/was/ui/imageReplacement.php?___image___=8/23/0/de-at.svg
|
|
#https://centurio.work/customers/evva/was/ui/imageReplacement.php?___image___=8/23/0/de-at.svg
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
|
|
-
|
|
|
|
#puts builder.to_xml
|
|
#puts builder.to_xml
|
|
Riddl::Parameter::Complex.new('image','application/xml',builder.to_xml)
|
|
Riddl::Parameter::Complex.new('image','application/xml',builder.to_xml)
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
class SearchErrors < Riddl::Implementation
|
|
class SearchErrors < Riddl::Implementation
|
|
def response
|
|
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
|
|
|
|
|
|
+ pattern = JSON.parse(Net::HTTP.get URI("https://centurio.work/customers/evva/was/ui/TransformProductCode.php?ProductCode=" + @p[0].value))
|
|
|
|
+
|
|
|
|
+ searchstring = "SELECT " + pattern.keys[0] + ".internalID AS ID"
|
|
|
|
+ searchstring = searchstring + " FROM " + pattern.map{ |key, val| "pattern " + key}.join(', ')
|
|
|
|
+ searchstring = searchstring + " WHERE " + pattern.map{ |key, val| pattern.keys[0] + ".internalID == " + key + ".internalID"}.join(' AND ')
|
|
|
|
+ searchstring = searchstring + " AND " + pattern.map{ |key, val| key + ".type == '" + key + "' AND (" + key + ".value == '"+ val +"' or " + key + ".value == '*')"}.join(' AND ') + " ORDER BY ID ASC"
|
|
|
|
+ result = $db.execute searchstring;
|
|
|
|
|
|
|
|
|
|
ret = []
|
|
ret = []
|
|
if result.length > 0
|
|
if result.length > 0
|
|
result.each do |item|
|
|
result.each do |item|
|
|
- result2 = $db.execute "SELECT DISTINCT error FROM error WHERE station = #{@r[0]} and patternID = #{item[0]}"
|
|
|
|
|
|
+ result2 = $db.execute "SELECT DISTINCT error FROM error WHERE internalID = #{item[0]} ORDER BY internalID ASC"
|
|
result2.each do |item2|
|
|
result2.each do |item2|
|
|
ret << item2[0].to_s
|
|
ret << item2[0].to_s
|
|
end
|
|
end
|