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, 2020 Eurotech and/or its affiliates and others
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License v1.0
6: * which accompanies this distribution, and is available at
7: * http://www.eclipse.org/legal/epl-v10.html
8: *
9: * Contributors:
10: * Eurotech - initial API and implementation
11: *******************************************************************************/
12: package org.eclipse.kapua.service.account.internal;
13:
14: import org.eclipse.kapua.KapuaException;
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: * Account entity 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, updatable = true)
82: protected Date expirationDate;
83:
84: /**
85: * Constructor
86: */
87: protected AccountImpl() {
88: super();
89: }
90:
91: /**
92: * Constructor.
93: *
94: * @param scopeId
95: * @since 1.0.0
96: */
97: public AccountImpl(KapuaId scopeId) {
98: super(scopeId);
99:
100: setParentAccountPath("");
101: }
102:
103: /**
104: * Constructor
105: *
106: * @param scopeId
107: * @param name
108: * @since 1.0.0
109: */
110: public AccountImpl(KapuaId scopeId, String name) {
111: super(scopeId, name);
112:
113: setParentAccountPath("");
114: }
115:
116: /**
117: * Clone constructor.
118: *
119: * @throws KapuaException
120: * @since 1.1.0
121: */
122: public AccountImpl(Account account) throws KapuaException {
123: super(account);
124:
125: setOrganization(new OrganizationImpl(account.getOrganization()));
126: setParentAccountPath(account.getParentAccountPath());
127: setChildAccounts(account.getChildAccounts());
128: setExpirationDate(account.getExpirationDate());
129: }
130:
131: @Override
132: public Organization getOrganization() {
133: return organization;
134: }
135:
136: @Override
137: public void setOrganization(Organization organization) {
138: this.organization = (OrganizationImpl) organization;
139: }
140:
141: @Override
142: public String getParentAccountPath() {
143: return parentAccountPath;
144: }
145:
146: @Override
147: public void setParentAccountPath(String parentAccountPath) {
148: this.parentAccountPath = parentAccountPath;
149: }
150:
151: @Override
152: public List<Account> getChildAccounts() {
153:• if (childAccounts == null) {
154: childAccounts = new ArrayList<>();
155: }
156:
157: return new ArrayList<>(childAccounts);
158: }
159:
160: private void setChildAccounts(List<Account> childAccounts) throws KapuaException {
161: List<AccountImpl> accounts = new ArrayList<>();
162:
163:• for (Account a : childAccounts) {
164: accounts.add(new AccountImpl(a));
165: }
166:
167: this.childAccounts = accounts;
168: }
169:
170: @Override
171: public Date getExpirationDate() {
172: return expirationDate;
173: }
174:
175: @Override
176: public void setExpirationDate(Date expirationDate) {
177: this.expirationDate = expirationDate;
178: }
179:
180:
181: }