-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2277b1e
Showing
2,304 changed files
with
168,034 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,52 @@ | ||
package org.entando.training.controllers; | ||
|
||
import org.entando.training.services.DemoService; | ||
import org.entando.entando.web.common.annotation.RestAccessControl; | ||
import org.json.JSONObject; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
|
||
@RestController | ||
public class DemoController { | ||
|
||
|
||
@Autowired | ||
DemoService demoService; | ||
|
||
private final Logger logger = LoggerFactory.getLogger(getClass()); | ||
|
||
@RestAccessControl(permission = "") | ||
@RequestMapping(value = "/fsi/leaderboard", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) | ||
public Map<String, Object> fetchLeaderboard() throws IOException { | ||
JSONObject resp = null; | ||
try { | ||
resp = demoService.getLeaderboardJson(); | ||
}catch(Exception e) { | ||
logger.error("Failed to get leaderboard ", e); | ||
} | ||
|
||
return resp.toMap(); | ||
} | ||
|
||
@RestAccessControl(permission = "") | ||
@RequestMapping(value = "/fsi/graphData/{type}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) | ||
public Map<String, Object> fetchGraphData(@PathVariable String type) throws IOException { | ||
return demoService.getDemoGraphJson(type).toMap(); | ||
} | ||
|
||
@RestAccessControl(permission = "") | ||
@RequestMapping(value = "/fsi/orderPaymentData", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) | ||
public Map<String, Object> fetchOrderPaymentData() throws IOException { | ||
return demoService.getTimeSeriesJson().toMap(); | ||
} | ||
|
||
} |
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,101 @@ | ||
package org.entando.training.services; | ||
|
||
import org.json.JSONArray; | ||
import org.json.JSONObject; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Arrays; | ||
import java.util.Calendar; | ||
import java.util.List; | ||
|
||
@Service | ||
public class DemoService { | ||
|
||
|
||
private static String graphJson = "{ min: 0, max:100, \"value\": 50}"; | ||
|
||
private static List<Integer> orders = Arrays.asList(800, 500, 650, 700, 500, 450, 800, 575, 485, 850, 700, 770, | ||
500, 575, 700, 765, 300, 850, 850, 999, 475, 999, 550, 780, | ||
650, 760, 850, 850, 175, 550, 999); | ||
|
||
private static List<Integer> payments = Arrays.asList(7, 5, 3, 8, 9, 7, 4, 3, 6, 7, 8, 6, | ||
3, 4, 11, 7, 7, 11, 11, 6, 6, 7, 10, 13, | ||
7, 8, 8, 7, 5, 7, 25); | ||
|
||
private static int[] tasksCompleted = {0, 30, 25}; | ||
private static int[] firstResponse = {144, 198, 195, 95}; | ||
private static int[] resolution = {144, 198, 191, 88}; | ||
private static int[] satisfaction = {144, 198, 198, 100}; | ||
|
||
private static String leaderboardJson = "{\"leaderboard\":[" + | ||
"{\"rank\": 1, \"name\": \"Meg Foley\", \"value\": 200}," + | ||
"{\"rank\": 2, \"name\": \"Eric Marts\", \"value\": 188}," + | ||
"{\"rank\": 3, \"name\": \"Walter Ambu\", \"value\": 175}" + | ||
"]}"; | ||
private static SimpleDateFormat fmt = new SimpleDateFormat("dd/MM/yyyy"); | ||
|
||
public JSONObject getDemoGraphJson(String key){ | ||
|
||
if(key.equals("tasks")) { | ||
return getDemoGraphJson(tasksCompleted[0], tasksCompleted[1], tasksCompleted[2], tasksCompleted[3]); | ||
}else if (key.equals("firstResponse")){ | ||
return getDemoGraphJson(firstResponse[0], firstResponse[1], firstResponse[2], firstResponse[3]); | ||
}else if(key.equals("resolution")){ | ||
return getDemoGraphJson(resolution[0], resolution[1], resolution[2], resolution[3]); | ||
}else if(key.equals("satisfaction")){ | ||
return getDemoGraphJson(satisfaction[0], satisfaction[1], satisfaction[2], satisfaction[3]); | ||
} | ||
|
||
return getDemoGraphJson(0, 100, 50, 50); | ||
} | ||
public JSONObject getDemoGraphJson(int min, int max, int value, int percentage){ | ||
|
||
JSONObject json = new JSONObject(graphJson); | ||
json.put("min", min); | ||
json.put("max", max); | ||
json.put("value", value); | ||
json.put("percentage", percentage); | ||
|
||
return json; | ||
} | ||
|
||
public JSONObject getLeaderboardJson(){ | ||
return new JSONObject(leaderboardJson); | ||
} | ||
|
||
public JSONObject getTimeSeriesJson() { | ||
JSONObject timeseries = new JSONObject(); | ||
|
||
JSONArray labels = new JSONArray(); | ||
JSONArray priceData = new JSONArray(); | ||
JSONArray orderData = new JSONArray(); | ||
|
||
Calendar cal = Calendar.getInstance(); | ||
cal.set(Calendar.MONTH, 0); | ||
cal.set(Calendar.DAY_OF_MONTH, 1); | ||
|
||
for(int i =0;i<31;i++){ | ||
labels.put(fmt.format(cal.getTime())); | ||
orderData.put(orders.get(i)); | ||
priceData.put(payments.get(i)); | ||
cal.add(Calendar.DAY_OF_MONTH, 1); | ||
} | ||
|
||
JSONArray datasets = new JSONArray(); | ||
JSONObject dataPrice = new JSONObject(); | ||
JSONObject dataOrder = new JSONObject(); | ||
|
||
dataPrice.put("data", priceData); | ||
dataOrder.put("data", orderData); | ||
|
||
datasets.put(dataPrice); | ||
datasets.put(dataOrder); | ||
|
||
JSONObject mainData = new JSONObject(); | ||
mainData.put("datasets", datasets); | ||
mainData.put("labels", labels); | ||
timeseries.put("data ", mainData); | ||
return timeseries; | ||
} | ||
} |
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 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans xmlns="http://www.springframework.org/schema/beans" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" | ||
xmlns:p="http://www.springframework.org/schema/p" xmlns:mvc="http://www.springframework.org/schema/mvc" | ||
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:security="http://www.springframework.org/schema/security" | ||
xmlns:util="http://www.springframework.org/schema/util" | ||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd | ||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd | ||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd | ||
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd | ||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> | ||
|
||
|
||
<context:component-scan base-package="org.entando.training" /> | ||
|
||
|
||
<bean id="entandoInterceptor" | ||
class="org.entando.entando.web.common.interceptor.EntandoOauth2Interceptor" /> | ||
<bean id="activityStreamInterceptor" | ||
class="org.entando.entando.web.common.interceptor.ActivityStreamInterceptor" /> | ||
|
||
<mvc:interceptors> | ||
<ref bean="entandoInterceptor" /> | ||
<ref bean="activityStreamInterceptor" /> | ||
</mvc:interceptors> | ||
|
||
</beans> |
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.