From 39950f0d6952c6a0f7906dbbae27524d4d69eecb Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Fri, 12 Apr 2019 16:43:16 +0200 Subject: [PATCH] several 'required' flags added to jdl and re-import --- .jhipster/Asset.json | 1 + .jhipster/Customer.json | 12 ++-- .jhipster/Membership.json | 1 + .jhipster/Share.json | 1 + build.gradle | 4 +- .../hostsharing/hsadminng/domain/Asset.java | 2 +- .../hsadminng/domain/Customer.java | 61 +++++++++---------- .../hsadminng/domain/Membership.java | 2 +- .../hostsharing/hsadminng/domain/Share.java | 2 +- .../service/CustomerQueryService.java | 31 +++++----- .../service/dto/CustomerCriteria.java | 38 ++++++------ .../service/mapper/CustomerMapper.java | 8 +-- src/main/jdl/customer.jdl | 13 ++-- ...20190403083738_added_entity_Membership.xml | 6 +- .../20190403083739_added_entity_Share.xml | 6 +- .../20190403083740_added_entity_Asset.xml | 6 +- .../asset/asset-update.component.html | 11 +++- .../customer/customer-update.component.html | 2 +- src/main/webapp/app/entities/entity.module.ts | 54 +++++++++++++++- .../membership-update.component.html | 12 +++- .../share/share-update.component.html | 11 +++- .../webapp/app/shared/model/customer.model.ts | 8 +-- src/main/webapp/i18n/de/customer.json | 4 +- src/main/webapp/i18n/en/customer.json | 4 +- .../asset/asset-update.component.spec.ts | 4 +- .../customer-update.component.spec.ts | 4 +- .../membership-update.component.spec.ts | 4 +- .../share/share-update.component.spec.ts | 4 +- 28 files changed, 190 insertions(+), 126 deletions(-) diff --git a/.jhipster/Asset.json b/.jhipster/Asset.json index baf8a85f..c1e70387 100644 --- a/.jhipster/Asset.json +++ b/.jhipster/Asset.json @@ -37,6 +37,7 @@ "relationshipType": "many-to-one", "otherEntityName": "membership", "otherEntityRelationshipName": "asset", + "relationshipValidateRules": "required", "relationshipName": "member", "otherEntityField": "id" } diff --git a/.jhipster/Customer.json b/.jhipster/Customer.json index b449ee9d..36d7340c 100644 --- a/.jhipster/Customer.json +++ b/.jhipster/Customer.json @@ -67,17 +67,17 @@ } ], "relationships": [ - { - "relationshipType": "one-to-many", - "otherEntityName": "membership", - "otherEntityRelationshipName": "customer", - "relationshipName": "membership" - }, { "relationshipType": "one-to-many", "otherEntityName": "customerContact", "otherEntityRelationshipName": "customer", "relationshipName": "role" + }, + { + "relationshipType": "one-to-many", + "otherEntityName": "membership", + "otherEntityRelationshipName": "customer", + "relationshipName": "membership" } ], "changelogDate": "20190403083735", diff --git a/.jhipster/Membership.json b/.jhipster/Membership.json index 3c479c3f..c44a5c77 100644 --- a/.jhipster/Membership.json +++ b/.jhipster/Membership.json @@ -30,6 +30,7 @@ "relationshipType": "many-to-one", "otherEntityName": "customer", "otherEntityRelationshipName": "membership", + "relationshipValidateRules": "required", "relationshipName": "customer", "otherEntityField": "prefix" } diff --git a/.jhipster/Share.json b/.jhipster/Share.json index 181ab499..630f5a24 100644 --- a/.jhipster/Share.json +++ b/.jhipster/Share.json @@ -37,6 +37,7 @@ "relationshipType": "many-to-one", "otherEntityName": "membership", "otherEntityRelationshipName": "share", + "relationshipValidateRules": "required", "relationshipName": "member", "otherEntityField": "id" } diff --git a/build.gradle b/build.gradle index 7f77ecd1..542e5db4 100644 --- a/build.gradle +++ b/build.gradle @@ -211,8 +211,8 @@ pitest { threads = 4 // Do not set these limit even lower, they are already pretty bad values! - // 83%*73% means that only ~60% of the code properly covered by automated tests. - mutationThreshold = 73 + // 83%*78% means that only ~66% of the code is properly covered by automated tests. + mutationThreshold = 78 coverageThreshold = 83 outputFormats = ['XML', 'HTML'] diff --git a/src/main/java/org/hostsharing/hsadminng/domain/Asset.java b/src/main/java/org/hostsharing/hsadminng/domain/Asset.java index f5256681..b223a037 100644 --- a/src/main/java/org/hostsharing/hsadminng/domain/Asset.java +++ b/src/main/java/org/hostsharing/hsadminng/domain/Asset.java @@ -44,7 +44,7 @@ public class Asset implements Serializable { private String comment; @NotNull - @ManyToOne + @ManyToOne(optional = false) @JsonIgnoreProperties("assets") private Membership member; diff --git a/src/main/java/org/hostsharing/hsadminng/domain/Customer.java b/src/main/java/org/hostsharing/hsadminng/domain/Customer.java index 1e6b248a..f48aa72c 100644 --- a/src/main/java/org/hostsharing/hsadminng/domain/Customer.java +++ b/src/main/java/org/hostsharing/hsadminng/domain/Customer.java @@ -1,15 +1,12 @@ package org.hostsharing.hsadminng.domain; -import com.fasterxml.jackson.annotation.JsonIgnore; - import javax.persistence.*; import javax.validation.constraints.*; - import java.io.Serializable; import java.util.HashSet; -import java.util.Set; import java.util.Objects; +import java.util.Set; /** * A Customer. @@ -58,10 +55,12 @@ public class Customer implements Serializable { @Column(name = "billing_salutation", length = 80) private String billingSalutation; - @OneToMany(mappedBy = "customer") - private Set memberships = new HashSet<>(); @OneToMany(mappedBy = "customer") private Set roles = new HashSet<>(); + + @OneToMany(mappedBy = "customer") + private Set memberships = new HashSet<>(); + // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove public Long getId() { return id; @@ -162,31 +161,6 @@ public class Customer implements Serializable { this.billingSalutation = billingSalutation; } - public Set getMemberships() { - return memberships; - } - - public Customer memberships(Set memberships) { - this.memberships = memberships; - return this; - } - - public Customer addMembership(Membership membership) { - this.memberships.add(membership); - membership.setCustomer(this); - return this; - } - - public Customer removeMembership(Membership membership) { - this.memberships.remove(membership); - membership.setCustomer(null); - return this; - } - - public void setMemberships(Set memberships) { - this.memberships = memberships; - } - public Set getRoles() { return roles; } @@ -211,6 +185,31 @@ public class Customer implements Serializable { public void setRoles(Set customerContacts) { this.roles = customerContacts; } + + public Set getMemberships() { + return memberships; + } + + public Customer memberships(Set memberships) { + this.memberships = memberships; + return this; + } + + public Customer addMembership(Membership membership) { + this.memberships.add(membership); + membership.setCustomer(this); + return this; + } + + public Customer removeMembership(Membership membership) { + this.memberships.remove(membership); + membership.setCustomer(null); + return this; + } + + public void setMemberships(Set memberships) { + this.memberships = memberships; + } // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove @Override diff --git a/src/main/java/org/hostsharing/hsadminng/domain/Membership.java b/src/main/java/org/hostsharing/hsadminng/domain/Membership.java index 4d48117e..9019382a 100644 --- a/src/main/java/org/hostsharing/hsadminng/domain/Membership.java +++ b/src/main/java/org/hostsharing/hsadminng/domain/Membership.java @@ -41,7 +41,7 @@ public class Membership implements Serializable { private Set assets = new HashSet<>(); @NotNull - @ManyToOne + @ManyToOne(optional = false) @JsonIgnoreProperties("memberships") private Customer customer; diff --git a/src/main/java/org/hostsharing/hsadminng/domain/Share.java b/src/main/java/org/hostsharing/hsadminng/domain/Share.java index d5d92426..5684d545 100644 --- a/src/main/java/org/hostsharing/hsadminng/domain/Share.java +++ b/src/main/java/org/hostsharing/hsadminng/domain/Share.java @@ -45,7 +45,7 @@ public class Share implements Serializable { private String comment; @NotNull - @ManyToOne + @ManyToOne(optional = false) @JsonIgnoreProperties("shares") private Membership member; diff --git a/src/main/java/org/hostsharing/hsadminng/service/CustomerQueryService.java b/src/main/java/org/hostsharing/hsadminng/service/CustomerQueryService.java index bc3397e2..214369a7 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/CustomerQueryService.java +++ b/src/main/java/org/hostsharing/hsadminng/service/CustomerQueryService.java @@ -1,9 +1,14 @@ package org.hostsharing.hsadminng.service; -import java.util.List; - -import javax.persistence.criteria.JoinType; - +import io.github.jhipster.service.QueryService; +import org.hostsharing.hsadminng.domain.Customer; +import org.hostsharing.hsadminng.domain.CustomerContact_; +import org.hostsharing.hsadminng.domain.Customer_; +import org.hostsharing.hsadminng.domain.Membership_; +import org.hostsharing.hsadminng.repository.CustomerRepository; +import org.hostsharing.hsadminng.service.dto.CustomerCriteria; +import org.hostsharing.hsadminng.service.dto.CustomerDTO; +import org.hostsharing.hsadminng.service.mapper.CustomerMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.data.domain.Page; @@ -12,14 +17,8 @@ import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import io.github.jhipster.service.QueryService; - -import org.hostsharing.hsadminng.domain.Customer; -import org.hostsharing.hsadminng.domain.*; // for static metamodels -import org.hostsharing.hsadminng.repository.CustomerRepository; -import org.hostsharing.hsadminng.service.dto.CustomerCriteria; -import org.hostsharing.hsadminng.service.dto.CustomerDTO; -import org.hostsharing.hsadminng.service.mapper.CustomerMapper; +import javax.persistence.criteria.JoinType; +import java.util.List; /** * Service for executing complex queries for Customer entities in the database. @@ -110,14 +109,14 @@ public class CustomerQueryService extends QueryService { if (criteria.getBillingSalutation() != null) { specification = specification.and(buildStringSpecification(criteria.getBillingSalutation(), Customer_.billingSalutation)); } - if (criteria.getMembershipId() != null) { - specification = specification.and(buildSpecification(criteria.getMembershipId(), - root -> root.join(Customer_.memberships, JoinType.LEFT).get(Membership_.id))); - } if (criteria.getRoleId() != null) { specification = specification.and(buildSpecification(criteria.getRoleId(), root -> root.join(Customer_.roles, JoinType.LEFT).get(CustomerContact_.id))); } + if (criteria.getMembershipId() != null) { + specification = specification.and(buildSpecification(criteria.getMembershipId(), + root -> root.join(Customer_.memberships, JoinType.LEFT).get(Membership_.id))); + } } return specification; } diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerCriteria.java b/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerCriteria.java index 546fef00..820b4c32 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerCriteria.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerCriteria.java @@ -1,15 +1,13 @@ package org.hostsharing.hsadminng.service.dto; -import java.io.Serializable; -import java.util.Objects; -import io.github.jhipster.service.filter.BooleanFilter; -import io.github.jhipster.service.filter.DoubleFilter; import io.github.jhipster.service.filter.Filter; -import io.github.jhipster.service.filter.FloatFilter; import io.github.jhipster.service.filter.IntegerFilter; import io.github.jhipster.service.filter.LongFilter; import io.github.jhipster.service.filter.StringFilter; +import java.io.Serializable; +import java.util.Objects; + /** * Criteria class for the Customer entity. This class is used in CustomerResource to * receive all the possible filtering options from the Http GET request parameters. @@ -38,10 +36,10 @@ public class CustomerCriteria implements Serializable { private StringFilter billingSalutation; - private LongFilter membershipId; - private LongFilter roleId; + private LongFilter membershipId; + public LongFilter getId() { return id; } @@ -106,14 +104,6 @@ public class CustomerCriteria implements Serializable { this.billingSalutation = billingSalutation; } - public LongFilter getMembershipId() { - return membershipId; - } - - public void setMembershipId(LongFilter membershipId) { - this.membershipId = membershipId; - } - public LongFilter getRoleId() { return roleId; } @@ -122,6 +112,14 @@ public class CustomerCriteria implements Serializable { this.roleId = roleId; } + public LongFilter getMembershipId() { + return membershipId; + } + + public void setMembershipId(LongFilter membershipId) { + this.membershipId = membershipId; + } + @Override public boolean equals(Object o) { @@ -141,8 +139,8 @@ public class CustomerCriteria implements Serializable { Objects.equals(contractualSalutation, that.contractualSalutation) && Objects.equals(billingAddress, that.billingAddress) && Objects.equals(billingSalutation, that.billingSalutation) && - Objects.equals(membershipId, that.membershipId) && - Objects.equals(roleId, that.roleId); + Objects.equals(roleId, that.roleId) && + Objects.equals(membershipId, that.membershipId); } @Override @@ -156,8 +154,8 @@ public class CustomerCriteria implements Serializable { contractualSalutation, billingAddress, billingSalutation, - membershipId, - roleId + roleId, + membershipId ); } @@ -172,8 +170,8 @@ public class CustomerCriteria implements Serializable { (contractualSalutation != null ? "contractualSalutation=" + contractualSalutation + ", " : "") + (billingAddress != null ? "billingAddress=" + billingAddress + ", " : "") + (billingSalutation != null ? "billingSalutation=" + billingSalutation + ", " : "") + - (membershipId != null ? "membershipId=" + membershipId + ", " : "") + (roleId != null ? "roleId=" + roleId + ", " : "") + + (membershipId != null ? "membershipId=" + membershipId + ", " : "") + "}"; } diff --git a/src/main/java/org/hostsharing/hsadminng/service/mapper/CustomerMapper.java b/src/main/java/org/hostsharing/hsadminng/service/mapper/CustomerMapper.java index 35da6964..4bb2f1e9 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/mapper/CustomerMapper.java +++ b/src/main/java/org/hostsharing/hsadminng/service/mapper/CustomerMapper.java @@ -1,9 +1,9 @@ package org.hostsharing.hsadminng.service.mapper; -import org.hostsharing.hsadminng.domain.*; +import org.hostsharing.hsadminng.domain.Customer; import org.hostsharing.hsadminng.service.dto.CustomerDTO; - -import org.mapstruct.*; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; /** * Mapper for the entity Customer and its DTO CustomerDTO. @@ -12,8 +12,8 @@ import org.mapstruct.*; public interface CustomerMapper extends EntityMapper { - @Mapping(target = "memberships", ignore = true) @Mapping(target = "roles", ignore = true) + @Mapping(target = "memberships", ignore = true) Customer toEntity(CustomerDTO customerDTO); default Customer fromId(Long id) { diff --git a/src/main/jdl/customer.jdl b/src/main/jdl/customer.jdl index 93ec95d6..14b17d8f 100644 --- a/src/main/jdl/customer.jdl +++ b/src/main/jdl/customer.jdl @@ -63,13 +63,10 @@ entity Asset { } relationship OneToMany { - Customer to Membership{customer(prefix)}, - Membership to Share{member}, - Membership to Asset{member} -} - -relationship ManyToOne { - CustomerContact{contact(email) required} to Contact{role}, - CustomerContact{customer(prefix) required} to Customer{role} + Contact{role} to CustomerContact{contact(email) required}, + Customer{role} to CustomerContact{customer(prefix) required}, + Customer to Membership{customer(prefix) required}, + Membership to Share{member required}, + Membership to Asset{member required} } diff --git a/src/main/resources/config/liquibase/changelog/20190403083738_added_entity_Membership.xml b/src/main/resources/config/liquibase/changelog/20190403083738_added_entity_Membership.xml index dbf69e2c..95973eb5 100644 --- a/src/main/resources/config/liquibase/changelog/20190403083738_added_entity_Membership.xml +++ b/src/main/resources/config/liquibase/changelog/20190403083738_added_entity_Membership.xml @@ -1,10 +1,8 @@ + xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd"> @@ -30,7 +28,7 @@ - + diff --git a/src/main/resources/config/liquibase/changelog/20190403083739_added_entity_Share.xml b/src/main/resources/config/liquibase/changelog/20190403083739_added_entity_Share.xml index fc66b034..24fd082a 100644 --- a/src/main/resources/config/liquibase/changelog/20190403083739_added_entity_Share.xml +++ b/src/main/resources/config/liquibase/changelog/20190403083739_added_entity_Share.xml @@ -1,10 +1,8 @@ + xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd"> @@ -38,7 +36,7 @@ - + diff --git a/src/main/resources/config/liquibase/changelog/20190403083740_added_entity_Asset.xml b/src/main/resources/config/liquibase/changelog/20190403083740_added_entity_Asset.xml index 229a29bc..682f4e2c 100644 --- a/src/main/resources/config/liquibase/changelog/20190403083740_added_entity_Asset.xml +++ b/src/main/resources/config/liquibase/changelog/20190403083740_added_entity_Asset.xml @@ -1,10 +1,8 @@ + xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd"> @@ -38,7 +36,7 @@ - + diff --git a/src/main/webapp/app/entities/asset/asset-update.component.html b/src/main/webapp/app/entities/asset/asset-update.component.html index 38bc16c7..0e1fa8d1 100644 --- a/src/main/webapp/app/entities/asset/asset-update.component.html +++ b/src/main/webapp/app/entities/asset/asset-update.component.html @@ -71,11 +71,18 @@
- +
+
+ + This field is required. + +
+ for="field_contractualAddress">Contractual Address
diff --git a/src/main/webapp/app/entities/entity.module.ts b/src/main/webapp/app/entities/entity.module.ts index 9a0d61ae..100c6ff5 100644 --- a/src/main/webapp/app/entities/entity.module.ts +++ b/src/main/webapp/app/entities/entity.module.ts @@ -1,4 +1,4 @@ -import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; @NgModule({ @@ -35,6 +35,58 @@ import { RouterModule } from '@angular/router'; { path: 'customer', loadChildren: './customer/customer.module#HsadminNgCustomerModule' + }, + { + path: 'customer', + loadChildren: './customer/customer.module#HsadminNgCustomerModule' + }, + { + path: 'membership', + loadChildren: './membership/membership.module#HsadminNgMembershipModule' + }, + { + path: 'share', + loadChildren: './share/share.module#HsadminNgShareModule' + }, + { + path: 'asset', + loadChildren: './asset/asset.module#HsadminNgAssetModule' + }, + { + path: 'customer', + loadChildren: './customer/customer.module#HsadminNgCustomerModule' + }, + { + path: 'membership', + loadChildren: './membership/membership.module#HsadminNgMembershipModule' + }, + { + path: 'share', + loadChildren: './share/share.module#HsadminNgShareModule' + }, + { + path: 'asset', + loadChildren: './asset/asset.module#HsadminNgAssetModule' + }, + { + path: 'customer', + loadChildren: './customer/customer.module#HsadminNgCustomerModule' + }, + { + path: 'membership', + loadChildren: './membership/membership.module#HsadminNgMembershipModule' + }, + { + path: 'share', + loadChildren: './share/share.module#HsadminNgShareModule' + }, + { + path: 'asset', + loadChildren: './asset/asset.module#HsadminNgAssetModule' + }, + { + path: 'membership', + loadChildren: './membership/membership.module#HsadminNgMembershipModule' } /* jhipster-needle-add-entity-route - JHipster will add entity modules routes here */ ]) diff --git a/src/main/webapp/app/entities/membership/membership-update.component.html b/src/main/webapp/app/entities/membership/membership-update.component.html index b79731b4..6b30a4c2 100644 --- a/src/main/webapp/app/entities/membership/membership-update.component.html +++ b/src/main/webapp/app/entities/membership/membership-update.component.html @@ -38,11 +38,19 @@
- +
+
+ + This field is required. + +