Skip to content
This repository was archived by the owner on Jul 19, 2024. It is now read-only.

Commit 428fbe3

Browse files
Merge pull request #25 from datacrop/system
System
2 parents 53b7a0d + 8c8874f commit 428fbe3

File tree

38 files changed

+4806
-2
lines changed

38 files changed

+4806
-2
lines changed

model-repository-server/api/pom.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,28 @@
5959
<mainClass>eu.datacrop.maize.model_repository.api.ModelRepositoryServerApplication</mainClass>
6060
</configuration>
6161
</plugin>
62+
<plugin>
63+
<groupId>org.apache.maven.plugins</groupId>
64+
<artifactId>maven-javadoc-plugin</artifactId>
65+
<version>3.4.1</version>
66+
<configuration>
67+
<source>${java.version}</source>
68+
</configuration>
69+
<executions>
70+
<execution>
71+
<id>aggregate</id>
72+
<goals>
73+
<goal>aggregate</goal>
74+
</goals>
75+
<configuration>
76+
<!-- Specific configuration for the aggregate report -->
77+
<reportOutputDirectory>${user.dir}/documents</reportOutputDirectory>
78+
<destDir>javadoc</destDir>
79+
</configuration>
80+
<phase>site</phase>
81+
</execution>
82+
</executions>
83+
</plugin>
6284
</plugins>
6385
</build>
6486

model-repository-server/api/src/main/java/eu/datacrop/maize/model_repository/api/ModelRepositoryServerApplication.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,40 @@
22

33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.boot.autoconfigure.domain.EntityScan;
56
import org.springframework.context.annotation.ComponentScan;
7+
import org.springframework.data.mongodb.config.EnableMongoAuditing;
8+
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
69

710
@SpringBootApplication
811
@ComponentScan(basePackages = {
912
"eu.datacrop.maize.model_repository.commons.dtos",
1013
"eu.datacrop.maize.model_repository.commons.enums",
14+
"eu.datacrop.maize.model_repository.commons.error",
15+
"eu.datacrop.maize.model_repository.commons.error.exceptions",
16+
"eu.datacrop.maize.model_repository.commons.error.messages",
1117
"eu.datacrop.maize.model_repository.commons.util",
1218
"eu.datacrop.maize.model_repository.commons.wrappers",
19+
"eu.datacrop.maize.model_repository.commons.wrappers.collection",
20+
"eu.datacrop.maize.model_repository.commons.wrappers.single",
21+
"eu.datacrop.maize.model_repository.mongodb.converters",
22+
"eu.datacrop.maize.model_repository.mongodb.converters.auxiliary",
23+
"eu.datacrop.maize.model_repository.mongodb.daos",
24+
"eu.datacrop.maize.model_repository.mongodb.listeners",
25+
"eu.datacrop.maize.model_repository.mongodb.model",
26+
"eu.datacrop.maize.model_repository.mongodb.model.auxiliary",
27+
"eu.datacrop.maize.model_repository.mongodb.repositories",
28+
"eu.datacrop.maize.model_repository.mongodb.services",
29+
"eu.datacrop.maize.model_repository.persistence.daos",
30+
"eu.datacrop.maize.model_repository.persistence.mongo_implementation",
31+
"eu.datacrop.maize.model_repository.persistence.mysql_implementation",
32+
"eu.datacrop.maize.model_repository.services.asset_management.persistence",
33+
})
34+
@EnableMongoAuditing
35+
@EnableMongoRepositories(basePackages = {"eu.datacrop.maize.model_repository.mongodb.repositories"})
36+
@EntityScan(basePackages = {
37+
"eu.datacrop.maize.model_repository.mongodb.model",
38+
"eu.datacrop.maize.model_repository.mongodb.model.auxiliary"
1339
})
1440
public class ModelRepositoryServerApplication {
1541

model-repository-server/commons/src/main/java/eu/datacrop/maize/model_repository/commons/dtos/requests/LocationRequestDto.java

Lines changed: 313 additions & 0 deletions
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,280 @@
1+
package eu.datacrop.maize.model_repository.commons.dtos.requests;
2+
3+
import org.json.JSONObject;
4+
5+
import java.io.Serial;
6+
import java.io.Serializable;
7+
import java.util.HashSet;
8+
import java.util.Objects;
9+
import java.util.Set;
10+
11+
/**********************************************************************************************************************
12+
* This class is a data transfer object representing IoT Systems. Used in HTTP requests.
13+
*
14+
* @author Angela-Maria Despotopoulou [Athens, Greece]
15+
* @since version 0.3.0
16+
*********************************************************************************************************************/
17+
public class SystemRequestDto implements Serializable {
18+
19+
@Serial
20+
private static final long serialVersionUID = -9170777359020648979L;
21+
22+
/******************************************************************************************************************
23+
* A human readable string representing a unique identifier for the IoT System. Mandatory field.
24+
*****************************************************************************************************************/
25+
private String name;
26+
27+
/******************************************************************************************************************
28+
* A textual description of the IoT System. Mandatory field.
29+
*****************************************************************************************************************/
30+
private String description;
31+
32+
/******************************************************************************************************************
33+
* The virtual or physical Location of the IoT System. Optional field.
34+
*****************************************************************************************************************/
35+
private LocationRequestDto location;
36+
37+
/******************************************************************************************************************
38+
* A human readable string representing the organization owning the IoT System. Optional field.
39+
*****************************************************************************************************************/
40+
private String organization;
41+
42+
/******************************************************************************************************************
43+
* A collection of versatile variables hosting additional information on the IoT System. Optional field.
44+
*****************************************************************************************************************/
45+
private transient Set<Object> additionalInformation;
46+
47+
/******************************************************************************************************************
48+
* Constructor of the SystemRequestDto class, used for the Builder pattern.
49+
*****************************************************************************************************************/
50+
public SystemRequestDto(String name, String description, LocationRequestDto location,
51+
String organization, Set<Object> additionalInformation) {
52+
this.name = name;
53+
this.description = description;
54+
this.organization = organization;
55+
56+
if (location == null) {
57+
this.location = new LocationRequestDto();
58+
} else {
59+
this.location = location;
60+
}
61+
if (additionalInformation == null) {
62+
this.additionalInformation = new HashSet<>();
63+
} else {
64+
this.additionalInformation = additionalInformation;
65+
}
66+
}
67+
68+
/******************************************************************************************************************
69+
* Constructor of the SystemRequestDto class, used for instantiation with "new".
70+
*****************************************************************************************************************/
71+
public SystemRequestDto(String name, String description, String organization) {
72+
this.name = name;
73+
this.description = description;
74+
this.organization = organization;
75+
this.location = new LocationRequestDto();
76+
this.additionalInformation = new HashSet<>();
77+
}
78+
79+
/******************************************************************************************************************
80+
* Empty constructor of the SystemRequestDto class.
81+
*****************************************************************************************************************/
82+
public SystemRequestDto() {
83+
this("", "", "");
84+
}
85+
86+
/******************************************************************************************************************
87+
* "Getter" method for "name" attribute.
88+
*
89+
* @return The current value of the object's "name" attribute.
90+
*****************************************************************************************************************/
91+
public String getName() {
92+
return name;
93+
}
94+
95+
/******************************************************************************************************************
96+
* "Setter" function for "name" attribute.
97+
*
98+
* @param name A value to assign to the object's "name" attribute, not null.
99+
*****************************************************************************************************************/
100+
public void setName(String name) {
101+
this.name = name;
102+
}
103+
104+
/******************************************************************************************************************
105+
* "Getter" method for "description" attribute.
106+
*
107+
* @return The current value of the object's "description" attribute.
108+
*****************************************************************************************************************/
109+
public String getDescription() {
110+
return description;
111+
}
112+
113+
/******************************************************************************************************************
114+
* "Setter" function for "description" attribute.
115+
*
116+
* @param description A value to assign to the object's "description" attribute, not null.
117+
*****************************************************************************************************************/
118+
public void setDescription(String description) {
119+
this.description = description;
120+
}
121+
122+
/******************************************************************************************************************
123+
* "Getter" method for "location" attribute.
124+
*
125+
* @return The current value of the object's "location" attribute.
126+
*****************************************************************************************************************/
127+
public LocationRequestDto getLocation() {
128+
if (this.location == null) {
129+
this.location = new LocationRequestDto();
130+
}
131+
return this.location;
132+
}
133+
134+
/******************************************************************************************************************
135+
* "Setter" function for "location" attribute.
136+
*
137+
* @param location A value to assign to the object's "location" attribute, not null.
138+
*****************************************************************************************************************/
139+
public void setLocation(LocationRequestDto location) {
140+
if (location == null) {
141+
this.location = new LocationRequestDto();
142+
} else {
143+
this.location = location;
144+
}
145+
}
146+
147+
/******************************************************************************************************************
148+
* "Getter" method for "organization" attribute.
149+
*
150+
* @return The current value of the object's "organization" attribute.
151+
*****************************************************************************************************************/
152+
public String getOrganization() {
153+
return organization;
154+
}
155+
156+
/******************************************************************************************************************
157+
* "Setter" function for "organization" attribute.
158+
*
159+
* @param organization A value to assign to the object's "organization" attribute, not null.
160+
*****************************************************************************************************************/
161+
public void setOrganization(String organization) {
162+
this.organization = organization;
163+
}
164+
165+
/******************************************************************************************************************
166+
* "Getter" method for "additionalInformation" attribute.
167+
*
168+
* @return The current value of the object's "additionalInformation" attribute.
169+
*****************************************************************************************************************/
170+
public Set<Object> getAdditionalInformation() {
171+
if (this.additionalInformation == null) {
172+
this.additionalInformation = new HashSet<>();
173+
}
174+
return additionalInformation;
175+
}
176+
177+
/******************************************************************************************************************
178+
* "Setter" function for "additionalInformation" attribute.
179+
*
180+
* @param additionalInformation A value to assign to the object's "additionalInformation" attribute, not null.
181+
*****************************************************************************************************************/
182+
public void setAdditionalInformation(Set<Object> additionalInformation) {
183+
if (additionalInformation == null) {
184+
this.additionalInformation = new HashSet<>();
185+
} else {
186+
this.additionalInformation = additionalInformation;
187+
}
188+
}
189+
190+
/******************************************************************************************************************
191+
* Method for gracefully adding AdditionalInformation objects to the IoT System object. Duplicates are removed.
192+
*
193+
* @param additionalInformation An object (free generic Object) with additional information on the IoT System.
194+
*****************************************************************************************************************/
195+
public void addAdditionalInformation(Object additionalInformation) {
196+
if (this.additionalInformation == null) {
197+
this.additionalInformation = new HashSet<>();
198+
}
199+
if (additionalInformation == null) {
200+
return;
201+
}
202+
this.additionalInformation.add(additionalInformation);
203+
}
204+
205+
/******************************************************************************************************************
206+
* Method for gracefully removing AdditionalInformation objects from the IoT System object.
207+
*
208+
* @param additionalInformation An object (free generic Object) with additional information on the IoT System.
209+
*****************************************************************************************************************/
210+
public void removeAdditionalInformation(Object additionalInformation) {
211+
if (this.additionalInformation == null) {
212+
this.additionalInformation = new HashSet<>();
213+
return;
214+
}
215+
this.additionalInformation.remove(additionalInformation);
216+
}
217+
218+
/******************************************************************************************************************
219+
* Method for gracefully removing all AdditionalInformation objects from the IoT System object.
220+
*****************************************************************************************************************/
221+
public void removeAllAdditionalInformation() {
222+
if (this.additionalInformation == null) {
223+
this.additionalInformation = new HashSet<>();
224+
return;
225+
}
226+
this.additionalInformation.clear();
227+
}
228+
229+
/******************************************************************************************************************
230+
* Method that checks whether two SystemRequestDto objects are equal.
231+
*
232+
* @param o The second Object to compare with the current Object, not null.
233+
*****************************************************************************************************************/
234+
@Override
235+
public boolean equals(Object o) {
236+
if (this == o) return true;
237+
if (o == null || getClass() != o.getClass()) return false;
238+
SystemRequestDto that = (SystemRequestDto) o;
239+
return name.equals(that.name);
240+
}
241+
242+
/******************************************************************************************************************
243+
* Method that returns the integer hash code value of the SystemRequestDto object.
244+
*****************************************************************************************************************/
245+
@Override
246+
public int hashCode() {
247+
return Objects.hash(name);
248+
}
249+
250+
/******************************************************************************************************************
251+
* Transforms a SystemRequestDto object to String.
252+
*
253+
* @return A string representation of the Object.
254+
*****************************************************************************************************************/
255+
@Override
256+
public String toString() {
257+
return "{" +
258+
"name='" + name + '\'' +
259+
", description='" + description + '\'' +
260+
", location=" + location +
261+
", organization='" + organization + '\'' +
262+
", additionalInformation=" + additionalInformation +
263+
'}';
264+
}
265+
266+
/**************************************************************************************************************
267+
* Transforms a LocationRequestDto object to JSONObject.
268+
*
269+
* @return A JSON representation of the Object.
270+
*************************************************************************************************************/
271+
public JSONObject toJSON() {
272+
JSONObject jo = new JSONObject();
273+
jo.put("name", name);
274+
jo.put("description", description);
275+
jo.put("location", location.toJSON());
276+
jo.put("organization", organization);
277+
jo.put("additionalInformation", additionalInformation); // This field might not work perfectly.
278+
return jo;
279+
}
280+
}

0 commit comments

Comments
 (0)