Skip to content

Commit

Permalink
Merge pull request #558 from dickschoeller/angular-client
Browse files Browse the repository at this point in the history
Add an angular client
  • Loading branch information
dickschoeller authored Jan 16, 2018
2 parents 81ec7f9 + bbfbcb7 commit a7e3817
Show file tree
Hide file tree
Showing 113 changed files with 22,714 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.schoellerfamily.gedbrowser.datamodel.Family;
import org.schoellerfamily.gedbrowser.persistence.domain.FamilyDocument;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -23,6 +24,7 @@
/**
* @author Dick Schoeller
*/
@CrossOrigin(origins = "http://localhost:4200")
@Controller
public final class FamilyController
extends OperationsEnabler<Family, FamilyDocument>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.schoellerfamily.gedbrowser.datamodel.Head;
import org.schoellerfamily.gedbrowser.persistence.domain.HeadDocument;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
Expand All @@ -14,6 +15,7 @@
/**
* @author Dick Schoeller
*/
@CrossOrigin(origins = "http://localhost:4200")
@Controller
public class HeadController
extends OperationsEnabler<Head, HeadDocument>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.schoellerfamily.gedbrowser.datamodel.Note;
import org.schoellerfamily.gedbrowser.persistence.domain.NoteDocument;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -22,6 +23,7 @@
/**
* @author Dick Schoeller
*/
@CrossOrigin(origins = "http://localhost:4200")
@Controller
public class NoteController
extends OperationsEnabler<Note, NoteDocument>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.schoellerfamily.gedbrowser.datamodel.Person;
import org.schoellerfamily.gedbrowser.persistence.domain.PersonDocument;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -22,6 +23,7 @@
/**
* @author Dick Schoeller
*/
@CrossOrigin(origins = "http://localhost:4200")
@Controller
public class PersonController
extends OperationsEnabler<Person, PersonDocument>
Expand Down Expand Up @@ -49,7 +51,7 @@ public ApiObject createPerson(@PathVariable final String db,
logger.info("Entering create person in db: " + db);
return create(readRoot(db), person, (i, id) ->
new ApiPerson(i.getType(), id, i.getAttributes(), i.getIndexName(),
i.getSurname()));
i.getSurname(), i.getLifespan()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.schoellerfamily.gedbrowser.datamodel.Source;
import org.schoellerfamily.gedbrowser.persistence.domain.SourceDocument;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -22,6 +23,7 @@
/**
* @author Dick Schoeller
*/
@CrossOrigin(origins = "http://localhost:4200")
@Controller
public class SourceController
extends OperationsEnabler<Source, SourceDocument>
Expand All @@ -48,7 +50,7 @@ public ApiObject createSource(@PathVariable final String db,
@RequestBody final ApiSource source) {
logger.info("Entering create source in db: " + db);
return create(readRoot(db), source, (i, id) ->
new ApiSource(i.getType(), id, i.getAttributes()));
new ApiSource(i.getType(), id, i.getAttributes(), i.getTitle()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.schoellerfamily.gedbrowser.datamodel.Submission;
import org.schoellerfamily.gedbrowser.persistence.domain.SubmissionDocument;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -22,6 +23,7 @@
/**
* @author Dick Schoeller
*/
@CrossOrigin(origins = "http://localhost:4200")
@Controller
public class SubmissionController
extends OperationsEnabler<Submission, SubmissionDocument>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.schoellerfamily.gedbrowser.datamodel.Submitter;
import org.schoellerfamily.gedbrowser.persistence.domain.SubmitterDocument;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -22,6 +23,7 @@
/**
* @author Dick Schoeller
*/
@CrossOrigin(origins = "http://localhost:4200")
@Controller
public class SubmitterController
extends OperationsEnabler<Submitter, SubmitterDocument>
Expand All @@ -48,7 +50,7 @@ public ApiObject createSubmitter(@PathVariable final String db,
@RequestBody final ApiSubmitter submitter) {
logger.info("Entering create submitter in db: " + db);
return create(readRoot(db), submitter, (i, id) ->
new ApiSubmitter(i.getType(), id, i.getAttributes()));
new ApiSubmitter(i.getType(), id, i.getAttributes(), i.getName()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package org.schoellerfamily.gedbrowser.api.datamodel;

import java.io.Serializable;

/**
* @author Dick Schoeller
*/
public final class ApiLifespan implements Serializable {
/** */
private static final long serialVersionUID = 1L;

/**
* Holds the birth date, empty string means unknown.
*/
private final String birthDate;

/**
* Holds the death date, null means unknown.
*/
private final String deathDate;

/**
* Constructor.
*/
public ApiLifespan() {
super();
birthDate = "";
deathDate = "";
}

/**
* @param birthDate the birth date
* @param deathDate the death date
*/
public ApiLifespan(final String birthDate, final String deathDate) {
this.birthDate = defaultValue(birthDate);
this.deathDate = defaultValue(deathDate);
}

/**
* @param input the input string
* @return input or empty string if input is null
*/
private static String defaultValue(final String input) {
if (input == null) {
return "";
}
return input;
}
/**
* @return the birth date
*/
public String getBirthDate() {
return birthDate;
}

/**
* @return the death date
*/
public String getDeathDate() {
return deathDate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,49 +14,60 @@ public final class ApiPerson extends ApiObject {
/**
* The name in a form that is usable for indexing.
*/
private String indexName;
private final String indexName;

/**
* The surname.
*/
private String surname;
private final String surname;

/**
* The lifespan of this person.
*/
private final ApiLifespan lifespan;

/**
* Constructor.
*/
public ApiPerson() {
super();
indexName = "";
surname = "";
lifespan = new ApiLifespan("", "");
}

/**
* Constructor.
*
* @param type a string describing the data type of this object
* @param string a string containing the primary value of this object
* @param indexName the name in a form that is usable for indexing
* @param surname the surname
* @param lifespan the lifespan of this person
*/
public ApiPerson(final String type, final String string,
final String indexName, final String surname) {
final String indexName, final String surname,
final ApiLifespan lifespan) {
super(type, string);
this.indexName = indexName;
this.surname = surname;
this.lifespan = lifespan;
}

/**
* Constructor.
* @param type a string describing the data type of this object
* @param string a string containing the primary value of this object
* @param attributes the list of subordinate attributes of this object
* @param indexName the name in a form that is usable for indexing
* @param surname the surname
* @param lifespan the lifespan of this person
*/
public ApiPerson(final String type, final String string,
final List<ApiAttribute> attributes,
final String indexName, final String surname) {
final List<ApiAttribute> attributes, final String indexName,
final String surname, final ApiLifespan lifespan) {
super(type, string, attributes);
this.indexName = indexName;
this.surname = surname;
this.lifespan = lifespan;
}

/**
Expand All @@ -73,6 +84,13 @@ public String getSurname() {
return surname;
}

/**
* @return the lifespan of this person
*/
public ApiLifespan getLifespan() {
return lifespan;
}

/**
* @param visitor the visitor
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,30 @@ public final class ApiSource extends ApiObject {
/** */
private static final long serialVersionUID = 2L;

/**
* The title string.
*/
private final String title;

/**
* Constructor.
*/
public ApiSource() {
super();
this.title = "Unknown";
}

/**
* Constructor.
*
* @param type a string describing the data type of this object
* @param string a string containing the primary value of this object
* @param title the title of the source
*/
public ApiSource(final String type, final String string) {
public ApiSource(final String type, final String string,
final String title) {
super(type, string);
this.title = title;
}

/**
Expand All @@ -32,10 +41,19 @@ public ApiSource(final String type, final String string) {
* @param type a string describing the data type of this object
* @param string a string containing the primary value of this object
* @param attributes the list of subordinate attributes of this object
* @param title the title of the source
*/
public ApiSource(final String type, final String string,
final List<ApiAttribute> attributes) {
final List<ApiAttribute> attributes, final String title) {
super(type, string, attributes);
this.title = title;
}

/**
* @return the title string
*/
public String getTitle() {
return title;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,30 @@ public final class ApiSubmitter extends ApiObject {
/** */
private static final long serialVersionUID = 2L;

/**
* The name of the submitter.
*/
private final String name;

/**
* Constructor.
*/
public ApiSubmitter() {
super();
this.name = "? ?";
}

/**
* Constructor.
*
* @param type a string describing the data type of this object
* @param string a string containing the primary value of this object
* @param name the name of the submitter
*/
public ApiSubmitter(final String type, final String string) {
public ApiSubmitter(final String type, final String string,
final String name) {
super(type, string);
this.name = name;
}

/**
Expand All @@ -32,10 +41,19 @@ public ApiSubmitter(final String type, final String string) {
* @param type a string describing the data type of this object
* @param string a string containing the primary value of this object
* @param attributes the list of subordinate attributes of this object
* @param name the name of the submitter
*/
public ApiSubmitter(final String type, final String string,
final List<ApiAttribute> attributes) {
final List<ApiAttribute> attributes, final String name) {
super(type, string, attributes);
this.name = name;
}

/**
* @return the submitter name
*/
public String getName() {
return name;
}

/**
Expand Down
Loading

0 comments on commit a7e3817

Please sign in to comment.