<commit_before>/*******************************************************************************
 *                                                                              
 *  Copyright FUJITSU LIMITED 2016                                             
 *                                                                              
 *  Author: schmid                                 
 *                                                                              
 *  Creation Date: 21.01.2009                                                      
 *                                                                              
 *  Completion Time:                                             
 *                                                                              
 *******************************************************************************/

package org.oscm.domobjects;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.OrderBy;
import javax.persistence.PrePersist;
import javax.persistence.Transient;

import org.oscm.domobjects.annotations.BusinessKey;
import org.oscm.internal.types.enumtypes.Salutation;
import org.oscm.internal.types.enumtypes.UserAccountStatus;
import org.oscm.internal.types.enumtypes.UserRoleType;

/**
 * PlatformUser represents a registered user of the SaaS platform. A User is
 * always assigned to a dedicated organization. The user is identified with it's
 * UserId string, which has to be unique throughout the whole system.
 * 
 * @author schmid
 */
@Entity
@NamedQueries({
        @NamedQuery(name = "PlatformUser.findByBusinessKey", query = "select obj from PlatformUser obj, "
                + "Organization o, Tenant t where obj.dataContainer.userId=:userId AND obj.organization = o AND o"
                + ".tenant = t AND t.dataContainer.tenantId = :tenantId "),
        @NamedQuery(name = "PlatformUser.findByUserId", query = "select obj from PlatformUser obj, "
                + "Organization o, where obj.dataContainer.userId=:userId AND obj.organization = o AND o"
                + ".tenant is null "),
        @NamedQuery(name = "PlatformUser.findByUserIdAndTenantKey", query = "select obj from PlatformUser obj, "
                + "Organization o, Tenant t where obj.dataContainer.userId=:userId AND obj.organization = o AND o"
                + ".tenant = t AND t.key = :tenantKey "),
        @NamedQuery(name = "PlatformUser.getOverdueOrganizationAdmins", query = "select obj from PlatformUser obj where obj.dataContainer.status = :status and obj.dataContainer.creationDate < :date"),
        @NamedQuery(name = "PlatformUser.getVisibleForOrganization", query = "SELECT DISTINCT pu FROM PlatformUser pu LEFT JOIN FETCH pu.assignedRoles LEFT JOIN FETCH pu.master WHERE pu.organization = :organization AND NOT EXISTS (SELECT ref FROM OnBehalfUserReference ref WHERE ref.slaveUser = pu)"),
        @NamedQuery(name = "PlatformUser.countRegisteredUsers", query = "select count(obj) from PlatformUser obj "),
        @NamedQuery(name = "PlatformUser.listByEmail", query = "select obj from PlatformUser obj where lower(obj.dataContainer.email) = lower(:email)"),
        @NamedQuery(name = "PlatformUser.findByIdPattern", query = "SELECT DISTINCT obj FROM PlatformUser obj where obj.dataContainer.userId like :userId order by obj.dataContainer.userId"),
        @NamedQuery(name = "PlatformUser.findByOrgAndReamUserId", query = "select obj from PlatformUser obj where obj.organization = :organization and obj.dataContainer.realmUserId=:realmUserId"),<commit_msg>fix query for finding platform user in default tenant<commit_after>/*******************************************************************************
 *                                                                              
 *  Copyright FUJITSU LIMITED 2016                                             
 *                                                                              
 *  Author: schmid                                 
 *                                                                              
 *  Creation Date: 21.01.2009                                                      
 *                                                                              
 *  Completion Time:                                             
 *                                                                              
 *******************************************************************************/

package org.oscm.domobjects;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.OrderBy;
import javax.persistence.PrePersist;
import javax.persistence.Transient;

import org.oscm.domobjects.annotations.BusinessKey;
import org.oscm.internal.types.enumtypes.Salutation;
import org.oscm.internal.types.enumtypes.UserAccountStatus;
import org.oscm.internal.types.enumtypes.UserRoleType;

/**
 * PlatformUser represents a registered user of the SaaS platform. A User is
 * always assigned to a dedicated organization. The user is identified with it's
 * UserId string, which has to be unique throughout the whole system.
 * 
 * @author schmid
 */
@Entity
@NamedQueries({
        @NamedQuery(name = "PlatformUser.findByBusinessKey", query = "select obj from PlatformUser obj, "
                + "Organization o, Tenant t where obj.dataContainer.userId=:userId AND obj.organization = o AND o"
                + ".tenant = t AND t.dataContainer.tenantId = :tenantId "),
        @NamedQuery(name = "PlatformUser.findByUserId", query = "select obj from PlatformUser obj, "
                + "Organization o where obj.dataContainer.userId=:userId AND obj.organization = o AND o"
                + ".tenant is null "),
        @NamedQuery(name = "PlatformUser.findByUserIdAndTenantKey", query = "select obj from PlatformUser obj, "
                + "Organization o, Tenant t where obj.dataContainer.userId=:userId AND obj.organization = o AND o"
                + ".tenant = t AND t.key = :tenantKey "),
        @NamedQuery(name = "PlatformUser.getOverdueOrganizationAdmins", query = "select obj from PlatformUser obj where obj.dataContainer.status = :status and obj.dataContainer.creationDate < :date"),
        @NamedQuery(name = "PlatformUser.getVisibleForOrganization", query = "SELECT DISTINCT pu FROM PlatformUser pu LEFT JOIN FETCH pu.assignedRoles LEFT JOIN FETCH pu.master WHERE pu.organization = :organization AND NOT EXISTS (SELECT ref FROM OnBehalfUserReference ref WHERE ref.slaveUser = pu)"),
        @NamedQuery(name = "PlatformUser.countRegisteredUsers", query = "select count(obj) from PlatformUser obj "),
        @NamedQuery(name = "PlatformUser.listByEmail", query = "select obj from PlatformUser obj where lower(obj.dataContainer.email) = lower(:email)"),
        @NamedQuery(name = "PlatformUser.findByIdPattern", query = "SELECT DISTINCT obj FROM PlatformUser obj where obj.dataContainer.userId like :userId order by obj.dataContainer.userId"),
        @NamedQuery(name = "PlatformUser.findByOrgAndReamUserId", query = "select obj from PlatformUser obj where obj.organization = :organization and obj.dataContainer.realmUserId=:realmUserId"),
{'fraction_non_alphanumeric': 0.11886209029066172, 'fraction_numerical': 0.002968460111317254, 'mean_word_length': 2.3846797823357053, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 42, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6960419', 'n_tokens_mistral': 1940, 'n_tokens_neox': 1889, 'n_words': 527}