blob: 274a6081002f4d78edd862cdbb05630fca20ee25 [file] [log] [blame]
package org.eclipse.osbp.authentication.account.dtos;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import javax.validation.constraints.Pattern;
import org.eclipse.osbp.authentication.account.dtos.UserAccountFilterDto;
import org.eclipse.osbp.dsl.common.datatypes.IDto;
import org.eclipse.osbp.dsl.dto.lib.MappingContext;
import org.eclipse.osbp.runtime.common.annotations.Dispose;
import org.eclipse.osbp.runtime.common.annotations.DomainReference;
import org.eclipse.osbp.runtime.common.annotations.Id;
import org.eclipse.osbp.runtime.common.annotations.Properties;
import org.eclipse.osbp.runtime.common.annotations.Property;
import org.eclipse.osbp.runtime.jsr303.validation.common.InfoSeverity;
@SuppressWarnings("all")
public class UserAccountDto implements IDto, Serializable, PropertyChangeListener {
private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
@Dispose
private boolean disposed;
@Id
private String id = java.util.UUID.randomUUID().toString();
private String email;
private String userName;
private String password;
@Pattern(regexp = "[0-9]*", payload = InfoSeverity.class)
private String extraPassword;
private boolean passwordReset;
@Properties(properties = @Property(key = "organization", value = ""))
private String position;
@Properties(properties = @Property(key = "perspective", value = ""))
private String defaultPerpective;
private boolean enabled;
private boolean locked;
private boolean superuser;
private boolean supervisor;
private boolean forcePwdChange;
private boolean notRegistered;
private int failedAttempt;
private int successfulAttempt;
private int cookieHashCode;
private String localeTag;
@Properties(properties = @Property(key = "Blob", value = "2"))
private String profileimage;
private String layoutingStrategy;
private String focusingStrategy;
private String theme;
private String printService;
@DomainReference
private List<UserAccountFilterDto> userAccountFilter;
public UserAccountDto() {
installLazyCollections();
}
/**
* Installs lazy collection resolving for entity {@link UserAccount} to the dto {@link UserAccountDto}.
*
*/
protected void installLazyCollections() {
userAccountFilter = new org.eclipse.osbp.dsl.dto.lib.OppositeDtoList<>(
org.eclipse.osbp.dsl.dto.lib.MappingContext.getCurrent(),
UserAccountFilterDto.class, "userAccount.id",
(java.util.function.Supplier<Object> & Serializable) () -> this.getId());
}
/**
* @return true, if the object is disposed.
* Disposed means, that it is prepared for garbage collection and may not be used anymore.
* Accessing objects that are already disposed will cause runtime exceptions.
*
*/
public boolean isDisposed() {
return this.disposed;
}
/**
* @see PropertyChangeSupport#addPropertyChangeListener(PropertyChangeListener)
*/
public void addPropertyChangeListener(final PropertyChangeListener listener) {
propertyChangeSupport.addPropertyChangeListener(listener);
}
/**
* @see PropertyChangeSupport#addPropertyChangeListener(String, PropertyChangeListener)
*/
public void addPropertyChangeListener(final String propertyName, final PropertyChangeListener listener) {
propertyChangeSupport.addPropertyChangeListener(propertyName, listener);
}
/**
* @see PropertyChangeSupport#removePropertyChangeListener(PropertyChangeListener)
*/
public void removePropertyChangeListener(final PropertyChangeListener listener) {
propertyChangeSupport.removePropertyChangeListener(listener);
}
/**
* @see PropertyChangeSupport#removePropertyChangeListener(String, PropertyChangeListener)
*/
public void removePropertyChangeListener(final String propertyName, final PropertyChangeListener listener) {
propertyChangeSupport.removePropertyChangeListener(propertyName, listener);
}
/**
* @see PropertyChangeSupport#firePropertyChange(String, Object, Object)
*/
public void firePropertyChange(final String propertyName, final Object oldValue, final Object newValue) {
propertyChangeSupport.firePropertyChange(propertyName, oldValue, newValue);
}
/**
* Checks whether the object is disposed.
* @throws RuntimeException if the object is disposed.
*/
private void checkDisposed() {
if (isDisposed()) {
throw new RuntimeException("Object already disposed: " + this);
}
}
/**
* Calling dispose will destroy that instance. The internal state will be
* set to 'disposed' and methods of that object must not be used anymore.
* Each call will result in runtime exceptions.<br/>
* If this object keeps composition containments, these will be disposed too.
* So the whole composition containment tree will be disposed on calling this method.
*/
@Dispose
public void dispose() {
if (isDisposed()) {
return;
}
firePropertyChange("disposed", this.disposed, this.disposed = true);
}
/**
* Returns the id property or <code>null</code> if not present.
*/
public String getId() {
return this.id;
}
/**
* Sets the <code>id</code> property to this instance.
*
* @param id - the property
* @throws RuntimeException if instance is <code>disposed</code>
*
*/
public void setId(final String id) {
firePropertyChange("id", this.id, this.id = id );
installLazyCollections();
}
/**
* Returns the email property or <code>null</code> if not present.
*/
public String getEmail() {
return this.email;
}
/**
* Sets the <code>email</code> property to this instance.
*
* @param email - the property
* @throws RuntimeException if instance is <code>disposed</code>
*
*/
public void setEmail(final String email) {
firePropertyChange("email", this.email, this.email = email );
}
/**
* Returns the userName property or <code>null</code> if not present.
*/
public String getUserName() {
return this.userName;
}
/**
* Sets the <code>userName</code> property to this instance.
*
* @param userName - the property
* @throws RuntimeException if instance is <code>disposed</code>
*
*/
public void setUserName(final String userName) {
firePropertyChange("userName", this.userName, this.userName = userName );
}
/**
* Returns the password property or <code>null</code> if not present.
*/
public String getPassword() {
return this.password;
}
/**
* Sets the <code>password</code> property to this instance.
*
* @param password - the property
* @throws RuntimeException if instance is <code>disposed</code>
*
*/
public void setPassword(final String password) {
firePropertyChange("password", this.password, this.password = password );
}
/**
* Returns the extraPassword property or <code>null</code> if not present.
*/
public String getExtraPassword() {
return this.extraPassword;
}
/**
* Sets the <code>extraPassword</code> property to this instance.
*
* @param extraPassword - the property
* @throws RuntimeException if instance is <code>disposed</code>
*
*/
public void setExtraPassword(final String extraPassword) {
firePropertyChange("extraPassword", this.extraPassword, this.extraPassword = extraPassword );
}
/**
* Returns the passwordReset property or <code>null</code> if not present.
*/
public boolean getPasswordReset() {
return this.passwordReset;
}
/**
* Sets the <code>passwordReset</code> property to this instance.
*
* @param passwordReset - the property
* @throws RuntimeException if instance is <code>disposed</code>
*
*/
public void setPasswordReset(final boolean passwordReset) {
firePropertyChange("passwordReset", this.passwordReset, this.passwordReset = passwordReset );
}
/**
* Returns the position property or <code>null</code> if not present.
*/
public String getPosition() {
return this.position;
}
/**
* Sets the <code>position</code> property to this instance.
*
* @param position - the property
* @throws RuntimeException if instance is <code>disposed</code>
*
*/
public void setPosition(final String position) {
firePropertyChange("position", this.position, this.position = position );
}
/**
* Returns the defaultPerpective property or <code>null</code> if not present.
*/
public String getDefaultPerpective() {
return this.defaultPerpective;
}
/**
* Sets the <code>defaultPerpective</code> property to this instance.
*
* @param defaultPerpective - the property
* @throws RuntimeException if instance is <code>disposed</code>
*
*/
public void setDefaultPerpective(final String defaultPerpective) {
firePropertyChange("defaultPerpective", this.defaultPerpective, this.defaultPerpective = defaultPerpective );
}
/**
* Returns the enabled property or <code>null</code> if not present.
*/
public boolean getEnabled() {
return this.enabled;
}
/**
* Sets the <code>enabled</code> property to this instance.
*
* @param enabled - the property
* @throws RuntimeException if instance is <code>disposed</code>
*
*/
public void setEnabled(final boolean enabled) {
firePropertyChange("enabled", this.enabled, this.enabled = enabled );
}
/**
* Returns the locked property or <code>null</code> if not present.
*/
public boolean getLocked() {
return this.locked;
}
/**
* Sets the <code>locked</code> property to this instance.
*
* @param locked - the property
* @throws RuntimeException if instance is <code>disposed</code>
*
*/
public void setLocked(final boolean locked) {
firePropertyChange("locked", this.locked, this.locked = locked );
}
/**
* Returns the superuser property or <code>null</code> if not present.
*/
public boolean getSuperuser() {
return this.superuser;
}
/**
* Sets the <code>superuser</code> property to this instance.
*
* @param superuser - the property
* @throws RuntimeException if instance is <code>disposed</code>
*
*/
public void setSuperuser(final boolean superuser) {
firePropertyChange("superuser", this.superuser, this.superuser = superuser );
}
/**
* Returns the supervisor property or <code>null</code> if not present.
*/
public boolean getSupervisor() {
return this.supervisor;
}
/**
* Sets the <code>supervisor</code> property to this instance.
*
* @param supervisor - the property
* @throws RuntimeException if instance is <code>disposed</code>
*
*/
public void setSupervisor(final boolean supervisor) {
firePropertyChange("supervisor", this.supervisor, this.supervisor = supervisor );
}
/**
* Returns the forcePwdChange property or <code>null</code> if not present.
*/
public boolean getForcePwdChange() {
return this.forcePwdChange;
}
/**
* Sets the <code>forcePwdChange</code> property to this instance.
*
* @param forcePwdChange - the property
* @throws RuntimeException if instance is <code>disposed</code>
*
*/
public void setForcePwdChange(final boolean forcePwdChange) {
firePropertyChange("forcePwdChange", this.forcePwdChange, this.forcePwdChange = forcePwdChange );
}
/**
* Returns the notRegistered property or <code>null</code> if not present.
*/
public boolean getNotRegistered() {
return this.notRegistered;
}
/**
* Sets the <code>notRegistered</code> property to this instance.
*
* @param notRegistered - the property
* @throws RuntimeException if instance is <code>disposed</code>
*
*/
public void setNotRegistered(final boolean notRegistered) {
firePropertyChange("notRegistered", this.notRegistered, this.notRegistered = notRegistered );
}
/**
* Returns the failedAttempt property or <code>null</code> if not present.
*/
public int getFailedAttempt() {
return this.failedAttempt;
}
/**
* Sets the <code>failedAttempt</code> property to this instance.
*
* @param failedAttempt - the property
* @throws RuntimeException if instance is <code>disposed</code>
*
*/
public void setFailedAttempt(final int failedAttempt) {
firePropertyChange("failedAttempt", this.failedAttempt, this.failedAttempt = failedAttempt );
}
/**
* Returns the successfulAttempt property or <code>null</code> if not present.
*/
public int getSuccessfulAttempt() {
return this.successfulAttempt;
}
/**
* Sets the <code>successfulAttempt</code> property to this instance.
*
* @param successfulAttempt - the property
* @throws RuntimeException if instance is <code>disposed</code>
*
*/
public void setSuccessfulAttempt(final int successfulAttempt) {
firePropertyChange("successfulAttempt", this.successfulAttempt, this.successfulAttempt = successfulAttempt );
}
/**
* Returns the cookieHashCode property or <code>null</code> if not present.
*/
public int getCookieHashCode() {
return this.cookieHashCode;
}
/**
* Sets the <code>cookieHashCode</code> property to this instance.
*
* @param cookieHashCode - the property
* @throws RuntimeException if instance is <code>disposed</code>
*
*/
public void setCookieHashCode(final int cookieHashCode) {
firePropertyChange("cookieHashCode", this.cookieHashCode, this.cookieHashCode = cookieHashCode );
}
/**
* Returns the localeTag property or <code>null</code> if not present.
*/
public String getLocaleTag() {
return this.localeTag;
}
/**
* Sets the <code>localeTag</code> property to this instance.
*
* @param localeTag - the property
* @throws RuntimeException if instance is <code>disposed</code>
*
*/
public void setLocaleTag(final String localeTag) {
firePropertyChange("localeTag", this.localeTag, this.localeTag = localeTag );
}
/**
* Returns the profileimage property or <code>null</code> if not present.
*/
public String getProfileimage() {
return this.profileimage;
}
/**
* Sets the <code>profileimage</code> property to this instance.
*
* @param profileimage - the property
* @throws RuntimeException if instance is <code>disposed</code>
*
*/
public void setProfileimage(final String profileimage) {
firePropertyChange("profileimage", this.profileimage, this.profileimage = profileimage );
}
/**
* Returns the layoutingStrategy property or <code>null</code> if not present.
*/
public String getLayoutingStrategy() {
return this.layoutingStrategy;
}
/**
* Sets the <code>layoutingStrategy</code> property to this instance.
*
* @param layoutingStrategy - the property
* @throws RuntimeException if instance is <code>disposed</code>
*
*/
public void setLayoutingStrategy(final String layoutingStrategy) {
firePropertyChange("layoutingStrategy", this.layoutingStrategy, this.layoutingStrategy = layoutingStrategy );
}
/**
* Returns the focusingStrategy property or <code>null</code> if not present.
*/
public String getFocusingStrategy() {
return this.focusingStrategy;
}
/**
* Sets the <code>focusingStrategy</code> property to this instance.
*
* @param focusingStrategy - the property
* @throws RuntimeException if instance is <code>disposed</code>
*
*/
public void setFocusingStrategy(final String focusingStrategy) {
firePropertyChange("focusingStrategy", this.focusingStrategy, this.focusingStrategy = focusingStrategy );
}
/**
* Returns the theme property or <code>null</code> if not present.
*/
public String getTheme() {
return this.theme;
}
/**
* Sets the <code>theme</code> property to this instance.
*
* @param theme - the property
* @throws RuntimeException if instance is <code>disposed</code>
*
*/
public void setTheme(final String theme) {
firePropertyChange("theme", this.theme, this.theme = theme );
}
/**
* Returns the printService property or <code>null</code> if not present.
*/
public String getPrintService() {
return this.printService;
}
/**
* Sets the <code>printService</code> property to this instance.
*
* @param printService - the property
* @throws RuntimeException if instance is <code>disposed</code>
*
*/
public void setPrintService(final String printService) {
firePropertyChange("printService", this.printService, this.printService = printService );
}
/**
* Returns an unmodifiable list of userAccountFilter.
*/
public List<UserAccountFilterDto> getUserAccountFilter() {
return Collections.unmodifiableList(internalGetUserAccountFilter());
}
/**
* Returns the list of <code>UserAccountFilterDto</code>s thereby lazy initializing it. For internal use only!
*
* @return list - the resulting list
*
*/
public List<UserAccountFilterDto> internalGetUserAccountFilter() {
if (this.userAccountFilter == null) {
this.userAccountFilter = new java.util.ArrayList<UserAccountFilterDto>();
}
return this.userAccountFilter;
}
/**
* Adds the given userAccountFilterDto to this object. <p>
* Since the reference is a composition reference, the opposite reference <code>UserAccountFilterDto#userAccount</code> of the <code>userAccountFilterDto</code> will be handled automatically and no further coding is required to keep them in sync.<p>
* See {@link UserAccountFilterDto#setUserAccount(UserAccountFilterDto)}.
*
* @param userAccountFilterDto - the property
* @throws RuntimeException if instance is <code>disposed</code>
*
*/
public void addToUserAccountFilter(final UserAccountFilterDto userAccountFilterDto) {
checkDisposed();
userAccountFilterDto.setUserAccount(this);
}
/**
* Removes the given userAccountFilterDto from this object. <p>
*
* @param userAccountFilterDto - the property
* @throws RuntimeException if instance is <code>disposed</code>
*
*/
public void removeFromUserAccountFilter(final UserAccountFilterDto userAccountFilterDto) {
checkDisposed();
userAccountFilterDto.setUserAccount(null);
}
/**
* For internal use only!
*/
public void internalAddToUserAccountFilter(final UserAccountFilterDto userAccountFilterDto) {
if(!MappingContext.isMappingMode()) {
// collections will become resolved! We need to send a delta notification.
List<UserAccountFilterDto> oldList = new java.util.ArrayList<>(internalGetUserAccountFilter());
internalGetUserAccountFilter().add(userAccountFilterDto);
firePropertyChange("userAccountFilter", oldList, internalGetUserAccountFilter());
} else {
// in mapping mode, we do NOT resolve any collection
internalGetUserAccountFilter().add(userAccountFilterDto);
}
}
/**
* For internal use only!
*/
public void internalRemoveFromUserAccountFilter(final UserAccountFilterDto userAccountFilterDto) {
if(!MappingContext.isMappingMode()) {
// collections will become resolved! We need to send a delta notification.
List<UserAccountFilterDto> oldList = new java.util.ArrayList<>(internalGetUserAccountFilter());
internalGetUserAccountFilter().remove(userAccountFilterDto);
firePropertyChange("userAccountFilter", oldList, internalGetUserAccountFilter());
}else{
// in mapping mode, we do NOT resolve any collection
internalGetUserAccountFilter().remove(userAccountFilterDto);
}
}
/**
* Sets the <code>userAccountFilter</code> property to this instance.
* Since the reference has an opposite reference, the opposite <code>UserAccountFilterDto#
* userAccount</code> of the <code>userAccountFilter</code> will be handled automatically and no
* further coding is required to keep them in sync.<p>
* See {@link UserAccountFilterDto#setUserAccount(UserAccountFilterDto)
*
* @param userAccountFilter - the property
* @throws RuntimeException if instance is <code>disposed</code>
*
*/
public void setUserAccountFilter(final List<UserAccountFilterDto> userAccountFilter) {
checkDisposed();
for (UserAccountFilterDto dto : internalGetUserAccountFilter().toArray(new UserAccountFilterDto[this.userAccountFilter.size()])) {
removeFromUserAccountFilter(dto);
}
if(userAccountFilter == null) {
return;
}
for (UserAccountFilterDto dto : userAccountFilter) {
addToUserAccountFilter(dto);
}
}
@Override
public boolean equals(final Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
UserAccountDto other = (UserAccountDto) obj;
if (this.id == null) {
if (other.id != null)
return false;
} else if (!this.id.equals(other.id))
return false;
return true;
}
@Override
public int hashCode() {
int prime = 31;
int result = 1;
result = prime * result + ((this.id== null) ? 0 : this.id.hashCode());
return result;
}
public UserAccountDto createDto() {
return new UserAccountDto();
}
public UserAccountDto copy(final MappingContext context) {
checkDisposed();
if (context == null) {
throw new IllegalArgumentException("Context must not be null!");
}
if(context.isMaxLevel()){
return null;
}
// if context contains a copied instance of this object
// then return it
UserAccountDto newDto = context.get(this);
if(newDto != null){
return newDto;
}
try{
context.increaseLevel();
newDto = createDto();
context.register(this, newDto);
// first copy the containments and attributes
copyContainments(this, newDto, context);
// then copy cross references to ensure proper
// opposite references are copied too.
copyCrossReferences(this, newDto, context);
} finally {
context.decreaseLevel();
}
return newDto;
}
public void copyContainments(final UserAccountDto dto, final UserAccountDto newDto, final MappingContext context) {
checkDisposed();
if (context == null) {
throw new IllegalArgumentException("Context must not be null!");
}
// copy attributes and beans (beans if derived from entity model)
// copy id
newDto.setId(getId());
// copy email
newDto.setEmail(getEmail());
// copy userName
newDto.setUserName(getUserName());
// copy password
newDto.setPassword(getPassword());
// copy extraPassword
newDto.setExtraPassword(getExtraPassword());
// copy passwordReset
newDto.setPasswordReset(getPasswordReset());
// copy position
newDto.setPosition(getPosition());
// copy defaultPerpective
newDto.setDefaultPerpective(getDefaultPerpective());
// copy enabled
newDto.setEnabled(getEnabled());
// copy locked
newDto.setLocked(getLocked());
// copy superuser
newDto.setSuperuser(getSuperuser());
// copy supervisor
newDto.setSupervisor(getSupervisor());
// copy forcePwdChange
newDto.setForcePwdChange(getForcePwdChange());
// copy notRegistered
newDto.setNotRegistered(getNotRegistered());
// copy failedAttempt
newDto.setFailedAttempt(getFailedAttempt());
// copy successfulAttempt
newDto.setSuccessfulAttempt(getSuccessfulAttempt());
// copy cookieHashCode
newDto.setCookieHashCode(getCookieHashCode());
// copy localeTag
newDto.setLocaleTag(getLocaleTag());
// copy profileimage
newDto.setProfileimage(getProfileimage());
// copy layoutingStrategy
newDto.setLayoutingStrategy(getLayoutingStrategy());
// copy focusingStrategy
newDto.setFocusingStrategy(getFocusingStrategy());
// copy theme
newDto.setTheme(getTheme());
// copy printService
newDto.setPrintService(getPrintService());
// copy containment references (cascading is true)
}
public void copyCrossReferences(final UserAccountDto dto, final UserAccountDto newDto, final org.eclipse.osbp.dsl.dto.lib.MappingContext context) {
checkDisposed();
if (context == null) {
throw new IllegalArgumentException("Context must not be null!");
}
// copy cross references (cascading is false)
// copy list of userAccountFilter dtos
for(org.eclipse.osbp.authentication.account.dtos.UserAccountFilterDto _dto : getUserAccountFilter()) {
newDto.addToUserAccountFilter(_dto.copy(context));
}
}
public void propertyChange(final java.beans.PropertyChangeEvent event) {
Object source = event.getSource();
// forward the event from embeddable beans to all listeners. So the parent of the embeddable
// bean will become notified and its dirty state can be handled properly
{
// no super class available to forward event
}
}
}