github.com/CiscoM31/godata@v1.0.10/metadata_model.go (about) 1 package godata 2 3 import ( 4 "encoding/xml" 5 ) 6 7 const ( 8 GoDataString = "Edm.String" 9 GoDataInt16 = "Edm.Int16" 10 GoDataInt32 = "Edm.Int32" 11 GoDataInt64 = "Edm.Int64" 12 GoDataDecimal = "Edm.Decimal" 13 GoDataBinary = "Edm.Binary" 14 GoDataBoolean = "Edm.Boolean" 15 GoDataTimeOfDay = "Edm.TimeOfDay" 16 GoDataDate = "Edm.Date" 17 GoDataDateTimeOffset = "Edm.DateTimeOffset" 18 ) 19 20 type GoDataMetadata struct { 21 XMLName xml.Name `xml:"edmx:Edmx"` 22 XMLNamespace string `xml:"xmlns:edmx,attr"` 23 Version string `xml:"Version,attr"` 24 DataServices *GoDataServices 25 References []*GoDataReference 26 } 27 28 func (t *GoDataMetadata) Bytes() ([]byte, error) { 29 output, err := xml.MarshalIndent(t, "", " ") 30 if err != nil { 31 return nil, err 32 } 33 34 return append([]byte(xml.Header), output...), nil 35 } 36 37 func (t *GoDataMetadata) String() string { 38 return "" 39 } 40 41 type GoDataReference struct { 42 XMLName xml.Name `xml:"edmx:Reference"` 43 Uri string `xml:"Uri,attr"` 44 Includes []*GoDataInclude 45 IncludeAnnotations []*GoDataIncludeAnnotations 46 } 47 48 type GoDataInclude struct { 49 XMLName xml.Name `xml:"edmx:Include"` 50 Namespace string `xml:"Namespace,attr"` 51 Alias string `xml:"Alias,attr,omitempty"` 52 } 53 54 type GoDataIncludeAnnotations struct { 55 XMLName xml.Name `xml:"edmx:IncludeAnnotations"` 56 TermNamespace string `xml:"TermNamespace,attr"` 57 Qualifier string `xml:"Qualifier,attr,omitempty"` 58 TargetNamespace string `xml:"TargetNamespace,attr,omitempty"` 59 } 60 61 type GoDataServices struct { 62 XMLName xml.Name `xml:"edmx:DataServices"` 63 Schemas []*GoDataSchema 64 } 65 66 type GoDataSchema struct { 67 XMLName xml.Name `xml:"Schema"` 68 Namespace string `xml:"Namespace,attr"` 69 Alias string `xml:"Alias,attr,omitempty"` 70 Actions []*GoDataAction 71 Annotations []*GoDataAnnotations 72 Annotation []*GoDataAnnotation 73 ComplexTypes []*GoDataComplexType 74 EntityContainers []*GoDataEntityContainer 75 EntityTypes []*GoDataEntityType 76 EnumTypes []*GoDataEnumType 77 Functions []*GoDataFunction 78 Terms []*GoDataTerm 79 TypeDefinitions []*GoDataTypeDefinition 80 } 81 82 type GoDataAction struct { 83 XMLName xml.Name `xml:"Action"` 84 Name string `xml:"Name,attr"` 85 IsBound string `xml:"IsBound,attr,omitempty"` 86 EntitySetPath string `xml:"EntitySetPath,attr,omitempty"` 87 Parameters []*GoDataParameter 88 ReturnType *GoDataReturnType 89 } 90 91 type GoDataAnnotations struct { 92 XMLName xml.Name `xml:"Annotations"` 93 Target string `xml:"Target,attr"` 94 Qualifier string `xml:"Qualifier,attr,omitempty"` 95 Annotations []*GoDataAnnotation 96 } 97 98 type GoDataAnnotation struct { 99 XMLName xml.Name `xml:"Annotation"` 100 Term string `xml:"Term,attr"` 101 Qualifier string `xml:"Qualifier,attr,omitempty"` 102 } 103 104 type GoDataComplexType struct { 105 XMLName xml.Name `xml:"ComplexType"` 106 Name string `xml:"Name,attr"` 107 BaseType string `xml:"BaseType,attr,omitempty"` 108 Abstract string `xml:"Abstract,attr,omitempty"` 109 OpenType string `xml:"OpenType,attr,omitempty"` 110 Properties []*GoDataProperty 111 NavigationProperties []*GoDataNavigationProperty 112 } 113 114 type GoDataEntityContainer struct { 115 XMLName xml.Name `xml:"EntityContainer"` 116 Name string `xml:"Name,attr"` 117 Extends string `xml:"Extends,attr,omitempty"` 118 EntitySets []*GoDataEntitySet 119 Singletons []*GoDataSingleton 120 ActionImports []*GoDataActionImport 121 FunctionImports []*GoDataFunctionImport 122 } 123 124 type GoDataEntityType struct { 125 XMLName xml.Name `xml:"EntityType"` 126 Name string `xml:"Name,attr"` 127 BaseType string `xml:"BaseType,attr,omitempty"` 128 Abstract string `xml:"Abstract,attr,omitempty"` 129 OpenType string `xml:"OpenType,attr,omitempty"` 130 HasStream string `xml:"HasStream,attr,omitempty"` 131 Key *GoDataKey 132 Properties []*GoDataProperty 133 NavigationProperties []*GoDataNavigationProperty 134 } 135 136 type GoDataEnumType struct { 137 XMLName xml.Name `xml:"EnumType"` 138 Name string `xml:"Name,attr"` 139 UnderlyingType string `xml:"UnderlyingType,attr,omitempty"` 140 IsFlags string `xml:"IsFlags,attr,omitempty"` 141 Members []*GoDataMember 142 } 143 144 type GoDataFunction struct { 145 XMLName xml.Name `xml:"Function"` 146 Name string `xml:"Name,attr"` 147 IsBound string `xml:"IsBound,attr,omitempty"` 148 IsComposable string `xml:"IsComposable,attr,omitempty"` 149 EntitySetPath string `xml:"EntitySetPath,attr,omitempty"` 150 Parameters []*GoDataParameter 151 ReturnType *GoDataReturnType 152 } 153 154 type GoDataTypeDefinition struct { 155 XMLName xml.Name `xml:"TypeDefinition"` 156 Name string `xml:"Name,attr"` 157 UnderlyingType string `xml:"UnderlyingTypeattr,omitempty"` 158 Annotations []*GoDataAnnotation 159 } 160 161 type GoDataProperty struct { 162 XMLName xml.Name `xml:"Property"` 163 Name string `xml:"Name,attr"` 164 Type string `xml:"Type,attr"` 165 Nullable string `xml:"Nullable,attr,omitempty"` 166 MaxLength int `xml:"MaxLength,attr,omitempty"` 167 Precision int `xml:"Precision,attr,omitempty"` 168 Scale int `xml:"Scale,attr,omitempty"` 169 Unicode string `xml:"Unicode,attr,omitempty"` 170 SRID string `xml:"SRID,attr,omitempty"` 171 DefaultValue string `xml:"DefaultValue,attr,omitempty"` 172 } 173 174 type GoDataNavigationProperty struct { 175 XMLName xml.Name `xml:"NavigationProperty"` 176 Name string `xml:"Name,attr"` 177 Type string `xml:"Type,attr"` 178 Nullable string `xml:"Nullable,attr,omitempty"` 179 Partner string `xml:"Partner,attr,omitempty"` 180 ContainsTarget string `xml:"ContainsTarget,attr,omitempty"` 181 ReferentialConstraints []*GoDataReferentialConstraint 182 } 183 184 type GoDataReferentialConstraint struct { 185 XMLName xml.Name `xml:"ReferentialConstraint"` 186 Property string `xml:"Property,attr"` 187 ReferencedProperty string `xml:"ReferencedProperty,attr"` 188 OnDelete *GoDataOnDelete `xml:"OnDelete,omitempty"` 189 } 190 191 type GoDataOnDelete struct { 192 XMLName xml.Name `xml:"OnDelete"` 193 Action string `xml:"Action,attr"` 194 } 195 196 type GoDataEntitySet struct { 197 XMLName xml.Name `xml:"EntitySet"` 198 Name string `xml:"Name,attr"` 199 EntityType string `xml:"EntityType,attr"` 200 IncludeInServiceDocument string `xml:"IncludeInServiceDocument,attr,omitempty"` 201 NavigationPropertyBindings []*GoDataNavigationPropertyBinding 202 } 203 204 type GoDataSingleton struct { 205 XMLName xml.Name `xml:"Singleton"` 206 Name string `xml:"Name,attr"` 207 Type string `xml:"Type,attr"` 208 NavigationPropertyBindings []*GoDataNavigationPropertyBinding 209 } 210 211 type GoDataNavigationPropertyBinding struct { 212 XMLName xml.Name `xml:"NavigationPropertyBinding"` 213 Path string `xml:"Path,attr"` 214 Target string `xml:"Target,attr"` 215 } 216 217 type GoDataActionImport struct { 218 XMLName xml.Name `xml:"ActionImport"` 219 Name string `xml:"Name,attr"` 220 Action string `xml:"Action,attr"` 221 EntitySet string `xml:"EntitySet,attr,omitempty"` 222 } 223 224 type GoDataFunctionImport struct { 225 XMLName xml.Name `xml:"FunctionImport"` 226 Name string `xml:"Name,attr"` 227 Function string `xml:"Function,attr"` 228 EntitySet string `xml:"EntitySet,attr,omitempty"` 229 IncludeInServiceDocument string `xml:"IncludeInServiceDocument,attr,omitempty"` 230 } 231 232 type GoDataKey struct { 233 XMLName xml.Name `xml:"Key"` 234 PropertyRef *GoDataPropertyRef 235 } 236 237 type GoDataPropertyRef struct { 238 XMLName xml.Name `xml:"PropertyRef"` 239 Name string `xml:"Name,attr"` 240 } 241 242 type GoDataParameter struct { 243 XMLName xml.Name `xml:"Parameter"` 244 Name string `xml:"Name,attr"` 245 Type string `xml:"Type,attr"` 246 Nullable string `xml:"Nullable,attr,omitempty"` 247 MaxLength int `xml:"MaxLength,attr,omitempty"` 248 Precision int `xml:"Precision,attr,omitempty"` 249 Scale int `xml:"Scale,attr,omitempty"` 250 SRID string `xml:"SRID,attr,omitempty"` 251 } 252 253 type GoDataReturnType struct { 254 XMLName xml.Name `xml:"ReturnType"` 255 Name string `xml:"Name,attr"` 256 Type string `xml:"Type,attr"` 257 Nullable string `xml:"Nullable,attr,omitempty"` 258 MaxLength int `xml:"MaxLength,attr,omitempty"` 259 Precision int `xml:"Precision,attr,omitempty"` 260 Scale int `xml:"Scale,attr,omitempty"` 261 SRID string `xml:"SRID,attr,omitempty"` 262 } 263 264 type GoDataMember struct { 265 XMLName xml.Name `xml:"Member"` 266 Name string `xml:"Name,attr"` 267 Value string `xml:"Value,attr,omitempty"` 268 } 269 270 type GoDataTerm struct { 271 XMLName xml.Name `xml:"Term"` 272 Name string `xml:"Name,attr"` 273 Type string `xml:"Type,attr"` 274 BaseTerm string `xml:"BaseTerm,attr,omitempty"` 275 DefaultValue string `xml:"DefaultValue,attr,omitempty"` 276 AppliesTo string `xml:"AppliesTo,attr,omitempty"` 277 }