Skip to content

Release V2.10.2 #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
"filename": "driver/web/adapter.go",
"hashed_secret": "a7d09aaaf55864f7ce39a7715aabed433c3fe661",
"is_verified": false,
"line_number": 232
"line_number": 234
}
],
"driver/web/auth.go": [
Expand All @@ -172,5 +172,5 @@
}
]
},
"generated_at": "2024-03-28T07:54:12Z"
"generated_at": "2024-06-26T14:32:05Z"
}
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [2.10.2] - 2024-06-27
### Fixed
- Populate building number in wayfinding building end points [#100](https://github.com/rokwire/gateway-building-block/issues/100)

### Added
- wayfinding/floorplans end point

[2.10.1] - 2024-05-22
### Fixed
- Incorrect event end times [#97](https://github.com/rokwire/gateway-building-block/issues/97)
Expand Down
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
Patches for **Gateway Building Block** in this repository will only be applied to the following versions:
| Version | Supported |
| ------- | ------------------ |
| 2.10.1 | :white_check_mark: |
| < 2.10.1 | :x: |
| 2.10.2 | :white_check_mark: |
| < 2.10.2 | :x: |

## Reporting a Bug or Vulnerability

Expand Down
48 changes: 48 additions & 0 deletions core/apis_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ package core
import (
"application/core/model"
"application/driven/uiucadapters"
"strings"
"time"

"encoding/json"
"os"
Expand Down Expand Up @@ -99,13 +101,49 @@ func (a appClient) GetEntrance(bldgID string, adaOnly bool, latitude float64, lo
}

func (a appClient) GetBuildings() (*[]model.Building, error) {
retData, err := a.getCachedBuildings()
if err != nil {
return nil, err
}
return retData, nil
}

func (a appClient) getCachedBuildings() (*[]model.Building, error) {
conf, _ := a.app.GetEnvConfigs()
crntDate := time.Now()
diff := crntDate.Sub(a.app.CampusBuildings.LoadDate)
if diff.Hours() < 24 {
retData := a.app.CampusBuildings.Buildings
return &retData, nil
}

retData, err := a.LocationAdapter.GetBuildings(conf)
if err != nil {
return nil, err
}
//any time we call out to get the list of buildings, we need to cache the results
a.app.CampusBuildings.Buildings = *retData
a.app.CampusBuildings.LoadDate = time.Now()
return retData, nil
}

func (a appClient) SearchBuildings(bldgName string, returnCompact bool) (*map[string]any, error) {
allbuildings, err := a.getCachedBuildings()
if err != nil {
return nil, err
}
var retData = make(map[string]any)
for _, v := range *allbuildings {
if strings.Contains(strings.ToLower(v.Name), strings.ToLower(bldgName)) {
if returnCompact {
crntBldg := model.CompactBuilding{Name: v.Name, FullAddress: v.FullAddress, Latitude: v.Latitude, Longitude: v.Longitude, ImageURL: v.ImageURL, Number: v.Number}
retData[v.Name] = crntBldg
} else {
retData[v.Name] = v
}
}
}
return &retData, nil
}

func (a appClient) GetContactInfo(uin string, accessToken string, mode string) (*model.Person, int, error) {
Expand Down Expand Up @@ -161,6 +199,16 @@ func (a appClient) GetSuccessTeam(uin string, unitid string, accesstoken string)

}

func (a appClient) GetFloorPlan(buildingnumber string, floornumber string) (*model.FloorPlan, int, error) {
conf, _ := a.app.GetEnvConfigs()

retData, err := a.LocationAdapter.GetFloorPlan(buildingnumber, floornumber, conf)
if err != nil {
return nil, 500, err
}
return retData, 200, nil
}

func (a appClient) GetPrimaryCareProvider(uin string, accesstoken string) (*[]model.SuccessTeamMember, int, error) {
conf, _ := a.app.GetEnvConfigs()
retData, status, err := a.SuccessTeamAdapter.GetPrimaryCareProvider(uin, accesstoken, conf)
Expand Down
9 changes: 9 additions & 0 deletions core/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package core

import (
"application/core/model"
"time"

"github.com/rokwire/core-auth-library-go/v3/authutils"
"github.com/rokwire/logging-library-go/v2/errors"
Expand Down Expand Up @@ -48,6 +49,8 @@ type Application struct {
System System // expose to the drivers adapters
shared Shared

CampusBuildings model.CachedBuildings //caches a list of all campus building data

AppointmentAdapters map[string]Appointments //expose to the different vendor specific appointment adapters

logger *logs.Logger
Expand Down Expand Up @@ -110,5 +113,11 @@ func NewApplication(version string, build string,
application.shared = newAppShared(&application)
application.eventsLogic = newAppEventsLogic(&application, eventsBBAdapter, geoBBAdapter, *logger)

_, err := application.Client.GetBuildings()
if err != nil {
//set to one day ago to force a retry and refresh
application.CampusBuildings.LoadDate = time.Now().AddDate(0, 0, -1)
}

return &application
}
3 changes: 3 additions & 0 deletions core/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ type Client interface {
GetSuccessTeam(uin string, unitid string, accessToken string) (*model.SuccessTeam, int, error)
GetPrimaryCareProvider(uin string, accessToken string) (*[]model.SuccessTeamMember, int, error)
GetAcademicAdvisors(uin string, unitid string, accessToken string) (*[]model.SuccessTeamMember, int, error)
GetFloorPlan(buildingnumber string, floornumber string) (*model.FloorPlan, int, error)
SearchBuildings(bldgName string, returnCompact bool) (*map[string]any, error)
}

// Admin exposes administrative APIs for the driver adapters
Expand Down Expand Up @@ -184,6 +186,7 @@ type WayFinding interface {
GetEntrance(bldgID string, adaAccessibleOnly bool, latitude float64, longitude float64, conf *model.EnvConfigData) (*model.Entrance, error)
GetBuildings(conf *model.EnvConfigData) (*[]model.Building, error)
GetBuilding(bldgID string, adaAccessibleOnly bool, latitude float64, longitude float64, conf *model.EnvConfigData) (*model.Building, error)
GetFloorPlan(bldgNum string, floornumber string, conf *model.EnvConfigData) (*model.FloorPlan, error)
}

// Appointments represents the adapter needed to interace with various appoinment data providers
Expand Down
28 changes: 28 additions & 0 deletions core/model/buildings.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,32 @@ type Building struct {
Entrances []Entrance
Latitude float64
Longitude float64
Floors []string
Features []BuildingFeature
}

// CompactBuilding represents minimal building informaiton needed to display a builgins details on the details panel
type CompactBuilding struct {
ID string
Name string
Number string
FullAddress string
ImageURL string
Latitude float64
Longitude float64
}

// BuildingFeature represents a feature found in buildings
type BuildingFeature struct {
ID string `json:"_id" bson:"_id"`
BuildingID string `json:"building_id" bson:"building_id"`
EQIndicator string `json:"eq_indicator" bson:"eq_indicator"`
Name string `json:"name" bson:"name"`
FoundOnFloor string `json:"found_on_floor" bson:"found_on_floor"`
FoundInRoom string `json:"found_in_room" bson:"found_in_room"`
IsADA bool `json:"is_ada" bson:"is_ada"`
IsExternal bool `json:"is_external" bson:"is_external"`
Comments string `json:"comments" bson:"comments"`
Latitude float64 `json:"latitude" bson:"latitude"`
Longitude float64 `json:"longitude" bson:"longitude"`
}
32 changes: 32 additions & 0 deletions core/model/cachedbuildings.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2022 Board of Trustees of the University of Illinois.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package model

import (
"time"

"github.com/rokwire/logging-library-go/v2/logutils"
)

const (
//TypeCachedBuildings type
TypeCachedBuildings logutils.MessageDataType = "cached buildings"
)

// CachedBuildings holds the building information from the building adapter
type CachedBuildings struct {
Buildings []Building `json:"buildings" bson:"buildings"`
LoadDate time.Time `json:"load_date" bson:"load_date"`
}
54 changes: 54 additions & 0 deletions core/model/floorplans.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2020 Board of Trustees of the University of Illinois.
* All rights reserved.

* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

* http://www.apache.org/licenses/LICENSE-2.0

* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package model

import (
"github.com/rokwire/logging-library-go/v2/logutils"
)

const (
//TypeFloorPlan type
TypeFloorPlan logutils.MessageDataType = "bldg floor plan"
)

// FloorPlanMarker respresents a floor plan marker
type FloorPlanMarker struct {
RenderID string `json:"_id" bson:"_id"`
Label string `json:"label" bson:"label"`
Description string `json:"description" bson:"description"`
Display string `json:"display" bson:"display"`
Icon string `json:"icon" bson:"icon"`
}

// FloorPlanHighlite represents a floor plan highlight
type FloorPlanHighlite struct {
RenderID string `json:"_id" bson:"_id"`
Label string `json:"label" bson:"label"`
Color string `json:"color" bson:"color"`
Display string `json:"display" bson:"display"`
}

// FloorPlan represents a floor plan object
type FloorPlan struct {
BuildingNumber string `json:"building_number" bson:"building_number"`
BuildingFloor string `json:"building_floor" bson:"building_floor"`
SVGEncoding string `json:"svg_encoding" bson:"svg_encoding"`
SVG string `json:"svg" bson:"svg"`
Markers []FloorPlanMarker `json:"markers" bson:"markers"`
Highlites []FloorPlanHighlite `json:"highlites" bson:"highlites"`
}
Loading
Loading