Commit 33a730d5 authored by Ikram Haq's avatar Ikram Haq
Browse files

Fix _links attribute issue related to subscriptions notifications

parent 432129f0
Loading
Loading
Loading
Loading
+82 −56
Original line number Diff line number Diff line
@@ -2088,17 +2088,17 @@ components:
    LocationInfo:
      properties:
        accuracy:
          description: Horizontal accuracy / (semi-major) uncertainty of location provided in meters, as defined in ETSI TS 123 032 [14]. Present only if "shape" equals 4, 5 or 6
          description: Horizontal accuracy/(semi-major) uncertainty of location provided in meters, as defined in [14]. Present only if "shape" equals 4, 5 or 6.
          type: integer
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: UnsignedInt
        accuracyAltitude:
          description: Altitude accuracy / uncertainty of location provided in meters, as defined in ETSI TS 123 032 [14]. Present only if "shape" equals 3 or 4
          description: Altitude accuracy/uncertainty of location provided in meters, as defined in [14]. Present only if "shape" equals 3 or 4.
          type: integer
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: UnsignedInt
        accuracySemiMinor:
          description: Horizontal accuracy / (semi-major) uncertainty of location provided in meters, as defined in ETSI TS 123 032 [14]. Present only if "shape" equals 4, 5 or 6
          description: Horizontal accuracy/(semi-major) uncertainty of location provided in meters, as defined in [14]. Present only if "shape" equals 4, 5 or 6.
          type: integer
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: UnsignedInt
@@ -2109,24 +2109,24 @@ components:
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: Float
        confidence:
          description: Confidence by which the position of a target entity is known to be within the shape description, expressed as a percentage and defined in ETSI TS 123 032 [14]. Present only if "shape" equals 1, 4 or 6
          description: Confidence by which the position of a target entity is known to be within the shape description, expressed as a percentage and defined in [14]. Present only if "shape" equals 1, 4 or 6.
          type: integer
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: UnsignedInt
        includedAngle:
          description: Present only if "shape" equals 6
          description: Present only if "shape" equals 6.
          type: integer
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: UnsignedInt
        innerRadius:
          description: Present only if "shape" equals 6
          description: Present only if "shape" equals 6.
          type: integer
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: UnsignedInt
        latitude:
          description: "Location latitude, expressed in the range -90\xB0 to +90\xB0. Cardinality greater than one only if \"shape\" equals 7."
          items:
          format: float
          items:
            type: number
          minItems: 1
          type: array
@@ -2134,65 +2134,96 @@ components:
          x-etsi-mec-origin-type: Float
        longitude:
          description: "Location longitude, expressed in the range -180\xB0 to +180\xB0. Cardinality greater than one only if \"shape\" equals 7."
          items:
          format: float
          items:
            type: number
          minItems: 1
          type: array
          x-etsi-mec-cardinality: 1..N
          x-etsi-mec-origin-type: Float
        offsetAngle:
          description: Present only if "shape" equals 6
          description: Present only if "shape" equals 6.
          type: integer
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: UnsignedInt
        orientationMajorAxis:
          description: "Angle of orientation of the major axis, expressed in the range 0\xB0 to 180\xB0, as defined in ETSI TS 123 032 [14]. Present only if \"shape\" equals 4 or 6"
          description: "Angle of orientation of the major axis, expressed in the range 0\xB0 to 180\xB0, as defined in [14]. Present only if \"shape\" equals 4 or 6."
          type: integer
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: UnsignedInt
        shape:
          description: 'Shape information, as detailed in ETSI TS 123 032 [14], associated with the reported location coordinate: <p>1 = ELLIPSOID_ARC <p>2 = ELLIPSOID_POINT <p>3 = ELLIPSOID_POINT_ALTITUDE <p>4 = ELLIPSOID_POINT_ALTITUDE_UNCERT_ELLIPSOID <p>5 = ELLIPSOID_POINT_UNCERT_CIRCLE <p>6 = ELLIPSOID_POINT_UNCERT_ELLIPSE <p>7 = POLYGON'
          description: 'Shape information, as detailed in [14], associated with the reported location coordinate:
            1 = Ellipsoid_Arc
            2 = ellipsoid_Point
            3 = ellipsoid_Point_Altitude
            4 = ellipsoid_Point_Altitude_Uncert_Ellipsoid
            5 = ellipsoid_Point_Uncert_Circle
            6 = ellipsoid_Point_Uncert_Ellipse
            7 = polygon'
          enum:
            - 1
            - 2
            - 3
            - 4
            - 5
            - 6
            - 7
          type: integer
          x-etsi-mec-cardinality: '1'
          x-etsi-mec-origin-type: Enum_inlined
        timestamp:
          $ref: '#/components/schemas/TimeStamp'
        uncertaintyRadius:
          description: Present only if "shape" equals 6
          description: Present only if "shape" equals 6.
          type: integer
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: UnsignedInt
        velocity:
          description: "Structure with attributes relating to the target entity\u2019s velocity, as defined in ETSI TS 123 032 [14]."
          $ref: '#/components/schemas/Velocity'
      required:
      - latitude
      - longitude
      - shape
      type: object
      x-etsi-ref: 6.5.3

    Velocity:
      description: "Structure with attributes relating to the target entity\u2019s velocity, as defined in [14]."
      properties:
        bearing:
              description: "Bearing, expressed in the range 0\xB0 to 360\xB0, as defined in ETSI TS 123 032 [14]."
          description: "Bearing, expressed in the range 0\xB0 to 360\xB0, as defined in [14]."
          type: integer
          x-etsi-mec-cardinality: '1'
          x-etsi-mec-origin-type: UnsignedInt
        horizontalSpeed:
              description: Horizontal speed, expressed in km/h and defined in ETSI TS 123 032 [14].
          description: Horizontal speed, expressed in km/h and defined in [14].
          type: integer
          x-etsi-mec-cardinality: '1'
          x-etsi-mec-origin-type: UnsignedInt
        uncertainty:
              description: Horizontal uncertainty, as defined in ETSI TS 123 032 [14]. Present only if "velocityType" equals 3 or 4
          description: Horizontal uncertainty, as defined in [14]. Present only if "velocityType" equals 3 or 4.
          type: integer
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: UnsignedInt
        velocityType:
              description: 'Velocity information, as detailed in ETSI TS 123 032 [14], associated with the reported location coordinate: <p>1 = HORIZONTAL <p>2 = HORIZONTAL_VERTICAL <p>3 = HORIZONTAL_UNCERT <p>4 = HORIZONTAL_VERTICAL_UNCERT'
          description: 'Velocity information, as detailed in [14], associated with the reported location coordinate:
            1 = Horizontal
            2 = Horizontal_Vertical
            3 = Horizontal_Uncert
            4 = Horizontal_Vertical_Uncert'
          enum:
            - 1
            - 2
            - 3
            - 4
          type: integer
          x-etsi-mec-cardinality: '1'
          x-etsi-mec-origin-type: Enum_inlined
        verticalSpeed:
              description: Vertical speed, expressed in km/h and defined in ETSI TS 123 032 [14]. Present only if "velocityType" equals 2 or 4
          description: Vertical speed, expressed in km/h and defined in [14]. Present only if "velocityType" equals 2 or 4.
          type: integer
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: Int
        verticalUncertainty:
              description: Vertical uncertainty, as defined in ETSI TS 123 032 [14]. Present only if "velocityType" equals 4
          description: Vertical uncertainty, as defined in [14]. Present only if "velocityType" equals 4.
          type: integer
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: UnsignedInt
@@ -2203,12 +2234,7 @@ components:
      type: object
      x-etsi-mec-cardinality: 0..1
      x-etsi-mec-origin-type: Structure (inlined)
      required:
        - latitude
        - longitude
        - shape
      type: object
      x-etsi-ref: 6.5.3


    UserDistanceNotification:
      properties:
+21 −15
Original line number Diff line number Diff line
@@ -939,7 +939,9 @@ func sendDistanceNotification(subsId int, returnAddr map[string]*gisClient.Dista

		var distanceNotif UserDistanceNotification
		distanceNotif.DistanceEvent = distanceCheck.Subscription.Criteria
		distanceNotif.Links = distanceCheck.Subscription.Links
		distanceNotif.Links = &SubscriptionLinks{
			Subscription: distanceCheck.Subscription.Links.Self,
		}
		var userList UserList
		var userInfoList []UserInfo
		for terminalAddr, distanceInfo := range returnAddr {
@@ -954,7 +956,6 @@ func sendDistanceNotification(subsId int, returnAddr map[string]*gisClient.Dista
			seconds := time.Now().Unix()
			var timestamp TimeStamp
			timestamp.Seconds = int32(seconds)
			locationInfo.Timestamp = &timestamp
			userInfo.LocationInfo = &locationInfo
			userInfoList = append(userInfoList, userInfo)
		}
@@ -1045,7 +1046,9 @@ func checkNotificationAreaCircle(addressToCheck string) {
				subsIdStr := strconv.Itoa(subsId)
				var areaCircleNotif UserAreaNotification
				areaCircleNotif.UserLocationEvent = areaCircleCheck.Subscription.LocationEventCriteria
				areaCircleNotif.Links = areaCircleCheck.Subscription.Links
				areaCircleNotif.Links = &SubscriptionLinks{
					Subscription: areaCircleCheck.Subscription.Links.Self,
				}
				areaCircleNotif.Address = addr
				var locationInfo LocationInfo
				locationInfo.Latitude = nil
@@ -1056,7 +1059,6 @@ func checkNotificationAreaCircle(addressToCheck string) {
				seconds := time.Now().Unix()
				var timestamp TimeStamp
				timestamp.Seconds = int32(seconds)
				locationInfo.Timestamp = &timestamp
				areaCircleNotif.LocationInfo = &locationInfo
				areaCircleNotif.NotificationType = "UserAreaNotification"
				var inlineCircleSubscriptionNotification InlineUserAreaNotification
@@ -1174,11 +1176,12 @@ func sendNotification(subsId int, periodicCheck *PeriodicCheck1) {
	seconds := time.Now().Unix()
	var timestamp TimeStamp
	timestamp.Seconds = int32(seconds)
	locationInfo.Timestamp = &timestamp
	periodicNotif.LocationInfo = &locationInfo
	periodicNotif.IsFinalNotification = false
	periodicNotif.Links = periodicCheck.Subscription.Links
	periodicNotif.NotificationType = "userLocationPeriodicSubscription"
	periodicNotif.Links = &SubscriptionLinks{
		Subscription: periodicCheck.Subscription.Links.Self,
	}
	periodicNotif.NotificationType = "UserLocationPeriodicNotification"
	result := new(NotificationResult)
	*result = SUCCESS
	periodicNotif.Result = result
@@ -1363,9 +1366,9 @@ func checkNotificationRegisteredZoneStatus1(zoneId string, apId string, nbUsersI
					zoneStatusNotif.UserNumEvent = "UNDER_ZONE_LOWER_THD"
				}
				seconds := time.Now().Unix()
				zoneStatusNotif.Links = &Links{} // Initialize Links outside the loop
				zoneStatusNotif.Links = &SubscriptionLinks{} // Initialize Links outside the loop
				for _, value_ := range zoneStatusSubscriptionMapLink {
					zoneStatusNotif.Links.Self = &LinkType{
					zoneStatusNotif.Links.Subscription = &LinkType{
						Href: value_.Subscription.Links.Self.Href,
					}
				}
@@ -1411,9 +1414,9 @@ func checkNotificationRegisteredUsers(oldZoneId string, newZoneId string, oldApI
			}
			var zonal UserLocationEventNotification
			zonal.Address = userId
			zonal.Links = &Links{} // Initialize Links outside the loop
			zonal.Links = &SubscriptionLinks{} // Initialize Links outside the loop
			for _, value_ := range userSubscriptionMapLink {
				zonal.Links.Self = &LinkType{
				zonal.Links.Subscription = &LinkType{
					Href: value_.Subscription.Links.Self.Href,
				}
			}
@@ -1717,9 +1720,9 @@ func sendNotification_1(subsId int, zoneId string, userId string, eventType Loca
		subscription := convertJsonToZonalSubscription_1(jsonInfo)

		var zonal ZoneLocationEventNotification
		zonal.Links = &Links{} // Initialize Links outside the loop
		zonal.Links = &SubscriptionLinks{} // Initialize Links outside the loop
		for _, value_ := range zonalSubscriptionMapLink {
			zonal.Links.Self = &LinkType{
			zonal.Links.Subscription = &LinkType{
				Href: value_.Subscription.Links.Self.Href,
			}
		}
@@ -3015,6 +3018,11 @@ func handleUserLocationPeriodicSubscription(w http.ResponseWriter, requestBody m
			errHandlerProblemDetails(w, "Mandatory SubscriptionType parameter not present or invalid", http.StatusBadRequest)
			return
		}
		if periodicSub.PeriodicEventInfo == nil {
			log.Error("Mandatory periodicEventInfo parameter not present")
			errHandlerProblemDetails(w, "Mandatory periodicEventInfo parameter not present", http.StatusBadRequest)
			return
		}
		// Add your logic to register the periodic-based subscription
		newSubsId := nextPeriodicSubscriptionIdAvailable
		nextPeriodicSubscriptionIdAvailable += 2
@@ -3998,7 +4006,6 @@ func updateUserInfo(address string, zoneId string, accessPointId string, longitu
		userInfo.LocationInfo.Latitude = nil
		userInfo.LocationInfo.Latitude = append(userInfo.LocationInfo.Latitude, *latitude)

		userInfo.LocationInfo.Timestamp = &timeStamp
	}

	// Update User info in DB & Send notifications
@@ -4088,7 +4095,6 @@ func updateAccessPointInfo(zoneId string, apId string, conTypeStr string, opStat
		var timeStamp TimeStamp
		timeStamp.Seconds = int32(seconds)

		apInfo.LocationInfo.Timestamp = &timeStamp
	}

	// Update AP info in DB & Send notifications
+11 −13
Original line number Diff line number Diff line
@@ -10,34 +10,32 @@
package server

type LocationInfo struct {
	// Horizontal accuracy / (semi-major) uncertainty of location provided in meters, as defined in ETSI TS 123 032 [14]. Present only if \"shape\" equals 4, 5 or 6
	// Horizontal accuracy/(semi-major) uncertainty of location provided in meters, as defined in [14]. Present only if \"shape\" equals 4, 5 or 6.
	Accuracy int32 `json:"accuracy,omitempty"`
	// Altitude accuracy / uncertainty of location provided in meters, as defined in ETSI TS 123 032 [14]. Present only if \"shape\" equals 3 or 4
	// Altitude accuracy/uncertainty of location provided in meters, as defined in [14]. Present only if \"shape\" equals 3 or 4.
	AccuracyAltitude int32 `json:"accuracyAltitude,omitempty"`
	// Horizontal accuracy / (semi-major) uncertainty of location provided in meters, as defined in ETSI TS 123 032 [14]. Present only if \"shape\" equals 4, 5 or 6
	// Horizontal accuracy/(semi-major) uncertainty of location provided in meters, as defined in [14]. Present only if \"shape\" equals 4, 5 or 6.
	AccuracySemiMinor int32 `json:"accuracySemiMinor,omitempty"`
	// Location altitude relative to the WGS84 ellipsoid surface.
	Altitude float32 `json:"altitude,omitempty"`
	// Confidence by which the position of a target entity is known to be within the shape description, expressed as a percentage and defined in ETSI TS 123 032 [14]. Present only if \"shape\" equals 1, 4 or 6
	// Confidence by which the position of a target entity is known to be within the shape description, expressed as a percentage and defined in [14]. Present only if \"shape\" equals 1, 4 or 6.
	Confidence int32 `json:"confidence,omitempty"`
	// Present only if \"shape\" equals 6
	// Present only if \"shape\" equals 6.
	IncludedAngle int32 `json:"includedAngle,omitempty"`
	// Present only if \"shape\" equals 6
	// Present only if \"shape\" equals 6.
	InnerRadius int32 `json:"innerRadius,omitempty"`
	// Location latitude, expressed in the range -90° to +90°. Cardinality greater than one only if \"shape\" equals 7.
	Latitude []float32 `json:"latitude"`
	// Location longitude, expressed in the range -180° to +180°. Cardinality greater than one only if \"shape\" equals 7.
	Longitude []float32 `json:"longitude"`
	// Present only if \"shape\" equals 6
	// Present only if \"shape\" equals 6.
	OffsetAngle int32 `json:"offsetAngle,omitempty"`
	// Angle of orientation of the major axis, expressed in the range 0° to 180°, as defined in ETSI TS 123 032 [14]. Present only if \"shape\" equals 4 or 6
	// Angle of orientation of the major axis, expressed in the range 0° to 180°, as defined in [14]. Present only if \"shape\" equals 4 or 6.
	OrientationMajorAxis int32 `json:"orientationMajorAxis,omitempty"`
	// Shape information, as detailed in ETSI TS 123 032 [14], associated with the reported location coordinate: <p>1 = ELLIPSOID_ARC <p>2 = ELLIPSOID_POINT <p>3 = ELLIPSOID_POINT_ALTITUDE <p>4 = ELLIPSOID_POINT_ALTITUDE_UNCERT_ELLIPSOID <p>5 = ELLIPSOID_POINT_UNCERT_CIRCLE <p>6 = ELLIPSOID_POINT_UNCERT_ELLIPSE <p>7 = POLYGON
	// Shape information, as detailed in [14], associated with the reported location coordinate: 1 = Ellipsoid_Arc 2 = ellipsoid_Point 3 = ellipsoid_Point_Altitude 4 = ellipsoid_Point_Altitude_Uncert_Ellipsoid 5 = ellipsoid_Point_Uncert_Circle 6 = ellipsoid_Point_Uncert_Ellipse 7 = polygon
	Shape int32 `json:"shape"`

	Timestamp *TimeStamp `json:"timestamp,omitempty"`
	// Present only if \"shape\" equals 6
	// Present only if \"shape\" equals 6.
	UncertaintyRadius int32 `json:"uncertaintyRadius,omitempty"`

	Velocity *LocationInfoVelocity `json:"velocity,omitempty"`
	Velocity *Velocity `json:"velocity,omitempty"`
}
+14 −0
Original line number Diff line number Diff line
/*
 * AdvantEDGE Location API
 *
 * Location Service is AdvantEDGE's implementation of [ETSI MEC ISG MEC013 Location API](https://www.etsi.org/deliver/etsi_gs/MEC/001_099/013/03.01.01_60/gs_mec013v030101p.pdf) <p>The API is based on the Open Mobile Alliance's specification RESTful Network API for Zonal Presence <p>[Copyright (c) ETSI 2017](https://forge.etsi.org/etsi-forge-copyright-notice.txt) <p>**Micro-service**<br>[meep-loc-serv](https://github.com/InterDigitalInc/AdvantEDGE/tree/master/go-apps/meep-loc-serv) <p>**Type & Usage**<br>Edge Service used by edge applications that want to get information about Users (UE) and Zone locations <p>**Note**<br>AdvantEDGE supports all of Location API endpoints (see below).
 *
 * API version: 3.1.1
 * Contact: AdvantEDGE@InterDigital.com
 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
 */
package server

type SubscriptionLinks struct {
	Subscription *LinkType `json:"subscription"`
}
+3 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@
package server

type UserAreaNotification struct {
	Links *Links `json:"_links"`

	// Address of user (e.g. ‘sip’ URI, ‘tel’ URI, ‘acr’ URI).
	Address string `json:"address"`

@@ -25,4 +25,6 @@ type UserAreaNotification struct {
	TimeStamp *TimeStamp `json:"timeStamp,omitempty"`

	UserLocationEvent []LocationEventType `json:"userLocationEvent"`

	Links *SubscriptionLinks `json:"_links,omitempty"`
}
Loading