First "full" DSL
- Search Type - Term - Vendor - Additional columns/sorting
This commit is contained in:
parent
cc703d5554
commit
d6a1c0afa1
9 changed files with 408 additions and 78 deletions
|
@ -15,17 +15,15 @@ fun hello(): String = "Hello from ${Platform.name}"
|
||||||
|
|
||||||
fun generateQueryUrl() = rcdbQuery {
|
fun generateQueryUrl() = rcdbQuery {
|
||||||
searchFor(SearchType.COASTER)
|
searchFor(SearchType.COASTER)
|
||||||
vendors(
|
searchTerm("Dragon")
|
||||||
Vendor.INTAMIN,
|
vendors {
|
||||||
Vendor.MACK
|
vekoma()
|
||||||
)
|
intamin()
|
||||||
sortBy(
|
mack()
|
||||||
Order.MANUFACTURER,
|
of(Vendor.PRESTON_AND_BARBIERI)
|
||||||
Order.INVERSIONS
|
}
|
||||||
)
|
sortBy {
|
||||||
custom(
|
manufacturer()
|
||||||
"foo",
|
inversion()
|
||||||
createRcdbParam(paramId = 12),
|
}
|
||||||
createRcdbParam(paramId = 24)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,48 @@ package de.pheerai.rcdbquery.dataMappings
|
||||||
enum class Order(
|
enum class Order(
|
||||||
override val prettyName: String,
|
override val prettyName: String,
|
||||||
override val fullName: String,
|
override val fullName: String,
|
||||||
override val paramId: Int
|
override val paramValue: Int
|
||||||
) : RcdbParamOption {
|
) : RcdbParamOption<Int> {
|
||||||
|
IMAGES("Images", "Amount of Images", 0),
|
||||||
|
NAME("Name", "Name of the Coaster", 1),
|
||||||
|
|
||||||
|
@Deprecated(
|
||||||
|
"The purpose of this parameter is yet unclear. You might want to use NAME instead",
|
||||||
|
level = DeprecationLevel.WARNING,
|
||||||
|
replaceWith = ReplaceWith("Order.NAME")
|
||||||
|
)
|
||||||
|
NAME_2("Name", "Name of the Coaster. Difference to NAME not clear", 2),
|
||||||
|
LOCATION("Location", 3),
|
||||||
|
PARK("Park", 4),
|
||||||
|
OPENED("Opened", "Opening Date", 8),
|
||||||
|
CLOSED("Closed", "Closing Date (past)", 9),
|
||||||
|
|
||||||
|
@Deprecated(
|
||||||
|
"This field seems to have been deprecated in favor of another parameter",
|
||||||
|
level = DeprecationLevel.WARNING,
|
||||||
|
replaceWith = ReplaceWith("Order.STATE")
|
||||||
|
)
|
||||||
|
STATE_2("State", "Operational State (legacy)", 10),
|
||||||
|
ENTERED("Entered", 12),
|
||||||
|
TYPE("Type", "Constrcution Type (Wood, Steel)", 13),
|
||||||
|
DESIGN("Design", "Train Design (Sit-Down, Invert,...)", 14),
|
||||||
|
CLASSIFICATION("Classification", "Coaster Classification (Coaster, Powered Coaster, Mountain Coaster)", 15),
|
||||||
|
LAYOUT("Layout", 16),
|
||||||
|
MODEL("Model", "Manufacturer Model", 17),
|
||||||
|
MODEL_LINE("Model-Line", "Coaster Model Line", 18),
|
||||||
|
SPEED("Speed", "Max. Speed", 19),
|
||||||
|
HEIGHT("Height", 20),
|
||||||
|
DROP("Drop", "Highest Drop", 21),
|
||||||
|
LENGTH("Length", 22),
|
||||||
|
ANGLE("Angle", 23),
|
||||||
|
INVERSIONS("Inversions", "Number of inversions", 24),
|
||||||
|
SERIAL_NO("Serial", "Serial number", 25),
|
||||||
|
SCALE("Scale", "Thrill factor", 26),
|
||||||
|
RIDE_TIME("Ride Time", 27),
|
||||||
|
STATE("State", "Operational state", 29),
|
||||||
MANUFACTURER("Manufacturer", 30),
|
MANUFACTURER("Manufacturer", 30),
|
||||||
INVERSIONS("Inversion", "Number of inversions", 24);
|
CLOSING("Closing", "(Future) closign date for temporary installations", 31)
|
||||||
|
;
|
||||||
|
|
||||||
constructor(name: String, paramId: Int) : this(name, name, paramId)
|
constructor(name: String, paramId: Int) : this(name, name, paramId)
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,7 @@
|
||||||
package de.pheerai.rcdbquery.dataMappings
|
package de.pheerai.rcdbquery.dataMappings
|
||||||
|
|
||||||
interface RcdbParamOption {
|
interface RcdbParamOption<out T> {
|
||||||
val prettyName: String
|
val prettyName: String
|
||||||
val fullName: String
|
val fullName: String
|
||||||
val paramId: Int
|
val paramValue: T
|
||||||
}
|
|
||||||
|
|
||||||
fun createRcdbParam(
|
|
||||||
prettyName: String = "",
|
|
||||||
fullName:String = "",
|
|
||||||
paramId: Int = -1
|
|
||||||
) : RcdbParamOption = object : RcdbParamOption {
|
|
||||||
override val prettyName: String
|
|
||||||
get() = prettyName
|
|
||||||
override val fullName: String
|
|
||||||
get() = fullName
|
|
||||||
override val paramId: Int
|
|
||||||
get() = paramId
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,2 @@
|
||||||
package de.pheerai.rcdbquery.dataMappings
|
package de.pheerai.rcdbquery.dataMappings
|
||||||
|
|
||||||
data class RcdbQueryParam<out T : RcdbParamOption>(val paramName: String, val paramOptions: List<T>)
|
|
||||||
data class RcdbQueryParamBuilder<T : RcdbParamOption>(var paramName: String, val paramOption: MutableList<T>) {
|
|
||||||
fun append(option: T) {
|
|
||||||
this.paramOption.add(option)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package de.pheerai.rcdbquery.dataMappings
|
||||||
|
|
||||||
|
class SearchTerm(override val paramValue: String): RcdbParamOption<String> {
|
||||||
|
override val prettyName = "Search Term"
|
||||||
|
override val fullName = "Search for elements whose name contain this term"
|
||||||
|
companion object {
|
||||||
|
const val staticParamName = "nc"
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,9 +3,12 @@ package de.pheerai.rcdbquery.dataMappings
|
||||||
enum class SearchType(
|
enum class SearchType(
|
||||||
override val prettyName: String,
|
override val prettyName: String,
|
||||||
override val fullName: String,
|
override val fullName: String,
|
||||||
override val paramId: Int
|
override val paramValue: Int
|
||||||
) : RcdbParamOption {
|
) : RcdbParamOption<Int> {
|
||||||
COASTER("Coaster", "Search for Roller Coaster", 2)
|
COASTER("Coaster", "Search for Roller Coaster", 2),
|
||||||
|
AMUSEMENT_PARK("Amusement Parks", "Searh for an amusement park", 3),
|
||||||
|
COMPANY("Company", "Search for company (manufacturer, engineering,...)", 12),
|
||||||
|
PERSON("Person", "Search for a person (designer, engineer,...)", 13)
|
||||||
;
|
;
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
@ -3,8 +3,229 @@ package de.pheerai.rcdbquery.dataMappings
|
||||||
enum class Vendor(
|
enum class Vendor(
|
||||||
override val prettyName: String,
|
override val prettyName: String,
|
||||||
override val fullName: String,
|
override val fullName: String,
|
||||||
override val paramId: Int
|
override val paramValue: Int
|
||||||
) : RcdbParamOption {
|
) : RcdbParamOption<Int> {
|
||||||
|
YAQIAO_MACHINE("Yaqiao", "Yaqiao Machine", 6471),
|
||||||
|
CREDIBLE("Credible", 6584),
|
||||||
|
ARROW("Arrow", "Arrow Dynamics", 6835),
|
||||||
|
PHILADELPHIA_TOBOGGAN_COASTERS("Philadelphia Toboggan Coasters", "Philadelphia Toboggan Coasters, Inc.", 6841),
|
||||||
|
DINN("Dinn", "Dinn Corporation", 6842),
|
||||||
|
SCHWARZKOPF("Schwarzkopf", 6844),
|
||||||
|
INTERNATIONAL_AMUSEMENT_DEVICES("International Amusement Devices", "International Amusement Devices, Inc.", 6846),
|
||||||
|
MORGAN("Morgan", 6847),
|
||||||
|
PREMIER("Premier", "Premier Rides", 6848),
|
||||||
|
TOGO("Togo", 6849),
|
||||||
|
E_AND_F_MILER("E&F Miler", "E&F Miler Industries", 6858),
|
||||||
|
INTERNATIONAL_COASTERS("International Coasters", "International Coasters, Inc.", 6859),
|
||||||
|
PINFARI("Pinfari", 6862),
|
||||||
|
RAUERHORST("Rauerhorst", "Rauerhorst Corporation", 6864),
|
||||||
|
NATIONAL_AMUSEMENT_DEVICE_COMPANY("National Amusement Device Company", 6867),
|
||||||
|
CCI("CCI", "Custom Coasters International, Inc.", 6868),
|
||||||
|
OVERLAND_AMUSEMENTS("Overland Amusements", 6870),
|
||||||
|
MOLINA_AND_SONS("Molina & Son's", 6871),
|
||||||
|
ALLAN_HERSCHELL("Allan Herschell Company", 6872),
|
||||||
|
SDC("S.D.C.", 6873),
|
||||||
|
HENSEL_PHELPS("Hensel Phelps","Hensel Phelps Construction Co.", 6879),
|
||||||
|
HOPKINS("Hopkins", 6881),
|
||||||
|
CHANCE("Chance", "Chance Rides", 6887),
|
||||||
|
BRADLEY_AND_KAYE("Bradley and Kaye", 6894),
|
||||||
|
SARTORI("Sartori", "Sartori Rides", 6895),
|
||||||
|
MICHAEL_BLACK("Michael Black Assoc.","Michael Black and Associates", 6898),
|
||||||
|
REVERCHON("Reverchon", 6902),
|
||||||
|
TOP_FUN("Top Fun", 6903),
|
||||||
|
WISDOM("WISDOM", "Wisdom Rides", 6904),
|
||||||
|
L_AND_T("L&T", "L&T Systems", 6906),
|
||||||
|
COASTER_WORKS("Coaster Works", "Coaster Works, Inc.", 6907),
|
||||||
|
GIOVANOLA("Giovanola", 6908),
|
||||||
|
B_A_SCHIFF("B. A. Schiff Assoc.","B. A. Schiff & Associates", 6914),
|
||||||
|
RCCA("RCCA", "Roller Coaster Corporation of America", 6918),
|
||||||
|
CARIPRO("Caripro", 6919),
|
||||||
|
SETPOINT("Setpoint", 6920),
|
||||||
|
SANSEI_YUSOKI("Sansei Yusoki", "Sansei Yusoki Co., Ltd.", 6923),
|
||||||
|
S_AND_S_SANSEI("S&S Sansei", "S&S Sansei Technologies", 6930),
|
||||||
|
BIG_COUNTRY_MOTIONEERING("Big Country Motioneering", 6938),
|
||||||
|
SOQUET("Soquet", 6940),
|
||||||
|
CAVAZZA_DIEGO("Cavazza Diego", 6942),
|
||||||
|
SUPERCAR("Supercar", 6944),
|
||||||
|
S_AND_MC("S&MC", 6947),
|
||||||
|
FAB("FAB", 6949),
|
||||||
|
BHS("BHS", "Bayerische Berg-, Hütten- und Salzwerke AG", 6951),
|
||||||
|
FABBRI("Fabbri", 6953),
|
||||||
|
MEISHO("Meisho", "Meisho Amusement Machines", 6954),
|
||||||
|
SENYO_KOGYO("Senyo","Senyo Kogyo Co., Ltd.", 6957),
|
||||||
|
NIPPON("Nippon", 6958),
|
||||||
|
OKAMOTO("Okamoto", "Okamoto Co., Ltd.", 6970),
|
||||||
|
PAX("Pax", "Pax Company", 6971),
|
||||||
|
HOEI_SANGYO("Hoei Sangyo", "Hoei Sangyo Co., Ltd.", 6973),
|
||||||
|
THOMPSON("Thompson","L.A. Thompson Scenic Railway Company", 6975),
|
||||||
|
WGH_TRANSPORTATION("WGH Transportation", 6979),
|
||||||
|
HARTON("TM Harton", "TM Harton Company", 7000),
|
||||||
|
APPLE("Apple", 7030),
|
||||||
|
INTERPARK("Interpark", 7035),
|
||||||
|
DPV_RIDES("D.P.V. Rides", 7038),
|
||||||
|
TRES_EIXOS("Três Eixos", 7041),
|
||||||
|
PRESTON_AND_BARBIERI("Preston & Barbieri", 7042),
|
||||||
|
DAMBROZ("Dambroz", 7055),
|
||||||
|
INVERTED_TECHNOLOGIES("Inverted Technologies", 7058),
|
||||||
|
HINDUSTAN("Hindustan Amusement Machines", 7065),
|
||||||
|
FAJUME("Fajume", 7083),
|
||||||
|
MCKAY("McKay Construction", 7099),
|
||||||
|
MERIDIAN("Meridian", "Meridian Ltd.", 7111),
|
||||||
|
BARBISAN("Barbisan", 7119),
|
||||||
|
BEIJING_SHIBAOLAI("Beijing Shibaolai Amusement Equipment", 7125),
|
||||||
|
BARBIERI("Barbieri Rides", 7137),
|
||||||
|
SUNKID_HEEGE("Sunkid Heege", "Sunkid Heege GmbH", 7140),
|
||||||
|
US_AMUSEMENT_COMPANY("U.S. Amusement Company", 7143),
|
||||||
|
LYNN_WELCHER("Lynn Welcher Construction Co.", 7152),
|
||||||
|
MONDIAL("Mondial", 7154),
|
||||||
|
C_AND_S("C&S", 7164),
|
||||||
|
MILER("Miler", "Miler Manufacturing", 7170),
|
||||||
|
BAILEY_RIDES("Bailey Rides", "Bailey Rides, Inc.", 7198),
|
||||||
|
AMERICAN_CONSTRUCTION("American Construction Co.", 7209),
|
||||||
|
AERIAL_TRAMWAY_CONSTRUCTION("Aerial Tramway Construction Co.", 7213),
|
||||||
|
BELMONT_CONSTRUCTION("Belmont Construction Co.", 7215),
|
||||||
|
SPIRAL_WHEEL_OPERATING_CORPORATION("Spiral Wheel Operating Corporation", 7216),
|
||||||
|
SKYTRAK("Skytrak International", 7222),
|
||||||
|
SELECT_CONTRACTS("Select Contracts", 7230),
|
||||||
|
MASAGO("Masago Industrial", 7236),
|
||||||
|
WESTECH("Westech", 7241),
|
||||||
|
INTERLINK("Interlink", 7243),
|
||||||
|
CHICAGO_COASTER("Chicago Coaster Co", 7249),
|
||||||
|
LUCREZIA_DI_CARTOCETO("Lucrezia Di Cartoceto", 7260),
|
||||||
|
BLACKPOOL_LEISURE("Blackpool Leisure Amusement Consultancy", 7268),
|
||||||
|
CINCINNATI_AMUSEMENT("Cincinnati Amusement Co.", 7290),
|
||||||
|
IE_PARK("I.E. Park", 7296),
|
||||||
|
PRINCETON_MACHINE("Princeton Machine", 7322),
|
||||||
|
POONAN_AMUSEMENT_RIDES("Poonan Amusement Rides Industries", 7330),
|
||||||
|
BREINIG_CONSTRUCTION("Breinig Construction Company", 7334),
|
||||||
|
FEDERAL_ENGINEERING("Federal Engineering Co.", 7341),
|
||||||
|
R_AND_C_ENTERTAINMENT("R&C Entertainment", 7349),
|
||||||
|
SPILLMAN_ENGINEERING("Spillman Engineering", 7354),
|
||||||
|
TRAVER_ENGINEERING("Traver Engineering Company", 7360),
|
||||||
|
MUNDIAL("Mundial", "Mundial Park, s.r.l.", 7379),
|
||||||
|
CARLL_AND_RAMAGOSA("Carll & Ramagosa", 7382),
|
||||||
|
MARTIN_AND_VLEMINCKX("Martin & Vleminckx", 7390),
|
||||||
|
CAM_BABY_KART("CAM Baby Kart", 7400),
|
||||||
|
EOS("EOS", 7418),
|
||||||
|
ACA("ACA", 7446),
|
||||||
|
IKEDA("Ikeda","Ikeda Works", 7447),
|
||||||
|
BUTLIN("Butlin", 7452),
|
||||||
|
TAKAHASHI_KIKAI_SANGYO("Takahashi Kikai Sangyo", 7472),
|
||||||
|
DYNAMIC("Dynamic Attractions", 7489),
|
||||||
|
GOLDEN_HORSE("Golden Horse", 7492),
|
||||||
|
WIEGAND("Wiegand", "Josef Wiegand GmbH & Co. KG", 7514),
|
||||||
|
ASCOT("Ascot Design", 7530),
|
||||||
|
DAL_AMUSEMENT_RIDES("DAL Amusement Rides Company", 7536),
|
||||||
|
CHILDRESS_COASTER("Childress Coaster", 7550),
|
||||||
|
CORDES_HOLZBAU("Cordes Holzbau", 7563),
|
||||||
|
FRONTIER_CONSTRUCTION("Frontier Construction Company", 7566),
|
||||||
|
DEBRINQUEDO("DeBrinquedo", 7567),
|
||||||
|
ZHEJIANG_JUMA_AMUSEMENT_EQUIPMENT("Zhejiang Juma Amusement Equipment Co., Ltd.", 7573),
|
||||||
|
SAEKI("Saeki", 7582),
|
||||||
|
KUMBAK("KumbaK","""KumbaK "The Amusement Engineers"""", 7608),
|
||||||
|
PINTO_BROTHERS("Pinto Brothers", 7657),
|
||||||
|
CEDEAL("Cedeal Rides", 7688),
|
||||||
|
DOPPELMAYR("Doppelmayr", 7700),
|
||||||
|
TANIGUCHI_SEISAKUSHO("Taniguchi Seisakusho", 7711),
|
||||||
|
SAMECO("Sameco", 7718),
|
||||||
|
SUL_PARK("Sul Park", 7728),
|
||||||
|
SECOND_AVENUE_TRACTION("Second Avenue Traction Company", 7738),
|
||||||
|
GOSETTO("Gosetto", 7761),
|
||||||
|
LEVENT_LUNAPARK("Levent Lunapark", 7839),
|
||||||
|
VAFAEI("Vafaei Rides", 7953),
|
||||||
|
VOSTOK("Vostok", 7959),
|
||||||
|
PARKASH_AMUSEMENTS("Parkash Amusements", 7963),
|
||||||
|
HEBEI_ZHONGYE_METALLURGICAL_EQUIPMENT_MANUFACTURING("Hebei Zhongye Metallurgical Equipment Manufacturing Co., Ltd", 7980),
|
||||||
|
R_AND_R("R&R", 8006),
|
||||||
|
ABC("abc", "abc rides", 8026), // Not a test object
|
||||||
|
TECHNICAL_PARK("Technical Park", 8046),
|
||||||
|
ROBLES_BOUSO("Robles Bouso Atracciones", 8057),
|
||||||
|
SAFECO("Safeco", 8063),
|
||||||
|
OKOBOJI("Okoboji Coaster Company", 8066),
|
||||||
|
OUTDOOR_AMUSEMENT("Outdoor Amusement Enterprise", "Outdoor Amusement Enterprise, Inc.", 8069),
|
||||||
|
BARTLING("Bartling", 8617),
|
||||||
|
BEIJING_JIUHUA_AMUSEMENT_RIDES_MANUFACTURING("Beijing Jiuhua Amusement Rides Manufacturing Co., Ltd.", 8765),
|
||||||
|
QIN_LONG("Qin Long", 8769),
|
||||||
|
CHANG_LONG("Chang Long", 8770),
|
||||||
|
JINFENG("Jinfeng", 9061),
|
||||||
|
NANFANG_AMUSEMENT_RIDES("Nanfang Amusement Rides Co.", 9069),
|
||||||
|
GG("Gravity Group", "Gravitykraft Corporation", 9225),
|
||||||
|
JINXIN_CREDIT("Jinxin Credit", 9279),
|
||||||
|
GUANGDONG_ZHONGSHAN_KANGLE_ENTERTAINMENT("Guangdong Zhongshan Kangle Entertainment Co. Ltd", 9364),
|
||||||
|
CHENGDU_XINDU_XINAN_PLAYINGMENT("Chengdu Xindu Xin'an Playingment", 9374),
|
||||||
|
ANALOG("Analog", 9522),
|
||||||
|
SAU_CON("Sấu Con", 9606),
|
||||||
|
FUN_RIDES_TECH("Fun Rides Tech", 10162),
|
||||||
|
DOUBLE_GRIP_TUBULAR_STEEL_AMUSEMENT_DEVICES("Double Grip Tubular Steel Amusement Devices Ltd.", 10275),
|
||||||
|
NOVA_ATRACOES("Nova Atrações", 10288),
|
||||||
|
HOPKINS_AND_PEARCE("Hopkins & Pearce", 10575),
|
||||||
|
RAINBOW("Rainbow Rides", 10638),
|
||||||
|
JINGBEI_AMUSEMENT_EQUIPMENT("Jingbei Amusement Equipment Co., Ltd.", 10699),
|
||||||
|
RADAR_PLAY("Radar Play", 10854),
|
||||||
|
DIVERMAX_ENTRETENIMENTO("Divermax Entretenimento", 10865),
|
||||||
|
FUN_XIAN_MACHINERY_MANUFACTURING_RANGER("Fun Xian Machinery Manufacturing Ranger Company", 10888),
|
||||||
|
CHANGHONG_ENTERTAINMENT_MACHINERY("Changhong Entertainment Machinery Co., Ltd.", 10951),
|
||||||
|
BAODING_HENGRUI_YOULE_JUXIE("Baoding Hengrui Youle Juxie Co., Ltd", 10966),
|
||||||
|
ZHONGSHAN_PLAYGROUND_EQUIPMENT_ENGINEERING("Zhongshan Playground Equipment Engineering Co., Ltd.", 11014),
|
||||||
|
SHANGHAI_QINGPU("Shanghai Qingpu", 11015),
|
||||||
|
GARCIA_BRINQUEDOS("Garcia Brinquedos", 11258),
|
||||||
|
BOMBAY_AMUSEMENT_RIDE("Bombay Amusement Ride, Limited", 11358),
|
||||||
|
YUNHAI_YOUYI("Yunhai Youyi", 11971),
|
||||||
|
ART_ENGINEERING("ART", "ART Engineering GmbH", 12029),
|
||||||
|
ZHIPAO("Zhipao", 12208),
|
||||||
|
GUOHUI_MACHINERY("Guohui Machinery", 12215),
|
||||||
|
CEZARY_BOROWIAK("Cezary Borowiak", 12595),
|
||||||
|
BRANDAUER("Brandauer", 12645),
|
||||||
|
NEW_HORSE("New Horse", 12656),
|
||||||
|
GROS("Gros", 12908),
|
||||||
|
AQUATIC_DEVELOPMENT_GROUP("Aquatic Development Group", 12962),
|
||||||
|
WUHAN_FUTE_AMUSEMENT_RIDES("Wuhan Fute Amusement Rides", 13779),
|
||||||
|
PRETZEL_AMUSEMENT_RIDE("Pretzel Amusement Ride Company", 14023),
|
||||||
|
CETI("CETI", 14170),
|
||||||
|
SC_ITALY("S.C. Italy", 14376),
|
||||||
|
XIAN_BAOLIU_PLAYGROUND_EQUIPMENT("Xi'an Baoliu Playground Equipment Factory", 14386),
|
||||||
|
PETER_PETZ("Peter Petz", 14428),
|
||||||
|
BEIJING_NORTH_RONGDA_AMUSEMENT_EQUIPMENT("Beijing North Rongda Amusement Equipment Co.,Ltd", 14436),
|
||||||
|
MADHU_AMUSEMENTS_AND_LEISURE_CONCEPTS("Madhu Amusements & Leisure Concepts", 14688),
|
||||||
|
MASTER_PARK("Master Park", 14787),
|
||||||
|
TECHFUN("Techfun", 14793),
|
||||||
|
STEIN("Stein", 14802),
|
||||||
|
ERBSCHLOE_FUN("Erbschloe Fun Construct", 14848),
|
||||||
|
JAHN_CONSTRUCTION("Jahn Construction Co.", 14909),
|
||||||
|
ZHONGSHAN_JINBO_RECREATION_EQUIPMENT("Zhongshan Jinbo Recreation Equipment Co.", 14952),
|
||||||
|
GUVEN_LUNAPARK("Güven Lunapark", 14971),
|
||||||
|
MOUNTAIN_SYSTEMS("Mountain Systems GmbH", 14979),
|
||||||
|
STAHL_HACKSTEINER("Stahl-Hacksteiner-Metall GmbH", 15084),
|
||||||
|
ZHENGZHOU_LIMEIQI_AMUSEMENT_EQUIPMENT("Zhengzhou Limeiqi Amusement Equipment Co., Ltd", 15198),
|
||||||
|
A_BRINQUEDOS("A Brinquedos", 15358),
|
||||||
|
METAL_PARK("Metal Park", 15359),
|
||||||
|
BEIJING_CHEN_JINYING_AMUSEMENT_EQUIPMENT("Beijing Chen Jinying Amusement Equipment", 15597),
|
||||||
|
SKYLINE_ATTRACTIONS("Skyline Attractions", 15673),
|
||||||
|
SUN_SHIYOULE("Sun Shiyoule", 15728),
|
||||||
|
NITTO_FUN("Nitto Fun", 15918),
|
||||||
|
RIDE_ENGINEERS_SWITZERLAND("RES", "Ride Engineers Switzerland", 15977),
|
||||||
|
IRAN_PARK("Iran Park", 15986),
|
||||||
|
WILLIAMS_AMUSEMENT_DEVICE("Williams Amusement Device Company", 16153),
|
||||||
|
YAMASAKUTALAB("Yamasakutalab", 16385),
|
||||||
|
ZHENGZHOU_SHANGDIAN_MACHINERY_EQUIPMENT("Zhengzhou Shangdian Machinery Equipment Co., Ltd.", 16448),
|
||||||
|
HUATONG_TAIKE_AMUSEMENT_EQUIPMENT("Huatong Taike Amusement Equipment Co., Ltd.", 16455),
|
||||||
|
MECPOWER("Mecpower", 16555),
|
||||||
|
MODERN_AMUSEMENT("Modern Amusement Group", 16578),
|
||||||
|
EXTREME_ENGINEERING("Extreme Engineering", 16800),
|
||||||
|
MAXWELL_AND_SONS("Maxwell & Sons", 16877),
|
||||||
|
TECHNIKA_KULTURY("Technika Kultury LLC", 17015),
|
||||||
|
ZHONGSHAN_SUPERGAME_AMUSEMENT_MACHINE("Zhongshan Supergame Amusement Machine Co.,LTD", 17377),
|
||||||
|
ZHEJIANG_PENGMING_AMUSEMENT_EQUIPMENT("Zhejiang Pengming Amusement Equipment Co., Ltd.", 17388),
|
||||||
|
GOLDEN_KOALA_AMUSEMENT_EQUIPMENT("Golden Koala Amusement Equipment Co. Ltd.", 17477),
|
||||||
|
HEBEI_TIANHONG_AMUSEMENT_EQUIPMENT("Hebei Tianhong Amusement Equipment Company", 17513),
|
||||||
|
KING("King", 17528),
|
||||||
|
TAIZHOU_BAOLU_MACHINERY("Taizhou Baolu Machinery", 17900),
|
||||||
|
YEISK_PLANT_ATTRACTION("Yeisk Plant Attraction", 18040),
|
||||||
|
HEBEI_H_AND_S_AMUSEMENT_EQUIPMENT("Hebei H&S Amusement Equipment Co, LTD.", 18205),
|
||||||
|
GOLDEN_DRAGON_AMUSEMENT("Golden Dragon Amusement Group", 18224),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
INTAMIN("Intamin", "Intamin Amusement Rides", 6837),
|
INTAMIN("Intamin", "Intamin Amusement Rides", 6837),
|
||||||
VEKOMA("Vekoma", 6836),
|
VEKOMA("Vekoma", 6836),
|
||||||
MACK("Mack Rides", "Mack Rides GmbH & Co KG", 6856),
|
MACK("Mack Rides", "Mack Rides GmbH & Co KG", 6856),
|
||||||
|
|
|
@ -2,18 +2,19 @@ package de.pheerai.rcdbquery.dsl
|
||||||
|
|
||||||
import de.pheerai.rcdbquery.dataMappings.*
|
import de.pheerai.rcdbquery.dataMappings.*
|
||||||
|
|
||||||
inline class RcdbQueryParams(val params: Map<String, List<Int>>)
|
inline class RcdbQueryParams(val params: Map<String, List<String>>)
|
||||||
class RcdbQueryParamsBuilder {
|
class RcdbQueryParamsBuilder {
|
||||||
// TODO: Somewhat wrap away, then use param of one option.
|
// TODO: Make way for single-valued params as well
|
||||||
private val params: MutableMap<String, List<RcdbParamOption>> = mutableMapOf()
|
private val params: MutableMap<String, List<RcdbParamOption<Any>>> = mutableMapOf()
|
||||||
|
|
||||||
|
// TODO: Validate that search type is set
|
||||||
fun build() = RcdbQueryParams(
|
fun build() = RcdbQueryParams(
|
||||||
params
|
params
|
||||||
.filter { it.value.isNotEmpty() }
|
.filter { it.value.isNotEmpty() }
|
||||||
.mapValues { e -> e.value.map { o -> o.paramId } }
|
.mapValues { e -> e.value.map { o -> o.paramValue.toString() } }
|
||||||
)
|
)
|
||||||
|
|
||||||
operator fun set(paramName: String, options: List<RcdbParamOption>) {
|
operator fun set(paramName: String, options: List<RcdbParamOption<Any>>) {
|
||||||
when (paramName) {
|
when (paramName) {
|
||||||
"order" -> if (this.params.containsKey(paramName)) {
|
"order" -> if (this.params.containsKey(paramName)) {
|
||||||
this.params[paramName] = this.params[paramName].append(options)
|
this.params[paramName] = this.params[paramName].append(options)
|
||||||
|
@ -24,7 +25,12 @@ class RcdbQueryParamsBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun List<RcdbParamOption>?.append(options: List<RcdbParamOption>) = this?.toMutableList()?.also { it.addAll(options) } ?: options
|
operator fun get(paramName: String) = this.params[paramName]
|
||||||
|
|
||||||
|
private fun List<RcdbParamOption<Any>>?.append(options: List<RcdbParamOption<Any>>) =
|
||||||
|
this?.toMutableList()?.also { it.addAll(options) } ?: options
|
||||||
|
|
||||||
|
fun keys() = this.params.keys.toSet()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun rcdbQuery(body: RcdbQueryParamsBuilder.() -> RcdbQueryParamsBuilder) =
|
fun rcdbQuery(body: RcdbQueryParamsBuilder.() -> RcdbQueryParamsBuilder) =
|
||||||
|
@ -46,29 +52,103 @@ fun rcdbQueryParams(body: RcdbQueryParamsBuilder.() -> RcdbQueryParamsBuilder):
|
||||||
return builder.build()
|
return builder.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: Even better typing (usage of
|
// TODO: Find way to only have one generic parameter
|
||||||
* ```
|
sealed class RcdbParamOptionBuilder<out U : Any, T : RcdbParamOption<U>> {
|
||||||
* vendors {
|
private val paramList: MutableList<T> = mutableListOf()
|
||||||
* vekoma()
|
|
||||||
* intamin()
|
|
||||||
* of(Vendors.PRESTON_AND_BARBIERI)
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
* instead.
|
|
||||||
* Maybe use inline class for MutableList / List?
|
|
||||||
*/
|
|
||||||
fun RcdbQueryParamsBuilder.vendors(vendors: List<Vendor>) = apply { this[Vendor.staticParamName] = vendors }
|
|
||||||
|
|
||||||
fun RcdbQueryParamsBuilder.vendors(vararg vendors: Vendor) = this.vendors(vendors.asList())
|
open fun add(param: T): RcdbParamOptionBuilder<U, T> {
|
||||||
|
paramList.add(param)
|
||||||
fun RcdbQueryParamsBuilder.sortBy(orders: List<Order>) = apply {
|
return this
|
||||||
this[Order.staticParamName] =orders
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun RcdbQueryParamsBuilder.sortBy(vararg orders: Order) = this.sortBy(orders.asList())
|
fun build() = paramList.toList()
|
||||||
|
}
|
||||||
|
|
||||||
fun RcdbQueryParamsBuilder.searchFor(searchType: SearchType) =
|
//region Vendors
|
||||||
apply { this[SearchType.staticParamName] = listOf(searchType) }
|
class VendorBuilder : RcdbParamOptionBuilder<Int, Vendor>() {
|
||||||
|
override fun add(param: Vendor): VendorBuilder {
|
||||||
|
super.add(param)
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun RcdbQueryParamsBuilder.custom(paramName: String, values: List<RcdbParamOption>) = apply { this[paramName] = values }
|
fun RcdbQueryParamsBuilder.vendors(body: VendorBuilder.() -> VendorBuilder): RcdbQueryParamsBuilder {
|
||||||
fun RcdbQueryParamsBuilder.custom(paramName: String, vararg values: RcdbParamOption) = apply { this[paramName] = values.asList() }
|
val builder = VendorBuilder()
|
||||||
|
builder.body()
|
||||||
|
this[Vendor.staticParamName] = builder.build()
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun VendorBuilder.of(vendor: Vendor) = this.add(vendor)
|
||||||
|
fun VendorBuilder.vekoma() = this.add(Vendor.VEKOMA)
|
||||||
|
fun VendorBuilder.intamin() = this.add(Vendor.INTAMIN)
|
||||||
|
fun VendorBuilder.mack() = this.add(Vendor.MACK)
|
||||||
|
fun VendorBuilder.bandm() = this.add(Vendor.B_AND_M)
|
||||||
|
fun VendorBuilder.gerstlauer() = this.add(Vendor.GERSTLAUER)
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
//region Order
|
||||||
|
class OrderBuilder : RcdbParamOptionBuilder<Int, Order>() {
|
||||||
|
override fun add(param: Order): OrderBuilder {
|
||||||
|
super.add(param)
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun RcdbQueryParamsBuilder.sortBy(body: OrderBuilder.() -> OrderBuilder): RcdbQueryParamsBuilder {
|
||||||
|
val builder = OrderBuilder()
|
||||||
|
builder.body()
|
||||||
|
this[Order.staticParamName] = builder.build()
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun OrderBuilder.of(order: Order) = this.add(order)
|
||||||
|
fun OrderBuilder.manufacturer() = this.add(Order.MANUFACTURER)
|
||||||
|
fun OrderBuilder.inversion() = this.add(Order.INVERSIONS)
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
//region Search type
|
||||||
|
fun RcdbQueryParamsBuilder.searchFor(searchType: SearchType) {
|
||||||
|
if (SearchType.staticParamName !in this.keys()) {
|
||||||
|
this[SearchType.staticParamName] = listOf(searchType)
|
||||||
|
} else {
|
||||||
|
error(
|
||||||
|
"""Only one search type must ever be set
|
||||||
|
| Old type: ${this[SearchType.staticParamName]!![0].prettyName}
|
||||||
|
| New type: ${searchType.prettyName}""".trimMargin()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
//region Search Term
|
||||||
|
fun RcdbQueryParamsBuilder.searchTerm(term: String) {
|
||||||
|
if (SearchTerm.staticParamName !in this.keys()) {
|
||||||
|
this[SearchTerm.staticParamName] = listOf(SearchTerm(term))
|
||||||
|
} else {
|
||||||
|
error(
|
||||||
|
"""Only one search term must ever be set
|
||||||
|
| Old term: ${this[SearchTerm.staticParamName]!![0].paramValue}
|
||||||
|
| New term: $term""".trimMargin()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
//region Unknown fields
|
||||||
|
@Suppress("unused")
|
||||||
|
@Deprecated(
|
||||||
|
"The parameter for extra columns has not yet been discovered (if it even exists). Use multiple values in the `sortBy` param instead (first values take sorting precedence)",
|
||||||
|
ReplaceWith("sortBy"), DeprecationLevel.ERROR
|
||||||
|
)
|
||||||
|
fun RcdbQueryParamsBuilder.extraColumns(orders: List<Order>): Nothing =
|
||||||
|
error("The parameter for extra columns has not yet been discovered (if it even exists). Use multiple values in the `sortBy` param instead (first values take sorting precedence)")
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
|
@Deprecated(
|
||||||
|
"The parameter for extra columns has not yet been discovered (if it even exists). Use multiple values in the `sortBy` param instead (first values take sorting precedence)",
|
||||||
|
ReplaceWith("sortBy"), DeprecationLevel.ERROR
|
||||||
|
)
|
||||||
|
fun RcdbQueryParamsBuilder.extraColumns(vararg orders: Order): Nothing =
|
||||||
|
error("The parameter for extra columns has not yet been discovered (if it even exists). Use multiple values in the `sortBy` param instead (first values take sorting precedence)")
|
||||||
|
//endregion
|
||||||
|
|
|
@ -11,15 +11,15 @@ class RcdbQueryDslTest {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"https://www.rcdb.com/r.htm?mk=6836,6856,6905&order=24,30",
|
"https://www.rcdb.com/r.htm?mk=6836,6856,6905&order=24,30",
|
||||||
rcdbQuery {
|
rcdbQuery {
|
||||||
vendors(
|
vendors {
|
||||||
Vendor.VEKOMA,
|
vekoma()
|
||||||
Vendor.MACK,
|
mack()
|
||||||
Vendor.MAURER
|
of(Vendor.MAURER)
|
||||||
)
|
}
|
||||||
sortBy(
|
sortBy {
|
||||||
Order.INVERSIONS,
|
inversion()
|
||||||
Order.MANUFACTURER
|
manufacturer()
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue