Files
wisemapping-open-source/wise-api/src/main/java/com/wisemapping/model/Account.java

199 lines
5.0 KiB
Java
Raw Normal View History

/*
2022-03-17 18:47:34 -03:00
* Copyright [2022] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.wisemapping.model;
import org.jetbrains.annotations.NotNull;
2012-07-12 23:56:04 -03:00
import org.jetbrains.annotations.Nullable;
2012-06-30 02:26:21 -03:00
2023-07-28 22:46:38 -07:00
import jakarta.persistence.*;
2024-03-23 23:07:14 -07:00
import java.io.Serializable;
2012-11-13 13:34:35 -03:00
import java.util.Calendar;
@Entity
2024-02-17 11:18:43 -08:00
@Table(name = "ACCOUNT")
@PrimaryKeyJoinColumn(name = "collaborator_id")
public class Account
extends Collaborator
implements Serializable {
2023-07-02 10:13:42 -07:00
public static final int MAX_PASSWORD_LENGTH_SIZE = 40;
private String firstname;
private String lastname;
private String password;
private String locale;
2023-07-02 10:13:42 -07:00
@Column(name = "activation_code")
private long activationCode;
2023-07-02 10:13:42 -07:00
@Column(name = "activation_date")
private Calendar activationDate;
2023-07-02 10:13:42 -07:00
@Column(name = "allow_send_email")
private boolean allowSendEmail = false;
2023-07-02 10:13:42 -07:00
2022-03-17 18:47:34 -03:00
@Column(name = "authentication_type")
private Character authenticationTypeCode = AuthenticationType.DATABASE.getCode();
2023-07-02 10:13:42 -07:00
2022-03-17 18:47:34 -03:00
@Column(name = "authenticator_uri")
2013-03-17 23:17:55 -03:00
private String authenticatorUri;
2023-07-02 10:13:42 -07:00
2022-12-13 02:36:58 +00:00
@Column(name = "google_sync")
2023-07-02 10:13:42 -07:00
private Boolean googleSync;
2022-12-13 02:36:58 +00:00
@Column(name = "sync_code")
2023-07-02 10:13:42 -07:00
private String syncCode;
2022-12-13 02:36:58 +00:00
@Column(name = "google_token")
2023-07-02 10:13:42 -07:00
private String googleToken;
2024-02-17 11:18:43 -08:00
public Account() {
}
2012-06-13 23:04:29 -03:00
public String getFullName() {
return this.getFirstname() + " " + this.getLastname();
}
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 getPassword() {
return password;
}
2022-03-17 18:47:34 -03:00
2023-07-28 22:46:38 -07:00
public void setPassword(@jakarta.validation.constraints.NotNull String password) {
this.password = password;
}
public boolean isActive() {
return activationDate != null;
}
public void setActivationCode(long code) {
this.activationCode = code;
}
public long getActivationCode() {
return activationCode;
}
public void setActivationDate(Calendar date) {
this.activationDate = date;
}
public Calendar getActivationDate() {
return activationDate;
}
public boolean isAllowSendEmail() {
return allowSendEmail;
}
public void setAllowSendEmail(boolean allowSendEmail) {
this.allowSendEmail = allowSendEmail;
}
2012-07-12 23:56:04 -03:00
@Nullable
2012-06-30 02:26:21 -03:00
public String getLocale() {
return locale;
}
2012-07-12 23:56:04 -03:00
public void setLocale(@Nullable String locale) {
2012-06-30 02:26:21 -03:00
this.locale = locale;
}
2013-03-10 19:07:52 -03:00
public char getAuthenticationTypeCode() {
return this.authenticationTypeCode;
}
public void setAuthenticationTypeCode(char code) {
this.authenticationTypeCode = code;
}
2013-03-17 23:17:55 -03:00
public AuthenticationType getAuthenticationType() {
2022-03-17 18:47:34 -03:00
return authenticationTypeCode != null ? AuthenticationType.valueOf(authenticationTypeCode) : AuthenticationType.DATABASE;
2013-03-10 19:07:52 -03:00
}
2013-03-17 23:17:55 -03:00
public void setAuthenticationType(@NotNull AuthenticationType authenticationType) {
this.authenticationTypeCode = authenticationType.getCode();
2013-03-10 19:07:52 -03:00
}
2022-03-17 18:47:34 -03:00
public boolean isDatabaseSchema() {
return this.getAuthenticationType() == AuthenticationType.DATABASE;
2013-03-17 23:17:55 -03:00
}
public String getAuthenticatorUri() {
return authenticatorUri;
}
public void setAuthenticatorUri(String authenticatorUri) {
this.authenticatorUri = authenticatorUri;
}
2022-12-13 02:36:58 +00:00
public void setAuthenticationTypeCode(Character authenticationTypeCode) {
2023-07-02 10:13:42 -07:00
this.authenticationTypeCode = authenticationTypeCode;
}
public Boolean getGoogleSync() {
2024-03-23 23:07:14 -07:00
return googleSync != null && googleSync;
2023-07-02 10:13:42 -07:00
}
public void setGoogleSync(Boolean googleSync) {
this.googleSync = googleSync;
}
public String getSyncCode() {
return syncCode;
}
public void setSyncCode(String syncCode) {
this.syncCode = syncCode;
}
public String getGoogleToken() {
return googleToken;
}
public void setGoogleToken(String googleToken) {
this.googleToken = googleToken;
}
@Override
2022-03-17 18:47:34 -03:00
public String toString() {
return "User{" +
"firstname='" + firstname + '\'' +
", lastname='" + lastname + '\'' +
"', email = '" + this.getEmail() + "}";
}
}