-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #283 from dRAGon-Okinawa/farm-silo-routing
Farm Silo Routing
- Loading branch information
Showing
50 changed files
with
1,024 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
BLACK='\033[0;30m' | ||
RED='\033[0;31m' | ||
GREEN='\033[0;32m' | ||
YELLOW='\033[1;33m' | ||
BLUE='\033[0;34m' | ||
PURPLE='\033[0;35m' | ||
CYAN='\033[0;36m' | ||
NC='\033[0m' | ||
|
||
printf "${CYAN}Let's go for a dRAGon ride! 🐉${NC}\n" | ||
printf "\n" | ||
|
||
printf "${YELLOW}[QUICKSTART]${NC}\n" | ||
printf "\t${BLUE}✨ Launch full dRAGon app ${NC}\tgradle bootRun\n" | ||
printf "\t${BLUE}Launch dRAGon backend only${NC}\tgradle bootRun -x :frontend:pnpmBuild -x :backend:copyWebApp\n" | ||
printf "\t${BLUE}Launch dRAGon frontend only${NC}\tpnpm --prefix frontend dev\n" | ||
|
||
printf "\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
#!/bin/bash | ||
|
||
# Prepare PNPM | ||
echo "Setting up pnpm store..." | ||
mkdir -p /tmp/pnpm && pnpm config set store-dir /tmp/pnpm/ | ||
|
||
# Install dependencies | ||
echo "Building the project..." | ||
gradle pnpmInstall build | ||
gradle pnpmInstall build | ||
|
||
# Configure the message of the day | ||
echo '/bin/sh .devcontainer/motd.sh' >> /home/vscode/.bashrc | ||
|
||
# Let's go for a dRAGon ride! 🐉 | ||
printf "${GREEN}Let's go for a dRAGon ride! 🐉\n\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
backend/src/main/java/ai/dragon/aspect/api/GenericApiExceptionHandling.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package ai.dragon.aspect.api; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Target(ElementType.METHOD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface GenericApiExceptionHandling { | ||
} |
37 changes: 37 additions & 0 deletions
37
backend/src/main/java/ai/dragon/aspect/api/GenericApiExceptionHandlingAspect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package ai.dragon.aspect.api; | ||
|
||
import org.aspectj.lang.ProceedingJoinPoint; | ||
import org.aspectj.lang.annotation.Around; | ||
import org.aspectj.lang.annotation.Aspect; | ||
import org.dizitart.no2.exceptions.UniqueConstraintException; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
import ai.dragon.dto.api.FailureApiResponse; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
|
||
@Aspect | ||
@Component | ||
public class GenericApiExceptionHandlingAspect { | ||
@Autowired | ||
private HttpServletResponse response; | ||
|
||
@Around("@annotation(GenericApiExceptionHandling)") | ||
public Object handleException(ProceedingJoinPoint pjp) throws Throwable { | ||
try { | ||
return pjp.proceed(); | ||
} catch (Exception ex) { | ||
int httpStatusCode = 500; | ||
if(ex instanceof UniqueConstraintException) { | ||
httpStatusCode = 422; | ||
} | ||
response.setStatus(httpStatusCode); | ||
|
||
return FailureApiResponse | ||
.builder() | ||
.msg(ex.getMessage()) | ||
.code(String.format("0%d", httpStatusCode)) | ||
.build(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
backend/src/main/java/ai/dragon/dto/api/DuplicatesApiResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package ai.dragon.dto.api; | ||
|
||
import ai.dragon.enumeration.ApiResponseCode; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
@Builder | ||
@Data | ||
public class DuplicatesApiResponse implements GenericApiResponse { | ||
@Builder.Default | ||
private Object data = null; | ||
|
||
@Builder.Default | ||
private String code = ApiResponseCode.DUPLICATES.toString(); | ||
|
||
@Builder.Default | ||
private String msg = "Unique Constraint Exception"; | ||
} |
18 changes: 18 additions & 0 deletions
18
backend/src/main/java/ai/dragon/dto/api/FailureApiResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package ai.dragon.dto.api; | ||
|
||
import ai.dragon.enumeration.ApiResponseCode; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
@Builder | ||
@Data | ||
public class FailureApiResponse implements GenericApiResponse { | ||
@Builder.Default | ||
private Object data = null; | ||
|
||
@Builder.Default | ||
private String code = ApiResponseCode.INTERNAL_SERVER_ERROR.toString(); | ||
|
||
@Builder.Default | ||
private String msg = "Internal Server Error"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
backend/src/main/java/ai/dragon/enumeration/ApiResponseCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package ai.dragon.enumeration; | ||
|
||
public enum ApiResponseCode { | ||
SUCCESS("0000"), | ||
DUPLICATES("0422"), | ||
INTERNAL_SERVER_ERROR("0500"); | ||
|
||
private String value; | ||
|
||
ApiResponseCode(String value) { | ||
this.value = value; | ||
} | ||
|
||
public static ApiResponseCode fromString(String text) { | ||
for (ApiResponseCode b : ApiResponseCode.values()) { | ||
if (b.value.equalsIgnoreCase(text)) { | ||
return b; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return value; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
backend/src/main/java/ai/dragon/enumeration/QueryRouterType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package ai.dragon.enumeration; | ||
|
||
public enum QueryRouterType { | ||
DEFAULT("Default"), | ||
LANGUAGE_MODEL("LanguageModel"); | ||
|
||
private String value; | ||
|
||
QueryRouterType(String value) { | ||
this.value = value; | ||
} | ||
|
||
public static QueryRouterType fromString(String text) { | ||
for (QueryRouterType b : QueryRouterType.values()) { | ||
if (b.value.equalsIgnoreCase(text)) { | ||
return b; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.