From ef8b007a8fcba4fc0cc19cf46466e4f413489bc7 Mon Sep 17 00:00:00 2001 From: Ashish Sam T George Date: Fri, 29 Sep 2023 02:26:44 +0530 Subject: [PATCH] Use Builder pattern for building Person and Tithe Entities - Create Builder class - Create Head of family and family members, when a new family is created - Create a new Graphql schema for Person mutation input through family - Removed @NotNull constraint in PersonMutationInput for family field --- .../java/com/tithe/entity/FamilyEntity.java | 13 ++- .../java/com/tithe/entity/PersonBuilder.java | 107 ++++++++++++++++++ .../java/com/tithe/entity/PersonEntity.java | 5 +- .../java/com/tithe/entity/TitheBuilder.java | 98 ++++++++++++++++ .../com/tithe/model/FamilyMutationInput.java | 7 ++ .../com/tithe/model/PersonMutationInput.java | 4 +- .../mutation/FamilyMutationService.java | 45 ++++++-- .../mutation/PersonMutationService.java | 106 ++++++++++++----- .../mutation/TitheMutationService.java | 4 +- .../service/query/PersonQueryService.java | 1 + .../service/query/TitheQueryService.java | 35 ------ .../resources/graphql/types/Family.graphqls | 3 + .../resources/graphql/types/Person.graphqls | 14 +++ 13 files changed, 364 insertions(+), 78 deletions(-) create mode 100755 Tithe-Spring/src/main/java/com/tithe/entity/PersonBuilder.java create mode 100755 Tithe-Spring/src/main/java/com/tithe/entity/TitheBuilder.java diff --git a/Tithe-Spring/src/main/java/com/tithe/entity/FamilyEntity.java b/Tithe-Spring/src/main/java/com/tithe/entity/FamilyEntity.java index 207fec2..36de3a9 100755 --- a/Tithe-Spring/src/main/java/com/tithe/entity/FamilyEntity.java +++ b/Tithe-Spring/src/main/java/com/tithe/entity/FamilyEntity.java @@ -3,6 +3,7 @@ */ package com.tithe.entity; + import java.util.List; import jakarta.persistence.CascadeType; @@ -13,6 +14,7 @@ import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToMany; +import jakarta.persistence.OneToOne; import jakarta.persistence.Table; import jakarta.persistence.UniqueConstraint; import jakarta.validation.constraints.NotBlank; @@ -21,6 +23,7 @@ import lombok.Data; import lombok.NoArgsConstructor; + /** * @author Ashish Sam T George * @@ -29,7 +32,8 @@ @AllArgsConstructor @NoArgsConstructor @Entity -@Table(name = "family_table", uniqueConstraints = @UniqueConstraint(columnNames = {"familyName", "phone"})) +@Table(name = "family_table", uniqueConstraints = @UniqueConstraint(columnNames = { "familyName", + "head_of_family_id", "phone" })) public class FamilyEntity { @Id @@ -51,7 +55,12 @@ public class FamilyEntity { @JoinColumn(name = "koottayma_id") private KoottaymaEntity koottayma; - @OneToMany(mappedBy = "family") + @NotNull(message = "Head of Family does not exist") + @OneToOne(cascade = CascadeType.PERSIST) + @JoinColumn(name = "head_of_family_id") + private PersonEntity headOfFamily; + + @OneToMany(cascade = CascadeType.PERSIST, mappedBy = "family") private List persons; @OneToMany(mappedBy = "family") diff --git a/Tithe-Spring/src/main/java/com/tithe/entity/PersonBuilder.java b/Tithe-Spring/src/main/java/com/tithe/entity/PersonBuilder.java new file mode 100755 index 0000000..2d03d04 --- /dev/null +++ b/Tithe-Spring/src/main/java/com/tithe/entity/PersonBuilder.java @@ -0,0 +1,107 @@ +/** + * + */ +package com.tithe.entity; + + +import java.time.LocalDate; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; + +import com.tithe.model.GenderEnum; +import com.tithe.utils.ObjectValidation; + + +/** + * @author Ashish Sam T George + * + */ +public class PersonBuilder { + + private Long personId; + private String baptismName; + private String personName; + private FamilyEntity family; + private RelationEntity relation; + private GenderEnum gender; + private LocalDate dob; + private String phone; + private List tithes; + private Boolean moved = false; + private List educations; + private List occupations; + private Boolean active = true; + + public PersonBuilder personId(Long personId) { + this.personId = personId; + return this; + } + + public PersonBuilder baptismName(String baptismName) { + this.baptismName = baptismName; + return this; + } + + public PersonBuilder personName(String personName) { + this.personName = personName; + return this; + } + + public PersonBuilder family(FamilyEntity family) { + this.family = family; + return this; + } + + public PersonBuilder relation(RelationEntity relation) { + this.relation = relation; + return this; + } + + public PersonBuilder gender(GenderEnum gender) { + this.gender = gender; + return this; + } + + public PersonBuilder dob(LocalDate dob) { + this.dob = dob; + return this; + } + + public PersonBuilder phone(String phone) { + this.phone = phone; + return this; + } + +// public PersonBuilder tithes(List tithes) { +// this.tithes = tithes; +// return this; +// } + + public PersonBuilder moved(Boolean moved) { + this.moved = moved; + return this; + } + + public PersonBuilder educations(List educations) { + this.educations = educations; + return this; + } + + public PersonBuilder occupations(List occupations) { + this.occupations = occupations; + return this; + } + + public PersonBuilder active(Boolean active) { + this.active = active; + return this; + } + + public PersonEntity build() { + PersonEntity person = new PersonEntity(personId, baptismName, personName, family, relation, gender, dob, phone, + tithes, moved, educations, occupations, active); + return person; + } + +} diff --git a/Tithe-Spring/src/main/java/com/tithe/entity/PersonEntity.java b/Tithe-Spring/src/main/java/com/tithe/entity/PersonEntity.java index fbad0e5..1e63e9e 100755 --- a/Tithe-Spring/src/main/java/com/tithe/entity/PersonEntity.java +++ b/Tithe-Spring/src/main/java/com/tithe/entity/PersonEntity.java @@ -53,8 +53,9 @@ public class PersonEntity { @NotBlank(message = "Name of Person is empty or null") private String personName; - @NotNull(message = "Family does not exist") - @ManyToOne(cascade = CascadeType.PERSIST) +// @NotNull(message = "Family does not exist") +// @ManyToOne(cascade = CascadeType.PERSIST) + @ManyToOne @JoinColumn(name = "family_id") private FamilyEntity family; diff --git a/Tithe-Spring/src/main/java/com/tithe/entity/TitheBuilder.java b/Tithe-Spring/src/main/java/com/tithe/entity/TitheBuilder.java new file mode 100755 index 0000000..0c54423 --- /dev/null +++ b/Tithe-Spring/src/main/java/com/tithe/entity/TitheBuilder.java @@ -0,0 +1,98 @@ +/** + * + */ +package com.tithe.entity; + + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; + +import com.tithe.model.TitheMutationInput; + + +/** + * @author Ashish Sam T George + * + */ +public class TitheBuilder { + + private Long titheId; + private Double titheAmount; + private PersonEntity person; + private FamilyEntity family; + private KoottaymaEntity koottayma; + private ParishEntity parish; + private ForaneEntity forane; + private LocalDate timeStamp; + + public TitheBuilder titheId(Long titheId) { + this.titheId = titheId; + return this; + } + + public TitheBuilder titheAmount(Double titheAmount) { + this.titheAmount = titheAmount; + return this; + } + + public TitheBuilder person(PersonEntity person) { + this.person = person; + return this; + } + + public TitheBuilder family(FamilyEntity family) { + this.family = family; + return this; + } + + public TitheBuilder koottayma(KoottaymaEntity koottayma) { + this.koottayma = koottayma; + return this; + } + + public TitheBuilder parish(ParishEntity parish) { + this.parish = parish; + return this; + } + + public TitheBuilder forane(ForaneEntity forane) { + this.forane = forane; + return this; + } + + public TitheBuilder timeStamp(LocalDate timeStamp) { + this.timeStamp = timeStamp; + return this; + } + + public TitheEntity build() { + TitheEntity tithe = new TitheEntity(titheId, titheAmount, person, family, koottayma, parish, + forane, timeStamp); + return tithe; + } + + public List buildTithe(PersonEntity person, + List titheMutationInputs) { + List tithes = new ArrayList<>(); + if (titheMutationInputs != null && titheMutationInputs.size() != 0) { +// objectValidation.validateObjects(titheMutationInputs); + + for (TitheMutationInput titheMutationInput : titheMutationInputs) { +// New Builder object for each tithe + TitheBuilder titheBuilder = new TitheBuilder(); + TitheEntity tithe = titheBuilder.titheAmount(titheMutationInput.getTitheAmount()) + .person(person) + .family(person.getFamily()) + .koottayma(person.getFamily().getKoottayma()) + .parish(person.getFamily().getKoottayma().getParish()) + .forane(person.getFamily().getKoottayma().getParish().getForane()) + .timeStamp(titheMutationInput.getTimeStamp()) + .build(); + tithes.add(tithe); + } + } + return tithes; + } + +} diff --git a/Tithe-Spring/src/main/java/com/tithe/model/FamilyMutationInput.java b/Tithe-Spring/src/main/java/com/tithe/model/FamilyMutationInput.java index 9f43f55..5bd7243 100755 --- a/Tithe-Spring/src/main/java/com/tithe/model/FamilyMutationInput.java +++ b/Tithe-Spring/src/main/java/com/tithe/model/FamilyMutationInput.java @@ -3,6 +3,8 @@ */ package com.tithe.model; +import java.util.List; + import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Positive; @@ -26,6 +28,11 @@ public class FamilyMutationInput { @Positive(message = "Id of Koottayma should be valid") @NotNull(message = "Id of Koottayma should not be empty or null") Long koottaymaId; + + @NotNull(message = "Head of Family should not be empty or null") + PersonMutationInput headOfFamily; + + List persons; Boolean active = true; diff --git a/Tithe-Spring/src/main/java/com/tithe/model/PersonMutationInput.java b/Tithe-Spring/src/main/java/com/tithe/model/PersonMutationInput.java index fa600de..b2b83b2 100755 --- a/Tithe-Spring/src/main/java/com/tithe/model/PersonMutationInput.java +++ b/Tithe-Spring/src/main/java/com/tithe/model/PersonMutationInput.java @@ -27,8 +27,8 @@ public class PersonMutationInput { @NotBlank(message = "Name of Person should not be empty or null") String personName; - @Positive(message = "Id of Family should be valid") - @NotNull(message = "Id of Family should not be empty or null") +// @Positive(message = "Id of Family should be valid") +// @NotNull(message = "Id of Family should not be empty or null") Long familyId; @Positive(message = "Id of Relation should be valid") diff --git a/Tithe-Spring/src/main/java/com/tithe/service/mutation/FamilyMutationService.java b/Tithe-Spring/src/main/java/com/tithe/service/mutation/FamilyMutationService.java index 61304e7..9679120 100755 --- a/Tithe-Spring/src/main/java/com/tithe/service/mutation/FamilyMutationService.java +++ b/Tithe-Spring/src/main/java/com/tithe/service/mutation/FamilyMutationService.java @@ -3,6 +3,8 @@ */ package com.tithe.service.mutation; + +import java.util.List; import java.util.Optional; import org.springframework.beans.factory.annotation.Autowired; @@ -10,9 +12,10 @@ import com.tithe.entity.AddressEntity; import com.tithe.entity.FamilyEntity; -import com.tithe.entity.KoottaymaEntity; +import com.tithe.entity.PersonEntity; import com.tithe.model.AddressMutationInput; import com.tithe.model.FamilyMutationInput; +import com.tithe.model.PersonMutationInput; import com.tithe.repository.FamilyRepository; import com.tithe.service.query.AddressQueryService; import com.tithe.service.query.KoottaymaQueryService; @@ -20,6 +23,7 @@ import graphql.GraphQLException; + /** * @author Ashish Sam T George * @@ -36,6 +40,9 @@ public class FamilyMutationService { @Autowired private KoottaymaQueryService koottaymaQueryService; + @Autowired + private PersonMutationService personMutationService; + @Autowired private FamilyRepository familyRepository; @@ -46,19 +53,37 @@ public FamilyEntity createOneFamily(FamilyMutationInput familyMutationInput) { FamilyEntity family = new FamilyEntity(); family.setFamilyName(familyMutationInput.getFamilyName()); +// If the same address already exists, then set that address to family entity or else build a new address +// entity and set it to family entity AddressMutationInput addressInput = familyMutationInput.getAddress(); - if (addressInput!=null) { + if (addressInput != null) { AddressEntity address = addressQueryService.getOneAddress(addressInput); - if (address!=null) { + if (address != null) { family.setAddress(address); - } - else { + } else { family.setAddress(addressQueryService.buildAddressEntity(addressInput)); } } family.setPhone(familyMutationInput.getPhone()); - family.setKoottayma(koottaymaQueryService.getOneKoottayma(familyMutationInput.getKoottaymaId())); + family.setKoottayma( + koottaymaQueryService.getOneKoottayma(familyMutationInput.getKoottaymaId())); + +// Build Head of Family person entity + PersonMutationInput headOfFamilyInput = familyMutationInput.getHeadOfFamily(); + PersonEntity headOfFamily = personMutationService.buildPersonWithTithe(family, + headOfFamilyInput); + family.setHeadOfFamily(headOfFamily); + +// Build Family members + List familyMemberInputs = familyMutationInput.getPersons(); + if (familyMemberInputs != null) { + + objectValidation.validateObjects(familyMemberInputs); + List familyMembers = personMutationService.buildPersonsWithTithe(family, + familyMemberInputs); + family.setPersons(familyMembers); + } family.setActive(familyMutationInput.getActive()); @@ -66,24 +91,24 @@ public FamilyEntity createOneFamily(FamilyMutationInput familyMutationInput) { } public FamilyEntity activateOneFamily(Long familyId) { - if (familyId!=null) { + if (familyId != null) { Optional obtainedFamily = familyRepository.findById(familyId); FamilyEntity family = obtainedFamily.orElseThrow(); family.setActive(true); return familyRepository.save(family); } - GraphQLException exception = new GraphQLException("Some Error Occured") ; + GraphQLException exception = new GraphQLException("Some Error Occured"); throw exception; } public FamilyEntity deactivateOneFamily(Long familyId) { - if (familyId!=null) { + if (familyId != null) { Optional obtainedFamily = familyRepository.findById(familyId); FamilyEntity family = obtainedFamily.orElseThrow(); family.setActive(false); return familyRepository.save(family); } - GraphQLException exception = new GraphQLException("Some Error Occured") ; + GraphQLException exception = new GraphQLException("Some Error Occured"); throw exception; } diff --git a/Tithe-Spring/src/main/java/com/tithe/service/mutation/PersonMutationService.java b/Tithe-Spring/src/main/java/com/tithe/service/mutation/PersonMutationService.java index 1bdc6dd..2e70183 100755 --- a/Tithe-Spring/src/main/java/com/tithe/service/mutation/PersonMutationService.java +++ b/Tithe-Spring/src/main/java/com/tithe/service/mutation/PersonMutationService.java @@ -3,14 +3,22 @@ */ package com.tithe.service.mutation; + import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import java.util.Optional; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import com.tithe.entity.EducationEntity; +import com.tithe.entity.FamilyEntity; +import com.tithe.entity.OccupationEntity; +import com.tithe.entity.PersonBuilder; import com.tithe.entity.PersonEntity; +import com.tithe.entity.RelationEntity; +import com.tithe.entity.TitheBuilder; import com.tithe.entity.TitheEntity; import com.tithe.model.PersonMutationInput; import com.tithe.model.TitheMutationInput; @@ -18,10 +26,14 @@ import com.tithe.service.query.EducationQueryService; import com.tithe.service.query.FamilyQueryService; import com.tithe.service.query.OccupationQueryService; +import com.tithe.service.query.PersonQueryService; import com.tithe.service.query.RelationQueryService; import com.tithe.service.query.TitheQueryService; import com.tithe.utils.ObjectValidation; +import graphql.GraphQLException; + + /** * @author Ashish Sam T George * @@ -35,6 +47,9 @@ public class PersonMutationService { @Autowired private PersonRepository personRepository; + @Autowired + private PersonQueryService personQueryService; + @Autowired private FamilyQueryService familyQueryService; @@ -52,34 +67,16 @@ public class PersonMutationService { public PersonEntity createOnePerson(PersonMutationInput personMutationInput) { +// Validate the obtained input objectValidation.validateObject(personMutationInput); - PersonEntity person = new PersonEntity(); - person.setBaptismName(personMutationInput.getBaptismName()); - person.setPersonName(personMutationInput.getPersonName()); - person.setFamily(familyQueryService.getOneFamily(personMutationInput.getFamilyId())); - person.setRelation(relationQueryService.getOneRelation(personMutationInput.getRelationId())); - person.setGender(personMutationInput.getGender()); - person.setDob(personMutationInput.getDob()); - person.setPhone(personMutationInput.getPhone()); - - List titheInputs = personMutationInput.getTithes(); - List tithes = new ArrayList<>(); - if (titheInputs!=null && titheInputs.size()!=0) { - tithes = titheQueryService.buildTitheEntities(person, titheInputs); - } - person.setTithes(tithes); - - person.setMoved(personMutationInput.getMoved()); - - if (personMutationInput.getEducationIds().size()!=0) { - person.setEducations(educationQueryService.getManyEducations(personMutationInput.getEducationIds())); - } - if (personMutationInput.getOccupationIds().size()!=0) { - person.setOccupations(occupationQueryService.getManyOccupations(personMutationInput.getOccupationIds())); +// Get family using the id, if exists, or else return error + FamilyEntity family = familyQueryService.getOneFamily(personMutationInput.getFamilyId()); + if (family == null) { + throw new GraphQLException("Family does not exist"); } - person.setActive(personMutationInput.getActive()); + PersonEntity person = buildPersonWithTithe(family, personMutationInput); return personRepository.save(person); } @@ -95,7 +92,7 @@ public PersonEntity activateOnePerson(Long id) { public List activateManyPersons(List ids) { List persons = personRepository.findAllById(ids); - if (persons.size()!=0) { + if (persons.size() != 0) { for (PersonEntity person : persons) { person.setActive(true); } @@ -116,7 +113,7 @@ public PersonEntity deactivateOnePerson(Long id) { public List deactivateManyPersons(List ids) { List persons = personRepository.findAllById(ids); - if (persons.size()!=0) { + if (persons.size() != 0) { for (PersonEntity person : persons) { person.setActive(false); } @@ -124,5 +121,62 @@ public List deactivateManyPersons(List ids) { } return null; } + + public List getEducations(List educationIds) { + List educations = new ArrayList<>(); + if (educationIds != null && educationIds.size() != 0) { + educations = educationQueryService.getManyEducations(educationIds); + } + return educations; + } + + public List getOccupations(List occupationIds){ + List occupations = new ArrayList<>(); + if (occupationIds != null && occupationIds.size() != 0) { + occupations = occupationQueryService.getManyOccupations(occupationIds); + } + return occupations; + } + + public PersonEntity buildPersonWithTithe(FamilyEntity family, PersonMutationInput personMutationInput) { + objectValidation.validateObject(personMutationInput); + + RelationEntity relation = relationQueryService + .getOneRelation(personMutationInput.getRelationId()); + + List educations = getEducations(personMutationInput.getEducationIds()); + + List occupations = getOccupations(personMutationInput.getOccupationIds()); + + PersonBuilder personBuilder = new PersonBuilder(); + PersonEntity person = personBuilder.baptismName(personMutationInput.getBaptismName()) + .personName(personMutationInput.getPersonName()) + .family(family) + .relation(relation) + .gender(personMutationInput.getGender()) + .dob(personMutationInput.getDob()) + .phone(personMutationInput.getPhone()) + .moved(personMutationInput.getMoved()) + .educations(educations) + .occupations(occupations) + .active(personMutationInput.getActive()) + .build(); + +// Build Tithe entity + TitheBuilder titheBuilder = new TitheBuilder(); + List tithes = titheBuilder.buildTithe(person, personMutationInput.getTithes()); + person.setTithes(tithes); + + return person; + } + + public List buildPersonsWithTithe(FamilyEntity family, List personMutationInputs){ + List persons = new ArrayList<>(); + for(PersonMutationInput personMutationInput: personMutationInputs) { + PersonEntity person = buildPersonWithTithe(family, personMutationInput); + persons.add(person); + } + return persons; + } } diff --git a/Tithe-Spring/src/main/java/com/tithe/service/mutation/TitheMutationService.java b/Tithe-Spring/src/main/java/com/tithe/service/mutation/TitheMutationService.java index edb15bf..f8fce65 100755 --- a/Tithe-Spring/src/main/java/com/tithe/service/mutation/TitheMutationService.java +++ b/Tithe-Spring/src/main/java/com/tithe/service/mutation/TitheMutationService.java @@ -9,6 +9,7 @@ import org.springframework.stereotype.Service; import com.tithe.entity.PersonEntity; +import com.tithe.entity.TitheBuilder; import com.tithe.entity.TitheEntity; import com.tithe.model.TitheMutationInput; import com.tithe.repository.TitheRepository; @@ -36,7 +37,8 @@ public List createManyTithes(Long personId, // TODO Try adding @NotNull in the method parameter above - No Use PersonEntity person = personQueryService.getOnePerson(personId); - List tithes = titheQueryService.buildTitheEntities(person, titheMutationInputs); + TitheBuilder titheBuilder = new TitheBuilder(); + List tithes = titheBuilder.buildTithe(person, titheMutationInputs); return titheRepository.saveAll(tithes); } diff --git a/Tithe-Spring/src/main/java/com/tithe/service/query/PersonQueryService.java b/Tithe-Spring/src/main/java/com/tithe/service/query/PersonQueryService.java index 148d9ec..0bc00de 100755 --- a/Tithe-Spring/src/main/java/com/tithe/service/query/PersonQueryService.java +++ b/Tithe-Spring/src/main/java/com/tithe/service/query/PersonQueryService.java @@ -39,6 +39,7 @@ public class PersonQueryService { @Autowired private FamilyQueryService familyQueryService; + public PersonEntity getOnePerson(Long id) { Optional person = personRepository.findById(id); diff --git a/Tithe-Spring/src/main/java/com/tithe/service/query/TitheQueryService.java b/Tithe-Spring/src/main/java/com/tithe/service/query/TitheQueryService.java index 9e94995..5fd23c2 100755 --- a/Tithe-Spring/src/main/java/com/tithe/service/query/TitheQueryService.java +++ b/Tithe-Spring/src/main/java/com/tithe/service/query/TitheQueryService.java @@ -3,17 +3,8 @@ */ package com.tithe.service.query; -import java.util.ArrayList; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.tithe.entity.PersonEntity; -import com.tithe.entity.TitheEntity; -import com.tithe.model.TitheMutationInput; -import com.tithe.utils.ObjectValidation; - /** * @author Ashish Sam T George * @@ -21,30 +12,4 @@ @Service public class TitheQueryService { - @Autowired - private ObjectValidation objectValidation; - - public List buildTitheEntities(PersonEntity person, - List titheMutationInputs) { - - objectValidation.validateObjects(titheMutationInputs); - - List tithes = new ArrayList<>(); - for (TitheMutationInput titheInput : titheMutationInputs) { - TitheEntity tithe = new TitheEntity(); - tithe.setTitheAmount(titheInput.getTitheAmount()); - tithe.setTimeStamp(titheInput.getTimeStamp()); - tithe.setPerson(person); - tithe.setFamily(person.getFamily()); - tithe.setKoottayma(tithe.getFamily().getKoottayma()); - tithe.setParish(tithe.getKoottayma().getParish()); - tithe.setForane(tithe.getParish().getForane()); - - tithes.add(tithe); - } - - return tithes; - - } - } diff --git a/Tithe-Spring/src/main/resources/graphql/types/Family.graphqls b/Tithe-Spring/src/main/resources/graphql/types/Family.graphqls index fc06189..57a32ec 100755 --- a/Tithe-Spring/src/main/resources/graphql/types/Family.graphqls +++ b/Tithe-Spring/src/main/resources/graphql/types/Family.graphqls @@ -4,6 +4,7 @@ type Family{ address: Address phone: String koottayma: Koottayma! + headOfFamily: Person persons: [Person] tithes: [Tithe] active: Boolean @@ -21,5 +22,7 @@ input FamilyMutationInput{ address: AddressMutationInput phone: String koottaymaId: ID! + headOfFamily: PersonMutationThroughFamilyInput! + persons: [PersonMutationThroughFamilyInput] active: Boolean = true } diff --git a/Tithe-Spring/src/main/resources/graphql/types/Person.graphqls b/Tithe-Spring/src/main/resources/graphql/types/Person.graphqls index 8e731ed..bd2c1b1 100755 --- a/Tithe-Spring/src/main/resources/graphql/types/Person.graphqls +++ b/Tithe-Spring/src/main/resources/graphql/types/Person.graphqls @@ -38,6 +38,20 @@ input PersonMutationInput{ active: Boolean = true } +input PersonMutationThroughFamilyInput{ + baptismName: String! + personName: String! + relationId: ID! + gender: GenderEnum! + dob: LocalDate! + phone: String + tithes: [TitheMutationInput] + moved: Boolean = false + educationIds: [ID] + occupationIds: [ID] + active: Boolean = true +} + type Relation{ relationId: ID! relationName: String!