Skip to content

Commit 464fff4

Browse files
Adding two new static file extension folders for Java Specific Workflows (#97)
* Adding two new static file extension folders for Java Specific Workflows When using a spring boot application in Java, many of the static files will be placed in META-INF/resources. Right now these are treated like first class concepts, eventually moving the weight of Java application down far enough to not be selected. Signed-off-by: Shawn Hurley <[email protected]> * adding test case for the coolstore application Signed-off-by: Shawn Hurley <[email protected]> * Restructure test resource Signed-off-by: thepetk <[email protected]> * Increase number of total projects Signed-off-by: thepetk <[email protected]> --------- Signed-off-by: Shawn Hurley <[email protected]> Signed-off-by: thepetk <[email protected]> Co-authored-by: thepetk <[email protected]>
1 parent e5e9330 commit 464fff4

File tree

98 files changed

+178693
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+178693
-2
lines changed

pkg/apis/recognizer/language_recognizer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func AnalyzeFile(configFile string, targetLanguage string) (model.Language, erro
143143
}
144144

145145
func isStaticFileExtension(path string) bool {
146-
staticDirs := [2]string{"static/", "templates/"}
146+
staticDirs := [4]string{"static/", "templates/", "META-INF/resources/", "public/"}
147147
for _, dir := range staticDirs {
148148
if strings.Contains(path, dir) {
149149
return true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>com.redhat.coolstore</groupId>
6+
<artifactId>coolstore</artifactId>
7+
<version>1.0.0-SNAPSHOT</version>
8+
<name>coolstore-quarkus</name>
9+
<properties>
10+
<compiler-plugin.version>3.13.0</compiler-plugin.version>
11+
<maven.compiler.release>21</maven.compiler.release>
12+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
14+
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
15+
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
16+
<quarkus.platform.version>3.12.3</quarkus.platform.version>
17+
<skipITs>true</skipITs>
18+
<surefire-plugin.version>3.2.5</surefire-plugin.version>
19+
</properties>
20+
<dependencyManagement>
21+
<dependencies>
22+
<dependency>
23+
<groupId>io.quarkus.platform</groupId>
24+
<artifactId>quarkus-bom</artifactId>
25+
<version>${quarkus.platform.version}</version>
26+
<type>pom</type>
27+
<scope>import</scope>
28+
</dependency>
29+
</dependencies>
30+
</dependencyManagement>
31+
<dependencies>
32+
<dependency>
33+
<groupId>io.quarkus</groupId>
34+
<artifactId>quarkus-arc</artifactId>
35+
</dependency>
36+
<dependency>
37+
<groupId>io.quarkus</groupId>
38+
<artifactId>quarkus-resteasy</artifactId>
39+
</dependency>
40+
<dependency>
41+
<groupId>io.quarkus</groupId>
42+
<artifactId>quarkus-resteasy-jackson</artifactId>
43+
</dependency>
44+
<dependency>
45+
<groupId>io.quarkus</groupId>
46+
<artifactId>quarkus-resteasy-client</artifactId>
47+
</dependency>
48+
<dependency>
49+
<groupId>io.quarkus</groupId>
50+
<artifactId>quarkus-resteasy-client-jackson</artifactId>
51+
</dependency>
52+
<dependency>
53+
<groupId>io.quarkus</groupId>
54+
<artifactId>quarkus-hibernate-orm</artifactId>
55+
</dependency>
56+
<dependency>
57+
<groupId>io.quarkus</groupId>
58+
<artifactId>quarkus-jdbc-postgresql</artifactId>
59+
</dependency>
60+
<dependency>
61+
<groupId>io.quarkus</groupId>
62+
<artifactId>quarkus-flyway</artifactId>
63+
</dependency>
64+
<dependency>
65+
<groupId>org.flywaydb</groupId>
66+
<artifactId>flyway-database-postgresql</artifactId>
67+
<version>10.12.0</version>
68+
<scope>runtime</scope>
69+
</dependency>
70+
<dependency>
71+
<groupId>io.quarkus</groupId>
72+
<artifactId>quarkus-undertow</artifactId>
73+
</dependency>
74+
<dependency>
75+
<groupId>io.quarkus</groupId>
76+
<artifactId>quarkus-messaging</artifactId>
77+
</dependency>
78+
<dependency>
79+
<groupId>io.quarkus</groupId>
80+
<artifactId>quarkus-container-image-docker</artifactId>
81+
</dependency>
82+
<dependency>
83+
<groupId>io.quarkus</groupId>
84+
<artifactId>quarkus-minikube</artifactId>
85+
</dependency>
86+
</dependencies>
87+
<build>
88+
<plugins>
89+
<plugin>
90+
<groupId>${quarkus.platform.group-id}</groupId>
91+
<artifactId>quarkus-maven-plugin</artifactId>
92+
<version>${quarkus.platform.version}</version>
93+
<extensions>true</extensions>
94+
<executions>
95+
<execution>
96+
<goals>
97+
<goal>build</goal>
98+
<goal>generate-code</goal>
99+
<goal>generate-code-tests</goal>
100+
<goal>native-image-agent</goal>
101+
</goals>
102+
</execution>
103+
</executions>
104+
</plugin>
105+
<plugin>
106+
<artifactId>maven-compiler-plugin</artifactId>
107+
<version>${compiler-plugin.version}</version>
108+
<configuration>
109+
<compilerArgs>
110+
<arg>-parameters</arg>
111+
</compilerArgs>
112+
</configuration>
113+
</plugin>
114+
<plugin>
115+
<artifactId>maven-surefire-plugin</artifactId>
116+
<version>${surefire-plugin.version}</version>
117+
<configuration>
118+
<systemPropertyVariables>
119+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
120+
<maven.home>${maven.home}</maven.home>
121+
</systemPropertyVariables>
122+
</configuration>
123+
</plugin>
124+
<plugin>
125+
<artifactId>maven-failsafe-plugin</artifactId>
126+
<version>${surefire-plugin.version}</version>
127+
<executions>
128+
<execution>
129+
<goals>
130+
<goal>integration-test</goal>
131+
<goal>verify</goal>
132+
</goals>
133+
</execution>
134+
</executions>
135+
<configuration>
136+
<systemPropertyVariables>
137+
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
138+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
139+
<maven.home>${maven.home}</maven.home>
140+
</systemPropertyVariables>
141+
</configuration>
142+
</plugin>
143+
</plugins>
144+
</build>
145+
146+
<profiles>
147+
<profile>
148+
<id>native</id>
149+
<activation>
150+
<property>
151+
<name>native</name>
152+
</property>
153+
</activation>
154+
<properties>
155+
<skipITs>false</skipITs>
156+
<quarkus.native.enabled>true</quarkus.native.enabled>
157+
</properties>
158+
</profile>
159+
</profiles>
160+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.redhat.coolstore.utils;
2+
3+
import jakarta.enterprise.inject.Produces;
4+
import jakarta.enterprise.inject.spi.InjectionPoint;
5+
import java.util.logging.Logger;
6+
7+
8+
public class Producers {
9+
10+
Logger log = Logger.getLogger(Producers.class.getName());
11+
12+
@Produces
13+
public Logger produceLog(InjectionPoint injectionPoint) {
14+
return Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName());
15+
}
16+
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
package com.redhat.coolstore.utils;
2+
3+
import com.redhat.coolstore.model.CatalogItemEntity;
4+
import com.redhat.coolstore.model.Order;
5+
import com.redhat.coolstore.model.OrderItem;
6+
import com.redhat.coolstore.model.Product;
7+
import com.redhat.coolstore.model.ShoppingCart;
8+
import java.io.StringReader;
9+
import java.io.StringWriter;
10+
import java.util.ArrayList;
11+
import java.util.List;
12+
import jakarta.json.Json;
13+
import jakarta.json.JsonArray;
14+
import jakarta.json.JsonArrayBuilder;
15+
import jakarta.json.JsonObject;
16+
import jakarta.json.JsonReader;
17+
import jakarta.json.JsonWriter;
18+
19+
import java.util.concurrent.ThreadLocalRandom;
20+
import java.util.logging.Logger;
21+
22+
/**
23+
* Created by tqvarnst on 2017-03-30.
24+
*/
25+
public class Transformers {
26+
27+
private static final String[] RANDOM_NAMES = {"Sven Karlsson","Johan Andersson","Karl Svensson","Anders Johansson","Stefan Olson","Martin Ericsson"};
28+
29+
30+
private static Logger log = Logger.getLogger(Transformers.class.getName());
31+
32+
public static Product toProduct(CatalogItemEntity entity) {
33+
Product prod = new Product();
34+
prod.setItemId(entity.getItemId());
35+
prod.setName(entity.getName());
36+
prod.setDesc(entity.getDesc());
37+
prod.setPrice(entity.getPrice());
38+
if (entity.getInventory() != null) {
39+
prod.setLocation(entity.getInventory().getLocation());
40+
prod.setLink(entity.getInventory().getLink());
41+
prod.setQuantity(entity.getInventory().getQuantity());
42+
} else {
43+
log.warning("Inventory for " + entity.getName() + "[" + entity.getItemId()+ "] unknown and missing");
44+
}
45+
return prod;
46+
}
47+
48+
public static String shoppingCartToJson(ShoppingCart cart) {
49+
JsonArrayBuilder cartItems = Json.createArrayBuilder();
50+
cart.getShoppingCartItemList().forEach(item -> {
51+
cartItems.add(Json.createObjectBuilder()
52+
.add("productSku",item.getProduct().getItemId())
53+
.add("quantity",item.getQuantity())
54+
);
55+
});
56+
57+
int randomNameAndEmailIndex = ThreadLocalRandom.current().nextInt(RANDOM_NAMES.length);
58+
59+
JsonObject jsonObject = Json.createObjectBuilder()
60+
.add("orderValue", Double.valueOf(cart.getCartTotal()))
61+
.add("customerName",RANDOM_NAMES[randomNameAndEmailIndex])
62+
.add("customerEmail",RANDOM_EMAILS[randomNameAndEmailIndex])
63+
.add("retailPrice", cart.getShoppingCartItemList().stream().mapToDouble(i -> i.getQuantity()*i.getPrice()).sum())
64+
.add("discount", Double.valueOf(cart.getCartItemPromoSavings()))
65+
.add("shippingFee", Double.valueOf(cart.getShippingTotal()))
66+
.add("shippingDiscount", Double.valueOf(cart.getShippingPromoSavings()))
67+
.add("items",cartItems)
68+
.build();
69+
StringWriter w = new StringWriter();
70+
try (JsonWriter writer = Json.createWriter(w)) {
71+
writer.write(jsonObject);
72+
}
73+
return w.toString();
74+
}
75+
76+
public static Order jsonToOrder(String json) {
77+
JsonReader jsonReader = Json.createReader(new StringReader(json));
78+
JsonObject rootObject = jsonReader.readObject();
79+
Order order = new Order();
80+
order.setCustomerName(rootObject.getString("customerName"));
81+
order.setCustomerEmail(rootObject.getString("customerEmail"));
82+
order.setOrderValue(rootObject.getJsonNumber("orderValue").doubleValue());
83+
order.setRetailPrice(rootObject.getJsonNumber("retailPrice").doubleValue());
84+
order.setDiscount(rootObject.getJsonNumber("discount").doubleValue());
85+
order.setShippingFee(rootObject.getJsonNumber("shippingFee").doubleValue());
86+
order.setShippingDiscount(rootObject.getJsonNumber("shippingDiscount").doubleValue());
87+
JsonArray jsonItems = rootObject.getJsonArray("items");
88+
List<OrderItem> items = new ArrayList<OrderItem>(jsonItems.size());
89+
for (JsonObject jsonItem : jsonItems.getValuesAs(JsonObject.class)) {
90+
OrderItem oi = new OrderItem();
91+
oi.setProductId(jsonItem.getString("productSku"));
92+
oi.setQuantity(jsonItem.getInt("quantity"));
93+
items.add(oi);
94+
}
95+
order.setItemList(items);
96+
return order;
97+
}
98+
99+
100+
}

0 commit comments

Comments
 (0)