<?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="Job"  package="performa.orm">
        <IMPORT value="performa.orm.types.*"/>    
        <IMPORT value="oneit.security.*"/>
        <IMPORT value="oneit.business.shopping.orm.*"/>

        <MULTIPLEREFERENCE  name="JobApplications"      type="JobApplication"       backreferenceName="Job" />
        <MULTIPLEREFERENCE  name="AssessmentCriterias"  type="AssessmentCriteria"   backreferenceName="Job" />
        <MULTIPLEREFERENCE  name="CultureCriterias"     type="CultureCriteria"      backreferenceName="Job" />
        
        <TRANSIENT  name="Email"                    type="String"           validators="Email"  />
        <TRANSIENT  name="Password"                 type="String"/>
        <TRANSIENT  name="ConfirmPassword"          type="String"/>
        <TRANSIENT  name="CompletedDetails"         type="Boolean"          defaultValue="Boolean.FALSE"/>
        <TRANSIENT  name="CompletedRequirements"    type="Boolean"          defaultValue="Boolean.FALSE"/>
        <TRANSIENT  name="CompletedCulture"         type="Boolean"          defaultValue="Boolean.FALSE"/>
        <TRANSIENT  name="CompletedAssessmentType"  type="Boolean"          defaultValue="Boolean.FALSE"/>
        <TRANSIENT  name="SaveAssessmentTemplate"   type="Boolean"          defaultValue="Boolean.FALSE"/>
        <TRANSIENT  name="SaveCultureTemplate"      type="Boolean"          defaultValue="Boolean.FALSE"/>
        <TRANSIENT  name="AssessmentTemplateName"   type="String"/>
        <TRANSIENT  name="CultureTemplateName"      type="String"/>
        <TRANSIENT  name="AppProcessOption"         type="AppProcessOption" attribHelper="EnumeratedAttributeHelper"/>
        <TRANSIENT  name="RankingCompleted"         type="Boolean"  />

        <TRANSIENTSINGLE name="AssessmentTemplate"  type="AssessmentCriteriaTemplate" />
        <TRANSIENTSINGLE name="CultureTemplate"     type="CultureCriteriaTemplate" />
        <TRANSIENTSINGLE name="JobTemplate"         type="Job" />
        
        <TABLE  name="tl_job"   tablePrefix="object"    polymorphic="FALSE">
            
            <ATTRIB name="JobTitle"                     type="String"           dbcol="job_title"       length="500"    mandatory="true"/>
            <ATTRIB name="JobDescription"               type="String"           dbcol="job_description" mandatory="true"/>
            <ATTRIB name="JobStatus"                    type="JobStatus"        dbcol="job_status"      attribHelper="EnumeratedAttributeHelper"    mandatory="true"/>
            <ATTRIB name="OpenDate"                     type="Date"             dbcol="open_date"/>
            <ATTRIB name="ApplyBy"                      type="Date"             dbcol="apply_by"/>
            <ATTRIB name="IncludeAssessmentCriteria"    type="Boolean"          dbcol="include_assessment_criteria" mandatory="true"    defaultValue="Boolean.FALSE"/>
            <ATTRIB name="AssessmentType"               type="AssessmentType"   dbcol="assessment_type" attribHelper="EnumeratedAttributeHelper"    mandatory="true"    defaultValue="AssessmentType.COMPREHENSIVE"/>
            <ATTRIB name="RandomKey"                    type="String"           dbcol="random_key"      length="10"/>
            <ATTRIB name="JobType"                      type="JobType"          dbcol="job_type"        attribHelper="EnumeratedAttributeHelper"    mandatory="true"    defaultValue="JobType.FULL_TIME"/>
            <ATTRIB name="ReferenceNumber"              type="String"           dbcol="ref_number"      length="100"/>
            <ATTRIB name="LastStatusChangeDate"         type="Date"             dbcol="last_status_change_date"/>
            <ATTRIB name="Remote"                       type="Boolean"          dbcol="remote"          defaultValue="Boolean.FALSE"/>
            <ATTRIB name="City"                         type="String"           dbcol="city"            length="100"/>
            <ATTRIB name="State"                        type="State"            dbcol="state"           defaultValue="State.WA"     attribHelper="EnumeratedAttributeHelper"/>
            <ATTRIB name="Country"                      type="Countries"        dbcol="country"         defaultValue="Countries.AU" attribHelper="EnumeratedAttributeHelper"/>
            <ATTRIB name="IsManuallyClosed"             type="Boolean"          dbcol="manually_closed" defaultValue="Boolean.FALSE"/>
            <ATTRIB name="LastEdited"                   type="Date"             dbcol="last_edited"     />

            <SINGLEREFERENCE    name="Level"        type="Level"        dbcol="level_id"    mandatory="false"/>
            <SINGLEREFERENCE    name="Client"       type="Client"       dbcol="client_id"   backreferenceName="Jobs"/>
            <SINGLEREFERENCE    name="CompanyUser"  type="CompanyUser"  dbcol="company_user_id" />
            <SINGLEREFERENCE    name="ShortenedURL" type="ShortenedURL" dbcol="shortened_url_id" />
            
        </TABLE>
        
        <SEARCH type="All"  paramFilter="tl_job.object_id is not null"   orderBy="tl_job.object_id"   />
        
        <SEARCH type="JobKey" paramFilter="tl_job.object_id is not null"   singleton="TRUE">
            <PARAM name="ID"    type="Long"     paramFilter="object_id = ${ID} " />
            <PARAM name="Key"   type="String"   paramFilter="random_key = ${Key}" />
        </SEARCH>
            
        <SEARCH type="Company"    paramFilter="tl_job.object_id is not null"  orderBy="tl_job.object_id">
            <TABLE  name="oneit_sec_user_extension" join="oneit_sec_user_extension.object_id = tl_job.company_user_id"/>
            <TABLE  name="tl_company"               join="tl_company.object_id = oneit_sec_user_extension.company_id"/>
            <PARAM name="Company"   type="Company"  transform="Company.getObjectID ()"  paramFilter="tl_company.object_id = ${Company}"/>
        </SEARCH>
    </BUSINESSCLASS>
    
</ROOT>