several 'required' flags added to jdl and re-import

This commit is contained in:
Michael Hoennig 2019-04-12 16:43:16 +02:00
parent 4dbbd5ecde
commit 39950f0d69
28 changed files with 190 additions and 126 deletions

View File

@ -37,6 +37,7 @@
"relationshipType": "many-to-one",
"otherEntityName": "membership",
"otherEntityRelationshipName": "asset",
"relationshipValidateRules": "required",
"relationshipName": "member",
"otherEntityField": "id"
}

View File

@ -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",

View File

@ -30,6 +30,7 @@
"relationshipType": "many-to-one",
"otherEntityName": "customer",
"otherEntityRelationshipName": "membership",
"relationshipValidateRules": "required",
"relationshipName": "customer",
"otherEntityField": "prefix"
}

View File

@ -37,6 +37,7 @@
"relationshipType": "many-to-one",
"otherEntityName": "membership",
"otherEntityRelationshipName": "share",
"relationshipValidateRules": "required",
"relationshipName": "member",
"otherEntityField": "id"
}

View File

@ -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']

View File

@ -44,7 +44,7 @@ public class Asset implements Serializable {
private String comment;
@NotNull
@ManyToOne
@ManyToOne(optional = false)
@JsonIgnoreProperties("assets")
private Membership member;

View File

@ -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<Membership> memberships = new HashSet<>();
@OneToMany(mappedBy = "customer")
private Set<CustomerContact> roles = new HashSet<>();
@OneToMany(mappedBy = "customer")
private Set<Membership> 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<Membership> getMemberships() {
return memberships;
}
public Customer memberships(Set<Membership> 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<Membership> memberships) {
this.memberships = memberships;
}
public Set<CustomerContact> getRoles() {
return roles;
}
@ -211,6 +185,31 @@ public class Customer implements Serializable {
public void setRoles(Set<CustomerContact> customerContacts) {
this.roles = customerContacts;
}
public Set<Membership> getMemberships() {
return memberships;
}
public Customer memberships(Set<Membership> 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<Membership> memberships) {
this.memberships = memberships;
}
// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove
@Override

View File

@ -41,7 +41,7 @@ public class Membership implements Serializable {
private Set<Asset> assets = new HashSet<>();
@NotNull
@ManyToOne
@ManyToOne(optional = false)
@JsonIgnoreProperties("memberships")
private Customer customer;

View File

@ -45,7 +45,7 @@ public class Share implements Serializable {
private String comment;
@NotNull
@ManyToOne
@ManyToOne(optional = false)
@JsonIgnoreProperties("shares")
private Membership member;

View File

@ -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<Customer> {
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;
}

View File

@ -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 + ", " : "") +
"}";
}

View File

@ -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<CustomerDTO, Customer> {
@Mapping(target = "memberships", ignore = true)
@Mapping(target = "roles", ignore = true)
@Mapping(target = "memberships", ignore = true)
Customer toEntity(CustomerDTO customerDTO);
default Customer fromId(Long id) {

View File

@ -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}
}

View File

@ -1,10 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
<property name="now" value="now()" dbms="h2"/>
@ -30,7 +28,7 @@
</column>
<column name="customer_id" type="bigint">
<constraints nullable="true" />
<constraints nullable="false"/>
</column>
<!-- jhipster-needle-liquibase-add-column - JHipster will add columns here, do not remove-->

View File

@ -1,10 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
<property name="now" value="now()" dbms="h2"/>
@ -38,7 +36,7 @@
</column>
<column name="member_id" type="bigint">
<constraints nullable="true" />
<constraints nullable="false"/>
</column>
<!-- jhipster-needle-liquibase-add-column - JHipster will add columns here, do not remove-->

View File

@ -1,10 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
<property name="now" value="now()" dbms="h2"/>
@ -38,7 +36,7 @@
</column>
<column name="member_id" type="bigint">
<constraints nullable="true" />
<constraints nullable="false"/>
</column>
<!-- jhipster-needle-liquibase-add-column - JHipster will add columns here, do not remove-->

View File

@ -71,11 +71,18 @@
<div class="form-group">
<label class="form-control-label" jhiTranslate="hsadminNgApp.asset.member" for="field_member">Member</label>
<select class="form-control" id="field_member" name="member" [(ngModel)]="asset.memberId" >
<option [ngValue]="null"></option>
<select class="form-control" id="field_member" name="member" [(ngModel)]="asset.memberId" required>
<option *ngIf="!editForm.value.member" [ngValue]="null" selected></option>
<option [ngValue]="membershipOption.id" *ngFor="let membershipOption of memberships; trackBy: trackMembershipById">{{membershipOption.id}}</option>
</select>
</div>
<div [hidden]="!(editForm.controls.member?.dirty && editForm.controls.member?.invalid)">
<small class="form-text text-danger"
[hidden]="!editForm.controls.member?.errors?.required"
jhiTranslate="entity.validation.required">
This field is required.
</small>
</div>
</div>
<div>
<button type="button" id="cancel-save" class="btn btn-secondary" (click)="previousState()">

View File

@ -64,7 +64,7 @@
</div>
<div class="form-group">
<label class="form-control-label" jhiTranslate="hsadminNgApp.customer.contractualAddress"
for="field_contractualAddress">Contractual Address X</label>
for="field_contractualAddress">Contractual Address</label>
<textarea class="form-control" name="contractualAddress" id="field_contractualAddress" rows="3"
[(ngModel)]="customer.contractualAddress" required maxlength="400"></textarea>
<div [hidden]="!(editForm.controls.contractualAddress?.dirty && editForm.controls.contractualAddress?.invalid)">

View File

@ -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 */
])

View File

@ -38,11 +38,19 @@
<div class="form-group">
<label class="form-control-label" jhiTranslate="hsadminNgApp.membership.customer" for="field_customer">Customer</label>
<select class="form-control" id="field_customer" name="customer" [(ngModel)]="membership.customerId" >
<option [ngValue]="null"></option>
<select class="form-control" id="field_customer" name="customer" [(ngModel)]="membership.customerId"
required>
<option *ngIf="!editForm.value.customer" [ngValue]="null" selected></option>
<option [ngValue]="customerOption.id" *ngFor="let customerOption of customers; trackBy: trackCustomerById">{{customerOption.prefix}}</option>
</select>
</div>
<div [hidden]="!(editForm.controls.customer?.dirty && editForm.controls.customer?.invalid)">
<small class="form-text text-danger"
[hidden]="!editForm.controls.customer?.errors?.required"
jhiTranslate="entity.validation.required">
This field is required.
</small>
</div>
</div>
<div>
<button type="button" id="cancel-save" class="btn btn-secondary" (click)="previousState()">

View File

@ -67,11 +67,18 @@
<div class="form-group">
<label class="form-control-label" jhiTranslate="hsadminNgApp.share.member" for="field_member">Member</label>
<select class="form-control" id="field_member" name="member" [(ngModel)]="share.memberId" >
<option [ngValue]="null"></option>
<select class="form-control" id="field_member" name="member" [(ngModel)]="share.memberId" required>
<option *ngIf="!editForm.value.member" [ngValue]="null" selected></option>
<option [ngValue]="membershipOption.id" *ngFor="let membershipOption of memberships; trackBy: trackMembershipById">{{membershipOption.id}}</option>
</select>
</div>
<div [hidden]="!(editForm.controls.member?.dirty && editForm.controls.member?.invalid)">
<small class="form-text text-danger"
[hidden]="!editForm.controls.member?.errors?.required"
jhiTranslate="entity.validation.required">
This field is required.
</small>
</div>
</div>
<div>
<button type="button" id="cancel-save" class="btn btn-secondary" (click)="previousState()">

View File

@ -1,5 +1,5 @@
import { IMembership } from 'app/shared/model/membership.model';
import { ICustomerContact } from 'app/shared/model/customer-contact.model';
import { IMembership } from 'app/shared/model/membership.model';
export interface ICustomer {
id?: number;
@ -10,8 +10,8 @@ export interface ICustomer {
contractualSalutation?: string;
billingAddress?: string;
billingSalutation?: string;
memberships?: IMembership[];
roles?: ICustomerContact[];
memberships?: IMembership[];
}
export class Customer implements ICustomer {
@ -24,7 +24,7 @@ export class Customer implements ICustomer {
public contractualSalutation?: string,
public billingAddress?: string,
public billingSalutation?: string,
public memberships?: IMembership[],
public roles?: ICustomerContact[]
public roles?: ICustomerContact[],
public memberships?: IMembership[]
) {}
}

View File

@ -22,8 +22,8 @@
"contractualSalutation": "Contractual Salutation",
"billingAddress": "Billing Address",
"billingSalutation": "Billing Salutation",
"membership": "Membership",
"role": "Role"
"role": "Role",
"membership": "Membership"
}
}
}

View File

@ -22,8 +22,8 @@
"contractualSalutation": "Contractual Salutation",
"billingAddress": "Billing Address",
"billingSalutation": "Billing Salutation",
"membership": "Membership",
"role": "Role"
"role": "Role",
"membership": "Membership"
}
}
}

View File

@ -1,7 +1,7 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { HttpResponse } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { of } from 'rxjs';
import { HsadminNgTestModule } from '../../../test.module';
import { AssetUpdateComponent } from 'app/entities/asset/asset-update.component';

View File

@ -1,7 +1,7 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { HttpResponse } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { of } from 'rxjs';
import { HsadminNgTestModule } from '../../../test.module';
import { CustomerUpdateComponent } from 'app/entities/customer/customer-update.component';

View File

@ -1,7 +1,7 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { HttpResponse } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { of } from 'rxjs';
import { HsadminNgTestModule } from '../../../test.module';
import { MembershipUpdateComponent } from 'app/entities/membership/membership-update.component';

View File

@ -1,7 +1,7 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { HttpResponse } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { of } from 'rxjs';
import { HsadminNgTestModule } from '../../../test.module';
import { ShareUpdateComponent } from 'app/entities/share/share-update.component';