Skip to content

Commit

Permalink
handle sonnar
Browse files Browse the repository at this point in the history
  • Loading branch information
ntqdinh-axonivy committed Jul 26, 2024
1 parent 5d311e5 commit 087ab8f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Optional;

import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
Expand All @@ -32,8 +33,9 @@ public ProductDetailModel toModel(Product product) {
return createModel(product, null);
}

public ProductDetailModel toModel(Product product, String tag) {
return createModel(product, tag);
public ProductDetailModel toModel(Product product, String version) {
String productId = Optional.ofNullable(product).map(Product::getId).orElse(StringUtils.EMPTY);
return createModel(product, convertVersionToTag(productId, version));
}

private ProductDetailModel createModel(Product product, String tag) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class GitHubConstants {
public static final String GITHUB_GET_ACCESS_TOKEN_URL = "https://github.com/login/oauth/access_token";
public static final String README_FILE_LOCALE_REGEX = "_(..)";
public static final String STANDARD_TAG_PREFIX = "v";
public static final String COMMON_IMAGES_FOLDER_NAME = "images";

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public static class Json {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.axonivy.market.constants.RequestMappingConstants.PRODUCT_DETAILS;
Expand Down Expand Up @@ -51,7 +46,7 @@ public ResponseEntity<Integer> syncInstallationCount(@PathVariable("key") String
@GetMapping("/{id}")
public ResponseEntity<ProductDetailModel> findProductDetails(@PathVariable("id") String id) {
var productDetail = productService.fetchProductDetail(id);
return new ResponseEntity<>(detailModelAssembler.toModel(productDetail, null), HttpStatus.OK);
return new ResponseEntity<>(detailModelAssembler.toModel(productDetail), HttpStatus.OK);
}

@GetMapping("/{id}/versions")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,41 @@

import java.util.Arrays;

import static com.axonivy.market.constants.GitHubConstants.COMMON_IMAGES_FOLDER_NAME;

@Getter
@AllArgsConstructor
public enum NonStandardProduct {
PORTAL ( "portal",true,"images","AxonIvyPortal/portal-product" ),
MICROSOFT_REPO_NAME ( "msgraph-connector",false,"images",""),
MICROSOFT_365 ( "msgraph",false,"images","msgraph-connector-product/products/msgraph-connector"), // No meta.json
MICROSOFT_CALENDAR ( "msgraph-calendar",false,"images","msgraph-connector-product/products/msgraph-calendar"), // no fix product json
MICROSOFT_MAIL ( "msgraph-mail",false,"images","msgraph-connector-product/products/msgraph-mail"),// no fix product json
MICROSOFT_TEAMS ( "msgraph-chat",false,"images","msgraph-connector-product/products/msgraph-chat"),// no fix product json
MICROSOFT_TODO ( "msgraph-todo",false,"images","msgraph-connector-product/products/msgraph-todo"),// no fix product json
CONNECTIVITY_FEATURE ( "connectivity-demo",false,"images","connectivity/connectivity-demos-product"),
EMPLOYEE_ONBOARDING ( "employee-onboarding",false,"images",""), // Invalid meta.json
ERROR_HANDLING ( "error-handling-demo",false,"images","error-handling/error-handling-demos-product"),
RULE_ENGINE_DEMOS ( "rule-engine-demo",false,"images","rule-engine/rule-engine-demos-product"),
WORKFLOW_DEMO ( "workflow-demo",false,"images","workflow/workflow-demos-product"),
HTML_DIALOG_DEMO ( "html-dialog-demo",false,"images","html-dialog/html-dialog-demos-product"),
PROCESSING_VALVE_DEMO ( "processing-valve-demo",false,"images",""),// no product json
OPENAI_CONNECTOR ( "openai-connector",false,"images","openai-connector-product"),
OPENAI_ASSISTANT ( "openai-assistant",false,"docs","openai-assistant-product"),
PORTAL("portal", true, COMMON_IMAGES_FOLDER_NAME, "AxonIvyPortal/portal-product"),
MICROSOFT_REPO_NAME("msgraph-connector", false, COMMON_IMAGES_FOLDER_NAME, ""),
MICROSOFT_365("msgraph", false, COMMON_IMAGES_FOLDER_NAME, "msgraph-connector-product/products/msgraph-connector"), // No meta.json
MICROSOFT_CALENDAR("msgraph-calendar", false, COMMON_IMAGES_FOLDER_NAME, "msgraph-connector-product/products/msgraph-calendar"), // no fix product json
MICROSOFT_MAIL("msgraph-mail", false, COMMON_IMAGES_FOLDER_NAME, "msgraph-connector-product/products/msgraph-mail"),// no fix product json
MICROSOFT_TEAMS("msgraph-chat", false, COMMON_IMAGES_FOLDER_NAME, "msgraph-connector-product/products/msgraph-chat"),// no fix product json
MICROSOFT_TODO("msgraph-todo", false, COMMON_IMAGES_FOLDER_NAME, "msgraph-connector-product/products/msgraph-todo"),// no fix product json
CONNECTIVITY_FEATURE("connectivity-demo", false, COMMON_IMAGES_FOLDER_NAME, "connectivity/connectivity-demos-product"),
EMPLOYEE_ONBOARDING("employee-onboarding", false, COMMON_IMAGES_FOLDER_NAME, ""), // Invalid meta.json
ERROR_HANDLING("error-handling-demo", false, COMMON_IMAGES_FOLDER_NAME, "error-handling/error-handling-demos-product"),
RULE_ENGINE_DEMOS("rule-engine-demo", false, COMMON_IMAGES_FOLDER_NAME, "rule-engine/rule-engine-demos-product"),
WORKFLOW_DEMO("workflow-demo", false, COMMON_IMAGES_FOLDER_NAME, "workflow/workflow-demos-product"),
HTML_DIALOG_DEMO("html-dialog-demo", false, COMMON_IMAGES_FOLDER_NAME, "html-dialog/html-dialog-demos-product"),
PROCESSING_VALVE_DEMO("processing-valve-demo", false, COMMON_IMAGES_FOLDER_NAME, ""),// no product json
OPENAI_CONNECTOR("openai-connector", false, COMMON_IMAGES_FOLDER_NAME, "openai-connector-product"),
OPENAI_ASSISTANT("openai-assistant", false, "docs", "openai-assistant-product"),
// Non standard image folder name
EXCEL_IMPORTER ( "excel-importer",false,"doc",""),
EXPRESS_IMPORTER ( "express-importer",false,"img",""),
GRAPHQL_DEMO ( "graphql-demo",false,"assets",""),
DEEPL_CONNECTOR ( "deepl-connector",false,"img",""),
DEFAULT("",false,"images","");
EXCEL_IMPORTER("excel-importer", false, "doc", ""),
EXPRESS_IMPORTER("express-importer", false, "img", ""),
GRAPHQL_DEMO("graphql-demo", false, "assets", ""),
DEEPL_CONNECTOR("deepl-connector", false, "img", ""),
DEFAULT("", false, COMMON_IMAGES_FOLDER_NAME, "");

private final String id;
private final boolean isVersionTagNumberOnly;
private final String pathToImageFolder;
private final String pathToProductFolder;

public static NonStandardProduct findById(String id){
public static NonStandardProduct findById(String id) {

return Arrays.stream(NonStandardProduct.values()).filter(product -> id.equalsIgnoreCase(product.getId())).findAny().orElse(DEFAULT);
}
}

0 comments on commit 087ab8f

Please sign in to comment.