expressions.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package expressions
  15. type PrimitveType string
  16. const (
  17. Bool PrimitveType = "Bool"
  18. DateTime PrimitveType = "DateTime"
  19. Double PrimitveType = "Double"
  20. String PrimitveType = "String"
  21. Null PrimitveType = "NULL"
  22. )
  23. /*type ConstExp struct {
  24. Bool bool
  25. DateTime DateTime
  26. Double Double
  27. }*/
  28. type ConstExp interface{}
  29. type PropertyExp struct {
  30. Property string `json:"property"`
  31. Type PrimitveType `json:"type"`
  32. }
  33. type PrimitiveObject struct {
  34. PropertyExp
  35. ConstExp
  36. }
  37. type OperatorExp struct {
  38. Left *PropertyExp `json:"left"`
  39. Right *PrimitiveObject `json:"right"`
  40. }
  41. type LogicalExp struct {
  42. EQ *OperatorExp `json:"eq"`
  43. IN *OperatorExp `json:"in"`
  44. LT *OperatorExp `json:"lt"`
  45. GT *OperatorExp `json:"gt"`
  46. AND []*LogicalExp `json:"and"`
  47. OR []*LogicalExp `json:"or"`
  48. NOT *LogicalExp `json:"not"`
  49. }
  50. type ArithmeticExp struct {
  51. ADD *OperatorExp `json:"add"`
  52. SUB *OperatorExp `json:"sub"`
  53. }
  54. type FilterExp struct {
  55. LogicalExp
  56. }
  57. type AlignerExp struct {
  58. Input *PropertyExp `json:"input"`
  59. }
  60. type MeasureExp struct {
  61. Mean *AlignerExp `json:"mean"`
  62. Min *AlignerExp `json:"min"`
  63. }
  64. type AggregateExp struct {
  65. MeasureExps []MeasureExp
  66. }