parent
f2e8b34192
commit
5a6b750a1b
@ -1,224 +0,0 @@ |
||||
package com.example.demo; |
||||
|
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.web.bind.annotation.DeleteMapping; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.PatchMapping; |
||||
import org.springframework.web.bind.annotation.PathVariable; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.PutMapping; |
||||
import org.springframework.web.bind.annotation.RequestBody; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
import org.springframework.web.client.RestTemplate; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
||||
import java.awt.image.BufferedImage; |
||||
import java.io.File; |
||||
import java.io.FileOutputStream; |
||||
import java.io.IOException; |
||||
import java.net.ConnectException; |
||||
import java.net.HttpURLConnection; |
||||
import java.net.URL; |
||||
import java.nio.channels.Channels; |
||||
import java.nio.channels.ReadableByteChannel; |
||||
import java.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.Optional; |
||||
|
||||
import javax.imageio.ImageIO; |
||||
import javax.websocket.server.PathParam; |
||||
|
||||
@Service |
||||
@RestController |
||||
public class Controller { |
||||
|
||||
public static DataRepository database; |
||||
RestTemplate connection = new RestTemplate(); |
||||
|
||||
public Controller(DataRepository database) { |
||||
this.database=database; |
||||
} |
||||
|
||||
@GetMapping("/movies") |
||||
public List<Movie> _8(@RequestParam("q") String q) { |
||||
System.out.println(connection.getForObject("http://www.omdbapi.com/?apikey={key}&s={title}", String.class, "6ba5969a",q)); |
||||
MovieRequest mr = connection.getForObject("http://www.omdbapi.com/?apikey={key}&s={title}", MovieRequest.class, "6ba5969a",q); |
||||
return mr.movies; |
||||
} |
||||
|
||||
@GetMapping("") |
||||
public Iterable<Data> _1(){ |
||||
return database.findAll(); |
||||
} |
||||
@PostMapping("") |
||||
public Data _2(@RequestBody Data data){ |
||||
return database.save(data); |
||||
} |
||||
@GetMapping("/data/{id}") |
||||
public Data _3(@PathVariable Long id) { |
||||
return database.findById(id).orElse(null); |
||||
} |
||||
@PutMapping("/data/{id}") |
||||
public Object _5(@PathVariable Long id,@RequestBody Data data) { |
||||
if (database.existsById(id)) { |
||||
return database.save(data); |
||||
} else { |
||||
return "ID "+id+" does not exist!"; |
||||
} |
||||
} |
||||
@PatchMapping("/data/{id}") |
||||
public Object _6(@PathVariable Long id,@RequestBody Data data) { |
||||
if (database.existsById(id)) { |
||||
return database.save(data); |
||||
} else { |
||||
return "ID "+id+" does not exist!"; |
||||
} |
||||
} |
||||
@GetMapping("/lessons/find/{name}") |
||||
public Data _7(@PathVariable String name) { |
||||
return database.findByName(name); |
||||
} |
||||
@GetMapping("/lessons/between") |
||||
public List<Data> _8(@DateTimeFormat(pattern = "MM-dd-yyyy")@RequestParam("date1") Date date1, |
||||
@DateTimeFormat(pattern = "MM-dd-yyyy")@RequestParam("date2") Date date2) { |
||||
return database.submittedOnBetween(date1, date2); |
||||
} |
||||
@DeleteMapping("/data/{id}") |
||||
public String _4(@PathVariable Long id) { |
||||
if (database.existsById(id)) { |
||||
database.deleteById(id); |
||||
return "Removed ID "+id+" from database."; |
||||
} else { |
||||
return "ID "+id+" does not exist!"; |
||||
} |
||||
} |
||||
|
||||
public static void downloadFileFromUrl(String url, String file) throws IOException{ |
||||
File filer = new File(file); |
||||
filer.createNewFile(); |
||||
|
||||
URL website = new URL(url); |
||||
HttpURLConnection connection = (HttpURLConnection) website.openConnection(); |
||||
/*for (String s : connection.getHeaderFields().keySet()) { |
||||
System.out.println(s+": "+connection.getHeaderFields().get(s)); |
||||
}*/ |
||||
connection.setRequestMethod("GET"); |
||||
//connection.setRequestProperty("Content-Type", "application/json");
|
||||
try { |
||||
ReadableByteChannel rbc = Channels.newChannel(connection.getInputStream()); |
||||
FileOutputStream fos = new FileOutputStream(file); |
||||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); |
||||
fos.close(); |
||||
} catch (ConnectException e) { |
||||
System.out.println("Failed to connect, moving on..."); |
||||
} |
||||
} |
||||
|
||||
public double CalculateArea(double width,double height) { |
||||
return width*height; |
||||
} |
||||
|
||||
public double CalculateArea(double radius) { |
||||
return Math.PI*Math.pow(radius, 2); |
||||
} |
||||
|
||||
@PostMapping("/math/area") |
||||
public String areaDisplay( |
||||
@RequestParam Map<String,String> map) { |
||||
if (map.containsKey("type")) { |
||||
if (map.get("type").equalsIgnoreCase("circle")) { |
||||
if (map.containsKey("radius")) { |
||||
return new StringBuilder("Area of a circle with a radius of ") |
||||
.append(map.get("radius")) |
||||
.append(" is "+CalculateArea(Double.parseDouble(map.get("radius")))) |
||||
.toString(); |
||||
} |
||||
}else if(map.get("type").equalsIgnoreCase("rectangle")) { |
||||
if (map.containsKey("width") && map.containsKey("height")) { |
||||
return new StringBuilder("Area of a ") |
||||
.append(map.get("width")).append("x") |
||||
.append(map.get("height")) |
||||
.append(" rectangle is "+CalculateArea(Double.parseDouble(map.get("width")),Double.parseDouble(map.get("height")))) |
||||
.toString(); |
||||
} |
||||
} |
||||
} |
||||
return "Invalid"; |
||||
} |
||||
|
||||
@GetMapping("/math/volume/{l}/{w}/{h}") |
||||
public String volumeDisplay( |
||||
@PathVariable(value="l") String length, |
||||
@PathVariable(value="w") String width, |
||||
@PathVariable(value="h") String height) { |
||||
return new StringBuilder("The volume of a ") |
||||
.append(length).append("x") |
||||
.append(width).append("x") |
||||
.append(height) |
||||
.append(" rectangle is ") |
||||
.append(Integer.parseInt(length)*Integer.parseInt(width)*Integer.parseInt(height)) |
||||
.toString(); |
||||
} |
||||
|
||||
@GetMapping("/math/calculate") |
||||
public String piDisplay(@RequestParam(value="operation",required=false) String operation, |
||||
@RequestParam(value="x") String x, |
||||
@RequestParam(value="y") String y) { |
||||
int val1=Integer.parseInt(x); |
||||
int val2=Integer.parseInt(y); |
||||
switch (operation) { |
||||
case "subtract":{ |
||||
return Integer.toString(val1-val2); |
||||
} |
||||
case "multiply":{ |
||||
return Integer.toString(val1*val2); |
||||
} |
||||
case "divide":{ |
||||
return Integer.toString(val1/val2); |
||||
} |
||||
default:{ |
||||
return Integer.toString(val1+val2); |
||||
} |
||||
} |
||||
} |
||||
|
||||
@GetMapping("/time") |
||||
public void updateTime( |
||||
@DateTimeFormat(pattern="MM-dd-yyyy HH:mm:ss") |
||||
@RequestParam("startDate") Date date1, |
||||
@DateTimeFormat(pattern="MM-dd-yyyy HH:mm:ss") |
||||
@RequestParam("endDate") Date date2 |
||||
) { |
||||
System.out.println(date1+"/"+date2); |
||||
} |
||||
|
||||
@PostMapping("/math/sum") |
||||
public String sumDisplay(@RequestParam Map<String,String> keys) { |
||||
int sum = 0; |
||||
for (String i : keys.keySet()) { |
||||
sum += Integer.parseInt(keys.get(i)); |
||||
} |
||||
return Integer.toString(sum); |
||||
} |
||||
|
||||
@GetMapping("/math/pi") |
||||
public String piDisplay() { |
||||
return Double.toString(Math.PI); |
||||
} |
||||
|
||||
@GetMapping("/image") |
||||
public HashMap<String,String> helloWorld(@RequestParam("url") String url){ |
||||
try { |
||||
downloadFileFromUrl("http://pbs.twimg.com/media/EdKE8xzVcCEf1qd.jpg","temp"); |
||||
BufferedImage img = ImageIO.read(new File("temp")); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return null; |
||||
} |
||||
} |
@ -1,11 +0,0 @@ |
||||
package com.example.demo; |
||||
|
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
import org.springframework.data.repository.CrudRepository; |
||||
|
||||
public interface DataRepository extends CrudRepository<Data,Long>{ |
||||
Data findByName(String name); |
||||
List<Data> submittedOnBetween(Date date1,Date date2); |
||||
} |
@ -1,25 +0,0 @@ |
||||
package com.example.demo; |
||||
|
||||
import java.util.Calendar; |
||||
import java.util.Date; |
||||
|
||||
import org.springframework.boot.SpringApplication; |
||||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
||||
|
||||
@SpringBootApplication |
||||
public class DemoApplication { |
||||
|
||||
public static void main(String[] args) { |
||||
SpringApplication.run(DemoApplication.class, args); |
||||
Date date1 = new Date(); |
||||
Date date2 = (Date)date1.clone(); |
||||
Calendar calendar = Calendar.getInstance(); |
||||
calendar.setTime(date2); |
||||
calendar.set(Calendar.HOUR_OF_DAY, 23); |
||||
calendar.set(Calendar.MINUTE, 59); |
||||
calendar.set(Calendar.SECOND, 59); |
||||
System.out.println(); |
||||
|
||||
} |
||||
|
||||
} |
@ -1,63 +0,0 @@ |
||||
package com.example.demo; |
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator; |
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import com.fasterxml.jackson.annotation.JsonProperty; |
||||
|
||||
@RequestMapping |
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
public class Movie { |
||||
String title; |
||||
String imdbId; |
||||
String poster; |
||||
int year; |
||||
|
||||
@JsonCreator |
||||
Movie( |
||||
@JsonProperty("Title") String title, |
||||
@JsonProperty("imdbID") String imdbId, |
||||
@JsonProperty("Poster") String poster, |
||||
@JsonProperty("Year") int year) { |
||||
this.title=title; |
||||
this.imdbId=imdbId; |
||||
this.poster=poster; |
||||
this.year=year; |
||||
} |
||||
|
||||
@JsonProperty("title") |
||||
public String getTitle() { |
||||
return title; |
||||
} |
||||
@JsonProperty("title") |
||||
public void setTitle(String title) { |
||||
this.title = title; |
||||
} |
||||
@JsonProperty("imdbId") |
||||
public String getImdbId() { |
||||
return imdbId; |
||||
} |
||||
@JsonProperty("imdbId") |
||||
public void setImdbId(String imdbId) { |
||||
this.imdbId = imdbId; |
||||
} |
||||
@JsonProperty("poster") |
||||
public String getPoster() { |
||||
return poster; |
||||
} |
||||
@JsonProperty("poster") |
||||
public void setPoster(String poster) { |
||||
this.poster = poster; |
||||
} |
||||
@JsonProperty("year") |
||||
public int getYear() { |
||||
return year; |
||||
} |
||||
@JsonProperty("year") |
||||
public void setYear(int year) { |
||||
this.year = year; |
||||
} |
||||
|
||||
|
||||
} |
@ -1,23 +0,0 @@ |
||||
package com.example.demo; |
||||
|
||||
import java.util.List; |
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty; |
||||
|
||||
@RequestMapping |
||||
public class MovieRequest { |
||||
List<Movie> movies; |
||||
|
||||
@JsonProperty("Search") |
||||
public List<Movie> getMovies() { |
||||
return movies; |
||||
} |
||||
|
||||
@JsonProperty("Search") |
||||
public void setMovies(List<Movie> movies) { |
||||
this.movies = movies; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,31 @@ |
||||
package sig.family; |
||||
|
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.web.filter.OncePerRequestFilter; |
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry; |
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc; |
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; |
||||
import javax.servlet.FilterChain; |
||||
import javax.servlet.ServletException; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.io.IOException; |
||||
|
||||
@Component |
||||
public class CorsFilter extends OncePerRequestFilter { |
||||
@Override |
||||
protected void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response, |
||||
|
||||
final FilterChain filterChain) |
||||
throws |
||||
ServletException, IOException { |
||||
response.addHeader("Access-Control-Allow-Origin", "*"); |
||||
response.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT, PATCH, HEAD"); |
||||
response.addHeader("Access-Control-Allow-Headers", "Origin, Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers"); |
||||
response.addHeader("Access-Control-Expose-Headers", "Access-Control-Allow-Origin, Access-Control-Allow-Credentials"); |
||||
response.addHeader("Access-Control-Allow-Credentials", "true"); |
||||
response.addIntHeader("Access-Control-Max-Age", 10); |
||||
filterChain.doFilter(request, response); |
||||
} |
||||
} |
@ -0,0 +1,172 @@ |
||||
package sig.family; |
||||
|
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.web.bind.annotation.DeleteMapping; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.PatchMapping; |
||||
import org.springframework.web.bind.annotation.PathVariable; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.PutMapping; |
||||
import org.springframework.web.bind.annotation.RequestBody; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
import org.springframework.web.client.RestTemplate; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
||||
import java.awt.image.BufferedImage; |
||||
import java.io.File; |
||||
import java.io.FileOutputStream; |
||||
import java.io.IOException; |
||||
import java.net.ConnectException; |
||||
import java.net.HttpURLConnection; |
||||
import java.net.URL; |
||||
import java.nio.channels.Channels; |
||||
import java.nio.channels.ReadableByteChannel; |
||||
import java.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.Optional; |
||||
|
||||
import javax.imageio.ImageIO; |
||||
import javax.websocket.server.PathParam; |
||||
|
||||
@Service |
||||
@RestController |
||||
public class Endpoints { |
||||
|
||||
FamilyRepository families; |
||||
FamilyMemberRepository members; |
||||
FamilyRelationshipRepository relationships; |
||||
LocationRepository locations; |
||||
KnownLocationRepository knownlocations; |
||||
RestTemplate connection = new RestTemplate(); |
||||
|
||||
public Endpoints(FamilyRepository families, |
||||
FamilyMemberRepository members, |
||||
FamilyRelationshipRepository relationships, |
||||
LocationRepository locations, |
||||
KnownLocationRepository knownlocations) { |
||||
this.families=families; |
||||
this.members=members; |
||||
this.relationships=relationships; |
||||
this.locations=locations; |
||||
this.knownlocations=knownlocations; |
||||
} |
||||
|
||||
@GetMapping("/family") |
||||
public Iterable<Family> _1() { |
||||
return families.findAll(); |
||||
} |
||||
|
||||
@GetMapping("/family/{id}") |
||||
public Optional<Family> _2(@PathVariable Long id) { |
||||
return families.findById(id); |
||||
} |
||||
|
||||
@PostMapping("/family") |
||||
/** |
||||
* @RequestBody requires: |
||||
* name - Name of new family. |
||||
* @return |
||||
*/ |
||||
public Family _3(@RequestBody Map<String,String> body) { |
||||
if (body.containsKey("name")) { |
||||
return families.save(new Family(body.get("name"))); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
@PostMapping("/member/create") |
||||
/** |
||||
* @RequestBody requires: |
||||
* firstName - First Name of family member. |
||||
* lastName - Last Name of family member. |
||||
* mobileId - ID of mobile device. |
||||
* @return |
||||
*/ |
||||
public FamilyMember _4( |
||||
@RequestBody Map<String,String> body) { |
||||
if (body.containsKey("firstName")&&body.containsKey("lastName")&&body.containsKey("mobileId")) { |
||||
return members.save(new FamilyMember(body.get("firstName"),body.get("lastName"),Long.parseLong(body.get("mobileId")))); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
@PostMapping("/relationship/{familyid}/{memberid}/{relationship}") |
||||
public FamilyRelationship _5( |
||||
@PathVariable Long familyid, |
||||
@PathVariable Long memberid, |
||||
@PathVariable String relationship) { |
||||
if (!families.existsById(familyid)||!members.existsById(memberid)) {return null;} |
||||
List<FamilyRelationship> fr = relationships.findByMemberId(memberid); |
||||
FamilyRelationship relation = null; |
||||
if (fr.size()>0) { |
||||
relation = fr.get(0); |
||||
relation.setFamilyId(familyid); |
||||
relation.setRelationship(relationship); |
||||
} else { |
||||
relation = new FamilyRelationship(familyid,memberid,relationship); |
||||
} |
||||
return relationships.save(relation); |
||||
} |
||||
|
||||
@DeleteMapping("/relationship/{familyid}/{memberid}") |
||||
public FamilyRelationship _6( |
||||
@PathVariable Long familyid, |
||||
@PathVariable Long memberid) { |
||||
List<FamilyRelationship> r = relationships.findByFamilyIdAndMemberId(familyid, memberid); |
||||
if (r.size()>0) { |
||||
FamilyRelationship f = r.get(0); |
||||
relationships.delete(f); |
||||
return f; |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
@PostMapping("/location") |
||||
/** |
||||
* @RequestBody requires: |
||||
* member - The member posting this location. |
||||
* x - The X coordinate of the location (latitude). |
||||
* y - The Y coordination of the location (longitude). |
||||
* @return |
||||
*/ |
||||
public Location _7(@RequestBody Map<String,String> body) { |
||||
if (body.containsKey("member")&&body.containsKey("x")&&body.containsKey("y")&&members.existsById(Long.parseLong(body.get("member")))) { |
||||
return locations.save(new Location(Double.parseDouble(body.get("x")),Double.parseDouble(body.get("y")),Long.parseLong(body.get("member")),new Date())); |
||||
} else { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
@PostMapping("/knownlocation") |
||||
/** |
||||
* @RequestBody requires: |
||||
* name - The name of the location. |
||||
* x - The X coordinate of the location (latitude). |
||||
* y - The Y coordination of the location (longitude). |
||||
* safe - True if safe, false if unsafe location. |
||||
* @return |
||||
*/ |
||||
public KnownLocation _8(@RequestBody Map<String,String> body) { |
||||
if (body.containsKey("name")&&body.containsKey("x")&&body.containsKey("y")&&body.containsKey("safe")) { |
||||
return knownlocations.save(new KnownLocation(Double.parseDouble(body.get("x")),Double.parseDouble(body.get("y")),body.get("name"),Boolean.parseBoolean(body.get("safe")))); |
||||
} else { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
@DeleteMapping("/knownlocation/{id}") |
||||
public KnownLocation _9(@PathVariable Long id) { |
||||
if (knownlocations.existsById(id)) { |
||||
KnownLocation k = knownlocations.findById(id).get(); |
||||
knownlocations.deleteById(id); |
||||
return k; |
||||
} else { |
||||
return null; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,16 @@ |
||||
package sig.family; |
||||
|
||||
import java.util.Calendar; |
||||
import java.util.Date; |
||||
|
||||
import org.springframework.boot.SpringApplication; |
||||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
||||
|
||||
@SpringBootApplication |
||||
public class FamilyApp { |
||||
|
||||
public static void main(String[] args) { |
||||
SpringApplication.run(FamilyApp.class, args); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,56 @@ |
||||
package sig.family; |
||||
|
||||
import javax.persistence.Entity; |
||||
import javax.persistence.GeneratedValue; |
||||
import javax.persistence.GenerationType; |
||||
import javax.persistence.Id; |
||||
import javax.persistence.Table; |
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
|
||||
@Entity |
||||
@Table(name="familymember") |
||||
@RequestMapping |
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
public class FamilyMember { |
||||
@Id |
||||
@GeneratedValue(strategy=GenerationType.IDENTITY) |
||||
Long id; |
||||
|
||||
String firstName,lastName; |
||||
|
||||
Long mobileDeviceId; |
||||
|
||||
public FamilyMember(String firstName, String lastName, Long mobileDeviceId) { |
||||
this.firstName = firstName; |
||||
this.lastName = lastName; |
||||
this.mobileDeviceId = mobileDeviceId; |
||||
} |
||||
|
||||
public Long getId() { |
||||
return id; |
||||
} |
||||
public void setId(Long id) { |
||||
this.id = id; |
||||
} |
||||
public String getFirstName() { |
||||
return firstName; |
||||
} |
||||
public void setFirstName(String firstName) { |
||||
this.firstName = firstName; |
||||
} |
||||
public String getLastName() { |
||||
return lastName; |
||||
} |
||||
public void setLastName(String lastName) { |
||||
this.lastName = lastName; |
||||
} |
||||
public Long getMobileDeviceId() { |
||||
return mobileDeviceId; |
||||
} |
||||
public void setMobileDeviceId(Long mobileDeviceId) { |
||||
this.mobileDeviceId = mobileDeviceId; |
||||
} |
||||
} |
@ -0,0 +1,6 @@ |
||||
package sig.family; |
||||
|
||||
import org.springframework.data.repository.CrudRepository; |
||||
|
||||
public interface FamilyMemberRepository extends CrudRepository<FamilyMember,Long>{ |
||||
} |
@ -0,0 +1,57 @@ |
||||
package sig.family; |
||||
|
||||
import javax.persistence.Entity; |
||||
import javax.persistence.GeneratedValue; |
||||
import javax.persistence.GenerationType; |
||||
import javax.persistence.Id; |
||||
import javax.persistence.Table; |
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator; |
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
|
||||
@Entity |
||||
@Table(name="familyrelationships") |
||||
@RequestMapping |
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
public class FamilyRelationship { |
||||
@Id |
||||
@GeneratedValue(strategy=GenerationType.IDENTITY) |
||||
Long id; |
||||
|
||||
public FamilyRelationship() {}; |
||||
|
||||
public FamilyRelationship(Long familyId, Long memberId, String relationship) { |
||||
this.familyId = familyId; |
||||
this.memberId = memberId; |
||||
this.relationship = relationship; |
||||
} |
||||
Long familyId; |
||||
Long memberId; |
||||
String relationship; |
||||
public Long getId() { |
||||
return id; |
||||
} |
||||
public void setId(Long id) { |
||||
this.id = id; |
||||
} |
||||
public Long getFamilyId() { |
||||
return familyId; |
||||
} |
||||
public void setFamilyId(Long familyId) { |
||||
this.familyId = familyId; |
||||
} |
||||
public Long getMemberId() { |
||||
return memberId; |
||||
} |
||||
public void setMemberId(Long memberId) { |
||||
this.memberId = memberId; |
||||
} |
||||
public String getRelationship() { |
||||
return relationship; |
||||
} |
||||
public void setRelationship(String relationship) { |
||||
this.relationship = relationship; |
||||
} |
||||
} |
@ -0,0 +1,10 @@ |
||||
package sig.family; |
||||
|
||||
import java.util.List; |
||||
|
||||
import org.springframework.data.repository.CrudRepository; |
||||
|
||||
public interface FamilyRelationshipRepository extends CrudRepository<FamilyRelationship,Long>{ |
||||
List<FamilyRelationship> findByMemberId(Long memberId); |
||||
List<FamilyRelationship> findByFamilyIdAndMemberId(Long familyId,Long memberId); |
||||
} |
@ -0,0 +1,6 @@ |
||||
package sig.family; |
||||
|
||||
import org.springframework.data.repository.CrudRepository; |
||||
|
||||
public interface FamilyRepository extends CrudRepository<Family,Long>{ |
||||
} |
@ -0,0 +1,72 @@ |
||||
package sig.family; |
||||
|
||||
import java.util.Date; |
||||
|
||||
import javax.persistence.Column; |
||||
import javax.persistence.Entity; |
||||
import javax.persistence.GeneratedValue; |
||||
import javax.persistence.GenerationType; |
||||
import javax.persistence.Id; |
||||
import javax.persistence.Table; |
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
|
||||
@Entity |
||||
@Table(name="knownlocations") |
||||
@RequestMapping |
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
public class KnownLocation { |
||||
@Id |
||||
@GeneratedValue(strategy=GenerationType.IDENTITY) |
||||
Long id; |
||||
double x,y; |
||||
String name; |
||||
boolean isSafe; |
||||
|
||||
public KnownLocation() {} |
||||
|
||||
public KnownLocation(double x, double y, String name, boolean isSafe) { |
||||
this.x = x; |
||||
this.y = y; |
||||
this.name=name; |
||||
this.isSafe=isSafe; |
||||
} |
||||
public Long getId() { |
||||
return id; |
||||
} |
||||
public void setId(Long id) { |
||||
this.id = id; |
||||
} |
||||
public double getX() { |
||||
return x; |
||||
} |
||||
public void setX(double x) { |
||||
this.x = x; |
||||
} |
||||
public double getY() { |
||||
return y; |
||||
} |
||||
public void setY(double y) { |
||||
this.y = y; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
public boolean isSafe() { |
||||
return isSafe; |
||||
} |
||||
|
||||
public void setSafe(boolean isSafe) { |
||||
this.isSafe = isSafe; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,7 @@ |
||||
package sig.family; |
||||
|
||||
import org.springframework.data.repository.CrudRepository; |
||||
|
||||
public interface KnownLocationRepository extends CrudRepository<KnownLocation,Long>{ |
||||
|
||||
} |
@ -0,0 +1,73 @@ |
||||
package sig.family; |
||||
|
||||
import java.util.Date; |
||||
|
||||
import javax.persistence.Column; |
||||
import javax.persistence.Entity; |
||||
import javax.persistence.GeneratedValue; |
||||
import javax.persistence.GenerationType; |
||||
import javax.persistence.Id; |
||||
import javax.persistence.Table; |
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
|
||||
@Entity |
||||
@Table(name="locations") |
||||
@RequestMapping |
||||
@JsonInclude(JsonInclude.Include.NON_NULL) |
||||
public class Location { |
||||
@Id |
||||
@GeneratedValue(strategy=GenerationType.IDENTITY) |
||||
Long id; |
||||
double x,y; |
||||
Long memberId; |
||||
|
||||
@Column(columnDefinition="datetime") |
||||
@JsonFormat(pattern="MM-dd-yyyy HH:mm:ss") |
||||
Date date; |
||||
|
||||
public Location() {} |
||||
|
||||
public Location(double x, double y, Long memberId, Date date) { |
||||
this.x = x; |
||||
this.y = y; |
||||
this.memberId = memberId; |
||||
this.date=date; |
||||
} |
||||
public Long getId() { |
||||
return id; |
||||
} |
||||
public void setId(Long id) { |
||||
this.id = id; |
||||
} |
||||
public double getX() { |
||||
return x; |
||||
} |
||||
public void setX(double x) { |
||||
this.x = x; |
||||
} |
||||
public double getY() { |
||||
return y; |
||||
} |
||||
public void setY(double y) { |
||||
this.y = y; |
||||
} |
||||
public Long getMemberId() { |
||||
return memberId; |
||||
} |
||||
public void setMemberId(Long memberId) { |
||||
this.memberId = memberId; |
||||
} |
||||
|
||||
public Date getDate() { |
||||
return date; |
||||
} |
||||
|
||||
public void setDate(Date date) { |
||||
this.date = date; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,7 @@ |
||||
package sig.family; |
||||
|
||||
import org.springframework.data.repository.CrudRepository; |
||||
|
||||
public interface LocationRepository extends CrudRepository<Location,Long>{ |
||||
|
||||
} |
Loading…
Reference in new issue