aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/.classpath1
-rw-r--r--api/src/main/java/market/guess/InputProvider.java5
-rw-r--r--api/src/main/java/market/guess/InputProviderFactory.java5
-rw-r--r--api/src/main/java/market/guess/OutputProvider.java7
-rw-r--r--api/src/main/java/market/guess/OutputProviderFactory.java5
-rw-r--r--api/src/main/java/market/guess/api/EventDTO.java8
-rw-r--r--api/src/main/java/market/guess/api/GuessMarketContext.java18
-rw-r--r--api/src/main/java/market/guess/api/GuessMarketEngine.java7
-rw-r--r--engine/.classpath7
-rw-r--r--engine/.project4
-rw-r--r--engine/src/main/java/market/guess/engine/GuessMarketEngine.java7
-rw-r--r--engine/src/main/java/market/guess/engine/LocalGuessMarketService.java6
-rw-r--r--engine/src/main/java/market/guess/engine/mechanism/LmsrTradingMechanism.java5
-rw-r--r--engine/src/main/java/market/guess/engine/model/Comision.java94
-rw-r--r--engine/src/main/java/market/guess/engine/model/GMEvent.java215
-rw-r--r--engine/src/main/java/market/guess/engine/model/GMEvents.java80
-rw-r--r--engine/src/main/java/market/guess/engine/model/GMLMSR.java60
-rw-r--r--engine/src/main/java/market/guess/engine/model/GMMethod.java70
-rw-r--r--engine/src/main/java/market/guess/engine/model/GMOptions.java80
-rw-r--r--engine/src/main/java/market/guess/engine/model/GuessMarket.java70
-rw-r--r--engine/src/main/java/market/guess/engine/model/ObjectFactory.java167
-rw-r--r--engine/src/main/java/market/guess/engine/provider/GuessMarketContext.java17
-rw-r--r--engine/src/main/java/market/guess/engine/provider/LocalGuessMarketContext.java81
-rw-r--r--lib/pico/picocontainer-2.15.2.jarbin0 -> 335842 bytes
-rw-r--r--ui-console/.classpath2
-rw-r--r--ui-console/.project3
-rw-r--r--ui-console/src/main/java/market/guess/ui/console/App.java26
-rw-r--r--ui-console/src/main/java/market/guess/ui/console/ConsoleInputProvider.java22
-rw-r--r--ui-console/src/main/java/market/guess/ui/console/ConsoleInputProviderFactory.java12
-rw-r--r--ui-console/src/main/java/market/guess/ui/console/ConsoleOutputProvider.java16
-rw-r--r--ui-console/src/main/java/market/guess/ui/console/ConsoleOutputProviderFactory.java12
-rw-r--r--ui-console/src/main/java/market/guess/ui/console/Menu.java34
32 files changed, 1115 insertions, 31 deletions
diff --git a/api/.classpath b/api/.classpath
index 0e305bc..ec2bc02 100644
--- a/api/.classpath
+++ b/api/.classpath
@@ -1,6 +1,5 @@
1<?xml version="1.0" encoding="UTF-8"?> 1<?xml version="1.0" encoding="UTF-8"?>
2<classpath> 2<classpath>
3 <!-- Defines your source folder -->
4 <classpathentry kind="src" output="bin/classes" path="src/main/java"/> 3 <classpathentry kind="src" output="bin/classes" path="src/main/java"/>
5 <classpathentry kind="src" output="bin/test-classes" path="src/test/java"> 4 <classpathentry kind="src" output="bin/test-classes" path="src/test/java">
6 <attributes> 5 <attributes>
diff --git a/api/src/main/java/market/guess/InputProvider.java b/api/src/main/java/market/guess/InputProvider.java
new file mode 100644
index 0000000..be7372b
--- /dev/null
+++ b/api/src/main/java/market/guess/InputProvider.java
@@ -0,0 +1,5 @@
1package market.guess;
2
3public interface InputProvider extends AutoCloseable {
4 int nextInt();
5}
diff --git a/api/src/main/java/market/guess/InputProviderFactory.java b/api/src/main/java/market/guess/InputProviderFactory.java
new file mode 100644
index 0000000..6801103
--- /dev/null
+++ b/api/src/main/java/market/guess/InputProviderFactory.java
@@ -0,0 +1,5 @@
1package market.guess;
2
3public interface InputProviderFactory {
4 InputProvider create();
5}
diff --git a/api/src/main/java/market/guess/OutputProvider.java b/api/src/main/java/market/guess/OutputProvider.java
new file mode 100644
index 0000000..774408e
--- /dev/null
+++ b/api/src/main/java/market/guess/OutputProvider.java
@@ -0,0 +1,7 @@
1package market.guess;
2
3public interface OutputProvider {
4 void print(Object object);
5
6 void println(Object object);
7}
diff --git a/api/src/main/java/market/guess/OutputProviderFactory.java b/api/src/main/java/market/guess/OutputProviderFactory.java
new file mode 100644
index 0000000..b4eb7f5
--- /dev/null
+++ b/api/src/main/java/market/guess/OutputProviderFactory.java
@@ -0,0 +1,5 @@
1package market.guess;
2
3public interface OutputProviderFactory {
4 OutputProvider create();
5}
diff --git a/api/src/main/java/market/guess/api/EventDTO.java b/api/src/main/java/market/guess/api/EventDTO.java
index 66b2312..2b2bc63 100644
--- a/api/src/main/java/market/guess/api/EventDTO.java
+++ b/api/src/main/java/market/guess/api/EventDTO.java
@@ -1 +1,9 @@
1package market.guess.api; 1package market.guess.api;
2
3public record EventDTO(
4 int id,
5 String name,
6 String description,
7 int commission,
8 CommissionChargeType commissionChargeType,
9 EventStatus status) {}
diff --git a/api/src/main/java/market/guess/api/GuessMarketContext.java b/api/src/main/java/market/guess/api/GuessMarketContext.java
new file mode 100644
index 0000000..12ffbeb
--- /dev/null
+++ b/api/src/main/java/market/guess/api/GuessMarketContext.java
@@ -0,0 +1,18 @@
1package market.guess.api;
2
3import java.util.List;
4import java.util.concurrent.CompletableFuture;
5
6public interface GuessMarketContext {
7 CompletableFuture<LoadResultDTO> LoadAsync();
8
9 void SaveChangesAsync();
10
11 List<EventDTO> GetAllEventsAsync();
12
13 void GetEventInfoByIdAsync();
14
15 void CreateEventAsync();
16
17 void UpdateEventAsync();
18}
diff --git a/api/src/main/java/market/guess/api/GuessMarketEngine.java b/api/src/main/java/market/guess/api/GuessMarketEngine.java
new file mode 100644
index 0000000..b6d44a4
--- /dev/null
+++ b/api/src/main/java/market/guess/api/GuessMarketEngine.java
@@ -0,0 +1,7 @@
1package market.guess.api;
2
3import java.util.concurrent.CompletableFuture;
4
5public interface GuessMarketEngine {
6 CompletableFuture<LoadResultDTO> loadEvents();
7}
diff --git a/engine/.classpath b/engine/.classpath
index df0a2ce..8bbb374 100644
--- a/engine/.classpath
+++ b/engine/.classpath
@@ -12,6 +12,13 @@
12 </attributes> 12 </attributes>
13 </classpathentry> 13 </classpathentry>
14 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> 14 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
15 <classpathentry kind="lib" path="../lib/jaxb/angus-activation.jar"/>
16 <classpathentry kind="lib" path="../lib/jaxb/jakarta.activation-api.jar"/>
17 <classpathentry kind="lib" path="../lib/jaxb/jaxb-core.jar"/>
18 <classpathentry kind="lib" path="../lib/jaxb/jaxb-impl.jar"/>
19 <classpathentry kind="lib" path="../lib/jaxb/jaxb-xjc.jar"/>
20 <classpathentry kind="lib" path="../lib/jaxb/jakarta.xml.bind-api.jar"/>
21 <classpathentry kind="lib" path="../lib/jaxb/jaxb-jxc.jar"/>
15 <classpathentry kind="lib" path="../lib/junit/junit-platform-console-standalone-6.1.1.jar"/> 22 <classpathentry kind="lib" path="../lib/junit/junit-platform-console-standalone-6.1.1.jar"/>
16 <classpathentry kind="output" path="bin"/> 23 <classpathentry kind="output" path="bin"/>
17</classpath> 24</classpath>
diff --git a/engine/.project b/engine/.project
index 943db42..df93b30 100644
--- a/engine/.project
+++ b/engine/.project
@@ -1,9 +1,9 @@
1<?xml version="1.0" encoding="UTF-8"?> 1<?xml version="1.0" encoding="UTF-8"?>
2<projectDescription> 2<projectDescription>
3 <name>gauss-market-engine</name> 3 <name>guess-market-engine</name>
4 <comment></comment> 4 <comment></comment>
5 <projects> 5 <projects>
6 <project>gauss-market-api</project> 6 <project>guess-market-api</project>
7 </projects> 7 </projects>
8 <buildSpec> 8 <buildSpec>
9 <buildCommand> 9 <buildCommand>
diff --git a/engine/src/main/java/market/guess/engine/GuessMarketEngine.java b/engine/src/main/java/market/guess/engine/GuessMarketEngine.java
deleted file mode 100644
index aab3cf4..0000000
--- a/engine/src/main/java/market/guess/engine/GuessMarketEngine.java
+++ /dev/null
@@ -1,7 +0,0 @@
1package market.guess.engine;
2
3import market.guess.api.LoadResultDTO;
4
5public interface GuessMarketEngine {
6 LoadResultDTO loadEvents();
7}
diff --git a/engine/src/main/java/market/guess/engine/LocalGuessMarketService.java b/engine/src/main/java/market/guess/engine/LocalGuessMarketService.java
index 5a16750..dafbef6 100644
--- a/engine/src/main/java/market/guess/engine/LocalGuessMarketService.java
+++ b/engine/src/main/java/market/guess/engine/LocalGuessMarketService.java
@@ -1,7 +1,9 @@
1package market.guess.engine; 1package market.guess.engine;
2 2
3import java.util.concurrent.CompletableFuture;
4import market.guess.api.GuessMarketContext;
5import market.guess.api.GuessMarketEngine;
3import market.guess.api.LoadResultDTO; 6import market.guess.api.LoadResultDTO;
4import market.guess.engine.provider.GuessMarketContext;
5 7
6public class LocalGuessMarketService implements GuessMarketEngine { 8public class LocalGuessMarketService implements GuessMarketEngine {
7 private final GuessMarketContext context; 9 private final GuessMarketContext context;
@@ -12,7 +14,7 @@ public class LocalGuessMarketService implements GuessMarketEngine {
12 } 14 }
13 15
14 @Override 16 @Override
15 public LoadResultDTO loadEvents() { 17 public CompletableFuture<LoadResultDTO> loadEvents() {
16 return context.LoadAsync(); 18 return context.LoadAsync();
17 } 19 }
18} 20}
diff --git a/engine/src/main/java/market/guess/engine/mechanism/LmsrTradingMechanism.java b/engine/src/main/java/market/guess/engine/mechanism/LmsrTradingMechanism.java
index 99a26ab..50a6fd1 100644
--- a/engine/src/main/java/market/guess/engine/mechanism/LmsrTradingMechanism.java
+++ b/engine/src/main/java/market/guess/engine/mechanism/LmsrTradingMechanism.java
@@ -34,4 +34,9 @@ public class LmsrTradingMechanism implements TradingMechanism {
34 // TODO Auto-generated method stub 34 // TODO Auto-generated method stub
35 throw new UnsupportedOperationException("Unimplemented method 'settle'"); 35 throw new UnsupportedOperationException("Unimplemented method 'settle'");
36 } 36 }
37
38 private BigDecimal getCost(int yayBuys, int nayBuys) {
39 return BigDecimal.valueOf(
40 10.0 * Math.log(Math.pow(Math.E, yayBuys / 10.0) + Math.pow(Math.E, nayBuys / 10.0)));
41 }
37} 42}
diff --git a/engine/src/main/java/market/guess/engine/model/Comision.java b/engine/src/main/java/market/guess/engine/model/Comision.java
new file mode 100644
index 0000000..05b4b7b
--- /dev/null
+++ b/engine/src/main/java/market/guess/engine/model/Comision.java
@@ -0,0 +1,94 @@
1//
2// This file was generated by the Eclipse Implementation of JAXB, v4.0.5
3// See https://eclipse-ee4j.github.io/jaxb-ri
4// Any modifications to this file will be lost upon recompilation of the source schema.
5//
6
7
8package market.guess.engine.model;
9
10import jakarta.xml.bind.annotation.XmlAccessType;
11import jakarta.xml.bind.annotation.XmlAccessorType;
12import jakarta.xml.bind.annotation.XmlAttribute;
13import jakarta.xml.bind.annotation.XmlRootElement;
14import jakarta.xml.bind.annotation.XmlType;
15import jakarta.xml.bind.annotation.XmlValue;
16
17
18/**
19 * <p>Java class for anonymous complex type</p>.
20 *
21 * <p>The following schema fragment specifies the expected content contained within this class.</p>
22 *
23 * <pre>{@code
24 * <complexType>
25 * <simpleContent>
26 * <extension base="<http://www.w3.org/2001/XMLSchema>int">
27 * <attribute name="type" use="required">
28 * <simpleType>
29 * <restriction base="{http://www.w3.org/2001/XMLSchema}string">
30 * <enumeration value="on-close"/>
31 * <enumeration value="on-purchase"/>
32 * </restriction>
33 * </simpleType>
34 * </attribute>
35 * </extension>
36 * </simpleContent>
37 * </complexType>
38 * }</pre>
39 *
40 *
41 */
42@XmlAccessorType(XmlAccessType.FIELD)
43@XmlType(name = "", propOrder = {
44 "value"
45})
46@XmlRootElement(name = "comision")
47public class Comision {
48
49 @XmlValue
50 protected int value;
51 @XmlAttribute(name = "type", required = true)
52 protected String type;
53
54 /**
55 * Gets the value of the value property.
56 *
57 */
58 public int getValue() {
59 return value;
60 }
61
62 /**
63 * Sets the value of the value property.
64 *
65 */
66 public void setValue(int value) {
67 this.value = value;
68 }
69
70 /**
71 * Gets the value of the type property.
72 *
73 * @return
74 * possible object is
75 * {@link String }
76 *
77 */
78 public String getType() {
79 return type;
80 }
81
82 /**
83 * Sets the value of the type property.
84 *
85 * @param value
86 * allowed object is
87 * {@link String }
88 *
89 */
90 public void setType(String value) {
91 this.type = value;
92 }
93
94}
diff --git a/engine/src/main/java/market/guess/engine/model/GMEvent.java b/engine/src/main/java/market/guess/engine/model/GMEvent.java
new file mode 100644
index 0000000..9f109d6
--- /dev/null
+++ b/engine/src/main/java/market/guess/engine/model/GMEvent.java
@@ -0,0 +1,215 @@
1//
2// This file was generated by the Eclipse Implementation of JAXB, v4.0.5
3// See https://eclipse-ee4j.github.io/jaxb-ri
4// Any modifications to this file will be lost upon recompilation of the source schema.
5//
6
7
8package market.guess.engine.model;
9
10import java.util.ArrayList;
11import java.util.List;
12import jakarta.xml.bind.annotation.XmlAccessType;
13import jakarta.xml.bind.annotation.XmlAccessorType;
14import jakarta.xml.bind.annotation.XmlAttribute;
15import jakarta.xml.bind.annotation.XmlElement;
16import jakarta.xml.bind.annotation.XmlRootElement;
17import jakarta.xml.bind.annotation.XmlType;
18
19
20/**
21 * <p>Java class for anonymous complex type</p>.
22 *
23 * <p>The following schema fragment specifies the expected content contained within this class.</p>
24 *
25 * <pre>{@code
26 * <complexType>
27 * <complexContent>
28 * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
29 * <sequence>
30 * <element ref="{}id"/>
31 * <element ref="{}description"/>
32 * <element ref="{}comision"/>
33 * <element ref="{}GM-options"/>
34 * <element ref="{}GM-method"/>
35 * </sequence>
36 * <attribute name="name" use="required">
37 * <simpleType>
38 * <list itemType="{http://www.w3.org/2001/XMLSchema}string" />
39 * </simpleType>
40 * </attribute>
41 * </restriction>
42 * </complexContent>
43 * </complexType>
44 * }</pre>
45 *
46 *
47 */
48@XmlAccessorType(XmlAccessType.FIELD)
49@XmlType(name = "", propOrder = {
50 "id",
51 "description",
52 "comision",
53 "gmOptions",
54 "gmMethod"
55})
56@XmlRootElement(name = "GM-event")
57public class GMEvent {
58
59 protected int id;
60 @XmlElement(required = true)
61 protected String description;
62 @XmlElement(required = true)
63 protected Comision comision;
64 @XmlElement(name = "GM-options", required = true)
65 protected GMOptions gmOptions;
66 @XmlElement(name = "GM-method", required = true)
67 protected GMMethod gmMethod;
68 @XmlAttribute(name = "name", required = true)
69 protected List<String> name;
70
71 /**
72 * Gets the value of the id property.
73 *
74 */
75 public int getId() {
76 return id;
77 }
78
79 /**
80 * Sets the value of the id property.
81 *
82 */
83 public void setId(int value) {
84 this.id = value;
85 }
86
87 /**
88 * Gets the value of the description property.
89 *
90 * @return
91 * possible object is
92 * {@link String }
93 *
94 */
95 public String getDescription() {
96 return description;
97 }
98
99 /**
100 * Sets the value of the description property.
101 *
102 * @param value
103 * allowed object is
104 * {@link String }
105 *
106 */
107 public void setDescription(String value) {
108 this.description = value;
109 }
110
111 /**
112 * Gets the value of the comision property.
113 *
114 * @return
115 * possible object is
116 * {@link Comision }
117 *
118 */
119 public Comision getComision() {
120 return comision;
121 }
122
123 /**
124 * Sets the value of the comision property.
125 *
126 * @param value
127 * allowed object is
128 * {@link Comision }
129 *
130 */
131 public void setComision(Comision value) {
132 this.comision = value;
133 }
134
135 /**
136 * Gets the value of the gmOptions property.
137 *
138 * @return
139 * possible object is
140 * {@link GMOptions }
141 *
142 */
143 public GMOptions getGMOptions() {
144 return gmOptions;
145 }
146
147 /**
148 * Sets the value of the gmOptions property.
149 *
150 * @param value
151 * allowed object is
152 * {@link GMOptions }
153 *
154 */
155 public void setGMOptions(GMOptions value) {
156 this.gmOptions = value;
157 }
158
159 /**
160 * Gets the value of the gmMethod property.
161 *
162 * @return
163 * possible object is
164 * {@link GMMethod }
165 *
166 */
167 public GMMethod getGMMethod() {
168 return gmMethod;
169 }
170
171 /**
172 * Sets the value of the gmMethod property.
173 *
174 * @param value
175 * allowed object is
176 * {@link GMMethod }
177 *
178 */
179 public void setGMMethod(GMMethod value) {
180 this.gmMethod = value;
181 }
182
183 /**
184 * Gets the value of the name property.
185 *
186 * <p>This accessor method returns a reference to the live list,
187 * not a snapshot. Therefore any modification you make to the
188 * returned list will be present inside the JAXB object.
189 * This is why there is not a <CODE>set</CODE> method for the name property.</p>
190 *
191 * <p>
192 * For example, to add a new item, do as follows:
193 * </p>
194 * <pre>
195 * getName().add(newItem);
196 * </pre>
197 *
198 *
199 * <p>
200 * Objects of the following type(s) are allowed in the list
201 * {@link String }
202 * </p>
203 *
204 *
205 * @return
206 * The value of the name property.
207 */
208 public List<String> getName() {
209 if (name == null) {
210 name = new ArrayList<>();
211 }
212 return this.name;
213 }
214
215}
diff --git a/engine/src/main/java/market/guess/engine/model/GMEvents.java b/engine/src/main/java/market/guess/engine/model/GMEvents.java
new file mode 100644
index 0000000..b40ff0c
--- /dev/null
+++ b/engine/src/main/java/market/guess/engine/model/GMEvents.java
@@ -0,0 +1,80 @@
1//
2// This file was generated by the Eclipse Implementation of JAXB, v4.0.5
3// See https://eclipse-ee4j.github.io/jaxb-ri
4// Any modifications to this file will be lost upon recompilation of the source schema.
5//
6
7
8package market.guess.engine.model;
9
10import java.util.ArrayList;
11import java.util.List;
12import jakarta.xml.bind.annotation.XmlAccessType;
13import jakarta.xml.bind.annotation.XmlAccessorType;
14import jakarta.xml.bind.annotation.XmlElement;
15import jakarta.xml.bind.annotation.XmlRootElement;
16import jakarta.xml.bind.annotation.XmlType;
17
18
19/**
20 * <p>Java class for anonymous complex type</p>.
21 *
22 * <p>The following schema fragment specifies the expected content contained within this class.</p>
23 *
24 * <pre>{@code
25 * <complexType>
26 * <complexContent>
27 * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
28 * <sequence>
29 * <element ref="{}GM-event" maxOccurs="unbounded"/>
30 * </sequence>
31 * </restriction>
32 * </complexContent>
33 * </complexType>
34 * }</pre>
35 *
36 *
37 */
38@XmlAccessorType(XmlAccessType.FIELD)
39@XmlType(name = "", propOrder = {
40 "gmEvent"
41})
42@XmlRootElement(name = "GM-events")
43public class GMEvents {
44
45 @XmlElement(name = "GM-event", required = true)
46 protected List<GMEvent> gmEvent;
47
48 /**
49 * Gets the value of the gmEvent property.
50 *
51 * <p>This accessor method returns a reference to the live list,
52 * not a snapshot. Therefore any modification you make to the
53 * returned list will be present inside the JAXB object.
54 * This is why there is not a <CODE>set</CODE> method for the gmEvent property.</p>
55 *
56 * <p>
57 * For example, to add a new item, do as follows:
58 * </p>
59 * <pre>
60 * getGMEvent().add(newItem);
61 * </pre>
62 *
63 *
64 * <p>
65 * Objects of the following type(s) are allowed in the list
66 * {@link GMEvent }
67 * </p>
68 *
69 *
70 * @return
71 * The value of the gmEvent property.
72 */
73 public List<GMEvent> getGMEvent() {
74 if (gmEvent == null) {
75 gmEvent = new ArrayList<>();
76 }
77 return this.gmEvent;
78 }
79
80}
diff --git a/engine/src/main/java/market/guess/engine/model/GMLMSR.java b/engine/src/main/java/market/guess/engine/model/GMLMSR.java
new file mode 100644
index 0000000..1f8eb45
--- /dev/null
+++ b/engine/src/main/java/market/guess/engine/model/GMLMSR.java
@@ -0,0 +1,60 @@
1//
2// This file was generated by the Eclipse Implementation of JAXB, v4.0.5
3// See https://eclipse-ee4j.github.io/jaxb-ri
4// Any modifications to this file will be lost upon recompilation of the source schema.
5//
6
7
8package market.guess.engine.model;
9
10import jakarta.xml.bind.annotation.XmlAccessType;
11import jakarta.xml.bind.annotation.XmlAccessorType;
12import jakarta.xml.bind.annotation.XmlRootElement;
13import jakarta.xml.bind.annotation.XmlType;
14
15
16/**
17 * <p>Java class for anonymous complex type</p>.
18 *
19 * <p>The following schema fragment specifies the expected content contained within this class.</p>
20 *
21 * <pre>{@code
22 * <complexType>
23 * <complexContent>
24 * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
25 * <sequence>
26 * <element ref="{}b"/>
27 * </sequence>
28 * </restriction>
29 * </complexContent>
30 * </complexType>
31 * }</pre>
32 *
33 *
34 */
35@XmlAccessorType(XmlAccessType.FIELD)
36@XmlType(name = "", propOrder = {
37 "b"
38})
39@XmlRootElement(name = "GM-LMSR")
40public class GMLMSR {
41
42 protected int b;
43
44 /**
45 * Gets the value of the b property.
46 *
47 */
48 public int getB() {
49 return b;
50 }
51
52 /**
53 * Sets the value of the b property.
54 *
55 */
56 public void setB(int value) {
57 this.b = value;
58 }
59
60}
diff --git a/engine/src/main/java/market/guess/engine/model/GMMethod.java b/engine/src/main/java/market/guess/engine/model/GMMethod.java
new file mode 100644
index 0000000..4841af9
--- /dev/null
+++ b/engine/src/main/java/market/guess/engine/model/GMMethod.java
@@ -0,0 +1,70 @@
1//
2// This file was generated by the Eclipse Implementation of JAXB, v4.0.5
3// See https://eclipse-ee4j.github.io/jaxb-ri
4// Any modifications to this file will be lost upon recompilation of the source schema.
5//
6
7
8package market.guess.engine.model;
9
10import jakarta.xml.bind.annotation.XmlAccessType;
11import jakarta.xml.bind.annotation.XmlAccessorType;
12import jakarta.xml.bind.annotation.XmlElement;
13import jakarta.xml.bind.annotation.XmlRootElement;
14import jakarta.xml.bind.annotation.XmlType;
15
16
17/**
18 * <p>Java class for anonymous complex type</p>.
19 *
20 * <p>The following schema fragment specifies the expected content contained within this class.</p>
21 *
22 * <pre>{@code
23 * <complexType>
24 * <complexContent>
25 * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
26 * <sequence>
27 * <element ref="{}GM-LMSR"/>
28 * </sequence>
29 * </restriction>
30 * </complexContent>
31 * </complexType>
32 * }</pre>
33 *
34 *
35 */
36@XmlAccessorType(XmlAccessType.FIELD)
37@XmlType(name = "", propOrder = {
38 "gmlmsr"
39})
40@XmlRootElement(name = "GM-method")
41public class GMMethod {
42
43 @XmlElement(name = "GM-LMSR", required = true)
44 protected GMLMSR gmlmsr;
45
46 /**
47 * Gets the value of the gmlmsr property.
48 *
49 * @return
50 * possible object is
51 * {@link GMLMSR }
52 *
53 */
54 public GMLMSR getGMLMSR() {
55 return gmlmsr;
56 }
57
58 /**
59 * Sets the value of the gmlmsr property.
60 *
61 * @param value
62 * allowed object is
63 * {@link GMLMSR }
64 *
65 */
66 public void setGMLMSR(GMLMSR value) {
67 this.gmlmsr = value;
68 }
69
70}
diff --git a/engine/src/main/java/market/guess/engine/model/GMOptions.java b/engine/src/main/java/market/guess/engine/model/GMOptions.java
new file mode 100644
index 0000000..666e57a
--- /dev/null
+++ b/engine/src/main/java/market/guess/engine/model/GMOptions.java
@@ -0,0 +1,80 @@
1//
2// This file was generated by the Eclipse Implementation of JAXB, v4.0.5
3// See https://eclipse-ee4j.github.io/jaxb-ri
4// Any modifications to this file will be lost upon recompilation of the source schema.
5//
6
7
8package market.guess.engine.model;
9
10import java.util.ArrayList;
11import java.util.List;
12import jakarta.xml.bind.annotation.XmlAccessType;
13import jakarta.xml.bind.annotation.XmlAccessorType;
14import jakarta.xml.bind.annotation.XmlElement;
15import jakarta.xml.bind.annotation.XmlRootElement;
16import jakarta.xml.bind.annotation.XmlType;
17
18
19/**
20 * <p>Java class for anonymous complex type</p>.
21 *
22 * <p>The following schema fragment specifies the expected content contained within this class.</p>
23 *
24 * <pre>{@code
25 * <complexType>
26 * <complexContent>
27 * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
28 * <sequence>
29 * <element ref="{}GM-option" maxOccurs="2"/>
30 * </sequence>
31 * </restriction>
32 * </complexContent>
33 * </complexType>
34 * }</pre>
35 *
36 *
37 */
38@XmlAccessorType(XmlAccessType.FIELD)
39@XmlType(name = "", propOrder = {
40 "gmOption"
41})
42@XmlRootElement(name = "GM-options")
43public class GMOptions {
44
45 @XmlElement(name = "GM-option", required = true)
46 protected List<String> gmOption;
47
48 /**
49 * Gets the value of the gmOption property.
50 *
51 * <p>This accessor method returns a reference to the live list,
52 * not a snapshot. Therefore any modification you make to the
53 * returned list will be present inside the JAXB object.
54 * This is why there is not a <CODE>set</CODE> method for the gmOption property.</p>
55 *
56 * <p>
57 * For example, to add a new item, do as follows:
58 * </p>
59 * <pre>
60 * getGMOption().add(newItem);
61 * </pre>
62 *
63 *
64 * <p>
65 * Objects of the following type(s) are allowed in the list
66 * {@link String }
67 * </p>
68 *
69 *
70 * @return
71 * The value of the gmOption property.
72 */
73 public List<String> getGMOption() {
74 if (gmOption == null) {
75 gmOption = new ArrayList<>();
76 }
77 return this.gmOption;
78 }
79
80}
diff --git a/engine/src/main/java/market/guess/engine/model/GuessMarket.java b/engine/src/main/java/market/guess/engine/model/GuessMarket.java
new file mode 100644
index 0000000..983b306
--- /dev/null
+++ b/engine/src/main/java/market/guess/engine/model/GuessMarket.java
@@ -0,0 +1,70 @@
1//
2// This file was generated by the Eclipse Implementation of JAXB, v4.0.5
3// See https://eclipse-ee4j.github.io/jaxb-ri
4// Any modifications to this file will be lost upon recompilation of the source schema.
5//
6
7
8package market.guess.engine.model;
9
10import jakarta.xml.bind.annotation.XmlAccessType;
11import jakarta.xml.bind.annotation.XmlAccessorType;
12import jakarta.xml.bind.annotation.XmlElement;
13import jakarta.xml.bind.annotation.XmlRootElement;
14import jakarta.xml.bind.annotation.XmlType;
15
16
17/**
18 * <p>Java class for anonymous complex type</p>.
19 *
20 * <p>The following schema fragment specifies the expected content contained within this class.</p>
21 *
22 * <pre>{@code
23 * <complexType>
24 * <complexContent>
25 * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
26 * <sequence>
27 * <element ref="{}GM-events"/>
28 * </sequence>
29 * </restriction>
30 * </complexContent>
31 * </complexType>
32 * }</pre>
33 *
34 *
35 */
36@XmlAccessorType(XmlAccessType.FIELD)
37@XmlType(name = "", propOrder = {
38 "gmEvents"
39})
40@XmlRootElement(name = "Guess-Market")
41public class GuessMarket {
42
43 @XmlElement(name = "GM-events", required = true)
44 protected GMEvents gmEvents;
45
46 /**
47 * Gets the value of the gmEvents property.
48 *
49 * @return
50 * possible object is
51 * {@link GMEvents }
52 *
53 */
54 public GMEvents getGMEvents() {
55 return gmEvents;
56 }
57
58 /**
59 * Sets the value of the gmEvents property.
60 *
61 * @param value
62 * allowed object is
63 * {@link GMEvents }
64 *
65 */
66 public void setGMEvents(GMEvents value) {
67 this.gmEvents = value;
68 }
69
70}
diff --git a/engine/src/main/java/market/guess/engine/model/ObjectFactory.java b/engine/src/main/java/market/guess/engine/model/ObjectFactory.java
new file mode 100644
index 0000000..b2a403a
--- /dev/null
+++ b/engine/src/main/java/market/guess/engine/model/ObjectFactory.java
@@ -0,0 +1,167 @@
1//
2// This file was generated by the Eclipse Implementation of JAXB, v4.0.5
3// See https://eclipse-ee4j.github.io/jaxb-ri
4// Any modifications to this file will be lost upon recompilation of the source schema.
5//
6
7
8package market.guess.engine.model;
9
10import javax.xml.namespace.QName;
11import jakarta.xml.bind.JAXBElement;
12import jakarta.xml.bind.annotation.XmlElementDecl;
13import jakarta.xml.bind.annotation.XmlRegistry;
14
15
16/**
17 * This object contains factory methods for each
18 * Java content interface and Java element interface
19 * generated in the market.guess.engine.model package.
20 * <p>An ObjectFactory allows you to programmatically
21 * construct new instances of the Java representation
22 * for XML content. The Java representation of XML
23 * content can consist of schema derived interfaces
24 * and classes representing the binding of schema
25 * type definitions, element declarations and model
26 * groups. Factory methods for each of these are
27 * provided in this class.
28 *
29 */
30@XmlRegistry
31public class ObjectFactory {
32
33 private static final QName _Id_QNAME = new QName("", "id");
34 private static final QName _Description_QNAME = new QName("", "description");
35 private static final QName _B_QNAME = new QName("", "b");
36 private static final QName _GMOption_QNAME = new QName("", "GM-option");
37
38 /**
39 * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: market.guess.engine.model
40 *
41 */
42 public ObjectFactory() {
43 }
44
45 /**
46 * Create an instance of {@link Comision }
47 *
48 * @return
49 * the new instance of {@link Comision }
50 */
51 public Comision createComision() {
52 return new Comision();
53 }
54
55 /**
56 * Create an instance of {@link GuessMarket }
57 *
58 * @return
59 * the new instance of {@link GuessMarket }
60 */
61 public GuessMarket createGuessMarket() {
62 return new GuessMarket();
63 }
64
65 /**
66 * Create an instance of {@link GMEvents }
67 *
68 * @return
69 * the new instance of {@link GMEvents }
70 */
71 public GMEvents createGMEvents() {
72 return new GMEvents();
73 }
74
75 /**
76 * Create an instance of {@link GMEvent }
77 *
78 * @return
79 * the new instance of {@link GMEvent }
80 */
81 public GMEvent createGMEvent() {
82 return new GMEvent();
83 }
84
85 /**
86 * Create an instance of {@link GMOptions }
87 *
88 * @return
89 * the new instance of {@link GMOptions }
90 */
91 public GMOptions createGMOptions() {
92 return new GMOptions();
93 }
94
95 /**
96 * Create an instance of {@link GMMethod }
97 *
98 * @return
99 * the new instance of {@link GMMethod }
100 */
101 public GMMethod createGMMethod() {
102 return new GMMethod();
103 }
104
105 /**
106 * Create an instance of {@link GMLMSR }
107 *
108 * @return
109 * the new instance of {@link GMLMSR }
110 */
111 public GMLMSR createGMLMSR() {
112 return new GMLMSR();
113 }
114
115 /**
116 * Create an instance of {@link JAXBElement }{@code <}{@link Integer }{@code >}
117 *
118 * @param value
119 * Java instance representing xml element's value.
120 * @return
121 * the new instance of {@link JAXBElement }{@code <}{@link Integer }{@code >}
122 */
123 @XmlElementDecl(namespace = "", name = "id")
124 public JAXBElement<Integer> createId(Integer value) {
125 return new JAXBElement<>(_Id_QNAME, Integer.class, null, value);
126 }
127
128 /**
129 * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}
130 *
131 * @param value
132 * Java instance representing xml element's value.
133 * @return
134 * the new instance of {@link JAXBElement }{@code <}{@link String }{@code >}
135 */
136 @XmlElementDecl(namespace = "", name = "description")
137 public JAXBElement<String> createDescription(String value) {
138 return new JAXBElement<>(_Description_QNAME, String.class, null, value);
139 }
140
141 /**
142 * Create an instance of {@link JAXBElement }{@code <}{@link Integer }{@code >}
143 *
144 * @param value
145 * Java instance representing xml element's value.
146 * @return
147 * the new instance of {@link JAXBElement }{@code <}{@link Integer }{@code >}
148 */
149 @XmlElementDecl(namespace = "", name = "b")
150 public JAXBElement<Integer> createB(Integer value) {
151 return new JAXBElement<>(_B_QNAME, Integer.class, null, value);
152 }
153
154 /**
155 * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}
156 *
157 * @param value
158 * Java instance representing xml element's value.
159 * @return
160 * the new instance of {@link JAXBElement }{@code <}{@link String }{@code >}
161 */
162 @XmlElementDecl(namespace = "", name = "GM-option")
163 public JAXBElement<String> createGMOption(String value) {
164 return new JAXBElement<>(_GMOption_QNAME, String.class, null, value);
165 }
166
167}
diff --git a/engine/src/main/java/market/guess/engine/provider/GuessMarketContext.java b/engine/src/main/java/market/guess/engine/provider/GuessMarketContext.java
deleted file mode 100644
index 2306c93..0000000
--- a/engine/src/main/java/market/guess/engine/provider/GuessMarketContext.java
+++ /dev/null
@@ -1,17 +0,0 @@
1package market.guess.engine.provider;
2
3import market.guess.api.LoadResultDTO;
4
5public interface GuessMarketContext {
6 LoadResultDTO LoadAsync();
7
8 void SaveChangesAsync();
9
10 void GetAllEventsAsync();
11
12 void GetEventInfoByIdAsync();
13
14 void CreateEventAsync();
15
16 void UpdateEventAsync();
17}
diff --git a/engine/src/main/java/market/guess/engine/provider/LocalGuessMarketContext.java b/engine/src/main/java/market/guess/engine/provider/LocalGuessMarketContext.java
new file mode 100644
index 0000000..628038d
--- /dev/null
+++ b/engine/src/main/java/market/guess/engine/provider/LocalGuessMarketContext.java
@@ -0,0 +1,81 @@
1package market.guess.engine.provider;
2
3import jakarta.xml.bind.JAXBContext;
4import jakarta.xml.bind.Marshaller;
5import java.io.File;
6import java.util.List;
7import java.util.concurrent.CompletableFuture;
8import market.guess.api.CommissionChargeType;
9import market.guess.api.EventDTO;
10import market.guess.api.EventStatus;
11import market.guess.api.GuessMarketContext;
12import market.guess.api.LoadResultDTO;
13import market.guess.engine.model.GuessMarket;
14
15public class LocalGuessMarketContext implements GuessMarketContext {
16 private GuessMarket context;
17
18 @Override
19 public CompletableFuture<LoadResultDTO> LoadAsync() {
20 try {
21 var file = new File("test-data/ex-1/multiple.xml");
22 var ctx = JAXBContext.newInstance(GuessMarket.class);
23 var unmarshaller = ctx.createUnmarshaller();
24
25 context = (GuessMarket) unmarshaller.unmarshal(file);
26
27 } catch (Exception e) {
28 e.printStackTrace();
29 }
30 return CompletableFuture.completedFuture(new LoadResultDTO());
31 }
32
33 @Override
34 public void SaveChangesAsync() {
35 try {
36
37 var ctx = JAXBContext.newInstance(GuessMarket.class);
38 var marshaller = ctx.createMarshaller();
39 marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
40
41 var file = new File("test-data/ex-1/output.xml");
42 marshaller.marshal(context, file);
43 } catch (Exception ex) {
44 ex.printStackTrace();
45 }
46 }
47
48 @Override
49 public List<EventDTO> GetAllEventsAsync() {
50 var events = context.getGMEvents();
51 return events.getGMEvent().stream()
52 .map(
53 o ->
54 new EventDTO(
55 o.getId(),
56 String.join(" ", o.getName()),
57 o.getDescription(),
58 o.getComision().getValue(),
59 CommissionChargeType.ON_CLOSE,
60 EventStatus.ACTIVE))
61 .toList();
62 }
63
64 @Override
65 public void GetEventInfoByIdAsync() {
66 // TODO Auto-generated method stub
67 throw new UnsupportedOperationException("Unimplemented method 'GetEventInfoByIdAsync'");
68 }
69
70 @Override
71 public void CreateEventAsync() {
72 // TODO Auto-generated method stub
73 throw new UnsupportedOperationException("Unimplemented method 'CreateEventAsync'");
74 }
75
76 @Override
77 public void UpdateEventAsync() {
78 // TODO Auto-generated method stub
79 throw new UnsupportedOperationException("Unimplemented method 'UpdateEventAsync'");
80 }
81}
diff --git a/lib/pico/picocontainer-2.15.2.jar b/lib/pico/picocontainer-2.15.2.jar
new file mode 100644
index 0000000..8b271ac
--- /dev/null
+++ b/lib/pico/picocontainer-2.15.2.jar
Binary files differ
diff --git a/ui-console/.classpath b/ui-console/.classpath
index ec2bc02..cfc0f9a 100644
--- a/ui-console/.classpath
+++ b/ui-console/.classpath
@@ -6,6 +6,8 @@
6 <attribute name="test" value="true"/> 6 <attribute name="test" value="true"/>
7 </attributes> 7 </attributes>
8 </classpathentry> 8 </classpathentry>
9 <classpathentry kind="src" path="/guess-market-api"/>
10 <classpathentry kind="lib" path="../lib/pico/picocontainer-2.15.2.jar"/>
9 <classpathentry kind="lib" path="../lib/junit/junit-platform-console-standalone-6.1.1.jar"/> 11 <classpathentry kind="lib" path="../lib/junit/junit-platform-console-standalone-6.1.1.jar"/>
10 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> 12 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
11 <classpathentry kind="output" path="bin"/> 13 <classpathentry kind="output" path="bin"/>
diff --git a/ui-console/.project b/ui-console/.project
index 9e047cb..d620a57 100644
--- a/ui-console/.project
+++ b/ui-console/.project
@@ -2,7 +2,8 @@
2<projectDescription> 2<projectDescription>
3 <name>guess-market-ui-console</name> 3 <name>guess-market-ui-console</name>
4 <comment></comment> 4 <comment></comment>
5 <projects> 5 <projects>
6 <project>guess-market-api</project>
6 </projects> 7 </projects>
7 <buildSpec> 8 <buildSpec>
8 <buildCommand> 9 <buildCommand>
diff --git a/ui-console/src/main/java/market/guess/ui/console/App.java b/ui-console/src/main/java/market/guess/ui/console/App.java
index 06be86d..5158478 100644
--- a/ui-console/src/main/java/market/guess/ui/console/App.java
+++ b/ui-console/src/main/java/market/guess/ui/console/App.java
@@ -1,7 +1,31 @@
1package market.guess.ui.console; 1package market.guess.ui.console;
2 2
3import org.picocontainer.DefaultPicoContainer;
4import org.picocontainer.behaviors.Caching;
5
3public class App { 6public class App {
4 public static void main() { 7 public static void main() {
5 IO.println("Hello World"); 8 var pico = new DefaultPicoContainer(new Caching());
9
10 pico.addComponent(ConsoleInputProviderFactory.class);
11 pico.addComponent(ConsoleOutputProviderFactory.class);
12 pico.addComponent(Menu.class);
13
14 pico.start();
15 // var context = new LocalGuessMarketContext();
16 // var factory = new ConsoleInputProviderFactory();
17 // var oFactory = new ConsoleOutputProviderFactory();
18 //
19 // context.LoadAsync();
20 // printMenu(oFactory.create());
21 //
22 // try (var provider = factory.create()) {
23 // var input = provider.nextInt();
24 // while (input != 0) {
25 // input = provider.nextInt();
26 // }
27 // } catch (Exception ex) {
28 // ex.printStackTrace();
29 //
6 } 30 }
7} 31}
diff --git a/ui-console/src/main/java/market/guess/ui/console/ConsoleInputProvider.java b/ui-console/src/main/java/market/guess/ui/console/ConsoleInputProvider.java
new file mode 100644
index 0000000..71de3be
--- /dev/null
+++ b/ui-console/src/main/java/market/guess/ui/console/ConsoleInputProvider.java
@@ -0,0 +1,22 @@
1package market.guess.ui.console;
2
3import java.util.Scanner;
4import market.guess.InputProvider;
5
6public class ConsoleInputProvider implements InputProvider {
7 private final Scanner scanner = new Scanner(System.in);
8
9 @Override
10 public int nextInt() {
11 while (!scanner.hasNextInt()) {
12 scanner.next();
13 }
14
15 return scanner.nextInt();
16 }
17
18 @Override
19 public void close() throws Exception {
20 scanner.close();
21 }
22}
diff --git a/ui-console/src/main/java/market/guess/ui/console/ConsoleInputProviderFactory.java b/ui-console/src/main/java/market/guess/ui/console/ConsoleInputProviderFactory.java
new file mode 100644
index 0000000..d122549
--- /dev/null
+++ b/ui-console/src/main/java/market/guess/ui/console/ConsoleInputProviderFactory.java
@@ -0,0 +1,12 @@
1package market.guess.ui.console;
2
3import market.guess.InputProvider;
4import market.guess.InputProviderFactory;
5
6public class ConsoleInputProviderFactory implements InputProviderFactory {
7
8 @Override
9 public InputProvider create() {
10 return new ConsoleInputProvider();
11 }
12}
diff --git a/ui-console/src/main/java/market/guess/ui/console/ConsoleOutputProvider.java b/ui-console/src/main/java/market/guess/ui/console/ConsoleOutputProvider.java
new file mode 100644
index 0000000..eb9f31b
--- /dev/null
+++ b/ui-console/src/main/java/market/guess/ui/console/ConsoleOutputProvider.java
@@ -0,0 +1,16 @@
1package market.guess.ui.console;
2
3import market.guess.OutputProvider;
4
5public class ConsoleOutputProvider implements OutputProvider {
6
7 @Override
8 public void print(Object object) {
9 IO.print(object);
10 }
11
12 @Override
13 public void println(Object object) {
14 IO.println(object);
15 }
16}
diff --git a/ui-console/src/main/java/market/guess/ui/console/ConsoleOutputProviderFactory.java b/ui-console/src/main/java/market/guess/ui/console/ConsoleOutputProviderFactory.java
new file mode 100644
index 0000000..6db91fc
--- /dev/null
+++ b/ui-console/src/main/java/market/guess/ui/console/ConsoleOutputProviderFactory.java
@@ -0,0 +1,12 @@
1package market.guess.ui.console;
2
3import market.guess.OutputProvider;
4import market.guess.OutputProviderFactory;
5
6public class ConsoleOutputProviderFactory implements OutputProviderFactory {
7
8 @Override
9 public OutputProvider create() {
10 return new ConsoleOutputProvider();
11 }
12}
diff --git a/ui-console/src/main/java/market/guess/ui/console/Menu.java b/ui-console/src/main/java/market/guess/ui/console/Menu.java
new file mode 100644
index 0000000..a5217a4
--- /dev/null
+++ b/ui-console/src/main/java/market/guess/ui/console/Menu.java
@@ -0,0 +1,34 @@
1package market.guess.ui.console;
2
3import market.guess.OutputProvider;
4import market.guess.OutputProviderFactory;
5import org.picocontainer.Startable;
6
7public class Menu implements Startable {
8 private final OutputProvider outputProvider;
9
10 public Menu(OutputProviderFactory factory) {
11 this.outputProvider = factory.create();
12 }
13
14 @Override
15 public void start() {
16 printMenu(outputProvider);
17 }
18
19 @Override
20 public void stop() {
21 // TODO Auto-generated method stub
22 throw new UnsupportedOperationException("Unimplemented method 'stop'");
23 }
24
25 private static void printMenu(OutputProvider provider) {
26 provider.println("[1] Load Marketplace");
27 provider.println("[2] Save Marketplace");
28 provider.println("[3] Show All Events");
29 provider.println("[4] Event Info");
30 provider.println("[5] Participate In Event");
31 provider.println("[6] Close Event");
32 provider.println("[7] Exit");
33 }
34}