<?xml version="1.0" encoding="UTF-8"?>

<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='http://www.oneit.com.au/schemas/5.2/BusinessObject.xsd'>

    <BUSINESSCLASS  name="CompanyUser"    package="performa.orm"  superclass="SecUserExtension">
        
        <IMPORT value="oneit.security.*"    />
        <IMPORT value="performa.orm.types.*"/>  
        
        <MULTIPLEREFERENCE  name="HiringTeams"  type="CompanyUserHiringTeamLink"    backreferenceName="CompanyUser" />
        
        <TRANSIENT  name="Email"                type="String"   validators="Email"  />
        <TRANSIENT  name="Password"             type="String"/>
        <TRANSIENT  name="ConfirmPassword"      type="String"/>
        <TRANSIENT  name="PrivacyPolicyAgreed"  type="Boolean"  defaultValue="Boolean.FALSE"/>
        <TRANSIENT  name="ConditionsAgreed"     type="Boolean"  defaultValue="Boolean.FALSE"/>
        
        <TRANSIENTSINGLE name="SelectedTeam"    type="HiringTeam"   />

        <TABLE  name="oneit_sec_user_extension" tablePrefix="object"    polymorphic="TRUE">

            <ATTRIB name="ForgotPasswordMailSendDate"   type="Date"                 dbcol="forgot_password_mail_send_date" />
            <ATTRIB name="ForgotPasswordKey"            type="String"               dbcol="forgot_password_key"     length="10"/>
            <ATTRIB name="Role"                         type="RoleType"             dbcol="role_type"               mandatory="false"   attribHelper="EnumeratedAttributeHelper"/>
            <ATTRIB name="Roles"                        type="Set&lt;RoleType&gt;"  dbcol="roles"                   mandatory="false"   attribHelper="DelimitedEnumsAttributeHelper"     attribHelperInstance="new DelimitedEnumsAttributeHelper (RoleType.FACTORY_RoleType)"/>
            <ATTRIB name="Phone"                        type="String"               dbcol="phone"                   mandatory="false"    length="30"    />
            <ATTRIB name="VerificationMailSendDate"     type="Date"                 dbcol="verification_mail_send_date" />
            <ATTRIB name="VerificationKey"              type="String"               dbcol="verification_key"        length="10"/>
            <ATTRIB name="IsAccountVerified"            type="Boolean"              dbcol="is_account_verified"     defaultValue="Boolean.FALSE"/>
            <ATTRIB name="IsEmailChanged"               type="Boolean"              dbcol="is_email_changed"        defaultValue="Boolean.FALSE"/>
            <ATTRIB name="IsDisabled"                   type="Boolean"              dbcol="is_disabled"             defaultValue="Boolean.FALSE"/>
            
            <SINGLEREFERENCE    name="User"                 type="SecUser"      dbcol="user_id"                 backreferenceName="Extensions"  inSuper='TRUE'/>
            <SINGLEREFERENCE    name="Company"              type="Company"      dbcol="company_id"              backreferenceName="Users"/>
            <SINGLEREFERENCE    name="DefaultHiringTeam"    type="HiringTeam"   dbcol="default_hiring_team_id"  />

        </TABLE>
        
        <SEARCH type="All"      paramFilter="oneit_sec_user_extension.object_id is not null and oneit_sec_user_extension.object_type = 'CompanyUser'"    >
        </SEARCH>
        
        <SEARCH type="AllCompanyUsers"  paramFilter="oneit_sec_user_extension.object_id is not null">
            <PARAM name="ReferenceExtension"    type="SecUserExtension"     transform="context.getTag (ReferenceExtension)" paramFilter="oneit_sec_user_extension.object_type = ${ReferenceExtension}"/>
        </SEARCH>
        
        <SEARCH type="IdPin"    paramFilter="oneit_sec_user_extension.object_id is not null"    singleton="TRUE">
            <PARAM name="ID"    type="Long"     paramFilter="object_id = ${ID} " />
            <PARAM name="Pin"   type="String"   paramFilter="verification_key = ${Pin}" />
        </SEARCH>
        
    </BUSINESSCLASS>
    
</ROOT>