Skip to content

Commit

Permalink
Merge pull request #125 from openbase/119-implement-low-battery-notif…
Browse files Browse the repository at this point in the history
…ication-system

119 implement low battery notification system
  • Loading branch information
DivineThreepwood authored Feb 20, 2024
2 parents d7b731f + 272736c commit 93bd150
Show file tree
Hide file tree
Showing 78 changed files with 2,514 additions and 1,610 deletions.
11 changes: 7 additions & 4 deletions build-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ WHITE='\033[0;37m'

APP_NAME='docker images'
APP_NAME=${BLUE}${APP_NAME}${NC}
echo -e "=== ${APP_NAME} build docker image...${WHITE}${NC}" &&
docker build -f docker/Dockerfile -t openbaseorg/bco:local .
docker build -f docker/device-manager/openhab/Dockerfile -t openbaseorg/bco-device-manager-openhab:local --build-arg BCO_BASE_IMAGE_VERSION=local docker/device-manager/openhab
docker build -f docker/bco-demo/Dockerfile -t openbaseorg/bco-demo:local --build-arg BCO_BASE_IMAGE_VERSION=local docker/bco-demo
IMAGE_TAG=${1:-local}

echo -e "=== ${APP_NAME} build docker image...${WHITE}${NC}"

docker build -f docker/Dockerfile -t openbaseorg/bco:${IMAGE_TAG} .
docker build -f docker/device-manager/openhab/Dockerfile -t openbaseorg/bco-device-manager-openhab:${IMAGE_TAG} --build-arg BCO_BASE_IMAGE_VERSION=${IMAGE_TAG} docker/device-manager/openhab
docker build -f docker/bco-demo/Dockerfile -t openbaseorg/bco-demo:${IMAGE_TAG} --build-arg BCO_BASE_IMAGE_VERSION=${IMAGE_TAG} docker/bco-demo

# use this for debugging purpose: DOCKER_BUILDKIT=0 docker build -f docker/Dockerfile --progress=plain .
echo -e "=== ${APP_NAME} were ${GREEN}successfully${NC} build.${NC}"
2 changes: 1 addition & 1 deletion lib/jul
Submodule jul updated 33 files
+3 −3 gradle.properties
+1 −1 gradle/wrapper/gradle-wrapper.properties
+0 −37 module/audio/src/main/java/org/openbase/jul/audio/AudioData.java
+15 −0 module/audio/src/main/java/org/openbase/jul/audio/AudioData.kt
+0 −85 module/audio/src/main/java/org/openbase/jul/audio/AudioDataImpl.java
+44 −0 module/audio/src/main/java/org/openbase/jul/audio/AudioDataImpl.kt
+0 −33 module/audio/src/main/java/org/openbase/jul/audio/AudioFileHolder.java
+11 −0 module/audio/src/main/java/org/openbase/jul/audio/AudioFileHolder.kt
+0 −149 module/audio/src/main/java/org/openbase/jul/audio/AudioPlayer.java
+156 −0 module/audio/src/main/java/org/openbase/jul/audio/AudioPlayer.kt
+0 −31 module/audio/src/main/java/org/openbase/jul/audio/AudioSource.java
+7 −0 module/audio/src/main/java/org/openbase/jul/audio/AudioSource.kt
+1 −1 ...munication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractControllerServer.java
+42 −26 .../communication/controller/src/main/java/org/openbase/jul/communication/controller/AbstractRemoteClient.java
+9 −6 module/communication/default/src/main/java/org/openbase/jul/communication/exception/RPCResolvedException.java
+11 −4 module/communication/mqtt/src/main/java/org/openbase/jul/communication/mqtt/RPCServerImpl.kt
+14 −11 module/exception/src/main/java/org/openbase/jul/exception/printer/ExceptionPrinter.java
+11 −3 module/extension/type/processing/src/main/java/org/openbase/jul/extension/type/processing/ScopeProcessor.java
+3 −3 ...xtension/type/util/src/main/java/org/openbase/jul/extension/type/util/TransactionSynchronizationFuture.java
+6 −9 module/pattern/default/src/main/java/org/openbase/jul/pattern/AbstractObservable.java
+3 −2 module/schedule/src/main/java/org/openbase/jul/schedule/RecurrenceEventFilter.java
+144 −47 module/storage/src/main/java/org/openbase/jul/storage/registry/AbstractRegistry.java
+2 −3 module/storage/src/main/java/org/openbase/jul/storage/registry/AbstractSynchronizer.java
+135 −62 module/storage/src/main/java/org/openbase/jul/storage/registry/FileSynchronizedRegistryImpl.java
+17 −18 module/storage/src/main/java/org/openbase/jul/storage/registry/version/GitVersionControl.java
+15 −18 module/visual/javafx/build.gradle.kts
+9 −4 module/visual/swing/build.gradle.kts
+0 −421 module/visual/swing/src/main/java/org/openbase/jul/visual/swing/engine/draw2d/AbstractResourcePanel.java
+413 −0 module/visual/swing/src/main/java/org/openbase/jul/visual/swing/engine/draw2d/AbstractResourcePanel.kt
+0 −267 module/visual/swing/src/main/java/org/openbase/jul/visual/swing/engine/draw2d/ResourceDisplayPanel.java
+236 −0 module/visual/swing/src/main/java/org/openbase/jul/visual/swing/engine/draw2d/ResourceDisplayPanel.kt
+36 −0 module/visual/swing/src/main/java/org/openbase/jul/visual/swing/engine/draw2d/ResourcePanel.kt
+28 −59 versions.properties
2 changes: 1 addition & 1 deletion lib/type
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ import org.springframework.context.annotation.Bean
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/@SpringBootApplication
*/
@SpringBootApplication
open class BcoGraphQlApiSpringBootApplication {
private var injector: Injector? = null

Expand All @@ -84,6 +85,8 @@ open class BcoGraphQlApiSpringBootApplication {
)
val unitDataOutputType = schema.getType("openbase_type_domotic_unit_UnitData") as GraphQLOutputType?
val unitConfigOutputType = schema.getType("openbase_type_domotic_unit_UnitConfig") as GraphQLOutputType?
val userMessageOutputType =
schema.getType("openbase_type_domotic_communication_UserMessage") as GraphQLOutputType?
val unitFilterInputType = schema.getType("Input_openbase_type_domotic_unit_UnitFilter") as GraphQLInputType?
val unitFilterInputConverter =
GqlInputConverter.newBuilder().add(UnitFilterType.UnitFilter.getDescriptor().file).build()
Expand All @@ -99,6 +102,11 @@ open class BcoGraphQlApiSpringBootApplication {
.argument(GraphQLArgument.newArgument().name("includeDisabledUnits").type(Scalars.GraphQLBoolean))
.build()
)
builder.field(
GraphQLFieldDefinition.newFieldDefinition().name("userMessages")
.type(GraphQLList.list(userMessageOutputType))
.build()
)
val codeRegistry = GraphQLCodeRegistry.newCodeRegistry(schema.codeRegistry)
.dataFetcher(FieldCoordinates.coordinates("Subscription", "units"), DataFetcher { dataFetchingEnvironment ->
val unitFilter = unitFilterInputConverter.createProtoBuf(
Expand All @@ -122,6 +130,11 @@ open class BcoGraphQlApiSpringBootApplication {
}
SubscriptionModule.subscribeUnitConfigs(unitFilter, includeDisabledUnits)
})
.dataFetcher(
FieldCoordinates.coordinates("Subscription", "userMessages"),
DataFetcher {
SubscriptionModule.subscribeUserMessages()
})
.build()
return GraphQLSchema.newSchema(schema)
.subscription(builder.build())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ abstract class AbstractBCOGraphQLContext(
abstract val languageCode: String?

val auth: AuthTokenType.AuthToken?
get() = AuthTokenType.AuthToken.newBuilder().setAuthenticationToken(token).build()
get() = token?.let { AuthTokenType.AuthToken.newBuilder().setAuthenticationToken(it).build() }

companion object {
const val DATA_LOADER_UNITS = "units"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import org.openbase.bco.api.graphql.error.GenericError
import org.openbase.bco.api.graphql.error.ServerError
import org.openbase.bco.authentication.lib.SessionManager
import org.openbase.bco.authentication.lib.iface.BCOSession
import org.openbase.bco.registry.message.remote.registerUserMessageAuthenticated
import org.openbase.bco.registry.message.remote.removeUserMessageAuthenticated
import org.openbase.bco.registry.message.remote.updateUserMessageAuthenticated
import org.openbase.bco.registry.remote.Registries
import org.openbase.bco.registry.remote.session.BCOSessionImpl
import org.openbase.bco.registry.unit.remote.registerUnitConfigAuthenticated
Expand All @@ -21,6 +24,7 @@ import org.openbase.jul.extension.type.processing.LabelProcessor.getBestMatch
import org.openbase.jul.extension.type.processing.LabelProcessor.replace
import org.openbase.type.configuration.EntryType
import org.openbase.type.configuration.MetaConfigType
import org.openbase.type.domotic.communication.UserMessageType.UserMessage
import org.openbase.type.domotic.service.ServiceTemplateType
import org.openbase.type.domotic.unit.UnitConfigType
import org.openbase.type.domotic.unit.UnitConfigType.UnitConfig
Expand Down Expand Up @@ -56,7 +60,8 @@ import java.util.concurrent.*
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/ class RegistrySchemaModule : SchemaModule() {
*/
class RegistrySchemaModule : SchemaModule() {

Check warning

Code scanning / detekt

Too many functions inside a/an file/class/object/interface always indicate a violation of the single responsibility principle. Maybe the file/class/object/interface wants to manage too many things at once. Extract functionality which clearly belongs together. Warning

Class 'RegistrySchemaModule' with '22' functions detected. Defined threshold inside classes is set to '11'
/**
* Check if an authentication token retrieved by the login method is still valid.
*
Expand Down Expand Up @@ -157,6 +162,10 @@ import java.util.concurrent.*
@Arg("includeDisabledUnits") includeDisabledUnits: Boolean?,
): ImmutableList<UnitConfigType.UnitConfig> = getUnitConfigs(unitFilter, includeDisabledUnits)

@Query("userMessages")
@Throws(BCOGraphQLError::class)
fun userMessages(): ImmutableList<UserMessage> = getUserMessages()

@Query("gatewayClasses")
@Throws(CouldNotPerformException::class, InterruptedException::class)
fun gatewayClasses(): ImmutableList<GatewayClassType.GatewayClass> =
Expand Down Expand Up @@ -401,7 +410,7 @@ import java.util.concurrent.*
break
}
}
if (!entry.value.isEmpty()) {
if (entry.value.isNotEmpty()) {
metaConfigBuilder.addEntry(entry)
}

Expand All @@ -419,6 +428,92 @@ import java.util.concurrent.*
throw GenericError(ex)
}

@Mutation("updateUserMessage")
@Throws(BCOGraphQLError::class)
fun updateUserMessage(
@Arg("userMessage") userMessage: UserMessage,
env: DataFetchingEnvironment,
): UserMessage = try {
val userMessageBuilder = Registries.getMessageRegistry(
ServerError.BCO_TIMEOUT_SHORT,
ServerError.BCO_TIMEOUT_TIME_UNIT
)
.getUserMessageById(userMessage.id)
.toBuilder()
userMessageBuilder.mergeFromWithoutRepeatedFields(userMessage)
Registries.getMessageRegistry(
ServerError.BCO_TIMEOUT_SHORT,
ServerError.BCO_TIMEOUT_TIME_UNIT
).updateUserMessageAuthenticated(
userMessageBuilder.build(),
env.context.auth
)[ServerError.BCO_TIMEOUT_SHORT, ServerError.BCO_TIMEOUT_TIME_UNIT]
} catch (ex: RuntimeException) {

Check warning

Code scanning / detekt

Caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled. Warning

Caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled.
throw GenericError(ex)
} catch (ex: CouldNotPerformException) {
throw GenericError(ex)
} catch (ex: InterruptedException) {
throw GenericError(ex)
} catch (ex: ExecutionException) {
throw GenericError(ex)
} catch (ex: TimeoutException) {
throw GenericError(ex)
}

@Mutation("removeUserMessage")
@Throws(BCOGraphQLError::class)
fun removeUserMessage(
@Arg("unitId") unitId: String?,
env: DataFetchingEnvironment,
): UserMessage = try {
val userMessage = Registries.getMessageRegistry(
ServerError.BCO_TIMEOUT_SHORT,
ServerError.BCO_TIMEOUT_TIME_UNIT
).getUserMessageById(unitId)
Registries.getMessageRegistry(
ServerError.BCO_TIMEOUT_SHORT,
ServerError.BCO_TIMEOUT_TIME_UNIT
).removeUserMessageAuthenticated(
userMessage,
env.context.auth
)[ServerError.BCO_TIMEOUT_SHORT, ServerError.BCO_TIMEOUT_TIME_UNIT]
} catch (ex: RuntimeException) {

Check warning

Code scanning / detekt

Caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled. Warning

Caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled.
throw GenericError(ex)
} catch (ex: CouldNotPerformException) {
throw GenericError(ex)
} catch (ex: InterruptedException) {
throw GenericError(ex)
} catch (ex: ExecutionException) {
throw GenericError(ex)
} catch (ex: TimeoutException) {
throw GenericError(ex)
}

@Mutation("registerUserMessage")
@Throws(BCOGraphQLError::class)
fun registerUserMessage(
@Arg("userMessage") userMessage: UserMessage?,
env: DataFetchingEnvironment,
): UserMessage = try {
Registries.getMessageRegistry(
ServerError.BCO_TIMEOUT_SHORT,
ServerError.BCO_TIMEOUT_TIME_UNIT
).registerUserMessageAuthenticated(
userMessage,
env.context.auth
)[ServerError.BCO_TIMEOUT_SHORT, ServerError.BCO_TIMEOUT_TIME_UNIT]
} catch (ex: RuntimeException) {

Check warning

Code scanning / detekt

Caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled. Warning

Caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled.
throw GenericError(ex)
} catch (ex: CouldNotPerformException) {
throw GenericError(ex)
} catch (ex: InterruptedException) {
throw GenericError(ex)
} catch (ex: ExecutionException) {
throw GenericError(ex)
} catch (ex: TimeoutException) {
throw GenericError(ex)
}

companion object {
@Throws(BCOGraphQLError::class)
fun getUnitConfigs(
Expand All @@ -438,5 +533,22 @@ import java.util.concurrent.*
} catch (ex: InterruptedException) {
throw GenericError(ex)
}

@Throws(BCOGraphQLError::class)
fun getUserMessages(
): ImmutableList<UserMessage> = try {
ImmutableList.copyOf(
Registries.getMessageRegistry(
ServerError.BCO_TIMEOUT_SHORT,
ServerError.BCO_TIMEOUT_TIME_UNIT
).userMessages
)
} catch (ex: RuntimeException) {

Check warning

Code scanning / detekt

Caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled. Warning

Caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled.
throw GenericError(ex)
} catch (ex: CouldNotPerformException) {
throw GenericError(ex)
} catch (ex: InterruptedException) {
throw GenericError(ex)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.openbase.bco.api.graphql.subscriptions

import com.google.common.collect.ImmutableList
import org.openbase.bco.api.graphql.error.ServerError
import org.openbase.bco.api.graphql.schema.RegistrySchemaModule
import org.openbase.bco.registry.remote.Registries
import org.openbase.jul.pattern.provider.DataProvider
import org.openbase.type.domotic.communication.UserMessageType
import org.openbase.type.domotic.registry.MessageRegistryDataType

class MessageRegistrySubscriptionObserver() :

Check warning

Code scanning / detekt

Empty block of code detected. As they serve no purpose they should be removed. Warning

An empty default constructor can be removed.
AbstractObserverMapper<DataProvider<MessageRegistryDataType.MessageRegistryData>, MessageRegistryDataType.MessageRegistryData, List<UserMessageType.UserMessage>>() {

Check warning

Code scanning / detekt

Line detected that is longer than the defined maximum line length in the code style. Warning

Line detected that is longer than the defined maximum line length in the code style.
private val userMessages: MutableList<UserMessageType.UserMessage>

init {
Registries.getMessageRegistry(
ServerError.BCO_TIMEOUT_SHORT,
ServerError.BCO_TIMEOUT_TIME_UNIT
)
userMessages = ArrayList(
RegistrySchemaModule.getUserMessages()
)
}

@Throws(Exception::class)
override fun update(
source: DataProvider<MessageRegistryDataType.MessageRegistryData>,
target: MessageRegistryDataType.MessageRegistryData,
) {
val newUserMessages: ImmutableList<UserMessageType.UserMessage> =
RegistrySchemaModule.getUserMessages()
if (newUserMessages == userMessages) {
// nothing has changed
return
}

// store update
userMessages.clear()
userMessages.addAll(newUserMessages)
super.update(source, target)
}

@Throws(Exception::class)
override fun mapData(
source: DataProvider<MessageRegistryDataType.MessageRegistryData>,
data: MessageRegistryDataType.MessageRegistryData,
): List<UserMessageType.UserMessage> {
return userMessages
}
}
Loading

0 comments on commit 93bd150

Please sign in to comment.