Merge remote-tracking branch 'origin/jhipster-generated'

This commit is contained in:
Michael Hoennig 2019-04-03 10:58:53 +02:00
commit 625d5295fd
206 changed files with 15434 additions and 0 deletions

53
.jhipster/Asset.json Normal file
View File

@ -0,0 +1,53 @@
{
"name": "Asset",
"fields": [
{
"fieldName": "date",
"fieldType": "LocalDate",
"fieldValidateRules": [
"required"
]
},
{
"fieldName": "action",
"fieldType": "AssetAction",
"fieldValues": "PAYMENT,HANDOVER,ADOPTION,LOSS,CLEARING,PAYBACK",
"fieldValidateRules": [
"required"
]
},
{
"fieldName": "amount",
"fieldType": "BigDecimal",
"fieldValidateRules": [
"required"
]
},
{
"fieldName": "comment",
"fieldType": "String",
"fieldValidateRules": [
"maxlength"
],
"fieldValidateRulesMaxlength": 160
}
],
"relationships": [
{
"relationshipType": "many-to-one",
"otherEntityName": "membership",
"otherEntityRelationshipName": "asset",
"relationshipName": "member",
"otherEntityField": "id"
}
],
"changelogDate": "20190403083740",
"entityTableName": "asset",
"dto": "mapstruct",
"pagination": "infinite-scroll",
"service": "serviceClass",
"jpaMetamodelFiltering": true,
"fluentMethods": true,
"clientRootFolder": "",
"applications": "*"
}

49
.jhipster/Contact.json Normal file
View File

@ -0,0 +1,49 @@
{
"name": "Contact",
"fields": [
{
"fieldName": "firstName",
"fieldType": "String",
"fieldValidateRules": [
"required",
"maxlength"
],
"fieldValidateRulesMaxlength": 80
},
{
"fieldName": "lastName",
"fieldType": "String",
"fieldValidateRules": [
"required",
"maxlength"
],
"fieldValidateRulesMaxlength": 80
},
{
"fieldName": "email",
"fieldType": "String",
"fieldValidateRules": [
"required",
"maxlength"
],
"fieldValidateRulesMaxlength": 80
}
],
"relationships": [
{
"relationshipType": "one-to-many",
"otherEntityName": "customerContact",
"otherEntityRelationshipName": "contact",
"relationshipName": "role"
}
],
"changelogDate": "20190403083736",
"entityTableName": "contact",
"dto": "mapstruct",
"pagination": "infinite-scroll",
"service": "serviceClass",
"jpaMetamodelFiltering": true,
"fluentMethods": true,
"clientRootFolder": "",
"applications": "*"
}

50
.jhipster/Customer.json Normal file
View File

@ -0,0 +1,50 @@
{
"name": "Customer",
"fields": [
{
"fieldName": "number",
"fieldType": "Integer",
"fieldValidateRules": [
"required",
"unique",
"min",
"max"
],
"fieldValidateRulesMin": 10000,
"fieldValidateRulesMax": 99999
},
{
"fieldName": "prefix",
"fieldType": "String",
"fieldValidateRules": [
"required",
"unique",
"pattern"
],
"fieldValidateRulesPattern": "[a-z][a-z0-9]+"
}
],
"relationships": [
{
"relationshipType": "one-to-many",
"otherEntityName": "membership",
"otherEntityRelationshipName": "customer",
"relationshipName": "membership"
},
{
"relationshipType": "one-to-many",
"otherEntityName": "customerContact",
"otherEntityRelationshipName": "customer",
"relationshipName": "role"
}
],
"changelogDate": "20190403083735",
"entityTableName": "customer",
"dto": "mapstruct",
"pagination": "infinite-scroll",
"service": "serviceClass",
"jpaMetamodelFiltering": true,
"fluentMethods": true,
"clientRootFolder": "",
"applications": "*"
}

View File

@ -0,0 +1,40 @@
{
"name": "CustomerContact",
"fields": [
{
"fieldName": "role",
"fieldType": "CustomerContactRole",
"fieldValues": "CONTRACTUAL,TECHNICAL,FINANCIAL",
"fieldValidateRules": [
"required"
]
}
],
"relationships": [
{
"relationshipType": "many-to-one",
"otherEntityName": "contact",
"otherEntityRelationshipName": "role",
"relationshipValidateRules": "required",
"relationshipName": "contact",
"otherEntityField": "email"
},
{
"relationshipType": "many-to-one",
"otherEntityName": "customer",
"otherEntityRelationshipName": "role",
"relationshipValidateRules": "required",
"relationshipName": "customer",
"otherEntityField": "prefix"
}
],
"changelogDate": "20190403083737",
"entityTableName": "customer_contact",
"dto": "mapstruct",
"pagination": "infinite-scroll",
"service": "serviceClass",
"jpaMetamodelFiltering": true,
"fluentMethods": true,
"clientRootFolder": "",
"applications": "*"
}

46
.jhipster/Membership.json Normal file
View File

@ -0,0 +1,46 @@
{
"name": "Membership",
"fields": [
{
"fieldName": "sinceDate",
"fieldType": "LocalDate",
"fieldValidateRules": [
"required"
]
},
{
"fieldName": "untilDate",
"fieldType": "LocalDate"
}
],
"relationships": [
{
"relationshipType": "one-to-many",
"otherEntityName": "share",
"otherEntityRelationshipName": "member",
"relationshipName": "share"
},
{
"relationshipType": "one-to-many",
"otherEntityName": "asset",
"otherEntityRelationshipName": "member",
"relationshipName": "asset"
},
{
"relationshipType": "many-to-one",
"otherEntityName": "customer",
"otherEntityRelationshipName": "membership",
"relationshipName": "customer",
"otherEntityField": "prefix"
}
],
"changelogDate": "20190403083738",
"entityTableName": "membership",
"dto": "mapstruct",
"pagination": "infinite-scroll",
"service": "serviceClass",
"jpaMetamodelFiltering": true,
"fluentMethods": true,
"clientRootFolder": "",
"applications": "*"
}

53
.jhipster/Share.json Normal file
View File

@ -0,0 +1,53 @@
{
"name": "Share",
"fields": [
{
"fieldName": "date",
"fieldType": "LocalDate",
"fieldValidateRules": [
"required"
]
},
{
"fieldName": "action",
"fieldType": "ShareAction",
"fieldValues": "SUBSCRIPTION,CANCELLATION",
"fieldValidateRules": [
"required"
]
},
{
"fieldName": "quantity",
"fieldType": "Integer",
"fieldValidateRules": [
"required"
]
},
{
"fieldName": "comment",
"fieldType": "String",
"fieldValidateRules": [
"maxlength"
],
"fieldValidateRulesMaxlength": 160
}
],
"relationships": [
{
"relationshipType": "many-to-one",
"otherEntityName": "membership",
"otherEntityRelationshipName": "share",
"relationshipName": "member",
"otherEntityField": "id"
}
],
"changelogDate": "20190403083739",
"entityTableName": "share",
"dto": "mapstruct",
"pagination": "infinite-scroll",
"service": "serviceClass",
"jpaMetamodelFiltering": true,
"fluentMethods": true,
"clientRootFolder": "",
"applications": "*"
}

View File

@ -0,0 +1,156 @@
package org.hostsharing.hsadminng.domain;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Objects;
import org.hostsharing.hsadminng.domain.enumeration.AssetAction;
/**
* A Asset.
*/
@Entity
@Table(name = "asset")
public class Asset implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
@SequenceGenerator(name = "sequenceGenerator")
private Long id;
@NotNull
@Column(name = "jhi_date", nullable = false)
private LocalDate date;
@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "action", nullable = false)
private AssetAction action;
@NotNull
@Column(name = "amount", precision = 10, scale = 2, nullable = false)
private BigDecimal amount;
@Size(max = 160)
@Column(name = "jhi_comment", length = 160)
private String comment;
@ManyToOne
@JsonIgnoreProperties("assets")
private Membership member;
// jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public LocalDate getDate() {
return date;
}
public Asset date(LocalDate date) {
this.date = date;
return this;
}
public void setDate(LocalDate date) {
this.date = date;
}
public AssetAction getAction() {
return action;
}
public Asset action(AssetAction action) {
this.action = action;
return this;
}
public void setAction(AssetAction action) {
this.action = action;
}
public BigDecimal getAmount() {
return amount;
}
public Asset amount(BigDecimal amount) {
this.amount = amount;
return this;
}
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
public String getComment() {
return comment;
}
public Asset comment(String comment) {
this.comment = comment;
return this;
}
public void setComment(String comment) {
this.comment = comment;
}
public Membership getMember() {
return member;
}
public Asset member(Membership membership) {
this.member = membership;
return this;
}
public void setMember(Membership membership) {
this.member = membership;
}
// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Asset asset = (Asset) o;
if (asset.getId() == null || getId() == null) {
return false;
}
return Objects.equals(getId(), asset.getId());
}
@Override
public int hashCode() {
return Objects.hashCode(getId());
}
@Override
public String toString() {
return "Asset{" +
"id=" + getId() +
", date='" + getDate() + "'" +
", action='" + getAction() + "'" +
", amount=" + getAmount() +
", comment='" + getComment() + "'" +
"}";
}
}

View File

@ -0,0 +1,148 @@
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;
/**
* A Contact.
*/
@Entity
@Table(name = "contact")
public class Contact implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
@SequenceGenerator(name = "sequenceGenerator")
private Long id;
@NotNull
@Size(max = 80)
@Column(name = "first_name", length = 80, nullable = false)
private String firstName;
@NotNull
@Size(max = 80)
@Column(name = "last_name", length = 80, nullable = false)
private String lastName;
@NotNull
@Size(max = 80)
@Column(name = "email", length = 80, nullable = false)
private String email;
@OneToMany(mappedBy = "contact")
private Set<CustomerContact> roles = new HashSet<>();
// jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public Contact firstName(String firstName) {
this.firstName = firstName;
return this;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public Contact lastName(String lastName) {
this.lastName = lastName;
return this;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getEmail() {
return email;
}
public Contact email(String email) {
this.email = email;
return this;
}
public void setEmail(String email) {
this.email = email;
}
public Set<CustomerContact> getRoles() {
return roles;
}
public Contact roles(Set<CustomerContact> customerContacts) {
this.roles = customerContacts;
return this;
}
public Contact addRole(CustomerContact customerContact) {
this.roles.add(customerContact);
customerContact.setContact(this);
return this;
}
public Contact removeRole(CustomerContact customerContact) {
this.roles.remove(customerContact);
customerContact.setContact(null);
return this;
}
public void setRoles(Set<CustomerContact> customerContacts) {
this.roles = customerContacts;
}
// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Contact contact = (Contact) o;
if (contact.getId() == null || getId() == null) {
return false;
}
return Objects.equals(getId(), contact.getId());
}
@Override
public int hashCode() {
return Objects.hashCode(getId());
}
@Override
public String toString() {
return "Contact{" +
"id=" + getId() +
", firstName='" + getFirstName() + "'" +
", lastName='" + getLastName() + "'" +
", email='" + getEmail() + "'" +
"}";
}
}

View File

@ -0,0 +1,157 @@
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;
/**
* A Customer.
*/
@Entity
@Table(name = "customer")
public class Customer implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
@SequenceGenerator(name = "sequenceGenerator")
private Long id;
@NotNull
@Min(value = 10000)
@Max(value = 99999)
@Column(name = "jhi_number", nullable = false, unique = true)
private Integer number;
@NotNull
@Pattern(regexp = "[a-z][a-z0-9]+")
@Column(name = "prefix", nullable = false, unique = true)
private String prefix;
@OneToMany(mappedBy = "customer")
private Set<Membership> memberships = new HashSet<>();
@OneToMany(mappedBy = "customer")
private Set<CustomerContact> roles = new HashSet<>();
// jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getNumber() {
return number;
}
public Customer number(Integer number) {
this.number = number;
return this;
}
public void setNumber(Integer number) {
this.number = number;
}
public String getPrefix() {
return prefix;
}
public Customer prefix(String prefix) {
this.prefix = prefix;
return this;
}
public void setPrefix(String prefix) {
this.prefix = prefix;
}
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;
}
public Customer roles(Set<CustomerContact> customerContacts) {
this.roles = customerContacts;
return this;
}
public Customer addRole(CustomerContact customerContact) {
this.roles.add(customerContact);
customerContact.setCustomer(this);
return this;
}
public Customer removeRole(CustomerContact customerContact) {
this.roles.remove(customerContact);
customerContact.setCustomer(null);
return this;
}
public void setRoles(Set<CustomerContact> customerContacts) {
this.roles = customerContacts;
}
// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Customer customer = (Customer) o;
if (customer.getId() == null || getId() == null) {
return false;
}
return Objects.equals(getId(), customer.getId());
}
@Override
public int hashCode() {
return Objects.hashCode(getId());
}
@Override
public String toString() {
return "Customer{" +
"id=" + getId() +
", number=" + getNumber() +
", prefix='" + getPrefix() + "'" +
"}";
}
}

View File

@ -0,0 +1,119 @@
package org.hostsharing.hsadminng.domain;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.util.Objects;
import org.hostsharing.hsadminng.domain.enumeration.CustomerContactRole;
/**
* A CustomerContact.
*/
@Entity
@Table(name = "customer_contact")
public class CustomerContact implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
@SequenceGenerator(name = "sequenceGenerator")
private Long id;
@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "jhi_role", nullable = false)
private CustomerContactRole role;
@ManyToOne(optional = false)
@NotNull
@JsonIgnoreProperties("roles")
private Contact contact;
@ManyToOne(optional = false)
@NotNull
@JsonIgnoreProperties("roles")
private Customer customer;
// jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public CustomerContactRole getRole() {
return role;
}
public CustomerContact role(CustomerContactRole role) {
this.role = role;
return this;
}
public void setRole(CustomerContactRole role) {
this.role = role;
}
public Contact getContact() {
return contact;
}
public CustomerContact contact(Contact contact) {
this.contact = contact;
return this;
}
public void setContact(Contact contact) {
this.contact = contact;
}
public Customer getCustomer() {
return customer;
}
public CustomerContact customer(Customer customer) {
this.customer = customer;
return this;
}
public void setCustomer(Customer customer) {
this.customer = customer;
}
// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CustomerContact customerContact = (CustomerContact) o;
if (customerContact.getId() == null || getId() == null) {
return false;
}
return Objects.equals(getId(), customerContact.getId());
}
@Override
public int hashCode() {
return Objects.hashCode(getId());
}
@Override
public String toString() {
return "CustomerContact{" +
"id=" + getId() +
", role='" + getRole() + "'" +
"}";
}
}

View File

@ -0,0 +1,172 @@
package org.hostsharing.hsadminng.domain;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.HashSet;
import java.util.Set;
import java.util.Objects;
/**
* A Membership.
*/
@Entity
@Table(name = "membership")
public class Membership implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
@SequenceGenerator(name = "sequenceGenerator")
private Long id;
@NotNull
@Column(name = "since_date", nullable = false)
private LocalDate sinceDate;
@Column(name = "until_date")
private LocalDate untilDate;
@OneToMany(mappedBy = "member")
private Set<Share> shares = new HashSet<>();
@OneToMany(mappedBy = "member")
private Set<Asset> assets = new HashSet<>();
@ManyToOne
@JsonIgnoreProperties("memberships")
private Customer customer;
// jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public LocalDate getSinceDate() {
return sinceDate;
}
public Membership sinceDate(LocalDate sinceDate) {
this.sinceDate = sinceDate;
return this;
}
public void setSinceDate(LocalDate sinceDate) {
this.sinceDate = sinceDate;
}
public LocalDate getUntilDate() {
return untilDate;
}
public Membership untilDate(LocalDate untilDate) {
this.untilDate = untilDate;
return this;
}
public void setUntilDate(LocalDate untilDate) {
this.untilDate = untilDate;
}
public Set<Share> getShares() {
return shares;
}
public Membership shares(Set<Share> shares) {
this.shares = shares;
return this;
}
public Membership addShare(Share share) {
this.shares.add(share);
share.setMember(this);
return this;
}
public Membership removeShare(Share share) {
this.shares.remove(share);
share.setMember(null);
return this;
}
public void setShares(Set<Share> shares) {
this.shares = shares;
}
public Set<Asset> getAssets() {
return assets;
}
public Membership assets(Set<Asset> assets) {
this.assets = assets;
return this;
}
public Membership addAsset(Asset asset) {
this.assets.add(asset);
asset.setMember(this);
return this;
}
public Membership removeAsset(Asset asset) {
this.assets.remove(asset);
asset.setMember(null);
return this;
}
public void setAssets(Set<Asset> assets) {
this.assets = assets;
}
public Customer getCustomer() {
return customer;
}
public Membership customer(Customer customer) {
this.customer = customer;
return this;
}
public void setCustomer(Customer customer) {
this.customer = customer;
}
// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Membership membership = (Membership) o;
if (membership.getId() == null || getId() == null) {
return false;
}
return Objects.equals(getId(), membership.getId());
}
@Override
public int hashCode() {
return Objects.hashCode(getId());
}
@Override
public String toString() {
return "Membership{" +
"id=" + getId() +
", sinceDate='" + getSinceDate() + "'" +
", untilDate='" + getUntilDate() + "'" +
"}";
}
}

View File

@ -0,0 +1,155 @@
package org.hostsharing.hsadminng.domain;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.Objects;
import org.hostsharing.hsadminng.domain.enumeration.ShareAction;
/**
* A Share.
*/
@Entity
@Table(name = "share")
public class Share implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
@SequenceGenerator(name = "sequenceGenerator")
private Long id;
@NotNull
@Column(name = "jhi_date", nullable = false)
private LocalDate date;
@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "action", nullable = false)
private ShareAction action;
@NotNull
@Column(name = "quantity", nullable = false)
private Integer quantity;
@Size(max = 160)
@Column(name = "jhi_comment", length = 160)
private String comment;
@ManyToOne
@JsonIgnoreProperties("shares")
private Membership member;
// jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public LocalDate getDate() {
return date;
}
public Share date(LocalDate date) {
this.date = date;
return this;
}
public void setDate(LocalDate date) {
this.date = date;
}
public ShareAction getAction() {
return action;
}
public Share action(ShareAction action) {
this.action = action;
return this;
}
public void setAction(ShareAction action) {
this.action = action;
}
public Integer getQuantity() {
return quantity;
}
public Share quantity(Integer quantity) {
this.quantity = quantity;
return this;
}
public void setQuantity(Integer quantity) {
this.quantity = quantity;
}
public String getComment() {
return comment;
}
public Share comment(String comment) {
this.comment = comment;
return this;
}
public void setComment(String comment) {
this.comment = comment;
}
public Membership getMember() {
return member;
}
public Share member(Membership membership) {
this.member = membership;
return this;
}
public void setMember(Membership membership) {
this.member = membership;
}
// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Share share = (Share) o;
if (share.getId() == null || getId() == null) {
return false;
}
return Objects.equals(getId(), share.getId());
}
@Override
public int hashCode() {
return Objects.hashCode(getId());
}
@Override
public String toString() {
return "Share{" +
"id=" + getId() +
", date='" + getDate() + "'" +
", action='" + getAction() + "'" +
", quantity=" + getQuantity() +
", comment='" + getComment() + "'" +
"}";
}
}

View File

@ -0,0 +1,8 @@
package org.hostsharing.hsadminng.domain.enumeration;
/**
* The AssetAction enumeration.
*/
public enum AssetAction {
PAYMENT, HANDOVER, ADOPTION, LOSS, CLEARING, PAYBACK
}

View File

@ -0,0 +1,8 @@
package org.hostsharing.hsadminng.domain.enumeration;
/**
* The CustomerContactRole enumeration.
*/
public enum CustomerContactRole {
CONTRACTUAL, TECHNICAL, FINANCIAL
}

View File

@ -0,0 +1,8 @@
package org.hostsharing.hsadminng.domain.enumeration;
/**
* The ShareAction enumeration.
*/
public enum ShareAction {
SUBSCRIPTION, CANCELLATION
}

View File

@ -0,0 +1,15 @@
package org.hostsharing.hsadminng.repository;
import org.hostsharing.hsadminng.domain.Asset;
import org.springframework.data.jpa.repository.*;
import org.springframework.stereotype.Repository;
/**
* Spring Data repository for the Asset entity.
*/
@SuppressWarnings("unused")
@Repository
public interface AssetRepository extends JpaRepository<Asset, Long>, JpaSpecificationExecutor<Asset> {
}

View File

@ -0,0 +1,15 @@
package org.hostsharing.hsadminng.repository;
import org.hostsharing.hsadminng.domain.Contact;
import org.springframework.data.jpa.repository.*;
import org.springframework.stereotype.Repository;
/**
* Spring Data repository for the Contact entity.
*/
@SuppressWarnings("unused")
@Repository
public interface ContactRepository extends JpaRepository<Contact, Long>, JpaSpecificationExecutor<Contact> {
}

View File

@ -0,0 +1,15 @@
package org.hostsharing.hsadminng.repository;
import org.hostsharing.hsadminng.domain.CustomerContact;
import org.springframework.data.jpa.repository.*;
import org.springframework.stereotype.Repository;
/**
* Spring Data repository for the CustomerContact entity.
*/
@SuppressWarnings("unused")
@Repository
public interface CustomerContactRepository extends JpaRepository<CustomerContact, Long>, JpaSpecificationExecutor<CustomerContact> {
}

View File

@ -0,0 +1,15 @@
package org.hostsharing.hsadminng.repository;
import org.hostsharing.hsadminng.domain.Customer;
import org.springframework.data.jpa.repository.*;
import org.springframework.stereotype.Repository;
/**
* Spring Data repository for the Customer entity.
*/
@SuppressWarnings("unused")
@Repository
public interface CustomerRepository extends JpaRepository<Customer, Long>, JpaSpecificationExecutor<Customer> {
}

View File

@ -0,0 +1,15 @@
package org.hostsharing.hsadminng.repository;
import org.hostsharing.hsadminng.domain.Membership;
import org.springframework.data.jpa.repository.*;
import org.springframework.stereotype.Repository;
/**
* Spring Data repository for the Membership entity.
*/
@SuppressWarnings("unused")
@Repository
public interface MembershipRepository extends JpaRepository<Membership, Long>, JpaSpecificationExecutor<Membership> {
}

View File

@ -0,0 +1,15 @@
package org.hostsharing.hsadminng.repository;
import org.hostsharing.hsadminng.domain.Share;
import org.springframework.data.jpa.repository.*;
import org.springframework.stereotype.Repository;
/**
* Spring Data repository for the Share entity.
*/
@SuppressWarnings("unused")
@Repository
public interface ShareRepository extends JpaRepository<Share, Long>, JpaSpecificationExecutor<Share> {
}

View File

@ -0,0 +1,111 @@
package org.hostsharing.hsadminng.service;
import java.util.List;
import javax.persistence.criteria.JoinType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
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.Asset;
import org.hostsharing.hsadminng.domain.*; // for static metamodels
import org.hostsharing.hsadminng.repository.AssetRepository;
import org.hostsharing.hsadminng.service.dto.AssetCriteria;
import org.hostsharing.hsadminng.service.dto.AssetDTO;
import org.hostsharing.hsadminng.service.mapper.AssetMapper;
/**
* Service for executing complex queries for Asset entities in the database.
* The main input is a {@link AssetCriteria} which gets converted to {@link Specification},
* in a way that all the filters must apply.
* It returns a {@link List} of {@link AssetDTO} or a {@link Page} of {@link AssetDTO} which fulfills the criteria.
*/
@Service
@Transactional(readOnly = true)
public class AssetQueryService extends QueryService<Asset> {
private final Logger log = LoggerFactory.getLogger(AssetQueryService.class);
private final AssetRepository assetRepository;
private final AssetMapper assetMapper;
public AssetQueryService(AssetRepository assetRepository, AssetMapper assetMapper) {
this.assetRepository = assetRepository;
this.assetMapper = assetMapper;
}
/**
* Return a {@link List} of {@link AssetDTO} which matches the criteria from the database
* @param criteria The object which holds all the filters, which the entities should match.
* @return the matching entities.
*/
@Transactional(readOnly = true)
public List<AssetDTO> findByCriteria(AssetCriteria criteria) {
log.debug("find by criteria : {}", criteria);
final Specification<Asset> specification = createSpecification(criteria);
return assetMapper.toDto(assetRepository.findAll(specification));
}
/**
* Return a {@link Page} of {@link AssetDTO} which matches the criteria from the database
* @param criteria The object which holds all the filters, which the entities should match.
* @param page The page, which should be returned.
* @return the matching entities.
*/
@Transactional(readOnly = true)
public Page<AssetDTO> findByCriteria(AssetCriteria criteria, Pageable page) {
log.debug("find by criteria : {}, page: {}", criteria, page);
final Specification<Asset> specification = createSpecification(criteria);
return assetRepository.findAll(specification, page)
.map(assetMapper::toDto);
}
/**
* Return the number of matching entities in the database
* @param criteria The object which holds all the filters, which the entities should match.
* @return the number of matching entities.
*/
@Transactional(readOnly = true)
public long countByCriteria(AssetCriteria criteria) {
log.debug("count by criteria : {}", criteria);
final Specification<Asset> specification = createSpecification(criteria);
return assetRepository.count(specification);
}
/**
* Function to convert AssetCriteria to a {@link Specification}
*/
private Specification<Asset> createSpecification(AssetCriteria criteria) {
Specification<Asset> specification = Specification.where(null);
if (criteria != null) {
if (criteria.getId() != null) {
specification = specification.and(buildSpecification(criteria.getId(), Asset_.id));
}
if (criteria.getDate() != null) {
specification = specification.and(buildRangeSpecification(criteria.getDate(), Asset_.date));
}
if (criteria.getAction() != null) {
specification = specification.and(buildSpecification(criteria.getAction(), Asset_.action));
}
if (criteria.getAmount() != null) {
specification = specification.and(buildRangeSpecification(criteria.getAmount(), Asset_.amount));
}
if (criteria.getComment() != null) {
specification = specification.and(buildStringSpecification(criteria.getComment(), Asset_.comment));
}
if (criteria.getMemberId() != null) {
specification = specification.and(buildSpecification(criteria.getMemberId(),
root -> root.join(Asset_.member, JoinType.LEFT).get(Membership_.id)));
}
}
return specification;
}
}

View File

@ -0,0 +1,84 @@
package org.hostsharing.hsadminng.service;
import org.hostsharing.hsadminng.domain.Asset;
import org.hostsharing.hsadminng.repository.AssetRepository;
import org.hostsharing.hsadminng.service.dto.AssetDTO;
import org.hostsharing.hsadminng.service.mapper.AssetMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Optional;
/**
* Service Implementation for managing Asset.
*/
@Service
@Transactional
public class AssetService {
private final Logger log = LoggerFactory.getLogger(AssetService.class);
private final AssetRepository assetRepository;
private final AssetMapper assetMapper;
public AssetService(AssetRepository assetRepository, AssetMapper assetMapper) {
this.assetRepository = assetRepository;
this.assetMapper = assetMapper;
}
/**
* Save a asset.
*
* @param assetDTO the entity to save
* @return the persisted entity
*/
public AssetDTO save(AssetDTO assetDTO) {
log.debug("Request to save Asset : {}", assetDTO);
Asset asset = assetMapper.toEntity(assetDTO);
asset = assetRepository.save(asset);
return assetMapper.toDto(asset);
}
/**
* Get all the assets.
*
* @param pageable the pagination information
* @return the list of entities
*/
@Transactional(readOnly = true)
public Page<AssetDTO> findAll(Pageable pageable) {
log.debug("Request to get all Assets");
return assetRepository.findAll(pageable)
.map(assetMapper::toDto);
}
/**
* Get one asset by id.
*
* @param id the id of the entity
* @return the entity
*/
@Transactional(readOnly = true)
public Optional<AssetDTO> findOne(Long id) {
log.debug("Request to get Asset : {}", id);
return assetRepository.findById(id)
.map(assetMapper::toDto);
}
/**
* Delete the asset by id.
*
* @param id the id of the entity
*/
public void delete(Long id) {
log.debug("Request to delete Asset : {}", id);
assetRepository.deleteById(id);
}
}

View File

@ -0,0 +1,108 @@
package org.hostsharing.hsadminng.service;
import java.util.List;
import javax.persistence.criteria.JoinType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
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.Contact;
import org.hostsharing.hsadminng.domain.*; // for static metamodels
import org.hostsharing.hsadminng.repository.ContactRepository;
import org.hostsharing.hsadminng.service.dto.ContactCriteria;
import org.hostsharing.hsadminng.service.dto.ContactDTO;
import org.hostsharing.hsadminng.service.mapper.ContactMapper;
/**
* Service for executing complex queries for Contact entities in the database.
* The main input is a {@link ContactCriteria} which gets converted to {@link Specification},
* in a way that all the filters must apply.
* It returns a {@link List} of {@link ContactDTO} or a {@link Page} of {@link ContactDTO} which fulfills the criteria.
*/
@Service
@Transactional(readOnly = true)
public class ContactQueryService extends QueryService<Contact> {
private final Logger log = LoggerFactory.getLogger(ContactQueryService.class);
private final ContactRepository contactRepository;
private final ContactMapper contactMapper;
public ContactQueryService(ContactRepository contactRepository, ContactMapper contactMapper) {
this.contactRepository = contactRepository;
this.contactMapper = contactMapper;
}
/**
* Return a {@link List} of {@link ContactDTO} which matches the criteria from the database
* @param criteria The object which holds all the filters, which the entities should match.
* @return the matching entities.
*/
@Transactional(readOnly = true)
public List<ContactDTO> findByCriteria(ContactCriteria criteria) {
log.debug("find by criteria : {}", criteria);
final Specification<Contact> specification = createSpecification(criteria);
return contactMapper.toDto(contactRepository.findAll(specification));
}
/**
* Return a {@link Page} of {@link ContactDTO} which matches the criteria from the database
* @param criteria The object which holds all the filters, which the entities should match.
* @param page The page, which should be returned.
* @return the matching entities.
*/
@Transactional(readOnly = true)
public Page<ContactDTO> findByCriteria(ContactCriteria criteria, Pageable page) {
log.debug("find by criteria : {}, page: {}", criteria, page);
final Specification<Contact> specification = createSpecification(criteria);
return contactRepository.findAll(specification, page)
.map(contactMapper::toDto);
}
/**
* Return the number of matching entities in the database
* @param criteria The object which holds all the filters, which the entities should match.
* @return the number of matching entities.
*/
@Transactional(readOnly = true)
public long countByCriteria(ContactCriteria criteria) {
log.debug("count by criteria : {}", criteria);
final Specification<Contact> specification = createSpecification(criteria);
return contactRepository.count(specification);
}
/**
* Function to convert ContactCriteria to a {@link Specification}
*/
private Specification<Contact> createSpecification(ContactCriteria criteria) {
Specification<Contact> specification = Specification.where(null);
if (criteria != null) {
if (criteria.getId() != null) {
specification = specification.and(buildSpecification(criteria.getId(), Contact_.id));
}
if (criteria.getFirstName() != null) {
specification = specification.and(buildStringSpecification(criteria.getFirstName(), Contact_.firstName));
}
if (criteria.getLastName() != null) {
specification = specification.and(buildStringSpecification(criteria.getLastName(), Contact_.lastName));
}
if (criteria.getEmail() != null) {
specification = specification.and(buildStringSpecification(criteria.getEmail(), Contact_.email));
}
if (criteria.getRoleId() != null) {
specification = specification.and(buildSpecification(criteria.getRoleId(),
root -> root.join(Contact_.roles, JoinType.LEFT).get(CustomerContact_.id)));
}
}
return specification;
}
}

View File

@ -0,0 +1,84 @@
package org.hostsharing.hsadminng.service;
import org.hostsharing.hsadminng.domain.Contact;
import org.hostsharing.hsadminng.repository.ContactRepository;
import org.hostsharing.hsadminng.service.dto.ContactDTO;
import org.hostsharing.hsadminng.service.mapper.ContactMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Optional;
/**
* Service Implementation for managing Contact.
*/
@Service
@Transactional
public class ContactService {
private final Logger log = LoggerFactory.getLogger(ContactService.class);
private final ContactRepository contactRepository;
private final ContactMapper contactMapper;
public ContactService(ContactRepository contactRepository, ContactMapper contactMapper) {
this.contactRepository = contactRepository;
this.contactMapper = contactMapper;
}
/**
* Save a contact.
*
* @param contactDTO the entity to save
* @return the persisted entity
*/
public ContactDTO save(ContactDTO contactDTO) {
log.debug("Request to save Contact : {}", contactDTO);
Contact contact = contactMapper.toEntity(contactDTO);
contact = contactRepository.save(contact);
return contactMapper.toDto(contact);
}
/**
* Get all the contacts.
*
* @param pageable the pagination information
* @return the list of entities
*/
@Transactional(readOnly = true)
public Page<ContactDTO> findAll(Pageable pageable) {
log.debug("Request to get all Contacts");
return contactRepository.findAll(pageable)
.map(contactMapper::toDto);
}
/**
* Get one contact by id.
*
* @param id the id of the entity
* @return the entity
*/
@Transactional(readOnly = true)
public Optional<ContactDTO> findOne(Long id) {
log.debug("Request to get Contact : {}", id);
return contactRepository.findById(id)
.map(contactMapper::toDto);
}
/**
* Delete the contact by id.
*
* @param id the id of the entity
*/
public void delete(Long id) {
log.debug("Request to delete Contact : {}", id);
contactRepository.deleteById(id);
}
}

View File

@ -0,0 +1,106 @@
package org.hostsharing.hsadminng.service;
import java.util.List;
import javax.persistence.criteria.JoinType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
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.CustomerContact;
import org.hostsharing.hsadminng.domain.*; // for static metamodels
import org.hostsharing.hsadminng.repository.CustomerContactRepository;
import org.hostsharing.hsadminng.service.dto.CustomerContactCriteria;
import org.hostsharing.hsadminng.service.dto.CustomerContactDTO;
import org.hostsharing.hsadminng.service.mapper.CustomerContactMapper;
/**
* Service for executing complex queries for CustomerContact entities in the database.
* The main input is a {@link CustomerContactCriteria} which gets converted to {@link Specification},
* in a way that all the filters must apply.
* It returns a {@link List} of {@link CustomerContactDTO} or a {@link Page} of {@link CustomerContactDTO} which fulfills the criteria.
*/
@Service
@Transactional(readOnly = true)
public class CustomerContactQueryService extends QueryService<CustomerContact> {
private final Logger log = LoggerFactory.getLogger(CustomerContactQueryService.class);
private final CustomerContactRepository customerContactRepository;
private final CustomerContactMapper customerContactMapper;
public CustomerContactQueryService(CustomerContactRepository customerContactRepository, CustomerContactMapper customerContactMapper) {
this.customerContactRepository = customerContactRepository;
this.customerContactMapper = customerContactMapper;
}
/**
* Return a {@link List} of {@link CustomerContactDTO} which matches the criteria from the database
* @param criteria The object which holds all the filters, which the entities should match.
* @return the matching entities.
*/
@Transactional(readOnly = true)
public List<CustomerContactDTO> findByCriteria(CustomerContactCriteria criteria) {
log.debug("find by criteria : {}", criteria);
final Specification<CustomerContact> specification = createSpecification(criteria);
return customerContactMapper.toDto(customerContactRepository.findAll(specification));
}
/**
* Return a {@link Page} of {@link CustomerContactDTO} which matches the criteria from the database
* @param criteria The object which holds all the filters, which the entities should match.
* @param page The page, which should be returned.
* @return the matching entities.
*/
@Transactional(readOnly = true)
public Page<CustomerContactDTO> findByCriteria(CustomerContactCriteria criteria, Pageable page) {
log.debug("find by criteria : {}, page: {}", criteria, page);
final Specification<CustomerContact> specification = createSpecification(criteria);
return customerContactRepository.findAll(specification, page)
.map(customerContactMapper::toDto);
}
/**
* Return the number of matching entities in the database
* @param criteria The object which holds all the filters, which the entities should match.
* @return the number of matching entities.
*/
@Transactional(readOnly = true)
public long countByCriteria(CustomerContactCriteria criteria) {
log.debug("count by criteria : {}", criteria);
final Specification<CustomerContact> specification = createSpecification(criteria);
return customerContactRepository.count(specification);
}
/**
* Function to convert CustomerContactCriteria to a {@link Specification}
*/
private Specification<CustomerContact> createSpecification(CustomerContactCriteria criteria) {
Specification<CustomerContact> specification = Specification.where(null);
if (criteria != null) {
if (criteria.getId() != null) {
specification = specification.and(buildSpecification(criteria.getId(), CustomerContact_.id));
}
if (criteria.getRole() != null) {
specification = specification.and(buildSpecification(criteria.getRole(), CustomerContact_.role));
}
if (criteria.getContactId() != null) {
specification = specification.and(buildSpecification(criteria.getContactId(),
root -> root.join(CustomerContact_.contact, JoinType.LEFT).get(Contact_.id)));
}
if (criteria.getCustomerId() != null) {
specification = specification.and(buildSpecification(criteria.getCustomerId(),
root -> root.join(CustomerContact_.customer, JoinType.LEFT).get(Customer_.id)));
}
}
return specification;
}
}

View File

@ -0,0 +1,84 @@
package org.hostsharing.hsadminng.service;
import org.hostsharing.hsadminng.domain.CustomerContact;
import org.hostsharing.hsadminng.repository.CustomerContactRepository;
import org.hostsharing.hsadminng.service.dto.CustomerContactDTO;
import org.hostsharing.hsadminng.service.mapper.CustomerContactMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Optional;
/**
* Service Implementation for managing CustomerContact.
*/
@Service
@Transactional
public class CustomerContactService {
private final Logger log = LoggerFactory.getLogger(CustomerContactService.class);
private final CustomerContactRepository customerContactRepository;
private final CustomerContactMapper customerContactMapper;
public CustomerContactService(CustomerContactRepository customerContactRepository, CustomerContactMapper customerContactMapper) {
this.customerContactRepository = customerContactRepository;
this.customerContactMapper = customerContactMapper;
}
/**
* Save a customerContact.
*
* @param customerContactDTO the entity to save
* @return the persisted entity
*/
public CustomerContactDTO save(CustomerContactDTO customerContactDTO) {
log.debug("Request to save CustomerContact : {}", customerContactDTO);
CustomerContact customerContact = customerContactMapper.toEntity(customerContactDTO);
customerContact = customerContactRepository.save(customerContact);
return customerContactMapper.toDto(customerContact);
}
/**
* Get all the customerContacts.
*
* @param pageable the pagination information
* @return the list of entities
*/
@Transactional(readOnly = true)
public Page<CustomerContactDTO> findAll(Pageable pageable) {
log.debug("Request to get all CustomerContacts");
return customerContactRepository.findAll(pageable)
.map(customerContactMapper::toDto);
}
/**
* Get one customerContact by id.
*
* @param id the id of the entity
* @return the entity
*/
@Transactional(readOnly = true)
public Optional<CustomerContactDTO> findOne(Long id) {
log.debug("Request to get CustomerContact : {}", id);
return customerContactRepository.findById(id)
.map(customerContactMapper::toDto);
}
/**
* Delete the customerContact by id.
*
* @param id the id of the entity
*/
public void delete(Long id) {
log.debug("Request to delete CustomerContact : {}", id);
customerContactRepository.deleteById(id);
}
}

View File

@ -0,0 +1,109 @@
package org.hostsharing.hsadminng.service;
import java.util.List;
import javax.persistence.criteria.JoinType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
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;
/**
* Service for executing complex queries for Customer entities in the database.
* The main input is a {@link CustomerCriteria} which gets converted to {@link Specification},
* in a way that all the filters must apply.
* It returns a {@link List} of {@link CustomerDTO} or a {@link Page} of {@link CustomerDTO} which fulfills the criteria.
*/
@Service
@Transactional(readOnly = true)
public class CustomerQueryService extends QueryService<Customer> {
private final Logger log = LoggerFactory.getLogger(CustomerQueryService.class);
private final CustomerRepository customerRepository;
private final CustomerMapper customerMapper;
public CustomerQueryService(CustomerRepository customerRepository, CustomerMapper customerMapper) {
this.customerRepository = customerRepository;
this.customerMapper = customerMapper;
}
/**
* Return a {@link List} of {@link CustomerDTO} which matches the criteria from the database
* @param criteria The object which holds all the filters, which the entities should match.
* @return the matching entities.
*/
@Transactional(readOnly = true)
public List<CustomerDTO> findByCriteria(CustomerCriteria criteria) {
log.debug("find by criteria : {}", criteria);
final Specification<Customer> specification = createSpecification(criteria);
return customerMapper.toDto(customerRepository.findAll(specification));
}
/**
* Return a {@link Page} of {@link CustomerDTO} which matches the criteria from the database
* @param criteria The object which holds all the filters, which the entities should match.
* @param page The page, which should be returned.
* @return the matching entities.
*/
@Transactional(readOnly = true)
public Page<CustomerDTO> findByCriteria(CustomerCriteria criteria, Pageable page) {
log.debug("find by criteria : {}, page: {}", criteria, page);
final Specification<Customer> specification = createSpecification(criteria);
return customerRepository.findAll(specification, page)
.map(customerMapper::toDto);
}
/**
* Return the number of matching entities in the database
* @param criteria The object which holds all the filters, which the entities should match.
* @return the number of matching entities.
*/
@Transactional(readOnly = true)
public long countByCriteria(CustomerCriteria criteria) {
log.debug("count by criteria : {}", criteria);
final Specification<Customer> specification = createSpecification(criteria);
return customerRepository.count(specification);
}
/**
* Function to convert CustomerCriteria to a {@link Specification}
*/
private Specification<Customer> createSpecification(CustomerCriteria criteria) {
Specification<Customer> specification = Specification.where(null);
if (criteria != null) {
if (criteria.getId() != null) {
specification = specification.and(buildSpecification(criteria.getId(), Customer_.id));
}
if (criteria.getNumber() != null) {
specification = specification.and(buildRangeSpecification(criteria.getNumber(), Customer_.number));
}
if (criteria.getPrefix() != null) {
specification = specification.and(buildStringSpecification(criteria.getPrefix(), Customer_.prefix));
}
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)));
}
}
return specification;
}
}

View File

@ -0,0 +1,84 @@
package org.hostsharing.hsadminng.service;
import org.hostsharing.hsadminng.domain.Customer;
import org.hostsharing.hsadminng.repository.CustomerRepository;
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;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Optional;
/**
* Service Implementation for managing Customer.
*/
@Service
@Transactional
public class CustomerService {
private final Logger log = LoggerFactory.getLogger(CustomerService.class);
private final CustomerRepository customerRepository;
private final CustomerMapper customerMapper;
public CustomerService(CustomerRepository customerRepository, CustomerMapper customerMapper) {
this.customerRepository = customerRepository;
this.customerMapper = customerMapper;
}
/**
* Save a customer.
*
* @param customerDTO the entity to save
* @return the persisted entity
*/
public CustomerDTO save(CustomerDTO customerDTO) {
log.debug("Request to save Customer : {}", customerDTO);
Customer customer = customerMapper.toEntity(customerDTO);
customer = customerRepository.save(customer);
return customerMapper.toDto(customer);
}
/**
* Get all the customers.
*
* @param pageable the pagination information
* @return the list of entities
*/
@Transactional(readOnly = true)
public Page<CustomerDTO> findAll(Pageable pageable) {
log.debug("Request to get all Customers");
return customerRepository.findAll(pageable)
.map(customerMapper::toDto);
}
/**
* Get one customer by id.
*
* @param id the id of the entity
* @return the entity
*/
@Transactional(readOnly = true)
public Optional<CustomerDTO> findOne(Long id) {
log.debug("Request to get Customer : {}", id);
return customerRepository.findById(id)
.map(customerMapper::toDto);
}
/**
* Delete the customer by id.
*
* @param id the id of the entity
*/
public void delete(Long id) {
log.debug("Request to delete Customer : {}", id);
customerRepository.deleteById(id);
}
}

View File

@ -0,0 +1,113 @@
package org.hostsharing.hsadminng.service;
import java.util.List;
import javax.persistence.criteria.JoinType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
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.Membership;
import org.hostsharing.hsadminng.domain.*; // for static metamodels
import org.hostsharing.hsadminng.repository.MembershipRepository;
import org.hostsharing.hsadminng.service.dto.MembershipCriteria;
import org.hostsharing.hsadminng.service.dto.MembershipDTO;
import org.hostsharing.hsadminng.service.mapper.MembershipMapper;
/**
* Service for executing complex queries for Membership entities in the database.
* The main input is a {@link MembershipCriteria} which gets converted to {@link Specification},
* in a way that all the filters must apply.
* It returns a {@link List} of {@link MembershipDTO} or a {@link Page} of {@link MembershipDTO} which fulfills the criteria.
*/
@Service
@Transactional(readOnly = true)
public class MembershipQueryService extends QueryService<Membership> {
private final Logger log = LoggerFactory.getLogger(MembershipQueryService.class);
private final MembershipRepository membershipRepository;
private final MembershipMapper membershipMapper;
public MembershipQueryService(MembershipRepository membershipRepository, MembershipMapper membershipMapper) {
this.membershipRepository = membershipRepository;
this.membershipMapper = membershipMapper;
}
/**
* Return a {@link List} of {@link MembershipDTO} which matches the criteria from the database
* @param criteria The object which holds all the filters, which the entities should match.
* @return the matching entities.
*/
@Transactional(readOnly = true)
public List<MembershipDTO> findByCriteria(MembershipCriteria criteria) {
log.debug("find by criteria : {}", criteria);
final Specification<Membership> specification = createSpecification(criteria);
return membershipMapper.toDto(membershipRepository.findAll(specification));
}
/**
* Return a {@link Page} of {@link MembershipDTO} which matches the criteria from the database
* @param criteria The object which holds all the filters, which the entities should match.
* @param page The page, which should be returned.
* @return the matching entities.
*/
@Transactional(readOnly = true)
public Page<MembershipDTO> findByCriteria(MembershipCriteria criteria, Pageable page) {
log.debug("find by criteria : {}, page: {}", criteria, page);
final Specification<Membership> specification = createSpecification(criteria);
return membershipRepository.findAll(specification, page)
.map(membershipMapper::toDto);
}
/**
* Return the number of matching entities in the database
* @param criteria The object which holds all the filters, which the entities should match.
* @return the number of matching entities.
*/
@Transactional(readOnly = true)
public long countByCriteria(MembershipCriteria criteria) {
log.debug("count by criteria : {}", criteria);
final Specification<Membership> specification = createSpecification(criteria);
return membershipRepository.count(specification);
}
/**
* Function to convert MembershipCriteria to a {@link Specification}
*/
private Specification<Membership> createSpecification(MembershipCriteria criteria) {
Specification<Membership> specification = Specification.where(null);
if (criteria != null) {
if (criteria.getId() != null) {
specification = specification.and(buildSpecification(criteria.getId(), Membership_.id));
}
if (criteria.getSinceDate() != null) {
specification = specification.and(buildRangeSpecification(criteria.getSinceDate(), Membership_.sinceDate));
}
if (criteria.getUntilDate() != null) {
specification = specification.and(buildRangeSpecification(criteria.getUntilDate(), Membership_.untilDate));
}
if (criteria.getShareId() != null) {
specification = specification.and(buildSpecification(criteria.getShareId(),
root -> root.join(Membership_.shares, JoinType.LEFT).get(Share_.id)));
}
if (criteria.getAssetId() != null) {
specification = specification.and(buildSpecification(criteria.getAssetId(),
root -> root.join(Membership_.assets, JoinType.LEFT).get(Asset_.id)));
}
if (criteria.getCustomerId() != null) {
specification = specification.and(buildSpecification(criteria.getCustomerId(),
root -> root.join(Membership_.customer, JoinType.LEFT).get(Customer_.id)));
}
}
return specification;
}
}

View File

@ -0,0 +1,84 @@
package org.hostsharing.hsadminng.service;
import org.hostsharing.hsadminng.domain.Membership;
import org.hostsharing.hsadminng.repository.MembershipRepository;
import org.hostsharing.hsadminng.service.dto.MembershipDTO;
import org.hostsharing.hsadminng.service.mapper.MembershipMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Optional;
/**
* Service Implementation for managing Membership.
*/
@Service
@Transactional
public class MembershipService {
private final Logger log = LoggerFactory.getLogger(MembershipService.class);
private final MembershipRepository membershipRepository;
private final MembershipMapper membershipMapper;
public MembershipService(MembershipRepository membershipRepository, MembershipMapper membershipMapper) {
this.membershipRepository = membershipRepository;
this.membershipMapper = membershipMapper;
}
/**
* Save a membership.
*
* @param membershipDTO the entity to save
* @return the persisted entity
*/
public MembershipDTO save(MembershipDTO membershipDTO) {
log.debug("Request to save Membership : {}", membershipDTO);
Membership membership = membershipMapper.toEntity(membershipDTO);
membership = membershipRepository.save(membership);
return membershipMapper.toDto(membership);
}
/**
* Get all the memberships.
*
* @param pageable the pagination information
* @return the list of entities
*/
@Transactional(readOnly = true)
public Page<MembershipDTO> findAll(Pageable pageable) {
log.debug("Request to get all Memberships");
return membershipRepository.findAll(pageable)
.map(membershipMapper::toDto);
}
/**
* Get one membership by id.
*
* @param id the id of the entity
* @return the entity
*/
@Transactional(readOnly = true)
public Optional<MembershipDTO> findOne(Long id) {
log.debug("Request to get Membership : {}", id);
return membershipRepository.findById(id)
.map(membershipMapper::toDto);
}
/**
* Delete the membership by id.
*
* @param id the id of the entity
*/
public void delete(Long id) {
log.debug("Request to delete Membership : {}", id);
membershipRepository.deleteById(id);
}
}

View File

@ -0,0 +1,111 @@
package org.hostsharing.hsadminng.service;
import java.util.List;
import javax.persistence.criteria.JoinType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
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.Share;
import org.hostsharing.hsadminng.domain.*; // for static metamodels
import org.hostsharing.hsadminng.repository.ShareRepository;
import org.hostsharing.hsadminng.service.dto.ShareCriteria;
import org.hostsharing.hsadminng.service.dto.ShareDTO;
import org.hostsharing.hsadminng.service.mapper.ShareMapper;
/**
* Service for executing complex queries for Share entities in the database.
* The main input is a {@link ShareCriteria} which gets converted to {@link Specification},
* in a way that all the filters must apply.
* It returns a {@link List} of {@link ShareDTO} or a {@link Page} of {@link ShareDTO} which fulfills the criteria.
*/
@Service
@Transactional(readOnly = true)
public class ShareQueryService extends QueryService<Share> {
private final Logger log = LoggerFactory.getLogger(ShareQueryService.class);
private final ShareRepository shareRepository;
private final ShareMapper shareMapper;
public ShareQueryService(ShareRepository shareRepository, ShareMapper shareMapper) {
this.shareRepository = shareRepository;
this.shareMapper = shareMapper;
}
/**
* Return a {@link List} of {@link ShareDTO} which matches the criteria from the database
* @param criteria The object which holds all the filters, which the entities should match.
* @return the matching entities.
*/
@Transactional(readOnly = true)
public List<ShareDTO> findByCriteria(ShareCriteria criteria) {
log.debug("find by criteria : {}", criteria);
final Specification<Share> specification = createSpecification(criteria);
return shareMapper.toDto(shareRepository.findAll(specification));
}
/**
* Return a {@link Page} of {@link ShareDTO} which matches the criteria from the database
* @param criteria The object which holds all the filters, which the entities should match.
* @param page The page, which should be returned.
* @return the matching entities.
*/
@Transactional(readOnly = true)
public Page<ShareDTO> findByCriteria(ShareCriteria criteria, Pageable page) {
log.debug("find by criteria : {}, page: {}", criteria, page);
final Specification<Share> specification = createSpecification(criteria);
return shareRepository.findAll(specification, page)
.map(shareMapper::toDto);
}
/**
* Return the number of matching entities in the database
* @param criteria The object which holds all the filters, which the entities should match.
* @return the number of matching entities.
*/
@Transactional(readOnly = true)
public long countByCriteria(ShareCriteria criteria) {
log.debug("count by criteria : {}", criteria);
final Specification<Share> specification = createSpecification(criteria);
return shareRepository.count(specification);
}
/**
* Function to convert ShareCriteria to a {@link Specification}
*/
private Specification<Share> createSpecification(ShareCriteria criteria) {
Specification<Share> specification = Specification.where(null);
if (criteria != null) {
if (criteria.getId() != null) {
specification = specification.and(buildSpecification(criteria.getId(), Share_.id));
}
if (criteria.getDate() != null) {
specification = specification.and(buildRangeSpecification(criteria.getDate(), Share_.date));
}
if (criteria.getAction() != null) {
specification = specification.and(buildSpecification(criteria.getAction(), Share_.action));
}
if (criteria.getQuantity() != null) {
specification = specification.and(buildRangeSpecification(criteria.getQuantity(), Share_.quantity));
}
if (criteria.getComment() != null) {
specification = specification.and(buildStringSpecification(criteria.getComment(), Share_.comment));
}
if (criteria.getMemberId() != null) {
specification = specification.and(buildSpecification(criteria.getMemberId(),
root -> root.join(Share_.member, JoinType.LEFT).get(Membership_.id)));
}
}
return specification;
}
}

View File

@ -0,0 +1,84 @@
package org.hostsharing.hsadminng.service;
import org.hostsharing.hsadminng.domain.Share;
import org.hostsharing.hsadminng.repository.ShareRepository;
import org.hostsharing.hsadminng.service.dto.ShareDTO;
import org.hostsharing.hsadminng.service.mapper.ShareMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Optional;
/**
* Service Implementation for managing Share.
*/
@Service
@Transactional
public class ShareService {
private final Logger log = LoggerFactory.getLogger(ShareService.class);
private final ShareRepository shareRepository;
private final ShareMapper shareMapper;
public ShareService(ShareRepository shareRepository, ShareMapper shareMapper) {
this.shareRepository = shareRepository;
this.shareMapper = shareMapper;
}
/**
* Save a share.
*
* @param shareDTO the entity to save
* @return the persisted entity
*/
public ShareDTO save(ShareDTO shareDTO) {
log.debug("Request to save Share : {}", shareDTO);
Share share = shareMapper.toEntity(shareDTO);
share = shareRepository.save(share);
return shareMapper.toDto(share);
}
/**
* Get all the shares.
*
* @param pageable the pagination information
* @return the list of entities
*/
@Transactional(readOnly = true)
public Page<ShareDTO> findAll(Pageable pageable) {
log.debug("Request to get all Shares");
return shareRepository.findAll(pageable)
.map(shareMapper::toDto);
}
/**
* Get one share by id.
*
* @param id the id of the entity
* @return the entity
*/
@Transactional(readOnly = true)
public Optional<ShareDTO> findOne(Long id) {
log.debug("Request to get Share : {}", id);
return shareRepository.findById(id)
.map(shareMapper::toDto);
}
/**
* Delete the share by id.
*
* @param id the id of the entity
*/
public void delete(Long id) {
log.debug("Request to delete Share : {}", id);
shareRepository.deleteById(id);
}
}

View File

@ -0,0 +1,136 @@
package org.hostsharing.hsadminng.service.dto;
import java.io.Serializable;
import java.util.Objects;
import org.hostsharing.hsadminng.domain.enumeration.AssetAction;
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 io.github.jhipster.service.filter.BigDecimalFilter;
import io.github.jhipster.service.filter.LocalDateFilter;
/**
* Criteria class for the Asset entity. This class is used in AssetResource to
* receive all the possible filtering options from the Http GET request parameters.
* For example the following could be a valid requests:
* <code> /assets?id.greaterThan=5&amp;attr1.contains=something&amp;attr2.specified=false</code>
* As Spring is unable to properly convert the types, unless specific {@link Filter} class are used, we need to use
* fix type specific filters.
*/
public class AssetCriteria implements Serializable {
/**
* Class for filtering AssetAction
*/
public static class AssetActionFilter extends Filter<AssetAction> {
}
private static final long serialVersionUID = 1L;
private LongFilter id;
private LocalDateFilter date;
private AssetActionFilter action;
private BigDecimalFilter amount;
private StringFilter comment;
private LongFilter memberId;
public LongFilter getId() {
return id;
}
public void setId(LongFilter id) {
this.id = id;
}
public LocalDateFilter getDate() {
return date;
}
public void setDate(LocalDateFilter date) {
this.date = date;
}
public AssetActionFilter getAction() {
return action;
}
public void setAction(AssetActionFilter action) {
this.action = action;
}
public BigDecimalFilter getAmount() {
return amount;
}
public void setAmount(BigDecimalFilter amount) {
this.amount = amount;
}
public StringFilter getComment() {
return comment;
}
public void setComment(StringFilter comment) {
this.comment = comment;
}
public LongFilter getMemberId() {
return memberId;
}
public void setMemberId(LongFilter memberId) {
this.memberId = memberId;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final AssetCriteria that = (AssetCriteria) o;
return
Objects.equals(id, that.id) &&
Objects.equals(date, that.date) &&
Objects.equals(action, that.action) &&
Objects.equals(amount, that.amount) &&
Objects.equals(comment, that.comment) &&
Objects.equals(memberId, that.memberId);
}
@Override
public int hashCode() {
return Objects.hash(
id,
date,
action,
amount,
comment,
memberId
);
}
@Override
public String toString() {
return "AssetCriteria{" +
(id != null ? "id=" + id + ", " : "") +
(date != null ? "date=" + date + ", " : "") +
(action != null ? "action=" + action + ", " : "") +
(amount != null ? "amount=" + amount + ", " : "") +
(comment != null ? "comment=" + comment + ", " : "") +
(memberId != null ? "memberId=" + memberId + ", " : "") +
"}";
}
}

View File

@ -0,0 +1,111 @@
package org.hostsharing.hsadminng.service.dto;
import java.time.LocalDate;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Objects;
import org.hostsharing.hsadminng.domain.enumeration.AssetAction;
/**
* A DTO for the Asset entity.
*/
public class AssetDTO implements Serializable {
private Long id;
@NotNull
private LocalDate date;
@NotNull
private AssetAction action;
@NotNull
private BigDecimal amount;
@Size(max = 160)
private String comment;
private Long memberId;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public LocalDate getDate() {
return date;
}
public void setDate(LocalDate date) {
this.date = date;
}
public AssetAction getAction() {
return action;
}
public void setAction(AssetAction action) {
this.action = action;
}
public BigDecimal getAmount() {
return amount;
}
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public Long getMemberId() {
return memberId;
}
public void setMemberId(Long membershipId) {
this.memberId = membershipId;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
AssetDTO assetDTO = (AssetDTO) o;
if (assetDTO.getId() == null || getId() == null) {
return false;
}
return Objects.equals(getId(), assetDTO.getId());
}
@Override
public int hashCode() {
return Objects.hashCode(getId());
}
@Override
public String toString() {
return "AssetDTO{" +
"id=" + getId() +
", date='" + getDate() + "'" +
", action='" + getAction() + "'" +
", amount=" + getAmount() +
", comment='" + getComment() + "'" +
", member=" + getMemberId() +
"}";
}
}

View File

@ -0,0 +1,115 @@
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;
/**
* Criteria class for the Contact entity. This class is used in ContactResource to
* receive all the possible filtering options from the Http GET request parameters.
* For example the following could be a valid requests:
* <code> /contacts?id.greaterThan=5&amp;attr1.contains=something&amp;attr2.specified=false</code>
* As Spring is unable to properly convert the types, unless specific {@link Filter} class are used, we need to use
* fix type specific filters.
*/
public class ContactCriteria implements Serializable {
private static final long serialVersionUID = 1L;
private LongFilter id;
private StringFilter firstName;
private StringFilter lastName;
private StringFilter email;
private LongFilter roleId;
public LongFilter getId() {
return id;
}
public void setId(LongFilter id) {
this.id = id;
}
public StringFilter getFirstName() {
return firstName;
}
public void setFirstName(StringFilter firstName) {
this.firstName = firstName;
}
public StringFilter getLastName() {
return lastName;
}
public void setLastName(StringFilter lastName) {
this.lastName = lastName;
}
public StringFilter getEmail() {
return email;
}
public void setEmail(StringFilter email) {
this.email = email;
}
public LongFilter getRoleId() {
return roleId;
}
public void setRoleId(LongFilter roleId) {
this.roleId = roleId;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final ContactCriteria that = (ContactCriteria) o;
return
Objects.equals(id, that.id) &&
Objects.equals(firstName, that.firstName) &&
Objects.equals(lastName, that.lastName) &&
Objects.equals(email, that.email) &&
Objects.equals(roleId, that.roleId);
}
@Override
public int hashCode() {
return Objects.hash(
id,
firstName,
lastName,
email,
roleId
);
}
@Override
public String toString() {
return "ContactCriteria{" +
(id != null ? "id=" + id + ", " : "") +
(firstName != null ? "firstName=" + firstName + ", " : "") +
(lastName != null ? "lastName=" + lastName + ", " : "") +
(email != null ? "email=" + email + ", " : "") +
(roleId != null ? "roleId=" + roleId + ", " : "") +
"}";
}
}

View File

@ -0,0 +1,88 @@
package org.hostsharing.hsadminng.service.dto;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.util.Objects;
/**
* A DTO for the Contact entity.
*/
public class ContactDTO implements Serializable {
private Long id;
@NotNull
@Size(max = 80)
private String firstName;
@NotNull
@Size(max = 80)
private String lastName;
@NotNull
@Size(max = 80)
private String email;
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 String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ContactDTO contactDTO = (ContactDTO) o;
if (contactDTO.getId() == null || getId() == null) {
return false;
}
return Objects.equals(getId(), contactDTO.getId());
}
@Override
public int hashCode() {
return Objects.hashCode(getId());
}
@Override
public String toString() {
return "ContactDTO{" +
"id=" + getId() +
", firstName='" + getFirstName() + "'" +
", lastName='" + getLastName() + "'" +
", email='" + getEmail() + "'" +
"}";
}
}

View File

@ -0,0 +1,108 @@
package org.hostsharing.hsadminng.service.dto;
import java.io.Serializable;
import java.util.Objects;
import org.hostsharing.hsadminng.domain.enumeration.CustomerContactRole;
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;
/**
* Criteria class for the CustomerContact entity. This class is used in CustomerContactResource to
* receive all the possible filtering options from the Http GET request parameters.
* For example the following could be a valid requests:
* <code> /customer-contacts?id.greaterThan=5&amp;attr1.contains=something&amp;attr2.specified=false</code>
* As Spring is unable to properly convert the types, unless specific {@link Filter} class are used, we need to use
* fix type specific filters.
*/
public class CustomerContactCriteria implements Serializable {
/**
* Class for filtering CustomerContactRole
*/
public static class CustomerContactRoleFilter extends Filter<CustomerContactRole> {
}
private static final long serialVersionUID = 1L;
private LongFilter id;
private CustomerContactRoleFilter role;
private LongFilter contactId;
private LongFilter customerId;
public LongFilter getId() {
return id;
}
public void setId(LongFilter id) {
this.id = id;
}
public CustomerContactRoleFilter getRole() {
return role;
}
public void setRole(CustomerContactRoleFilter role) {
this.role = role;
}
public LongFilter getContactId() {
return contactId;
}
public void setContactId(LongFilter contactId) {
this.contactId = contactId;
}
public LongFilter getCustomerId() {
return customerId;
}
public void setCustomerId(LongFilter customerId) {
this.customerId = customerId;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final CustomerContactCriteria that = (CustomerContactCriteria) o;
return
Objects.equals(id, that.id) &&
Objects.equals(role, that.role) &&
Objects.equals(contactId, that.contactId) &&
Objects.equals(customerId, that.customerId);
}
@Override
public int hashCode() {
return Objects.hash(
id,
role,
contactId,
customerId
);
}
@Override
public String toString() {
return "CustomerContactCriteria{" +
(id != null ? "id=" + id + ", " : "") +
(role != null ? "role=" + role + ", " : "") +
(contactId != null ? "contactId=" + contactId + ", " : "") +
(customerId != null ? "customerId=" + customerId + ", " : "") +
"}";
}
}

View File

@ -0,0 +1,106 @@
package org.hostsharing.hsadminng.service.dto;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.util.Objects;
import org.hostsharing.hsadminng.domain.enumeration.CustomerContactRole;
/**
* A DTO for the CustomerContact entity.
*/
public class CustomerContactDTO implements Serializable {
private Long id;
@NotNull
private CustomerContactRole role;
private Long contactId;
private String contactEmail;
private Long customerId;
private String customerPrefix;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public CustomerContactRole getRole() {
return role;
}
public void setRole(CustomerContactRole role) {
this.role = role;
}
public Long getContactId() {
return contactId;
}
public void setContactId(Long contactId) {
this.contactId = contactId;
}
public String getContactEmail() {
return contactEmail;
}
public void setContactEmail(String contactEmail) {
this.contactEmail = contactEmail;
}
public Long getCustomerId() {
return customerId;
}
public void setCustomerId(Long customerId) {
this.customerId = customerId;
}
public String getCustomerPrefix() {
return customerPrefix;
}
public void setCustomerPrefix(String customerPrefix) {
this.customerPrefix = customerPrefix;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CustomerContactDTO customerContactDTO = (CustomerContactDTO) o;
if (customerContactDTO.getId() == null || getId() == null) {
return false;
}
return Objects.equals(getId(), customerContactDTO.getId());
}
@Override
public int hashCode() {
return Objects.hashCode(getId());
}
@Override
public String toString() {
return "CustomerContactDTO{" +
"id=" + getId() +
", role='" + getRole() + "'" +
", contact=" + getContactId() +
", contact='" + getContactEmail() + "'" +
", customer=" + getCustomerId() +
", customer='" + getCustomerPrefix() + "'" +
"}";
}
}

View File

@ -0,0 +1,115 @@
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;
/**
* 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.
* For example the following could be a valid requests:
* <code> /customers?id.greaterThan=5&amp;attr1.contains=something&amp;attr2.specified=false</code>
* As Spring is unable to properly convert the types, unless specific {@link Filter} class are used, we need to use
* fix type specific filters.
*/
public class CustomerCriteria implements Serializable {
private static final long serialVersionUID = 1L;
private LongFilter id;
private IntegerFilter number;
private StringFilter prefix;
private LongFilter membershipId;
private LongFilter roleId;
public LongFilter getId() {
return id;
}
public void setId(LongFilter id) {
this.id = id;
}
public IntegerFilter getNumber() {
return number;
}
public void setNumber(IntegerFilter number) {
this.number = number;
}
public StringFilter getPrefix() {
return prefix;
}
public void setPrefix(StringFilter prefix) {
this.prefix = prefix;
}
public LongFilter getMembershipId() {
return membershipId;
}
public void setMembershipId(LongFilter membershipId) {
this.membershipId = membershipId;
}
public LongFilter getRoleId() {
return roleId;
}
public void setRoleId(LongFilter roleId) {
this.roleId = roleId;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final CustomerCriteria that = (CustomerCriteria) o;
return
Objects.equals(id, that.id) &&
Objects.equals(number, that.number) &&
Objects.equals(prefix, that.prefix) &&
Objects.equals(membershipId, that.membershipId) &&
Objects.equals(roleId, that.roleId);
}
@Override
public int hashCode() {
return Objects.hash(
id,
number,
prefix,
membershipId,
roleId
);
}
@Override
public String toString() {
return "CustomerCriteria{" +
(id != null ? "id=" + id + ", " : "") +
(number != null ? "number=" + number + ", " : "") +
(prefix != null ? "prefix=" + prefix + ", " : "") +
(membershipId != null ? "membershipId=" + membershipId + ", " : "") +
(roleId != null ? "roleId=" + roleId + ", " : "") +
"}";
}
}

View File

@ -0,0 +1,76 @@
package org.hostsharing.hsadminng.service.dto;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.util.Objects;
/**
* A DTO for the Customer entity.
*/
public class CustomerDTO implements Serializable {
private Long id;
@NotNull
@Min(value = 10000)
@Max(value = 99999)
private Integer number;
@NotNull
@Pattern(regexp = "[a-z][a-z0-9]+")
private String prefix;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getNumber() {
return number;
}
public void setNumber(Integer number) {
this.number = number;
}
public String getPrefix() {
return prefix;
}
public void setPrefix(String prefix) {
this.prefix = prefix;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CustomerDTO customerDTO = (CustomerDTO) o;
if (customerDTO.getId() == null || getId() == null) {
return false;
}
return Objects.equals(getId(), customerDTO.getId());
}
@Override
public int hashCode() {
return Objects.hashCode(getId());
}
@Override
public String toString() {
return "CustomerDTO{" +
"id=" + getId() +
", number=" + getNumber() +
", prefix='" + getPrefix() + "'" +
"}";
}
}

View File

@ -0,0 +1,129 @@
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 io.github.jhipster.service.filter.LocalDateFilter;
/**
* Criteria class for the Membership entity. This class is used in MembershipResource to
* receive all the possible filtering options from the Http GET request parameters.
* For example the following could be a valid requests:
* <code> /memberships?id.greaterThan=5&amp;attr1.contains=something&amp;attr2.specified=false</code>
* As Spring is unable to properly convert the types, unless specific {@link Filter} class are used, we need to use
* fix type specific filters.
*/
public class MembershipCriteria implements Serializable {
private static final long serialVersionUID = 1L;
private LongFilter id;
private LocalDateFilter sinceDate;
private LocalDateFilter untilDate;
private LongFilter shareId;
private LongFilter assetId;
private LongFilter customerId;
public LongFilter getId() {
return id;
}
public void setId(LongFilter id) {
this.id = id;
}
public LocalDateFilter getSinceDate() {
return sinceDate;
}
public void setSinceDate(LocalDateFilter sinceDate) {
this.sinceDate = sinceDate;
}
public LocalDateFilter getUntilDate() {
return untilDate;
}
public void setUntilDate(LocalDateFilter untilDate) {
this.untilDate = untilDate;
}
public LongFilter getShareId() {
return shareId;
}
public void setShareId(LongFilter shareId) {
this.shareId = shareId;
}
public LongFilter getAssetId() {
return assetId;
}
public void setAssetId(LongFilter assetId) {
this.assetId = assetId;
}
public LongFilter getCustomerId() {
return customerId;
}
public void setCustomerId(LongFilter customerId) {
this.customerId = customerId;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final MembershipCriteria that = (MembershipCriteria) o;
return
Objects.equals(id, that.id) &&
Objects.equals(sinceDate, that.sinceDate) &&
Objects.equals(untilDate, that.untilDate) &&
Objects.equals(shareId, that.shareId) &&
Objects.equals(assetId, that.assetId) &&
Objects.equals(customerId, that.customerId);
}
@Override
public int hashCode() {
return Objects.hash(
id,
sinceDate,
untilDate,
shareId,
assetId,
customerId
);
}
@Override
public String toString() {
return "MembershipCriteria{" +
(id != null ? "id=" + id + ", " : "") +
(sinceDate != null ? "sinceDate=" + sinceDate + ", " : "") +
(untilDate != null ? "untilDate=" + untilDate + ", " : "") +
(shareId != null ? "shareId=" + shareId + ", " : "") +
(assetId != null ? "assetId=" + assetId + ", " : "") +
(customerId != null ? "customerId=" + customerId + ", " : "") +
"}";
}
}

View File

@ -0,0 +1,95 @@
package org.hostsharing.hsadminng.service.dto;
import java.time.LocalDate;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.util.Objects;
/**
* A DTO for the Membership entity.
*/
public class MembershipDTO implements Serializable {
private Long id;
@NotNull
private LocalDate sinceDate;
private LocalDate untilDate;
private Long customerId;
private String customerPrefix;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public LocalDate getSinceDate() {
return sinceDate;
}
public void setSinceDate(LocalDate sinceDate) {
this.sinceDate = sinceDate;
}
public LocalDate getUntilDate() {
return untilDate;
}
public void setUntilDate(LocalDate untilDate) {
this.untilDate = untilDate;
}
public Long getCustomerId() {
return customerId;
}
public void setCustomerId(Long customerId) {
this.customerId = customerId;
}
public String getCustomerPrefix() {
return customerPrefix;
}
public void setCustomerPrefix(String customerPrefix) {
this.customerPrefix = customerPrefix;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
MembershipDTO membershipDTO = (MembershipDTO) o;
if (membershipDTO.getId() == null || getId() == null) {
return false;
}
return Objects.equals(getId(), membershipDTO.getId());
}
@Override
public int hashCode() {
return Objects.hashCode(getId());
}
@Override
public String toString() {
return "MembershipDTO{" +
"id=" + getId() +
", sinceDate='" + getSinceDate() + "'" +
", untilDate='" + getUntilDate() + "'" +
", customer=" + getCustomerId() +
", customer='" + getCustomerPrefix() + "'" +
"}";
}
}

View File

@ -0,0 +1,135 @@
package org.hostsharing.hsadminng.service.dto;
import java.io.Serializable;
import java.util.Objects;
import org.hostsharing.hsadminng.domain.enumeration.ShareAction;
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 io.github.jhipster.service.filter.LocalDateFilter;
/**
* Criteria class for the Share entity. This class is used in ShareResource to
* receive all the possible filtering options from the Http GET request parameters.
* For example the following could be a valid requests:
* <code> /shares?id.greaterThan=5&amp;attr1.contains=something&amp;attr2.specified=false</code>
* As Spring is unable to properly convert the types, unless specific {@link Filter} class are used, we need to use
* fix type specific filters.
*/
public class ShareCriteria implements Serializable {
/**
* Class for filtering ShareAction
*/
public static class ShareActionFilter extends Filter<ShareAction> {
}
private static final long serialVersionUID = 1L;
private LongFilter id;
private LocalDateFilter date;
private ShareActionFilter action;
private IntegerFilter quantity;
private StringFilter comment;
private LongFilter memberId;
public LongFilter getId() {
return id;
}
public void setId(LongFilter id) {
this.id = id;
}
public LocalDateFilter getDate() {
return date;
}
public void setDate(LocalDateFilter date) {
this.date = date;
}
public ShareActionFilter getAction() {
return action;
}
public void setAction(ShareActionFilter action) {
this.action = action;
}
public IntegerFilter getQuantity() {
return quantity;
}
public void setQuantity(IntegerFilter quantity) {
this.quantity = quantity;
}
public StringFilter getComment() {
return comment;
}
public void setComment(StringFilter comment) {
this.comment = comment;
}
public LongFilter getMemberId() {
return memberId;
}
public void setMemberId(LongFilter memberId) {
this.memberId = memberId;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final ShareCriteria that = (ShareCriteria) o;
return
Objects.equals(id, that.id) &&
Objects.equals(date, that.date) &&
Objects.equals(action, that.action) &&
Objects.equals(quantity, that.quantity) &&
Objects.equals(comment, that.comment) &&
Objects.equals(memberId, that.memberId);
}
@Override
public int hashCode() {
return Objects.hash(
id,
date,
action,
quantity,
comment,
memberId
);
}
@Override
public String toString() {
return "ShareCriteria{" +
(id != null ? "id=" + id + ", " : "") +
(date != null ? "date=" + date + ", " : "") +
(action != null ? "action=" + action + ", " : "") +
(quantity != null ? "quantity=" + quantity + ", " : "") +
(comment != null ? "comment=" + comment + ", " : "") +
(memberId != null ? "memberId=" + memberId + ", " : "") +
"}";
}
}

View File

@ -0,0 +1,110 @@
package org.hostsharing.hsadminng.service.dto;
import java.time.LocalDate;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.util.Objects;
import org.hostsharing.hsadminng.domain.enumeration.ShareAction;
/**
* A DTO for the Share entity.
*/
public class ShareDTO implements Serializable {
private Long id;
@NotNull
private LocalDate date;
@NotNull
private ShareAction action;
@NotNull
private Integer quantity;
@Size(max = 160)
private String comment;
private Long memberId;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public LocalDate getDate() {
return date;
}
public void setDate(LocalDate date) {
this.date = date;
}
public ShareAction getAction() {
return action;
}
public void setAction(ShareAction action) {
this.action = action;
}
public Integer getQuantity() {
return quantity;
}
public void setQuantity(Integer quantity) {
this.quantity = quantity;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public Long getMemberId() {
return memberId;
}
public void setMemberId(Long membershipId) {
this.memberId = membershipId;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ShareDTO shareDTO = (ShareDTO) o;
if (shareDTO.getId() == null || getId() == null) {
return false;
}
return Objects.equals(getId(), shareDTO.getId());
}
@Override
public int hashCode() {
return Objects.hashCode(getId());
}
@Override
public String toString() {
return "ShareDTO{" +
"id=" + getId() +
", date='" + getDate() + "'" +
", action='" + getAction() + "'" +
", quantity=" + getQuantity() +
", comment='" + getComment() + "'" +
", member=" + getMemberId() +
"}";
}
}

View File

@ -0,0 +1,28 @@
package org.hostsharing.hsadminng.service.mapper;
import org.hostsharing.hsadminng.domain.*;
import org.hostsharing.hsadminng.service.dto.AssetDTO;
import org.mapstruct.*;
/**
* Mapper for the entity Asset and its DTO AssetDTO.
*/
@Mapper(componentModel = "spring", uses = {MembershipMapper.class})
public interface AssetMapper extends EntityMapper<AssetDTO, Asset> {
@Mapping(source = "member.id", target = "memberId")
AssetDTO toDto(Asset asset);
@Mapping(source = "memberId", target = "member")
Asset toEntity(AssetDTO assetDTO);
default Asset fromId(Long id) {
if (id == null) {
return null;
}
Asset asset = new Asset();
asset.setId(id);
return asset;
}
}

View File

@ -0,0 +1,26 @@
package org.hostsharing.hsadminng.service.mapper;
import org.hostsharing.hsadminng.domain.*;
import org.hostsharing.hsadminng.service.dto.ContactDTO;
import org.mapstruct.*;
/**
* Mapper for the entity Contact and its DTO ContactDTO.
*/
@Mapper(componentModel = "spring", uses = {})
public interface ContactMapper extends EntityMapper<ContactDTO, Contact> {
@Mapping(target = "roles", ignore = true)
Contact toEntity(ContactDTO contactDTO);
default Contact fromId(Long id) {
if (id == null) {
return null;
}
Contact contact = new Contact();
contact.setId(id);
return contact;
}
}

View File

@ -0,0 +1,32 @@
package org.hostsharing.hsadminng.service.mapper;
import org.hostsharing.hsadminng.domain.*;
import org.hostsharing.hsadminng.service.dto.CustomerContactDTO;
import org.mapstruct.*;
/**
* Mapper for the entity CustomerContact and its DTO CustomerContactDTO.
*/
@Mapper(componentModel = "spring", uses = {ContactMapper.class, CustomerMapper.class})
public interface CustomerContactMapper extends EntityMapper<CustomerContactDTO, CustomerContact> {
@Mapping(source = "contact.id", target = "contactId")
@Mapping(source = "contact.email", target = "contactEmail")
@Mapping(source = "customer.id", target = "customerId")
@Mapping(source = "customer.prefix", target = "customerPrefix")
CustomerContactDTO toDto(CustomerContact customerContact);
@Mapping(source = "contactId", target = "contact")
@Mapping(source = "customerId", target = "customer")
CustomerContact toEntity(CustomerContactDTO customerContactDTO);
default CustomerContact fromId(Long id) {
if (id == null) {
return null;
}
CustomerContact customerContact = new CustomerContact();
customerContact.setId(id);
return customerContact;
}
}

View File

@ -0,0 +1,27 @@
package org.hostsharing.hsadminng.service.mapper;
import org.hostsharing.hsadminng.domain.*;
import org.hostsharing.hsadminng.service.dto.CustomerDTO;
import org.mapstruct.*;
/**
* Mapper for the entity Customer and its DTO CustomerDTO.
*/
@Mapper(componentModel = "spring", uses = {})
public interface CustomerMapper extends EntityMapper<CustomerDTO, Customer> {
@Mapping(target = "memberships", ignore = true)
@Mapping(target = "roles", ignore = true)
Customer toEntity(CustomerDTO customerDTO);
default Customer fromId(Long id) {
if (id == null) {
return null;
}
Customer customer = new Customer();
customer.setId(id);
return customer;
}
}

View File

@ -0,0 +1,21 @@
package org.hostsharing.hsadminng.service.mapper;
import java.util.List;
/**
* Contract for a generic dto to entity mapper.
*
* @param <D> - DTO type parameter.
* @param <E> - Entity type parameter.
*/
public interface EntityMapper <D, E> {
E toEntity(D dto);
D toDto(E entity);
List <E> toEntity(List<D> dtoList);
List <D> toDto(List<E> entityList);
}

View File

@ -0,0 +1,31 @@
package org.hostsharing.hsadminng.service.mapper;
import org.hostsharing.hsadminng.domain.*;
import org.hostsharing.hsadminng.service.dto.MembershipDTO;
import org.mapstruct.*;
/**
* Mapper for the entity Membership and its DTO MembershipDTO.
*/
@Mapper(componentModel = "spring", uses = {CustomerMapper.class})
public interface MembershipMapper extends EntityMapper<MembershipDTO, Membership> {
@Mapping(source = "customer.id", target = "customerId")
@Mapping(source = "customer.prefix", target = "customerPrefix")
MembershipDTO toDto(Membership membership);
@Mapping(target = "shares", ignore = true)
@Mapping(target = "assets", ignore = true)
@Mapping(source = "customerId", target = "customer")
Membership toEntity(MembershipDTO membershipDTO);
default Membership fromId(Long id) {
if (id == null) {
return null;
}
Membership membership = new Membership();
membership.setId(id);
return membership;
}
}

View File

@ -0,0 +1,28 @@
package org.hostsharing.hsadminng.service.mapper;
import org.hostsharing.hsadminng.domain.*;
import org.hostsharing.hsadminng.service.dto.ShareDTO;
import org.mapstruct.*;
/**
* Mapper for the entity Share and its DTO ShareDTO.
*/
@Mapper(componentModel = "spring", uses = {MembershipMapper.class})
public interface ShareMapper extends EntityMapper<ShareDTO, Share> {
@Mapping(source = "member.id", target = "memberId")
ShareDTO toDto(Share share);
@Mapping(source = "memberId", target = "member")
Share toEntity(ShareDTO shareDTO);
default Share fromId(Long id) {
if (id == null) {
return null;
}
Share share = new Share();
share.setId(id);
return share;
}
}

View File

@ -0,0 +1,138 @@
package org.hostsharing.hsadminng.web.rest;
import org.hostsharing.hsadminng.service.AssetService;
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
import org.hostsharing.hsadminng.web.rest.util.HeaderUtil;
import org.hostsharing.hsadminng.web.rest.util.PaginationUtil;
import org.hostsharing.hsadminng.service.dto.AssetDTO;
import org.hostsharing.hsadminng.service.dto.AssetCriteria;
import org.hostsharing.hsadminng.service.AssetQueryService;
import io.github.jhipster.web.util.ResponseUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Optional;
/**
* REST controller for managing Asset.
*/
@RestController
@RequestMapping("/api")
public class AssetResource {
private final Logger log = LoggerFactory.getLogger(AssetResource.class);
private static final String ENTITY_NAME = "asset";
private final AssetService assetService;
private final AssetQueryService assetQueryService;
public AssetResource(AssetService assetService, AssetQueryService assetQueryService) {
this.assetService = assetService;
this.assetQueryService = assetQueryService;
}
/**
* POST /assets : Create a new asset.
*
* @param assetDTO the assetDTO to create
* @return the ResponseEntity with status 201 (Created) and with body the new assetDTO, or with status 400 (Bad Request) if the asset has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/assets")
public ResponseEntity<AssetDTO> createAsset(@Valid @RequestBody AssetDTO assetDTO) throws URISyntaxException {
log.debug("REST request to save Asset : {}", assetDTO);
if (assetDTO.getId() != null) {
throw new BadRequestAlertException("A new asset cannot already have an ID", ENTITY_NAME, "idexists");
}
AssetDTO result = assetService.save(assetDTO);
return ResponseEntity.created(new URI("/api/assets/" + result.getId()))
.headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
.body(result);
}
/**
* PUT /assets : Updates an existing asset.
*
* @param assetDTO the assetDTO to update
* @return the ResponseEntity with status 200 (OK) and with body the updated assetDTO,
* or with status 400 (Bad Request) if the assetDTO is not valid,
* or with status 500 (Internal Server Error) if the assetDTO couldn't be updated
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PutMapping("/assets")
public ResponseEntity<AssetDTO> updateAsset(@Valid @RequestBody AssetDTO assetDTO) throws URISyntaxException {
log.debug("REST request to update Asset : {}", assetDTO);
if (assetDTO.getId() == null) {
throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
}
AssetDTO result = assetService.save(assetDTO);
return ResponseEntity.ok()
.headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, assetDTO.getId().toString()))
.body(result);
}
/**
* GET /assets : get all the assets.
*
* @param pageable the pagination information
* @param criteria the criterias which the requested entities should match
* @return the ResponseEntity with status 200 (OK) and the list of assets in body
*/
@GetMapping("/assets")
public ResponseEntity<List<AssetDTO>> getAllAssets(AssetCriteria criteria, Pageable pageable) {
log.debug("REST request to get Assets by criteria: {}", criteria);
Page<AssetDTO> page = assetQueryService.findByCriteria(criteria, pageable);
HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/assets");
return ResponseEntity.ok().headers(headers).body(page.getContent());
}
/**
* GET /assets/count : count all the assets.
*
* @param criteria the criterias which the requested entities should match
* @return the ResponseEntity with status 200 (OK) and the count in body
*/
@GetMapping("/assets/count")
public ResponseEntity<Long> countAssets(AssetCriteria criteria) {
log.debug("REST request to count Assets by criteria: {}", criteria);
return ResponseEntity.ok().body(assetQueryService.countByCriteria(criteria));
}
/**
* GET /assets/:id : get the "id" asset.
*
* @param id the id of the assetDTO to retrieve
* @return the ResponseEntity with status 200 (OK) and with body the assetDTO, or with status 404 (Not Found)
*/
@GetMapping("/assets/{id}")
public ResponseEntity<AssetDTO> getAsset(@PathVariable Long id) {
log.debug("REST request to get Asset : {}", id);
Optional<AssetDTO> assetDTO = assetService.findOne(id);
return ResponseUtil.wrapOrNotFound(assetDTO);
}
/**
* DELETE /assets/:id : delete the "id" asset.
*
* @param id the id of the assetDTO to delete
* @return the ResponseEntity with status 200 (OK)
*/
@DeleteMapping("/assets/{id}")
public ResponseEntity<Void> deleteAsset(@PathVariable Long id) {
log.debug("REST request to delete Asset : {}", id);
assetService.delete(id);
return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build();
}
}

View File

@ -0,0 +1,138 @@
package org.hostsharing.hsadminng.web.rest;
import org.hostsharing.hsadminng.service.ContactService;
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
import org.hostsharing.hsadminng.web.rest.util.HeaderUtil;
import org.hostsharing.hsadminng.web.rest.util.PaginationUtil;
import org.hostsharing.hsadminng.service.dto.ContactDTO;
import org.hostsharing.hsadminng.service.dto.ContactCriteria;
import org.hostsharing.hsadminng.service.ContactQueryService;
import io.github.jhipster.web.util.ResponseUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Optional;
/**
* REST controller for managing Contact.
*/
@RestController
@RequestMapping("/api")
public class ContactResource {
private final Logger log = LoggerFactory.getLogger(ContactResource.class);
private static final String ENTITY_NAME = "contact";
private final ContactService contactService;
private final ContactQueryService contactQueryService;
public ContactResource(ContactService contactService, ContactQueryService contactQueryService) {
this.contactService = contactService;
this.contactQueryService = contactQueryService;
}
/**
* POST /contacts : Create a new contact.
*
* @param contactDTO the contactDTO to create
* @return the ResponseEntity with status 201 (Created) and with body the new contactDTO, or with status 400 (Bad Request) if the contact has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/contacts")
public ResponseEntity<ContactDTO> createContact(@Valid @RequestBody ContactDTO contactDTO) throws URISyntaxException {
log.debug("REST request to save Contact : {}", contactDTO);
if (contactDTO.getId() != null) {
throw new BadRequestAlertException("A new contact cannot already have an ID", ENTITY_NAME, "idexists");
}
ContactDTO result = contactService.save(contactDTO);
return ResponseEntity.created(new URI("/api/contacts/" + result.getId()))
.headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
.body(result);
}
/**
* PUT /contacts : Updates an existing contact.
*
* @param contactDTO the contactDTO to update
* @return the ResponseEntity with status 200 (OK) and with body the updated contactDTO,
* or with status 400 (Bad Request) if the contactDTO is not valid,
* or with status 500 (Internal Server Error) if the contactDTO couldn't be updated
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PutMapping("/contacts")
public ResponseEntity<ContactDTO> updateContact(@Valid @RequestBody ContactDTO contactDTO) throws URISyntaxException {
log.debug("REST request to update Contact : {}", contactDTO);
if (contactDTO.getId() == null) {
throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
}
ContactDTO result = contactService.save(contactDTO);
return ResponseEntity.ok()
.headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, contactDTO.getId().toString()))
.body(result);
}
/**
* GET /contacts : get all the contacts.
*
* @param pageable the pagination information
* @param criteria the criterias which the requested entities should match
* @return the ResponseEntity with status 200 (OK) and the list of contacts in body
*/
@GetMapping("/contacts")
public ResponseEntity<List<ContactDTO>> getAllContacts(ContactCriteria criteria, Pageable pageable) {
log.debug("REST request to get Contacts by criteria: {}", criteria);
Page<ContactDTO> page = contactQueryService.findByCriteria(criteria, pageable);
HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/contacts");
return ResponseEntity.ok().headers(headers).body(page.getContent());
}
/**
* GET /contacts/count : count all the contacts.
*
* @param criteria the criterias which the requested entities should match
* @return the ResponseEntity with status 200 (OK) and the count in body
*/
@GetMapping("/contacts/count")
public ResponseEntity<Long> countContacts(ContactCriteria criteria) {
log.debug("REST request to count Contacts by criteria: {}", criteria);
return ResponseEntity.ok().body(contactQueryService.countByCriteria(criteria));
}
/**
* GET /contacts/:id : get the "id" contact.
*
* @param id the id of the contactDTO to retrieve
* @return the ResponseEntity with status 200 (OK) and with body the contactDTO, or with status 404 (Not Found)
*/
@GetMapping("/contacts/{id}")
public ResponseEntity<ContactDTO> getContact(@PathVariable Long id) {
log.debug("REST request to get Contact : {}", id);
Optional<ContactDTO> contactDTO = contactService.findOne(id);
return ResponseUtil.wrapOrNotFound(contactDTO);
}
/**
* DELETE /contacts/:id : delete the "id" contact.
*
* @param id the id of the contactDTO to delete
* @return the ResponseEntity with status 200 (OK)
*/
@DeleteMapping("/contacts/{id}")
public ResponseEntity<Void> deleteContact(@PathVariable Long id) {
log.debug("REST request to delete Contact : {}", id);
contactService.delete(id);
return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build();
}
}

View File

@ -0,0 +1,138 @@
package org.hostsharing.hsadminng.web.rest;
import org.hostsharing.hsadminng.service.CustomerContactService;
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
import org.hostsharing.hsadminng.web.rest.util.HeaderUtil;
import org.hostsharing.hsadminng.web.rest.util.PaginationUtil;
import org.hostsharing.hsadminng.service.dto.CustomerContactDTO;
import org.hostsharing.hsadminng.service.dto.CustomerContactCriteria;
import org.hostsharing.hsadminng.service.CustomerContactQueryService;
import io.github.jhipster.web.util.ResponseUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Optional;
/**
* REST controller for managing CustomerContact.
*/
@RestController
@RequestMapping("/api")
public class CustomerContactResource {
private final Logger log = LoggerFactory.getLogger(CustomerContactResource.class);
private static final String ENTITY_NAME = "customerContact";
private final CustomerContactService customerContactService;
private final CustomerContactQueryService customerContactQueryService;
public CustomerContactResource(CustomerContactService customerContactService, CustomerContactQueryService customerContactQueryService) {
this.customerContactService = customerContactService;
this.customerContactQueryService = customerContactQueryService;
}
/**
* POST /customer-contacts : Create a new customerContact.
*
* @param customerContactDTO the customerContactDTO to create
* @return the ResponseEntity with status 201 (Created) and with body the new customerContactDTO, or with status 400 (Bad Request) if the customerContact has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/customer-contacts")
public ResponseEntity<CustomerContactDTO> createCustomerContact(@Valid @RequestBody CustomerContactDTO customerContactDTO) throws URISyntaxException {
log.debug("REST request to save CustomerContact : {}", customerContactDTO);
if (customerContactDTO.getId() != null) {
throw new BadRequestAlertException("A new customerContact cannot already have an ID", ENTITY_NAME, "idexists");
}
CustomerContactDTO result = customerContactService.save(customerContactDTO);
return ResponseEntity.created(new URI("/api/customer-contacts/" + result.getId()))
.headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
.body(result);
}
/**
* PUT /customer-contacts : Updates an existing customerContact.
*
* @param customerContactDTO the customerContactDTO to update
* @return the ResponseEntity with status 200 (OK) and with body the updated customerContactDTO,
* or with status 400 (Bad Request) if the customerContactDTO is not valid,
* or with status 500 (Internal Server Error) if the customerContactDTO couldn't be updated
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PutMapping("/customer-contacts")
public ResponseEntity<CustomerContactDTO> updateCustomerContact(@Valid @RequestBody CustomerContactDTO customerContactDTO) throws URISyntaxException {
log.debug("REST request to update CustomerContact : {}", customerContactDTO);
if (customerContactDTO.getId() == null) {
throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
}
CustomerContactDTO result = customerContactService.save(customerContactDTO);
return ResponseEntity.ok()
.headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, customerContactDTO.getId().toString()))
.body(result);
}
/**
* GET /customer-contacts : get all the customerContacts.
*
* @param pageable the pagination information
* @param criteria the criterias which the requested entities should match
* @return the ResponseEntity with status 200 (OK) and the list of customerContacts in body
*/
@GetMapping("/customer-contacts")
public ResponseEntity<List<CustomerContactDTO>> getAllCustomerContacts(CustomerContactCriteria criteria, Pageable pageable) {
log.debug("REST request to get CustomerContacts by criteria: {}", criteria);
Page<CustomerContactDTO> page = customerContactQueryService.findByCriteria(criteria, pageable);
HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/customer-contacts");
return ResponseEntity.ok().headers(headers).body(page.getContent());
}
/**
* GET /customer-contacts/count : count all the customerContacts.
*
* @param criteria the criterias which the requested entities should match
* @return the ResponseEntity with status 200 (OK) and the count in body
*/
@GetMapping("/customer-contacts/count")
public ResponseEntity<Long> countCustomerContacts(CustomerContactCriteria criteria) {
log.debug("REST request to count CustomerContacts by criteria: {}", criteria);
return ResponseEntity.ok().body(customerContactQueryService.countByCriteria(criteria));
}
/**
* GET /customer-contacts/:id : get the "id" customerContact.
*
* @param id the id of the customerContactDTO to retrieve
* @return the ResponseEntity with status 200 (OK) and with body the customerContactDTO, or with status 404 (Not Found)
*/
@GetMapping("/customer-contacts/{id}")
public ResponseEntity<CustomerContactDTO> getCustomerContact(@PathVariable Long id) {
log.debug("REST request to get CustomerContact : {}", id);
Optional<CustomerContactDTO> customerContactDTO = customerContactService.findOne(id);
return ResponseUtil.wrapOrNotFound(customerContactDTO);
}
/**
* DELETE /customer-contacts/:id : delete the "id" customerContact.
*
* @param id the id of the customerContactDTO to delete
* @return the ResponseEntity with status 200 (OK)
*/
@DeleteMapping("/customer-contacts/{id}")
public ResponseEntity<Void> deleteCustomerContact(@PathVariable Long id) {
log.debug("REST request to delete CustomerContact : {}", id);
customerContactService.delete(id);
return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build();
}
}

View File

@ -0,0 +1,138 @@
package org.hostsharing.hsadminng.web.rest;
import org.hostsharing.hsadminng.service.CustomerService;
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
import org.hostsharing.hsadminng.web.rest.util.HeaderUtil;
import org.hostsharing.hsadminng.web.rest.util.PaginationUtil;
import org.hostsharing.hsadminng.service.dto.CustomerDTO;
import org.hostsharing.hsadminng.service.dto.CustomerCriteria;
import org.hostsharing.hsadminng.service.CustomerQueryService;
import io.github.jhipster.web.util.ResponseUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Optional;
/**
* REST controller for managing Customer.
*/
@RestController
@RequestMapping("/api")
public class CustomerResource {
private final Logger log = LoggerFactory.getLogger(CustomerResource.class);
private static final String ENTITY_NAME = "customer";
private final CustomerService customerService;
private final CustomerQueryService customerQueryService;
public CustomerResource(CustomerService customerService, CustomerQueryService customerQueryService) {
this.customerService = customerService;
this.customerQueryService = customerQueryService;
}
/**
* POST /customers : Create a new customer.
*
* @param customerDTO the customerDTO to create
* @return the ResponseEntity with status 201 (Created) and with body the new customerDTO, or with status 400 (Bad Request) if the customer has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/customers")
public ResponseEntity<CustomerDTO> createCustomer(@Valid @RequestBody CustomerDTO customerDTO) throws URISyntaxException {
log.debug("REST request to save Customer : {}", customerDTO);
if (customerDTO.getId() != null) {
throw new BadRequestAlertException("A new customer cannot already have an ID", ENTITY_NAME, "idexists");
}
CustomerDTO result = customerService.save(customerDTO);
return ResponseEntity.created(new URI("/api/customers/" + result.getId()))
.headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
.body(result);
}
/**
* PUT /customers : Updates an existing customer.
*
* @param customerDTO the customerDTO to update
* @return the ResponseEntity with status 200 (OK) and with body the updated customerDTO,
* or with status 400 (Bad Request) if the customerDTO is not valid,
* or with status 500 (Internal Server Error) if the customerDTO couldn't be updated
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PutMapping("/customers")
public ResponseEntity<CustomerDTO> updateCustomer(@Valid @RequestBody CustomerDTO customerDTO) throws URISyntaxException {
log.debug("REST request to update Customer : {}", customerDTO);
if (customerDTO.getId() == null) {
throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
}
CustomerDTO result = customerService.save(customerDTO);
return ResponseEntity.ok()
.headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, customerDTO.getId().toString()))
.body(result);
}
/**
* GET /customers : get all the customers.
*
* @param pageable the pagination information
* @param criteria the criterias which the requested entities should match
* @return the ResponseEntity with status 200 (OK) and the list of customers in body
*/
@GetMapping("/customers")
public ResponseEntity<List<CustomerDTO>> getAllCustomers(CustomerCriteria criteria, Pageable pageable) {
log.debug("REST request to get Customers by criteria: {}", criteria);
Page<CustomerDTO> page = customerQueryService.findByCriteria(criteria, pageable);
HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/customers");
return ResponseEntity.ok().headers(headers).body(page.getContent());
}
/**
* GET /customers/count : count all the customers.
*
* @param criteria the criterias which the requested entities should match
* @return the ResponseEntity with status 200 (OK) and the count in body
*/
@GetMapping("/customers/count")
public ResponseEntity<Long> countCustomers(CustomerCriteria criteria) {
log.debug("REST request to count Customers by criteria: {}", criteria);
return ResponseEntity.ok().body(customerQueryService.countByCriteria(criteria));
}
/**
* GET /customers/:id : get the "id" customer.
*
* @param id the id of the customerDTO to retrieve
* @return the ResponseEntity with status 200 (OK) and with body the customerDTO, or with status 404 (Not Found)
*/
@GetMapping("/customers/{id}")
public ResponseEntity<CustomerDTO> getCustomer(@PathVariable Long id) {
log.debug("REST request to get Customer : {}", id);
Optional<CustomerDTO> customerDTO = customerService.findOne(id);
return ResponseUtil.wrapOrNotFound(customerDTO);
}
/**
* DELETE /customers/:id : delete the "id" customer.
*
* @param id the id of the customerDTO to delete
* @return the ResponseEntity with status 200 (OK)
*/
@DeleteMapping("/customers/{id}")
public ResponseEntity<Void> deleteCustomer(@PathVariable Long id) {
log.debug("REST request to delete Customer : {}", id);
customerService.delete(id);
return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build();
}
}

View File

@ -0,0 +1,138 @@
package org.hostsharing.hsadminng.web.rest;
import org.hostsharing.hsadminng.service.MembershipService;
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
import org.hostsharing.hsadminng.web.rest.util.HeaderUtil;
import org.hostsharing.hsadminng.web.rest.util.PaginationUtil;
import org.hostsharing.hsadminng.service.dto.MembershipDTO;
import org.hostsharing.hsadminng.service.dto.MembershipCriteria;
import org.hostsharing.hsadminng.service.MembershipQueryService;
import io.github.jhipster.web.util.ResponseUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Optional;
/**
* REST controller for managing Membership.
*/
@RestController
@RequestMapping("/api")
public class MembershipResource {
private final Logger log = LoggerFactory.getLogger(MembershipResource.class);
private static final String ENTITY_NAME = "membership";
private final MembershipService membershipService;
private final MembershipQueryService membershipQueryService;
public MembershipResource(MembershipService membershipService, MembershipQueryService membershipQueryService) {
this.membershipService = membershipService;
this.membershipQueryService = membershipQueryService;
}
/**
* POST /memberships : Create a new membership.
*
* @param membershipDTO the membershipDTO to create
* @return the ResponseEntity with status 201 (Created) and with body the new membershipDTO, or with status 400 (Bad Request) if the membership has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/memberships")
public ResponseEntity<MembershipDTO> createMembership(@Valid @RequestBody MembershipDTO membershipDTO) throws URISyntaxException {
log.debug("REST request to save Membership : {}", membershipDTO);
if (membershipDTO.getId() != null) {
throw new BadRequestAlertException("A new membership cannot already have an ID", ENTITY_NAME, "idexists");
}
MembershipDTO result = membershipService.save(membershipDTO);
return ResponseEntity.created(new URI("/api/memberships/" + result.getId()))
.headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
.body(result);
}
/**
* PUT /memberships : Updates an existing membership.
*
* @param membershipDTO the membershipDTO to update
* @return the ResponseEntity with status 200 (OK) and with body the updated membershipDTO,
* or with status 400 (Bad Request) if the membershipDTO is not valid,
* or with status 500 (Internal Server Error) if the membershipDTO couldn't be updated
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PutMapping("/memberships")
public ResponseEntity<MembershipDTO> updateMembership(@Valid @RequestBody MembershipDTO membershipDTO) throws URISyntaxException {
log.debug("REST request to update Membership : {}", membershipDTO);
if (membershipDTO.getId() == null) {
throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
}
MembershipDTO result = membershipService.save(membershipDTO);
return ResponseEntity.ok()
.headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, membershipDTO.getId().toString()))
.body(result);
}
/**
* GET /memberships : get all the memberships.
*
* @param pageable the pagination information
* @param criteria the criterias which the requested entities should match
* @return the ResponseEntity with status 200 (OK) and the list of memberships in body
*/
@GetMapping("/memberships")
public ResponseEntity<List<MembershipDTO>> getAllMemberships(MembershipCriteria criteria, Pageable pageable) {
log.debug("REST request to get Memberships by criteria: {}", criteria);
Page<MembershipDTO> page = membershipQueryService.findByCriteria(criteria, pageable);
HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/memberships");
return ResponseEntity.ok().headers(headers).body(page.getContent());
}
/**
* GET /memberships/count : count all the memberships.
*
* @param criteria the criterias which the requested entities should match
* @return the ResponseEntity with status 200 (OK) and the count in body
*/
@GetMapping("/memberships/count")
public ResponseEntity<Long> countMemberships(MembershipCriteria criteria) {
log.debug("REST request to count Memberships by criteria: {}", criteria);
return ResponseEntity.ok().body(membershipQueryService.countByCriteria(criteria));
}
/**
* GET /memberships/:id : get the "id" membership.
*
* @param id the id of the membershipDTO to retrieve
* @return the ResponseEntity with status 200 (OK) and with body the membershipDTO, or with status 404 (Not Found)
*/
@GetMapping("/memberships/{id}")
public ResponseEntity<MembershipDTO> getMembership(@PathVariable Long id) {
log.debug("REST request to get Membership : {}", id);
Optional<MembershipDTO> membershipDTO = membershipService.findOne(id);
return ResponseUtil.wrapOrNotFound(membershipDTO);
}
/**
* DELETE /memberships/:id : delete the "id" membership.
*
* @param id the id of the membershipDTO to delete
* @return the ResponseEntity with status 200 (OK)
*/
@DeleteMapping("/memberships/{id}")
public ResponseEntity<Void> deleteMembership(@PathVariable Long id) {
log.debug("REST request to delete Membership : {}", id);
membershipService.delete(id);
return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build();
}
}

View File

@ -0,0 +1,138 @@
package org.hostsharing.hsadminng.web.rest;
import org.hostsharing.hsadminng.service.ShareService;
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
import org.hostsharing.hsadminng.web.rest.util.HeaderUtil;
import org.hostsharing.hsadminng.web.rest.util.PaginationUtil;
import org.hostsharing.hsadminng.service.dto.ShareDTO;
import org.hostsharing.hsadminng.service.dto.ShareCriteria;
import org.hostsharing.hsadminng.service.ShareQueryService;
import io.github.jhipster.web.util.ResponseUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Optional;
/**
* REST controller for managing Share.
*/
@RestController
@RequestMapping("/api")
public class ShareResource {
private final Logger log = LoggerFactory.getLogger(ShareResource.class);
private static final String ENTITY_NAME = "share";
private final ShareService shareService;
private final ShareQueryService shareQueryService;
public ShareResource(ShareService shareService, ShareQueryService shareQueryService) {
this.shareService = shareService;
this.shareQueryService = shareQueryService;
}
/**
* POST /shares : Create a new share.
*
* @param shareDTO the shareDTO to create
* @return the ResponseEntity with status 201 (Created) and with body the new shareDTO, or with status 400 (Bad Request) if the share has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/shares")
public ResponseEntity<ShareDTO> createShare(@Valid @RequestBody ShareDTO shareDTO) throws URISyntaxException {
log.debug("REST request to save Share : {}", shareDTO);
if (shareDTO.getId() != null) {
throw new BadRequestAlertException("A new share cannot already have an ID", ENTITY_NAME, "idexists");
}
ShareDTO result = shareService.save(shareDTO);
return ResponseEntity.created(new URI("/api/shares/" + result.getId()))
.headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
.body(result);
}
/**
* PUT /shares : Updates an existing share.
*
* @param shareDTO the shareDTO to update
* @return the ResponseEntity with status 200 (OK) and with body the updated shareDTO,
* or with status 400 (Bad Request) if the shareDTO is not valid,
* or with status 500 (Internal Server Error) if the shareDTO couldn't be updated
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PutMapping("/shares")
public ResponseEntity<ShareDTO> updateShare(@Valid @RequestBody ShareDTO shareDTO) throws URISyntaxException {
log.debug("REST request to update Share : {}", shareDTO);
if (shareDTO.getId() == null) {
throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
}
ShareDTO result = shareService.save(shareDTO);
return ResponseEntity.ok()
.headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, shareDTO.getId().toString()))
.body(result);
}
/**
* GET /shares : get all the shares.
*
* @param pageable the pagination information
* @param criteria the criterias which the requested entities should match
* @return the ResponseEntity with status 200 (OK) and the list of shares in body
*/
@GetMapping("/shares")
public ResponseEntity<List<ShareDTO>> getAllShares(ShareCriteria criteria, Pageable pageable) {
log.debug("REST request to get Shares by criteria: {}", criteria);
Page<ShareDTO> page = shareQueryService.findByCriteria(criteria, pageable);
HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/shares");
return ResponseEntity.ok().headers(headers).body(page.getContent());
}
/**
* GET /shares/count : count all the shares.
*
* @param criteria the criterias which the requested entities should match
* @return the ResponseEntity with status 200 (OK) and the count in body
*/
@GetMapping("/shares/count")
public ResponseEntity<Long> countShares(ShareCriteria criteria) {
log.debug("REST request to count Shares by criteria: {}", criteria);
return ResponseEntity.ok().body(shareQueryService.countByCriteria(criteria));
}
/**
* GET /shares/:id : get the "id" share.
*
* @param id the id of the shareDTO to retrieve
* @return the ResponseEntity with status 200 (OK) and with body the shareDTO, or with status 404 (Not Found)
*/
@GetMapping("/shares/{id}")
public ResponseEntity<ShareDTO> getShare(@PathVariable Long id) {
log.debug("REST request to get Share : {}", id);
Optional<ShareDTO> shareDTO = shareService.findOne(id);
return ResponseUtil.wrapOrNotFound(shareDTO);
}
/**
* DELETE /shares/:id : delete the "id" share.
*
* @param id the id of the shareDTO to delete
* @return the ResponseEntity with status 200 (OK)
*/
@DeleteMapping("/shares/{id}")
public ResponseEntity<Void> deleteShare(@PathVariable Long id) {
log.debug("REST request to delete Share : {}", id);
shareService.delete(id);
return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build();
}
}

71
src/main/jdl/customer.jdl Normal file
View File

@ -0,0 +1,71 @@
filter all
dto all with mapstruct
service all with serviceClass
paginate all with infinite-scroll
entity Customer {
number Integer required unique min(10000) max(99999),
prefix String required unique pattern(/[a-z][a-z0-9]+/),
}
entity Contact {
firstName String required maxlength(80),
lastName String required maxlength(80),
email String required maxlength(80)
}
enum CustomerContactRole {
CONTRACTUAL,
TECHNICAL,
FINANCIAL
}
entity CustomerContact {
role CustomerContactRole required
}
entity Membership {
sinceDate LocalDate required,
untilDate LocalDate
}
enum ShareAction {
SUBSCRIPTION,
CANCELLATION
}
entity Share {
date LocalDate required,
action ShareAction required,
quantity Integer required,
comment String maxlength(160)
}
enum AssetAction {
PAYMENT,
HANDOVER,
ADOPTION,
LOSS,
CLEARING,
PAYBACK
}
entity Asset {
date LocalDate required,
action AssetAction required,
amount BigDecimal required,
comment String maxlength(160)
}
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}
}

View File

@ -0,0 +1,37 @@
<?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">
<property name="now" value="now()" dbms="h2"/>
<property name="now" value="current_timestamp" dbms="postgresql"/>
<property name="floatType" value="float4" dbms="postgresql, h2"/>
<property name="floatType" value="float" dbms="mysql, oracle, mssql"/>
<!--
Added the entity Customer.
-->
<changeSet id="20190403083735-1" author="jhipster">
<createTable tableName="customer">
<column name="id" type="bigint" autoIncrement="${autoIncrement}">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="jhi_number" type="integer">
<constraints nullable="false" unique="true" uniqueConstraintName="ux_customer_jhi_number" />
</column>
<column name="prefix" type="varchar(255)">
<constraints nullable="false" unique="true" uniqueConstraintName="ux_customer_prefix" />
</column>
<!-- jhipster-needle-liquibase-add-column - JHipster will add columns here, do not remove-->
</createTable>
</changeSet>
<!-- jhipster-needle-liquibase-add-changeset - JHipster will add changesets here, do not remove-->
</databaseChangeLog>

View File

@ -0,0 +1,41 @@
<?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">
<property name="now" value="now()" dbms="h2"/>
<property name="now" value="current_timestamp" dbms="postgresql"/>
<property name="floatType" value="float4" dbms="postgresql, h2"/>
<property name="floatType" value="float" dbms="mysql, oracle, mssql"/>
<!--
Added the entity Contact.
-->
<changeSet id="20190403083736-1" author="jhipster">
<createTable tableName="contact">
<column name="id" type="bigint" autoIncrement="${autoIncrement}">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="first_name" type="varchar(80)">
<constraints nullable="false" />
</column>
<column name="last_name" type="varchar(80)">
<constraints nullable="false" />
</column>
<column name="email" type="varchar(80)">
<constraints nullable="false" />
</column>
<!-- jhipster-needle-liquibase-add-column - JHipster will add columns here, do not remove-->
</createTable>
</changeSet>
<!-- jhipster-needle-liquibase-add-changeset - JHipster will add changesets here, do not remove-->
</databaseChangeLog>

View File

@ -0,0 +1,41 @@
<?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">
<property name="now" value="now()" dbms="h2"/>
<property name="now" value="current_timestamp" dbms="postgresql"/>
<property name="floatType" value="float4" dbms="postgresql, h2"/>
<property name="floatType" value="float" dbms="mysql, oracle, mssql"/>
<!--
Added the entity CustomerContact.
-->
<changeSet id="20190403083737-1" author="jhipster">
<createTable tableName="customer_contact">
<column name="id" type="bigint" autoIncrement="${autoIncrement}">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="jhi_role" type="varchar(255)">
<constraints nullable="false" />
</column>
<column name="contact_id" type="bigint">
<constraints nullable="false" />
</column>
<column name="customer_id" type="bigint">
<constraints nullable="false" />
</column>
<!-- jhipster-needle-liquibase-add-column - JHipster will add columns here, do not remove-->
</createTable>
</changeSet>
<!-- jhipster-needle-liquibase-add-changeset - JHipster will add changesets here, do not remove-->
</databaseChangeLog>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
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">
<!--
Added the constraints for entity CustomerContact.
-->
<changeSet id="20190403083737-2" author="jhipster">
<addForeignKeyConstraint baseColumnNames="contact_id"
baseTableName="customer_contact"
constraintName="fk_customer_contact_contact_id"
referencedColumnNames="id"
referencedTableName="contact"/>
<addForeignKeyConstraint baseColumnNames="customer_id"
baseTableName="customer_contact"
constraintName="fk_customer_contact_customer_id"
referencedColumnNames="id"
referencedTableName="customer"/>
</changeSet>
</databaseChangeLog>

View File

@ -0,0 +1,41 @@
<?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">
<property name="now" value="now()" dbms="h2"/>
<property name="now" value="current_timestamp" dbms="postgresql"/>
<property name="floatType" value="float4" dbms="postgresql, h2"/>
<property name="floatType" value="float" dbms="mysql, oracle, mssql"/>
<!--
Added the entity Membership.
-->
<changeSet id="20190403083738-1" author="jhipster">
<createTable tableName="membership">
<column name="id" type="bigint" autoIncrement="${autoIncrement}">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="since_date" type="date">
<constraints nullable="false" />
</column>
<column name="until_date" type="date">
<constraints nullable="true" />
</column>
<column name="customer_id" type="bigint">
<constraints nullable="true" />
</column>
<!-- jhipster-needle-liquibase-add-column - JHipster will add columns here, do not remove-->
</createTable>
</changeSet>
<!-- jhipster-needle-liquibase-add-changeset - JHipster will add changesets here, do not remove-->
</databaseChangeLog>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
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">
<!--
Added the constraints for entity Membership.
-->
<changeSet id="20190403083738-2" author="jhipster">
<addForeignKeyConstraint baseColumnNames="customer_id"
baseTableName="membership"
constraintName="fk_membership_customer_id"
referencedColumnNames="id"
referencedTableName="customer"/>
</changeSet>
</databaseChangeLog>

View File

@ -0,0 +1,49 @@
<?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">
<property name="now" value="now()" dbms="h2"/>
<property name="now" value="current_timestamp" dbms="postgresql"/>
<property name="floatType" value="float4" dbms="postgresql, h2"/>
<property name="floatType" value="float" dbms="mysql, oracle, mssql"/>
<!--
Added the entity Share.
-->
<changeSet id="20190403083739-1" author="jhipster">
<createTable tableName="share">
<column name="id" type="bigint" autoIncrement="${autoIncrement}">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="jhi_date" type="date">
<constraints nullable="false" />
</column>
<column name="action" type="varchar(255)">
<constraints nullable="false" />
</column>
<column name="quantity" type="integer">
<constraints nullable="false" />
</column>
<column name="jhi_comment" type="varchar(160)">
<constraints nullable="true" />
</column>
<column name="member_id" type="bigint">
<constraints nullable="true" />
</column>
<!-- jhipster-needle-liquibase-add-column - JHipster will add columns here, do not remove-->
</createTable>
</changeSet>
<!-- jhipster-needle-liquibase-add-changeset - JHipster will add changesets here, do not remove-->
</databaseChangeLog>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
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">
<!--
Added the constraints for entity Share.
-->
<changeSet id="20190403083739-2" author="jhipster">
<addForeignKeyConstraint baseColumnNames="member_id"
baseTableName="share"
constraintName="fk_share_member_id"
referencedColumnNames="id"
referencedTableName="membership"/>
</changeSet>
</databaseChangeLog>

View File

@ -0,0 +1,49 @@
<?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">
<property name="now" value="now()" dbms="h2"/>
<property name="now" value="current_timestamp" dbms="postgresql"/>
<property name="floatType" value="float4" dbms="postgresql, h2"/>
<property name="floatType" value="float" dbms="mysql, oracle, mssql"/>
<!--
Added the entity Asset.
-->
<changeSet id="20190403083740-1" author="jhipster">
<createTable tableName="asset">
<column name="id" type="bigint" autoIncrement="${autoIncrement}">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="jhi_date" type="date">
<constraints nullable="false" />
</column>
<column name="action" type="varchar(255)">
<constraints nullable="false" />
</column>
<column name="amount" type="decimal(10,2)">
<constraints nullable="false" />
</column>
<column name="jhi_comment" type="varchar(160)">
<constraints nullable="true" />
</column>
<column name="member_id" type="bigint">
<constraints nullable="true" />
</column>
<!-- jhipster-needle-liquibase-add-column - JHipster will add columns here, do not remove-->
</createTable>
</changeSet>
<!-- jhipster-needle-liquibase-add-changeset - JHipster will add changesets here, do not remove-->
</databaseChangeLog>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
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">
<!--
Added the constraints for entity Asset.
-->
<changeSet id="20190403083740-2" author="jhipster">
<addForeignKeyConstraint baseColumnNames="member_id"
baseTableName="asset"
constraintName="fk_asset_member_id"
referencedColumnNames="id"
referencedTableName="membership"/>
</changeSet>
</databaseChangeLog>

View File

@ -5,6 +5,16 @@
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
<include file="config/liquibase/changelog/00000000000000_initial_schema.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20190403083735_added_entity_Customer.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20190403083736_added_entity_Contact.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20190403083737_added_entity_CustomerContact.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20190403083738_added_entity_Membership.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20190403083739_added_entity_Share.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20190403083740_added_entity_Asset.xml" relativeToChangelogFile="false"/>
<!-- jhipster-needle-liquibase-add-changelog - JHipster will add liquibase changelogs here -->
<include file="config/liquibase/changelog/20190403083737_added_entity_constraints_CustomerContact.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20190403083738_added_entity_constraints_Membership.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20190403083739_added_entity_constraints_Share.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20190403083740_added_entity_constraints_Asset.xml" relativeToChangelogFile="false"/>
<!-- jhipster-needle-liquibase-add-constraints-changelog - JHipster will add liquibase constraints changelogs here -->
</databaseChangeLog>

View File

@ -0,0 +1,19 @@
<form name="deleteForm" (ngSubmit)="confirmDelete(asset.id)">
<div class="modal-header">
<h4 class="modal-title" jhiTranslate="entity.delete.title">Confirm delete operation</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"
(click)="clear()">&times;</button>
</div>
<div class="modal-body">
<jhi-alert-error></jhi-alert-error>
<p id="jhi-delete-asset-heading" jhiTranslate="hsadminNgApp.asset.delete.question" [translateValues]="{id: asset.id}">Are you sure you want to delete this Asset?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal" (click)="clear()">
<fa-icon [icon]="'ban'"></fa-icon>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span>
</button>
<button id="jhi-confirm-delete-asset" type="submit" class="btn btn-danger">
<fa-icon [icon]="'times'"></fa-icon>&nbsp;<span jhiTranslate="entity.action.delete">Delete</span>
</button>
</div>
</form>

View File

@ -0,0 +1,65 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { NgbActiveModal, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
import { JhiEventManager } from 'ng-jhipster';
import { IAsset } from 'app/shared/model/asset.model';
import { AssetService } from './asset.service';
@Component({
selector: 'jhi-asset-delete-dialog',
templateUrl: './asset-delete-dialog.component.html'
})
export class AssetDeleteDialogComponent {
asset: IAsset;
constructor(protected assetService: AssetService, public activeModal: NgbActiveModal, protected eventManager: JhiEventManager) {}
clear() {
this.activeModal.dismiss('cancel');
}
confirmDelete(id: number) {
this.assetService.delete(id).subscribe(response => {
this.eventManager.broadcast({
name: 'assetListModification',
content: 'Deleted an asset'
});
this.activeModal.dismiss(true);
});
}
}
@Component({
selector: 'jhi-asset-delete-popup',
template: ''
})
export class AssetDeletePopupComponent implements OnInit, OnDestroy {
protected ngbModalRef: NgbModalRef;
constructor(protected activatedRoute: ActivatedRoute, protected router: Router, protected modalService: NgbModal) {}
ngOnInit() {
this.activatedRoute.data.subscribe(({ asset }) => {
setTimeout(() => {
this.ngbModalRef = this.modalService.open(AssetDeleteDialogComponent as Component, { size: 'lg', backdrop: 'static' });
this.ngbModalRef.componentInstance.asset = asset;
this.ngbModalRef.result.then(
result => {
this.router.navigate(['/asset', { outlets: { popup: null } }]);
this.ngbModalRef = null;
},
reason => {
this.router.navigate(['/asset', { outlets: { popup: null } }]);
this.ngbModalRef = null;
}
);
}, 0);
});
}
ngOnDestroy() {
this.ngbModalRef = null;
}
}

View File

@ -0,0 +1,45 @@
<div class="row justify-content-center">
<div class="col-8">
<div *ngIf="asset">
<h2><span jhiTranslate="hsadminNgApp.asset.detail.title">Asset</span> {{asset.id}}</h2>
<hr>
<jhi-alert-error></jhi-alert-error>
<dl class="row-md jh-entity-details">
<dt><span jhiTranslate="hsadminNgApp.asset.date">Date</span></dt>
<dd>
<span>{{asset.date}}</span>
</dd>
<dt><span jhiTranslate="hsadminNgApp.asset.action">Action</span></dt>
<dd>
<span jhiTranslate="{{'hsadminNgApp.AssetAction.' + asset.action}}">{{asset.action}}</span>
</dd>
<dt><span jhiTranslate="hsadminNgApp.asset.amount">Amount</span></dt>
<dd>
<span>{{asset.amount}}</span>
</dd>
<dt><span jhiTranslate="hsadminNgApp.asset.comment">Comment</span></dt>
<dd>
<span>{{asset.comment}}</span>
</dd>
<dt><span jhiTranslate="hsadminNgApp.asset.member">Member</span></dt>
<dd>
<div *ngIf="asset.memberId">
<a [routerLink]="['/membership', asset.memberId, 'view']">{{asset.memberId}}</a>
</div>
</dd>
</dl>
<button type="submit"
(click)="previousState()"
class="btn btn-info">
<fa-icon [icon]="'arrow-left'"></fa-icon>&nbsp;<span jhiTranslate="entity.action.back"> Back</span>
</button>
<button type="button"
[routerLink]="['/asset', asset.id, 'edit']"
class="btn btn-primary">
<fa-icon [icon]="'pencil-alt'"></fa-icon>&nbsp;<span jhiTranslate="entity.action.edit"> Edit</span>
</button>
</div>
</div>
</div>

View File

@ -0,0 +1,24 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { IAsset } from 'app/shared/model/asset.model';
@Component({
selector: 'jhi-asset-detail',
templateUrl: './asset-detail.component.html'
})
export class AssetDetailComponent implements OnInit {
asset: IAsset;
constructor(protected activatedRoute: ActivatedRoute) {}
ngOnInit() {
this.activatedRoute.data.subscribe(({ asset }) => {
this.asset = asset;
});
}
previousState() {
window.history.back();
}
}

View File

@ -0,0 +1,90 @@
<div class="row justify-content-center">
<div class="col-8">
<form name="editForm" role="form" novalidate (ngSubmit)="save()" #editForm="ngForm">
<h2 id="jhi-asset-heading" jhiTranslate="hsadminNgApp.asset.home.createOrEditLabel">Create or edit a Asset</h2>
<div>
<jhi-alert-error></jhi-alert-error>
<div class="form-group" [hidden]="!asset.id">
<label for="id" jhiTranslate="global.field.id">ID</label>
<input type="text" class="form-control" id="id" name="id"
[(ngModel)]="asset.id" readonly />
</div>
<div class="form-group">
<label class="form-control-label" jhiTranslate="hsadminNgApp.asset.date" for="field_date">Date</label>
<div class="input-group">
<input id="field_date" type="text" class="form-control" name="date" ngbDatepicker #dateDp="ngbDatepicker" [(ngModel)]="asset.date"
required/>
<span class="input-group-append">
<button type="button" class="btn btn-secondary" (click)="dateDp.toggle()"><fa-icon [icon]="'calendar-alt'"></fa-icon></button>
</span>
</div>
<div [hidden]="!(editForm.controls.date?.dirty && editForm.controls.date?.invalid)">
<small class="form-text text-danger"
[hidden]="!editForm.controls.date?.errors?.required" jhiTranslate="entity.validation.required">
This field is required.
</small>
</div>
</div>
<div class="form-group">
<label class="form-control-label" jhiTranslate="hsadminNgApp.asset.action" for="field_action">Action</label>
<select class="form-control" name="action" [(ngModel)]="asset.action" id="field_action" required>
<option value="PAYMENT">{{'hsadminNgApp.AssetAction.PAYMENT' | translate}}</option>
<option value="HANDOVER">{{'hsadminNgApp.AssetAction.HANDOVER' | translate}}</option>
<option value="ADOPTION">{{'hsadminNgApp.AssetAction.ADOPTION' | translate}}</option>
<option value="LOSS">{{'hsadminNgApp.AssetAction.LOSS' | translate}}</option>
<option value="CLEARING">{{'hsadminNgApp.AssetAction.CLEARING' | translate}}</option>
<option value="PAYBACK">{{'hsadminNgApp.AssetAction.PAYBACK' | translate}}</option>
</select>
<div [hidden]="!(editForm.controls.action?.dirty && editForm.controls.action?.invalid)">
<small class="form-text text-danger"
[hidden]="!editForm.controls.action?.errors?.required" jhiTranslate="entity.validation.required">
This field is required.
</small>
</div>
</div>
<div class="form-group">
<label class="form-control-label" jhiTranslate="hsadminNgApp.asset.amount" for="field_amount">Amount</label>
<input type="number" class="form-control" name="amount" id="field_amount"
[(ngModel)]="asset.amount" required/>
<div [hidden]="!(editForm.controls.amount?.dirty && editForm.controls.amount?.invalid)">
<small class="form-text text-danger"
[hidden]="!editForm.controls.amount?.errors?.required" jhiTranslate="entity.validation.required">
This field is required.
</small>
<small class="form-text text-danger"
[hidden]="!editForm.controls.amount?.errors?.number" jhiTranslate="entity.validation.number">
This field should be a number.
</small>
</div>
</div>
<div class="form-group">
<label class="form-control-label" jhiTranslate="hsadminNgApp.asset.comment" for="field_comment">Comment</label>
<input type="text" class="form-control" name="comment" id="field_comment"
[(ngModel)]="asset.comment" maxlength="160"/>
<div [hidden]="!(editForm.controls.comment?.dirty && editForm.controls.comment?.invalid)">
<small class="form-text text-danger"
[hidden]="!editForm.controls.comment?.errors?.maxlength" jhiTranslate="entity.validation.maxlength" [translateValues]="{ max: 160 }">
This field cannot be longer than 160 characters.
</small>
</div>
</div>
<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>
<option [ngValue]="membershipOption.id" *ngFor="let membershipOption of memberships; trackBy: trackMembershipById">{{membershipOption.id}}</option>
</select>
</div>
</div>
<div>
<button type="button" id="cancel-save" class="btn btn-secondary" (click)="previousState()">
<fa-icon [icon]="'ban'"></fa-icon>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span>
</button>
<button type="submit" id="save-entity" [disabled]="editForm.form.invalid || isSaving" class="btn btn-primary">
<fa-icon [icon]="'save'"></fa-icon>&nbsp;<span jhiTranslate="entity.action.save">Save</span>
</button>
</div>
</form>
</div>
</div>

View File

@ -0,0 +1,78 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { HttpResponse, HttpErrorResponse } from '@angular/common/http';
import { Observable } from 'rxjs';
import { filter, map } from 'rxjs/operators';
import * as moment from 'moment';
import { JhiAlertService } from 'ng-jhipster';
import { IAsset } from 'app/shared/model/asset.model';
import { AssetService } from './asset.service';
import { IMembership } from 'app/shared/model/membership.model';
import { MembershipService } from 'app/entities/membership';
@Component({
selector: 'jhi-asset-update',
templateUrl: './asset-update.component.html'
})
export class AssetUpdateComponent implements OnInit {
asset: IAsset;
isSaving: boolean;
memberships: IMembership[];
dateDp: any;
constructor(
protected jhiAlertService: JhiAlertService,
protected assetService: AssetService,
protected membershipService: MembershipService,
protected activatedRoute: ActivatedRoute
) {}
ngOnInit() {
this.isSaving = false;
this.activatedRoute.data.subscribe(({ asset }) => {
this.asset = asset;
});
this.membershipService
.query()
.pipe(
filter((mayBeOk: HttpResponse<IMembership[]>) => mayBeOk.ok),
map((response: HttpResponse<IMembership[]>) => response.body)
)
.subscribe((res: IMembership[]) => (this.memberships = res), (res: HttpErrorResponse) => this.onError(res.message));
}
previousState() {
window.history.back();
}
save() {
this.isSaving = true;
if (this.asset.id !== undefined) {
this.subscribeToSaveResponse(this.assetService.update(this.asset));
} else {
this.subscribeToSaveResponse(this.assetService.create(this.asset));
}
}
protected subscribeToSaveResponse(result: Observable<HttpResponse<IAsset>>) {
result.subscribe((res: HttpResponse<IAsset>) => this.onSaveSuccess(), (res: HttpErrorResponse) => this.onSaveError());
}
protected onSaveSuccess() {
this.isSaving = false;
this.previousState();
}
protected onSaveError() {
this.isSaving = false;
}
protected onError(errorMessage: string) {
this.jhiAlertService.error(errorMessage, null, null);
}
trackMembershipById(index: number, item: IMembership) {
return item.id;
}
}

View File

@ -0,0 +1,66 @@
<div>
<h2 id="page-heading">
<span jhiTranslate="hsadminNgApp.asset.home.title">Assets</span>
<button id="jh-create-entity" class="btn btn-primary float-right jh-create-entity create-asset" [routerLink]="['/asset/new']">
<fa-icon [icon]="'plus'"></fa-icon>
<span jhiTranslate="hsadminNgApp.asset.home.createLabel">
Create new Asset
</span>
</button>
</h2>
<jhi-alert></jhi-alert>
<br/>
<div class="table-responsive" *ngIf="assets">
<table class="table table-striped">
<thead>
<tr jhiSort [(predicate)]="predicate" [(ascending)]="reverse" [callback]="reset.bind(this)">
<th jhiSortBy="id"><span jhiTranslate="global.field.id">ID</span> <fa-icon [icon]="'sort'"></fa-icon></th>
<th jhiSortBy="date"><span jhiTranslate="hsadminNgApp.asset.date">Date</span> <fa-icon [icon]="'sort'"></fa-icon></th>
<th jhiSortBy="action"><span jhiTranslate="hsadminNgApp.asset.action">Action</span> <fa-icon [icon]="'sort'"></fa-icon></th>
<th jhiSortBy="amount"><span jhiTranslate="hsadminNgApp.asset.amount">Amount</span> <fa-icon [icon]="'sort'"></fa-icon></th>
<th jhiSortBy="comment"><span jhiTranslate="hsadminNgApp.asset.comment">Comment</span> <fa-icon [icon]="'sort'"></fa-icon></th>
<th jhiSortBy="memberId"><span jhiTranslate="hsadminNgApp.asset.member">Member</span> <fa-icon [icon]="'sort'"></fa-icon></th>
<th></th>
</tr>
</thead>
<tbody infinite-scroll (scrolled)="loadPage(page + 1)" [infiniteScrollDisabled]="page >= links['last']" [infiniteScrollDistance]="0">
<tr *ngFor="let asset of assets ;trackBy: trackId">
<td><a [routerLink]="['/asset', asset.id, 'view' ]">{{asset.id}}</a></td>
<td>{{asset.date | date:'mediumDate'}}</td>
<td jhiTranslate="{{'hsadminNgApp.AssetAction.' + asset.action}}">{{asset.action}}</td>
<td>{{asset.amount}}</td>
<td>{{asset.comment}}</td>
<td>
<div *ngIf="asset.memberId">
<a [routerLink]="['../membership', asset.memberId , 'view' ]" >{{asset.memberId}}</a>
</div>
</td>
<td class="text-right">
<div class="btn-group flex-btn-group-container">
<button type="submit"
[routerLink]="['/asset', asset.id, 'view' ]"
class="btn btn-info btn-sm">
<fa-icon [icon]="'eye'"></fa-icon>
<span class="d-none d-md-inline" jhiTranslate="entity.action.view">View</span>
</button>
<button type="submit"
[routerLink]="['/asset', asset.id, 'edit']"
class="btn btn-primary btn-sm">
<fa-icon [icon]="'pencil-alt'"></fa-icon>
<span class="d-none d-md-inline" jhiTranslate="entity.action.edit">Edit</span>
</button>
<button type="submit"
[routerLink]="['/', 'asset', { outlets: { popup: asset.id + '/delete'} }]"
replaceUrl="true"
queryParamsHandling="merge"
class="btn btn-danger btn-sm">
<fa-icon [icon]="'times'"></fa-icon>
<span class="d-none d-md-inline" jhiTranslate="entity.action.delete">Delete</span>
</button>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>

View File

@ -0,0 +1,108 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { HttpErrorResponse, HttpHeaders, HttpResponse } from '@angular/common/http';
import { Subscription } from 'rxjs';
import { filter, map } from 'rxjs/operators';
import { JhiEventManager, JhiParseLinks, JhiAlertService } from 'ng-jhipster';
import { IAsset } from 'app/shared/model/asset.model';
import { AccountService } from 'app/core';
import { ITEMS_PER_PAGE } from 'app/shared';
import { AssetService } from './asset.service';
@Component({
selector: 'jhi-asset',
templateUrl: './asset.component.html'
})
export class AssetComponent implements OnInit, OnDestroy {
assets: IAsset[];
currentAccount: any;
eventSubscriber: Subscription;
itemsPerPage: number;
links: any;
page: any;
predicate: any;
reverse: any;
totalItems: number;
constructor(
protected assetService: AssetService,
protected jhiAlertService: JhiAlertService,
protected eventManager: JhiEventManager,
protected parseLinks: JhiParseLinks,
protected accountService: AccountService
) {
this.assets = [];
this.itemsPerPage = ITEMS_PER_PAGE;
this.page = 0;
this.links = {
last: 0
};
this.predicate = 'id';
this.reverse = true;
}
loadAll() {
this.assetService
.query({
page: this.page,
size: this.itemsPerPage,
sort: this.sort()
})
.subscribe(
(res: HttpResponse<IAsset[]>) => this.paginateAssets(res.body, res.headers),
(res: HttpErrorResponse) => this.onError(res.message)
);
}
reset() {
this.page = 0;
this.assets = [];
this.loadAll();
}
loadPage(page) {
this.page = page;
this.loadAll();
}
ngOnInit() {
this.loadAll();
this.accountService.identity().then(account => {
this.currentAccount = account;
});
this.registerChangeInAssets();
}
ngOnDestroy() {
this.eventManager.destroy(this.eventSubscriber);
}
trackId(index: number, item: IAsset) {
return item.id;
}
registerChangeInAssets() {
this.eventSubscriber = this.eventManager.subscribe('assetListModification', response => this.reset());
}
sort() {
const result = [this.predicate + ',' + (this.reverse ? 'asc' : 'desc')];
if (this.predicate !== 'id') {
result.push('id');
}
return result;
}
protected paginateAssets(data: IAsset[], headers: HttpHeaders) {
this.links = this.parseLinks.parse(headers.get('link'));
this.totalItems = parseInt(headers.get('X-Total-Count'), 10);
for (let i = 0; i < data.length; i++) {
this.assets.push(data[i]);
}
}
protected onError(errorMessage: string) {
this.jhiAlertService.error(errorMessage, null, null);
}
}

View File

@ -0,0 +1,34 @@
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { RouterModule } from '@angular/router';
import { JhiLanguageService } from 'ng-jhipster';
import { JhiLanguageHelper } from 'app/core';
import { HsadminNgSharedModule } from 'app/shared';
import {
AssetComponent,
AssetDetailComponent,
AssetUpdateComponent,
AssetDeletePopupComponent,
AssetDeleteDialogComponent,
assetRoute,
assetPopupRoute
} from './';
const ENTITY_STATES = [...assetRoute, ...assetPopupRoute];
@NgModule({
imports: [HsadminNgSharedModule, RouterModule.forChild(ENTITY_STATES)],
declarations: [AssetComponent, AssetDetailComponent, AssetUpdateComponent, AssetDeleteDialogComponent, AssetDeletePopupComponent],
entryComponents: [AssetComponent, AssetUpdateComponent, AssetDeleteDialogComponent, AssetDeletePopupComponent],
providers: [{ provide: JhiLanguageService, useClass: JhiLanguageService }],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class HsadminNgAssetModule {
constructor(private languageService: JhiLanguageService, private languageHelper: JhiLanguageHelper) {
this.languageHelper.language.subscribe((languageKey: string) => {
if (languageKey !== undefined) {
this.languageService.changeLanguage(languageKey);
}
});
}
}

View File

@ -0,0 +1,93 @@
import { Injectable } from '@angular/core';
import { HttpResponse } from '@angular/common/http';
import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot, Routes } from '@angular/router';
import { UserRouteAccessService } from 'app/core';
import { Observable, of } from 'rxjs';
import { filter, map } from 'rxjs/operators';
import { Asset } from 'app/shared/model/asset.model';
import { AssetService } from './asset.service';
import { AssetComponent } from './asset.component';
import { AssetDetailComponent } from './asset-detail.component';
import { AssetUpdateComponent } from './asset-update.component';
import { AssetDeletePopupComponent } from './asset-delete-dialog.component';
import { IAsset } from 'app/shared/model/asset.model';
@Injectable({ providedIn: 'root' })
export class AssetResolve implements Resolve<IAsset> {
constructor(private service: AssetService) {}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<IAsset> {
const id = route.params['id'] ? route.params['id'] : null;
if (id) {
return this.service.find(id).pipe(
filter((response: HttpResponse<Asset>) => response.ok),
map((asset: HttpResponse<Asset>) => asset.body)
);
}
return of(new Asset());
}
}
export const assetRoute: Routes = [
{
path: '',
component: AssetComponent,
data: {
authorities: ['ROLE_USER'],
pageTitle: 'hsadminNgApp.asset.home.title'
},
canActivate: [UserRouteAccessService]
},
{
path: ':id/view',
component: AssetDetailComponent,
resolve: {
asset: AssetResolve
},
data: {
authorities: ['ROLE_USER'],
pageTitle: 'hsadminNgApp.asset.home.title'
},
canActivate: [UserRouteAccessService]
},
{
path: 'new',
component: AssetUpdateComponent,
resolve: {
asset: AssetResolve
},
data: {
authorities: ['ROLE_USER'],
pageTitle: 'hsadminNgApp.asset.home.title'
},
canActivate: [UserRouteAccessService]
},
{
path: ':id/edit',
component: AssetUpdateComponent,
resolve: {
asset: AssetResolve
},
data: {
authorities: ['ROLE_USER'],
pageTitle: 'hsadminNgApp.asset.home.title'
},
canActivate: [UserRouteAccessService]
}
];
export const assetPopupRoute: Routes = [
{
path: ':id/delete',
component: AssetDeletePopupComponent,
resolve: {
asset: AssetResolve
},
data: {
authorities: ['ROLE_USER'],
pageTitle: 'hsadminNgApp.asset.home.title'
},
canActivate: [UserRouteAccessService],
outlet: 'popup'
}
];

View File

@ -0,0 +1,74 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpResponse } from '@angular/common/http';
import { Observable } from 'rxjs';
import * as moment from 'moment';
import { DATE_FORMAT } from 'app/shared/constants/input.constants';
import { map } from 'rxjs/operators';
import { SERVER_API_URL } from 'app/app.constants';
import { createRequestOption } from 'app/shared';
import { IAsset } from 'app/shared/model/asset.model';
type EntityResponseType = HttpResponse<IAsset>;
type EntityArrayResponseType = HttpResponse<IAsset[]>;
@Injectable({ providedIn: 'root' })
export class AssetService {
public resourceUrl = SERVER_API_URL + 'api/assets';
constructor(protected http: HttpClient) {}
create(asset: IAsset): Observable<EntityResponseType> {
const copy = this.convertDateFromClient(asset);
return this.http
.post<IAsset>(this.resourceUrl, copy, { observe: 'response' })
.pipe(map((res: EntityResponseType) => this.convertDateFromServer(res)));
}
update(asset: IAsset): Observable<EntityResponseType> {
const copy = this.convertDateFromClient(asset);
return this.http
.put<IAsset>(this.resourceUrl, copy, { observe: 'response' })
.pipe(map((res: EntityResponseType) => this.convertDateFromServer(res)));
}
find(id: number): Observable<EntityResponseType> {
return this.http
.get<IAsset>(`${this.resourceUrl}/${id}`, { observe: 'response' })
.pipe(map((res: EntityResponseType) => this.convertDateFromServer(res)));
}
query(req?: any): Observable<EntityArrayResponseType> {
const options = createRequestOption(req);
return this.http
.get<IAsset[]>(this.resourceUrl, { params: options, observe: 'response' })
.pipe(map((res: EntityArrayResponseType) => this.convertDateArrayFromServer(res)));
}
delete(id: number): Observable<HttpResponse<any>> {
return this.http.delete<any>(`${this.resourceUrl}/${id}`, { observe: 'response' });
}
protected convertDateFromClient(asset: IAsset): IAsset {
const copy: IAsset = Object.assign({}, asset, {
date: asset.date != null && asset.date.isValid() ? asset.date.format(DATE_FORMAT) : null
});
return copy;
}
protected convertDateFromServer(res: EntityResponseType): EntityResponseType {
if (res.body) {
res.body.date = res.body.date != null ? moment(res.body.date) : null;
}
return res;
}
protected convertDateArrayFromServer(res: EntityArrayResponseType): EntityArrayResponseType {
if (res.body) {
res.body.forEach((asset: IAsset) => {
asset.date = asset.date != null ? moment(asset.date) : null;
});
}
return res;
}
}

View File

@ -0,0 +1,6 @@
export * from './asset.service';
export * from './asset-update.component';
export * from './asset-delete-dialog.component';
export * from './asset-detail.component';
export * from './asset.component';
export * from './asset.route';

View File

@ -0,0 +1,19 @@
<form name="deleteForm" (ngSubmit)="confirmDelete(contact.id)">
<div class="modal-header">
<h4 class="modal-title" jhiTranslate="entity.delete.title">Confirm delete operation</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"
(click)="clear()">&times;</button>
</div>
<div class="modal-body">
<jhi-alert-error></jhi-alert-error>
<p id="jhi-delete-contact-heading" jhiTranslate="hsadminNgApp.contact.delete.question" [translateValues]="{id: contact.id}">Are you sure you want to delete this Contact?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal" (click)="clear()">
<fa-icon [icon]="'ban'"></fa-icon>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span>
</button>
<button id="jhi-confirm-delete-contact" type="submit" class="btn btn-danger">
<fa-icon [icon]="'times'"></fa-icon>&nbsp;<span jhiTranslate="entity.action.delete">Delete</span>
</button>
</div>
</form>

View File

@ -0,0 +1,65 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { NgbActiveModal, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
import { JhiEventManager } from 'ng-jhipster';
import { IContact } from 'app/shared/model/contact.model';
import { ContactService } from './contact.service';
@Component({
selector: 'jhi-contact-delete-dialog',
templateUrl: './contact-delete-dialog.component.html'
})
export class ContactDeleteDialogComponent {
contact: IContact;
constructor(protected contactService: ContactService, public activeModal: NgbActiveModal, protected eventManager: JhiEventManager) {}
clear() {
this.activeModal.dismiss('cancel');
}
confirmDelete(id: number) {
this.contactService.delete(id).subscribe(response => {
this.eventManager.broadcast({
name: 'contactListModification',
content: 'Deleted an contact'
});
this.activeModal.dismiss(true);
});
}
}
@Component({
selector: 'jhi-contact-delete-popup',
template: ''
})
export class ContactDeletePopupComponent implements OnInit, OnDestroy {
protected ngbModalRef: NgbModalRef;
constructor(protected activatedRoute: ActivatedRoute, protected router: Router, protected modalService: NgbModal) {}
ngOnInit() {
this.activatedRoute.data.subscribe(({ contact }) => {
setTimeout(() => {
this.ngbModalRef = this.modalService.open(ContactDeleteDialogComponent as Component, { size: 'lg', backdrop: 'static' });
this.ngbModalRef.componentInstance.contact = contact;
this.ngbModalRef.result.then(
result => {
this.router.navigate(['/contact', { outlets: { popup: null } }]);
this.ngbModalRef = null;
},
reason => {
this.router.navigate(['/contact', { outlets: { popup: null } }]);
this.ngbModalRef = null;
}
);
}, 0);
});
}
ngOnDestroy() {
this.ngbModalRef = null;
}
}

View File

@ -0,0 +1,35 @@
<div class="row justify-content-center">
<div class="col-8">
<div *ngIf="contact">
<h2><span jhiTranslate="hsadminNgApp.contact.detail.title">Contact</span> {{contact.id}}</h2>
<hr>
<jhi-alert-error></jhi-alert-error>
<dl class="row-md jh-entity-details">
<dt><span jhiTranslate="hsadminNgApp.contact.firstName">First Name</span></dt>
<dd>
<span>{{contact.firstName}}</span>
</dd>
<dt><span jhiTranslate="hsadminNgApp.contact.lastName">Last Name</span></dt>
<dd>
<span>{{contact.lastName}}</span>
</dd>
<dt><span jhiTranslate="hsadminNgApp.contact.email">Email</span></dt>
<dd>
<span>{{contact.email}}</span>
</dd>
</dl>
<button type="submit"
(click)="previousState()"
class="btn btn-info">
<fa-icon [icon]="'arrow-left'"></fa-icon>&nbsp;<span jhiTranslate="entity.action.back"> Back</span>
</button>
<button type="button"
[routerLink]="['/contact', contact.id, 'edit']"
class="btn btn-primary">
<fa-icon [icon]="'pencil-alt'"></fa-icon>&nbsp;<span jhiTranslate="entity.action.edit"> Edit</span>
</button>
</div>
</div>
</div>

View File

@ -0,0 +1,24 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { IContact } from 'app/shared/model/contact.model';
@Component({
selector: 'jhi-contact-detail',
templateUrl: './contact-detail.component.html'
})
export class ContactDetailComponent implements OnInit {
contact: IContact;
constructor(protected activatedRoute: ActivatedRoute) {}
ngOnInit() {
this.activatedRoute.data.subscribe(({ contact }) => {
this.contact = contact;
});
}
previousState() {
window.history.back();
}
}

View File

@ -0,0 +1,69 @@
<div class="row justify-content-center">
<div class="col-8">
<form name="editForm" role="form" novalidate (ngSubmit)="save()" #editForm="ngForm">
<h2 id="jhi-contact-heading" jhiTranslate="hsadminNgApp.contact.home.createOrEditLabel">Create or edit a Contact</h2>
<div>
<jhi-alert-error></jhi-alert-error>
<div class="form-group" [hidden]="!contact.id">
<label for="id" jhiTranslate="global.field.id">ID</label>
<input type="text" class="form-control" id="id" name="id"
[(ngModel)]="contact.id" readonly />
</div>
<div class="form-group">
<label class="form-control-label" jhiTranslate="hsadminNgApp.contact.firstName" for="field_firstName">First Name</label>
<input type="text" class="form-control" name="firstName" id="field_firstName"
[(ngModel)]="contact.firstName" required maxlength="80"/>
<div [hidden]="!(editForm.controls.firstName?.dirty && editForm.controls.firstName?.invalid)">
<small class="form-text text-danger"
[hidden]="!editForm.controls.firstName?.errors?.required" jhiTranslate="entity.validation.required">
This field is required.
</small>
<small class="form-text text-danger"
[hidden]="!editForm.controls.firstName?.errors?.maxlength" jhiTranslate="entity.validation.maxlength" [translateValues]="{ max: 80 }">
This field cannot be longer than 80 characters.
</small>
</div>
</div>
<div class="form-group">
<label class="form-control-label" jhiTranslate="hsadminNgApp.contact.lastName" for="field_lastName">Last Name</label>
<input type="text" class="form-control" name="lastName" id="field_lastName"
[(ngModel)]="contact.lastName" required maxlength="80"/>
<div [hidden]="!(editForm.controls.lastName?.dirty && editForm.controls.lastName?.invalid)">
<small class="form-text text-danger"
[hidden]="!editForm.controls.lastName?.errors?.required" jhiTranslate="entity.validation.required">
This field is required.
</small>
<small class="form-text text-danger"
[hidden]="!editForm.controls.lastName?.errors?.maxlength" jhiTranslate="entity.validation.maxlength" [translateValues]="{ max: 80 }">
This field cannot be longer than 80 characters.
</small>
</div>
</div>
<div class="form-group">
<label class="form-control-label" jhiTranslate="hsadminNgApp.contact.email" for="field_email">Email</label>
<input type="text" class="form-control" name="email" id="field_email"
[(ngModel)]="contact.email" required maxlength="80"/>
<div [hidden]="!(editForm.controls.email?.dirty && editForm.controls.email?.invalid)">
<small class="form-text text-danger"
[hidden]="!editForm.controls.email?.errors?.required" jhiTranslate="entity.validation.required">
This field is required.
</small>
<small class="form-text text-danger"
[hidden]="!editForm.controls.email?.errors?.maxlength" jhiTranslate="entity.validation.maxlength" [translateValues]="{ max: 80 }">
This field cannot be longer than 80 characters.
</small>
</div>
</div>
</div>
<div>
<button type="button" id="cancel-save" class="btn btn-secondary" (click)="previousState()">
<fa-icon [icon]="'ban'"></fa-icon>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span>
</button>
<button type="submit" id="save-entity" [disabled]="editForm.form.invalid || isSaving" class="btn btn-primary">
<fa-icon [icon]="'save'"></fa-icon>&nbsp;<span jhiTranslate="entity.action.save">Save</span>
</button>
</div>
</form>
</div>
</div>

View File

@ -0,0 +1,51 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { HttpResponse, HttpErrorResponse } from '@angular/common/http';
import { Observable } from 'rxjs';
import { filter, map } from 'rxjs/operators';
import { IContact } from 'app/shared/model/contact.model';
import { ContactService } from './contact.service';
@Component({
selector: 'jhi-contact-update',
templateUrl: './contact-update.component.html'
})
export class ContactUpdateComponent implements OnInit {
contact: IContact;
isSaving: boolean;
constructor(protected contactService: ContactService, protected activatedRoute: ActivatedRoute) {}
ngOnInit() {
this.isSaving = false;
this.activatedRoute.data.subscribe(({ contact }) => {
this.contact = contact;
});
}
previousState() {
window.history.back();
}
save() {
this.isSaving = true;
if (this.contact.id !== undefined) {
this.subscribeToSaveResponse(this.contactService.update(this.contact));
} else {
this.subscribeToSaveResponse(this.contactService.create(this.contact));
}
}
protected subscribeToSaveResponse(result: Observable<HttpResponse<IContact>>) {
result.subscribe((res: HttpResponse<IContact>) => this.onSaveSuccess(), (res: HttpErrorResponse) => this.onSaveError());
}
protected onSaveSuccess() {
this.isSaving = false;
this.previousState();
}
protected onSaveError() {
this.isSaving = false;
}
}

View File

@ -0,0 +1,58 @@
<div>
<h2 id="page-heading">
<span jhiTranslate="hsadminNgApp.contact.home.title">Contacts</span>
<button id="jh-create-entity" class="btn btn-primary float-right jh-create-entity create-contact" [routerLink]="['/contact/new']">
<fa-icon [icon]="'plus'"></fa-icon>
<span jhiTranslate="hsadminNgApp.contact.home.createLabel">
Create new Contact
</span>
</button>
</h2>
<jhi-alert></jhi-alert>
<br/>
<div class="table-responsive" *ngIf="contacts">
<table class="table table-striped">
<thead>
<tr jhiSort [(predicate)]="predicate" [(ascending)]="reverse" [callback]="reset.bind(this)">
<th jhiSortBy="id"><span jhiTranslate="global.field.id">ID</span> <fa-icon [icon]="'sort'"></fa-icon></th>
<th jhiSortBy="firstName"><span jhiTranslate="hsadminNgApp.contact.firstName">First Name</span> <fa-icon [icon]="'sort'"></fa-icon></th>
<th jhiSortBy="lastName"><span jhiTranslate="hsadminNgApp.contact.lastName">Last Name</span> <fa-icon [icon]="'sort'"></fa-icon></th>
<th jhiSortBy="email"><span jhiTranslate="hsadminNgApp.contact.email">Email</span> <fa-icon [icon]="'sort'"></fa-icon></th>
<th></th>
</tr>
</thead>
<tbody infinite-scroll (scrolled)="loadPage(page + 1)" [infiniteScrollDisabled]="page >= links['last']" [infiniteScrollDistance]="0">
<tr *ngFor="let contact of contacts ;trackBy: trackId">
<td><a [routerLink]="['/contact', contact.id, 'view' ]">{{contact.id}}</a></td>
<td>{{contact.firstName}}</td>
<td>{{contact.lastName}}</td>
<td>{{contact.email}}</td>
<td class="text-right">
<div class="btn-group flex-btn-group-container">
<button type="submit"
[routerLink]="['/contact', contact.id, 'view' ]"
class="btn btn-info btn-sm">
<fa-icon [icon]="'eye'"></fa-icon>
<span class="d-none d-md-inline" jhiTranslate="entity.action.view">View</span>
</button>
<button type="submit"
[routerLink]="['/contact', contact.id, 'edit']"
class="btn btn-primary btn-sm">
<fa-icon [icon]="'pencil-alt'"></fa-icon>
<span class="d-none d-md-inline" jhiTranslate="entity.action.edit">Edit</span>
</button>
<button type="submit"
[routerLink]="['/', 'contact', { outlets: { popup: contact.id + '/delete'} }]"
replaceUrl="true"
queryParamsHandling="merge"
class="btn btn-danger btn-sm">
<fa-icon [icon]="'times'"></fa-icon>
<span class="d-none d-md-inline" jhiTranslate="entity.action.delete">Delete</span>
</button>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>

View File

@ -0,0 +1,108 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { HttpErrorResponse, HttpHeaders, HttpResponse } from '@angular/common/http';
import { Subscription } from 'rxjs';
import { filter, map } from 'rxjs/operators';
import { JhiEventManager, JhiParseLinks, JhiAlertService } from 'ng-jhipster';
import { IContact } from 'app/shared/model/contact.model';
import { AccountService } from 'app/core';
import { ITEMS_PER_PAGE } from 'app/shared';
import { ContactService } from './contact.service';
@Component({
selector: 'jhi-contact',
templateUrl: './contact.component.html'
})
export class ContactComponent implements OnInit, OnDestroy {
contacts: IContact[];
currentAccount: any;
eventSubscriber: Subscription;
itemsPerPage: number;
links: any;
page: any;
predicate: any;
reverse: any;
totalItems: number;
constructor(
protected contactService: ContactService,
protected jhiAlertService: JhiAlertService,
protected eventManager: JhiEventManager,
protected parseLinks: JhiParseLinks,
protected accountService: AccountService
) {
this.contacts = [];
this.itemsPerPage = ITEMS_PER_PAGE;
this.page = 0;
this.links = {
last: 0
};
this.predicate = 'id';
this.reverse = true;
}
loadAll() {
this.contactService
.query({
page: this.page,
size: this.itemsPerPage,
sort: this.sort()
})
.subscribe(
(res: HttpResponse<IContact[]>) => this.paginateContacts(res.body, res.headers),
(res: HttpErrorResponse) => this.onError(res.message)
);
}
reset() {
this.page = 0;
this.contacts = [];
this.loadAll();
}
loadPage(page) {
this.page = page;
this.loadAll();
}
ngOnInit() {
this.loadAll();
this.accountService.identity().then(account => {
this.currentAccount = account;
});
this.registerChangeInContacts();
}
ngOnDestroy() {
this.eventManager.destroy(this.eventSubscriber);
}
trackId(index: number, item: IContact) {
return item.id;
}
registerChangeInContacts() {
this.eventSubscriber = this.eventManager.subscribe('contactListModification', response => this.reset());
}
sort() {
const result = [this.predicate + ',' + (this.reverse ? 'asc' : 'desc')];
if (this.predicate !== 'id') {
result.push('id');
}
return result;
}
protected paginateContacts(data: IContact[], headers: HttpHeaders) {
this.links = this.parseLinks.parse(headers.get('link'));
this.totalItems = parseInt(headers.get('X-Total-Count'), 10);
for (let i = 0; i < data.length; i++) {
this.contacts.push(data[i]);
}
}
protected onError(errorMessage: string) {
this.jhiAlertService.error(errorMessage, null, null);
}
}

View File

@ -0,0 +1,40 @@
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { RouterModule } from '@angular/router';
import { JhiLanguageService } from 'ng-jhipster';
import { JhiLanguageHelper } from 'app/core';
import { HsadminNgSharedModule } from 'app/shared';
import {
ContactComponent,
ContactDetailComponent,
ContactUpdateComponent,
ContactDeletePopupComponent,
ContactDeleteDialogComponent,
contactRoute,
contactPopupRoute
} from './';
const ENTITY_STATES = [...contactRoute, ...contactPopupRoute];
@NgModule({
imports: [HsadminNgSharedModule, RouterModule.forChild(ENTITY_STATES)],
declarations: [
ContactComponent,
ContactDetailComponent,
ContactUpdateComponent,
ContactDeleteDialogComponent,
ContactDeletePopupComponent
],
entryComponents: [ContactComponent, ContactUpdateComponent, ContactDeleteDialogComponent, ContactDeletePopupComponent],
providers: [{ provide: JhiLanguageService, useClass: JhiLanguageService }],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class HsadminNgContactModule {
constructor(private languageService: JhiLanguageService, private languageHelper: JhiLanguageHelper) {
this.languageHelper.language.subscribe((languageKey: string) => {
if (languageKey !== undefined) {
this.languageService.changeLanguage(languageKey);
}
});
}
}

View File

@ -0,0 +1,93 @@
import { Injectable } from '@angular/core';
import { HttpResponse } from '@angular/common/http';
import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot, Routes } from '@angular/router';
import { UserRouteAccessService } from 'app/core';
import { Observable, of } from 'rxjs';
import { filter, map } from 'rxjs/operators';
import { Contact } from 'app/shared/model/contact.model';
import { ContactService } from './contact.service';
import { ContactComponent } from './contact.component';
import { ContactDetailComponent } from './contact-detail.component';
import { ContactUpdateComponent } from './contact-update.component';
import { ContactDeletePopupComponent } from './contact-delete-dialog.component';
import { IContact } from 'app/shared/model/contact.model';
@Injectable({ providedIn: 'root' })
export class ContactResolve implements Resolve<IContact> {
constructor(private service: ContactService) {}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<IContact> {
const id = route.params['id'] ? route.params['id'] : null;
if (id) {
return this.service.find(id).pipe(
filter((response: HttpResponse<Contact>) => response.ok),
map((contact: HttpResponse<Contact>) => contact.body)
);
}
return of(new Contact());
}
}
export const contactRoute: Routes = [
{
path: '',
component: ContactComponent,
data: {
authorities: ['ROLE_USER'],
pageTitle: 'hsadminNgApp.contact.home.title'
},
canActivate: [UserRouteAccessService]
},
{
path: ':id/view',
component: ContactDetailComponent,
resolve: {
contact: ContactResolve
},
data: {
authorities: ['ROLE_USER'],
pageTitle: 'hsadminNgApp.contact.home.title'
},
canActivate: [UserRouteAccessService]
},
{
path: 'new',
component: ContactUpdateComponent,
resolve: {
contact: ContactResolve
},
data: {
authorities: ['ROLE_USER'],
pageTitle: 'hsadminNgApp.contact.home.title'
},
canActivate: [UserRouteAccessService]
},
{
path: ':id/edit',
component: ContactUpdateComponent,
resolve: {
contact: ContactResolve
},
data: {
authorities: ['ROLE_USER'],
pageTitle: 'hsadminNgApp.contact.home.title'
},
canActivate: [UserRouteAccessService]
}
];
export const contactPopupRoute: Routes = [
{
path: ':id/delete',
component: ContactDeletePopupComponent,
resolve: {
contact: ContactResolve
},
data: {
authorities: ['ROLE_USER'],
pageTitle: 'hsadminNgApp.contact.home.title'
},
canActivate: [UserRouteAccessService],
outlet: 'popup'
}
];

View File

@ -0,0 +1,38 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpResponse } from '@angular/common/http';
import { Observable } from 'rxjs';
import { SERVER_API_URL } from 'app/app.constants';
import { createRequestOption } from 'app/shared';
import { IContact } from 'app/shared/model/contact.model';
type EntityResponseType = HttpResponse<IContact>;
type EntityArrayResponseType = HttpResponse<IContact[]>;
@Injectable({ providedIn: 'root' })
export class ContactService {
public resourceUrl = SERVER_API_URL + 'api/contacts';
constructor(protected http: HttpClient) {}
create(contact: IContact): Observable<EntityResponseType> {
return this.http.post<IContact>(this.resourceUrl, contact, { observe: 'response' });
}
update(contact: IContact): Observable<EntityResponseType> {
return this.http.put<IContact>(this.resourceUrl, contact, { observe: 'response' });
}
find(id: number): Observable<EntityResponseType> {
return this.http.get<IContact>(`${this.resourceUrl}/${id}`, { observe: 'response' });
}
query(req?: any): Observable<EntityArrayResponseType> {
const options = createRequestOption(req);
return this.http.get<IContact[]>(this.resourceUrl, { params: options, observe: 'response' });
}
delete(id: number): Observable<HttpResponse<any>> {
return this.http.delete<any>(`${this.resourceUrl}/${id}`, { observe: 'response' });
}
}

View File

@ -0,0 +1,6 @@
export * from './contact.service';
export * from './contact-update.component';
export * from './contact-delete-dialog.component';
export * from './contact-detail.component';
export * from './contact.component';
export * from './contact.route';

View File

@ -0,0 +1,19 @@
<form name="deleteForm" (ngSubmit)="confirmDelete(customerContact.id)">
<div class="modal-header">
<h4 class="modal-title" jhiTranslate="entity.delete.title">Confirm delete operation</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"
(click)="clear()">&times;</button>
</div>
<div class="modal-body">
<jhi-alert-error></jhi-alert-error>
<p id="jhi-delete-customerContact-heading" jhiTranslate="hsadminNgApp.customerContact.delete.question" [translateValues]="{id: customerContact.id}">Are you sure you want to delete this Customer Contact?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal" (click)="clear()">
<fa-icon [icon]="'ban'"></fa-icon>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span>
</button>
<button id="jhi-confirm-delete-customerContact" type="submit" class="btn btn-danger">
<fa-icon [icon]="'times'"></fa-icon>&nbsp;<span jhiTranslate="entity.action.delete">Delete</span>
</button>
</div>
</form>

View File

@ -0,0 +1,72 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { NgbActiveModal, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
import { JhiEventManager } from 'ng-jhipster';
import { ICustomerContact } from 'app/shared/model/customer-contact.model';
import { CustomerContactService } from './customer-contact.service';
@Component({
selector: 'jhi-customer-contact-delete-dialog',
templateUrl: './customer-contact-delete-dialog.component.html'
})
export class CustomerContactDeleteDialogComponent {
customerContact: ICustomerContact;
constructor(
protected customerContactService: CustomerContactService,
public activeModal: NgbActiveModal,
protected eventManager: JhiEventManager
) {}
clear() {
this.activeModal.dismiss('cancel');
}
confirmDelete(id: number) {
this.customerContactService.delete(id).subscribe(response => {
this.eventManager.broadcast({
name: 'customerContactListModification',
content: 'Deleted an customerContact'
});
this.activeModal.dismiss(true);
});
}
}
@Component({
selector: 'jhi-customer-contact-delete-popup',
template: ''
})
export class CustomerContactDeletePopupComponent implements OnInit, OnDestroy {
protected ngbModalRef: NgbModalRef;
constructor(protected activatedRoute: ActivatedRoute, protected router: Router, protected modalService: NgbModal) {}
ngOnInit() {
this.activatedRoute.data.subscribe(({ customerContact }) => {
setTimeout(() => {
this.ngbModalRef = this.modalService.open(CustomerContactDeleteDialogComponent as Component, {
size: 'lg',
backdrop: 'static'
});
this.ngbModalRef.componentInstance.customerContact = customerContact;
this.ngbModalRef.result.then(
result => {
this.router.navigate(['/customer-contact', { outlets: { popup: null } }]);
this.ngbModalRef = null;
},
reason => {
this.router.navigate(['/customer-contact', { outlets: { popup: null } }]);
this.ngbModalRef = null;
}
);
}, 0);
});
}
ngOnDestroy() {
this.ngbModalRef = null;
}
}

View File

@ -0,0 +1,39 @@
<div class="row justify-content-center">
<div class="col-8">
<div *ngIf="customerContact">
<h2><span jhiTranslate="hsadminNgApp.customerContact.detail.title">Customer Contact</span> {{customerContact.id}}</h2>
<hr>
<jhi-alert-error></jhi-alert-error>
<dl class="row-md jh-entity-details">
<dt><span jhiTranslate="hsadminNgApp.customerContact.role">Role</span></dt>
<dd>
<span jhiTranslate="{{'hsadminNgApp.CustomerContactRole.' + customerContact.role}}">{{customerContact.role}}</span>
</dd>
<dt><span jhiTranslate="hsadminNgApp.customerContact.contact">Contact</span></dt>
<dd>
<div *ngIf="customerContact.contactId">
<a [routerLink]="['/contact', customerContact.contactId, 'view']">{{customerContact.contactEmail}}</a>
</div>
</dd>
<dt><span jhiTranslate="hsadminNgApp.customerContact.customer">Customer</span></dt>
<dd>
<div *ngIf="customerContact.customerId">
<a [routerLink]="['/customer', customerContact.customerId, 'view']">{{customerContact.customerPrefix}}</a>
</div>
</dd>
</dl>
<button type="submit"
(click)="previousState()"
class="btn btn-info">
<fa-icon [icon]="'arrow-left'"></fa-icon>&nbsp;<span jhiTranslate="entity.action.back"> Back</span>
</button>
<button type="button"
[routerLink]="['/customer-contact', customerContact.id, 'edit']"
class="btn btn-primary">
<fa-icon [icon]="'pencil-alt'"></fa-icon>&nbsp;<span jhiTranslate="entity.action.edit"> Edit</span>
</button>
</div>
</div>
</div>

View File

@ -0,0 +1,24 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ICustomerContact } from 'app/shared/model/customer-contact.model';
@Component({
selector: 'jhi-customer-contact-detail',
templateUrl: './customer-contact-detail.component.html'
})
export class CustomerContactDetailComponent implements OnInit {
customerContact: ICustomerContact;
constructor(protected activatedRoute: ActivatedRoute) {}
ngOnInit() {
this.activatedRoute.data.subscribe(({ customerContact }) => {
this.customerContact = customerContact;
});
}
previousState() {
window.history.back();
}
}

View File

@ -0,0 +1,64 @@
<div class="row justify-content-center">
<div class="col-8">
<form name="editForm" role="form" novalidate (ngSubmit)="save()" #editForm="ngForm">
<h2 id="jhi-customer-contact-heading" jhiTranslate="hsadminNgApp.customerContact.home.createOrEditLabel">Create or edit a Customer Contact</h2>
<div>
<jhi-alert-error></jhi-alert-error>
<div class="form-group" [hidden]="!customerContact.id">
<label for="id" jhiTranslate="global.field.id">ID</label>
<input type="text" class="form-control" id="id" name="id"
[(ngModel)]="customerContact.id" readonly />
</div>
<div class="form-group">
<label class="form-control-label" jhiTranslate="hsadminNgApp.customerContact.role" for="field_role">Role</label>
<select class="form-control" name="role" [(ngModel)]="customerContact.role" id="field_role" required>
<option value="CONTRACTUAL">{{'hsadminNgApp.CustomerContactRole.CONTRACTUAL' | translate}}</option>
<option value="TECHNICAL">{{'hsadminNgApp.CustomerContactRole.TECHNICAL' | translate}}</option>
<option value="FINANCIAL">{{'hsadminNgApp.CustomerContactRole.FINANCIAL' | translate}}</option>
</select>
<div [hidden]="!(editForm.controls.role?.dirty && editForm.controls.role?.invalid)">
<small class="form-text text-danger"
[hidden]="!editForm.controls.role?.errors?.required" jhiTranslate="entity.validation.required">
This field is required.
</small>
</div>
</div>
<div class="form-group">
<label class="form-control-label" jhiTranslate="hsadminNgApp.customerContact.contact" for="field_contact">Contact</label>
<select class="form-control" id="field_contact" name="contact" [(ngModel)]="customerContact.contactId" required>
<option *ngIf="!editForm.value.contact" [ngValue]="null" selected></option>
<option [ngValue]="contactOption.id" *ngFor="let contactOption of contacts; trackBy: trackContactById">{{contactOption.email}}</option>
</select>
</div>
<div [hidden]="!(editForm.controls.contact?.dirty && editForm.controls.contact?.invalid)">
<small class="form-text text-danger"
[hidden]="!editForm.controls.contact?.errors?.required" jhiTranslate="entity.validation.required">
This field is required.
</small>
</div>
<div class="form-group">
<label class="form-control-label" jhiTranslate="hsadminNgApp.customerContact.customer" for="field_customer">Customer</label>
<select class="form-control" id="field_customer" name="customer" [(ngModel)]="customerContact.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()">
<fa-icon [icon]="'ban'"></fa-icon>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span>
</button>
<button type="submit" id="save-entity" [disabled]="editForm.form.invalid || isSaving" class="btn btn-primary">
<fa-icon [icon]="'save'"></fa-icon>&nbsp;<span jhiTranslate="entity.action.save">Save</span>
</button>
</div>
</form>
</div>
</div>

View File

@ -0,0 +1,92 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { HttpResponse, HttpErrorResponse } from '@angular/common/http';
import { Observable } from 'rxjs';
import { filter, map } from 'rxjs/operators';
import { JhiAlertService } from 'ng-jhipster';
import { ICustomerContact } from 'app/shared/model/customer-contact.model';
import { CustomerContactService } from './customer-contact.service';
import { IContact } from 'app/shared/model/contact.model';
import { ContactService } from 'app/entities/contact';
import { ICustomer } from 'app/shared/model/customer.model';
import { CustomerService } from 'app/entities/customer';
@Component({
selector: 'jhi-customer-contact-update',
templateUrl: './customer-contact-update.component.html'
})
export class CustomerContactUpdateComponent implements OnInit {
customerContact: ICustomerContact;
isSaving: boolean;
contacts: IContact[];
customers: ICustomer[];
constructor(
protected jhiAlertService: JhiAlertService,
protected customerContactService: CustomerContactService,
protected contactService: ContactService,
protected customerService: CustomerService,
protected activatedRoute: ActivatedRoute
) {}
ngOnInit() {
this.isSaving = false;
this.activatedRoute.data.subscribe(({ customerContact }) => {
this.customerContact = customerContact;
});
this.contactService
.query()
.pipe(
filter((mayBeOk: HttpResponse<IContact[]>) => mayBeOk.ok),
map((response: HttpResponse<IContact[]>) => response.body)
)
.subscribe((res: IContact[]) => (this.contacts = res), (res: HttpErrorResponse) => this.onError(res.message));
this.customerService
.query()
.pipe(
filter((mayBeOk: HttpResponse<ICustomer[]>) => mayBeOk.ok),
map((response: HttpResponse<ICustomer[]>) => response.body)
)
.subscribe((res: ICustomer[]) => (this.customers = res), (res: HttpErrorResponse) => this.onError(res.message));
}
previousState() {
window.history.back();
}
save() {
this.isSaving = true;
if (this.customerContact.id !== undefined) {
this.subscribeToSaveResponse(this.customerContactService.update(this.customerContact));
} else {
this.subscribeToSaveResponse(this.customerContactService.create(this.customerContact));
}
}
protected subscribeToSaveResponse(result: Observable<HttpResponse<ICustomerContact>>) {
result.subscribe((res: HttpResponse<ICustomerContact>) => this.onSaveSuccess(), (res: HttpErrorResponse) => this.onSaveError());
}
protected onSaveSuccess() {
this.isSaving = false;
this.previousState();
}
protected onSaveError() {
this.isSaving = false;
}
protected onError(errorMessage: string) {
this.jhiAlertService.error(errorMessage, null, null);
}
trackContactById(index: number, item: IContact) {
return item.id;
}
trackCustomerById(index: number, item: ICustomer) {
return item.id;
}
}

Some files were not shown because too many files have changed in this diff Show More