Skip to content

Commit

Permalink
Merge pull request #2 from inspectIT/VHVAPM-513
Browse files Browse the repository at this point in the history
Vhvapm 513
  • Loading branch information
levinkerschberger authored Aug 26, 2024
2 parents cb81eca + 5a70f16 commit 5198ab3
Show file tree
Hide file tree
Showing 60 changed files with 5,534 additions and 6,771 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/frontend/.nuxt/
/frontend/node_modules/
/out/
.DS_Store
.idea
*.iml

/agentmanager/frontend/src/.nuxt/
/agentmanager/frontend/src/node_modules/
File renamed without changes.
File renamed without changes.
File renamed without changes.
262 changes: 262 additions & 0 deletions agentmanager/backend/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,262 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>rocks.gepard</groupId>
<artifactId>backend</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>backend</name>
<description>backend</description>
<properties>
<java.version>17</java.version>
<kotlin.version>1.9.0</kotlin.version>
</properties>

<!-- DEPENDENCIES-->
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-kotlin</artifactId>
</dependency>

<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
</dependency>

<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit5</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>2.2.2</version>
</dependency>

<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>0.2.2</version>
</dependency>

<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>

<!-- PLUGINS-->
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>

<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<source>src/main/kotlin</source>
<source>target/generated-sources/annotations</source>
<source>target/generated-sources/openapi/src/main/java</source>
</sourceDirs>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<sourceDirs>
<source>src/test/kotlin</source>
<source>target/generated-test-sources/test-annotations</source>
</sourceDirs>
</configuration>
</execution>
</executions>
<configuration>
<args>
<arg>-Xjsr305=strict</arg>
</args>
<compilerPlugins>
<plugin>spring</plugin>
<plugin>jpa</plugin>
</compilerPlugins>
<jvmTarget>1.8</jvmTarget>
</configuration>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-noarg</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>

<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>6.1.0</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>
${project.basedir}/src/main/resources/openai/AgentController-1.0.0.yaml
</inputSpec>
<generatorName>spring</generatorName>
<apiPackage>rocks.gepard.backend.infrastructure.incoming.api</apiPackage>
<modelPackage>rocks.gepard.backend.infrastructure.incoming.model</modelPackage>
<configOptions>
<interfaceOnly>true</interfaceOnly>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package rocks.gepard.backend

import org.springframework.boot.ApplicationArguments
import org.springframework.boot.ApplicationRunner
import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.boot.web.servlet.FilterRegistrationBean
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
Expand All @@ -12,18 +13,19 @@ import org.springframework.web.filter.CorsFilter
import java.util.function.Consumer

@Configuration
@EnableConfigurationProperties
class AgentManagerConfiguration {
// Bootstrap some test data into the in-memory database
@Bean
fun init(repository: AgentRepository): ApplicationRunner {
return ApplicationRunner { _: ApplicationArguments? ->
arrayOf("Affe", "Häschen", "Schildkröte", "Hund", "Katze").forEach {
val agent = Agent(it)
repository.save(agent)
}
repository.findAll().forEach(/* action = */ Consumer { x: Agent? -> println(x) })
}
}
// @Bean
// fun init(repository: AgentRepository): ApplicationRunner {
// return ApplicationRunner { _: ApplicationArguments? ->
// arrayOf("Affe", "Häschen", "Schildkröte", "Hund", "Katze").forEach {
// val agent = Agent(it)
// repository.save(agent)
// }
// repository.findAll().forEach(/* action = */ Consumer { x: Agent? -> println(x) })
// }
// }

// Fix the CORS errors
@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package rocks.gepard.backend

import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.context.properties.ConfigurationProperties

@SpringBootApplication
class BackendApplication {
Expand All @@ -11,4 +12,4 @@ class BackendApplication {
SpringApplication.run(BackendApplication::class.java, *args)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package rocks.gepard.backend.application

import rocks.gepard.backend.infrastructure.incoming.model.AgentResponseDto


class AgentCache<K, V> : GenericCache<K, V> {

private val cache = HashMap<K,V>()

override val size: Int
get() = cache.size

override fun set(key: K, value: V) {
cache[key] = value
}

override fun remove(key: K) = cache.remove(key)

override fun get(key: K) = cache[key]

override fun clear() = cache.clear()

fun getAllAgents() : MutableList<AgentResponseDto>{
return TODO()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package rocks.gepard.backend.application

import org.springframework.stereotype.Service
import rocks.gepard.backend.domain.model.Agent
import rocks.gepard.backend.infrastructure.incoming.model.AgentDto
import rocks.gepard.backend.infrastructure.incoming.model.AgentResponseDto

@Service
class AgentService {

private val agentCache: AgentCache<String, Agent> = AgentCache()

fun storeAgent(agent: Agent?) {
agent?.let {
agentCache.set(it.name, it)
}
}

fun getAllAgents(): MutableList<AgentResponseDto> {

return agentCache.getAllAgents()
}

fun getAgentByName(agentName: String?): AgentResponseDto? {
return agentName
?.let { agentCache.get(it) }
?.let(Agent::toResponseDto)
}
}

fun Agent.toResponseDto(): AgentResponseDto {
return AgentResponseDto().name(this.name)
.javaversion(this.getJavaVersion())
.otelversion(this.getOtelVersion())
.config(this.configuration.toString())
}
Loading

0 comments on commit 5198ab3

Please sign in to comment.