|
@@ -376,7 +376,7 @@ class GetImages < Riddl::Implementation
|
|
builder = Nokogiri::XML::Builder.new do |xml|
|
|
builder = Nokogiri::XML::Builder.new do |xml|
|
|
xml.images(){
|
|
xml.images(){
|
|
result.each do |row|
|
|
result.each do |row|
|
|
- xml<< GetImage::prepare(@r[0], @r[1], row[0]).to_xml( save_with:formatted_no_decl )
|
|
|
|
|
|
+ xml<< GetImage::prepare(@r[0], @r[1], row[0], @a[0][:appconf]["wasurl"]).to_xml( save_with:formatted_no_decl )
|
|
end
|
|
end
|
|
}
|
|
}
|
|
end
|
|
end
|
|
@@ -513,20 +513,20 @@ end
|
|
|
|
|
|
|
|
|
|
class GetImage < Riddl::Implementation
|
|
class GetImage < Riddl::Implementation
|
|
- def self::prepare(station, pattern, imageID)
|
|
|
|
|
|
+ def self::prepare(station, pattern, imageID, wasurl)
|
|
result = $db.execute "SELECT * FROM image WHERE internalID = #{pattern} and imageID = #{imageID}"
|
|
result = $db.execute "SELECT * FROM image WHERE internalID = #{pattern} and imageID = #{imageID}"
|
|
Nokogiri::XML::Builder.new do |xml|
|
|
Nokogiri::XML::Builder.new do |xml|
|
|
xml.image(:id => imageID){
|
|
xml.image(:id => imageID){
|
|
result.each do |row|
|
|
result.each do |row|
|
|
xml.variant(:lang => row[2], :label => row[3]){
|
|
xml.variant(:lang => row[2], :label => row[3]){
|
|
- xml.text("https://centurio.work/customers/evva/was/images/uploads/#{station}/#{pattern}/#{imageID}/#{row[3]}.svg")
|
|
|
|
|
|
+ xml.text(wasurl + "images/uploads/#{station}/#{pattern}/#{imageID}/#{row[3]}.svg")
|
|
}
|
|
}
|
|
end
|
|
end
|
|
}
|
|
}
|
|
end
|
|
end
|
|
end
|
|
end
|
|
def response
|
|
def response
|
|
- builder = GetImage::prepare(@r[0], @r[1], @r[3])
|
|
|
|
|
|
+ builder = GetImage::prepare(@r[0], @r[1], @r[3], @a[0][:appconf]["wasurl"])
|
|
Riddl::Parameter::Complex.new('image','application/xml',builder.to_xml)
|
|
Riddl::Parameter::Complex.new('image','application/xml',builder.to_xml)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
@@ -635,7 +635,7 @@ 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
|
|
|
|
|
|
- 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(@a[0][:appconf]["wasurl"] + "ui/TransformProductCode.php?ProductCode=" + @p[0].value))
|
|
|
|
|
|
|
|
|
|
#Get first key dynamicly and then build sql query
|
|
#Get first key dynamicly and then build sql query
|
|
@@ -664,7 +664,7 @@ end
|
|
|
|
|
|
class SearchImagesSingle < Riddl::Implementation
|
|
class SearchImagesSingle < Riddl::Implementation
|
|
def response
|
|
def response
|
|
- 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(@a[0][:appconf]["wasurl"] + "ui/TransformProductCode.php?ProductCode=" + @p[0].value))
|
|
|
|
|
|
searchstring = "SELECT " + pattern.keys[0] + ".internalID AS ID"
|
|
searchstring = "SELECT " + pattern.keys[0] + ".internalID AS ID"
|
|
searchstring = searchstring + " FROM " + pattern.map{ |key, val| "pattern " + key}.join(', ')
|
|
searchstring = searchstring + " FROM " + pattern.map{ |key, val| "pattern " + key}.join(', ')
|
|
@@ -686,7 +686,7 @@ class SearchImagesSingle < Riddl::Implementation
|
|
result3 = $db.execute "SELECT DISTINCT internalID, imageID, language, label FROM image WHERE internalID = #{item[0]} and imageID =#{item2[1]}"
|
|
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[0].to_s + "/" + item3[1].to_s + "/" + item3[2].to_s + ".svg"
|
|
|
|
|
|
+ uri = @a[0][:appconf]["wasurl"] + "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
|
|
@@ -716,7 +716,7 @@ end
|
|
|
|
|
|
class SearchErrors < Riddl::Implementation
|
|
class SearchErrors < Riddl::Implementation
|
|
def response
|
|
def response
|
|
- 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(@a[0][:appconf]["wasurl"] + "ui/TransformProductCode.php?ProductCode=" + @p[0].value))
|
|
|
|
|
|
searchstring = "SELECT " + pattern.keys[0] + ".internalID AS ID"
|
|
searchstring = "SELECT " + pattern.keys[0] + ".internalID AS ID"
|
|
searchstring = searchstring + " FROM " + pattern.map{ |key, val| "pattern " + key}.join(', ')
|
|
searchstring = searchstring + " FROM " + pattern.map{ |key, val| "pattern " + key}.join(', ')
|
|
@@ -814,14 +814,25 @@ class GetAssignment < Riddl::Implementation
|
|
station = $db.execute "SELECT value FROM patternassignments WHERE ID = #{@r[1]} AND AssID = #{row[0]} AND type == 'STATION'"
|
|
station = $db.execute "SELECT value FROM patternassignments WHERE ID = #{@r[1]} AND AssID = #{row[0]} AND type == 'STATION'"
|
|
stationvalue = Integer(station[0][0])
|
|
stationvalue = Integer(station[0][0])
|
|
|
|
|
|
- singleItem = $db.execute "SELECT value FROM patternassignments WHERE ID = #{@r[1]} AND AssID = #{row[0]} AND type != 'STATION'"
|
|
|
|
|
|
+ #old where pattern is stored as string
|
|
|
|
+ #singleItem = $db.execute "SELECT value FROM patternassignments WHERE ID = #{@r[1]} AND AssID = #{row[0]} AND type != 'STATION'"
|
|
|
|
+ #if(ret[stationvalue] == nil)
|
|
|
|
+ # ret[stationvalue] = Hash.new()
|
|
|
|
+ #end
|
|
|
|
+ #ret[stationvalue][row[0]] = singleItem.join('.')
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ singleItem = $db.execute "SELECT type, value FROM patternassignments WHERE ID = #{@r[1]} AND AssID = #{row[0]} AND type != 'STATION'"
|
|
|
|
|
|
if(ret[stationvalue] == nil)
|
|
if(ret[stationvalue] == nil)
|
|
ret[stationvalue] = Hash.new()
|
|
ret[stationvalue] = Hash.new()
|
|
end
|
|
end
|
|
- ret[stationvalue][row[0]] = singleItem.join('.')
|
|
|
|
|
|
+ ret[stationvalue][row[0]] = Hash.new()
|
|
|
|
+
|
|
|
|
+ singleItem.each do |it|
|
|
|
|
+ ret[stationvalue][row[0]][it[0]] = it[1]
|
|
|
|
+ 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))
|
|
@@ -845,30 +856,43 @@ class ListAssignmentSearch < Riddl::Implementation
|
|
|
|
|
|
#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
|
|
|
|
|
|
- pattern = JSON.parse(Net::HTTP.get URI("https://centurio.work/customers/evva/was/ui/TransformProductCode.php?ProductCode=" + @p[0].value))
|
|
|
|
|
|
|
|
- puts @p[1].value + @p[2].value
|
|
|
|
-#$db.execute "CREATE TABLE IF NOT EXISTS patternassignments(ID INT, AssID INT, type CHARACTER(20), value CHARACTER(20), FOREIGN KEY(ID) REFERENCES assignments(ID) ON DELETE CASCADE)"
|
|
|
|
|
|
+ pattern = JSON.parse(Net::HTTP.get URI(@a[0][:appconf]["wasurl"] + "ui/TransformProductCode.php?ProductCode=" + @p[0].value))
|
|
|
|
+
|
|
|
|
+ #$db.execute "CREATE TABLE IF NOT EXISTS patternassignments(ID INT, AssID INT, type CHARACTER(20), value CHARACTER(20), FOREIGN KEY(ID) REFERENCES assignments(ID) ON DELETE CASCADE)"
|
|
|
|
|
|
#Get first key dynamicly and then build sql query
|
|
#Get first key dynamicly and then build sql query
|
|
- searchstring = "SELECT " + pattern.keys[0] + ".ID AS ID"
|
|
|
|
- searchstring = searchstring + " FROM " + pattern.map{ |key, val| "patternassignments " + key}.join(', ')
|
|
|
|
- searchstring = searchstring + " , patternassignments STATION , patternassignments ValText"
|
|
|
|
- searchstring = searchstring + " WHERE " + pattern.map{ |key, val| pattern.keys[0] + ".AssID == " + key + ".AssID"}.join(' AND ') + " AND ";
|
|
|
|
- searchstring = searchstring + pattern.map{ |key, val| pattern.keys[0] + ".ID == " + key + ".ID"}.join(' AND ')
|
|
|
|
-
|
|
|
|
- searchstring = searchstring + " AND " + pattern.keys[0] + ".AssID == STATION.AssID"
|
|
|
|
- searchstring = searchstring + " AND " + pattern.keys[0] + ".AssID == ValText.AssID"
|
|
|
|
- searchstring = searchstring + " AND " + pattern.keys[0] + ".ID == STATION.ID"
|
|
|
|
- searchstring = searchstring + " AND " + pattern.keys[0] + ".ID == ValText.ID"
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- searchstring = searchstring + " AND STATION.type == 'STATION'" + " AND STATION.value == '" + @p[1].value + "'"
|
|
|
|
- searchstring = searchstring + " AND ValText.type == 'TEXT'" + " AND ValText.value == '" + @p[2].value + "'"
|
|
|
|
|
|
+ if(pattern.keys[0] != nil)
|
|
|
|
+ searchstring = "SELECT " + pattern.keys[0] + ".ID AS ID"
|
|
|
|
+ searchstring = searchstring + " FROM " + pattern.map{ |key, val| "patternassignments " + key}.join(', ')
|
|
|
|
+ searchstring = searchstring + " , patternassignments STATION , patternassignments ValText"
|
|
|
|
+ searchstring = searchstring + " WHERE " + pattern.map{ |key, val| pattern.keys[0] + ".AssID == " + key + ".AssID"}.join(' AND ') + " AND ";
|
|
|
|
+ searchstring = searchstring + pattern.map{ |key, val| pattern.keys[0] + ".ID == " + key + ".ID"}.join(' AND ')
|
|
|
|
+
|
|
|
|
+ searchstring = searchstring + " AND " + pattern.keys[0] + ".AssID == STATION.AssID"
|
|
|
|
+ searchstring = searchstring + " AND " + pattern.keys[0] + ".AssID == ValText.AssID"
|
|
|
|
+ searchstring = searchstring + " AND " + pattern.keys[0] + ".ID == STATION.ID"
|
|
|
|
+ searchstring = searchstring + " AND " + pattern.keys[0] + ".ID == ValText.ID"
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ searchstring = searchstring + " AND STATION.type == 'STATION'" + " AND STATION.value == '" + @p[1].value + "'"
|
|
|
|
+ searchstring = searchstring + " AND ValText.type == 'TEXT'" + " AND ValText.value == '" + @p[2].value + "'"
|
|
|
|
+
|
|
|
|
+ searchstring = searchstring + " AND " + pattern.map{ |key, val| key + ".type == '" + key + "' AND (" + key + ".value == '"+ val +"' or " + key + ".value == '*')"}.join(' AND ') + " ORDER BY ID ASC"
|
|
|
|
+
|
|
|
|
+ #puts searchstring;
|
|
|
|
+ else
|
|
|
|
+ searchstring = "SELECT * FROM "
|
|
|
|
+ searchstring = searchstring + "patternassignments STATION , patternassignments ValText"
|
|
|
|
+ searchstring = searchstring + " WHERE"
|
|
|
|
+ searchstring = searchstring + " STATION.type == 'STATION'" + " AND STATION.value == '" + @p[1].value + "'"
|
|
|
|
+ searchstring = searchstring + " AND ValText.type == 'TEXT'" + " AND ValText.value == '" + @p[2].value + "'"
|
|
|
|
+ searchstring = searchstring + " AND ValText.AssID == STATION.AssID"
|
|
|
|
+ searchstring = searchstring + " ORDER BY ID ASC"
|
|
|
|
+
|
|
|
|
|
|
- searchstring = searchstring + " AND " + pattern.map{ |key, val| key + ".type == '" + key + "' AND (" + key + ".value == '"+ val +"' or " + key + ".value == '*')"}.join(' AND ') + " ORDER BY ID ASC"
|
|
|
|
|
|
+ end
|
|
|
|
|
|
- #puts searchstring;
|
|
|
|
|
|
|
|
result = $db.execute searchstring;
|
|
result = $db.execute searchstring;
|
|
|
|
|
|
@@ -964,7 +988,7 @@ server = Riddl::Server.new(File.join(__dir__,'/was.xml'), :host => 'localhost')
|
|
#should add deleteReplacement
|
|
#should add deleteReplacement
|
|
end
|
|
end
|
|
on resource 'images' do
|
|
on resource 'images' do
|
|
- run GetImages if get
|
|
|
|
|
|
+ run GetImages, opts if get
|
|
#run CreateImage if post #'image'
|
|
#run CreateImage if post #'image'
|
|
run AddExternalImage if post 'externalImage'
|
|
run AddExternalImage if post 'externalImage'
|
|
run UploadImage if post
|
|
run UploadImage if post
|
|
@@ -974,7 +998,7 @@ server = Riddl::Server.new(File.join(__dir__,'/was.xml'), :host => 'localhost')
|
|
end
|
|
end
|
|
end
|
|
end
|
|
on resource '\d+' do
|
|
on resource '\d+' do
|
|
- run GetImage if get
|
|
|
|
|
|
+ run GetImage, opts if get
|
|
on resource do
|
|
on resource do
|
|
run UpdateImageLabel if put 'label'
|
|
run UpdateImageLabel if put 'label'
|
|
run GetRealImage if get
|
|
run GetRealImage if get
|
|
@@ -986,13 +1010,13 @@ server = Riddl::Server.new(File.join(__dir__,'/was.xml'), :host => 'localhost')
|
|
on resource 'search' do
|
|
on resource 'search' do
|
|
run ListSearch if get
|
|
run ListSearch if get
|
|
on resource 'imagesWIZ' do
|
|
on resource 'imagesWIZ' do
|
|
- run SearchImages if get
|
|
|
|
|
|
+ run SearchImages, opts if get
|
|
on resource '\d+' do
|
|
on resource '\d+' do
|
|
- run SearchImagesSingle if get
|
|
|
|
|
|
+ run SearchImagesSingle, opts if get
|
|
end
|
|
end
|
|
end
|
|
end
|
|
on resource 'errorsWIZ' do
|
|
on resource 'errorsWIZ' do
|
|
- run SearchErrors if get
|
|
|
|
|
|
+ run SearchErrors, opts if get
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
@@ -1000,7 +1024,7 @@ server = Riddl::Server.new(File.join(__dir__,'/was.xml'), :host => 'localhost')
|
|
run GetAssignments if get
|
|
run GetAssignments if get
|
|
run SaveNewAssignment if post 'list'
|
|
run SaveNewAssignment if post 'list'
|
|
on resource 'search' do
|
|
on resource 'search' do
|
|
- run ListAssignmentSearch if get
|
|
|
|
|
|
+ run ListAssignmentSearch, opts if get
|
|
end
|
|
end
|
|
on resource '\d+' do
|
|
on resource '\d+' do
|
|
run GetAssignment if get
|
|
run GetAssignment if get
|