<?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.*"/>  
        
        <TRANSIENT  name="Password"             type="String"/>
        <TRANSIENT  name="ConfirmPassword"      type="String"/>
        
        <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="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"/>
            
            <SINGLEREFERENCE    name="User"     type="SecUser"  dbcol="user_id"     backreferenceName="Extensions"  inSuper='TRUE'/>
            <SINGLEREFERENCE    name="Company"  type="Company"  dbcol="company_id"  backreferenceName="Users"/>
            
        </TABLE>
        
        <SEARCH type="All"      paramFilter="oneit_sec_user_extension.object_id is not null"    >
        </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>