Skip to content
Snippets Groups Projects
Commit 8529ce47 authored by Leonard's avatar Leonard
Browse files

services and daos done

parent 886e4093
No related branches found
No related tags found
No related merge requests found
Showing
with 277 additions and 35 deletions
......@@ -11,23 +11,38 @@ import java.io.Serializable;
@Setter
public class Planet implements Serializable {
/** Planet name */
@DatabaseField(id = true,columnName = "name")
/**
* Planet name
*/
@DatabaseField(id = true, columnName = "name")
@NonNull
private String name;
/** Horizontale Position auf der Karte */
/**
* Horizontale Position auf der Karte
*/
@DatabaseField(columnName = "posX")
@NonNull
private float posX;
/** Vertikale Position auf der Karte */
/**
* Vertikale Position auf der Karte
*/
@DatabaseField(columnName = "posY")
@NonNull
private float posY;
/** Ereignis dass auf diesem Planeten eintrifft */
@DatabaseField(columnName = "event",foreign = true)
/**
* Ereignis dass auf diesem Planeten eintrifft
*/
@DatabaseField(columnName = "event", foreign = true)
@NonNull
private PlanetEvent event;
/**
* If already discovered set to true
*/
@DatabaseField(columnName = "discovered")
@NonNull
private boolean discovered = false;
}
......@@ -8,11 +8,15 @@ import com.j256.ormlite.support.ConnectionSource;
public class CrewDAO extends ObjectDAO<Crew> {
/** Database connection */
/**
* Database connection
*/
private ConnectionSource source;
/** Crew dao */
private Dao<Crew,String> crewDao;
/**
* Crew dao
*/
private Dao<Crew, String> crewDao;
/**
* Add a new crew member to the database
......@@ -25,6 +29,16 @@ public class CrewDAO extends ObjectDAO<Crew> {
}
/**
* Update a crew member in the database
*
* @param c - the crew member to update in the database
* @throws CrewNotFoundException if the crew cannot be found in the database
*/
public void update(Crew c) throws CrewNotFoundException {
}
/**
* Remove an existing crew member from the database
*
......@@ -36,7 +50,11 @@ public class CrewDAO extends ObjectDAO<Crew> {
}
/** Constructor
* @param source - database connection source */
public CrewDAO(ConnectionSource source){}
/**
* Constructor
*
* @param source - database connection source
*/
public CrewDAO(ConnectionSource source) {
}
}
......@@ -7,17 +7,23 @@ import com.galaxytrucker.galaxytruckerreloaded.Server.Persistence.ObjectDAO;
public class OverworldDAO extends ObjectDAO<Overworld> {
/** Add a new OverWorld to the database
/**
* Add a new OverWorld to the database
*
* @param o - the overworld to add to the database
* @throws DuplicateOverworldException if the OverWorld already exists in the database */
* @throws DuplicateOverworldException if the OverWorld already exists in the database
*/
@Override
public void persist(Overworld o) throws DuplicateOverworldException {
}
/** Remove an existing OverWorld from the database
/**
* Remove an existing OverWorld from the database
*
* @param o - the OverWorld to remove
* @throws OverworldNotFoundException if the OverWorld cannot be found in the database */
* @throws OverworldNotFoundException if the OverWorld cannot be found in the database
*/
@Override
public void remove(Overworld o) throws OverworldNotFoundException {
......
......@@ -17,6 +17,16 @@ public class PlanetDAO extends ObjectDAO<Planet> {
}
/**
* Update an existing planet in the database
*
* @param p - the planet to update
* @throws PlanetNotFoundException if the planet cannot be found in the database
*/
public void update(Planet p) throws PlanetNotFoundException {
}
/**
* Remove an existing planet from the database
*
......
......@@ -38,6 +38,13 @@ public class ShipDAO extends ObjectDAO<Ship> {
}
/** Update a ship in the database
* @param s - the ship to update
* @throws ShipNotFoundException if the ship cannot be found in the database */
public void update(Ship s) throws ShipNotFoundException{
}
/**
* Get a ship from the database using its associated user
*
......
......@@ -6,17 +6,23 @@ import com.galaxytrucker.galaxytruckerreloaded.Server.Exception.SystemNotFoundEx
public class SystemDAO extends ObjectDAO<System> {
/** Add a new system to the database
/**
* Add a new system to the database
*
* @param s - the system to add
* @throws DuplicateSystemException if the system already exists in the database */
* @throws DuplicateSystemException if the system already exists in the database
*/
@Override
public void persist(System s) throws DuplicateSystemException {
}
/** Remove an existing system from the database
/**
* Remove an existing system from the database
*
* @param s - the system to remove
* @throws SystemNotFoundException if the system cannot be found in the database */
* @throws SystemNotFoundException if the system cannot be found in the database
*/
@Override
public void remove(System s) throws SystemNotFoundException {
......
......@@ -37,6 +37,13 @@ public class UserDAO extends ObjectDAO<User> {
}
/** Update a user in the database
* @param u - the user to update
* @throws UserNotFoundException if the user cannot be found in the database */
public void update(User u) throws UserNotFoundException {
}
/**
* Get a user from the database using his username
*
......
package com.galaxytrucker.galaxytruckerreloaded.Server.Services;
import com.galaxytrucker.galaxytruckerreloaded.Model.Crew.Crew;
import com.galaxytrucker.galaxytruckerreloaded.Server.Exception.CrewNotFoundException;
import com.galaxytrucker.galaxytruckerreloaded.Server.Exception.DuplicateCrewException;
import com.galaxytrucker.galaxytruckerreloaded.Server.Persistence.CrewDAO;
public class CrewService {
/**
* DAO
*/
private CrewDAO crewDAO;
/**
* Add a new crew member
*
* @param c - the crew member to add
* @throws DuplicateCrewException if the crew already exists
*/
public void addCrew(Crew c) throws DuplicateCrewException {
}
/**
* Edit an existing crew member
*
* @param c - the crew member to edit
* @throws CrewNotFoundException if the crew cannot be found
*/
public void editCrew(Crew c) throws CrewNotFoundException {
}
/**
* Remove an existing crew member
*
* @param c - the crew to remove
* @throws CrewNotFoundException if the crew cannot be found
*/
public void removeCrew(Crew c) throws CrewNotFoundException {
}
}
package com.galaxytrucker.galaxytruckerreloaded.Server.Services;
import com.galaxytrucker.galaxytruckerreloaded.Model.Map.Overworld;
import com.galaxytrucker.galaxytruckerreloaded.Server.Exception.DuplicateOverworldException;
import com.galaxytrucker.galaxytruckerreloaded.Server.Exception.OverworldNotFoundException;
import com.galaxytrucker.galaxytruckerreloaded.Server.Persistence.OverworldDAO;
public class OverworldService {
/**
* DAO
*/
private OverworldDAO overworldDAO;
/**
* Add a new OverWorld
*
* @param o - the OverWorld to add
* @throws DuplicateOverworldException if the OverWorld already exists
*/
public void addOverworld(Overworld o) throws DuplicateOverworldException {
}
/**
* Remove an existing OverWorld
*
* @param o - the OverWorld to remove
* @throws OverworldNotFoundException if the OverWorld cannot be found
*/
public void removeOverworld(Overworld o) throws OverworldNotFoundException {
}
}
package com.galaxytrucker.galaxytruckerreloaded.Server.Services;
import com.galaxytrucker.galaxytruckerreloaded.Model.Map.Planet;
import com.galaxytrucker.galaxytruckerreloaded.Server.Exception.DuplicatePlanetException;
import com.galaxytrucker.galaxytruckerreloaded.Server.Exception.PlanetNotFoundException;
import com.galaxytrucker.galaxytruckerreloaded.Server.Persistence.PlanetDAO;
public class PlanetService {
/**
* Planet DAO
*/
private PlanetDAO planetDAO;
/**
* Add a new planet
*
* @param p - the planet to add
* @throws DuplicatePlanetException if the planet already exists
*/
public void addPlanet(Planet p) throws DuplicatePlanetException {
}
/**
* Edit an existing planet
*
* @param p - the planet to edit
* @throws PlanetNotFoundException if the planet cannot be found
*/
public void editPlanet(Planet p) throws PlanetNotFoundException {
}
/**
* Remove an existing planet
*
* @param p - the planet to remove
* @throws PlanetNotFoundException if the planet cannot be found
*/
public void removePlanet(Planet p) throws PlanetNotFoundException {
}
}
......@@ -2,6 +2,10 @@ package com.galaxytrucker.galaxytruckerreloaded.Server.Services;
import com.galaxytrucker.galaxytruckerreloaded.Model.Ship;
import com.galaxytrucker.galaxytruckerreloaded.Model.User;
import com.galaxytrucker.galaxytruckerreloaded.Server.Exception.DuplicateShipException;
import com.galaxytrucker.galaxytruckerreloaded.Server.Exception.ShipNotFoundException;
import com.galaxytrucker.galaxytruckerreloaded.Server.Exception.UserNotFoundException;
import com.galaxytrucker.galaxytruckerreloaded.Server.Persistence.ObjectDAO;
import com.galaxytrucker.galaxytruckerreloaded.Server.Persistence.ShipDAO;
import com.j256.ormlite.support.ConnectionSource;
......@@ -16,16 +20,27 @@ public class ShipService {
* Add a new ship to the database
*
* @param s - the ship to add
*
* @throws DuplicateShipException if the ship already exists in the database
*/
public void addShip(Ship s) {
public void persist(Ship s) throws DuplicateShipException {
}
/** Update a ship in the database
* @param s - the ship to update \
* @throws ShipNotFoundException if the ship cannot be found in the database */
public void update(Ship s) throws ShipNotFoundException{
}
/**
* Fetch a ship from the database using the user associated to it
*
* @param u - the user associated to the ship
*
* @throws UserNotFoundException if the user cannot be found in the database
*/
public User getShipByUser(User u) {
public User getShipByUser(User u) throws UserNotFoundException {
return null;
}
......@@ -34,7 +49,7 @@ public class ShipService {
*
* @param s - the ship to remove from the database
*/
public void removeShip(Ship s) {
public void remove(Ship s) throws ShipNotFoundException {
}
/**
......
package com.galaxytrucker.galaxytruckerreloaded.Server.Services;
import com.galaxytrucker.galaxytruckerreloaded.Model.ShipLayout.System;
import com.galaxytrucker.galaxytruckerreloaded.Server.Exception.DuplicateSystemException;
import com.galaxytrucker.galaxytruckerreloaded.Server.Exception.SystemNotFoundException;
import com.galaxytrucker.galaxytruckerreloaded.Server.Persistence.SystemDAO;
public class SystemService {
/**
* System dao
*/
private SystemDAO systemDAO;
/**
* Add a new system
*
* @param s - the system to add
* @throws DuplicateSystemException if the system already exists
*/
public void addSystem(System s) throws DuplicateSystemException {
}
/**
* Remove a system
*
* @param s - the system to remove
* @throws SystemNotFoundException if the system cannot be found
*/
public void removeSystem(System s) throws SystemNotFoundException {
}
}
package com.galaxytrucker.galaxytruckerreloaded.Server.Services;
import com.galaxytrucker.galaxytruckerreloaded.Model.User;
import com.galaxytrucker.galaxytruckerreloaded.Server.Exception.DuplicateUserException;
import com.galaxytrucker.galaxytruckerreloaded.Server.Exception.UserNotFoundException;
import com.galaxytrucker.galaxytruckerreloaded.Server.Persistence.UserDAO;
import com.j256.ormlite.support.ConnectionSource;
......@@ -14,35 +16,41 @@ public class UserService {
/**
* add a new user to the database
*
* @param user - the user to add
* @param username - the username of the user to add
*
* @throws DuplicateUserException if the user already exists
*/
public void addUser(User user) {
public void addUser(String username) throws DuplicateUserException {
}
/**
* Fetch a user from the database
*
* @param username - the username of the user to fetch
*
* @throws UserNotFoundException if the user couldn't be found
*/
public User getUser(String username) {
public User getUser(String username) throws UserNotFoundException {
return null;
}
/**
* Remove a user from the database
* Update a user in the database
*
* @param u - the user to remove
* @param u - the user to update
* @throws UserNotFoundException if the user cannot be found in the database
*/
public void removeUser(User u) {
public void updateUser(User u) throws UserNotFoundException {
}
/**
* Remove a user using his username
*
* @param username - the username of the user to remove
*
* @throws UserNotFoundException if the user cannot be found
*/
public void removeUserByUsername(String username) {
public void removeUserByUsername(String username) throws UserNotFoundException {
}
/**
......@@ -59,13 +67,17 @@ public class UserService {
*
* @param username - the username of the user
*/
public void saveGame(String username) {
public void saveGame(String username) throws UserNotFoundException {
}
/** Login
/**
* Login
*
* @param username - the username of the user
* @return true - if the login was successful else return false */
public boolean login(String username){
* @return true - if the login was successful else return false
*
*/
public boolean login(String username) {
return false;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment