Skip to content

Package: AccountImpl

AccountImpl

nameinstructionbranchcomplexitylinemethod
AccountImpl()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
AccountImpl(Account)
M: 23 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
AccountImpl(KapuaId)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
AccountImpl(KapuaId, String)
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
getChildAccounts()
M: 14 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
getExpirationDate()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getOrganization()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getParentAccountPath()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
setChildAccounts(List)
M: 26 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
setExpirationDate(Date)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setOrganization(Organization)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setParentAccountPath(String)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2016, 2022 Eurotech and/or its affiliates and others
3: *
4: * This program and the accompanying materials are made
5: * available under the terms of the Eclipse Public License 2.0
6: * which is available at https://www.eclipse.org/legal/epl-2.0/
7: *
8: * SPDX-License-Identifier: EPL-2.0
9: *
10: * Contributors:
11: * Eurotech - initial API and implementation
12: *******************************************************************************/
13: package org.eclipse.kapua.service.account.internal;
14:
15: import org.eclipse.kapua.commons.model.AbstractKapuaNamedEntity;
16: import org.eclipse.kapua.model.id.KapuaId;
17: import org.eclipse.kapua.service.account.Account;
18: import org.eclipse.kapua.service.account.Organization;
19:
20: import javax.persistence.AttributeOverride;
21: import javax.persistence.AttributeOverrides;
22: import javax.persistence.Basic;
23: import javax.persistence.Column;
24: import javax.persistence.Embedded;
25: import javax.persistence.Entity;
26: import javax.persistence.FetchType;
27: import javax.persistence.JoinColumn;
28: import javax.persistence.NamedQueries;
29: import javax.persistence.NamedQuery;
30: import javax.persistence.OneToMany;
31: import javax.persistence.OrderBy;
32: import javax.persistence.Table;
33: import javax.persistence.Temporal;
34: import javax.persistence.TemporalType;
35: import java.util.ArrayList;
36: import java.util.Date;
37: import java.util.List;
38:
39: /**
40: * {@link Account} implementation.
41: *
42: * @since 1.0
43: */
44: @Entity(name = "Account")
45: @NamedQueries({
46: @NamedQuery(name = "Account.findChildAccounts", query = "SELECT a FROM Account a WHERE a.scopeId = :scopeId ORDER BY a.name"),
47: @NamedQuery(name = "Account.findChildAccountsRecursive", query = "SELECT a FROM Account a WHERE a.parentAccountPath LIKE :parentAccountPath ORDER BY a.name")
48: })
49: @Table(name = "act_account")
50: public class AccountImpl extends AbstractKapuaNamedEntity implements Account {
51:
52: private static final long serialVersionUID = 8530992430658117928L;
53:
54: @Embedded
55: @AttributeOverrides({
56: @AttributeOverride(name = "name", column = @Column(name = "org_name")),
57: @AttributeOverride(name = "personName", column = @Column(name = "org_person_name")),
58: @AttributeOverride(name = "email", column = @Column(name = "org_email")),
59: @AttributeOverride(name = "phoneNumber", column = @Column(name = "org_phone_number")),
60: @AttributeOverride(name = "addressLine1", column = @Column(name = "org_address_line_1")),
61: @AttributeOverride(name = "addressLine2", column = @Column(name = "org_address_line_2")),
62: @AttributeOverride(name = "addressLine3", column = @Column(name = "org_address_line_3")),
63: @AttributeOverride(name = "addressLine3", column = @Column(name = "org_address_line_3")),
64: @AttributeOverride(name = "zipPostCode", column = @Column(name = "org_zip_postcode")),
65: @AttributeOverride(name = "city", column = @Column(name = "org_city")),
66: @AttributeOverride(name = "stateProvinceCounty", column = @Column(name = "org_state_province_county")),
67: @AttributeOverride(name = "country", column = @Column(name = "org_country")),
68: })
69: private OrganizationImpl organization;
70:
71: @Basic
72: @Column(name = "parent_account_path", nullable = false, updatable = true)
73: private String parentAccountPath;
74:
75: @OneToMany(fetch = FetchType.LAZY)
76: @JoinColumn(name = "scope_id", referencedColumnName = "id", insertable = false, updatable = false)
77: @OrderBy("name ASC")
78: private List<AccountImpl> childAccounts;
79:
80: @Temporal(TemporalType.TIMESTAMP)
81: @Column(name = "expiration_date", nullable = false)
82: private Date expirationDate;
83:
84: /**
85: * Constructor.
86: *
87: * @since 1.0.0
88: */
89: protected AccountImpl() {
90: super();
91: }
92:
93: /**
94: * Constructor.
95: *
96: * @param scopeId The {@link Account#getScopeId()}.
97: * @since 1.0.0
98: */
99: public AccountImpl(KapuaId scopeId) {
100: super(scopeId);
101:
102: setParentAccountPath("");
103: }
104:
105: /**
106: * Constructor.
107: *
108: * @param scopeId The {@link Account#getScopeId()}.
109: * @param name The {@link Account#getName()}
110: * @since 1.0.0
111: */
112: public AccountImpl(KapuaId scopeId, String name) {
113: super(scopeId, name);
114:
115: setParentAccountPath("");
116: }
117:
118: /**
119: * Clone constructor.
120: *
121: * @since 1.1.0
122: */
123: public AccountImpl(Account account) {
124: super(account);
125:
126: setOrganization(new OrganizationImpl(account.getOrganization()));
127: setParentAccountPath(account.getParentAccountPath());
128: setChildAccounts(account.getChildAccounts());
129: setExpirationDate(account.getExpirationDate());
130: }
131:
132: @Override
133: public Organization getOrganization() {
134: return organization;
135: }
136:
137: @Override
138: public void setOrganization(Organization organization) {
139: this.organization = (OrganizationImpl) organization;
140: }
141:
142: @Override
143: public String getParentAccountPath() {
144: return parentAccountPath;
145: }
146:
147: @Override
148: public void setParentAccountPath(String parentAccountPath) {
149: this.parentAccountPath = parentAccountPath;
150: }
151:
152: @Override
153: public List<Account> getChildAccounts() {
154:• if (childAccounts == null) {
155: childAccounts = new ArrayList<>();
156: }
157:
158: return new ArrayList<>(childAccounts);
159: }
160:
161: private void setChildAccounts(List<Account> childAccounts) {
162: List<AccountImpl> accounts = new ArrayList<>();
163:
164:• for (Account a : childAccounts) {
165: accounts.add(new AccountImpl(a));
166: }
167:
168: this.childAccounts = accounts;
169: }
170:
171: @Override
172: public Date getExpirationDate() {
173: return expirationDate;
174: }
175:
176: @Override
177: public void setExpirationDate(Date expirationDate) {
178: this.expirationDate = expirationDate;
179: }
180:
181:
182: }