Interface Metadata
- All Known Implementing Classes:
AbstractMetadata
,DummyMetadata
,MetadataDummy
,MetadataFile
,MetadataOdoo
@ProviderType
public interface Metadata
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final class
Defines Events a Metadata can throw. -
Method Summary
Modifier and TypeMethodDescriptionstatic String
activeStateChannelsToString
(Map<ChannelAddress, EdgeConfig.Component.Channel> activeStateChannels) Helper method for creating a String of all active State-Channels by Level.void
addEdgeToUser
(User user, Edge edge) Assigns Edge to current user.default Edge
addEdgeToUser
(User user, String setupPassword) Assigns Edge with given setupPassword to the logged in user and returns it.authenticate
(String token) Authenticates the User by a Token.authenticate
(String username, String password) Authenticates the User by username and password.edge()
Handles operations with Edge.Gets all Offline-Edges.Get an Edge by its unique Edge-ID.getEdgeBySetupPassword
(String setupPassword) Get an Edge by Edge-SetupPassword.getEdgeIdForApikey
(String apikey) Gets the Edge-ID for an API-Key, i.e.getEdgeMetadataForUser
(User user, String edgeId) Gets the Role for a edge of the current user.default Edge
getEdgeOrError
(String edgeId) Get an Edge by its unique Edge-ID.org.osgi.service.event.EventAdmin
Returns an EventAdmin, used by Edge objects.getPageDevice
(User user, GetEdgesRequest.PaginationOptions paginationOptions) Gets a map of Edge-IDs with the role of the given user.getSerialNumberForEdge
(Edge edge) Get serial number for the givenEdge
.byte[]
getSetupProtocol
(User user, int setupProtocolId) Returns the Setup Protocol PDF for the given id.com.google.gson.JsonObject
getSetupProtocolData
(User user, String edgeId) Return the Setup Protocol data as a JsonObject.Gets the User for the given User-ID.getUserAlertingSettings
(String edgeId) Gets all the alerting settings for given edge id.getUserAlertingSettings
(String edgeId, String userId) Gets the alerting settings for given edge id and userId.getUserInformation
(User user) Gets information about the given userUser
.boolean
Was the Metadata service fully initialized?.void
Closes a session for a User.void
registerUser
(com.google.gson.JsonObject user, OpenemsOEM.Manufacturer oem) Register a user.void
setUserAlertingSettings
(User user, String edgeId, List<AlertingSetting> users) Sets the alerting settings for the given list of users.void
setUserInformation
(User user, com.google.gson.JsonObject jsonObject) Update the given userUser
with new informationJsonObject
.int
submitSetupProtocol
(User user, com.google.gson.JsonObject jsonObject) Submit the installation assistant protocol.void
updateUserLanguage
(User user, Language language) Update language from given user.
-
Method Details
-
isInitialized
boolean isInitialized()Was the Metadata service fully initialized?.The service might take some time in the beginning to establish a connection or to cache data from an external database.
- Returns:
- true if it is initialized
-
authenticate
Authenticates the User by username and password.- Parameters:
username
- the Usernamepassword
- the Password- Returns:
- the
User
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
authenticate
Authenticates the User by a Token.- Parameters:
token
- the Token- Returns:
- the
User
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
logout
Closes a session for a User.- Parameters:
user
- theUser
-
edge
EdgeHandler edge()Handles operations with Edge.To be completed. This should eventually replace Edge.
- Returns:
- an
EdgeHandler
-
getEdgeIdForApikey
Gets the Edge-ID for an API-Key, i.e. authenticates the API-Key.- Parameters:
apikey
- the API-Key- Returns:
- the Edge-ID or Empty
-
getEdge
Get an Edge by its unique Edge-ID.- Parameters:
edgeId
- the Edge-ID- Returns:
- the Edge as Optional
-
getEdgeOrError
Get an Edge by its unique Edge-ID. Throws an Exception if there is no Edge with this ID.- Parameters:
edgeId
- the Edge-ID- Returns:
- the Edge
- Throws:
OpenemsException
- on error
-
getEdgeBySetupPassword
Get an Edge by Edge-SetupPassword.- Parameters:
setupPassword
- to find Edge- Returns:
- Edge as a Optional
-
getUser
Gets the User for the given User-ID.- Parameters:
userId
- the User-ID- Returns:
- the
User
, or Empty
-
getAllOfflineEdges
Collection<Edge> getAllOfflineEdges()Gets all Offline-Edges.- Returns:
- collection of Edges.
-
addEdgeToUser
default Edge addEdgeToUser(User user, String setupPassword) throws OpenemsError.OpenemsNamedException Assigns Edge with given setupPassword to the logged in user and returns it.If the setupPassword is invalid, an OpenemsNamedException is thrown.
- Parameters:
user
- theUser
setupPassword
- the Setup-Password- Returns:
- the Edge for the given Setup-Password
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
addEdgeToUser
Assigns Edge to current user.If assignment fails, an OpenemsNamedException is thrown.
- Parameters:
user
- TheUser
edge
- TheEdge
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
activeStateChannelsToString
static String activeStateChannelsToString(Map<ChannelAddress, EdgeConfig.Component.Channel> activeStateChannels) Helper method for creating a String of all active State-Channels by Level.- Parameters:
activeStateChannels
- Map of ChannelAddress and EdgeConfig.Component.Channel; as returned by Edge.onSetSumState()- Returns:
- a string
-
getUserInformation
Gets information about the given userUser
.- Parameters:
user
-User
to read information- Returns:
Map
about the user- Throws:
OpenemsError.OpenemsNamedException
- on error
-
setUserInformation
void setUserInformation(User user, com.google.gson.JsonObject jsonObject) throws OpenemsError.OpenemsNamedException Update the given userUser
with new informationJsonObject
.- Parameters:
user
-User
to updatejsonObject
-JsonObject
information about the user- Throws:
OpenemsError.OpenemsNamedException
- on error
-
getSetupProtocol
Returns the Setup Protocol PDF for the given id.- Parameters:
user
-User
the current usersetupProtocolId
- the setup protocol id to search- Returns:
- the Setup Protocol PDF as a byte array
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
getSetupProtocolData
com.google.gson.JsonObject getSetupProtocolData(User user, String edgeId) throws OpenemsError.OpenemsNamedException Return the Setup Protocol data as a JsonObject.- Parameters:
user
-User
the current useredgeId
- theEdge
ID to get the data- Returns:
- Setup Protocol as a JsonObject
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
submitSetupProtocol
int submitSetupProtocol(User user, com.google.gson.JsonObject jsonObject) throws OpenemsError.OpenemsNamedException Submit the installation assistant protocol.- Parameters:
user
-User
the current userjsonObject
-JsonObject
the setup protocol- Returns:
- id of created setup protocol
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
registerUser
void registerUser(com.google.gson.JsonObject user, OpenemsOEM.Manufacturer oem) throws OpenemsError.OpenemsNamedException Register a user.- Parameters:
user
-JsonObject
that represents an useroem
- OEM name- Throws:
OpenemsError.OpenemsNamedException
- on error
-
updateUserLanguage
Update language from given user.- Parameters:
user
-User
the current userlanguage
- to set language- Throws:
OpenemsError.OpenemsNamedException
- on error
-
getUserAlertingSettings
Gets all the alerting settings for given edge id.- Parameters:
edgeId
- the Edge ID- Returns:
- List of
AlertingSetting
- Throws:
OpenemsException
- on error
-
getUserAlertingSettings
Gets the alerting settings for given edge id and userId.- Parameters:
edgeId
- the Edge IDuserId
- the User ID- Returns:
- List of
UserRoleDelayTime
- Throws:
OpenemsException
- on error
-
setUserAlertingSettings
void setUserAlertingSettings(User user, String edgeId, List<AlertingSetting> users) throws OpenemsException Sets the alerting settings for the given list of users.- Parameters:
user
-User
the current useredgeId
- the Edge-IDusers
- list of users to update- Throws:
OpenemsException
- on error
-
getEventAdmin
org.osgi.service.event.EventAdmin getEventAdmin()Returns an EventAdmin, used by Edge objects.- Returns:
EventAdmin
-
getSerialNumberForEdge
Get serial number for the givenEdge
. -
getPageDevice
List<GetEdgesResponse.EdgeMetadata> getPageDevice(User user, GetEdgesRequest.PaginationOptions paginationOptions) throws OpenemsError.OpenemsNamedException Gets a map of Edge-IDs with the role of the given user.- Parameters:
user
-User
the current userpaginationOptions
- the options of the requesting page- Returns:
- the role to the Edge-IDs
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
getEdgeMetadataForUser
GetEdgesResponse.EdgeMetadata getEdgeMetadataForUser(User user, String edgeId) throws OpenemsError.OpenemsNamedException Gets the Role for a edge of the current user.- Parameters:
user
-User
the current useredgeId
- the Edge-ID- Returns:
- the role to the edge
- Throws:
OpenemsError.OpenemsNamedException
- on error
-