-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Multiple servers, reworked class managing, establishment managing
- Loading branch information
Showing
27 changed files
with
355 additions
and
275 deletions.
There are no files selected for viewing
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
This file was deleted.
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
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
50 changes: 50 additions & 0 deletions
50
src/main/java/fr/litarvan/sakado/server/data/DataServer.java
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,50 @@ | ||
package fr.litarvan.sakado.server.data; | ||
|
||
import fr.litarvan.sakado.server.data.network.NetworkClient; | ||
|
||
import java.io.IOException; | ||
|
||
public class DataServer | ||
{ | ||
private String name; | ||
private String host; | ||
private int port; | ||
|
||
private transient NetworkClient client; | ||
|
||
public DataServer() | ||
{ | ||
} | ||
|
||
public DataServer(String name, String host, int port) | ||
{ | ||
this.name = name; | ||
this.host = host; | ||
this.port = port; | ||
} | ||
|
||
public void init() throws IOException | ||
{ | ||
this.client = new NetworkClient(host, port); | ||
} | ||
|
||
public NetworkClient getClient() | ||
{ | ||
return this.client; | ||
} | ||
|
||
public String getName() | ||
{ | ||
return name; | ||
} | ||
|
||
public String getHost() | ||
{ | ||
return host; | ||
} | ||
|
||
public int getPort() | ||
{ | ||
return port; | ||
} | ||
} |
95 changes: 95 additions & 0 deletions
95
src/main/java/fr/litarvan/sakado/server/data/Establishment.java
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,95 @@ | ||
package fr.litarvan.sakado.server.data; | ||
|
||
import fr.litarvan.sakado.server.StudentClass; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class Establishment | ||
{ | ||
private String name; | ||
private FetchMethod method; | ||
|
||
private transient List<StudentClass> classes; | ||
|
||
public Establishment() | ||
{ | ||
this.classes = new ArrayList<>(); | ||
} | ||
|
||
public Establishment(String name, FetchMethod method) | ||
{ | ||
this(); | ||
|
||
this.name = name; | ||
this.method = method; | ||
} | ||
|
||
public StudentClass classOf(User user) | ||
{ | ||
for (StudentClass cl : classes) | ||
{ | ||
if (cl.getMembers().contains(user.getUsername()) && cl.getEstablishment() == user.getEstablishment()) | ||
{ | ||
return cl; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public StudentClass getClassByName(String name) | ||
{ | ||
for (StudentClass cl : this.classes) | ||
{ | ||
if (cl.getName().equalsIgnoreCase(name)) | ||
{ | ||
return cl; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public String getName() | ||
{ | ||
return name; | ||
} | ||
|
||
public FetchMethod getMethod() | ||
{ | ||
return method; | ||
} | ||
|
||
public List<StudentClass> getClasses() | ||
{ | ||
return classes; | ||
} | ||
|
||
public static class FetchMethod | ||
{ | ||
private String server; | ||
private Map<String, String> params; | ||
|
||
public FetchMethod() | ||
{ | ||
} | ||
|
||
public FetchMethod(String server, Map<String, String> params) | ||
{ | ||
this.server = server; | ||
this.params = params; | ||
} | ||
|
||
public String getServer() | ||
{ | ||
return server; | ||
} | ||
|
||
public Map<String, String> getParams() | ||
{ | ||
return params; | ||
} | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.