Commit d070edcb by chenith Committed by Harsh Shah

Implement client and company related business objects.

Replaced AdminUser ext by CompanyUser.
parent 159dfb4a
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">tl_industry</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="NAME" type="String" nullable="false" length="200"/>
<column name="VALUE" type="String" nullable="false" length="200"/>
<column name="DESCRIPTION" type="String" nullable="true" length="200"/>
<column name="SORT_ORDER" type="Long" nullable="false"/>
<column name="DISABLED" type="Boolean" nullable="false"/>
</NODE>
</NODE></OBJECTS>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">tl_client</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="object_type" type="String" nullable="false" length="30"/>
<column name="company_name" type="String" nullable="false" length="100"/>
<column name="company_logo" type="BLOB" nullable="true"/>
<column name="email" type="String" nullable="true" length="100"/>
<column name="contact_name" type="String" nullable="true" length="100"/>
<column name="contact_surname" type="String" nullable="true" length="100"/>
<column name="phone" type="String" nullable="true" length="30"/>
<column name="state" type="String" nullable="true" length="200"/>
<column name="country" type="String" nullable="true" length="200"/>
<column name="post_code" type="String" nullable="true" length="10"/>
<column name="company_id" type="Long" length="11" nullable="true"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_client" indexName="idx_tl_client_company_id" isUnique="false"><column name="company_id"/></NODE>
</NODE></OBJECTS>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">tl_company</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="object_type" type="String" nullable="false" length="30"/>
<column name="company_name" type="String" nullable="false" length="100"/>
<column name="hiring_team_type" type="String" nullable="true" length="200"/>
<column name="industry" type="String" nullable="true" length="200"/>
<column name="time_zone" type="String" nullable="true" length="200"/>
<column name="added_by_user_id" type="Long" length="11" nullable="false"/>
</NODE>
</NODE></OBJECTS>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">oneit_sec_user_extension</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="object_type" type="String" nullable="false" length="30"/>
<column name="forgot_password_mail_send_date" type="Date" nullable="true"/>
<column name="forgot_password_key" type="String" nullable="true" length="10"/>
<column name="role_type" type="String" nullable="true" length="200"/>
<column name="phone" type="String" nullable="true" length="30"/>
<column name="user_id" type="Long" length="11" nullable="true"/>
<column name="company_id" type="Long" length="11" nullable="true"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="oneit_sec_user_extension" indexName="idx_oneit_sec_user_extension_user_id" isUnique="false"><column name="user_id"/></NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="oneit_sec_user_extension" indexName="idx_oneit_sec_user_extension_company_id" isUnique="false"><column name="company_id"/></NODE>
</NODE></OBJECTS>
\ No newline at end of file
......@@ -24,7 +24,8 @@
<column name="state" type="String" nullable="true" length="200"/>
<column name="country" type="String" nullable="true" length="200"/>
<column name="level_id" type="Long" length="11" nullable="false"/>
<column name="secuser_id" type="Long" length="11" nullable="true"/>
<column name="client_id" type="Long" length="11" nullable="true"/>
<column name="company_user_id" type="Long" length="11" nullable="true"/>
</NODE>
</NODE></OBJECTS>
\ No newline at end of file
-- DROP TABLE tl_industry;
CREATE TABLE tl_industry (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
NAME varchar(200) NOT NULL,
VALUE varchar(200) NOT NULL,
DESCRIPTION varchar(200) NULL,
SORT_ORDER numeric(12) NOT NULL ,
DISABLED char(1) NOT NULL
);
ALTER TABLE tl_industry ADD
CONSTRAINT PK_tl_industry PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- DROP TABLE tl_client;
CREATE TABLE tl_client (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
, object_type varchar(30) NOT NULL ,
company_name varchar(100) NOT NULL,
company_logo image NULL,
email varchar(100) NULL,
contact_name varchar(100) NULL,
contact_surname varchar(100) NULL,
phone varchar(30) NULL,
state varchar(200) NULL,
country varchar(200) NULL,
post_code varchar(10) NULL,
company_id numeric(12) NULL
);
ALTER TABLE tl_client ADD
CONSTRAINT PK_tl_client PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_tl_client_company_id
ON tl_client (company_id);
-- DROP TABLE tl_Company;
CREATE TABLE tl_Company (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
, object_type varchar(30) NOT NULL ,
company_name varchar(100) NOT NULL,
hiring_team_type varchar(200) NULL,
industry varchar(200) NULL,
time_zone varchar(200) NULL,
added_by_user_id numeric(12) NOT NULL
);
ALTER TABLE tl_Company ADD
CONSTRAINT PK_tl_Company PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- DROP TABLE oneit_sec_user_extension;
CREATE TABLE oneit_sec_user_extension (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
, object_type varchar(30) NOT NULL ,
forgot_password_mail_send_date datetime NULL,
forgot_password_key varchar(10) NULL,
role_type varchar(200) NULL,
phone varchar(30) NULL,
user_id numeric(12) NULL,
company_id numeric(12) NULL
);
ALTER TABLE oneit_sec_user_extension ADD
CONSTRAINT PK_oneit_sec_user_extension PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_oneit_sec_user_extension_user_id
ON oneit_sec_user_extension (user_id);
CREATE INDEX idx_oneit_sec_user_extension_company_id
ON oneit_sec_user_extension (company_id);
......@@ -24,7 +24,8 @@ CREATE TABLE tl_job (
state varchar(200) NULL,
country varchar(200) NULL,
level_id numeric(12) NOT NULL,
secuser_id numeric(12) NULL
client_id numeric(12) NULL,
company_user_id numeric(12) NULL
);
......
-- DROP TABLE tl_industry;
CREATE TABLE tl_industry (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
NAME varchar2(200) NOT NULL,
VALUE varchar2(200) NOT NULL,
DESCRIPTION varchar2(200) NULL,
SORT_ORDER number(12) NOT NULL ,
DISABLED char(1) NOT NULL
);
ALTER TABLE tl_industry ADD
CONSTRAINT PK_tl_industry PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- DROP TABLE tl_client;
CREATE TABLE tl_client (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
, object_type varchar2(30) NOT NULL ,
company_name varchar2(100) NOT NULL,
company_logo blob NULL,
email varchar2(100) NULL,
contact_name varchar2(100) NULL,
contact_surname varchar2(100) NULL,
phone varchar2(30) NULL,
state varchar2(200) NULL,
country varchar2(200) NULL,
post_code varchar2(10) NULL,
company_id number(12) NULL
);
ALTER TABLE tl_client ADD
CONSTRAINT PK_tl_client PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_tl_client_company_id
ON tl_client (company_id);
-- DROP TABLE tl_Company;
CREATE TABLE tl_Company (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
, object_type varchar2(30) NOT NULL ,
company_name varchar2(100) NOT NULL,
hiring_team_type varchar2(200) NULL,
industry varchar2(200) NULL,
time_zone varchar2(200) NULL,
added_by_user_id number(12) NOT NULL
);
ALTER TABLE tl_Company ADD
CONSTRAINT PK_tl_Company PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- DROP TABLE oneit_sec_user_extension;
CREATE TABLE oneit_sec_user_extension (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
, object_type varchar2(30) NOT NULL ,
forgot_password_mail_send_date date NULL,
forgot_password_key varchar2(10) NULL,
role_type varchar2(200) NULL,
phone varchar2(30) NULL,
user_id number(12) NULL,
company_id number(12) NULL
);
ALTER TABLE oneit_sec_user_extension ADD
CONSTRAINT PK_oneit_sec_user_extension PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_oneit_sec_user_extension_user_id
ON oneit_sec_user_extension (user_id);
CREATE INDEX idx_oneit_sec_user_extension_company_id
ON oneit_sec_user_extension (company_id);
......@@ -25,7 +25,8 @@ CREATE TABLE tl_job (
state varchar2(200) NULL,
country varchar2(200) NULL,
level_id number(12) NOT NULL,
secuser_id number(12) NULL
client_id number(12) NULL,
company_user_id number(12) NULL
);
......
-- @AutoRun
-- drop table tl_industry;
CREATE TABLE tl_industry (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
NAME varchar(200) NOT NULL,
VALUE varchar(200) NOT NULL,
DESCRIPTION varchar(200) NULL,
SORT_ORDER numeric(12) NOT NULL ,
DISABLED char(1) NOT NULL
);
ALTER TABLE tl_industry ADD
CONSTRAINT pk_tl_industry PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- @AutoRun
-- drop table tl_client;
CREATE TABLE tl_client (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
, object_type varchar(30) NOT NULL ,
company_name varchar(100) NOT NULL,
company_logo bytea NULL,
email varchar(100) NULL,
contact_name varchar(100) NULL,
contact_surname varchar(100) NULL,
phone varchar(30) NULL,
state varchar(200) NULL,
country varchar(200) NULL,
post_code varchar(10) NULL,
company_id numeric(12) NULL
);
ALTER TABLE tl_client ADD
CONSTRAINT pk_tl_client PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_tl_client_company_id
ON tl_client (company_id);
-- @AutoRun
-- drop table tl_company;
CREATE TABLE tl_company (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
, object_type varchar(30) NOT NULL ,
company_name varchar(100) NOT NULL,
hiring_team_type varchar(200) NULL,
industry varchar(200) NULL,
time_zone varchar(200) NULL,
added_by_user_id numeric(12) NOT NULL
);
ALTER TABLE tl_company ADD
CONSTRAINT pk_tl_company PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- @AutoRun
-- drop table oneit_sec_user_extension;
CREATE TABLE oneit_sec_user_extension (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
, object_type varchar(30) NOT NULL ,
forgot_password_mail_send_date timestamp NULL,
forgot_password_key varchar(10) NULL,
role_type varchar(200) NULL,
phone varchar(30) NULL,
user_id numeric(12) NULL,
company_id numeric(12) NULL
);
ALTER TABLE oneit_sec_user_extension ADD
CONSTRAINT pk_oneit_sec_user_extension PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_oneit_sec_user_extension_user_id
ON oneit_sec_user_extension (user_id);
CREATE INDEX idx_oneit_sec_user_extension_company_id
ON oneit_sec_user_extension (company_id);
......@@ -25,7 +25,8 @@ CREATE TABLE tl_job (
state varchar(200) NULL,
country varchar(200) NULL,
level_id numeric(12) NOT NULL,
secuser_id numeric(12) NULL
client_id numeric(12) NULL,
company_user_id numeric(12) NULL
);
......
......@@ -18,7 +18,7 @@ import oneit.utils.transform.MapTransform;
import oneit.utils.transform.param.ErrorTransform;
import oneit.utils.transform.param.ORMTransform;
import oneit.utils.transform.param.PrefixCompoundTransform;
import performa.orm.AdminUser;
import performa.orm.CompanyUser;
public class ForgotPasswordFP extends SaveFP
......@@ -58,21 +58,21 @@ public class ForgotPasswordFP extends SaveFP
{
LogMgr.log(LOG, LogLevel.PROCESSING1, "Inside ForgotPasswordFP for send reset pasword link mail to ", email);
AdminUser adminUser = secUser.getExtensionOrCreate(AdminUser.REFERENCE_AdminUser);
CompanyUser companyUser = secUser.getExtensionOrCreate(CompanyUser.REFERENCE_CompanyUser);
if(adminUser.getForgotPasswordKey()==null)
if(companyUser.getForgotPasswordKey()==null)
{
String resetCode = new RandomStringGen().generateHumanAlphaNum(new Integer(DEFAULT_PASSWORD_LENGTH));
adminUser.setForgotPasswordKey(resetCode);
companyUser.setForgotPasswordKey(resetCode);
}
adminUser.setForgotPasswordMailSendDate(new Date());
companyUser.setForgotPasswordMailSendDate(new Date());
Map emailParams = CollectionUtils.mapEntry("resetcode", adminUser.getForgotPasswordKey())
Map emailParams = CollectionUtils.mapEntry("resetcode", companyUser.getForgotPasswordKey())
.mapEntry("url", LoopbackHTTP.getRemoteAccessURL()
+ "/extensions/adminportal/reset_password.jsp"
+ "?id=" + adminUser.getID()
+ "&key=" + adminUser.getForgotPasswordKey()).toMap();
+ "?id=" + companyUser.getID()
+ "&key=" + companyUser.getForgotPasswordKey()).toMap();
PrefixCompoundTransform compoundTransform = new PrefixCompoundTransform();
ObjectTransform defaultTransform = new MapTransform(emailParams);
......
......@@ -8,7 +8,7 @@ import oneit.security.SecUser;
import oneit.servlets.forms.*;
import oneit.servlets.process.*;
import oneit.utils.*;
import performa.orm.AdminUser;
import performa.orm.CompanyUser;
import performa.utils.Utils;
......@@ -21,13 +21,13 @@ public class ResetPasswordFP extends ORMProcessFormProcessor
public SuccessfulResult processForm(ORMProcessState process, SubmissionDetails submission, Map params) throws BusinessException, StorageException
{
SecUser user = (SecUser) process.getAttribute("SecUser");
AdminUser adminUser = user.getExtension(AdminUser.REFERENCE_AdminUser);
CompanyUser companyUser = user.getExtension(CompanyUser.REFERENCE_CompanyUser);
if(adminUser != null)
if(companyUser != null)
{
LogMgr.log(LOG, LogLevel.PROCESSING1, "Inside ResetPasswordFP for reset pasword to ", user);
adminUser.setForgotPasswordKey(null);
companyUser.setForgotPasswordKey(null);
}
return Utils.processSuccessfulLogin(process, submission, params, user);
......
<?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="AdminUser" package="performa.orm" superclass="SecUserExtension">
<IMPORT value="oneit.security.*" />
<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"/>
<SINGLEREFERENCE name="User" type="SecUser" dbcol="user_id" backreferenceName="Extensions" inSuper='TRUE'/>
</TABLE>
<SEARCH type="All" paramFilter="oneit_sec_user_extension.object_id is not null" >
</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>
\ No newline at end of file
/*
* IMPORTANT!!!! XSL Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2 rev3 [oneit.objstore.BusinessObjectTemplate.xsl]
*
* Version: 1.0
* Vendor: Apache Software Foundation (Xalan XSLTC)
* Vendor URL: http://xml.apache.org/xalan-j
*/
package performa.orm;
import java.io.*;
import java.util.*;
import oneit.appservices.config.*;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.attributes.*;
import oneit.objstore.rdbms.filters.*;
import oneit.objstore.parser.*;
import oneit.objstore.validator.*;
import oneit.objstore.utils.*;
import oneit.utils.*;
import oneit.utils.filter.Filter;
import oneit.utils.transform.*;
import oneit.utils.parsers.FieldException;
import performa.orm.types.*;
import oneit.business.shopping.orm.*;
public abstract class BaseClient extends BaseBusinessClass
{
// Reference instance for the object
public static final Client REFERENCE_Client = new Client ();
// Reference instance for the object
public static final Client DUMMY_Client = new DummyClient ();
// Static constants corresponding to field names
public static final String FIELD_CompanyName = "CompanyName";
public static final String FIELD_CompanyLogo = "CompanyLogo";
public static final String FIELD_Email = "Email";
public static final String FIELD_ContactName = "ContactName";
public static final String FIELD_ContactSurname = "ContactSurname";
public static final String FIELD_Phone = "Phone";
public static final String FIELD_State = "State";
public static final String FIELD_Country = "Country";
public static final String FIELD_PostCode = "PostCode";
public static final String SINGLEREFERENCE_Company = "Company";
public static final String BACKREF_Company = "";
// Static constants corresponding to searches
public static final String SEARCH_All = "All";
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper<Client> HELPER_CompanyName = DefaultAttributeHelper.INSTANCE;
private static final BLOBAttributeHelper HELPER_CompanyLogo = BLOBAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<Client> HELPER_Email = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<Client> HELPER_ContactName = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<Client> HELPER_ContactSurname = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<Client> HELPER_Phone = DefaultAttributeHelper.INSTANCE;
private static final EnumeratedAttributeHelper<Client, State> HELPER_State = new EnumeratedAttributeHelper<Client, State> (State.FACTORY_State);
private static final EnumeratedAttributeHelper<Client, Countries> HELPER_Country = new EnumeratedAttributeHelper<Client, Countries> (Countries.FACTORY_Countries);
private static final DefaultAttributeHelper<Client> HELPER_PostCode = DefaultAttributeHelper.INSTANCE;
// Private attributes corresponding to business object data
private String _CompanyName;
private BinaryContent _CompanyLogo;
private String _Email;
private String _ContactName;
private String _ContactSurname;
private String _Phone;
private State _State;
private Countries _Country;
private String _PostCode;
// Private attributes corresponding to single references
private SingleAssociation<Client, Company> _Company;
// Private attributes corresponding to multiple references
// Map of maps of metadata
private static final Map ATTRIBUTES_METADATA_Client = new HashMap ();
// Arrays of validators for each attribute
private static final AttributeValidator[] FIELD_CompanyName_Validators;
private static final AttributeValidator[] FIELD_CompanyLogo_Validators;
private static final AttributeValidator[] FIELD_Email_Validators;
private static final AttributeValidator[] FIELD_ContactName_Validators;
private static final AttributeValidator[] FIELD_ContactSurname_Validators;
private static final AttributeValidator[] FIELD_Phone_Validators;
private static final AttributeValidator[] FIELD_State_Validators;
private static final AttributeValidator[] FIELD_Country_Validators;
private static final AttributeValidator[] FIELD_PostCode_Validators;
// Arrays of behaviour decorators
private static final ClientBehaviourDecorator[] Client_BehaviourDecorators;
static
{
try
{
String tmp_Company = Company.BACKREF_Clients;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_Company();
FIELD_CompanyName_Validators = (AttributeValidator[])setupAttribMetaData_CompanyName(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_CompanyLogo_Validators = (AttributeValidator[])setupAttribMetaData_CompanyLogo(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_Email_Validators = (AttributeValidator[])setupAttribMetaData_Email(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_ContactName_Validators = (AttributeValidator[])setupAttribMetaData_ContactName(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_ContactSurname_Validators = (AttributeValidator[])setupAttribMetaData_ContactSurname(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_Phone_Validators = (AttributeValidator[])setupAttribMetaData_Phone(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_State_Validators = (AttributeValidator[])setupAttribMetaData_State(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_Country_Validators = (AttributeValidator[])setupAttribMetaData_Country(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_PostCode_Validators = (AttributeValidator[])setupAttribMetaData_PostCode(validatorMapping).toArray (new AttributeValidator[0]);
REFERENCE_Client.initialiseReference ();
DUMMY_Client.initialiseReference ();
Client_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(Client.class).toArray(new ClientBehaviourDecorator[0]);
}
catch (RuntimeException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
throw e;
}
}
// Meta Info setup
private static void setupAssocMetaData_Company()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Clients");
metaInfo.put ("dbcol", "company_id");
metaInfo.put ("name", "Company");
metaInfo.put ("type", "Company");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Client.Company:", metaInfo);
ATTRIBUTES_METADATA_Client.put (SINGLEREFERENCE_Company, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static List setupAttribMetaData_CompanyName(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "company_name");
metaInfo.put ("length", "100");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "CompanyName");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Client.CompanyName:", metaInfo);
ATTRIBUTES_METADATA_Client.put (FIELD_CompanyName, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(Client.class, "CompanyName", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Client.CompanyName:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_CompanyLogo(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("attribHelper", "BLOBAttributeHelper");
metaInfo.put ("attribHelperInstance", "BLOBAttributeHelper.INSTANCE");
metaInfo.put ("binaryHandler", "loggedin");
metaInfo.put ("dbcol", "company_logo");
metaInfo.put ("mandatory", "false");
metaInfo.put ("name", "CompanyLogo");
metaInfo.put ("type", "BinaryContent");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Client.CompanyLogo:", metaInfo);
ATTRIBUTES_METADATA_Client.put (FIELD_CompanyLogo, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(Client.class, "CompanyLogo", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Client.CompanyLogo:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_Email(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "email");
metaInfo.put ("length", "100");
metaInfo.put ("mandatory", "false");
metaInfo.put ("name", "Email");
metaInfo.put ("type", "String");
metaInfo.put ("validators", "Email");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Client.Email:", metaInfo);
ATTRIBUTES_METADATA_Client.put (FIELD_Email, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(Client.class, "Email", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Client.Email:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_ContactName(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "contact_name");
metaInfo.put ("length", "100");
metaInfo.put ("mandatory", "false");
metaInfo.put ("name", "ContactName");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Client.ContactName:", metaInfo);
ATTRIBUTES_METADATA_Client.put (FIELD_ContactName, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(Client.class, "ContactName", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Client.ContactName:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_ContactSurname(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "contact_surname");
metaInfo.put ("length", "100");
metaInfo.put ("mandatory", "false");
metaInfo.put ("name", "ContactSurname");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Client.ContactSurname:", metaInfo);
ATTRIBUTES_METADATA_Client.put (FIELD_ContactSurname, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(Client.class, "ContactSurname", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Client.ContactSurname:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_Phone(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "phone");
metaInfo.put ("length", "30");
metaInfo.put ("mandatory", "false");
metaInfo.put ("name", "Phone");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Client.Phone:", metaInfo);
ATTRIBUTES_METADATA_Client.put (FIELD_Phone, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(Client.class, "Phone", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Client.Phone:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_State(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("attribHelper", "EnumeratedAttributeHelper");
metaInfo.put ("dbcol", "state");
metaInfo.put ("defaultValue", "State.WA");
metaInfo.put ("mandatory", "false");
metaInfo.put ("name", "State");
metaInfo.put ("type", "State");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Client.State:", metaInfo);
ATTRIBUTES_METADATA_Client.put (FIELD_State, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(Client.class, "State", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Client.State:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_Country(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("attribHelper", "EnumeratedAttributeHelper");
metaInfo.put ("dbcol", "country");
metaInfo.put ("defaultValue", "Countries.AU");
metaInfo.put ("mandatory", "false");
metaInfo.put ("name", "Country");
metaInfo.put ("type", "Countries");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Client.Country:", metaInfo);
ATTRIBUTES_METADATA_Client.put (FIELD_Country, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(Client.class, "Country", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Client.Country:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_PostCode(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "post_code");
metaInfo.put ("length", "10");
metaInfo.put ("mandatory", "false");
metaInfo.put ("name", "PostCode");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Client.PostCode:", metaInfo);
ATTRIBUTES_METADATA_Client.put (FIELD_PostCode, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(Client.class, "PostCode", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Client.PostCode:", validators);
return validators;
}
// END OF STATIC METADATA DEFINITION
// This constructor should not be called
protected BaseClient ()
{
}
protected BBCBehaviourDecorator[] getBehaviours()
{
return Client_BehaviourDecorators;
}
// Initialise the attributes
protected void _initialiseNewObjAttributes (ObjectTransaction transaction) throws StorageException
{
super._initialiseNewObjAttributes (transaction);
_CompanyName = (String)(HELPER_CompanyName.initialise (_CompanyName));
_CompanyLogo = (BinaryContent)(HELPER_CompanyLogo.initialise (_CompanyLogo));
_Email = (String)(HELPER_Email.initialise (_Email));
_ContactName = (String)(HELPER_ContactName.initialise (_ContactName));
_ContactSurname = (String)(HELPER_ContactSurname.initialise (_ContactSurname));
_Phone = (String)(HELPER_Phone.initialise (_Phone));
_State = (State)(State.WA);
_Country = (Countries)(Countries.AU);
_PostCode = (String)(HELPER_PostCode.initialise (_PostCode));
}
// Initialise the associations
protected void _initialiseAssociations ()
{
super._initialiseAssociations ();
_Company = new SingleAssociation<Client, Company> (this, SINGLEREFERENCE_Company, Company.MULTIPLEREFERENCE_Clients, Company.REFERENCE_Company, "tl_client");
}
// Initialise the associations
protected BaseBusinessClass initialiseReference ()
{
super.initialiseReference ();
_Company = new SingleAssociation<Client, Company> (this, SINGLEREFERENCE_Company, Company.MULTIPLEREFERENCE_Clients, Company.REFERENCE_Company, "tl_client");
return this;
}
/**
* Get the attribute CompanyName
*/
public String getCompanyName ()
{
assertValid();
String valToReturn = _CompanyName;
for (ClientBehaviourDecorator bhd : Client_BehaviourDecorators)
{
valToReturn = bhd.getCompanyName ((Client)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preCompanyNameChange (String newCompanyName) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postCompanyNameChange () throws FieldException
{
}
public FieldWriteability getWriteability_CompanyName ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute CompanyName. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setCompanyName (String newCompanyName) throws FieldException
{
boolean oldAndNewIdentical = HELPER_CompanyName.compare (_CompanyName, newCompanyName);
try
{
for (ClientBehaviourDecorator bhd : Client_BehaviourDecorators)
{
newCompanyName = bhd.setCompanyName ((Client)this, newCompanyName);
oldAndNewIdentical = HELPER_CompanyName.compare (_CompanyName, newCompanyName);
}
BusinessObjectParser.assertFieldCondition (newCompanyName != null, this, FIELD_CompanyName, "mandatory");
if (FIELD_CompanyName_Validators.length > 0)
{
Object newCompanyNameObj = HELPER_CompanyName.toObject (newCompanyName);
if (newCompanyNameObj != null)
{
int loopMax = FIELD_CompanyName_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_Client.get (FIELD_CompanyName);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_CompanyName_Validators[v].checkAttribute (this, FIELD_CompanyName, metadata, newCompanyNameObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_CompanyName () != FieldWriteability.FALSE, "Field CompanyName is not writeable");
preCompanyNameChange (newCompanyName);
markFieldChange (FIELD_CompanyName);
_CompanyName = newCompanyName;
postFieldChange (FIELD_CompanyName);
postCompanyNameChange ();
}
}
/**
* Get the attribute CompanyLogo
*/
public BinaryContent getCompanyLogo ()
{
assertValid();
BinaryContent valToReturn = _CompanyLogo;
for (ClientBehaviourDecorator bhd : Client_BehaviourDecorators)
{
valToReturn = bhd.getCompanyLogo ((Client)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preCompanyLogoChange (BinaryContent newCompanyLogo) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postCompanyLogoChange () throws FieldException
{
}
public FieldWriteability getWriteability_CompanyLogo ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute CompanyLogo. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setCompanyLogo (BinaryContent newCompanyLogo) throws FieldException
{
boolean oldAndNewIdentical = HELPER_CompanyLogo.compare (_CompanyLogo, newCompanyLogo);
try
{
for (ClientBehaviourDecorator bhd : Client_BehaviourDecorators)
{
newCompanyLogo = bhd.setCompanyLogo ((Client)this, newCompanyLogo);
oldAndNewIdentical = HELPER_CompanyLogo.compare (_CompanyLogo, newCompanyLogo);
}
if (FIELD_CompanyLogo_Validators.length > 0)
{
Object newCompanyLogoObj = HELPER_CompanyLogo.toObject (newCompanyLogo);
if (newCompanyLogoObj != null)
{
int loopMax = FIELD_CompanyLogo_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_Client.get (FIELD_CompanyLogo);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_CompanyLogo_Validators[v].checkAttribute (this, FIELD_CompanyLogo, metadata, newCompanyLogoObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_CompanyLogo () != FieldWriteability.FALSE, "Field CompanyLogo is not writeable");
preCompanyLogoChange (newCompanyLogo);
markFieldChange (FIELD_CompanyLogo);
_CompanyLogo = newCompanyLogo;
postFieldChange (FIELD_CompanyLogo);
postCompanyLogoChange ();
}
}
/**
* Get the attribute Email
*/
public String getEmail ()
{
assertValid();
String valToReturn = _Email;
for (ClientBehaviourDecorator bhd : Client_BehaviourDecorators)
{
valToReturn = bhd.getEmail ((Client)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preEmailChange (String newEmail) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postEmailChange () throws FieldException
{
}
public FieldWriteability getWriteability_Email ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute Email. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setEmail (String newEmail) throws FieldException
{
boolean oldAndNewIdentical = HELPER_Email.compare (_Email, newEmail);
try
{
for (ClientBehaviourDecorator bhd : Client_BehaviourDecorators)
{
newEmail = bhd.setEmail ((Client)this, newEmail);
oldAndNewIdentical = HELPER_Email.compare (_Email, newEmail);
}
if (FIELD_Email_Validators.length > 0)
{
Object newEmailObj = HELPER_Email.toObject (newEmail);
if (newEmailObj != null)
{
int loopMax = FIELD_Email_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_Client.get (FIELD_Email);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_Email_Validators[v].checkAttribute (this, FIELD_Email, metadata, newEmailObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_Email () != FieldWriteability.FALSE, "Field Email is not writeable");
preEmailChange (newEmail);
markFieldChange (FIELD_Email);
_Email = newEmail;
postFieldChange (FIELD_Email);
postEmailChange ();
}
}
/**
* Get the attribute ContactName
*/
public String getContactName ()
{
assertValid();
String valToReturn = _ContactName;
for (ClientBehaviourDecorator bhd : Client_BehaviourDecorators)
{
valToReturn = bhd.getContactName ((Client)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preContactNameChange (String newContactName) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postContactNameChange () throws FieldException
{
}
public FieldWriteability getWriteability_ContactName ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute ContactName. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setContactName (String newContactName) throws FieldException
{
boolean oldAndNewIdentical = HELPER_ContactName.compare (_ContactName, newContactName);
try
{
for (ClientBehaviourDecorator bhd : Client_BehaviourDecorators)
{
newContactName = bhd.setContactName ((Client)this, newContactName);
oldAndNewIdentical = HELPER_ContactName.compare (_ContactName, newContactName);
}
if (FIELD_ContactName_Validators.length > 0)
{
Object newContactNameObj = HELPER_ContactName.toObject (newContactName);
if (newContactNameObj != null)
{
int loopMax = FIELD_ContactName_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_Client.get (FIELD_ContactName);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_ContactName_Validators[v].checkAttribute (this, FIELD_ContactName, metadata, newContactNameObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_ContactName () != FieldWriteability.FALSE, "Field ContactName is not writeable");
preContactNameChange (newContactName);
markFieldChange (FIELD_ContactName);
_ContactName = newContactName;
postFieldChange (FIELD_ContactName);
postContactNameChange ();
}
}
/**
* Get the attribute ContactSurname
*/
public String getContactSurname ()
{
assertValid();
String valToReturn = _ContactSurname;
for (ClientBehaviourDecorator bhd : Client_BehaviourDecorators)
{
valToReturn = bhd.getContactSurname ((Client)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preContactSurnameChange (String newContactSurname) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postContactSurnameChange () throws FieldException
{
}
public FieldWriteability getWriteability_ContactSurname ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute ContactSurname. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setContactSurname (String newContactSurname) throws FieldException
{
boolean oldAndNewIdentical = HELPER_ContactSurname.compare (_ContactSurname, newContactSurname);
try
{
for (ClientBehaviourDecorator bhd : Client_BehaviourDecorators)
{
newContactSurname = bhd.setContactSurname ((Client)this, newContactSurname);
oldAndNewIdentical = HELPER_ContactSurname.compare (_ContactSurname, newContactSurname);
}
if (FIELD_ContactSurname_Validators.length > 0)
{
Object newContactSurnameObj = HELPER_ContactSurname.toObject (newContactSurname);
if (newContactSurnameObj != null)
{
int loopMax = FIELD_ContactSurname_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_Client.get (FIELD_ContactSurname);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_ContactSurname_Validators[v].checkAttribute (this, FIELD_ContactSurname, metadata, newContactSurnameObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_ContactSurname () != FieldWriteability.FALSE, "Field ContactSurname is not writeable");
preContactSurnameChange (newContactSurname);
markFieldChange (FIELD_ContactSurname);
_ContactSurname = newContactSurname;
postFieldChange (FIELD_ContactSurname);
postContactSurnameChange ();
}
}
/**
* Get the attribute Phone
*/
public String getPhone ()
{
assertValid();
String valToReturn = _Phone;
for (ClientBehaviourDecorator bhd : Client_BehaviourDecorators)
{
valToReturn = bhd.getPhone ((Client)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void prePhoneChange (String newPhone) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postPhoneChange () throws FieldException
{
}
public FieldWriteability getWriteability_Phone ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute Phone. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setPhone (String newPhone) throws FieldException
{
boolean oldAndNewIdentical = HELPER_Phone.compare (_Phone, newPhone);
try
{
for (ClientBehaviourDecorator bhd : Client_BehaviourDecorators)
{
newPhone = bhd.setPhone ((Client)this, newPhone);
oldAndNewIdentical = HELPER_Phone.compare (_Phone, newPhone);
}
if (FIELD_Phone_Validators.length > 0)
{
Object newPhoneObj = HELPER_Phone.toObject (newPhone);
if (newPhoneObj != null)
{
int loopMax = FIELD_Phone_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_Client.get (FIELD_Phone);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_Phone_Validators[v].checkAttribute (this, FIELD_Phone, metadata, newPhoneObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_Phone () != FieldWriteability.FALSE, "Field Phone is not writeable");
prePhoneChange (newPhone);
markFieldChange (FIELD_Phone);
_Phone = newPhone;
postFieldChange (FIELD_Phone);
postPhoneChange ();
}
}
/**
* Get the attribute State
*/
public State getState ()
{
assertValid();
State valToReturn = _State;
for (ClientBehaviourDecorator bhd : Client_BehaviourDecorators)
{
valToReturn = bhd.getState ((Client)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preStateChange (State newState) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postStateChange () throws FieldException
{
}
public FieldWriteability getWriteability_State ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute State. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setState (State newState) throws FieldException
{
boolean oldAndNewIdentical = HELPER_State.compare (_State, newState);
try
{
for (ClientBehaviourDecorator bhd : Client_BehaviourDecorators)
{
newState = bhd.setState ((Client)this, newState);
oldAndNewIdentical = HELPER_State.compare (_State, newState);
}
if (FIELD_State_Validators.length > 0)
{
Object newStateObj = HELPER_State.toObject (newState);
if (newStateObj != null)
{
int loopMax = FIELD_State_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_Client.get (FIELD_State);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_State_Validators[v].checkAttribute (this, FIELD_State, metadata, newStateObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_State () != FieldWriteability.FALSE, "Field State is not writeable");
preStateChange (newState);
markFieldChange (FIELD_State);
_State = newState;
postFieldChange (FIELD_State);
postStateChange ();
}
}
/**
* Get the attribute Country
*/
public Countries getCountry ()
{
assertValid();
Countries valToReturn = _Country;
for (ClientBehaviourDecorator bhd : Client_BehaviourDecorators)
{
valToReturn = bhd.getCountry ((Client)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preCountryChange (Countries newCountry) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postCountryChange () throws FieldException
{
}
public FieldWriteability getWriteability_Country ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute Country. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setCountry (Countries newCountry) throws FieldException
{
boolean oldAndNewIdentical = HELPER_Country.compare (_Country, newCountry);
try
{
for (ClientBehaviourDecorator bhd : Client_BehaviourDecorators)
{
newCountry = bhd.setCountry ((Client)this, newCountry);
oldAndNewIdentical = HELPER_Country.compare (_Country, newCountry);
}
if (FIELD_Country_Validators.length > 0)
{
Object newCountryObj = HELPER_Country.toObject (newCountry);
if (newCountryObj != null)
{
int loopMax = FIELD_Country_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_Client.get (FIELD_Country);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_Country_Validators[v].checkAttribute (this, FIELD_Country, metadata, newCountryObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_Country () != FieldWriteability.FALSE, "Field Country is not writeable");
preCountryChange (newCountry);
markFieldChange (FIELD_Country);
_Country = newCountry;
postFieldChange (FIELD_Country);
postCountryChange ();
}
}
/**
* Get the attribute PostCode
*/
public String getPostCode ()
{
assertValid();
String valToReturn = _PostCode;
for (ClientBehaviourDecorator bhd : Client_BehaviourDecorators)
{
valToReturn = bhd.getPostCode ((Client)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void prePostCodeChange (String newPostCode) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postPostCodeChange () throws FieldException
{
}
public FieldWriteability getWriteability_PostCode ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute PostCode. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setPostCode (String newPostCode) throws FieldException
{
boolean oldAndNewIdentical = HELPER_PostCode.compare (_PostCode, newPostCode);
try
{
for (ClientBehaviourDecorator bhd : Client_BehaviourDecorators)
{
newPostCode = bhd.setPostCode ((Client)this, newPostCode);
oldAndNewIdentical = HELPER_PostCode.compare (_PostCode, newPostCode);
}
if (FIELD_PostCode_Validators.length > 0)
{
Object newPostCodeObj = HELPER_PostCode.toObject (newPostCode);
if (newPostCodeObj != null)
{
int loopMax = FIELD_PostCode_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_Client.get (FIELD_PostCode);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_PostCode_Validators[v].checkAttribute (this, FIELD_PostCode, metadata, newPostCodeObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_PostCode () != FieldWriteability.FALSE, "Field PostCode is not writeable");
prePostCodeChange (newPostCode);
markFieldChange (FIELD_PostCode);
_PostCode = newPostCode;
postFieldChange (FIELD_PostCode);
postPostCodeChange ();
}
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getSingleAssocs()
{
List result = super.getSingleAssocs ();
result.add("Company");
return result;
}
public BaseBusinessClass getSingleAssocReferenceInstance (String assocName)
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Company))
{
return _Company.getReferencedType ();
}
else
{
return super.getSingleAssocReferenceInstance (assocName);
}
}
public String getSingleAssocBackReference(String assocName)
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Company))
{
return Company.MULTIPLEREFERENCE_Clients ;
}
else
{
return super.getSingleAssocBackReference (assocName);
}
}
public BaseBusinessClass getSingleAssoc (String assocName) throws StorageException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Company))
{
return getCompany ();
}
else
{
return super.getSingleAssoc (assocName);
}
}
public BaseBusinessClass getSingleAssoc (String assocName, Get getType) throws StorageException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Company))
{
return getCompany (getType);
}
else
{
return super.getSingleAssoc (assocName, getType);
}
}
public Long getSingleAssocID (String assocName) throws StorageException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Company))
{
return getCompanyID ();
}
else
{
return super.getSingleAssocID (assocName);
}
}
public void setSingleAssoc (String assocName, BaseBusinessClass newValue) throws StorageException, FieldException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Company))
{
setCompany ((Company)(newValue));
}
else
{
super.setSingleAssoc (assocName, newValue);
}
}
/**
* Get the reference Company
*/
public Company getCompany () throws StorageException
{
assertValid();
try
{
return (Company)(_Company.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in Client:", this.getObjectID (), ", was trying to get Company:", getCompanyID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _Company.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Company getCompany (Get getType) throws StorageException
{
assertValid();
return _Company.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getCompanyID ()
{
assertValid();
if (_Company == null)
{
return null;
}
else
{
return _Company.getID ();
}
}
/**
* Called prior to the assoc changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preCompanyChange (Company newCompany) throws FieldException
{
}
/**
* Called after the assoc changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postCompanyChange () throws FieldException
{
}
public FieldWriteability getWriteability_Company ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference Company. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setCompany (Company newCompany) throws StorageException, FieldException
{
if (_Company.wouldReferencedChange (newCompany))
{
assertValid();
Debug.assertion (getWriteability_Company () != FieldWriteability.FALSE, "Assoc Company is not writeable");
preCompanyChange (newCompany);
Company oldCompany = getCompany ();
if (oldCompany != null)
{
// This is to stop validation from triggering when we are removed
_Company.set (null);
oldCompany.removeFromClients ((Client)(this));
}
_Company.set (newCompany);
if (newCompany != null)
{
newCompany.addToClients ((Client)(this));
}
postCompanyChange ();
}
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getMultiAssocs()
{
List result = super.getMultiAssocs ();
return result;
}
/**
* Get the reference instance for the multi assoc name.
*/
public BaseBusinessClass getMultiAssocReferenceInstance(String attribName)
{
return super.getMultiAssocReferenceInstance(attribName);
}
public String getMultiAssocBackReference(String attribName)
{
return super.getMultiAssocBackReference(attribName);
}
/**
* Get the assoc count for the multi assoc name.
*/
public int getMultiAssocCount(String attribName) throws StorageException
{
return super.getMultiAssocCount(attribName);
}
/**
* Get the assoc at a particular index
*/
public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException
{
return super.getMultiAssocAt(attribName, index);
}
/**
* Add to a multi assoc by attribute name
*/
public void addToMultiAssoc(String attribName, BaseBusinessClass newElement) throws StorageException
{
super.addToMultiAssoc(attribName, newElement);
}
/**
* Remove from a multi assoc by attribute name
*/
public void removeFromMultiAssoc(String attribName, BaseBusinessClass oldElement) throws StorageException
{
super.removeFromMultiAssoc(attribName, oldElement);
}
protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements)
{
super.__loadMultiAssoc(attribName, elements);
}
protected boolean __isMultiAssocLoaded (String attribName)
{
return super.__isMultiAssocLoaded(attribName);
}
public void onDelete ()
{
try
{
// Ensure we are removed from any loaded multi-associations that aren't mandatory
if (_Company.isLoaded () || getTransaction ().isObjectLoaded (_Company.getReferencedType (), getCompanyID ()))
{
Company referenced = getCompany ();
if (referenced != null)
{
// Stop the callback
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Clients from ", getObjectID (), " to ", referenced.getObjectID ());
_Company.set (null);
referenced.removeFromClients ((Client)this);
}
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
super.onDelete ();
}
public Client newInstance ()
{
return new Client ();
}
public Client referenceInstance ()
{
return REFERENCE_Client;
}
public Client getInTransaction (ObjectTransaction t) throws StorageException
{
return getClientByID (t, getObjectID());
}
public BaseBusinessClass dummyInstance ()
{
return DUMMY_Client;
}
public String getBaseSetName ()
{
return "tl_client";
}
/**
* This is where an object returns the Persistent sets that will
* store it into the database.
* The should be entered into allSets
*/
public void getPersistentSets (PersistentSetCollection allSets)
{
ObjectStatus myStatus = getStatus ();
PersistentSetStatus myPSetStatus = myStatus.getPSetStatus();
ObjectID myID = getID();
super.getPersistentSets (allSets);
PersistentSet tl_clientPSet = allSets.getPersistentSet (myID, "tl_client", myPSetStatus);
tl_clientPSet.setAttrib (FIELD_ObjectID, myID);
tl_clientPSet.setAttrib (FIELD_CompanyName, HELPER_CompanyName.toObject (_CompanyName)); //
tl_clientPSet.setAttrib (FIELD_CompanyLogo, HELPER_CompanyLogo.toObject (_CompanyLogo)); //
tl_clientPSet.setAttrib (FIELD_Email, HELPER_Email.toObject (_Email)); //
tl_clientPSet.setAttrib (FIELD_ContactName, HELPER_ContactName.toObject (_ContactName)); //
tl_clientPSet.setAttrib (FIELD_ContactSurname, HELPER_ContactSurname.toObject (_ContactSurname)); //
tl_clientPSet.setAttrib (FIELD_Phone, HELPER_Phone.toObject (_Phone)); //
tl_clientPSet.setAttrib (FIELD_State, HELPER_State.toObject (_State)); //
tl_clientPSet.setAttrib (FIELD_Country, HELPER_Country.toObject (_Country)); //
tl_clientPSet.setAttrib (FIELD_PostCode, HELPER_PostCode.toObject (_PostCode)); //
_Company.getPersistentSets (allSets);
}
/**
* Sets the objects state based on Persistent sets.
*/
public void setFromPersistentSets (ObjectID objectID, PersistentSetCollection allSets)
{
super.setFromPersistentSets (objectID, allSets);
PersistentSet tl_clientPSet = allSets.getPersistentSet (objectID, "tl_client");
_CompanyName = (String)(HELPER_CompanyName.fromObject (_CompanyName, tl_clientPSet.getAttrib (FIELD_CompanyName))); //
_CompanyLogo = (BinaryContent)(HELPER_CompanyLogo.fromObject (_CompanyLogo, tl_clientPSet.getAttrib (FIELD_CompanyLogo))); //
_Email = (String)(HELPER_Email.fromObject (_Email, tl_clientPSet.getAttrib (FIELD_Email))); //
_ContactName = (String)(HELPER_ContactName.fromObject (_ContactName, tl_clientPSet.getAttrib (FIELD_ContactName))); //
_ContactSurname = (String)(HELPER_ContactSurname.fromObject (_ContactSurname, tl_clientPSet.getAttrib (FIELD_ContactSurname))); //
_Phone = (String)(HELPER_Phone.fromObject (_Phone, tl_clientPSet.getAttrib (FIELD_Phone))); //
_State = (State)(HELPER_State.fromObject (_State, tl_clientPSet.getAttrib (FIELD_State))); //
_Country = (Countries)(HELPER_Country.fromObject (_Country, tl_clientPSet.getAttrib (FIELD_Country))); //
_PostCode = (String)(HELPER_PostCode.fromObject (_PostCode, tl_clientPSet.getAttrib (FIELD_PostCode))); //
_Company.setFromPersistentSets (objectID, allSets);
}
public void setAttributesFrom (BaseBusinessClass other, MultiException e)
{
super.setAttributesFrom (other, e);
if (other instanceof Client)
{
Client otherClient = (Client)other;
try
{
setCompanyName (otherClient.getCompanyName ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setCompanyLogo (otherClient.getCompanyLogo ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setEmail (otherClient.getEmail ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setContactName (otherClient.getContactName ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setContactSurname (otherClient.getContactSurname ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setPhone (otherClient.getPhone ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setState (otherClient.getState ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setCountry (otherClient.getCountry ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setPostCode (otherClient.getPostCode ());
}
catch (FieldException ex)
{
e.addException (ex);
}
}
}
/**
* Set the attributes in this to copies of the attributes in source.
*/
public void copyAttributesFrom (BaseBusinessClass source)
{
super.copyAttributesFrom (source);
if (source instanceof BaseClient)
{
BaseClient sourceClient = (BaseClient)(source);
_CompanyName = sourceClient._CompanyName;
_CompanyLogo = sourceClient._CompanyLogo;
_Email = sourceClient._Email;
_ContactName = sourceClient._ContactName;
_ContactSurname = sourceClient._ContactSurname;
_Phone = sourceClient._Phone;
_State = sourceClient._State;
_Country = sourceClient._Country;
_PostCode = sourceClient._PostCode;
}
}
/**
* Set the associations in this to copies of the attributes in source.
*/
public void copySingleAssociationsFrom (BaseBusinessClass source, boolean linkToGhosts)
{
super.copySingleAssociationsFrom (source, linkToGhosts);
if (source instanceof BaseClient)
{
BaseClient sourceClient = (BaseClient)(source);
_Company.copyFrom (sourceClient._Company, linkToGhosts);
}
}
/**
* Set the associations in this to copies of the attributes in source.
*/
public void copyAssociationsFrom (BaseBusinessClass source, boolean linkToGhosts)
{
super.copyAssociationsFrom (source, linkToGhosts);
if (source instanceof BaseClient)
{
BaseClient sourceClient = (BaseClient)(source);
}
}
public void validate (ValidationContext context)
{
super.validate (context);
}
/**
* Subclasses must override this to read in their attributes
*/
protected void readExternalData(Map<String, Object> vals) throws IOException, ClassNotFoundException
{
super.readExternalData(vals);
_CompanyName = (String)(HELPER_CompanyName.readExternal (_CompanyName, vals.get(FIELD_CompanyName))); //
_CompanyLogo = (BinaryContent)(HELPER_CompanyLogo.readExternal (_CompanyLogo, vals.get(FIELD_CompanyLogo))); //
_Email = (String)(HELPER_Email.readExternal (_Email, vals.get(FIELD_Email))); //
_ContactName = (String)(HELPER_ContactName.readExternal (_ContactName, vals.get(FIELD_ContactName))); //
_ContactSurname = (String)(HELPER_ContactSurname.readExternal (_ContactSurname, vals.get(FIELD_ContactSurname))); //
_Phone = (String)(HELPER_Phone.readExternal (_Phone, vals.get(FIELD_Phone))); //
_State = (State)(HELPER_State.readExternal (_State, vals.get(FIELD_State))); //
_Country = (Countries)(HELPER_Country.readExternal (_Country, vals.get(FIELD_Country))); //
_PostCode = (String)(HELPER_PostCode.readExternal (_PostCode, vals.get(FIELD_PostCode))); //
_Company.readExternalData(vals.get(SINGLEREFERENCE_Company));
}
/**
* Subclasses must override this to write out their attributes
*/
protected void writeExternalData(Map<String, Object> vals) throws IOException
{
super.writeExternalData(vals);
vals.put (FIELD_CompanyName, HELPER_CompanyName.writeExternal (_CompanyName));
vals.put (FIELD_CompanyLogo, HELPER_CompanyLogo.writeExternal (_CompanyLogo));
vals.put (FIELD_Email, HELPER_Email.writeExternal (_Email));
vals.put (FIELD_ContactName, HELPER_ContactName.writeExternal (_ContactName));
vals.put (FIELD_ContactSurname, HELPER_ContactSurname.writeExternal (_ContactSurname));
vals.put (FIELD_Phone, HELPER_Phone.writeExternal (_Phone));
vals.put (FIELD_State, HELPER_State.writeExternal (_State));
vals.put (FIELD_Country, HELPER_Country.writeExternal (_Country));
vals.put (FIELD_PostCode, HELPER_PostCode.writeExternal (_PostCode));
vals.put (SINGLEREFERENCE_Company, _Company.writeExternalData());
}
public void compare (BaseBusinessClass other, AttributeChangeListener listener) throws StorageException
{
super.compare (other, listener);
if (other instanceof BaseClient)
{
BaseClient otherClient = (BaseClient)(other);
if (!HELPER_CompanyName.compare(this._CompanyName, otherClient._CompanyName))
{
listener.notifyFieldChange(this, other, FIELD_CompanyName, HELPER_CompanyName.toObject(this._CompanyName), HELPER_CompanyName.toObject(otherClient._CompanyName));
}
if (!HELPER_CompanyLogo.compare(this._CompanyLogo, otherClient._CompanyLogo))
{
listener.notifyFieldChange(this, other, FIELD_CompanyLogo, HELPER_CompanyLogo.toObject(this._CompanyLogo), HELPER_CompanyLogo.toObject(otherClient._CompanyLogo));
}
if (!HELPER_Email.compare(this._Email, otherClient._Email))
{
listener.notifyFieldChange(this, other, FIELD_Email, HELPER_Email.toObject(this._Email), HELPER_Email.toObject(otherClient._Email));
}
if (!HELPER_ContactName.compare(this._ContactName, otherClient._ContactName))
{
listener.notifyFieldChange(this, other, FIELD_ContactName, HELPER_ContactName.toObject(this._ContactName), HELPER_ContactName.toObject(otherClient._ContactName));
}
if (!HELPER_ContactSurname.compare(this._ContactSurname, otherClient._ContactSurname))
{
listener.notifyFieldChange(this, other, FIELD_ContactSurname, HELPER_ContactSurname.toObject(this._ContactSurname), HELPER_ContactSurname.toObject(otherClient._ContactSurname));
}
if (!HELPER_Phone.compare(this._Phone, otherClient._Phone))
{
listener.notifyFieldChange(this, other, FIELD_Phone, HELPER_Phone.toObject(this._Phone), HELPER_Phone.toObject(otherClient._Phone));
}
if (!HELPER_State.compare(this._State, otherClient._State))
{
listener.notifyFieldChange(this, other, FIELD_State, HELPER_State.toObject(this._State), HELPER_State.toObject(otherClient._State));
}
if (!HELPER_Country.compare(this._Country, otherClient._Country))
{
listener.notifyFieldChange(this, other, FIELD_Country, HELPER_Country.toObject(this._Country), HELPER_Country.toObject(otherClient._Country));
}
if (!HELPER_PostCode.compare(this._PostCode, otherClient._PostCode))
{
listener.notifyFieldChange(this, other, FIELD_PostCode, HELPER_PostCode.toObject(this._PostCode), HELPER_PostCode.toObject(otherClient._PostCode));
}
// Compare single assocs
_Company.compare (otherClient._Company, listener);
// Compare multiple assocs
}
}
public void visitTransients (AttributeVisitor visitor) throws StorageException
{
super.visitAttributes (visitor);
}
public void visitAttributes (AttributeVisitor visitor) throws StorageException
{
super.visitAttributes (visitor);
visitor.visitField(this, FIELD_CompanyName, HELPER_CompanyName.toObject(getCompanyName()));
visitor.visitField(this, FIELD_CompanyLogo, HELPER_CompanyLogo.toObject(getCompanyLogo()));
visitor.visitField(this, FIELD_Email, HELPER_Email.toObject(getEmail()));
visitor.visitField(this, FIELD_ContactName, HELPER_ContactName.toObject(getContactName()));
visitor.visitField(this, FIELD_ContactSurname, HELPER_ContactSurname.toObject(getContactSurname()));
visitor.visitField(this, FIELD_Phone, HELPER_Phone.toObject(getPhone()));
visitor.visitField(this, FIELD_State, HELPER_State.toObject(getState()));
visitor.visitField(this, FIELD_Country, HELPER_Country.toObject(getCountry()));
visitor.visitField(this, FIELD_PostCode, HELPER_PostCode.toObject(getPostCode()));
visitor.visitAssociation (_Company);
}
public void visitAssociations (AssociationVisitor visitor, AssociatedScope scope) throws StorageException
{
super.visitAssociations (visitor, scope);
if (scope.includes (_Company))
{
visitor.visit (_Company);
}
}
public static Client createClient (ObjectTransaction transaction) throws StorageException
{
Client result = new Client ();
result.initialiseNewObject (transaction);
return result;
}
public static Client getClientByID (ObjectTransaction transaction, Long objectID) throws StorageException
{
return (Client)(transaction.getObjectByID (REFERENCE_Client, objectID));
}
public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_CompanyName))
{
return filter.matches (getCompanyName ());
}
else if (attribName.equals (FIELD_CompanyLogo))
{
return filter.matches (getCompanyLogo ());
}
else if (attribName.equals (FIELD_Email))
{
return filter.matches (getEmail ());
}
else if (attribName.equals (FIELD_ContactName))
{
return filter.matches (getContactName ());
}
else if (attribName.equals (FIELD_ContactSurname))
{
return filter.matches (getContactSurname ());
}
else if (attribName.equals (FIELD_Phone))
{
return filter.matches (getPhone ());
}
else if (attribName.equals (FIELD_State))
{
return filter.matches (getState ());
}
else if (attribName.equals (FIELD_Country))
{
return filter.matches (getCountry ());
}
else if (attribName.equals (FIELD_PostCode))
{
return filter.matches (getPostCode ());
}
else if (attribName.equals (SINGLEREFERENCE_Company))
{
return filter.matches (getCompany ());
}
else
{
return super.testFilter (attribName, filter);
}
}
public static SearchAll SearchByAll () { return new SearchAll (); }
public static class SearchAll extends SearchObject<Client>
{
public SearchAll andObjectID (QueryFilter<Long> filter)
{
filter.addFilter (context, "tl_client.object_id", FIELD_ObjectID);
return this;
}
public SearchAll andObjectCreated (QueryFilter<Date> filter)
{
filter.addFilter (context, "tl_client.object_created_date", FIELD_ObjectCreated);
return this;
}
public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{
filter.addFilter (context, "tl_client.object_last_updated_date", FIELD_ObjectLastModified);
return this;
}
public SearchAll andCompanyName (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_client.company_name", "CompanyName");
return this;
}
public SearchAll andCompanyLogo (QueryFilter<BinaryContent> filter)
{
filter.addFilter (context, "tl_client.company_logo", "CompanyLogo");
return this;
}
public SearchAll andEmail (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_client.email", "Email");
return this;
}
public SearchAll andContactName (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_client.contact_name", "ContactName");
return this;
}
public SearchAll andContactSurname (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_client.contact_surname", "ContactSurname");
return this;
}
public SearchAll andPhone (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_client.phone", "Phone");
return this;
}
public SearchAll andState (QueryFilter<State> filter)
{
filter.addFilter (context, "tl_client.state", "State");
return this;
}
public SearchAll andCountry (QueryFilter<Countries> filter)
{
filter.addFilter (context, "tl_client.country", "Country");
return this;
}
public SearchAll andPostCode (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_client.post_code", "PostCode");
return this;
}
public SearchAll andCompany (QueryFilter<Company> filter)
{
filter.addFilter (context, "tl_client.company_id", "Company");
return this;
}
public Client[]
search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_Client, SEARCH_All, criteria);
Set<Client> typedResults = new LinkedHashSet <Client> ();
for (BaseBusinessClass bbcResult : results)
{
Client aResult = (Client)bbcResult;
typedResults.add (aResult);
}
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new Client[0]);
}
}
public static Client[]
searchAll (ObjectTransaction transaction) throws StorageException
{
return SearchByAll ()
.search (transaction);
}
public Object getAttribute (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_CompanyName))
{
return HELPER_CompanyName.toObject (getCompanyName ());
}
else if (attribName.equals (FIELD_CompanyLogo))
{
return HELPER_CompanyLogo.toObject (getCompanyLogo ());
}
else if (attribName.equals (FIELD_Email))
{
return HELPER_Email.toObject (getEmail ());
}
else if (attribName.equals (FIELD_ContactName))
{
return HELPER_ContactName.toObject (getContactName ());
}
else if (attribName.equals (FIELD_ContactSurname))
{
return HELPER_ContactSurname.toObject (getContactSurname ());
}
else if (attribName.equals (FIELD_Phone))
{
return HELPER_Phone.toObject (getPhone ());
}
else if (attribName.equals (FIELD_State))
{
return HELPER_State.toObject (getState ());
}
else if (attribName.equals (FIELD_Country))
{
return HELPER_Country.toObject (getCountry ());
}
else if (attribName.equals (FIELD_PostCode))
{
return HELPER_PostCode.toObject (getPostCode ());
}
else
{
return super.getAttribute (attribName);
}
}
public AttributeHelper getAttributeHelper (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_CompanyName))
{
return HELPER_CompanyName;
}
else if (attribName.equals (FIELD_CompanyLogo))
{
return HELPER_CompanyLogo;
}
else if (attribName.equals (FIELD_Email))
{
return HELPER_Email;
}
else if (attribName.equals (FIELD_ContactName))
{
return HELPER_ContactName;
}
else if (attribName.equals (FIELD_ContactSurname))
{
return HELPER_ContactSurname;
}
else if (attribName.equals (FIELD_Phone))
{
return HELPER_Phone;
}
else if (attribName.equals (FIELD_State))
{
return HELPER_State;
}
else if (attribName.equals (FIELD_Country))
{
return HELPER_Country;
}
else if (attribName.equals (FIELD_PostCode))
{
return HELPER_PostCode;
}
else
{
return super.getAttributeHelper (attribName);
}
}
public void setAttribute (String attribName, Object attribValue) throws FieldException
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_CompanyName))
{
setCompanyName ((String)(HELPER_CompanyName.fromObject (_CompanyName, attribValue)));
}
else if (attribName.equals (FIELD_CompanyLogo))
{
setCompanyLogo ((BinaryContent)(HELPER_CompanyLogo.fromObject (_CompanyLogo, attribValue)));
}
else if (attribName.equals (FIELD_Email))
{
setEmail ((String)(HELPER_Email.fromObject (_Email, attribValue)));
}
else if (attribName.equals (FIELD_ContactName))
{
setContactName ((String)(HELPER_ContactName.fromObject (_ContactName, attribValue)));
}
else if (attribName.equals (FIELD_ContactSurname))
{
setContactSurname ((String)(HELPER_ContactSurname.fromObject (_ContactSurname, attribValue)));
}
else if (attribName.equals (FIELD_Phone))
{
setPhone ((String)(HELPER_Phone.fromObject (_Phone, attribValue)));
}
else if (attribName.equals (FIELD_State))
{
setState ((State)(HELPER_State.fromObject (_State, attribValue)));
}
else if (attribName.equals (FIELD_Country))
{
setCountry ((Countries)(HELPER_Country.fromObject (_Country, attribValue)));
}
else if (attribName.equals (FIELD_PostCode))
{
setPostCode ((String)(HELPER_PostCode.fromObject (_PostCode, attribValue)));
}
else
{
super.setAttribute (attribName, attribValue);
}
}
public boolean isWriteable (String fieldName)
{
return getWriteable (fieldName) == FieldWriteability.TRUE;
}
public FieldWriteability getWriteable (String fieldName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (fieldName.equals (FIELD_CompanyName))
{
return getWriteability_CompanyName ();
}
else if (fieldName.equals (FIELD_CompanyLogo))
{
return getWriteability_CompanyLogo ();
}
else if (fieldName.equals (FIELD_Email))
{
return getWriteability_Email ();
}
else if (fieldName.equals (FIELD_ContactName))
{
return getWriteability_ContactName ();
}
else if (fieldName.equals (FIELD_ContactSurname))
{
return getWriteability_ContactSurname ();
}
else if (fieldName.equals (FIELD_Phone))
{
return getWriteability_Phone ();
}
else if (fieldName.equals (FIELD_State))
{
return getWriteability_State ();
}
else if (fieldName.equals (FIELD_Country))
{
return getWriteability_Country ();
}
else if (fieldName.equals (FIELD_PostCode))
{
return getWriteability_PostCode ();
}
else if (fieldName.equals (SINGLEREFERENCE_Company))
{
return getWriteability_Company ();
}
else
{
return super.getWriteable (fieldName);
}
}
public void putUnwriteable (Set<String> fields)
{
if (getWriteability_CompanyName () != FieldWriteability.TRUE)
{
fields.add (FIELD_CompanyName);
}
if (getWriteability_CompanyLogo () != FieldWriteability.TRUE)
{
fields.add (FIELD_CompanyLogo);
}
if (getWriteability_Email () != FieldWriteability.TRUE)
{
fields.add (FIELD_Email);
}
if (getWriteability_ContactName () != FieldWriteability.TRUE)
{
fields.add (FIELD_ContactName);
}
if (getWriteability_ContactSurname () != FieldWriteability.TRUE)
{
fields.add (FIELD_ContactSurname);
}
if (getWriteability_Phone () != FieldWriteability.TRUE)
{
fields.add (FIELD_Phone);
}
if (getWriteability_State () != FieldWriteability.TRUE)
{
fields.add (FIELD_State);
}
if (getWriteability_Country () != FieldWriteability.TRUE)
{
fields.add (FIELD_Country);
}
if (getWriteability_PostCode () != FieldWriteability.TRUE)
{
fields.add (FIELD_PostCode);
}
super.putUnwriteable (fields);
}
public List<AbstractAttribute> getAttributes ()
{
List result = super.getAttributes ();
result.add(HELPER_CompanyName.getAttribObject (getClass (), _CompanyName, true, FIELD_CompanyName));
result.add(HELPER_CompanyLogo.getAttribObject (getClass (), _CompanyLogo, false, FIELD_CompanyLogo));
result.add(HELPER_Email.getAttribObject (getClass (), _Email, false, FIELD_Email));
result.add(HELPER_ContactName.getAttribObject (getClass (), _ContactName, false, FIELD_ContactName));
result.add(HELPER_ContactSurname.getAttribObject (getClass (), _ContactSurname, false, FIELD_ContactSurname));
result.add(HELPER_Phone.getAttribObject (getClass (), _Phone, false, FIELD_Phone));
result.add(HELPER_State.getAttribObject (getClass (), _State, false, FIELD_State));
result.add(HELPER_Country.getAttribObject (getClass (), _Country, false, FIELD_Country));
result.add(HELPER_PostCode.getAttribObject (getClass (), _PostCode, false, FIELD_PostCode));
return result;
}
public Map getAttributeMetadata (String attribute)
{
if (ATTRIBUTES_METADATA_Client.containsKey (attribute))
{
return (Map)ATTRIBUTES_METADATA_Client.get (attribute);
}
else
{
return super.getAttributeMetadata (attribute);
}
}
public Object getAttributeMetadata (String attribute, String metadata)
{
if (ATTRIBUTES_METADATA_Client.containsKey (attribute))
{
return ((Map)ATTRIBUTES_METADATA_Client.get (attribute)).get(metadata);
}
else
{
return super.getAttributeMetadata (attribute, metadata);
}
}
public void preCommit (boolean willBeStored) throws Exception
{
super.preCommit(willBeStored);
if(willBeStored)
{
{
oneit.servlets.objstore.binary.BinaryContentHandler bchandler = oneit.servlets.objstore.binary.BinaryContentServlet.getHandler("loggedin");
if(bchandler != null)
{
bchandler.preCommit(willBeStored, this, "CompanyLogo");
}
else
{
LogMgr.log(BUSINESS_OBJECTS, LogLevel.SYSTEMWARNING, "Unknown BinaryContentHandler loggedin on attribute CompanyLogo");
}
}
}
}
public oneit.servlets.objstore.binary.BinaryContentHandler getBinaryContentHandler(String attribName)
{
if(CollectionUtils.equals(attribName, "CompanyLogo"))
{
return oneit.servlets.objstore.binary.BinaryContentServlet.getHandler("loggedin");
}
return super.getBinaryContentHandler(attribName);
}
public static class ClientBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<Client>
{
/**
* Get the attribute CompanyName
*/
public String getCompanyName (Client obj, String original)
{
return original;
}
/**
* Change the value set for attribute CompanyName.
* May modify the field beforehand
* Occurs before validation.
*/
public String setCompanyName (Client obj, String newCompanyName) throws FieldException
{
return newCompanyName;
}
/**
* Get the attribute CompanyLogo
*/
public BinaryContent getCompanyLogo (Client obj, BinaryContent original)
{
return original;
}
/**
* Change the value set for attribute CompanyLogo.
* May modify the field beforehand
* Occurs before validation.
*/
public BinaryContent setCompanyLogo (Client obj, BinaryContent newCompanyLogo) throws FieldException
{
return newCompanyLogo;
}
/**
* Get the attribute Email
*/
public String getEmail (Client obj, String original)
{
return original;
}
/**
* Change the value set for attribute Email.
* May modify the field beforehand
* Occurs before validation.
*/
public String setEmail (Client obj, String newEmail) throws FieldException
{
return newEmail;
}
/**
* Get the attribute ContactName
*/
public String getContactName (Client obj, String original)
{
return original;
}
/**
* Change the value set for attribute ContactName.
* May modify the field beforehand
* Occurs before validation.
*/
public String setContactName (Client obj, String newContactName) throws FieldException
{
return newContactName;
}
/**
* Get the attribute ContactSurname
*/
public String getContactSurname (Client obj, String original)
{
return original;
}
/**
* Change the value set for attribute ContactSurname.
* May modify the field beforehand
* Occurs before validation.
*/
public String setContactSurname (Client obj, String newContactSurname) throws FieldException
{
return newContactSurname;
}
/**
* Get the attribute Phone
*/
public String getPhone (Client obj, String original)
{
return original;
}
/**
* Change the value set for attribute Phone.
* May modify the field beforehand
* Occurs before validation.
*/
public String setPhone (Client obj, String newPhone) throws FieldException
{
return newPhone;
}
/**
* Get the attribute State
*/
public State getState (Client obj, State original)
{
return original;
}
/**
* Change the value set for attribute State.
* May modify the field beforehand
* Occurs before validation.
*/
public State setState (Client obj, State newState) throws FieldException
{
return newState;
}
/**
* Get the attribute Country
*/
public Countries getCountry (Client obj, Countries original)
{
return original;
}
/**
* Change the value set for attribute Country.
* May modify the field beforehand
* Occurs before validation.
*/
public Countries setCountry (Client obj, Countries newCountry) throws FieldException
{
return newCountry;
}
/**
* Get the attribute PostCode
*/
public String getPostCode (Client obj, String original)
{
return original;
}
/**
* Change the value set for attribute PostCode.
* May modify the field beforehand
* Occurs before validation.
*/
public String setPostCode (Client obj, String newPostCode) throws FieldException
{
return newPostCode;
}
}
public ORMPipeLine pipes()
{
return new ClientPipeLineFactory<Client, Client> ((Client)this);
}
/**
* Use this instead of pipes() to get rid of type casting.
*/
public ClientPipeLineFactory<Client, Client> pipelineClient()
{
return (ClientPipeLineFactory<Client, Client>) pipes();
}
public static ClientPipeLineFactory<Client, Client> pipesClient(Collection<Client> items)
{
return REFERENCE_Client.new ClientPipeLineFactory<Client, Client> (items);
}
public static ClientPipeLineFactory<Client, Client> pipesClient(Client[] _items)
{
return pipesClient(Arrays.asList (_items));
}
public static ClientPipeLineFactory<Client, Client> pipesClient()
{
return pipesClient((Collection)null);
}
public class ClientPipeLineFactory<From extends BaseBusinessClass, Me extends Client> extends BaseBusinessClass.ORMPipeLine<From, Me>
{
public <Prev> ClientPipeLineFactory (PipeLine<From, Prev> pipeLine, Pipe<Prev, Me> nextPipe)
{
super (pipeLine, nextPipe);
}
public ClientPipeLineFactory (From seed)
{
super(seed);
}
public ClientPipeLineFactory (Collection<From> seed)
{
super(seed);
}
public PipeLine<From, ? extends Object> to(String name)
{
if (name.equals ("CompanyName"))
{
return toCompanyName ();
}
if (name.equals ("CompanyLogo"))
{
return toCompanyLogo ();
}
if (name.equals ("Email"))
{
return toEmail ();
}
if (name.equals ("ContactName"))
{
return toContactName ();
}
if (name.equals ("ContactSurname"))
{
return toContactSurname ();
}
if (name.equals ("Phone"))
{
return toPhone ();
}
if (name.equals ("State"))
{
return toState ();
}
if (name.equals ("Country"))
{
return toCountry ();
}
if (name.equals ("PostCode"))
{
return toPostCode ();
}
if (name.equals ("Company"))
{
return toCompany ();
}
return super.to(name);
}
public PipeLine<From, String> toCompanyName () { return pipe(new ORMAttributePipe<Me, String>(FIELD_CompanyName)); }
public PipeLine<From, BinaryContent> toCompanyLogo () { return pipe(new ORMAttributePipe<Me, BinaryContent>(FIELD_CompanyLogo)); }
public PipeLine<From, String> toEmail () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Email)); }
public PipeLine<From, String> toContactName () { return pipe(new ORMAttributePipe<Me, String>(FIELD_ContactName)); }
public PipeLine<From, String> toContactSurname () { return pipe(new ORMAttributePipe<Me, String>(FIELD_ContactSurname)); }
public PipeLine<From, String> toPhone () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Phone)); }
public PipeLine<From, State> toState () { return pipe(new ORMAttributePipe<Me, State>(FIELD_State)); }
public PipeLine<From, Countries> toCountry () { return pipe(new ORMAttributePipe<Me, Countries>(FIELD_Country)); }
public PipeLine<From, String> toPostCode () { return pipe(new ORMAttributePipe<Me, String>(FIELD_PostCode)); }
public Company.CompanyPipeLineFactory<From, Company> toCompany () { return toCompany (Filter.ALL); }
public Company.CompanyPipeLineFactory<From, Company> toCompany (Filter<Company> filter)
{
return Company.REFERENCE_Company.new CompanyPipeLineFactory<From, Company> (this, new ORMSingleAssocPipe<Me, Company>(SINGLEREFERENCE_Company, filter));
}
}
public boolean isTransientAttrib(String attribName)
{
return super.isTransientAttrib(attribName);
}
public boolean isTransientSingleReference(String assocName)
{
return super.isTransientSingleReference(assocName);
}
}
class DummyClient extends Client
{
// Default constructor primarily to support Externalisable
public DummyClient()
{
super();
}
public void assertValid ()
{
}
public Company getCompany () throws StorageException
{
return (Company)(Company.DUMMY_Company);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getCompanyID ()
{
return Company.DUMMY_Company.getObjectID();
}
}
/*
* IMPORTANT!!!! XSL Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2 rev3 [oneit.objstore.BusinessObjectTemplate.xsl]
*
* Version: 1.0
* Vendor: Apache Software Foundation (Xalan XSLTC)
* Vendor URL: http://xml.apache.org/xalan-j
*/
package performa.orm;
import java.io.*;
import java.util.*;
import oneit.appservices.config.*;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.attributes.*;
import oneit.objstore.rdbms.filters.*;
import oneit.objstore.parser.*;
import oneit.objstore.validator.*;
import oneit.objstore.utils.*;
import oneit.utils.*;
import oneit.utils.filter.Filter;
import oneit.utils.transform.*;
import oneit.utils.parsers.FieldException;
import performa.orm.types.*;
import performa.orm.types.TimeZone;
public abstract class BaseCompany extends BaseBusinessClass
{
// Reference instance for the object
public static final Company REFERENCE_Company = new Company ();
// Reference instance for the object
public static final Company DUMMY_Company = new DummyCompany ();
// Static constants corresponding to field names
public static final String FIELD_CompanyName = "CompanyName";
public static final String FIELD_HiringTeamType = "HiringTeamType";
public static final String FIELD_Industry = "Industry";
public static final String FIELD_TimeZone = "TimeZone";
public static final String SINGLEREFERENCE_AddedByUser = "AddedByUser";
public static final String MULTIPLEREFERENCE_Users = "Users";
public static final String BACKREF_Users = "";
public static final String MULTIPLEREFERENCE_Clients = "Clients";
public static final String BACKREF_Clients = "";
// Static constants corresponding to searches
public static final String SEARCH_All = "All";
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper<Company> HELPER_CompanyName = DefaultAttributeHelper.INSTANCE;
private static final EnumeratedAttributeHelper<Company, HiringTeamType> HELPER_HiringTeamType = new EnumeratedAttributeHelper<Company, HiringTeamType> (HiringTeamType.FACTORY_HiringTeamType);
private static final EnumeratedAttributeHelper<Company, Industry> HELPER_Industry = new EnumeratedAttributeHelper<Company, Industry> (Industry.FACTORY_Industry);
private static final EnumeratedAttributeHelper<Company, TimeZone> HELPER_TimeZone = new EnumeratedAttributeHelper<Company, TimeZone> (TimeZone.FACTORY_TimeZone);
// Private attributes corresponding to business object data
private String _CompanyName;
private HiringTeamType _HiringTeamType;
private Industry _Industry;
private TimeZone _TimeZone;
// Private attributes corresponding to single references
private SingleAssociation<Company, CompanyUser> _AddedByUser;
// Private attributes corresponding to multiple references
private MultipleAssociation<Company, CompanyUser> _Users;
private MultipleAssociation<Company, Client> _Clients;
// Map of maps of metadata
private static final Map ATTRIBUTES_METADATA_Company = new HashMap ();
// Arrays of validators for each attribute
private static final AttributeValidator[] FIELD_CompanyName_Validators;
private static final AttributeValidator[] FIELD_HiringTeamType_Validators;
private static final AttributeValidator[] FIELD_Industry_Validators;
private static final AttributeValidator[] FIELD_TimeZone_Validators;
// Arrays of behaviour decorators
private static final CompanyBehaviourDecorator[] Company_BehaviourDecorators;
static
{
try
{
String tmp_Users = CompanyUser.BACKREF_Company;
String tmp_Clients = Client.BACKREF_Company;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_Users();
setupAssocMetaData_Clients();
setupAssocMetaData_AddedByUser();
FIELD_CompanyName_Validators = (AttributeValidator[])setupAttribMetaData_CompanyName(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_HiringTeamType_Validators = (AttributeValidator[])setupAttribMetaData_HiringTeamType(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_Industry_Validators = (AttributeValidator[])setupAttribMetaData_Industry(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_TimeZone_Validators = (AttributeValidator[])setupAttribMetaData_TimeZone(validatorMapping).toArray (new AttributeValidator[0]);
REFERENCE_Company.initialiseReference ();
DUMMY_Company.initialiseReference ();
Company_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(Company.class).toArray(new CompanyBehaviourDecorator[0]);
}
catch (RuntimeException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
throw e;
}
}
// Meta Info setup
private static void setupAssocMetaData_Users()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Company");
metaInfo.put ("name", "Users");
metaInfo.put ("type", "CompanyUser");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Company.Users:", metaInfo);
ATTRIBUTES_METADATA_Company.put (MULTIPLEREFERENCE_Users, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static void setupAssocMetaData_Clients()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Company");
metaInfo.put ("name", "Clients");
metaInfo.put ("type", "Client");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Company.Clients:", metaInfo);
ATTRIBUTES_METADATA_Company.put (MULTIPLEREFERENCE_Clients, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static void setupAssocMetaData_AddedByUser()
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "added_by_user_id");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "AddedByUser");
metaInfo.put ("type", "CompanyUser");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Company.AddedByUser:", metaInfo);
ATTRIBUTES_METADATA_Company.put (SINGLEREFERENCE_AddedByUser, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static List setupAttribMetaData_CompanyName(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "company_name");
metaInfo.put ("length", "100");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "CompanyName");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Company.CompanyName:", metaInfo);
ATTRIBUTES_METADATA_Company.put (FIELD_CompanyName, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(Company.class, "CompanyName", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Company.CompanyName:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_HiringTeamType(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("attribHelper", "EnumeratedAttributeHelper");
metaInfo.put ("dbcol", "hiring_team_type");
metaInfo.put ("mandatory", "false");
metaInfo.put ("name", "HiringTeamType");
metaInfo.put ("type", "HiringTeamType");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Company.HiringTeamType:", metaInfo);
ATTRIBUTES_METADATA_Company.put (FIELD_HiringTeamType, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(Company.class, "HiringTeamType", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Company.HiringTeamType:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_Industry(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("attribHelper", "EnumeratedAttributeHelper");
metaInfo.put ("dbcol", "industry");
metaInfo.put ("mandatory", "false");
metaInfo.put ("name", "Industry");
metaInfo.put ("type", "Industry");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Company.Industry:", metaInfo);
ATTRIBUTES_METADATA_Company.put (FIELD_Industry, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(Company.class, "Industry", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Company.Industry:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_TimeZone(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("attribHelper", "EnumeratedAttributeHelper");
metaInfo.put ("dbcol", "time_zone");
metaInfo.put ("mandatory", "false");
metaInfo.put ("name", "TimeZone");
metaInfo.put ("type", "TimeZone");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Company.TimeZone:", metaInfo);
ATTRIBUTES_METADATA_Company.put (FIELD_TimeZone, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(Company.class, "TimeZone", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Company.TimeZone:", validators);
return validators;
}
// END OF STATIC METADATA DEFINITION
// This constructor should not be called
protected BaseCompany ()
{
}
protected BBCBehaviourDecorator[] getBehaviours()
{
return Company_BehaviourDecorators;
}
// Initialise the attributes
protected void _initialiseNewObjAttributes (ObjectTransaction transaction) throws StorageException
{
super._initialiseNewObjAttributes (transaction);
_CompanyName = (String)(HELPER_CompanyName.initialise (_CompanyName));
_HiringTeamType = (HiringTeamType)(HELPER_HiringTeamType.initialise (_HiringTeamType));
_Industry = (Industry)(HELPER_Industry.initialise (_Industry));
_TimeZone = (TimeZone)(HELPER_TimeZone.initialise (_TimeZone));
}
// Initialise the associations
protected void _initialiseAssociations ()
{
super._initialiseAssociations ();
_AddedByUser = new SingleAssociation<Company, CompanyUser> (this, SINGLEREFERENCE_AddedByUser, null, CompanyUser.REFERENCE_CompanyUser, "tl_Company");
_Users = new MultipleAssociation<Company, CompanyUser> (this, MULTIPLEREFERENCE_Users, CompanyUser.SINGLEREFERENCE_Company, CompanyUser.REFERENCE_CompanyUser);
_Clients = new MultipleAssociation<Company, Client> (this, MULTIPLEREFERENCE_Clients, Client.SINGLEREFERENCE_Company, Client.REFERENCE_Client);
}
// Initialise the associations
protected BaseBusinessClass initialiseReference ()
{
super.initialiseReference ();
_AddedByUser = new SingleAssociation<Company, CompanyUser> (this, SINGLEREFERENCE_AddedByUser, null, CompanyUser.REFERENCE_CompanyUser, "tl_Company");
_Users = new MultipleAssociation<Company, CompanyUser> (this, MULTIPLEREFERENCE_Users, CompanyUser.SINGLEREFERENCE_Company, CompanyUser.REFERENCE_CompanyUser);
_Clients = new MultipleAssociation<Company, Client> (this, MULTIPLEREFERENCE_Clients, Client.SINGLEREFERENCE_Company, Client.REFERENCE_Client);
return this;
}
/**
* Get the attribute CompanyName
*/
public String getCompanyName ()
{
assertValid();
String valToReturn = _CompanyName;
for (CompanyBehaviourDecorator bhd : Company_BehaviourDecorators)
{
valToReturn = bhd.getCompanyName ((Company)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preCompanyNameChange (String newCompanyName) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postCompanyNameChange () throws FieldException
{
}
public FieldWriteability getWriteability_CompanyName ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute CompanyName. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setCompanyName (String newCompanyName) throws FieldException
{
boolean oldAndNewIdentical = HELPER_CompanyName.compare (_CompanyName, newCompanyName);
try
{
for (CompanyBehaviourDecorator bhd : Company_BehaviourDecorators)
{
newCompanyName = bhd.setCompanyName ((Company)this, newCompanyName);
oldAndNewIdentical = HELPER_CompanyName.compare (_CompanyName, newCompanyName);
}
BusinessObjectParser.assertFieldCondition (newCompanyName != null, this, FIELD_CompanyName, "mandatory");
if (FIELD_CompanyName_Validators.length > 0)
{
Object newCompanyNameObj = HELPER_CompanyName.toObject (newCompanyName);
if (newCompanyNameObj != null)
{
int loopMax = FIELD_CompanyName_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_Company.get (FIELD_CompanyName);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_CompanyName_Validators[v].checkAttribute (this, FIELD_CompanyName, metadata, newCompanyNameObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_CompanyName () != FieldWriteability.FALSE, "Field CompanyName is not writeable");
preCompanyNameChange (newCompanyName);
markFieldChange (FIELD_CompanyName);
_CompanyName = newCompanyName;
postFieldChange (FIELD_CompanyName);
postCompanyNameChange ();
}
}
/**
* Get the attribute HiringTeamType
*/
public HiringTeamType getHiringTeamType ()
{
assertValid();
HiringTeamType valToReturn = _HiringTeamType;
for (CompanyBehaviourDecorator bhd : Company_BehaviourDecorators)
{
valToReturn = bhd.getHiringTeamType ((Company)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preHiringTeamTypeChange (HiringTeamType newHiringTeamType) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postHiringTeamTypeChange () throws FieldException
{
}
public FieldWriteability getWriteability_HiringTeamType ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute HiringTeamType. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setHiringTeamType (HiringTeamType newHiringTeamType) throws FieldException
{
boolean oldAndNewIdentical = HELPER_HiringTeamType.compare (_HiringTeamType, newHiringTeamType);
try
{
for (CompanyBehaviourDecorator bhd : Company_BehaviourDecorators)
{
newHiringTeamType = bhd.setHiringTeamType ((Company)this, newHiringTeamType);
oldAndNewIdentical = HELPER_HiringTeamType.compare (_HiringTeamType, newHiringTeamType);
}
if (FIELD_HiringTeamType_Validators.length > 0)
{
Object newHiringTeamTypeObj = HELPER_HiringTeamType.toObject (newHiringTeamType);
if (newHiringTeamTypeObj != null)
{
int loopMax = FIELD_HiringTeamType_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_Company.get (FIELD_HiringTeamType);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_HiringTeamType_Validators[v].checkAttribute (this, FIELD_HiringTeamType, metadata, newHiringTeamTypeObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_HiringTeamType () != FieldWriteability.FALSE, "Field HiringTeamType is not writeable");
preHiringTeamTypeChange (newHiringTeamType);
markFieldChange (FIELD_HiringTeamType);
_HiringTeamType = newHiringTeamType;
postFieldChange (FIELD_HiringTeamType);
postHiringTeamTypeChange ();
}
}
/**
* Get the attribute Industry
*/
public Industry getIndustry ()
{
assertValid();
Industry valToReturn = _Industry;
for (CompanyBehaviourDecorator bhd : Company_BehaviourDecorators)
{
valToReturn = bhd.getIndustry ((Company)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preIndustryChange (Industry newIndustry) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postIndustryChange () throws FieldException
{
}
public FieldWriteability getWriteability_Industry ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute Industry. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setIndustry (Industry newIndustry) throws FieldException
{
boolean oldAndNewIdentical = HELPER_Industry.compare (_Industry, newIndustry);
try
{
for (CompanyBehaviourDecorator bhd : Company_BehaviourDecorators)
{
newIndustry = bhd.setIndustry ((Company)this, newIndustry);
oldAndNewIdentical = HELPER_Industry.compare (_Industry, newIndustry);
}
if (FIELD_Industry_Validators.length > 0)
{
Object newIndustryObj = HELPER_Industry.toObject (newIndustry);
if (newIndustryObj != null)
{
int loopMax = FIELD_Industry_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_Company.get (FIELD_Industry);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_Industry_Validators[v].checkAttribute (this, FIELD_Industry, metadata, newIndustryObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_Industry () != FieldWriteability.FALSE, "Field Industry is not writeable");
preIndustryChange (newIndustry);
markFieldChange (FIELD_Industry);
_Industry = newIndustry;
postFieldChange (FIELD_Industry);
postIndustryChange ();
}
}
/**
* Get the attribute TimeZone
*/
public TimeZone getTimeZone ()
{
assertValid();
TimeZone valToReturn = _TimeZone;
for (CompanyBehaviourDecorator bhd : Company_BehaviourDecorators)
{
valToReturn = bhd.getTimeZone ((Company)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preTimeZoneChange (TimeZone newTimeZone) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postTimeZoneChange () throws FieldException
{
}
public FieldWriteability getWriteability_TimeZone ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute TimeZone. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setTimeZone (TimeZone newTimeZone) throws FieldException
{
boolean oldAndNewIdentical = HELPER_TimeZone.compare (_TimeZone, newTimeZone);
try
{
for (CompanyBehaviourDecorator bhd : Company_BehaviourDecorators)
{
newTimeZone = bhd.setTimeZone ((Company)this, newTimeZone);
oldAndNewIdentical = HELPER_TimeZone.compare (_TimeZone, newTimeZone);
}
if (FIELD_TimeZone_Validators.length > 0)
{
Object newTimeZoneObj = HELPER_TimeZone.toObject (newTimeZone);
if (newTimeZoneObj != null)
{
int loopMax = FIELD_TimeZone_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_Company.get (FIELD_TimeZone);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_TimeZone_Validators[v].checkAttribute (this, FIELD_TimeZone, metadata, newTimeZoneObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_TimeZone () != FieldWriteability.FALSE, "Field TimeZone is not writeable");
preTimeZoneChange (newTimeZone);
markFieldChange (FIELD_TimeZone);
_TimeZone = newTimeZone;
postFieldChange (FIELD_TimeZone);
postTimeZoneChange ();
}
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getSingleAssocs()
{
List result = super.getSingleAssocs ();
result.add("AddedByUser");
return result;
}
public BaseBusinessClass getSingleAssocReferenceInstance (String assocName)
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_AddedByUser))
{
return _AddedByUser.getReferencedType ();
}
else
{
return super.getSingleAssocReferenceInstance (assocName);
}
}
public String getSingleAssocBackReference(String assocName)
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_AddedByUser))
{
return null ;
}
else
{
return super.getSingleAssocBackReference (assocName);
}
}
public BaseBusinessClass getSingleAssoc (String assocName) throws StorageException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_AddedByUser))
{
return getAddedByUser ();
}
else
{
return super.getSingleAssoc (assocName);
}
}
public BaseBusinessClass getSingleAssoc (String assocName, Get getType) throws StorageException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_AddedByUser))
{
return getAddedByUser (getType);
}
else
{
return super.getSingleAssoc (assocName, getType);
}
}
public Long getSingleAssocID (String assocName) throws StorageException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_AddedByUser))
{
return getAddedByUserID ();
}
else
{
return super.getSingleAssocID (assocName);
}
}
public void setSingleAssoc (String assocName, BaseBusinessClass newValue) throws StorageException, FieldException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_AddedByUser))
{
setAddedByUser ((CompanyUser)(newValue));
}
else
{
super.setSingleAssoc (assocName, newValue);
}
}
/**
* Get the reference AddedByUser
*/
public CompanyUser getAddedByUser () throws StorageException
{
assertValid();
try
{
return (CompanyUser)(_AddedByUser.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in Company:", this.getObjectID (), ", was trying to get CompanyUser:", getAddedByUserID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _AddedByUser.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public CompanyUser getAddedByUser (Get getType) throws StorageException
{
assertValid();
return _AddedByUser.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getAddedByUserID ()
{
assertValid();
if (_AddedByUser == null)
{
return null;
}
else
{
return _AddedByUser.getID ();
}
}
/**
* Called prior to the assoc changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preAddedByUserChange (CompanyUser newAddedByUser) throws FieldException
{
}
/**
* Called after the assoc changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postAddedByUserChange () throws FieldException
{
}
public FieldWriteability getWriteability_AddedByUser ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference AddedByUser. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setAddedByUser (CompanyUser newAddedByUser) throws StorageException, FieldException
{
BusinessObjectParser.assertFieldCondition (newAddedByUser != null, this, SINGLEREFERENCE_AddedByUser, "mandatory");
if (_AddedByUser.wouldReferencedChange (newAddedByUser))
{
assertValid();
Debug.assertion (getWriteability_AddedByUser () != FieldWriteability.FALSE, "Assoc AddedByUser is not writeable");
preAddedByUserChange (newAddedByUser);
_AddedByUser.set (newAddedByUser);
postAddedByUserChange ();
}
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getMultiAssocs()
{
List result = super.getMultiAssocs ();
result.add("Users");
result.add("Clients");
return result;
}
/**
* Get the reference instance for the multi assoc name.
*/
public BaseBusinessClass getMultiAssocReferenceInstance(String attribName)
{
if (MULTIPLEREFERENCE_Users.equals(attribName))
{
return CompanyUser.REFERENCE_CompanyUser ;
}
if (MULTIPLEREFERENCE_Clients.equals(attribName))
{
return Client.REFERENCE_Client ;
}
return super.getMultiAssocReferenceInstance(attribName);
}
public String getMultiAssocBackReference(String attribName)
{
if (MULTIPLEREFERENCE_Users.equals(attribName))
{
return CompanyUser.SINGLEREFERENCE_Company ;
}
if (MULTIPLEREFERENCE_Clients.equals(attribName))
{
return Client.SINGLEREFERENCE_Company ;
}
return super.getMultiAssocBackReference(attribName);
}
/**
* Get the assoc count for the multi assoc name.
*/
public int getMultiAssocCount(String attribName) throws StorageException
{
if (MULTIPLEREFERENCE_Users.equals(attribName))
{
return this.getUsersCount();
}
if (MULTIPLEREFERENCE_Clients.equals(attribName))
{
return this.getClientsCount();
}
return super.getMultiAssocCount(attribName);
}
/**
* Get the assoc at a particular index
*/
public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException
{
if (MULTIPLEREFERENCE_Users.equals(attribName))
{
return this.getUsersAt(index);
}
if (MULTIPLEREFERENCE_Clients.equals(attribName))
{
return this.getClientsAt(index);
}
return super.getMultiAssocAt(attribName, index);
}
/**
* Add to a multi assoc by attribute name
*/
public void addToMultiAssoc(String attribName, BaseBusinessClass newElement) throws StorageException
{
if (MULTIPLEREFERENCE_Users.equals(attribName))
{
addToUsers((CompanyUser)newElement);
return;
}
if (MULTIPLEREFERENCE_Clients.equals(attribName))
{
addToClients((Client)newElement);
return;
}
super.addToMultiAssoc(attribName, newElement);
}
/**
* Remove from a multi assoc by attribute name
*/
public void removeFromMultiAssoc(String attribName, BaseBusinessClass oldElement) throws StorageException
{
if (MULTIPLEREFERENCE_Users.equals(attribName))
{
removeFromUsers((CompanyUser)oldElement);
return;
}
if (MULTIPLEREFERENCE_Clients.equals(attribName))
{
removeFromClients((Client)oldElement);
return;
}
super.removeFromMultiAssoc(attribName, oldElement);
}
protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements)
{
if (MULTIPLEREFERENCE_Users.equals(attribName))
{
_Users.__loadAssociation (elements);
return;
}
if (MULTIPLEREFERENCE_Clients.equals(attribName))
{
_Clients.__loadAssociation (elements);
return;
}
super.__loadMultiAssoc(attribName, elements);
}
protected boolean __isMultiAssocLoaded (String attribName)
{
if (MULTIPLEREFERENCE_Users.equals(attribName))
{
return _Users.isLoaded ();
}
if (MULTIPLEREFERENCE_Clients.equals(attribName))
{
return _Clients.isLoaded ();
}
return super.__isMultiAssocLoaded(attribName);
}
public FieldWriteability getWriteability_Users ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
public int getUsersCount () throws StorageException
{
assertValid();
return _Users.getReferencedObjectsCount ();
}
public void addToUsers (CompanyUser newElement) throws StorageException
{
if (_Users.wouldAddChange (newElement))
{
assertValid();
Debug.assertion (getWriteability_Users () != FieldWriteability.FALSE, "MultiAssoc Users is not writeable (add)");
_Users.appendElement (newElement);
try
{
if (newElement.getCompany () != this)
{
newElement.setCompany ((Company)(this));
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public void removeFromUsers (CompanyUser elementToRemove) throws StorageException
{
if (_Users.wouldRemoveChange (elementToRemove))
{
assertValid();
Debug.assertion (getWriteability_Users () != FieldWriteability.FALSE, "MultiAssoc Users is not writeable (remove)");
_Users.removeElement (elementToRemove);
try
{
if (elementToRemove.getCompany () != null)
{
elementToRemove.setCompany (null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public CompanyUser getUsersAt (int index) throws StorageException
{
return (CompanyUser)(_Users.getElementAt (index));
}
public SortedSet<CompanyUser> getUsersSet () throws StorageException
{
return _Users.getSet ();
}
public FieldWriteability getWriteability_Clients ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
public int getClientsCount () throws StorageException
{
assertValid();
return _Clients.getReferencedObjectsCount ();
}
public void addToClients (Client newElement) throws StorageException
{
if (_Clients.wouldAddChange (newElement))
{
assertValid();
Debug.assertion (getWriteability_Clients () != FieldWriteability.FALSE, "MultiAssoc Clients is not writeable (add)");
_Clients.appendElement (newElement);
try
{
if (newElement.getCompany () != this)
{
newElement.setCompany ((Company)(this));
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public void removeFromClients (Client elementToRemove) throws StorageException
{
if (_Clients.wouldRemoveChange (elementToRemove))
{
assertValid();
Debug.assertion (getWriteability_Clients () != FieldWriteability.FALSE, "MultiAssoc Clients is not writeable (remove)");
_Clients.removeElement (elementToRemove);
try
{
if (elementToRemove.getCompany () != null)
{
elementToRemove.setCompany (null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public Client getClientsAt (int index) throws StorageException
{
return (Client)(_Clients.getElementAt (index));
}
public SortedSet<Client> getClientsSet () throws StorageException
{
return _Clients.getSet ();
}
public void onDelete ()
{
try
{
for(CompanyUser referenced : CollectionUtils.reverse(getUsersSet()))
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Company from ", getObjectID (), " to ", referenced.getObjectID ());
referenced.setCompany(null);
}
for(Client referenced : CollectionUtils.reverse(getClientsSet()))
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Company from ", getObjectID (), " to ", referenced.getObjectID ());
referenced.setCompany(null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
super.onDelete ();
}
public Company newInstance ()
{
return new Company ();
}
public Company referenceInstance ()
{
return REFERENCE_Company;
}
public Company getInTransaction (ObjectTransaction t) throws StorageException
{
return getCompanyByID (t, getObjectID());
}
public BaseBusinessClass dummyInstance ()
{
return DUMMY_Company;
}
public String getBaseSetName ()
{
return "tl_Company";
}
/**
* This is where an object returns the Persistent sets that will
* store it into the database.
* The should be entered into allSets
*/
public void getPersistentSets (PersistentSetCollection allSets)
{
ObjectStatus myStatus = getStatus ();
PersistentSetStatus myPSetStatus = myStatus.getPSetStatus();
ObjectID myID = getID();
super.getPersistentSets (allSets);
PersistentSet tl_CompanyPSet = allSets.getPersistentSet (myID, "tl_Company", myPSetStatus);
tl_CompanyPSet.setAttrib (FIELD_ObjectID, myID);
tl_CompanyPSet.setAttrib (FIELD_CompanyName, HELPER_CompanyName.toObject (_CompanyName)); //
tl_CompanyPSet.setAttrib (FIELD_HiringTeamType, HELPER_HiringTeamType.toObject (_HiringTeamType)); //
tl_CompanyPSet.setAttrib (FIELD_Industry, HELPER_Industry.toObject (_Industry)); //
tl_CompanyPSet.setAttrib (FIELD_TimeZone, HELPER_TimeZone.toObject (_TimeZone)); //
_AddedByUser.getPersistentSets (allSets);
}
/**
* Sets the objects state based on Persistent sets.
*/
public void setFromPersistentSets (ObjectID objectID, PersistentSetCollection allSets)
{
super.setFromPersistentSets (objectID, allSets);
PersistentSet tl_CompanyPSet = allSets.getPersistentSet (objectID, "tl_Company");
_CompanyName = (String)(HELPER_CompanyName.fromObject (_CompanyName, tl_CompanyPSet.getAttrib (FIELD_CompanyName))); //
_HiringTeamType = (HiringTeamType)(HELPER_HiringTeamType.fromObject (_HiringTeamType, tl_CompanyPSet.getAttrib (FIELD_HiringTeamType))); //
_Industry = (Industry)(HELPER_Industry.fromObject (_Industry, tl_CompanyPSet.getAttrib (FIELD_Industry))); //
_TimeZone = (TimeZone)(HELPER_TimeZone.fromObject (_TimeZone, tl_CompanyPSet.getAttrib (FIELD_TimeZone))); //
_AddedByUser.setFromPersistentSets (objectID, allSets);
}
public void setAttributesFrom (BaseBusinessClass other, MultiException e)
{
super.setAttributesFrom (other, e);
if (other instanceof Company)
{
Company otherCompany = (Company)other;
try
{
setCompanyName (otherCompany.getCompanyName ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setHiringTeamType (otherCompany.getHiringTeamType ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setIndustry (otherCompany.getIndustry ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setTimeZone (otherCompany.getTimeZone ());
}
catch (FieldException ex)
{
e.addException (ex);
}
}
}
/**
* Set the attributes in this to copies of the attributes in source.
*/
public void copyAttributesFrom (BaseBusinessClass source)
{
super.copyAttributesFrom (source);
if (source instanceof BaseCompany)
{
BaseCompany sourceCompany = (BaseCompany)(source);
_CompanyName = sourceCompany._CompanyName;
_HiringTeamType = sourceCompany._HiringTeamType;
_Industry = sourceCompany._Industry;
_TimeZone = sourceCompany._TimeZone;
}
}
/**
* Set the associations in this to copies of the attributes in source.
*/
public void copySingleAssociationsFrom (BaseBusinessClass source, boolean linkToGhosts)
{
super.copySingleAssociationsFrom (source, linkToGhosts);
if (source instanceof BaseCompany)
{
BaseCompany sourceCompany = (BaseCompany)(source);
_AddedByUser.copyFrom (sourceCompany._AddedByUser, linkToGhosts);
}
}
/**
* Set the associations in this to copies of the attributes in source.
*/
public void copyAssociationsFrom (BaseBusinessClass source, boolean linkToGhosts)
{
super.copyAssociationsFrom (source, linkToGhosts);
if (source instanceof BaseCompany)
{
BaseCompany sourceCompany = (BaseCompany)(source);
_Users.copyFrom (sourceCompany._Users, linkToGhosts);
_Clients.copyFrom (sourceCompany._Clients, linkToGhosts);
}
}
public void validate (ValidationContext context)
{
super.validate (context);
context.check (getAddedByUserID() != null, this, SINGLEREFERENCE_AddedByUser, "mandatory");
}
/**
* Subclasses must override this to read in their attributes
*/
protected void readExternalData(Map<String, Object> vals) throws IOException, ClassNotFoundException
{
super.readExternalData(vals);
_CompanyName = (String)(HELPER_CompanyName.readExternal (_CompanyName, vals.get(FIELD_CompanyName))); //
_HiringTeamType = (HiringTeamType)(HELPER_HiringTeamType.readExternal (_HiringTeamType, vals.get(FIELD_HiringTeamType))); //
_Industry = (Industry)(HELPER_Industry.readExternal (_Industry, vals.get(FIELD_Industry))); //
_TimeZone = (TimeZone)(HELPER_TimeZone.readExternal (_TimeZone, vals.get(FIELD_TimeZone))); //
_AddedByUser.readExternalData(vals.get(SINGLEREFERENCE_AddedByUser));
_Users.readExternalData(vals.get(MULTIPLEREFERENCE_Users));
_Clients.readExternalData(vals.get(MULTIPLEREFERENCE_Clients));
}
/**
* Subclasses must override this to write out their attributes
*/
protected void writeExternalData(Map<String, Object> vals) throws IOException
{
super.writeExternalData(vals);
vals.put (FIELD_CompanyName, HELPER_CompanyName.writeExternal (_CompanyName));
vals.put (FIELD_HiringTeamType, HELPER_HiringTeamType.writeExternal (_HiringTeamType));
vals.put (FIELD_Industry, HELPER_Industry.writeExternal (_Industry));
vals.put (FIELD_TimeZone, HELPER_TimeZone.writeExternal (_TimeZone));
vals.put (SINGLEREFERENCE_AddedByUser, _AddedByUser.writeExternalData());
vals.put (MULTIPLEREFERENCE_Users, _Users.writeExternalData());
vals.put (MULTIPLEREFERENCE_Clients, _Clients.writeExternalData());
}
public void compare (BaseBusinessClass other, AttributeChangeListener listener) throws StorageException
{
super.compare (other, listener);
if (other instanceof BaseCompany)
{
BaseCompany otherCompany = (BaseCompany)(other);
if (!HELPER_CompanyName.compare(this._CompanyName, otherCompany._CompanyName))
{
listener.notifyFieldChange(this, other, FIELD_CompanyName, HELPER_CompanyName.toObject(this._CompanyName), HELPER_CompanyName.toObject(otherCompany._CompanyName));
}
if (!HELPER_HiringTeamType.compare(this._HiringTeamType, otherCompany._HiringTeamType))
{
listener.notifyFieldChange(this, other, FIELD_HiringTeamType, HELPER_HiringTeamType.toObject(this._HiringTeamType), HELPER_HiringTeamType.toObject(otherCompany._HiringTeamType));
}
if (!HELPER_Industry.compare(this._Industry, otherCompany._Industry))
{
listener.notifyFieldChange(this, other, FIELD_Industry, HELPER_Industry.toObject(this._Industry), HELPER_Industry.toObject(otherCompany._Industry));
}
if (!HELPER_TimeZone.compare(this._TimeZone, otherCompany._TimeZone))
{
listener.notifyFieldChange(this, other, FIELD_TimeZone, HELPER_TimeZone.toObject(this._TimeZone), HELPER_TimeZone.toObject(otherCompany._TimeZone));
}
// Compare single assocs
_AddedByUser.compare (otherCompany._AddedByUser, listener);
// Compare multiple assocs
_Users.compare (otherCompany._Users, listener);
_Clients.compare (otherCompany._Clients, listener);
}
}
public void visitTransients (AttributeVisitor visitor) throws StorageException
{
super.visitAttributes (visitor);
}
public void visitAttributes (AttributeVisitor visitor) throws StorageException
{
super.visitAttributes (visitor);
visitor.visitField(this, FIELD_CompanyName, HELPER_CompanyName.toObject(getCompanyName()));
visitor.visitField(this, FIELD_HiringTeamType, HELPER_HiringTeamType.toObject(getHiringTeamType()));
visitor.visitField(this, FIELD_Industry, HELPER_Industry.toObject(getIndustry()));
visitor.visitField(this, FIELD_TimeZone, HELPER_TimeZone.toObject(getTimeZone()));
visitor.visitAssociation (_AddedByUser);
visitor.visitAssociation (_Users);
visitor.visitAssociation (_Clients);
}
public void visitAssociations (AssociationVisitor visitor, AssociatedScope scope) throws StorageException
{
super.visitAssociations (visitor, scope);
if (scope.includes (_AddedByUser))
{
visitor.visit (_AddedByUser);
}
if (scope.includes (_Users))
{
visitor.visit (_Users);
}
if (scope.includes (_Clients))
{
visitor.visit (_Clients);
}
}
public static Company createCompany (ObjectTransaction transaction) throws StorageException
{
Company result = new Company ();
result.initialiseNewObject (transaction);
return result;
}
public static Company getCompanyByID (ObjectTransaction transaction, Long objectID) throws StorageException
{
return (Company)(transaction.getObjectByID (REFERENCE_Company, objectID));
}
public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_CompanyName))
{
return filter.matches (getCompanyName ());
}
else if (attribName.equals (FIELD_HiringTeamType))
{
return filter.matches (getHiringTeamType ());
}
else if (attribName.equals (FIELD_Industry))
{
return filter.matches (getIndustry ());
}
else if (attribName.equals (FIELD_TimeZone))
{
return filter.matches (getTimeZone ());
}
else if (attribName.equals (SINGLEREFERENCE_AddedByUser))
{
return filter.matches (getAddedByUser ());
}
else
{
return super.testFilter (attribName, filter);
}
}
public static SearchAll SearchByAll () { return new SearchAll (); }
public static class SearchAll extends SearchObject<Company>
{
public SearchAll andObjectID (QueryFilter<Long> filter)
{
filter.addFilter (context, "tl_Company.object_id", FIELD_ObjectID);
return this;
}
public SearchAll andObjectCreated (QueryFilter<Date> filter)
{
filter.addFilter (context, "tl_Company.object_created_date", FIELD_ObjectCreated);
return this;
}
public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{
filter.addFilter (context, "tl_Company.object_last_updated_date", FIELD_ObjectLastModified);
return this;
}
public SearchAll andCompanyName (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_Company.company_name", "CompanyName");
return this;
}
public SearchAll andHiringTeamType (QueryFilter<HiringTeamType> filter)
{
filter.addFilter (context, "tl_Company.hiring_team_type", "HiringTeamType");
return this;
}
public SearchAll andIndustry (QueryFilter<Industry> filter)
{
filter.addFilter (context, "tl_Company.industry", "Industry");
return this;
}
public SearchAll andTimeZone (QueryFilter<TimeZone> filter)
{
filter.addFilter (context, "tl_Company.time_zone", "TimeZone");
return this;
}
public SearchAll andAddedByUser (QueryFilter<CompanyUser> filter)
{
filter.addFilter (context, "tl_Company.added_by_user_id", "AddedByUser");
return this;
}
public Company[]
search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_Company, SEARCH_All, criteria);
Set<Company> typedResults = new LinkedHashSet <Company> ();
for (BaseBusinessClass bbcResult : results)
{
Company aResult = (Company)bbcResult;
typedResults.add (aResult);
}
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new Company[0]);
}
}
public static Company[]
searchAll (ObjectTransaction transaction) throws StorageException
{
return SearchByAll ()
.search (transaction);
}
public Object getAttribute (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_CompanyName))
{
return HELPER_CompanyName.toObject (getCompanyName ());
}
else if (attribName.equals (FIELD_HiringTeamType))
{
return HELPER_HiringTeamType.toObject (getHiringTeamType ());
}
else if (attribName.equals (FIELD_Industry))
{
return HELPER_Industry.toObject (getIndustry ());
}
else if (attribName.equals (FIELD_TimeZone))
{
return HELPER_TimeZone.toObject (getTimeZone ());
}
else
{
return super.getAttribute (attribName);
}
}
public AttributeHelper getAttributeHelper (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_CompanyName))
{
return HELPER_CompanyName;
}
else if (attribName.equals (FIELD_HiringTeamType))
{
return HELPER_HiringTeamType;
}
else if (attribName.equals (FIELD_Industry))
{
return HELPER_Industry;
}
else if (attribName.equals (FIELD_TimeZone))
{
return HELPER_TimeZone;
}
else
{
return super.getAttributeHelper (attribName);
}
}
public void setAttribute (String attribName, Object attribValue) throws FieldException
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_CompanyName))
{
setCompanyName ((String)(HELPER_CompanyName.fromObject (_CompanyName, attribValue)));
}
else if (attribName.equals (FIELD_HiringTeamType))
{
setHiringTeamType ((HiringTeamType)(HELPER_HiringTeamType.fromObject (_HiringTeamType, attribValue)));
}
else if (attribName.equals (FIELD_Industry))
{
setIndustry ((Industry)(HELPER_Industry.fromObject (_Industry, attribValue)));
}
else if (attribName.equals (FIELD_TimeZone))
{
setTimeZone ((TimeZone)(HELPER_TimeZone.fromObject (_TimeZone, attribValue)));
}
else
{
super.setAttribute (attribName, attribValue);
}
}
public boolean isWriteable (String fieldName)
{
return getWriteable (fieldName) == FieldWriteability.TRUE;
}
public FieldWriteability getWriteable (String fieldName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (fieldName.equals (FIELD_CompanyName))
{
return getWriteability_CompanyName ();
}
else if (fieldName.equals (FIELD_HiringTeamType))
{
return getWriteability_HiringTeamType ();
}
else if (fieldName.equals (FIELD_Industry))
{
return getWriteability_Industry ();
}
else if (fieldName.equals (FIELD_TimeZone))
{
return getWriteability_TimeZone ();
}
else if (fieldName.equals (MULTIPLEREFERENCE_Users))
{
return getWriteability_Users ();
}
else if (fieldName.equals (MULTIPLEREFERENCE_Clients))
{
return getWriteability_Clients ();
}
else if (fieldName.equals (SINGLEREFERENCE_AddedByUser))
{
return getWriteability_AddedByUser ();
}
else
{
return super.getWriteable (fieldName);
}
}
public void putUnwriteable (Set<String> fields)
{
if (getWriteability_CompanyName () != FieldWriteability.TRUE)
{
fields.add (FIELD_CompanyName);
}
if (getWriteability_HiringTeamType () != FieldWriteability.TRUE)
{
fields.add (FIELD_HiringTeamType);
}
if (getWriteability_Industry () != FieldWriteability.TRUE)
{
fields.add (FIELD_Industry);
}
if (getWriteability_TimeZone () != FieldWriteability.TRUE)
{
fields.add (FIELD_TimeZone);
}
super.putUnwriteable (fields);
}
public List<AbstractAttribute> getAttributes ()
{
List result = super.getAttributes ();
result.add(HELPER_CompanyName.getAttribObject (getClass (), _CompanyName, true, FIELD_CompanyName));
result.add(HELPER_HiringTeamType.getAttribObject (getClass (), _HiringTeamType, false, FIELD_HiringTeamType));
result.add(HELPER_Industry.getAttribObject (getClass (), _Industry, false, FIELD_Industry));
result.add(HELPER_TimeZone.getAttribObject (getClass (), _TimeZone, false, FIELD_TimeZone));
return result;
}
public Map getAttributeMetadata (String attribute)
{
if (ATTRIBUTES_METADATA_Company.containsKey (attribute))
{
return (Map)ATTRIBUTES_METADATA_Company.get (attribute);
}
else
{
return super.getAttributeMetadata (attribute);
}
}
public Object getAttributeMetadata (String attribute, String metadata)
{
if (ATTRIBUTES_METADATA_Company.containsKey (attribute))
{
return ((Map)ATTRIBUTES_METADATA_Company.get (attribute)).get(metadata);
}
else
{
return super.getAttributeMetadata (attribute, metadata);
}
}
public void preCommit (boolean willBeStored) throws Exception
{
super.preCommit(willBeStored);
if(willBeStored)
{
}
}
public oneit.servlets.objstore.binary.BinaryContentHandler getBinaryContentHandler(String attribName)
{
return super.getBinaryContentHandler(attribName);
}
public static class CompanyBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<Company>
{
/**
* Get the attribute CompanyName
*/
public String getCompanyName (Company obj, String original)
{
return original;
}
/**
* Change the value set for attribute CompanyName.
* May modify the field beforehand
* Occurs before validation.
*/
public String setCompanyName (Company obj, String newCompanyName) throws FieldException
{
return newCompanyName;
}
/**
* Get the attribute HiringTeamType
*/
public HiringTeamType getHiringTeamType (Company obj, HiringTeamType original)
{
return original;
}
/**
* Change the value set for attribute HiringTeamType.
* May modify the field beforehand
* Occurs before validation.
*/
public HiringTeamType setHiringTeamType (Company obj, HiringTeamType newHiringTeamType) throws FieldException
{
return newHiringTeamType;
}
/**
* Get the attribute Industry
*/
public Industry getIndustry (Company obj, Industry original)
{
return original;
}
/**
* Change the value set for attribute Industry.
* May modify the field beforehand
* Occurs before validation.
*/
public Industry setIndustry (Company obj, Industry newIndustry) throws FieldException
{
return newIndustry;
}
/**
* Get the attribute TimeZone
*/
public TimeZone getTimeZone (Company obj, TimeZone original)
{
return original;
}
/**
* Change the value set for attribute TimeZone.
* May modify the field beforehand
* Occurs before validation.
*/
public TimeZone setTimeZone (Company obj, TimeZone newTimeZone) throws FieldException
{
return newTimeZone;
}
}
public ORMPipeLine pipes()
{
return new CompanyPipeLineFactory<Company, Company> ((Company)this);
}
/**
* Use this instead of pipes() to get rid of type casting.
*/
public CompanyPipeLineFactory<Company, Company> pipelineCompany()
{
return (CompanyPipeLineFactory<Company, Company>) pipes();
}
public static CompanyPipeLineFactory<Company, Company> pipesCompany(Collection<Company> items)
{
return REFERENCE_Company.new CompanyPipeLineFactory<Company, Company> (items);
}
public static CompanyPipeLineFactory<Company, Company> pipesCompany(Company[] _items)
{
return pipesCompany(Arrays.asList (_items));
}
public static CompanyPipeLineFactory<Company, Company> pipesCompany()
{
return pipesCompany((Collection)null);
}
public class CompanyPipeLineFactory<From extends BaseBusinessClass, Me extends Company> extends BaseBusinessClass.ORMPipeLine<From, Me>
{
public <Prev> CompanyPipeLineFactory (PipeLine<From, Prev> pipeLine, Pipe<Prev, Me> nextPipe)
{
super (pipeLine, nextPipe);
}
public CompanyPipeLineFactory (From seed)
{
super(seed);
}
public CompanyPipeLineFactory (Collection<From> seed)
{
super(seed);
}
public PipeLine<From, ? extends Object> to(String name)
{
if (name.equals ("Users"))
{
return toUsers ();
}
if (name.equals ("Clients"))
{
return toClients ();
}
if (name.equals ("CompanyName"))
{
return toCompanyName ();
}
if (name.equals ("HiringTeamType"))
{
return toHiringTeamType ();
}
if (name.equals ("Industry"))
{
return toIndustry ();
}
if (name.equals ("TimeZone"))
{
return toTimeZone ();
}
if (name.equals ("AddedByUser"))
{
return toAddedByUser ();
}
return super.to(name);
}
public PipeLine<From, String> toCompanyName () { return pipe(new ORMAttributePipe<Me, String>(FIELD_CompanyName)); }
public PipeLine<From, HiringTeamType> toHiringTeamType () { return pipe(new ORMAttributePipe<Me, HiringTeamType>(FIELD_HiringTeamType)); }
public PipeLine<From, Industry> toIndustry () { return pipe(new ORMAttributePipe<Me, Industry>(FIELD_Industry)); }
public PipeLine<From, TimeZone> toTimeZone () { return pipe(new ORMAttributePipe<Me, TimeZone>(FIELD_TimeZone)); }
public CompanyUser.CompanyUserPipeLineFactory<From, CompanyUser> toAddedByUser () { return toAddedByUser (Filter.ALL); }
public CompanyUser.CompanyUserPipeLineFactory<From, CompanyUser> toAddedByUser (Filter<CompanyUser> filter)
{
return CompanyUser.REFERENCE_CompanyUser.new CompanyUserPipeLineFactory<From, CompanyUser> (this, new ORMSingleAssocPipe<Me, CompanyUser>(SINGLEREFERENCE_AddedByUser, filter));
}
public CompanyUser.CompanyUserPipeLineFactory<From, CompanyUser> toUsers () { return toUsers(Filter.ALL); }
public CompanyUser.CompanyUserPipeLineFactory<From, CompanyUser> toUsers (Filter<CompanyUser> filter)
{
return CompanyUser.REFERENCE_CompanyUser.new CompanyUserPipeLineFactory<From, CompanyUser> (this, new ORMMultiAssocPipe<Me, CompanyUser>(MULTIPLEREFERENCE_Users, filter));
}
public Client.ClientPipeLineFactory<From, Client> toClients () { return toClients(Filter.ALL); }
public Client.ClientPipeLineFactory<From, Client> toClients (Filter<Client> filter)
{
return Client.REFERENCE_Client.new ClientPipeLineFactory<From, Client> (this, new ORMMultiAssocPipe<Me, Client>(MULTIPLEREFERENCE_Clients, filter));
}
}
public boolean isTransientAttrib(String attribName)
{
return super.isTransientAttrib(attribName);
}
public boolean isTransientSingleReference(String assocName)
{
return super.isTransientSingleReference(assocName);
}
}
class DummyCompany extends Company
{
// Default constructor primarily to support Externalisable
public DummyCompany()
{
super();
}
public void assertValid ()
{
}
public CompanyUser getAddedByUser () throws StorageException
{
return (CompanyUser)(CompanyUser.DUMMY_CompanyUser);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getAddedByUserID ()
{
return CompanyUser.DUMMY_CompanyUser.getObjectID();
}
public int getUsersCount () throws StorageException
{
return 0;
}
public CompanyUser getUsersAt (int index) throws StorageException
{
throw new RuntimeException ("No elements in a dummy object in association Users");
}
public SortedSet getUsersSet () throws StorageException
{
return new TreeSet();
}
public int getClientsCount () throws StorageException
{
return 0;
}
public Client getClientsAt (int index) throws StorageException
{
throw new RuntimeException ("No elements in a dummy object in association Clients");
}
public SortedSet getClientsSet () throws StorageException
{
return new TreeSet();
}
}
......@@ -28,68 +28,84 @@ import oneit.utils.parsers.FieldException;
import oneit.security.*;
import performa.orm.types.*;
public abstract class BaseAdminUser extends SecUserExtension
public abstract class BaseCompanyUser extends SecUserExtension
{
// Reference instance for the object
public static final AdminUser REFERENCE_AdminUser = new AdminUser ();
public static final CompanyUser REFERENCE_CompanyUser = new CompanyUser ();
// Reference instance for the object
public static final AdminUser DUMMY_AdminUser = new DummyAdminUser ();
public static final CompanyUser DUMMY_CompanyUser = new DummyCompanyUser ();
// Static constants corresponding to field names
public static final String FIELD_ForgotPasswordMailSendDate = "ForgotPasswordMailSendDate";
public static final String FIELD_ForgotPasswordKey = "ForgotPasswordKey";
public static final String FIELD_Role = "Role";
public static final String FIELD_Phone = "Phone";
public static final String SINGLEREFERENCE_Company = "Company";
public static final String BACKREF_Company = "";
// Static constants corresponding to searches
public static final String SEARCH_All = "All";
public static final String SEARCH_IdPin = "IdPin";
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper<AdminUser> HELPER_ForgotPasswordMailSendDate = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<AdminUser> HELPER_ForgotPasswordKey = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<CompanyUser> HELPER_ForgotPasswordMailSendDate = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<CompanyUser> HELPER_ForgotPasswordKey = DefaultAttributeHelper.INSTANCE;
private static final EnumeratedAttributeHelper<CompanyUser, RoleType> HELPER_Role = new EnumeratedAttributeHelper<CompanyUser, RoleType> (RoleType.FACTORY_RoleType);
private static final DefaultAttributeHelper<CompanyUser> HELPER_Phone = DefaultAttributeHelper.INSTANCE;
// Private attributes corresponding to business object data
private Date _ForgotPasswordMailSendDate;
private String _ForgotPasswordKey;
private RoleType _Role;
private String _Phone;
// Private attributes corresponding to single references
private SingleAssociation<CompanyUser, Company> _Company;
// Private attributes corresponding to multiple references
// Map of maps of metadata
private static final Map ATTRIBUTES_METADATA_AdminUser = new HashMap ();
private static final Map ATTRIBUTES_METADATA_CompanyUser = new HashMap ();
// Arrays of validators for each attribute
private static final AttributeValidator[] FIELD_ForgotPasswordMailSendDate_Validators;
private static final AttributeValidator[] FIELD_ForgotPasswordKey_Validators;
private static final AttributeValidator[] FIELD_Role_Validators;
private static final AttributeValidator[] FIELD_Phone_Validators;
// Arrays of behaviour decorators
private static final AdminUserBehaviourDecorator[] AdminUser_BehaviourDecorators;
private static final CompanyUserBehaviourDecorator[] CompanyUser_BehaviourDecorators;
static
{
try
{
String tmp_Company = Company.BACKREF_Users;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_Company();
FIELD_ForgotPasswordMailSendDate_Validators = (AttributeValidator[])setupAttribMetaData_ForgotPasswordMailSendDate(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_ForgotPasswordKey_Validators = (AttributeValidator[])setupAttribMetaData_ForgotPasswordKey(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_Role_Validators = (AttributeValidator[])setupAttribMetaData_Role(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_Phone_Validators = (AttributeValidator[])setupAttribMetaData_Phone(validatorMapping).toArray (new AttributeValidator[0]);
REFERENCE_AdminUser.initialiseReference ();
DUMMY_AdminUser.initialiseReference ();
AdminUser_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(AdminUser.class).toArray(new AdminUserBehaviourDecorator[0]);
REFERENCE_CompanyUser.initialiseReference ();
DUMMY_CompanyUser.initialiseReference ();
CompanyUser_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(CompanyUser.class).toArray(new CompanyUserBehaviourDecorator[0]);
}
catch (RuntimeException e)
{
......@@ -100,6 +116,21 @@ public abstract class BaseAdminUser extends SecUserExtension
// Meta Info setup
private static void setupAssocMetaData_Company()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Users");
metaInfo.put ("dbcol", "company_id");
metaInfo.put ("name", "Company");
metaInfo.put ("type", "Company");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CompanyUser.Company:", metaInfo);
ATTRIBUTES_METADATA_CompanyUser.put (SINGLEREFERENCE_Company, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static List setupAttribMetaData_ForgotPasswordMailSendDate(Map validatorMapping)
{
Map metaInfo = new HashMap ();
......@@ -108,11 +139,11 @@ public abstract class BaseAdminUser extends SecUserExtension
metaInfo.put ("name", "ForgotPasswordMailSendDate");
metaInfo.put ("type", "Date");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for AdminUser.ForgotPasswordMailSendDate:", metaInfo);
ATTRIBUTES_METADATA_AdminUser.put (FIELD_ForgotPasswordMailSendDate, Collections.unmodifiableMap (metaInfo));
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CompanyUser.ForgotPasswordMailSendDate:", metaInfo);
ATTRIBUTES_METADATA_CompanyUser.put (FIELD_ForgotPasswordMailSendDate, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(AdminUser.class, "ForgotPasswordMailSendDate", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for AdminUser.ForgotPasswordMailSendDate:", validators);
List validators = BaseBusinessClass.getAttribValidators(CompanyUser.class, "ForgotPasswordMailSendDate", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for CompanyUser.ForgotPasswordMailSendDate:", validators);
return validators;
}
......@@ -127,11 +158,51 @@ public abstract class BaseAdminUser extends SecUserExtension
metaInfo.put ("name", "ForgotPasswordKey");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for AdminUser.ForgotPasswordKey:", metaInfo);
ATTRIBUTES_METADATA_AdminUser.put (FIELD_ForgotPasswordKey, Collections.unmodifiableMap (metaInfo));
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CompanyUser.ForgotPasswordKey:", metaInfo);
ATTRIBUTES_METADATA_CompanyUser.put (FIELD_ForgotPasswordKey, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(AdminUser.class, "ForgotPasswordKey", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for AdminUser.ForgotPasswordKey:", validators);
List validators = BaseBusinessClass.getAttribValidators(CompanyUser.class, "ForgotPasswordKey", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for CompanyUser.ForgotPasswordKey:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_Role(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("attribHelper", "EnumeratedAttributeHelper");
metaInfo.put ("dbcol", "role_type");
metaInfo.put ("mandatory", "false");
metaInfo.put ("name", "Role");
metaInfo.put ("type", "RoleType");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CompanyUser.Role:", metaInfo);
ATTRIBUTES_METADATA_CompanyUser.put (FIELD_Role, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(CompanyUser.class, "Role", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for CompanyUser.Role:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_Phone(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "phone");
metaInfo.put ("length", "30");
metaInfo.put ("mandatory", "false");
metaInfo.put ("name", "Phone");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CompanyUser.Phone:", metaInfo);
ATTRIBUTES_METADATA_CompanyUser.put (FIELD_Phone, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(CompanyUser.class, "Phone", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for CompanyUser.Phone:", validators);
return validators;
}
......@@ -141,14 +212,14 @@ public abstract class BaseAdminUser extends SecUserExtension
// This constructor should not be called
protected BaseAdminUser ()
protected BaseCompanyUser ()
{
}
protected BBCBehaviourDecorator[] getBehaviours()
{
return AdminUser_BehaviourDecorators;
return CompanyUser_BehaviourDecorators;
}
......@@ -165,6 +236,8 @@ public abstract class BaseAdminUser extends SecUserExtension
_ForgotPasswordMailSendDate = (Date)(HELPER_ForgotPasswordMailSendDate.initialise (_ForgotPasswordMailSendDate));
_ForgotPasswordKey = (String)(HELPER_ForgotPasswordKey.initialise (_ForgotPasswordKey));
_Role = (RoleType)(HELPER_Role.initialise (_Role));
_Phone = (String)(HELPER_Phone.initialise (_Phone));
}
......@@ -173,6 +246,7 @@ public abstract class BaseAdminUser extends SecUserExtension
{
super._initialiseAssociations ();
_Company = new SingleAssociation<CompanyUser, Company> (this, SINGLEREFERENCE_Company, Company.MULTIPLEREFERENCE_Users, Company.REFERENCE_Company, "oneit_sec_user_extension");
}
......@@ -182,6 +256,7 @@ public abstract class BaseAdminUser extends SecUserExtension
{
super.initialiseReference ();
_Company = new SingleAssociation<CompanyUser, Company> (this, SINGLEREFERENCE_Company, Company.MULTIPLEREFERENCE_Users, Company.REFERENCE_Company, "oneit_sec_user_extension");
return this;
......@@ -197,9 +272,9 @@ public abstract class BaseAdminUser extends SecUserExtension
assertValid();
Date valToReturn = _ForgotPasswordMailSendDate;
for (AdminUserBehaviourDecorator bhd : AdminUser_BehaviourDecorators)
for (CompanyUserBehaviourDecorator bhd : CompanyUser_BehaviourDecorators)
{
valToReturn = bhd.getForgotPasswordMailSendDate ((AdminUser)this, valToReturn);
valToReturn = bhd.getForgotPasswordMailSendDate ((CompanyUser)this, valToReturn);
}
return valToReturn;
......@@ -241,9 +316,9 @@ public abstract class BaseAdminUser extends SecUserExtension
try
{
for (AdminUserBehaviourDecorator bhd : AdminUser_BehaviourDecorators)
for (CompanyUserBehaviourDecorator bhd : CompanyUser_BehaviourDecorators)
{
newForgotPasswordMailSendDate = bhd.setForgotPasswordMailSendDate ((AdminUser)this, newForgotPasswordMailSendDate);
newForgotPasswordMailSendDate = bhd.setForgotPasswordMailSendDate ((CompanyUser)this, newForgotPasswordMailSendDate);
oldAndNewIdentical = HELPER_ForgotPasswordMailSendDate.compare (_ForgotPasswordMailSendDate, newForgotPasswordMailSendDate);
}
......@@ -256,7 +331,7 @@ public abstract class BaseAdminUser extends SecUserExtension
if (newForgotPasswordMailSendDateObj != null)
{
int loopMax = FIELD_ForgotPasswordMailSendDate_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_AdminUser.get (FIELD_ForgotPasswordMailSendDate);
Map metadata = (Map)ATTRIBUTES_METADATA_CompanyUser.get (FIELD_ForgotPasswordMailSendDate);
for (int v = 0 ; v < loopMax ; ++v)
{
......@@ -295,9 +370,9 @@ public abstract class BaseAdminUser extends SecUserExtension
assertValid();
String valToReturn = _ForgotPasswordKey;
for (AdminUserBehaviourDecorator bhd : AdminUser_BehaviourDecorators)
for (CompanyUserBehaviourDecorator bhd : CompanyUser_BehaviourDecorators)
{
valToReturn = bhd.getForgotPasswordKey ((AdminUser)this, valToReturn);
valToReturn = bhd.getForgotPasswordKey ((CompanyUser)this, valToReturn);
}
return valToReturn;
......@@ -339,9 +414,9 @@ public abstract class BaseAdminUser extends SecUserExtension
try
{
for (AdminUserBehaviourDecorator bhd : AdminUser_BehaviourDecorators)
for (CompanyUserBehaviourDecorator bhd : CompanyUser_BehaviourDecorators)
{
newForgotPasswordKey = bhd.setForgotPasswordKey ((AdminUser)this, newForgotPasswordKey);
newForgotPasswordKey = bhd.setForgotPasswordKey ((CompanyUser)this, newForgotPasswordKey);
oldAndNewIdentical = HELPER_ForgotPasswordKey.compare (_ForgotPasswordKey, newForgotPasswordKey);
}
......@@ -354,7 +429,7 @@ public abstract class BaseAdminUser extends SecUserExtension
if (newForgotPasswordKeyObj != null)
{
int loopMax = FIELD_ForgotPasswordKey_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_AdminUser.get (FIELD_ForgotPasswordKey);
Map metadata = (Map)ATTRIBUTES_METADATA_CompanyUser.get (FIELD_ForgotPasswordKey);
for (int v = 0 ; v < loopMax ; ++v)
{
......@@ -385,6 +460,202 @@ public abstract class BaseAdminUser extends SecUserExtension
}
}
/**
* Get the attribute Role
*/
public RoleType getRole ()
{
assertValid();
RoleType valToReturn = _Role;
for (CompanyUserBehaviourDecorator bhd : CompanyUser_BehaviourDecorators)
{
valToReturn = bhd.getRole ((CompanyUser)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preRoleChange (RoleType newRole) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postRoleChange () throws FieldException
{
}
public FieldWriteability getWriteability_Role ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute Role. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setRole (RoleType newRole) throws FieldException
{
boolean oldAndNewIdentical = HELPER_Role.compare (_Role, newRole);
try
{
for (CompanyUserBehaviourDecorator bhd : CompanyUser_BehaviourDecorators)
{
newRole = bhd.setRole ((CompanyUser)this, newRole);
oldAndNewIdentical = HELPER_Role.compare (_Role, newRole);
}
if (FIELD_Role_Validators.length > 0)
{
Object newRoleObj = HELPER_Role.toObject (newRole);
if (newRoleObj != null)
{
int loopMax = FIELD_Role_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_CompanyUser.get (FIELD_Role);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_Role_Validators[v].checkAttribute (this, FIELD_Role, metadata, newRoleObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_Role () != FieldWriteability.FALSE, "Field Role is not writeable");
preRoleChange (newRole);
markFieldChange (FIELD_Role);
_Role = newRole;
postFieldChange (FIELD_Role);
postRoleChange ();
}
}
/**
* Get the attribute Phone
*/
public String getPhone ()
{
assertValid();
String valToReturn = _Phone;
for (CompanyUserBehaviourDecorator bhd : CompanyUser_BehaviourDecorators)
{
valToReturn = bhd.getPhone ((CompanyUser)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void prePhoneChange (String newPhone) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postPhoneChange () throws FieldException
{
}
public FieldWriteability getWriteability_Phone ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute Phone. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setPhone (String newPhone) throws FieldException
{
boolean oldAndNewIdentical = HELPER_Phone.compare (_Phone, newPhone);
try
{
for (CompanyUserBehaviourDecorator bhd : CompanyUser_BehaviourDecorators)
{
newPhone = bhd.setPhone ((CompanyUser)this, newPhone);
oldAndNewIdentical = HELPER_Phone.compare (_Phone, newPhone);
}
if (FIELD_Phone_Validators.length > 0)
{
Object newPhoneObj = HELPER_Phone.toObject (newPhone);
if (newPhoneObj != null)
{
int loopMax = FIELD_Phone_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_CompanyUser.get (FIELD_Phone);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_Phone_Validators[v].checkAttribute (this, FIELD_Phone, metadata, newPhoneObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_Phone () != FieldWriteability.FALSE, "Field Phone is not writeable");
prePhoneChange (newPhone);
markFieldChange (FIELD_Phone);
_Phone = newPhone;
postFieldChange (FIELD_Phone);
postPhoneChange ();
}
}
/**
......@@ -395,6 +666,8 @@ public abstract class BaseAdminUser extends SecUserExtension
List result = super.getSingleAssocs ();
result.add("Company");
return result;
}
......@@ -406,7 +679,10 @@ public abstract class BaseAdminUser extends SecUserExtension
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Company))
{
return _Company.getReferencedType ();
}
else
{
return super.getSingleAssocReferenceInstance (assocName);
......@@ -420,7 +696,10 @@ public abstract class BaseAdminUser extends SecUserExtension
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Company))
{
return Company.MULTIPLEREFERENCE_Users ;
}
else
{
return super.getSingleAssocBackReference (assocName);
......@@ -434,7 +713,10 @@ public abstract class BaseAdminUser extends SecUserExtension
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Company))
{
return getCompany ();
}
else
{
return super.getSingleAssoc (assocName);
......@@ -448,7 +730,10 @@ public abstract class BaseAdminUser extends SecUserExtension
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Company))
{
return getCompany (getType);
}
else
{
return super.getSingleAssoc (assocName, getType);
......@@ -462,7 +747,10 @@ public abstract class BaseAdminUser extends SecUserExtension
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Company))
{
return getCompanyID ();
}
else
{
return super.getSingleAssocID (assocName);
......@@ -476,7 +764,10 @@ public abstract class BaseAdminUser extends SecUserExtension
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Company))
{
setCompany ((Company)(newValue));
}
else
{
super.setSingleAssoc (assocName, newValue);
......@@ -486,6 +777,113 @@ public abstract class BaseAdminUser extends SecUserExtension
/**
* Get the reference Company
*/
public Company getCompany () throws StorageException
{
assertValid();
try
{
return (Company)(_Company.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in CompanyUser:", this.getObjectID (), ", was trying to get Company:", getCompanyID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _Company.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Company getCompany (Get getType) throws StorageException
{
assertValid();
return _Company.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getCompanyID ()
{
assertValid();
if (_Company == null)
{
return null;
}
else
{
return _Company.getID ();
}
}
/**
* Called prior to the assoc changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preCompanyChange (Company newCompany) throws FieldException
{
}
/**
* Called after the assoc changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postCompanyChange () throws FieldException
{
}
public FieldWriteability getWriteability_Company ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference Company. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setCompany (Company newCompany) throws StorageException, FieldException
{
if (_Company.wouldReferencedChange (newCompany))
{
assertValid();
Debug.assertion (getWriteability_Company () != FieldWriteability.FALSE, "Assoc Company is not writeable");
preCompanyChange (newCompany);
Company oldCompany = getCompany ();
if (oldCompany != null)
{
// This is to stop validation from triggering when we are removed
_Company.set (null);
oldCompany.removeFromUsers ((CompanyUser)(this));
}
_Company.set (newCompany);
if (newCompany != null)
{
newCompany.addToUsers ((CompanyUser)(this));
}
postCompanyChange ();
}
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getMultiAssocs()
......@@ -583,6 +981,20 @@ public abstract class BaseAdminUser extends SecUserExtension
{
try
{
// Ensure we are removed from any loaded multi-associations that aren't mandatory
if (_Company.isLoaded () || getTransaction ().isObjectLoaded (_Company.getReferencedType (), getCompanyID ()))
{
Company referenced = getCompany ();
if (referenced != null)
{
// Stop the callback
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Users from ", getObjectID (), " to ", referenced.getObjectID ());
_Company.set (null);
referenced.removeFromUsers ((CompanyUser)this);
}
}
}
catch (Exception e)
{
......@@ -593,27 +1005,27 @@ public abstract class BaseAdminUser extends SecUserExtension
}
public AdminUser newInstance ()
public CompanyUser newInstance ()
{
return new AdminUser ();
return new CompanyUser ();
}
public AdminUser referenceInstance ()
public CompanyUser referenceInstance ()
{
return REFERENCE_AdminUser;
return REFERENCE_CompanyUser;
}
public AdminUser getInTransaction (ObjectTransaction t) throws StorageException
public CompanyUser getInTransaction (ObjectTransaction t) throws StorageException
{
return getAdminUserByID (t, getObjectID());
return getCompanyUserByID (t, getObjectID());
}
public BaseBusinessClass dummyInstance ()
{
return DUMMY_AdminUser;
return DUMMY_CompanyUser;
}
......@@ -645,6 +1057,9 @@ public abstract class BaseAdminUser extends SecUserExtension
oneit_sec_user_extensionPSet.setAttrib (FIELD_ObjectID, myID);
oneit_sec_user_extensionPSet.setAttrib (FIELD_ForgotPasswordMailSendDate, HELPER_ForgotPasswordMailSendDate.toObject (_ForgotPasswordMailSendDate)); //
oneit_sec_user_extensionPSet.setAttrib (FIELD_ForgotPasswordKey, HELPER_ForgotPasswordKey.toObject (_ForgotPasswordKey)); //
oneit_sec_user_extensionPSet.setAttrib (FIELD_Role, HELPER_Role.toObject (_Role)); //
oneit_sec_user_extensionPSet.setAttrib (FIELD_Phone, HELPER_Phone.toObject (_Phone)); //
_Company.getPersistentSets (allSets);
}
......@@ -661,6 +1076,9 @@ public abstract class BaseAdminUser extends SecUserExtension
_ForgotPasswordMailSendDate = (Date)(HELPER_ForgotPasswordMailSendDate.fromObject (_ForgotPasswordMailSendDate, oneit_sec_user_extensionPSet.getAttrib (FIELD_ForgotPasswordMailSendDate))); //
_ForgotPasswordKey = (String)(HELPER_ForgotPasswordKey.fromObject (_ForgotPasswordKey, oneit_sec_user_extensionPSet.getAttrib (FIELD_ForgotPasswordKey))); //
_Role = (RoleType)(HELPER_Role.fromObject (_Role, oneit_sec_user_extensionPSet.getAttrib (FIELD_Role))); //
_Phone = (String)(HELPER_Phone.fromObject (_Phone, oneit_sec_user_extensionPSet.getAttrib (FIELD_Phone))); //
_Company.setFromPersistentSets (objectID, allSets);
}
......@@ -672,13 +1090,22 @@ public abstract class BaseAdminUser extends SecUserExtension
{
super.setAttributesFrom (other, e);
if (other instanceof AdminUser)
if (other instanceof CompanyUser)
{
AdminUser otherAdminUser = (AdminUser)other;
CompanyUser otherCompanyUser = (CompanyUser)other;
try
{
setForgotPasswordMailSendDate (otherCompanyUser.getForgotPasswordMailSendDate ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setForgotPasswordMailSendDate (otherAdminUser.getForgotPasswordMailSendDate ());
setForgotPasswordKey (otherCompanyUser.getForgotPasswordKey ());
}
catch (FieldException ex)
{
......@@ -687,7 +1114,16 @@ public abstract class BaseAdminUser extends SecUserExtension
try
{
setForgotPasswordKey (otherAdminUser.getForgotPasswordKey ());
setRole (otherCompanyUser.getRole ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setPhone (otherCompanyUser.getPhone ());
}
catch (FieldException ex)
{
......@@ -705,12 +1141,14 @@ public abstract class BaseAdminUser extends SecUserExtension
{
super.copyAttributesFrom (source);
if (source instanceof BaseAdminUser)
if (source instanceof BaseCompanyUser)
{
BaseAdminUser sourceAdminUser = (BaseAdminUser)(source);
BaseCompanyUser sourceCompanyUser = (BaseCompanyUser)(source);
_ForgotPasswordMailSendDate = sourceAdminUser._ForgotPasswordMailSendDate;
_ForgotPasswordKey = sourceAdminUser._ForgotPasswordKey;
_ForgotPasswordMailSendDate = sourceCompanyUser._ForgotPasswordMailSendDate;
_ForgotPasswordKey = sourceCompanyUser._ForgotPasswordKey;
_Role = sourceCompanyUser._Role;
_Phone = sourceCompanyUser._Phone;
}
}
......@@ -723,10 +1161,11 @@ public abstract class BaseAdminUser extends SecUserExtension
{
super.copySingleAssociationsFrom (source, linkToGhosts);
if (source instanceof BaseAdminUser)
if (source instanceof BaseCompanyUser)
{
BaseAdminUser sourceAdminUser = (BaseAdminUser)(source);
BaseCompanyUser sourceCompanyUser = (BaseCompanyUser)(source);
_Company.copyFrom (sourceCompanyUser._Company, linkToGhosts);
}
}
......@@ -739,9 +1178,9 @@ public abstract class BaseAdminUser extends SecUserExtension
{
super.copyAssociationsFrom (source, linkToGhosts);
if (source instanceof BaseAdminUser)
if (source instanceof BaseCompanyUser)
{
BaseAdminUser sourceAdminUser = (BaseAdminUser)(source);
BaseCompanyUser sourceCompanyUser = (BaseCompanyUser)(source);
}
......@@ -765,6 +1204,9 @@ public abstract class BaseAdminUser extends SecUserExtension
_ForgotPasswordMailSendDate = (Date)(HELPER_ForgotPasswordMailSendDate.readExternal (_ForgotPasswordMailSendDate, vals.get(FIELD_ForgotPasswordMailSendDate))); //
_ForgotPasswordKey = (String)(HELPER_ForgotPasswordKey.readExternal (_ForgotPasswordKey, vals.get(FIELD_ForgotPasswordKey))); //
_Role = (RoleType)(HELPER_Role.readExternal (_Role, vals.get(FIELD_Role))); //
_Phone = (String)(HELPER_Phone.readExternal (_Phone, vals.get(FIELD_Phone))); //
_Company.readExternalData(vals.get(SINGLEREFERENCE_Company));
}
......@@ -778,6 +1220,9 @@ public abstract class BaseAdminUser extends SecUserExtension
vals.put (FIELD_ForgotPasswordMailSendDate, HELPER_ForgotPasswordMailSendDate.writeExternal (_ForgotPasswordMailSendDate));
vals.put (FIELD_ForgotPasswordKey, HELPER_ForgotPasswordKey.writeExternal (_ForgotPasswordKey));
vals.put (FIELD_Role, HELPER_Role.writeExternal (_Role));
vals.put (FIELD_Phone, HELPER_Phone.writeExternal (_Phone));
vals.put (SINGLEREFERENCE_Company, _Company.writeExternalData());
}
......@@ -786,21 +1231,30 @@ public abstract class BaseAdminUser extends SecUserExtension
{
super.compare (other, listener);
if (other instanceof BaseAdminUser)
if (other instanceof BaseCompanyUser)
{
BaseAdminUser otherAdminUser = (BaseAdminUser)(other);
BaseCompanyUser otherCompanyUser = (BaseCompanyUser)(other);
if (!HELPER_ForgotPasswordMailSendDate.compare(this._ForgotPasswordMailSendDate, otherAdminUser._ForgotPasswordMailSendDate))
if (!HELPER_ForgotPasswordMailSendDate.compare(this._ForgotPasswordMailSendDate, otherCompanyUser._ForgotPasswordMailSendDate))
{
listener.notifyFieldChange(this, other, FIELD_ForgotPasswordMailSendDate, HELPER_ForgotPasswordMailSendDate.toObject(this._ForgotPasswordMailSendDate), HELPER_ForgotPasswordMailSendDate.toObject(otherCompanyUser._ForgotPasswordMailSendDate));
}
if (!HELPER_ForgotPasswordKey.compare(this._ForgotPasswordKey, otherCompanyUser._ForgotPasswordKey))
{
listener.notifyFieldChange(this, other, FIELD_ForgotPasswordMailSendDate, HELPER_ForgotPasswordMailSendDate.toObject(this._ForgotPasswordMailSendDate), HELPER_ForgotPasswordMailSendDate.toObject(otherAdminUser._ForgotPasswordMailSendDate));
listener.notifyFieldChange(this, other, FIELD_ForgotPasswordKey, HELPER_ForgotPasswordKey.toObject(this._ForgotPasswordKey), HELPER_ForgotPasswordKey.toObject(otherCompanyUser._ForgotPasswordKey));
}
if (!HELPER_ForgotPasswordKey.compare(this._ForgotPasswordKey, otherAdminUser._ForgotPasswordKey))
if (!HELPER_Role.compare(this._Role, otherCompanyUser._Role))
{
listener.notifyFieldChange(this, other, FIELD_ForgotPasswordKey, HELPER_ForgotPasswordKey.toObject(this._ForgotPasswordKey), HELPER_ForgotPasswordKey.toObject(otherAdminUser._ForgotPasswordKey));
listener.notifyFieldChange(this, other, FIELD_Role, HELPER_Role.toObject(this._Role), HELPER_Role.toObject(otherCompanyUser._Role));
}
if (!HELPER_Phone.compare(this._Phone, otherCompanyUser._Phone))
{
listener.notifyFieldChange(this, other, FIELD_Phone, HELPER_Phone.toObject(this._Phone), HELPER_Phone.toObject(otherCompanyUser._Phone));
}
// Compare single assocs
_Company.compare (otherCompanyUser._Company, listener);
// Compare multiple assocs
......@@ -823,6 +1277,9 @@ public abstract class BaseAdminUser extends SecUserExtension
visitor.visitField(this, FIELD_ForgotPasswordMailSendDate, HELPER_ForgotPasswordMailSendDate.toObject(getForgotPasswordMailSendDate()));
visitor.visitField(this, FIELD_ForgotPasswordKey, HELPER_ForgotPasswordKey.toObject(getForgotPasswordKey()));
visitor.visitField(this, FIELD_Role, HELPER_Role.toObject(getRole()));
visitor.visitField(this, FIELD_Phone, HELPER_Phone.toObject(getPhone()));
visitor.visitAssociation (_Company);
}
......@@ -831,13 +1288,17 @@ public abstract class BaseAdminUser extends SecUserExtension
{
super.visitAssociations (visitor, scope);
if (scope.includes (_Company))
{
visitor.visit (_Company);
}
}
public static AdminUser createAdminUser (ObjectTransaction transaction) throws StorageException
public static CompanyUser createCompanyUser (ObjectTransaction transaction) throws StorageException
{
AdminUser result = new AdminUser ();
CompanyUser result = new CompanyUser ();
result.initialiseNewObject (transaction);
......@@ -845,9 +1306,9 @@ public abstract class BaseAdminUser extends SecUserExtension
}
public static AdminUser getAdminUserByID (ObjectTransaction transaction, Long objectID) throws StorageException
public static CompanyUser getCompanyUserByID (ObjectTransaction transaction, Long objectID) throws StorageException
{
return (AdminUser)(transaction.getObjectByID (REFERENCE_AdminUser, objectID));
return (CompanyUser)(transaction.getObjectByID (REFERENCE_CompanyUser, objectID));
}
public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
......@@ -864,6 +1325,18 @@ public abstract class BaseAdminUser extends SecUserExtension
{
return filter.matches (getForgotPasswordKey ());
}
else if (attribName.equals (FIELD_Role))
{
return filter.matches (getRole ());
}
else if (attribName.equals (FIELD_Phone))
{
return filter.matches (getPhone ());
}
else if (attribName.equals (SINGLEREFERENCE_Company))
{
return filter.matches (getCompany ());
}
else
{
return super.testFilter (attribName, filter);
......@@ -873,7 +1346,7 @@ public abstract class BaseAdminUser extends SecUserExtension
public static SearchAll SearchByAll () { return new SearchAll (); }
public static class SearchAll extends SearchObject<AdminUser>
public static class SearchAll extends SearchObject<CompanyUser>
{
public SearchAll andObjectID (QueryFilter<Long> filter)
......@@ -907,117 +1380,54 @@ public abstract class BaseAdminUser extends SecUserExtension
return this;
}
public SearchAll andUser (QueryFilter<SecUser> filter)
{
filter.addFilter (context, "oneit_sec_user_extension.user_id", "User");
return this;
}
public AdminUser[]
search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_AdminUser, SEARCH_All, criteria);
Set<AdminUser> typedResults = new LinkedHashSet <AdminUser> ();
for (BaseBusinessClass bbcResult : results)
{
AdminUser aResult = (AdminUser)bbcResult;
typedResults.add (aResult);
}
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new AdminUser[0]);
}
}
public static AdminUser[]
searchAll (ObjectTransaction transaction) throws StorageException
{
return SearchByAll ()
.search (transaction);
}
public static SearchIdPin SearchByIdPin () { return new SearchIdPin (); }
public static class SearchIdPin extends SearchObject<AdminUser>
{
public SearchIdPin byID (Long ID)
{
by ("ID", ID);
return this;
}
public SearchIdPin byPin (String Pin)
{
by ("Pin", Pin);
return this;
}
public SearchIdPin andObjectID (QueryFilter<Long> filter)
public SearchAll andRole (QueryFilter<RoleType> filter)
{
filter.addFilter (context, "oneit_sec_user_extension.object_id", FIELD_ObjectID);
filter.addFilter (context, "oneit_sec_user_extension.role_type", "Role");
return this;
}
public SearchIdPin andObjectCreated (QueryFilter<Date> filter)
{
filter.addFilter (context, "oneit_sec_user_extension.object_created_date", FIELD_ObjectCreated);
return this;
}
public SearchIdPin andObjectLastModified (QueryFilter<Date> filter)
{
filter.addFilter (context, "oneit_sec_user_extension.object_last_updated_date", FIELD_ObjectLastModified);
return this;
}
public SearchIdPin andForgotPasswordMailSendDate (QueryFilter<Date> filter)
public SearchAll andPhone (QueryFilter<String> filter)
{
filter.addFilter (context, "oneit_sec_user_extension.forgot_password_mail_send_date", "ForgotPasswordMailSendDate");
filter.addFilter (context, "oneit_sec_user_extension.phone", "Phone");
return this;
}
public SearchIdPin andForgotPasswordKey (QueryFilter<String> filter)
public SearchAll andUser (QueryFilter<SecUser> filter)
{
filter.addFilter (context, "oneit_sec_user_extension.forgot_password_key", "ForgotPasswordKey");
filter.addFilter (context, "oneit_sec_user_extension.user_id", "User");
return this;
}
public SearchIdPin andUser (QueryFilter<SecUser> filter)
public SearchAll andCompany (QueryFilter<Company> filter)
{
filter.addFilter (context, "oneit_sec_user_extension.user_id", "User");
filter.addFilter (context, "oneit_sec_user_extension.company_id", "Company");
return this;
}
public AdminUser search (ObjectTransaction transaction) throws StorageException
public CompanyUser[]
search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_AdminUser, SEARCH_IdPin, criteria);
Set<AdminUser> typedResults = new LinkedHashSet <AdminUser> ();
BaseBusinessClass[] results = super.search (transaction, REFERENCE_CompanyUser, SEARCH_All, criteria);
Set<CompanyUser> typedResults = new LinkedHashSet <CompanyUser> ();
for (BaseBusinessClass bbcResult : results)
{
AdminUser aResult = (AdminUser)bbcResult;
CompanyUser aResult = (CompanyUser)bbcResult;
typedResults.add (aResult);
}
return (AdminUser)singletonResult(ObjstoreUtils.removeDeleted(transaction, typedResults).toArray(new BaseBusinessClass[0]), "AdminUser", "");
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new CompanyUser[0]);
}
}
public static AdminUser searchIdPin (ObjectTransaction transaction, Long ID, String Pin) throws StorageException
public static CompanyUser[]
searchAll (ObjectTransaction transaction) throws StorageException
{
return SearchByIdPin ()
.byID (ID)
.byPin (Pin)
return SearchByAll ()
.search (transaction);
}
......@@ -1037,6 +1447,14 @@ public abstract class BaseAdminUser extends SecUserExtension
{
return HELPER_ForgotPasswordKey.toObject (getForgotPasswordKey ());
}
else if (attribName.equals (FIELD_Role))
{
return HELPER_Role.toObject (getRole ());
}
else if (attribName.equals (FIELD_Phone))
{
return HELPER_Phone.toObject (getPhone ());
}
else
{
return super.getAttribute (attribName);
......@@ -1058,6 +1476,14 @@ public abstract class BaseAdminUser extends SecUserExtension
{
return HELPER_ForgotPasswordKey;
}
else if (attribName.equals (FIELD_Role))
{
return HELPER_Role;
}
else if (attribName.equals (FIELD_Phone))
{
return HELPER_Phone;
}
else
{
return super.getAttributeHelper (attribName);
......@@ -1079,6 +1505,14 @@ public abstract class BaseAdminUser extends SecUserExtension
{
setForgotPasswordKey ((String)(HELPER_ForgotPasswordKey.fromObject (_ForgotPasswordKey, attribValue)));
}
else if (attribName.equals (FIELD_Role))
{
setRole ((RoleType)(HELPER_Role.fromObject (_Role, attribValue)));
}
else if (attribName.equals (FIELD_Phone))
{
setPhone ((String)(HELPER_Phone.fromObject (_Phone, attribValue)));
}
else
{
super.setAttribute (attribName, attribValue);
......@@ -1107,6 +1541,18 @@ public abstract class BaseAdminUser extends SecUserExtension
{
return getWriteability_ForgotPasswordKey ();
}
else if (fieldName.equals (FIELD_Role))
{
return getWriteability_Role ();
}
else if (fieldName.equals (FIELD_Phone))
{
return getWriteability_Phone ();
}
else if (fieldName.equals (SINGLEREFERENCE_Company))
{
return getWriteability_Company ();
}
else
{
return super.getWriteable (fieldName);
......@@ -1127,6 +1573,16 @@ public abstract class BaseAdminUser extends SecUserExtension
fields.add (FIELD_ForgotPasswordKey);
}
if (getWriteability_Role () != FieldWriteability.TRUE)
{
fields.add (FIELD_Role);
}
if (getWriteability_Phone () != FieldWriteability.TRUE)
{
fields.add (FIELD_Phone);
}
super.putUnwriteable (fields);
}
......@@ -1138,6 +1594,8 @@ public abstract class BaseAdminUser extends SecUserExtension
result.add(HELPER_ForgotPasswordMailSendDate.getAttribObject (getClass (), _ForgotPasswordMailSendDate, false, FIELD_ForgotPasswordMailSendDate));
result.add(HELPER_ForgotPasswordKey.getAttribObject (getClass (), _ForgotPasswordKey, false, FIELD_ForgotPasswordKey));
result.add(HELPER_Role.getAttribObject (getClass (), _Role, false, FIELD_Role));
result.add(HELPER_Phone.getAttribObject (getClass (), _Phone, false, FIELD_Phone));
return result;
}
......@@ -1145,9 +1603,9 @@ public abstract class BaseAdminUser extends SecUserExtension
public Map getAttributeMetadata (String attribute)
{
if (ATTRIBUTES_METADATA_AdminUser.containsKey (attribute))
if (ATTRIBUTES_METADATA_CompanyUser.containsKey (attribute))
{
return (Map)ATTRIBUTES_METADATA_AdminUser.get (attribute);
return (Map)ATTRIBUTES_METADATA_CompanyUser.get (attribute);
}
else
{
......@@ -1158,9 +1616,9 @@ public abstract class BaseAdminUser extends SecUserExtension
public Object getAttributeMetadata (String attribute, String metadata)
{
if (ATTRIBUTES_METADATA_AdminUser.containsKey (attribute))
if (ATTRIBUTES_METADATA_CompanyUser.containsKey (attribute))
{
return ((Map)ATTRIBUTES_METADATA_AdminUser.get (attribute)).get(metadata);
return ((Map)ATTRIBUTES_METADATA_CompanyUser.get (attribute)).get(metadata);
}
else
{
......@@ -1185,13 +1643,13 @@ public abstract class BaseAdminUser extends SecUserExtension
return super.getBinaryContentHandler(attribName);
}
public static class AdminUserBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<AdminUser>
public static class CompanyUserBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<CompanyUser>
{
/**
* Get the attribute ForgotPasswordMailSendDate
*/
public Date getForgotPasswordMailSendDate (AdminUser obj, Date original)
public Date getForgotPasswordMailSendDate (CompanyUser obj, Date original)
{
return original;
}
......@@ -1201,7 +1659,7 @@ public abstract class BaseAdminUser extends SecUserExtension
* May modify the field beforehand
* Occurs before validation.
*/
public Date setForgotPasswordMailSendDate (AdminUser obj, Date newForgotPasswordMailSendDate) throws FieldException
public Date setForgotPasswordMailSendDate (CompanyUser obj, Date newForgotPasswordMailSendDate) throws FieldException
{
return newForgotPasswordMailSendDate;
}
......@@ -1209,7 +1667,7 @@ public abstract class BaseAdminUser extends SecUserExtension
/**
* Get the attribute ForgotPasswordKey
*/
public String getForgotPasswordKey (AdminUser obj, String original)
public String getForgotPasswordKey (CompanyUser obj, String original)
{
return original;
}
......@@ -1219,56 +1677,92 @@ public abstract class BaseAdminUser extends SecUserExtension
* May modify the field beforehand
* Occurs before validation.
*/
public String setForgotPasswordKey (AdminUser obj, String newForgotPasswordKey) throws FieldException
public String setForgotPasswordKey (CompanyUser obj, String newForgotPasswordKey) throws FieldException
{
return newForgotPasswordKey;
}
/**
* Get the attribute Role
*/
public RoleType getRole (CompanyUser obj, RoleType original)
{
return original;
}
/**
* Change the value set for attribute Role.
* May modify the field beforehand
* Occurs before validation.
*/
public RoleType setRole (CompanyUser obj, RoleType newRole) throws FieldException
{
return newRole;
}
/**
* Get the attribute Phone
*/
public String getPhone (CompanyUser obj, String original)
{
return original;
}
/**
* Change the value set for attribute Phone.
* May modify the field beforehand
* Occurs before validation.
*/
public String setPhone (CompanyUser obj, String newPhone) throws FieldException
{
return newPhone;
}
}
public ORMPipeLine pipes()
{
return new AdminUserPipeLineFactory<AdminUser, AdminUser> ((AdminUser)this);
return new CompanyUserPipeLineFactory<CompanyUser, CompanyUser> ((CompanyUser)this);
}
/**
* Use this instead of pipes() to get rid of type casting.
*/
public AdminUserPipeLineFactory<AdminUser, AdminUser> pipelineAdminUser()
public CompanyUserPipeLineFactory<CompanyUser, CompanyUser> pipelineCompanyUser()
{
return (AdminUserPipeLineFactory<AdminUser, AdminUser>) pipes();
return (CompanyUserPipeLineFactory<CompanyUser, CompanyUser>) pipes();
}
public static AdminUserPipeLineFactory<AdminUser, AdminUser> pipesAdminUser(Collection<AdminUser> items)
public static CompanyUserPipeLineFactory<CompanyUser, CompanyUser> pipesCompanyUser(Collection<CompanyUser> items)
{
return REFERENCE_AdminUser.new AdminUserPipeLineFactory<AdminUser, AdminUser> (items);
return REFERENCE_CompanyUser.new CompanyUserPipeLineFactory<CompanyUser, CompanyUser> (items);
}
public static AdminUserPipeLineFactory<AdminUser, AdminUser> pipesAdminUser(AdminUser[] _items)
public static CompanyUserPipeLineFactory<CompanyUser, CompanyUser> pipesCompanyUser(CompanyUser[] _items)
{
return pipesAdminUser(Arrays.asList (_items));
return pipesCompanyUser(Arrays.asList (_items));
}
public static AdminUserPipeLineFactory<AdminUser, AdminUser> pipesAdminUser()
public static CompanyUserPipeLineFactory<CompanyUser, CompanyUser> pipesCompanyUser()
{
return pipesAdminUser((Collection)null);
return pipesCompanyUser((Collection)null);
}
public class AdminUserPipeLineFactory<From extends BaseBusinessClass, Me extends AdminUser> extends SecUserExtensionPipeLineFactory<From, Me>
public class CompanyUserPipeLineFactory<From extends BaseBusinessClass, Me extends CompanyUser> extends SecUserExtensionPipeLineFactory<From, Me>
{
public <Prev> AdminUserPipeLineFactory (PipeLine<From, Prev> pipeLine, Pipe<Prev, Me> nextPipe)
public <Prev> CompanyUserPipeLineFactory (PipeLine<From, Prev> pipeLine, Pipe<Prev, Me> nextPipe)
{
super (pipeLine, nextPipe);
}
public AdminUserPipeLineFactory (From seed)
public CompanyUserPipeLineFactory (From seed)
{
super(seed);
}
public AdminUserPipeLineFactory (Collection<From> seed)
public CompanyUserPipeLineFactory (Collection<From> seed)
{
super(seed);
}
......@@ -1284,6 +1778,18 @@ public abstract class BaseAdminUser extends SecUserExtension
{
return toForgotPasswordKey ();
}
if (name.equals ("Role"))
{
return toRole ();
}
if (name.equals ("Phone"))
{
return toPhone ();
}
if (name.equals ("Company"))
{
return toCompany ();
}
return super.to(name);
......@@ -1294,6 +1800,16 @@ public abstract class BaseAdminUser extends SecUserExtension
public PipeLine<From, String> toForgotPasswordKey () { return pipe(new ORMAttributePipe<Me, String>(FIELD_ForgotPasswordKey)); }
public PipeLine<From, RoleType> toRole () { return pipe(new ORMAttributePipe<Me, RoleType>(FIELD_Role)); }
public PipeLine<From, String> toPhone () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Phone)); }
public Company.CompanyPipeLineFactory<From, Company> toCompany () { return toCompany (Filter.ALL); }
public Company.CompanyPipeLineFactory<From, Company> toCompany (Filter<Company> filter)
{
return Company.REFERENCE_Company.new CompanyPipeLineFactory<From, Company> (this, new ORMSingleAssocPipe<Me, Company>(SINGLEREFERENCE_Company, filter));
}
}
public boolean isTransientAttrib(String attribName)
......@@ -1311,10 +1827,10 @@ public abstract class BaseAdminUser extends SecUserExtension
}
}
class DummyAdminUser extends AdminUser
class DummyCompanyUser extends CompanyUser
{
// Default constructor primarily to support Externalisable
public DummyAdminUser()
public DummyCompanyUser()
{
super();
}
......@@ -1324,6 +1840,20 @@ class DummyAdminUser extends AdminUser
}
public Company getCompany () throws StorageException
{
return (Company)(Company.DUMMY_Company);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getCompanyID ()
{
return Company.DUMMY_Company.getObjectID();
}
}
......@@ -75,7 +75,8 @@ public abstract class BaseJob extends BaseBusinessClass
public static final String SINGLEREFERENCE_CultureTemplate = "CultureTemplate";
public static final String SINGLEREFERENCE_JobTemplate = "JobTemplate";
public static final String SINGLEREFERENCE_Level = "Level";
public static final String SINGLEREFERENCE_SecUser = "SecUser";
public static final String SINGLEREFERENCE_Client = "Client";
public static final String SINGLEREFERENCE_CompanyUser = "CompanyUser";
public static final String MULTIPLEREFERENCE_JobApplications = "JobApplications";
public static final String BACKREF_JobApplications = "";
public static final String MULTIPLEREFERENCE_AssessmentCriterias = "AssessmentCriterias";
......@@ -153,7 +154,8 @@ public abstract class BaseJob extends BaseBusinessClass
private SingleAssociation<Job, CultureCriteriaTemplate> _CultureTemplate;
private SingleAssociation<Job, Job> _JobTemplate;
private SingleAssociation<Job, Level> _Level;
private SingleAssociation<Job, SecUser> _SecUser;
private SingleAssociation<Job, Client> _Client;
private SingleAssociation<Job, CompanyUser> _CompanyUser;
// Private attributes corresponding to multiple references
......@@ -216,7 +218,8 @@ public abstract class BaseJob extends BaseBusinessClass
setupAssocMetaData_CultureTemplate();
setupAssocMetaData_JobTemplate();
setupAssocMetaData_Level();
setupAssocMetaData_SecUser();
setupAssocMetaData_Client();
setupAssocMetaData_CompanyUser();
FIELD_Email_Validators = (AttributeValidator[])setupAttribMetaData_Email(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_Password_Validators = (AttributeValidator[])setupAttribMetaData_Password(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_ConfirmPassword_Validators = (AttributeValidator[])setupAttribMetaData_ConfirmPassword(validatorMapping).toArray (new AttributeValidator[0]);
......@@ -355,16 +358,30 @@ public abstract class BaseJob extends BaseBusinessClass
// Meta Info setup
private static void setupAssocMetaData_SecUser()
private static void setupAssocMetaData_Client()
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "secuser_id");
metaInfo.put ("name", "SecUser");
metaInfo.put ("type", "SecUser");
metaInfo.put ("dbcol", "client_id");
metaInfo.put ("name", "Client");
metaInfo.put ("type", "Client");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Job.SecUser:", metaInfo);
ATTRIBUTES_METADATA_Job.put (SINGLEREFERENCE_SecUser, Collections.unmodifiableMap (metaInfo));
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Job.Client:", metaInfo);
ATTRIBUTES_METADATA_Job.put (SINGLEREFERENCE_Client, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static void setupAssocMetaData_CompanyUser()
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "company_user_id");
metaInfo.put ("name", "CompanyUser");
metaInfo.put ("type", "CompanyUser");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Job.CompanyUser:", metaInfo);
ATTRIBUTES_METADATA_Job.put (SINGLEREFERENCE_CompanyUser, Collections.unmodifiableMap (metaInfo));
}
......@@ -937,7 +954,8 @@ public abstract class BaseJob extends BaseBusinessClass
_CultureTemplate = new SingleAssociation<Job, CultureCriteriaTemplate> (this, SINGLEREFERENCE_CultureTemplate, null, CultureCriteriaTemplate.REFERENCE_CultureCriteriaTemplate, "");
_JobTemplate = new SingleAssociation<Job, Job> (this, SINGLEREFERENCE_JobTemplate, null, Job.REFERENCE_Job, "");
_Level = new SingleAssociation<Job, Level> (this, SINGLEREFERENCE_Level, null, Level.REFERENCE_Level, "tl_job");
_SecUser = new SingleAssociation<Job, SecUser> (this, SINGLEREFERENCE_SecUser, null, SecUser.REFERENCE_SecUser, "tl_job");
_Client = new SingleAssociation<Job, Client> (this, SINGLEREFERENCE_Client, null, Client.REFERENCE_Client, "tl_job");
_CompanyUser = new SingleAssociation<Job, CompanyUser> (this, SINGLEREFERENCE_CompanyUser, null, CompanyUser.REFERENCE_CompanyUser, "tl_job");
_JobApplications = new MultipleAssociation<Job, JobApplication> (this, MULTIPLEREFERENCE_JobApplications, JobApplication.SINGLEREFERENCE_Job, JobApplication.REFERENCE_JobApplication);
_AssessmentCriterias = new MultipleAssociation<Job, AssessmentCriteria> (this, MULTIPLEREFERENCE_AssessmentCriterias, AssessmentCriteria.SINGLEREFERENCE_Job, AssessmentCriteria.REFERENCE_AssessmentCriteria);
_CultureCriterias = new MultipleAssociation<Job, CultureCriteria> (this, MULTIPLEREFERENCE_CultureCriterias, CultureCriteria.SINGLEREFERENCE_Job, CultureCriteria.REFERENCE_CultureCriteria);
......@@ -954,7 +972,8 @@ public abstract class BaseJob extends BaseBusinessClass
_CultureTemplate = new SingleAssociation<Job, CultureCriteriaTemplate> (this, SINGLEREFERENCE_CultureTemplate, null, CultureCriteriaTemplate.REFERENCE_CultureCriteriaTemplate, "");
_JobTemplate = new SingleAssociation<Job, Job> (this, SINGLEREFERENCE_JobTemplate, null, Job.REFERENCE_Job, "");
_Level = new SingleAssociation<Job, Level> (this, SINGLEREFERENCE_Level, null, Level.REFERENCE_Level, "tl_job");
_SecUser = new SingleAssociation<Job, SecUser> (this, SINGLEREFERENCE_SecUser, null, SecUser.REFERENCE_SecUser, "tl_job");
_Client = new SingleAssociation<Job, Client> (this, SINGLEREFERENCE_Client, null, Client.REFERENCE_Client, "tl_job");
_CompanyUser = new SingleAssociation<Job, CompanyUser> (this, SINGLEREFERENCE_CompanyUser, null, CompanyUser.REFERENCE_CompanyUser, "tl_job");
_JobApplications = new MultipleAssociation<Job, JobApplication> (this, MULTIPLEREFERENCE_JobApplications, JobApplication.SINGLEREFERENCE_Job, JobApplication.REFERENCE_JobApplication);
_AssessmentCriterias = new MultipleAssociation<Job, AssessmentCriteria> (this, MULTIPLEREFERENCE_AssessmentCriterias, AssessmentCriteria.SINGLEREFERENCE_Job, AssessmentCriteria.REFERENCE_AssessmentCriteria);
_CultureCriterias = new MultipleAssociation<Job, CultureCriteria> (this, MULTIPLEREFERENCE_CultureCriterias, CultureCriteria.SINGLEREFERENCE_Job, CultureCriteria.REFERENCE_CultureCriteria);
......@@ -3635,7 +3654,9 @@ public abstract class BaseJob extends BaseBusinessClass
result.add("Level");
result.add("SecUser");
result.add("Client");
result.add("CompanyUser");
return result;
......@@ -3660,9 +3681,12 @@ public abstract class BaseJob extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_Level))
{
return _Level.getReferencedType ();
}else if (assocName.equals (SINGLEREFERENCE_SecUser))
}else if (assocName.equals (SINGLEREFERENCE_Client))
{
return _Client.getReferencedType ();
}else if (assocName.equals (SINGLEREFERENCE_CompanyUser))
{
return _SecUser.getReferencedType ();
return _CompanyUser.getReferencedType ();
}
else
{
......@@ -3680,7 +3704,10 @@ public abstract class BaseJob extends BaseBusinessClass
else if (assocName.equals (SINGLEREFERENCE_Level))
{
return null ;
}else if (assocName.equals (SINGLEREFERENCE_SecUser))
}else if (assocName.equals (SINGLEREFERENCE_Client))
{
return null ;
}else if (assocName.equals (SINGLEREFERENCE_CompanyUser))
{
return null ;
}
......@@ -3709,9 +3736,12 @@ public abstract class BaseJob extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_Level))
{
return getLevel ();
}else if (assocName.equals (SINGLEREFERENCE_SecUser))
}else if (assocName.equals (SINGLEREFERENCE_Client))
{
return getSecUser ();
return getClient ();
}else if (assocName.equals (SINGLEREFERENCE_CompanyUser))
{
return getCompanyUser ();
}
else
{
......@@ -3738,9 +3768,12 @@ public abstract class BaseJob extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_Level))
{
return getLevel (getType);
}else if (assocName.equals (SINGLEREFERENCE_SecUser))
}else if (assocName.equals (SINGLEREFERENCE_Client))
{
return getClient (getType);
}else if (assocName.equals (SINGLEREFERENCE_CompanyUser))
{
return getSecUser (getType);
return getCompanyUser (getType);
}
else
{
......@@ -3767,9 +3800,12 @@ public abstract class BaseJob extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_Level))
{
return getLevelID ();
}else if (assocName.equals (SINGLEREFERENCE_SecUser))
}else if (assocName.equals (SINGLEREFERENCE_Client))
{
return getClientID ();
}else if (assocName.equals (SINGLEREFERENCE_CompanyUser))
{
return getSecUserID ();
return getCompanyUserID ();
}
else
{
......@@ -3796,9 +3832,12 @@ public abstract class BaseJob extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_Level))
{
setLevel ((Level)(newValue));
}else if (assocName.equals (SINGLEREFERENCE_SecUser))
}else if (assocName.equals (SINGLEREFERENCE_Client))
{
setSecUser ((SecUser)(newValue));
setClient ((Client)(newValue));
}else if (assocName.equals (SINGLEREFERENCE_CompanyUser))
{
setCompanyUser ((CompanyUser)(newValue));
}
else
{
......@@ -4186,20 +4225,20 @@ public abstract class BaseJob extends BaseBusinessClass
}
/**
* Get the reference SecUser
* Get the reference Client
*/
public SecUser getSecUser () throws StorageException
public Client getClient () throws StorageException
{
assertValid();
try
{
return (SecUser)(_SecUser.get ());
return (Client)(_Client.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in Job:", this.getObjectID (), ", was trying to get SecUser:", getSecUserID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _SecUser.get ().getClass ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in Job:", this.getObjectID (), ", was trying to get Client:", getClientID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _Client.get ().getClass ());
throw e;
}
}
......@@ -4208,27 +4247,27 @@ public abstract class BaseJob extends BaseBusinessClass
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public SecUser getSecUser (Get getType) throws StorageException
public Client getClient (Get getType) throws StorageException
{
assertValid();
return _SecUser.get(getType);
return _Client.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getSecUserID ()
public Long getClientID ()
{
assertValid();
if (_SecUser == null)
if (_Client == null)
{
return null;
}
else
{
return _SecUser.getID ();
return _Client.getID ();
}
}
......@@ -4236,7 +4275,7 @@ public abstract class BaseJob extends BaseBusinessClass
* Called prior to the assoc changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preSecUserChange (SecUser newSecUser) throws FieldException
protected void preClientChange (Client newClient) throws FieldException
{
}
......@@ -4246,36 +4285,130 @@ public abstract class BaseJob extends BaseBusinessClass
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postSecUserChange () throws FieldException
protected void postClientChange () throws FieldException
{
}
public FieldWriteability getWriteability_SecUser ()
public FieldWriteability getWriteability_Client ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference SecUser. Checks to ensure a new value
* Set the reference Client. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setSecUser (SecUser newSecUser) throws StorageException, FieldException
public void setClient (Client newClient) throws StorageException, FieldException
{
if (_SecUser.wouldReferencedChange (newSecUser))
if (_Client.wouldReferencedChange (newClient))
{
assertValid();
Debug.assertion (getWriteability_SecUser () != FieldWriteability.FALSE, "Assoc SecUser is not writeable");
preSecUserChange (newSecUser);
Debug.assertion (getWriteability_Client () != FieldWriteability.FALSE, "Assoc Client is not writeable");
preClientChange (newClient);
_SecUser.set (newSecUser);
_Client.set (newClient);
postSecUserChange ();
postClientChange ();
}
}
/**
* Get the reference CompanyUser
*/
public CompanyUser getCompanyUser () throws StorageException
{
assertValid();
try
{
return (CompanyUser)(_CompanyUser.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in Job:", this.getObjectID (), ", was trying to get CompanyUser:", getCompanyUserID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _CompanyUser.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public CompanyUser getCompanyUser (Get getType) throws StorageException
{
assertValid();
return _CompanyUser.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getCompanyUserID ()
{
assertValid();
if (_CompanyUser == null)
{
return null;
}
else
{
return _CompanyUser.getID ();
}
}
/**
* Called prior to the assoc changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preCompanyUserChange (CompanyUser newCompanyUser) throws FieldException
{
}
/**
* Called after the assoc changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postCompanyUserChange () throws FieldException
{
}
public FieldWriteability getWriteability_CompanyUser ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference CompanyUser. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setCompanyUser (CompanyUser newCompanyUser) throws StorageException, FieldException
{
if (_CompanyUser.wouldReferencedChange (newCompanyUser))
{
assertValid();
Debug.assertion (getWriteability_CompanyUser () != FieldWriteability.FALSE, "Assoc CompanyUser is not writeable");
preCompanyUserChange (newCompanyUser);
_CompanyUser.set (newCompanyUser);
postCompanyUserChange ();
}
}
......@@ -4819,7 +4952,8 @@ public abstract class BaseJob extends BaseBusinessClass
tl_jobPSet.setAttrib (FIELD_State, HELPER_State.toObject (_State)); //
tl_jobPSet.setAttrib (FIELD_Country, HELPER_Country.toObject (_Country)); //
_Level.getPersistentSets (allSets);
_SecUser.getPersistentSets (allSets);
_Client.getPersistentSets (allSets);
_CompanyUser.getPersistentSets (allSets);
}
......@@ -4850,7 +4984,8 @@ public abstract class BaseJob extends BaseBusinessClass
_State = (State)(HELPER_State.fromObject (_State, tl_jobPSet.getAttrib (FIELD_State))); //
_Country = (Countries)(HELPER_Country.fromObject (_Country, tl_jobPSet.getAttrib (FIELD_Country))); //
_Level.setFromPersistentSets (objectID, allSets);
_SecUser.setFromPersistentSets (objectID, allSets);
_Client.setFromPersistentSets (objectID, allSets);
_CompanyUser.setFromPersistentSets (objectID, allSets);
}
......@@ -5063,7 +5198,8 @@ public abstract class BaseJob extends BaseBusinessClass
_CultureTemplate.copyFrom (sourceJob._CultureTemplate, linkToGhosts);
_JobTemplate.copyFrom (sourceJob._JobTemplate, linkToGhosts);
_Level.copyFrom (sourceJob._Level, linkToGhosts);
_SecUser.copyFrom (sourceJob._SecUser, linkToGhosts);
_Client.copyFrom (sourceJob._Client, linkToGhosts);
_CompanyUser.copyFrom (sourceJob._CompanyUser, linkToGhosts);
}
}
......@@ -5136,7 +5272,8 @@ public abstract class BaseJob extends BaseBusinessClass
_CultureTemplate.readExternalData(vals.get(SINGLEREFERENCE_CultureTemplate));
_JobTemplate.readExternalData(vals.get(SINGLEREFERENCE_JobTemplate));
_Level.readExternalData(vals.get(SINGLEREFERENCE_Level));
_SecUser.readExternalData(vals.get(SINGLEREFERENCE_SecUser));
_Client.readExternalData(vals.get(SINGLEREFERENCE_Client));
_CompanyUser.readExternalData(vals.get(SINGLEREFERENCE_CompanyUser));
_JobApplications.readExternalData(vals.get(MULTIPLEREFERENCE_JobApplications));
_AssessmentCriterias.readExternalData(vals.get(MULTIPLEREFERENCE_AssessmentCriterias));
_CultureCriterias.readExternalData(vals.get(MULTIPLEREFERENCE_CultureCriterias));
......@@ -5182,7 +5319,8 @@ public abstract class BaseJob extends BaseBusinessClass
vals.put (SINGLEREFERENCE_CultureTemplate, _CultureTemplate.writeExternalData());
vals.put (SINGLEREFERENCE_JobTemplate, _JobTemplate.writeExternalData());
vals.put (SINGLEREFERENCE_Level, _Level.writeExternalData());
vals.put (SINGLEREFERENCE_SecUser, _SecUser.writeExternalData());
vals.put (SINGLEREFERENCE_Client, _Client.writeExternalData());
vals.put (SINGLEREFERENCE_CompanyUser, _CompanyUser.writeExternalData());
vals.put (MULTIPLEREFERENCE_JobApplications, _JobApplications.writeExternalData());
vals.put (MULTIPLEREFERENCE_AssessmentCriterias, _AssessmentCriterias.writeExternalData());
vals.put (MULTIPLEREFERENCE_CultureCriterias, _CultureCriterias.writeExternalData());
......@@ -5265,7 +5403,8 @@ public abstract class BaseJob extends BaseBusinessClass
_CultureTemplate.compare (otherJob._CultureTemplate, listener);
_JobTemplate.compare (otherJob._JobTemplate, listener);
_Level.compare (otherJob._Level, listener);
_SecUser.compare (otherJob._SecUser, listener);
_Client.compare (otherJob._Client, listener);
_CompanyUser.compare (otherJob._CompanyUser, listener);
// Compare multiple assocs
......@@ -5320,7 +5459,8 @@ public abstract class BaseJob extends BaseBusinessClass
visitor.visitAssociation (_CultureTemplate);
visitor.visitAssociation (_JobTemplate);
visitor.visitAssociation (_Level);
visitor.visitAssociation (_SecUser);
visitor.visitAssociation (_Client);
visitor.visitAssociation (_CompanyUser);
visitor.visitAssociation (_JobApplications);
visitor.visitAssociation (_AssessmentCriterias);
visitor.visitAssociation (_CultureCriterias);
......@@ -5348,9 +5488,13 @@ public abstract class BaseJob extends BaseBusinessClass
{
visitor.visit (_Level);
}
if (scope.includes (_SecUser))
if (scope.includes (_Client))
{
visitor.visit (_SecUser);
visitor.visit (_Client);
}
if (scope.includes (_CompanyUser))
{
visitor.visit (_CompanyUser);
}
if (scope.includes (_JobApplications))
{
......@@ -5453,9 +5597,13 @@ public abstract class BaseJob extends BaseBusinessClass
{
return filter.matches (getLevel ());
}
else if (attribName.equals (SINGLEREFERENCE_SecUser))
else if (attribName.equals (SINGLEREFERENCE_Client))
{
return filter.matches (getClient ());
}
else if (attribName.equals (SINGLEREFERENCE_CompanyUser))
{
return filter.matches (getSecUser ());
return filter.matches (getCompanyUser ());
}
else
{
......@@ -5584,9 +5732,15 @@ public abstract class BaseJob extends BaseBusinessClass
return this;
}
public SearchAll andSecUser (QueryFilter<SecUser> filter)
public SearchAll andClient (QueryFilter<Client> filter)
{
filter.addFilter (context, "tl_job.client_id", "Client");
return this;
}
public SearchAll andCompanyUser (QueryFilter<CompanyUser> filter)
{
filter.addFilter (context, "tl_job.secuser_id", "SecUser");
filter.addFilter (context, "tl_job.company_user_id", "CompanyUser");
return this;
}
......@@ -5749,9 +5903,15 @@ public abstract class BaseJob extends BaseBusinessClass
return this;
}
public SearchJobKey andSecUser (QueryFilter<SecUser> filter)
public SearchJobKey andClient (QueryFilter<Client> filter)
{
filter.addFilter (context, "tl_job.secuser_id", "SecUser");
filter.addFilter (context, "tl_job.client_id", "Client");
return this;
}
public SearchJobKey andCompanyUser (QueryFilter<CompanyUser> filter)
{
filter.addFilter (context, "tl_job.company_user_id", "CompanyUser");
return this;
}
......@@ -6236,9 +6396,13 @@ public abstract class BaseJob extends BaseBusinessClass
{
return getWriteability_Level ();
}
else if (fieldName.equals (SINGLEREFERENCE_SecUser))
else if (fieldName.equals (SINGLEREFERENCE_Client))
{
return getWriteability_SecUser ();
return getWriteability_Client ();
}
else if (fieldName.equals (SINGLEREFERENCE_CompanyUser))
{
return getWriteability_CompanyUser ();
}
else if (fieldName.equals (FIELD_Email))
{
......@@ -7205,9 +7369,13 @@ public abstract class BaseJob extends BaseBusinessClass
{
return toLevel ();
}
if (name.equals ("SecUser"))
if (name.equals ("Client"))
{
return toSecUser ();
return toClient ();
}
if (name.equals ("CompanyUser"))
{
return toCompanyUser ();
}
......@@ -7292,11 +7460,17 @@ public abstract class BaseJob extends BaseBusinessClass
{
return Level.REFERENCE_Level.new LevelPipeLineFactory<From, Level> (this, new ORMSingleAssocPipe<Me, Level>(SINGLEREFERENCE_Level, filter));
}
public SecUser.SecUserPipeLineFactory<From, SecUser> toSecUser () { return toSecUser (Filter.ALL); }
public Client.ClientPipeLineFactory<From, Client> toClient () { return toClient (Filter.ALL); }
public Client.ClientPipeLineFactory<From, Client> toClient (Filter<Client> filter)
{
return Client.REFERENCE_Client.new ClientPipeLineFactory<From, Client> (this, new ORMSingleAssocPipe<Me, Client>(SINGLEREFERENCE_Client, filter));
}
public CompanyUser.CompanyUserPipeLineFactory<From, CompanyUser> toCompanyUser () { return toCompanyUser (Filter.ALL); }
public SecUser.SecUserPipeLineFactory<From, SecUser> toSecUser (Filter<SecUser> filter)
public CompanyUser.CompanyUserPipeLineFactory<From, CompanyUser> toCompanyUser (Filter<CompanyUser> filter)
{
return SecUser.REFERENCE_SecUser.new SecUserPipeLineFactory<From, SecUser> (this, new ORMSingleAssocPipe<Me, SecUser>(SINGLEREFERENCE_SecUser, filter));
return CompanyUser.REFERENCE_CompanyUser.new CompanyUserPipeLineFactory<From, CompanyUser> (this, new ORMSingleAssocPipe<Me, CompanyUser>(SINGLEREFERENCE_CompanyUser, filter));
}
public JobApplication.JobApplicationPipeLineFactory<From, JobApplication> toJobApplications () { return toJobApplications(Filter.ALL); }
......@@ -7478,18 +7652,32 @@ class DummyJob extends Job
return Level.DUMMY_Level.getObjectID();
}
public SecUser getSecUser () throws StorageException
public Client getClient () throws StorageException
{
return (Client)(Client.DUMMY_Client);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getClientID ()
{
return Client.DUMMY_Client.getObjectID();
}
public CompanyUser getCompanyUser () throws StorageException
{
return (SecUser)(SecUser.DUMMY_SecUser);
return (CompanyUser)(CompanyUser.DUMMY_CompanyUser);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getSecUserID ()
public Long getCompanyUserID ()
{
return SecUser.DUMMY_SecUser.getObjectID();
return CompanyUser.DUMMY_CompanyUser.getObjectID();
}
public int getJobApplicationsCount () throws StorageException
......
package performa.orm;
import java.io.*;
import java.util.*;
import oneit.appservices.config.*;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.utils.*;
import performa.orm.types.*;
import oneit.business.shopping.orm.*;
public class Client extends BaseClient
{
private static final long serialVersionUID = 0L;
// This constructor should not be called
public Client ()
{
// Do not add any code to this, always put it in initialiseNewObject
}
}
<?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="Client" package="performa.orm">
<IMPORT value="performa.orm.types.*"/>
<IMPORT value="oneit.business.shopping.orm.*"/>
<TABLE name="tl_client" tablePrefix="object" polymorphic="TRUE">
<ATTRIB name="CompanyName" type="String" dbcol="company_name" mandatory="true" length="100"/>
<ATTRIB name="CompanyLogo" type="BinaryContent" dbcol="company_logo" mandatory="false" binaryHandler="loggedin" attribHelper="BLOBAttributeHelper" attribHelperInstance="BLOBAttributeHelper.INSTANCE" />
<ATTRIB name="Email" type="String" dbcol="email" mandatory="false" length="100" validators="Email" />
<ATTRIB name="ContactName" type="String" dbcol="contact_name" mandatory="false" length="100"/>
<ATTRIB name="ContactSurname" type="String" dbcol="contact_surname" mandatory="false" length="100"/>
<ATTRIB name="Phone" type="String" dbcol="phone" mandatory="false" length="30" />
<ATTRIB name="State" type="State" dbcol="state" mandatory="false" defaultValue="State.WA" attribHelper="EnumeratedAttributeHelper"/>
<ATTRIB name="Country" type="Countries" dbcol="country" mandatory="false" defaultValue="Countries.AU" attribHelper="EnumeratedAttributeHelper"/>
<ATTRIB name="PostCode" type="String" dbcol="post_code" mandatory="false" length="10"/>
<SINGLEREFERENCE name="Company" type="Company" dbcol="company_id" backreferenceName="Clients"/>
</TABLE>
<SEARCH type="All" paramFilter="tl_client.object_id is not null">
</SEARCH>
</BUSINESSCLASS>
</ROOT>
\ No newline at end of file
package performa.orm;
import java.io.*;
import java.util.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.rdbms.*;
import oneit.objstore.utils.*;
import oneit.sql.*;
import oneit.utils.resource.*;
import oneit.utils.*;
import oneit.utils.threading.*;
import performa.orm.types.*;
import oneit.business.shopping.orm.*;
/**
* IMPORTANT!!!! Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2[oneit.objstore.PersistenceMgrTemplate.xsl]
*/
public class ClientPersistenceMgr extends ObjectPersistenceMgr
{
private static final LoggingArea ClientPersistence = LoggingArea.createLoggingArea(ObjectPersistenceMgr.OBJECT_PERSISTENCE, "Client");
// Private attributes corresponding to business object data
private String dummyCompanyName;
private BinaryContent dummyCompanyLogo;
private String dummyEmail;
private String dummyContactName;
private String dummyContactSurname;
private String dummyPhone;
private State dummyState;
private Countries dummyCountry;
private String dummyPostCode;
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper HELPER_CompanyName = DefaultAttributeHelper.INSTANCE;
private static final BLOBAttributeHelper HELPER_CompanyLogo = BLOBAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_Email = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_ContactName = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_ContactSurname = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_Phone = DefaultAttributeHelper.INSTANCE;
private static final EnumeratedAttributeHelper HELPER_State = new EnumeratedAttributeHelper (State.FACTORY_State);
private static final EnumeratedAttributeHelper HELPER_Country = new EnumeratedAttributeHelper (Countries.FACTORY_Countries);
private static final DefaultAttributeHelper HELPER_PostCode = DefaultAttributeHelper.INSTANCE;
public ClientPersistenceMgr ()
{
dummyCompanyName = (String)(HELPER_CompanyName.initialise (dummyCompanyName));
dummyCompanyLogo = (BinaryContent)(HELPER_CompanyLogo.initialise (dummyCompanyLogo));
dummyEmail = (String)(HELPER_Email.initialise (dummyEmail));
dummyContactName = (String)(HELPER_ContactName.initialise (dummyContactName));
dummyContactSurname = (String)(HELPER_ContactSurname.initialise (dummyContactSurname));
dummyPhone = (String)(HELPER_Phone.initialise (dummyPhone));
dummyState = (State)(HELPER_State.initialise (dummyState));
dummyCountry = (Countries)(HELPER_Country.initialise (dummyCountry));
dummyPostCode = (String)(HELPER_PostCode.initialise (dummyPostCode));
}
private String SELECT_COLUMNS = "{PREFIX}tl_client.object_id as id, {PREFIX}tl_client.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_client.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_client.object_TYPE as OBJECT_TYPE, {PREFIX}tl_client.company_name, {PREFIX}tl_client.company_logo, {PREFIX}tl_client.email, {PREFIX}tl_client.contact_name, {PREFIX}tl_client.contact_surname, {PREFIX}tl_client.phone, {PREFIX}tl_client.state, {PREFIX}tl_client.country, {PREFIX}tl_client.post_code, {PREFIX}tl_client.company_id, 1 AS commasafe ";
private String SELECT_JOINS = "";
public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
Set<BaseBusinessClass> resultByIDs = fetchByIDs(Collections.singleton (id), allPSets, context, sqlMgr);
if (resultByIDs.isEmpty ())
{
return null;
}
else if (resultByIDs.size () > 1)
{
throw new StorageException ("Multiple results for id:" + id);
}
else
{
return resultByIDs.iterator ().next ();
}
}
public Set<BaseBusinessClass> fetchByIDs(Set<ObjectID> ids, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
Set<BaseBusinessClass> results = new HashSet ();
Set<Long> idsToFetch = new HashSet ();
for (ObjectID id : ids)
{
if (context.containsObject(id)) // Check for cached version
{
BaseBusinessClass objectToReturn = context.getObjectToReplace(id, Client.REFERENCE_Client);
if (objectToReturn instanceof Client)
{
LogMgr.log (ClientPersistence, LogLevel.TRACE, "Cache hit for id:", id);
results.add (objectToReturn);
}
else
{
throw new StorageException ("Cache collision for id:" + id + " with object " + objectToReturn + "while fetching a Client");
}
}
PersistentSet tl_clientPSet = allPSets.getPersistentSet(id, "tl_client", PersistentSetStatus.FETCHED);
String objectType = null;
// Check for persistent sets already prefetched
if (false ||
!tl_clientPSet.containsAttrib("OBJECT_TYPE") || !tl_clientPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!tl_clientPSet.containsAttrib(Client.FIELD_CompanyName)||
!tl_clientPSet.containsAttrib(Client.FIELD_CompanyLogo)||
!tl_clientPSet.containsAttrib(Client.FIELD_Email)||
!tl_clientPSet.containsAttrib(Client.FIELD_ContactName)||
!tl_clientPSet.containsAttrib(Client.FIELD_ContactSurname)||
!tl_clientPSet.containsAttrib(Client.FIELD_Phone)||
!tl_clientPSet.containsAttrib(Client.FIELD_State)||
!tl_clientPSet.containsAttrib(Client.FIELD_Country)||
!tl_clientPSet.containsAttrib(Client.FIELD_PostCode)||
!tl_clientPSet.containsAttrib(Client.SINGLEREFERENCE_Company))
{
// We will need to retrieve it
idsToFetch.add (id.longValue());
}
else
{
LogMgr.log (ClientPersistence, LogLevel.DEBUG2, "Persistent set preloaded id:", id);
/* Polymorphic */
objectType = (String)(tl_clientPSet.getAttrib("OBJECT_TYPE"));
if (context.getReferenceObject (Client.REFERENCE_Client, objectType) != Client.REFERENCE_Client)
{
idsToFetch.add (id.longValue());
}
else
{
Client result = new Client ();
result.setFromPersistentSets(id, allPSets);
context.addRetrievedObject(result);
results.add (result);
}
}
}
if (idsToFetch.size () > 0)
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_client " +
"WHERE " + SELECT_JOINS + "{PREFIX}tl_client.object_id IN ?";
BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false);
for (BaseBusinessClass objFetched : resultsFetched)
{
results.add (objFetched);
}
}
return results;
}
public BaseBusinessClass[] getReferencedObjects(ObjectID _objectID, String refName, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
if (false)
{
throw new RuntimeException ();
}
else if (refName.equals (Client.SINGLEREFERENCE_Company))
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_client " +
"WHERE " + SELECT_JOINS + "company_id = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
return results;
}
else
{
throw new IllegalArgumentException ("Illegal reference type:" + refName);
}
}
public void update(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{
EqualityResult test = EqualityResult.compare (obj, obj.getBackup ());
ObjectID objectID = obj.getID ();
if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave())
{
PersistentSet tl_clientPSet = allPSets.getPersistentSet(objectID, "tl_client");
if (tl_clientPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_clientPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}tl_client " +
"SET company_name = ?, company_logo = ?, email = ?, contact_name = ?, contact_surname = ?, phone = ?, state = ?, country = ?, post_code = ?, company_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE tl_client.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_CompanyName.getForSQL(dummyCompanyName, tl_clientPSet.getAttrib (Client.FIELD_CompanyName))).listEntry (HELPER_CompanyLogo.getForSQL(dummyCompanyLogo, tl_clientPSet.getAttrib (Client.FIELD_CompanyLogo))).listEntry (HELPER_Email.getForSQL(dummyEmail, tl_clientPSet.getAttrib (Client.FIELD_Email))).listEntry (HELPER_ContactName.getForSQL(dummyContactName, tl_clientPSet.getAttrib (Client.FIELD_ContactName))).listEntry (HELPER_ContactSurname.getForSQL(dummyContactSurname, tl_clientPSet.getAttrib (Client.FIELD_ContactSurname))).listEntry (HELPER_Phone.getForSQL(dummyPhone, tl_clientPSet.getAttrib (Client.FIELD_Phone))).listEntry (HELPER_State.getForSQL(dummyState, tl_clientPSet.getAttrib (Client.FIELD_State))).listEntry (HELPER_Country.getForSQL(dummyCountry, tl_clientPSet.getAttrib (Client.FIELD_Country))).listEntry (HELPER_PostCode.getForSQL(dummyPostCode, tl_clientPSet.getAttrib (Client.FIELD_PostCode))).listEntry (SQLManager.CheckNull((Long)(tl_clientPSet.getAttrib (Client.SINGLEREFERENCE_Company)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1)
{
// Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr,
"SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}tl_client WHERE object_id = ?",
new Object[] { objectID.longID () });
if (r.next ())
{
Date d = new java.util.Date (r.getTimestamp (2).getTime());
String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]",
new Object[] { "tl_client", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ());
LogMgr.log (ClientPersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "tl_client");
}
else
{
String errorMsg = "Attempt to update nonexistent row in table:tl_client for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (ClientPersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
tl_clientPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
else
{
LogMgr.log (ClientPersistence, LogLevel.DEBUG1, "Skipping update since no attribs or simple assocs changed on ", objectID);
}
}
public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet tl_clientPSet = allPSets.getPersistentSet(objectID, "tl_client");
LogMgr.log (ClientPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (tl_clientPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_clientPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsDeleted = executeStatement (sqlMgr,
"DELETE " +
"FROM {PREFIX}tl_client " +
"WHERE tl_client.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ",
new Object[] { objectID.longID(), obj.getObjectLastModified () });
if (rowsDeleted != 1)
{
// Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr,
"SELECT object_id FROM {PREFIX}tl_client WHERE object_id = ?",
new Object[] { objectID.longID() });
if (r.next ())
{
throw new ConcurrentUpdateConflictException (obj, "tl_client");
}
else
{
String errorMsg = "Attempt to delete nonexistent row in table:tl_client for row:" + objectID;
LogMgr.log (ClientPersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
tl_clientPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
public ResultSet executeSearchQueryAll (SQLManager sqlMgr) throws SQLException
{
throw new RuntimeException ("NOT implemented: executeSearchQueryAll");
}
public BaseBusinessClass[] loadQuery (PersistentSetCollection allPSets, SQLManager sqlMgr, RDBMSPersistenceContext context, String query, Object[] params, Integer maxRows, boolean truncateExtra) throws SQLException, StorageException
{
LinkedHashMap<ObjectID, Client> results = new LinkedHashMap ();
MultiHashtable<String,ObjectID> needsRefetch = new MultiHashtable ();
ResultSet r = executeQuery (sqlMgr, query, params);
while (r.next())
{
ThreadUtils.checkInterrupted ();
ObjectID objectID = new ObjectID (Client.REFERENCE_Client.getObjectIDSpace (), r.getLong ("id"));
Client resultElement;
if (maxRows != null && !results.containsKey (objectID) && results.size () >= maxRows)
{
if (truncateExtra)
{
break;
}
else
{
throw new SearchRowsExceededException ("Maximum rows exceeded:" + maxRows);
}
}
if (context.containsObject(objectID))
{
BaseBusinessClass cachedElement = context.getObjectToReplace(objectID, Client.REFERENCE_Client);
if (cachedElement instanceof Client)
{
LogMgr.log (ClientPersistence, LogLevel.TRACE, "Cache hit for id:", objectID);
resultElement = (Client)cachedElement;
}
else
{
throw new StorageException ("Cache collision for id:" + objectID + " with object " + cachedElement + "while fetching a Client");
}
}
else
{
PersistentSet tl_clientPSet = allPSets.getPersistentSet(objectID, "tl_client", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID);
String objectType = (String)(tl_clientPSet.getAttrib("OBJECT_TYPE"));
if (context.getReferenceObject (Client.REFERENCE_Client, objectType) != Client.REFERENCE_Client)
{
needsRefetch.add (objectType, objectID); // We will fetch these later
resultElement = new Client ();
resultElement.initialiseGhost (objectID);
}
else
{
resultElement = new Client ();
resultElement.setFromPersistentSets(objectID, allPSets);
context.addRetrievedObject(resultElement);
}
}
results.put (objectID, resultElement);
}
for (String objectType : needsRefetch.keySet())
{
BaseBusinessClass referenceObject = context.getReferenceObject (Client.REFERENCE_Client, objectType);
ObjectPersistenceMgr persistenceMgr = context.getPersistenceMgr (referenceObject);
ResourceCheckpoint checkpoint = sqlMgr.getCheckpoint();
Set<BaseBusinessClass> objsRefetched = persistenceMgr.fetchByIDs(new HashSet (needsRefetch.getValuesForKey (objectType)), allPSets, context, sqlMgr);
checkpoint.releaseNewResources();
for (BaseBusinessClass objRefetched : objsRefetched)
{
results.put (objRefetched.getID (), (Client)objRefetched);
}
}
BaseBusinessClass[] resultsArr = new BaseBusinessClass[results.size ()];
return results.values ().toArray (resultsArr);
}
public BaseBusinessClass[] find(String searchType, PersistentSetCollection allPSets, Hashtable criteria, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
LogMgr.log (ClientPersistence, LogLevel.DEBUG2, "Search executing:", searchType, " criteria:", criteria);
String customParamFilter = (String)criteria.get (SEARCH_CustomFilter);
String customOrderBy = (String)criteria.get (SEARCH_OrderBy);
String customTables = (String)criteria.get (SEARCH_CustomExtraTables);
Boolean noCommaBeforeCustomExtraTables = (Boolean)criteria.get (SEARCH_CustomExtraTablesNoComma);
if (searchType.equals (SEARCH_CustomSQL))
{
Set<ObjectID> processedIDs = new HashSet();
SearchParamTransform tx = new SearchParamTransform (criteria);
Object[] searchParams;
customParamFilter = StringUtils.replaceParams (customParamFilter, tx);
searchParams = tx.getParamsArray();
if (customOrderBy != null)
{
customOrderBy = " ORDER BY " + customOrderBy;
}
else
{
customOrderBy = "";
}
ResultSet r;
String concatCustomTableWith = CollectionUtils.equals(noCommaBeforeCustomExtraTables, true) ? " " : ", ";
String tables = StringUtils.subBlanks(customTables) == null ? " " : concatCustomTableWith + customTables + " ";
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_client " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
return results;
}
else if (searchType.equals (Client.SEARCH_All))
{
// Local scope for transformed variables
{
}
String orderBy = " ";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter: tl_client.object_id is not null
String preFilter = "(tl_client.object_id is not null)"
+ " ";
preFilter += context.getLoadingAttributes ().getCustomSQL() ;
SearchParamTransform tx = new SearchParamTransform (criteria);
filter = StringUtils.replaceParams (preFilter, tx);
searchParams = tx.getParamsArray();
Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_client " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, maxRows, truncateExtra);
return results;
}
else
{
throw new IllegalArgumentException ("Illegal search type:" + searchType);
}
}
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{
PersistentSet tl_clientPSet = allPSets.getPersistentSet(objectID, "tl_client", PersistentSetStatus.FETCHED);
// Object Modified
tl_clientPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created
tl_clientPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));tl_clientPSet.setAttrib("OBJECT_TYPE", r.getString ("OBJECT_TYPE"));
tl_clientPSet.setAttrib(Client.FIELD_CompanyName, HELPER_CompanyName.getFromRS(dummyCompanyName, r, "company_name"));
tl_clientPSet.setAttrib(Client.FIELD_CompanyLogo, HELPER_CompanyLogo.getFromRS(dummyCompanyLogo, r, "company_logo"));
tl_clientPSet.setAttrib(Client.FIELD_Email, HELPER_Email.getFromRS(dummyEmail, r, "email"));
tl_clientPSet.setAttrib(Client.FIELD_ContactName, HELPER_ContactName.getFromRS(dummyContactName, r, "contact_name"));
tl_clientPSet.setAttrib(Client.FIELD_ContactSurname, HELPER_ContactSurname.getFromRS(dummyContactSurname, r, "contact_surname"));
tl_clientPSet.setAttrib(Client.FIELD_Phone, HELPER_Phone.getFromRS(dummyPhone, r, "phone"));
tl_clientPSet.setAttrib(Client.FIELD_State, HELPER_State.getFromRS(dummyState, r, "state"));
tl_clientPSet.setAttrib(Client.FIELD_Country, HELPER_Country.getFromRS(dummyCountry, r, "country"));
tl_clientPSet.setAttrib(Client.FIELD_PostCode, HELPER_PostCode.getFromRS(dummyPostCode, r, "post_code"));
tl_clientPSet.setAttrib(Client.SINGLEREFERENCE_Company, r.getObject ("company_id"));
}
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet tl_clientPSet = allPSets.getPersistentSet(objectID, "tl_client");
if (tl_clientPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_clientPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
executeStatement (sqlMgr,
"INSERT INTO {PREFIX}tl_client " +
" (company_name, company_logo, email, contact_name, contact_surname, phone, state, country, post_code, company_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE, object_TYPE) " +
"VALUES " +
" (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", ?)",
CollectionUtils.listEntry (HELPER_CompanyName.getForSQL(dummyCompanyName, tl_clientPSet.getAttrib (Client.FIELD_CompanyName))).listEntry (HELPER_CompanyLogo.getForSQL(dummyCompanyLogo, tl_clientPSet.getAttrib (Client.FIELD_CompanyLogo))).listEntry (HELPER_Email.getForSQL(dummyEmail, tl_clientPSet.getAttrib (Client.FIELD_Email))).listEntry (HELPER_ContactName.getForSQL(dummyContactName, tl_clientPSet.getAttrib (Client.FIELD_ContactName))).listEntry (HELPER_ContactSurname.getForSQL(dummyContactSurname, tl_clientPSet.getAttrib (Client.FIELD_ContactSurname))).listEntry (HELPER_Phone.getForSQL(dummyPhone, tl_clientPSet.getAttrib (Client.FIELD_Phone))).listEntry (HELPER_State.getForSQL(dummyState, tl_clientPSet.getAttrib (Client.FIELD_State))).listEntry (HELPER_Country.getForSQL(dummyCountry, tl_clientPSet.getAttrib (Client.FIELD_Country))).listEntry (HELPER_PostCode.getForSQL(dummyPostCode, tl_clientPSet.getAttrib (Client.FIELD_PostCode))) .listEntry (SQLManager.CheckNull((Long)(tl_clientPSet.getAttrib (Client.SINGLEREFERENCE_Company)))) .listEntry (objectID.longID ()).listEntry (context.getTag (obj)).toList().toArray());
tl_clientPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
}
package performa.orm;
import java.io.*;
import java.util.*;
import oneit.appservices.config.*;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.utils.*;
import performa.orm.types.*;
public class Company extends BaseCompany
{
private static final long serialVersionUID = 0L;
// This constructor should not be called
public Company ()
{
// Do not add any code to this, always put it in initialiseNewObject
}
}
<?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="Company" package="performa.orm">
<IMPORT value="performa.orm.types.*"/>
<IMPORT value="performa.orm.types.TimeZone"/>
<MULTIPLEREFERENCE name="Users" type="CompanyUser" backreferenceName="Company"/>
<MULTIPLEREFERENCE name="Clients" type="Client" backreferenceName="Company"/>
<TABLE name="tl_Company" tablePrefix="object" polymorphic="TRUE">
<ATTRIB name="CompanyName" type="String" dbcol="company_name" mandatory="true" length="100" />
<ATTRIB name="HiringTeamType" type="HiringTeamType" dbcol="hiring_team_type" mandatory="false" attribHelper="EnumeratedAttributeHelper"/>
<ATTRIB name="Industry" type="Industry" dbcol="industry" mandatory="false" attribHelper="EnumeratedAttributeHelper"/>
<ATTRIB name="TimeZone" type="TimeZone" dbcol="time_zone" mandatory="false" attribHelper="EnumeratedAttributeHelper"/>
<SINGLEREFERENCE name="AddedByUser" type="CompanyUser" dbcol="added_by_user_id" mandatory="true"/>
</TABLE>
<SEARCH type="All" paramFilter="tl_company.object_id is not null" >
</SEARCH>
</BUSINESSCLASS>
</ROOT>
\ No newline at end of file
package performa.orm;
import java.io.*;
import java.util.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.rdbms.*;
import oneit.objstore.utils.*;
import oneit.sql.*;
import oneit.utils.resource.*;
import oneit.utils.*;
import oneit.utils.threading.*;
import performa.orm.types.*;
import performa.orm.types.TimeZone;
/**
* IMPORTANT!!!! Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2[oneit.objstore.PersistenceMgrTemplate.xsl]
*/
public class CompanyPersistenceMgr extends ObjectPersistenceMgr
{
private static final LoggingArea CompanyPersistence = LoggingArea.createLoggingArea(ObjectPersistenceMgr.OBJECT_PERSISTENCE, "Company");
// Private attributes corresponding to business object data
private String dummyCompanyName;
private HiringTeamType dummyHiringTeamType;
private Industry dummyIndustry;
private TimeZone dummyTimeZone;
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper HELPER_CompanyName = DefaultAttributeHelper.INSTANCE;
private static final EnumeratedAttributeHelper HELPER_HiringTeamType = new EnumeratedAttributeHelper (HiringTeamType.FACTORY_HiringTeamType);
private static final EnumeratedAttributeHelper HELPER_Industry = new EnumeratedAttributeHelper (Industry.FACTORY_Industry);
private static final EnumeratedAttributeHelper HELPER_TimeZone = new EnumeratedAttributeHelper (TimeZone.FACTORY_TimeZone);
public CompanyPersistenceMgr ()
{
dummyCompanyName = (String)(HELPER_CompanyName.initialise (dummyCompanyName));
dummyHiringTeamType = (HiringTeamType)(HELPER_HiringTeamType.initialise (dummyHiringTeamType));
dummyIndustry = (Industry)(HELPER_Industry.initialise (dummyIndustry));
dummyTimeZone = (TimeZone)(HELPER_TimeZone.initialise (dummyTimeZone));
}
private String SELECT_COLUMNS = "{PREFIX}tl_Company.object_id as id, {PREFIX}tl_Company.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_Company.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_Company.object_TYPE as OBJECT_TYPE, {PREFIX}tl_Company.company_name, {PREFIX}tl_Company.hiring_team_type, {PREFIX}tl_Company.industry, {PREFIX}tl_Company.time_zone, {PREFIX}tl_Company.added_by_user_id, 1 AS commasafe ";
private String SELECT_JOINS = "";
public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
Set<BaseBusinessClass> resultByIDs = fetchByIDs(Collections.singleton (id), allPSets, context, sqlMgr);
if (resultByIDs.isEmpty ())
{
return null;
}
else if (resultByIDs.size () > 1)
{
throw new StorageException ("Multiple results for id:" + id);
}
else
{
return resultByIDs.iterator ().next ();
}
}
public Set<BaseBusinessClass> fetchByIDs(Set<ObjectID> ids, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
Set<BaseBusinessClass> results = new HashSet ();
Set<Long> idsToFetch = new HashSet ();
for (ObjectID id : ids)
{
if (context.containsObject(id)) // Check for cached version
{
BaseBusinessClass objectToReturn = context.getObjectToReplace(id, Company.REFERENCE_Company);
if (objectToReturn instanceof Company)
{
LogMgr.log (CompanyPersistence, LogLevel.TRACE, "Cache hit for id:", id);
results.add (objectToReturn);
}
else
{
throw new StorageException ("Cache collision for id:" + id + " with object " + objectToReturn + "while fetching a Company");
}
}
PersistentSet tl_CompanyPSet = allPSets.getPersistentSet(id, "tl_Company", PersistentSetStatus.FETCHED);
String objectType = null;
// Check for persistent sets already prefetched
if (false ||
!tl_CompanyPSet.containsAttrib("OBJECT_TYPE") || !tl_CompanyPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!tl_CompanyPSet.containsAttrib(Company.FIELD_CompanyName)||
!tl_CompanyPSet.containsAttrib(Company.FIELD_HiringTeamType)||
!tl_CompanyPSet.containsAttrib(Company.FIELD_Industry)||
!tl_CompanyPSet.containsAttrib(Company.FIELD_TimeZone)||
!tl_CompanyPSet.containsAttrib(Company.SINGLEREFERENCE_AddedByUser))
{
// We will need to retrieve it
idsToFetch.add (id.longValue());
}
else
{
LogMgr.log (CompanyPersistence, LogLevel.DEBUG2, "Persistent set preloaded id:", id);
/* Polymorphic */
objectType = (String)(tl_CompanyPSet.getAttrib("OBJECT_TYPE"));
if (context.getReferenceObject (Company.REFERENCE_Company, objectType) != Company.REFERENCE_Company)
{
idsToFetch.add (id.longValue());
}
else
{
Company result = new Company ();
result.setFromPersistentSets(id, allPSets);
context.addRetrievedObject(result);
results.add (result);
}
}
}
if (idsToFetch.size () > 0)
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_Company " +
"WHERE " + SELECT_JOINS + "{PREFIX}tl_Company.object_id IN ?";
BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false);
for (BaseBusinessClass objFetched : resultsFetched)
{
results.add (objFetched);
}
}
return results;
}
public BaseBusinessClass[] getReferencedObjects(ObjectID _objectID, String refName, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
if (false)
{
throw new RuntimeException ();
}
else
{
throw new IllegalArgumentException ("Illegal reference type:" + refName);
}
}
public void update(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{
EqualityResult test = EqualityResult.compare (obj, obj.getBackup ());
ObjectID objectID = obj.getID ();
if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave())
{
PersistentSet tl_CompanyPSet = allPSets.getPersistentSet(objectID, "tl_Company");
if (tl_CompanyPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_CompanyPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}tl_Company " +
"SET company_name = ?, hiring_team_type = ?, industry = ?, time_zone = ?, added_by_user_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE tl_Company.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_CompanyName.getForSQL(dummyCompanyName, tl_CompanyPSet.getAttrib (Company.FIELD_CompanyName))).listEntry (HELPER_HiringTeamType.getForSQL(dummyHiringTeamType, tl_CompanyPSet.getAttrib (Company.FIELD_HiringTeamType))).listEntry (HELPER_Industry.getForSQL(dummyIndustry, tl_CompanyPSet.getAttrib (Company.FIELD_Industry))).listEntry (HELPER_TimeZone.getForSQL(dummyTimeZone, tl_CompanyPSet.getAttrib (Company.FIELD_TimeZone))).listEntry (SQLManager.CheckNull((Long)(tl_CompanyPSet.getAttrib (Company.SINGLEREFERENCE_AddedByUser)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1)
{
// Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr,
"SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}tl_Company WHERE object_id = ?",
new Object[] { objectID.longID () });
if (r.next ())
{
Date d = new java.util.Date (r.getTimestamp (2).getTime());
String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]",
new Object[] { "tl_Company", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ());
LogMgr.log (CompanyPersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "tl_Company");
}
else
{
String errorMsg = "Attempt to update nonexistent row in table:tl_Company for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (CompanyPersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
tl_CompanyPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
else
{
LogMgr.log (CompanyPersistence, LogLevel.DEBUG1, "Skipping update since no attribs or simple assocs changed on ", objectID);
}
}
public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet tl_CompanyPSet = allPSets.getPersistentSet(objectID, "tl_Company");
LogMgr.log (CompanyPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (tl_CompanyPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_CompanyPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsDeleted = executeStatement (sqlMgr,
"DELETE " +
"FROM {PREFIX}tl_Company " +
"WHERE tl_Company.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ",
new Object[] { objectID.longID(), obj.getObjectLastModified () });
if (rowsDeleted != 1)
{
// Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr,
"SELECT object_id FROM {PREFIX}tl_Company WHERE object_id = ?",
new Object[] { objectID.longID() });
if (r.next ())
{
throw new ConcurrentUpdateConflictException (obj, "tl_Company");
}
else
{
String errorMsg = "Attempt to delete nonexistent row in table:tl_Company for row:" + objectID;
LogMgr.log (CompanyPersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
tl_CompanyPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
public ResultSet executeSearchQueryAll (SQLManager sqlMgr) throws SQLException
{
throw new RuntimeException ("NOT implemented: executeSearchQueryAll");
}
public BaseBusinessClass[] loadQuery (PersistentSetCollection allPSets, SQLManager sqlMgr, RDBMSPersistenceContext context, String query, Object[] params, Integer maxRows, boolean truncateExtra) throws SQLException, StorageException
{
LinkedHashMap<ObjectID, Company> results = new LinkedHashMap ();
MultiHashtable<String,ObjectID> needsRefetch = new MultiHashtable ();
ResultSet r = executeQuery (sqlMgr, query, params);
while (r.next())
{
ThreadUtils.checkInterrupted ();
ObjectID objectID = new ObjectID (Company.REFERENCE_Company.getObjectIDSpace (), r.getLong ("id"));
Company resultElement;
if (maxRows != null && !results.containsKey (objectID) && results.size () >= maxRows)
{
if (truncateExtra)
{
break;
}
else
{
throw new SearchRowsExceededException ("Maximum rows exceeded:" + maxRows);
}
}
if (context.containsObject(objectID))
{
BaseBusinessClass cachedElement = context.getObjectToReplace(objectID, Company.REFERENCE_Company);
if (cachedElement instanceof Company)
{
LogMgr.log (CompanyPersistence, LogLevel.TRACE, "Cache hit for id:", objectID);
resultElement = (Company)cachedElement;
}
else
{
throw new StorageException ("Cache collision for id:" + objectID + " with object " + cachedElement + "while fetching a Company");
}
}
else
{
PersistentSet tl_CompanyPSet = allPSets.getPersistentSet(objectID, "tl_Company", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID);
String objectType = (String)(tl_CompanyPSet.getAttrib("OBJECT_TYPE"));
if (context.getReferenceObject (Company.REFERENCE_Company, objectType) != Company.REFERENCE_Company)
{
needsRefetch.add (objectType, objectID); // We will fetch these later
resultElement = new Company ();
resultElement.initialiseGhost (objectID);
}
else
{
resultElement = new Company ();
resultElement.setFromPersistentSets(objectID, allPSets);
context.addRetrievedObject(resultElement);
}
}
results.put (objectID, resultElement);
}
for (String objectType : needsRefetch.keySet())
{
BaseBusinessClass referenceObject = context.getReferenceObject (Company.REFERENCE_Company, objectType);
ObjectPersistenceMgr persistenceMgr = context.getPersistenceMgr (referenceObject);
ResourceCheckpoint checkpoint = sqlMgr.getCheckpoint();
Set<BaseBusinessClass> objsRefetched = persistenceMgr.fetchByIDs(new HashSet (needsRefetch.getValuesForKey (objectType)), allPSets, context, sqlMgr);
checkpoint.releaseNewResources();
for (BaseBusinessClass objRefetched : objsRefetched)
{
results.put (objRefetched.getID (), (Company)objRefetched);
}
}
BaseBusinessClass[] resultsArr = new BaseBusinessClass[results.size ()];
return results.values ().toArray (resultsArr);
}
public BaseBusinessClass[] find(String searchType, PersistentSetCollection allPSets, Hashtable criteria, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
LogMgr.log (CompanyPersistence, LogLevel.DEBUG2, "Search executing:", searchType, " criteria:", criteria);
String customParamFilter = (String)criteria.get (SEARCH_CustomFilter);
String customOrderBy = (String)criteria.get (SEARCH_OrderBy);
String customTables = (String)criteria.get (SEARCH_CustomExtraTables);
Boolean noCommaBeforeCustomExtraTables = (Boolean)criteria.get (SEARCH_CustomExtraTablesNoComma);
if (searchType.equals (SEARCH_CustomSQL))
{
Set<ObjectID> processedIDs = new HashSet();
SearchParamTransform tx = new SearchParamTransform (criteria);
Object[] searchParams;
customParamFilter = StringUtils.replaceParams (customParamFilter, tx);
searchParams = tx.getParamsArray();
if (customOrderBy != null)
{
customOrderBy = " ORDER BY " + customOrderBy;
}
else
{
customOrderBy = "";
}
ResultSet r;
String concatCustomTableWith = CollectionUtils.equals(noCommaBeforeCustomExtraTables, true) ? " " : ", ";
String tables = StringUtils.subBlanks(customTables) == null ? " " : concatCustomTableWith + customTables + " ";
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_Company " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
return results;
}
else if (searchType.equals (Company.SEARCH_All))
{
// Local scope for transformed variables
{
}
String orderBy = " ";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter: tl_company.object_id is not null
String preFilter = "(tl_company.object_id is not null)"
+ " ";
preFilter += context.getLoadingAttributes ().getCustomSQL() ;
SearchParamTransform tx = new SearchParamTransform (criteria);
filter = StringUtils.replaceParams (preFilter, tx);
searchParams = tx.getParamsArray();
Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_Company " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, maxRows, truncateExtra);
return results;
}
else
{
throw new IllegalArgumentException ("Illegal search type:" + searchType);
}
}
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{
PersistentSet tl_CompanyPSet = allPSets.getPersistentSet(objectID, "tl_Company", PersistentSetStatus.FETCHED);
// Object Modified
tl_CompanyPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created
tl_CompanyPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));tl_CompanyPSet.setAttrib("OBJECT_TYPE", r.getString ("OBJECT_TYPE"));
tl_CompanyPSet.setAttrib(Company.FIELD_CompanyName, HELPER_CompanyName.getFromRS(dummyCompanyName, r, "company_name"));
tl_CompanyPSet.setAttrib(Company.FIELD_HiringTeamType, HELPER_HiringTeamType.getFromRS(dummyHiringTeamType, r, "hiring_team_type"));
tl_CompanyPSet.setAttrib(Company.FIELD_Industry, HELPER_Industry.getFromRS(dummyIndustry, r, "industry"));
tl_CompanyPSet.setAttrib(Company.FIELD_TimeZone, HELPER_TimeZone.getFromRS(dummyTimeZone, r, "time_zone"));
tl_CompanyPSet.setAttrib(Company.SINGLEREFERENCE_AddedByUser, r.getObject ("added_by_user_id"));
}
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet tl_CompanyPSet = allPSets.getPersistentSet(objectID, "tl_Company");
if (tl_CompanyPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_CompanyPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
executeStatement (sqlMgr,
"INSERT INTO {PREFIX}tl_Company " +
" (company_name, hiring_team_type, industry, time_zone, added_by_user_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE, object_TYPE) " +
"VALUES " +
" (?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", ?)",
CollectionUtils.listEntry (HELPER_CompanyName.getForSQL(dummyCompanyName, tl_CompanyPSet.getAttrib (Company.FIELD_CompanyName))).listEntry (HELPER_HiringTeamType.getForSQL(dummyHiringTeamType, tl_CompanyPSet.getAttrib (Company.FIELD_HiringTeamType))).listEntry (HELPER_Industry.getForSQL(dummyIndustry, tl_CompanyPSet.getAttrib (Company.FIELD_Industry))).listEntry (HELPER_TimeZone.getForSQL(dummyTimeZone, tl_CompanyPSet.getAttrib (Company.FIELD_TimeZone))) .listEntry (SQLManager.CheckNull((Long)(tl_CompanyPSet.getAttrib (Company.SINGLEREFERENCE_AddedByUser)))) .listEntry (objectID.longID ()).listEntry (context.getTag (obj)).toList().toArray());
tl_CompanyPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
}
package performa.orm;
import oneit.objstore.ObjectTransaction;
import oneit.security.SecUser;
import oneit.utils.CollectionUtils;
import oneit.utils.StringUtils;
import oneit.objstore.*;
import oneit.utils.*;
public class AdminUser extends BaseAdminUser
public class CompanyUser extends BaseCompanyUser
{
private static final long serialVersionUID = 0L;
// This constructor should not be called
public AdminUser ()
public CompanyUser ()
{
// Do not add any code to this, always put it in initialiseNewObject
}
public static AdminUser getAdminUserForForgotPassword(ObjectTransaction transaction, String userIDStr, String code)
public static CompanyUser getCompanyUserForForgotPassword(ObjectTransaction transaction, String userIDStr, String code)
{
userIDStr = StringUtils.subBlanks(userIDStr);
code = StringUtils.subBlanks(code);
if(userIDStr != null && code!=null)
{
AdminUser adminUser = AdminUser.getAdminUserByID(transaction, Long.parseLong(userIDStr));
CompanyUser companyUser = CompanyUser.getCompanyUserByID(transaction, Long.parseLong(userIDStr));
if(adminUser != null && CollectionUtils.equals(adminUser.getForgotPasswordKey(), code))
if(companyUser != null && CollectionUtils.equals(companyUser.getForgotPasswordKey(), code))
{
return adminUser;
return companyUser;
}
}
......
<?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.*"/>
<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" />
<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>
</BUSINESSCLASS>
</ROOT>
\ No newline at end of file
......@@ -15,6 +15,7 @@ import oneit.utils.resource.*;
import oneit.utils.*;
import oneit.utils.threading.*;
import oneit.security.*;
import performa.orm.types.*;
......@@ -22,30 +23,36 @@ import oneit.security.*;
* IMPORTANT!!!! Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2[oneit.objstore.PersistenceMgrTemplate.xsl]
*/
public class AdminUserPersistenceMgr extends SecUserExtensionPersistenceMgr
public class CompanyUserPersistenceMgr extends SecUserExtensionPersistenceMgr
{
private static final LoggingArea AdminUserPersistence = LoggingArea.createLoggingArea(ObjectPersistenceMgr.OBJECT_PERSISTENCE, "AdminUser");
private static final LoggingArea CompanyUserPersistence = LoggingArea.createLoggingArea(ObjectPersistenceMgr.OBJECT_PERSISTENCE, "CompanyUser");
// Private attributes corresponding to business object data
private Date dummyForgotPasswordMailSendDate;
private String dummyForgotPasswordKey;
private RoleType dummyRole;
private String dummyPhone;
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper HELPER_ForgotPasswordMailSendDate = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_ForgotPasswordKey = DefaultAttributeHelper.INSTANCE;
private static final EnumeratedAttributeHelper HELPER_Role = new EnumeratedAttributeHelper (RoleType.FACTORY_RoleType);
private static final DefaultAttributeHelper HELPER_Phone = DefaultAttributeHelper.INSTANCE;
public AdminUserPersistenceMgr ()
public CompanyUserPersistenceMgr ()
{
dummyForgotPasswordMailSendDate = (Date)(HELPER_ForgotPasswordMailSendDate.initialise (dummyForgotPasswordMailSendDate));
dummyForgotPasswordKey = (String)(HELPER_ForgotPasswordKey.initialise (dummyForgotPasswordKey));
dummyRole = (RoleType)(HELPER_Role.initialise (dummyRole));
dummyPhone = (String)(HELPER_Phone.initialise (dummyPhone));
}
private String SELECT_COLUMNS = "{PREFIX}oneit_sec_user_extension.object_id as id, {PREFIX}oneit_sec_user_extension.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}oneit_sec_user_extension.object_CREATED_DATE as CREATED_DATE, {PREFIX}oneit_sec_user_extension.object_TYPE as OBJECT_TYPE, {PREFIX}oneit_sec_user_extension.forgot_password_mail_send_date, {PREFIX}oneit_sec_user_extension.forgot_password_key, {PREFIX}oneit_sec_user_extension.user_id, 1 AS commasafe ";
private String SELECT_COLUMNS = "{PREFIX}oneit_sec_user_extension.object_id as id, {PREFIX}oneit_sec_user_extension.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}oneit_sec_user_extension.object_CREATED_DATE as CREATED_DATE, {PREFIX}oneit_sec_user_extension.object_TYPE as OBJECT_TYPE, {PREFIX}oneit_sec_user_extension.forgot_password_mail_send_date, {PREFIX}oneit_sec_user_extension.forgot_password_key, {PREFIX}oneit_sec_user_extension.role_type, {PREFIX}oneit_sec_user_extension.phone, {PREFIX}oneit_sec_user_extension.user_id, {PREFIX}oneit_sec_user_extension.company_id, 1 AS commasafe ";
private String SELECT_JOINS = "";
public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
......@@ -77,16 +84,16 @@ public class AdminUserPersistenceMgr extends SecUserExtensionPersistenceMgr
{
if (context.containsObject(id)) // Check for cached version
{
BaseBusinessClass objectToReturn = context.getObjectToReplace(id, AdminUser.REFERENCE_AdminUser);
BaseBusinessClass objectToReturn = context.getObjectToReplace(id, CompanyUser.REFERENCE_CompanyUser);
if (objectToReturn instanceof AdminUser)
if (objectToReturn instanceof CompanyUser)
{
LogMgr.log (AdminUserPersistence, LogLevel.TRACE, "Cache hit for id:", id);
LogMgr.log (CompanyUserPersistence, LogLevel.TRACE, "Cache hit for id:", id);
results.add (objectToReturn);
}
else
{
throw new StorageException ("Cache collision for id:" + id + " with object " + objectToReturn + "while fetching a AdminUser");
throw new StorageException ("Cache collision for id:" + id + " with object " + objectToReturn + "while fetching a CompanyUser");
}
}
......@@ -97,27 +104,30 @@ public class AdminUserPersistenceMgr extends SecUserExtensionPersistenceMgr
// Check for persistent sets already prefetched
if (false ||
!oneit_sec_user_extensionPSet.containsAttrib("OBJECT_TYPE") || !oneit_sec_user_extensionPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!oneit_sec_user_extensionPSet.containsAttrib(AdminUser.FIELD_ForgotPasswordMailSendDate)||
!oneit_sec_user_extensionPSet.containsAttrib(AdminUser.FIELD_ForgotPasswordKey)||
!oneit_sec_user_extensionPSet.containsAttrib(AdminUser.SINGLEREFERENCE_User))
!oneit_sec_user_extensionPSet.containsAttrib(CompanyUser.FIELD_ForgotPasswordMailSendDate)||
!oneit_sec_user_extensionPSet.containsAttrib(CompanyUser.FIELD_ForgotPasswordKey)||
!oneit_sec_user_extensionPSet.containsAttrib(CompanyUser.FIELD_Role)||
!oneit_sec_user_extensionPSet.containsAttrib(CompanyUser.FIELD_Phone)||
!oneit_sec_user_extensionPSet.containsAttrib(CompanyUser.SINGLEREFERENCE_User)||
!oneit_sec_user_extensionPSet.containsAttrib(CompanyUser.SINGLEREFERENCE_Company))
{
// We will need to retrieve it
idsToFetch.add (id.longValue());
}
else
{
LogMgr.log (AdminUserPersistence, LogLevel.DEBUG2, "Persistent set preloaded id:", id);
LogMgr.log (CompanyUserPersistence, LogLevel.DEBUG2, "Persistent set preloaded id:", id);
/* Polymorphic */
objectType = (String)(oneit_sec_user_extensionPSet.getAttrib("OBJECT_TYPE"));
if (context.getReferenceObject (AdminUser.REFERENCE_AdminUser, objectType) != AdminUser.REFERENCE_AdminUser)
if (context.getReferenceObject (CompanyUser.REFERENCE_CompanyUser, objectType) != CompanyUser.REFERENCE_CompanyUser)
{
idsToFetch.add (id.longValue());
}
else
{
AdminUser result = new AdminUser ();
CompanyUser result = new CompanyUser ();
result.setFromPersistentSets(id, allPSets);
context.addRetrievedObject(result);
......@@ -154,7 +164,7 @@ public class AdminUserPersistenceMgr extends SecUserExtensionPersistenceMgr
{
throw new RuntimeException ();
}
else if (refName.equals (AdminUser.SINGLEREFERENCE_User))
else if (refName.equals (CompanyUser.SINGLEREFERENCE_User))
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}oneit_sec_user_extension " +
......@@ -164,6 +174,16 @@ public class AdminUserPersistenceMgr extends SecUserExtensionPersistenceMgr
return results;
}
else if (refName.equals (CompanyUser.SINGLEREFERENCE_Company))
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}oneit_sec_user_extension " +
"WHERE " + SELECT_JOINS + "company_id = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
return results;
}
else
{
throw new IllegalArgumentException ("Illegal reference type:" + refName);
......@@ -188,10 +208,10 @@ public class AdminUserPersistenceMgr extends SecUserExtensionPersistenceMgr
{
int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}oneit_sec_user_extension " +
"SET forgot_password_mail_send_date = ?, forgot_password_key = ?, user_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"SET forgot_password_mail_send_date = ?, forgot_password_key = ?, role_type = ?, phone = ?, user_id = ? , company_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE oneit_sec_user_extension.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_ForgotPasswordMailSendDate.getForSQL(dummyForgotPasswordMailSendDate, oneit_sec_user_extensionPSet.getAttrib (AdminUser.FIELD_ForgotPasswordMailSendDate))).listEntry (HELPER_ForgotPasswordKey.getForSQL(dummyForgotPasswordKey, oneit_sec_user_extensionPSet.getAttrib (AdminUser.FIELD_ForgotPasswordKey))).listEntry (SQLManager.CheckNull((Long)(oneit_sec_user_extensionPSet.getAttrib (AdminUser.SINGLEREFERENCE_User)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
CollectionUtils.listEntry (HELPER_ForgotPasswordMailSendDate.getForSQL(dummyForgotPasswordMailSendDate, oneit_sec_user_extensionPSet.getAttrib (CompanyUser.FIELD_ForgotPasswordMailSendDate))).listEntry (HELPER_ForgotPasswordKey.getForSQL(dummyForgotPasswordKey, oneit_sec_user_extensionPSet.getAttrib (CompanyUser.FIELD_ForgotPasswordKey))).listEntry (HELPER_Role.getForSQL(dummyRole, oneit_sec_user_extensionPSet.getAttrib (CompanyUser.FIELD_Role))).listEntry (HELPER_Phone.getForSQL(dummyPhone, oneit_sec_user_extensionPSet.getAttrib (CompanyUser.FIELD_Phone))).listEntry (SQLManager.CheckNull((Long)(oneit_sec_user_extensionPSet.getAttrib (CompanyUser.SINGLEREFERENCE_User)))).listEntry (SQLManager.CheckNull((Long)(oneit_sec_user_extensionPSet.getAttrib (CompanyUser.SINGLEREFERENCE_Company)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1)
{
......@@ -207,14 +227,14 @@ public class AdminUserPersistenceMgr extends SecUserExtensionPersistenceMgr
new Object[] { "oneit_sec_user_extension", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ());
LogMgr.log (AdminUserPersistence, LogLevel.BUSINESS1, errorMsg);
LogMgr.log (CompanyUserPersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "oneit_sec_user_extension");
}
else
{
String errorMsg = "Attempt to update nonexistent row in table:oneit_sec_user_extension for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (AdminUserPersistence, LogLevel.BUSINESS1, errorMsg);
LogMgr.log (CompanyUserPersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
......@@ -225,7 +245,7 @@ public class AdminUserPersistenceMgr extends SecUserExtensionPersistenceMgr
}
else
{
LogMgr.log (AdminUserPersistence, LogLevel.DEBUG1, "Skipping update since no attribs or simple assocs changed on ", objectID);
LogMgr.log (CompanyUserPersistence, LogLevel.DEBUG1, "Skipping update since no attribs or simple assocs changed on ", objectID);
}
}
......@@ -237,7 +257,7 @@ public class AdminUserPersistenceMgr extends SecUserExtensionPersistenceMgr
PersistentSet oneit_sec_user_extensionPSet = allPSets.getPersistentSet(objectID, "oneit_sec_user_extension");
LogMgr.log (AdminUserPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
LogMgr.log (CompanyUserPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (oneit_sec_user_extensionPSet.getStatus () != PersistentSetStatus.PROCESSED &&
......@@ -264,7 +284,7 @@ public class AdminUserPersistenceMgr extends SecUserExtensionPersistenceMgr
{
String errorMsg = "Attempt to delete nonexistent row in table:oneit_sec_user_extension for row:" + objectID;
LogMgr.log (AdminUserPersistence, LogLevel.SYSTEMERROR1, errorMsg);
LogMgr.log (CompanyUserPersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
......@@ -279,17 +299,13 @@ public class AdminUserPersistenceMgr extends SecUserExtensionPersistenceMgr
{
throw new RuntimeException ("NOT implemented: executeSearchQueryAll");
}
public ResultSet executeSearchQueryIdPin (SQLManager sqlMgr, Long ID, String Pin) throws SQLException
{
throw new RuntimeException ("NOT implemented: executeSearchQueryIdPin");
}
public BaseBusinessClass[] loadQuery (PersistentSetCollection allPSets, SQLManager sqlMgr, RDBMSPersistenceContext context, String query, Object[] params, Integer maxRows, boolean truncateExtra) throws SQLException, StorageException
{
LinkedHashMap<ObjectID, AdminUser> results = new LinkedHashMap ();
LinkedHashMap<ObjectID, CompanyUser> results = new LinkedHashMap ();
MultiHashtable<String,ObjectID> needsRefetch = new MultiHashtable ();
......@@ -299,8 +315,8 @@ public class AdminUserPersistenceMgr extends SecUserExtensionPersistenceMgr
{
ThreadUtils.checkInterrupted ();
ObjectID objectID = new ObjectID (AdminUser.REFERENCE_AdminUser.getObjectIDSpace (), r.getLong ("id"));
AdminUser resultElement;
ObjectID objectID = new ObjectID (CompanyUser.REFERENCE_CompanyUser.getObjectIDSpace (), r.getLong ("id"));
CompanyUser resultElement;
if (maxRows != null && !results.containsKey (objectID) && results.size () >= maxRows)
{
......@@ -316,16 +332,16 @@ public class AdminUserPersistenceMgr extends SecUserExtensionPersistenceMgr
if (context.containsObject(objectID))
{
BaseBusinessClass cachedElement = context.getObjectToReplace(objectID, AdminUser.REFERENCE_AdminUser);
BaseBusinessClass cachedElement = context.getObjectToReplace(objectID, CompanyUser.REFERENCE_CompanyUser);
if (cachedElement instanceof AdminUser)
if (cachedElement instanceof CompanyUser)
{
LogMgr.log (AdminUserPersistence, LogLevel.TRACE, "Cache hit for id:", objectID);
resultElement = (AdminUser)cachedElement;
LogMgr.log (CompanyUserPersistence, LogLevel.TRACE, "Cache hit for id:", objectID);
resultElement = (CompanyUser)cachedElement;
}
else
{
throw new StorageException ("Cache collision for id:" + objectID + " with object " + cachedElement + "while fetching a AdminUser");
throw new StorageException ("Cache collision for id:" + objectID + " with object " + cachedElement + "while fetching a CompanyUser");
}
}
else
......@@ -337,17 +353,17 @@ public class AdminUserPersistenceMgr extends SecUserExtensionPersistenceMgr
String objectType = (String)(oneit_sec_user_extensionPSet.getAttrib("OBJECT_TYPE"));
if (context.getReferenceObject (AdminUser.REFERENCE_AdminUser, objectType) != AdminUser.REFERENCE_AdminUser)
if (context.getReferenceObject (CompanyUser.REFERENCE_CompanyUser, objectType) != CompanyUser.REFERENCE_CompanyUser)
{
needsRefetch.add (objectType, objectID); // We will fetch these later
resultElement = new AdminUser ();
resultElement = new CompanyUser ();
resultElement.initialiseGhost (objectID);
}
else
{
resultElement = new AdminUser ();
resultElement = new CompanyUser ();
resultElement.setFromPersistentSets(objectID, allPSets);
context.addRetrievedObject(resultElement);
......@@ -363,7 +379,7 @@ public class AdminUserPersistenceMgr extends SecUserExtensionPersistenceMgr
for (String objectType : needsRefetch.keySet())
{
BaseBusinessClass referenceObject = context.getReferenceObject (AdminUser.REFERENCE_AdminUser, objectType);
BaseBusinessClass referenceObject = context.getReferenceObject (CompanyUser.REFERENCE_CompanyUser, objectType);
ObjectPersistenceMgr persistenceMgr = context.getPersistenceMgr (referenceObject);
ResourceCheckpoint checkpoint = sqlMgr.getCheckpoint();
......@@ -373,7 +389,7 @@ public class AdminUserPersistenceMgr extends SecUserExtensionPersistenceMgr
for (BaseBusinessClass objRefetched : objsRefetched)
{
results.put (objRefetched.getID (), (AdminUser)objRefetched);
results.put (objRefetched.getID (), (CompanyUser)objRefetched);
}
}
......@@ -387,7 +403,7 @@ public class AdminUserPersistenceMgr extends SecUserExtensionPersistenceMgr
public BaseBusinessClass[] find(String searchType, PersistentSetCollection allPSets, Hashtable criteria, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
LogMgr.log (AdminUserPersistence, LogLevel.DEBUG2, "Search executing:", searchType, " criteria:", criteria);
LogMgr.log (CompanyUserPersistence, LogLevel.DEBUG2, "Search executing:", searchType, " criteria:", criteria);
String customParamFilter = (String)criteria.get (SEARCH_CustomFilter);
String customOrderBy = (String)criteria.get (SEARCH_OrderBy);
String customTables = (String)criteria.get (SEARCH_CustomExtraTables);
......@@ -425,7 +441,7 @@ public class AdminUserPersistenceMgr extends SecUserExtensionPersistenceMgr
return results;
}
else if (searchType.equals (AdminUser.SEARCH_All))
else if (searchType.equals (CompanyUser.SEARCH_All))
{
// Local scope for transformed variables
{
......@@ -463,58 +479,6 @@ public class AdminUserPersistenceMgr extends SecUserExtensionPersistenceMgr
return results;
}
else if (searchType.equals (AdminUser.SEARCH_IdPin))
{
// Local scope for transformed variables
{
}
String orderBy = " ";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter: oneit_sec_user_extension.object_id is not null
String preFilter = "(oneit_sec_user_extension.object_id is not null)"
+ " ";
if (criteria.containsKey("ID"))
{
preFilter += " AND (object_id = ${ID} ) ";
preFilter += "";
}
if (criteria.containsKey("Pin"))
{
preFilter += " AND (verification_key = ${Pin}) ";
preFilter += "";
}
preFilter += context.getLoadingAttributes ().getCustomSQL() ;
SearchParamTransform tx = new SearchParamTransform (criteria);
filter = StringUtils.replaceParams (preFilter, tx);
searchParams = tx.getParamsArray();
Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}oneit_sec_user_extension " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, maxRows, truncateExtra);
return results;
}
else
{
......@@ -524,7 +488,7 @@ public class AdminUserPersistenceMgr extends SecUserExtensionPersistenceMgr
for (int x = 0 ; x < resultsArray.length ; ++x)
{
if (resultsArray[x] instanceof AdminUser)
if (resultsArray[x] instanceof CompanyUser)
{
results.add (resultsArray[x]);
}
......@@ -554,10 +518,13 @@ public class AdminUserPersistenceMgr extends SecUserExtensionPersistenceMgr
// Object Created
oneit_sec_user_extensionPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));oneit_sec_user_extensionPSet.setAttrib("OBJECT_TYPE", r.getString ("OBJECT_TYPE"));
oneit_sec_user_extensionPSet.setAttrib(AdminUser.FIELD_ForgotPasswordMailSendDate, HELPER_ForgotPasswordMailSendDate.getFromRS(dummyForgotPasswordMailSendDate, r, "forgot_password_mail_send_date"));
oneit_sec_user_extensionPSet.setAttrib(AdminUser.FIELD_ForgotPasswordKey, HELPER_ForgotPasswordKey.getFromRS(dummyForgotPasswordKey, r, "forgot_password_key"));
oneit_sec_user_extensionPSet.setAttrib(CompanyUser.FIELD_ForgotPasswordMailSendDate, HELPER_ForgotPasswordMailSendDate.getFromRS(dummyForgotPasswordMailSendDate, r, "forgot_password_mail_send_date"));
oneit_sec_user_extensionPSet.setAttrib(CompanyUser.FIELD_ForgotPasswordKey, HELPER_ForgotPasswordKey.getFromRS(dummyForgotPasswordKey, r, "forgot_password_key"));
oneit_sec_user_extensionPSet.setAttrib(CompanyUser.FIELD_Role, HELPER_Role.getFromRS(dummyRole, r, "role_type"));
oneit_sec_user_extensionPSet.setAttrib(CompanyUser.FIELD_Phone, HELPER_Phone.getFromRS(dummyPhone, r, "phone"));
oneit_sec_user_extensionPSet.setAttrib(AdminUser.SINGLEREFERENCE_User, r.getObject ("user_id"));
oneit_sec_user_extensionPSet.setAttrib(CompanyUser.SINGLEREFERENCE_User, r.getObject ("user_id"));
oneit_sec_user_extensionPSet.setAttrib(CompanyUser.SINGLEREFERENCE_Company, r.getObject ("company_id"));
}
......@@ -574,10 +541,10 @@ public class AdminUserPersistenceMgr extends SecUserExtensionPersistenceMgr
{
executeStatement (sqlMgr,
"INSERT INTO {PREFIX}oneit_sec_user_extension " +
" (forgot_password_mail_send_date, forgot_password_key, user_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE, object_TYPE) " +
" (forgot_password_mail_send_date, forgot_password_key, role_type, phone, user_id, company_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE, object_TYPE) " +
"VALUES " +
" (?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", ?)",
CollectionUtils.listEntry (HELPER_ForgotPasswordMailSendDate.getForSQL(dummyForgotPasswordMailSendDate, oneit_sec_user_extensionPSet.getAttrib (AdminUser.FIELD_ForgotPasswordMailSendDate))).listEntry (HELPER_ForgotPasswordKey.getForSQL(dummyForgotPasswordKey, oneit_sec_user_extensionPSet.getAttrib (AdminUser.FIELD_ForgotPasswordKey))) .listEntry (SQLManager.CheckNull((Long)(oneit_sec_user_extensionPSet.getAttrib (AdminUser.SINGLEREFERENCE_User)))) .listEntry (objectID.longID ()).listEntry (context.getTag (obj)).toList().toArray());
" (?, ?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", ?)",
CollectionUtils.listEntry (HELPER_ForgotPasswordMailSendDate.getForSQL(dummyForgotPasswordMailSendDate, oneit_sec_user_extensionPSet.getAttrib (CompanyUser.FIELD_ForgotPasswordMailSendDate))).listEntry (HELPER_ForgotPasswordKey.getForSQL(dummyForgotPasswordKey, oneit_sec_user_extensionPSet.getAttrib (CompanyUser.FIELD_ForgotPasswordKey))).listEntry (HELPER_Role.getForSQL(dummyRole, oneit_sec_user_extensionPSet.getAttrib (CompanyUser.FIELD_Role))).listEntry (HELPER_Phone.getForSQL(dummyPhone, oneit_sec_user_extensionPSet.getAttrib (CompanyUser.FIELD_Phone))) .listEntry (SQLManager.CheckNull((Long)(oneit_sec_user_extensionPSet.getAttrib (CompanyUser.SINGLEREFERENCE_User)))).listEntry (SQLManager.CheckNull((Long)(oneit_sec_user_extensionPSet.getAttrib (CompanyUser.SINGLEREFERENCE_Company)))) .listEntry (objectID.longID ()).listEntry (context.getTag (obj)).toList().toArray());
oneit_sec_user_extensionPSet.setStatus (PersistentSetStatus.PROCESSED);
}
......
......@@ -53,7 +53,11 @@ public class Job extends BaseJob
public void initAttribs() throws BusinessException
{
setRandomKey(RandomStringGen.getRandomStringGen().generateAlphaNum(4));
setSecUser(SecUser.getTXUser(getTransaction()));
//TODO: verify
SecUser txUser = SecUser.getTXUser(getTransaction());
setCompanyUser(txUser.getExtension(CompanyUser.REFERENCE_CompanyUser));
}
......
......@@ -46,9 +46,10 @@
<ATTRIB name="State" type="State" dbcol="state" defaultValue="State.WA" attribHelper="EnumeratedAttributeHelper"/>
<ATTRIB name="Country" type="Countries" dbcol="country" defaultValue="Countries.AU" attribHelper="EnumeratedAttributeHelper"/>
<SINGLEREFERENCE name="Level" type="Level" dbcol="level_id" mandatory="true"/>
<SINGLEREFERENCE name="SecUser" type="SecUser" dbcol="secuser_id" />
<SINGLEREFERENCE name="Level" type="Level" dbcol="level_id" mandatory="true"/>
<SINGLEREFERENCE name="Client" type="Client" dbcol="client_id" />
<SINGLEREFERENCE name="CompanyUser" type="CompanyUser" dbcol="company_user_id" />
</TABLE>
<SEARCH type="All" paramFilter="tl_job.object_id is not null" orderBy="tl_job.object_id" />
......
......@@ -86,7 +86,7 @@ public class JobPersistenceMgr extends ObjectPersistenceMgr
}
private String SELECT_COLUMNS = "{PREFIX}tl_job.object_id as id, {PREFIX}tl_job.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_job.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_job.job_title, {PREFIX}tl_job.job_description, {PREFIX}tl_job.job_status, {PREFIX}tl_job.open_date, {PREFIX}tl_job.apply_by, {PREFIX}tl_job.include_assessment_criteria, {PREFIX}tl_job.assessment_type, {PREFIX}tl_job.random_key, {PREFIX}tl_job.job_type, {PREFIX}tl_job.ref_number, {PREFIX}tl_job.last_status_change_date, {PREFIX}tl_job.remote, {PREFIX}tl_job.city, {PREFIX}tl_job.state, {PREFIX}tl_job.country, {PREFIX}tl_job.level_id, {PREFIX}tl_job.secuser_id, 1 AS commasafe ";
private String SELECT_COLUMNS = "{PREFIX}tl_job.object_id as id, {PREFIX}tl_job.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_job.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_job.job_title, {PREFIX}tl_job.job_description, {PREFIX}tl_job.job_status, {PREFIX}tl_job.open_date, {PREFIX}tl_job.apply_by, {PREFIX}tl_job.include_assessment_criteria, {PREFIX}tl_job.assessment_type, {PREFIX}tl_job.random_key, {PREFIX}tl_job.job_type, {PREFIX}tl_job.ref_number, {PREFIX}tl_job.last_status_change_date, {PREFIX}tl_job.remote, {PREFIX}tl_job.city, {PREFIX}tl_job.state, {PREFIX}tl_job.country, {PREFIX}tl_job.level_id, {PREFIX}tl_job.client_id, {PREFIX}tl_job.company_user_id, 1 AS commasafe ";
private String SELECT_JOINS = "";
public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
......@@ -153,7 +153,8 @@ public class JobPersistenceMgr extends ObjectPersistenceMgr
!tl_jobPSet.containsAttrib(Job.FIELD_State)||
!tl_jobPSet.containsAttrib(Job.FIELD_Country)||
!tl_jobPSet.containsAttrib(Job.SINGLEREFERENCE_Level)||
!tl_jobPSet.containsAttrib(Job.SINGLEREFERENCE_SecUser))
!tl_jobPSet.containsAttrib(Job.SINGLEREFERENCE_Client)||
!tl_jobPSet.containsAttrib(Job.SINGLEREFERENCE_CompanyUser))
{
// We will need to retrieve it
idsToFetch.add (id.longValue());
......@@ -223,10 +224,10 @@ public class JobPersistenceMgr extends ObjectPersistenceMgr
{
int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}tl_job " +
"SET job_title = ?, job_description = ?, job_status = ?, open_date = ?, apply_by = ?, include_assessment_criteria = ?, assessment_type = ?, random_key = ?, job_type = ?, ref_number = ?, last_status_change_date = ?, remote = ?, city = ?, state = ?, country = ?, level_id = ? , secuser_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"SET job_title = ?, job_description = ?, job_status = ?, open_date = ?, apply_by = ?, include_assessment_criteria = ?, assessment_type = ?, random_key = ?, job_type = ?, ref_number = ?, last_status_change_date = ?, remote = ?, city = ?, state = ?, country = ?, level_id = ? , client_id = ? , company_user_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE tl_job.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_JobTitle.getForSQL(dummyJobTitle, tl_jobPSet.getAttrib (Job.FIELD_JobTitle))).listEntry (HELPER_JobDescription.getForSQL(dummyJobDescription, tl_jobPSet.getAttrib (Job.FIELD_JobDescription))).listEntry (HELPER_JobStatus.getForSQL(dummyJobStatus, tl_jobPSet.getAttrib (Job.FIELD_JobStatus))).listEntry (HELPER_OpenDate.getForSQL(dummyOpenDate, tl_jobPSet.getAttrib (Job.FIELD_OpenDate))).listEntry (HELPER_ApplyBy.getForSQL(dummyApplyBy, tl_jobPSet.getAttrib (Job.FIELD_ApplyBy))).listEntry (HELPER_IncludeAssessmentCriteria.getForSQL(dummyIncludeAssessmentCriteria, tl_jobPSet.getAttrib (Job.FIELD_IncludeAssessmentCriteria))).listEntry (HELPER_AssessmentType.getForSQL(dummyAssessmentType, tl_jobPSet.getAttrib (Job.FIELD_AssessmentType))).listEntry (HELPER_RandomKey.getForSQL(dummyRandomKey, tl_jobPSet.getAttrib (Job.FIELD_RandomKey))).listEntry (HELPER_JobType.getForSQL(dummyJobType, tl_jobPSet.getAttrib (Job.FIELD_JobType))).listEntry (HELPER_ReferenceNumber.getForSQL(dummyReferenceNumber, tl_jobPSet.getAttrib (Job.FIELD_ReferenceNumber))).listEntry (HELPER_LastStatusChangeDate.getForSQL(dummyLastStatusChangeDate, tl_jobPSet.getAttrib (Job.FIELD_LastStatusChangeDate))).listEntry (HELPER_Remote.getForSQL(dummyRemote, tl_jobPSet.getAttrib (Job.FIELD_Remote))).listEntry (HELPER_City.getForSQL(dummyCity, tl_jobPSet.getAttrib (Job.FIELD_City))).listEntry (HELPER_State.getForSQL(dummyState, tl_jobPSet.getAttrib (Job.FIELD_State))).listEntry (HELPER_Country.getForSQL(dummyCountry, tl_jobPSet.getAttrib (Job.FIELD_Country))).listEntry (SQLManager.CheckNull((Long)(tl_jobPSet.getAttrib (Job.SINGLEREFERENCE_Level)))).listEntry (SQLManager.CheckNull((Long)(tl_jobPSet.getAttrib (Job.SINGLEREFERENCE_SecUser)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
CollectionUtils.listEntry (HELPER_JobTitle.getForSQL(dummyJobTitle, tl_jobPSet.getAttrib (Job.FIELD_JobTitle))).listEntry (HELPER_JobDescription.getForSQL(dummyJobDescription, tl_jobPSet.getAttrib (Job.FIELD_JobDescription))).listEntry (HELPER_JobStatus.getForSQL(dummyJobStatus, tl_jobPSet.getAttrib (Job.FIELD_JobStatus))).listEntry (HELPER_OpenDate.getForSQL(dummyOpenDate, tl_jobPSet.getAttrib (Job.FIELD_OpenDate))).listEntry (HELPER_ApplyBy.getForSQL(dummyApplyBy, tl_jobPSet.getAttrib (Job.FIELD_ApplyBy))).listEntry (HELPER_IncludeAssessmentCriteria.getForSQL(dummyIncludeAssessmentCriteria, tl_jobPSet.getAttrib (Job.FIELD_IncludeAssessmentCriteria))).listEntry (HELPER_AssessmentType.getForSQL(dummyAssessmentType, tl_jobPSet.getAttrib (Job.FIELD_AssessmentType))).listEntry (HELPER_RandomKey.getForSQL(dummyRandomKey, tl_jobPSet.getAttrib (Job.FIELD_RandomKey))).listEntry (HELPER_JobType.getForSQL(dummyJobType, tl_jobPSet.getAttrib (Job.FIELD_JobType))).listEntry (HELPER_ReferenceNumber.getForSQL(dummyReferenceNumber, tl_jobPSet.getAttrib (Job.FIELD_ReferenceNumber))).listEntry (HELPER_LastStatusChangeDate.getForSQL(dummyLastStatusChangeDate, tl_jobPSet.getAttrib (Job.FIELD_LastStatusChangeDate))).listEntry (HELPER_Remote.getForSQL(dummyRemote, tl_jobPSet.getAttrib (Job.FIELD_Remote))).listEntry (HELPER_City.getForSQL(dummyCity, tl_jobPSet.getAttrib (Job.FIELD_City))).listEntry (HELPER_State.getForSQL(dummyState, tl_jobPSet.getAttrib (Job.FIELD_State))).listEntry (HELPER_Country.getForSQL(dummyCountry, tl_jobPSet.getAttrib (Job.FIELD_Country))).listEntry (SQLManager.CheckNull((Long)(tl_jobPSet.getAttrib (Job.SINGLEREFERENCE_Level)))).listEntry (SQLManager.CheckNull((Long)(tl_jobPSet.getAttrib (Job.SINGLEREFERENCE_Client)))).listEntry (SQLManager.CheckNull((Long)(tl_jobPSet.getAttrib (Job.SINGLEREFERENCE_CompanyUser)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1)
{
......@@ -555,7 +556,8 @@ public class JobPersistenceMgr extends ObjectPersistenceMgr
tl_jobPSet.setAttrib(Job.FIELD_Country, HELPER_Country.getFromRS(dummyCountry, r, "country"));
tl_jobPSet.setAttrib(Job.SINGLEREFERENCE_Level, r.getObject ("level_id"));
tl_jobPSet.setAttrib(Job.SINGLEREFERENCE_SecUser, r.getObject ("secuser_id"));
tl_jobPSet.setAttrib(Job.SINGLEREFERENCE_Client, r.getObject ("client_id"));
tl_jobPSet.setAttrib(Job.SINGLEREFERENCE_CompanyUser, r.getObject ("company_user_id"));
}
......@@ -572,10 +574,10 @@ public class JobPersistenceMgr extends ObjectPersistenceMgr
{
executeStatement (sqlMgr,
"INSERT INTO {PREFIX}tl_job " +
" (job_title, job_description, job_status, open_date, apply_by, include_assessment_criteria, assessment_type, random_key, job_type, ref_number, last_status_change_date, remote, city, state, country, level_id, secuser_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
" (job_title, job_description, job_status, open_date, apply_by, include_assessment_criteria, assessment_type, random_key, job_type, ref_number, last_status_change_date, remote, city, state, country, level_id, client_id, company_user_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " +
" (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_JobTitle.getForSQL(dummyJobTitle, tl_jobPSet.getAttrib (Job.FIELD_JobTitle))).listEntry (HELPER_JobDescription.getForSQL(dummyJobDescription, tl_jobPSet.getAttrib (Job.FIELD_JobDescription))).listEntry (HELPER_JobStatus.getForSQL(dummyJobStatus, tl_jobPSet.getAttrib (Job.FIELD_JobStatus))).listEntry (HELPER_OpenDate.getForSQL(dummyOpenDate, tl_jobPSet.getAttrib (Job.FIELD_OpenDate))).listEntry (HELPER_ApplyBy.getForSQL(dummyApplyBy, tl_jobPSet.getAttrib (Job.FIELD_ApplyBy))).listEntry (HELPER_IncludeAssessmentCriteria.getForSQL(dummyIncludeAssessmentCriteria, tl_jobPSet.getAttrib (Job.FIELD_IncludeAssessmentCriteria))).listEntry (HELPER_AssessmentType.getForSQL(dummyAssessmentType, tl_jobPSet.getAttrib (Job.FIELD_AssessmentType))).listEntry (HELPER_RandomKey.getForSQL(dummyRandomKey, tl_jobPSet.getAttrib (Job.FIELD_RandomKey))).listEntry (HELPER_JobType.getForSQL(dummyJobType, tl_jobPSet.getAttrib (Job.FIELD_JobType))).listEntry (HELPER_ReferenceNumber.getForSQL(dummyReferenceNumber, tl_jobPSet.getAttrib (Job.FIELD_ReferenceNumber))).listEntry (HELPER_LastStatusChangeDate.getForSQL(dummyLastStatusChangeDate, tl_jobPSet.getAttrib (Job.FIELD_LastStatusChangeDate))).listEntry (HELPER_Remote.getForSQL(dummyRemote, tl_jobPSet.getAttrib (Job.FIELD_Remote))).listEntry (HELPER_City.getForSQL(dummyCity, tl_jobPSet.getAttrib (Job.FIELD_City))).listEntry (HELPER_State.getForSQL(dummyState, tl_jobPSet.getAttrib (Job.FIELD_State))).listEntry (HELPER_Country.getForSQL(dummyCountry, tl_jobPSet.getAttrib (Job.FIELD_Country))) .listEntry (SQLManager.CheckNull((Long)(tl_jobPSet.getAttrib (Job.SINGLEREFERENCE_Level)))).listEntry (SQLManager.CheckNull((Long)(tl_jobPSet.getAttrib (Job.SINGLEREFERENCE_SecUser)))) .listEntry (objectID.longID ()).toList().toArray());
" (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_JobTitle.getForSQL(dummyJobTitle, tl_jobPSet.getAttrib (Job.FIELD_JobTitle))).listEntry (HELPER_JobDescription.getForSQL(dummyJobDescription, tl_jobPSet.getAttrib (Job.FIELD_JobDescription))).listEntry (HELPER_JobStatus.getForSQL(dummyJobStatus, tl_jobPSet.getAttrib (Job.FIELD_JobStatus))).listEntry (HELPER_OpenDate.getForSQL(dummyOpenDate, tl_jobPSet.getAttrib (Job.FIELD_OpenDate))).listEntry (HELPER_ApplyBy.getForSQL(dummyApplyBy, tl_jobPSet.getAttrib (Job.FIELD_ApplyBy))).listEntry (HELPER_IncludeAssessmentCriteria.getForSQL(dummyIncludeAssessmentCriteria, tl_jobPSet.getAttrib (Job.FIELD_IncludeAssessmentCriteria))).listEntry (HELPER_AssessmentType.getForSQL(dummyAssessmentType, tl_jobPSet.getAttrib (Job.FIELD_AssessmentType))).listEntry (HELPER_RandomKey.getForSQL(dummyRandomKey, tl_jobPSet.getAttrib (Job.FIELD_RandomKey))).listEntry (HELPER_JobType.getForSQL(dummyJobType, tl_jobPSet.getAttrib (Job.FIELD_JobType))).listEntry (HELPER_ReferenceNumber.getForSQL(dummyReferenceNumber, tl_jobPSet.getAttrib (Job.FIELD_ReferenceNumber))).listEntry (HELPER_LastStatusChangeDate.getForSQL(dummyLastStatusChangeDate, tl_jobPSet.getAttrib (Job.FIELD_LastStatusChangeDate))).listEntry (HELPER_Remote.getForSQL(dummyRemote, tl_jobPSet.getAttrib (Job.FIELD_Remote))).listEntry (HELPER_City.getForSQL(dummyCity, tl_jobPSet.getAttrib (Job.FIELD_City))).listEntry (HELPER_State.getForSQL(dummyState, tl_jobPSet.getAttrib (Job.FIELD_State))).listEntry (HELPER_Country.getForSQL(dummyCountry, tl_jobPSet.getAttrib (Job.FIELD_Country))) .listEntry (SQLManager.CheckNull((Long)(tl_jobPSet.getAttrib (Job.SINGLEREFERENCE_Level)))).listEntry (SQLManager.CheckNull((Long)(tl_jobPSet.getAttrib (Job.SINGLEREFERENCE_Client)))).listEntry (SQLManager.CheckNull((Long)(tl_jobPSet.getAttrib (Job.SINGLEREFERENCE_CompanyUser)))) .listEntry (objectID.longID ()).toList().toArray());
tl_jobPSet.setStatus (PersistentSetStatus.PROCESSED);
}
......
package performa.orm.types;
import java.io.*;
import java.util.*;
import oneit.appservices.config.*;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.utils.*;
import oneit.appservices.dbenums.*;
public class BO_Industry extends BaseBO_Industry
{
private static final long serialVersionUID = 0L;
// This constructor should not be called
public BO_Industry ()
{
// Do not add any code to this, always put it in initialiseNewObject
}
}
package performa.orm.types;
import java.io.*;
import java.util.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.rdbms.*;
import oneit.objstore.utils.*;
import oneit.sql.*;
import oneit.utils.resource.*;
import oneit.utils.*;
import oneit.utils.threading.*;
import oneit.appservices.dbenums.*;
/**
* IMPORTANT!!!! Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2[oneit.objstore.PersistenceMgrTemplate.xsl]
*/
public class BO_IndustryPersistenceMgr extends AbstractEnumeratedBOPersistenceMgr
{
private static final LoggingArea BO_IndustryPersistence = LoggingArea.createLoggingArea(ObjectPersistenceMgr.OBJECT_PERSISTENCE, "BO_Industry");
// Private attributes corresponding to business object data
private String dummyName;
private String dummyValue;
private String dummyDescription;
private long dummySortOrder;
private boolean dummyDisabled;
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper HELPER_Name = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_Value = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_Description = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_SortOrder = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_Disabled = DefaultAttributeHelper.INSTANCE;
public BO_IndustryPersistenceMgr ()
{
dummyName = (String)(HELPER_Name.initialise (dummyName));
dummyValue = (String)(HELPER_Value.initialise (dummyValue));
dummyDescription = (String)(HELPER_Description.initialise (dummyDescription));
dummySortOrder = (long)(HELPER_SortOrder.initialise (dummySortOrder));
dummyDisabled = (boolean)(HELPER_Disabled.initialise (dummyDisabled));
}
private String SELECT_COLUMNS = "{PREFIX}tl_industry.Object_id as id, {PREFIX}tl_industry.Object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_industry.Object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_industry.NAME, {PREFIX}tl_industry.VALUE, {PREFIX}tl_industry.DESCRIPTION, {PREFIX}tl_industry.SORT_ORDER, {PREFIX}tl_industry.DISABLED, 1 AS commasafe ";
private String SELECT_JOINS = "";
public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
Set<BaseBusinessClass> resultByIDs = fetchByIDs(Collections.singleton (id), allPSets, context, sqlMgr);
if (resultByIDs.isEmpty ())
{
return null;
}
else if (resultByIDs.size () > 1)
{
throw new StorageException ("Multiple results for id:" + id);
}
else
{
return resultByIDs.iterator ().next ();
}
}
public Set<BaseBusinessClass> fetchByIDs(Set<ObjectID> ids, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
Set<BaseBusinessClass> results = new HashSet ();
Set<Long> idsToFetch = new HashSet ();
for (ObjectID id : ids)
{
if (context.containsObject(id)) // Check for cached version
{
BaseBusinessClass objectToReturn = context.getObjectToReplace(id, BO_Industry.REFERENCE_BO_Industry);
if (objectToReturn instanceof BO_Industry)
{
LogMgr.log (BO_IndustryPersistence, LogLevel.TRACE, "Cache hit for id:", id);
results.add (objectToReturn);
}
else
{
throw new StorageException ("Cache collision for id:" + id + " with object " + objectToReturn + "while fetching a BO_Industry");
}
}
PersistentSet tl_industryPSet = allPSets.getPersistentSet(id, "tl_industry", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched
if (false || !tl_industryPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!tl_industryPSet.containsAttrib(BO_Industry.FIELD_Name)||
!tl_industryPSet.containsAttrib(BO_Industry.FIELD_Value)||
!tl_industryPSet.containsAttrib(BO_Industry.FIELD_Description)||
!tl_industryPSet.containsAttrib(BO_Industry.FIELD_SortOrder)||
!tl_industryPSet.containsAttrib(BO_Industry.FIELD_Disabled))
{
// We will need to retrieve it
idsToFetch.add (id.longValue());
}
else
{
LogMgr.log (BO_IndustryPersistence, LogLevel.DEBUG2, "Persistent set preloaded id:", id);
/* Non Polymorphic */
BO_Industry result = new BO_Industry ();
result.setFromPersistentSets(id, allPSets);
context.addRetrievedObject(result);
results.add (result);
}
}
if (idsToFetch.size () > 0)
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_industry " +
"WHERE " + SELECT_JOINS + "{PREFIX}tl_industry.Object_id IN ?";
BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false);
for (BaseBusinessClass objFetched : resultsFetched)
{
results.add (objFetched);
}
}
return results;
}
public BaseBusinessClass[] getReferencedObjects(ObjectID _objectID, String refName, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
if (false)
{
throw new RuntimeException ();
}
else
{
throw new IllegalArgumentException ("Illegal reference type:" + refName);
}
}
public void update(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{
EqualityResult test = EqualityResult.compare (obj, obj.getBackup ());
ObjectID objectID = obj.getID ();
if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave())
{
PersistentSet tl_industryPSet = allPSets.getPersistentSet(objectID, "tl_industry");
if (tl_industryPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_industryPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}tl_industry " +
"SET NAME = ?, VALUE = ?, DESCRIPTION = ?, SORT_ORDER = ?, DISABLED = ? , Object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE tl_industry.Object_id = ? AND " + getConcurrencyCheck (sqlMgr, "Object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_Name.getForSQL(dummyName, tl_industryPSet.getAttrib (BO_Industry.FIELD_Name))).listEntry (HELPER_Value.getForSQL(dummyValue, tl_industryPSet.getAttrib (BO_Industry.FIELD_Value))).listEntry (HELPER_Description.getForSQL(dummyDescription, tl_industryPSet.getAttrib (BO_Industry.FIELD_Description))).listEntry (HELPER_SortOrder.getForSQL(dummySortOrder, tl_industryPSet.getAttrib (BO_Industry.FIELD_SortOrder))).listEntry (HELPER_Disabled.getForSQL(dummyDisabled, tl_industryPSet.getAttrib (BO_Industry.FIELD_Disabled))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1)
{
// Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr,
"SELECT Object_id, Object_LAST_UPDATED_DATE FROM {PREFIX}tl_industry WHERE Object_id = ?",
new Object[] { objectID.longID () });
if (r.next ())
{
Date d = new java.util.Date (r.getTimestamp (2).getTime());
String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]",
new Object[] { "tl_industry", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ());
LogMgr.log (BO_IndustryPersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "tl_industry");
}
else
{
String errorMsg = "Attempt to update nonexistent row in table:tl_industry for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (BO_IndustryPersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
tl_industryPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
else
{
LogMgr.log (BO_IndustryPersistence, LogLevel.DEBUG1, "Skipping update since no attribs or simple assocs changed on ", objectID);
}
}
public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet tl_industryPSet = allPSets.getPersistentSet(objectID, "tl_industry");
LogMgr.log (BO_IndustryPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (tl_industryPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_industryPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsDeleted = executeStatement (sqlMgr,
"DELETE " +
"FROM {PREFIX}tl_industry " +
"WHERE tl_industry.Object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("Object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ",
new Object[] { objectID.longID(), obj.getObjectLastModified () });
if (rowsDeleted != 1)
{
// Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr,
"SELECT Object_id FROM {PREFIX}tl_industry WHERE Object_id = ?",
new Object[] { objectID.longID() });
if (r.next ())
{
throw new ConcurrentUpdateConflictException (obj, "tl_industry");
}
else
{
String errorMsg = "Attempt to delete nonexistent row in table:tl_industry for row:" + objectID;
LogMgr.log (BO_IndustryPersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
tl_industryPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
public ResultSet executeSearchQueryALL (SQLManager sqlMgr) throws SQLException
{
throw new RuntimeException ("NOT implemented: executeSearchQueryALL");
}
public ResultSet executeSearchQueryBY_NAME (SQLManager sqlMgr, String name) throws SQLException
{
throw new RuntimeException ("NOT implemented: executeSearchQueryBY_NAME");
}
public ResultSet executeSearchQueryBY_VALUE (SQLManager sqlMgr, String value) throws SQLException
{
throw new RuntimeException ("NOT implemented: executeSearchQueryBY_VALUE");
}
public BaseBusinessClass[] loadQuery (PersistentSetCollection allPSets, SQLManager sqlMgr, RDBMSPersistenceContext context, String query, Object[] params, Integer maxRows, boolean truncateExtra) throws SQLException, StorageException
{
LinkedHashMap<ObjectID, BO_Industry> results = new LinkedHashMap ();
ResultSet r = executeQuery (sqlMgr, query, params);
while (r.next())
{
ThreadUtils.checkInterrupted ();
ObjectID objectID = new ObjectID (BO_Industry.REFERENCE_BO_Industry.getObjectIDSpace (), r.getLong ("id"));
BO_Industry resultElement;
if (maxRows != null && !results.containsKey (objectID) && results.size () >= maxRows)
{
if (truncateExtra)
{
break;
}
else
{
throw new SearchRowsExceededException ("Maximum rows exceeded:" + maxRows);
}
}
if (context.containsObject(objectID))
{
BaseBusinessClass cachedElement = context.getObjectToReplace(objectID, BO_Industry.REFERENCE_BO_Industry);
if (cachedElement instanceof BO_Industry)
{
LogMgr.log (BO_IndustryPersistence, LogLevel.TRACE, "Cache hit for id:", objectID);
resultElement = (BO_Industry)cachedElement;
}
else
{
throw new StorageException ("Cache collision for id:" + objectID + " with object " + cachedElement + "while fetching a BO_Industry");
}
}
else
{
PersistentSet tl_industryPSet = allPSets.getPersistentSet(objectID, "tl_industry", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID);
resultElement = new BO_Industry ();
resultElement.setFromPersistentSets(objectID, allPSets);
context.addRetrievedObject(resultElement);
}
results.put (objectID, resultElement);
}
BaseBusinessClass[] resultsArr = new BaseBusinessClass[results.size ()];
return results.values ().toArray (resultsArr);
}
public BaseBusinessClass[] find(String searchType, PersistentSetCollection allPSets, Hashtable criteria, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
LogMgr.log (BO_IndustryPersistence, LogLevel.DEBUG2, "Search executing:", searchType, " criteria:", criteria);
String customParamFilter = (String)criteria.get (SEARCH_CustomFilter);
String customOrderBy = (String)criteria.get (SEARCH_OrderBy);
String customTables = (String)criteria.get (SEARCH_CustomExtraTables);
Boolean noCommaBeforeCustomExtraTables = (Boolean)criteria.get (SEARCH_CustomExtraTablesNoComma);
if (searchType.equals (SEARCH_CustomSQL))
{
Set<ObjectID> processedIDs = new HashSet();
SearchParamTransform tx = new SearchParamTransform (criteria);
Object[] searchParams;
customParamFilter = StringUtils.replaceParams (customParamFilter, tx);
searchParams = tx.getParamsArray();
if (customOrderBy != null)
{
customOrderBy = " ORDER BY " + customOrderBy;
}
else
{
customOrderBy = "";
}
ResultSet r;
String concatCustomTableWith = CollectionUtils.equals(noCommaBeforeCustomExtraTables, true) ? " " : ", ";
String tables = StringUtils.subBlanks(customTables) == null ? " " : concatCustomTableWith + customTables + " ";
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_industry " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
return results;
}
else if (searchType.equals (BO_Industry.SEARCH_ALL))
{
// Local scope for transformed variables
{
}
String orderBy = " ";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter:
filter = "object_id IS NOT NULL"
+ " ";
searchParams = new Object[] { };
Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_industry " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, maxRows, truncateExtra);
return results;
}
else if (searchType.equals (BO_Industry.SEARCH_BY_NAME))
{
// Local scope for transformed variables
{
}
String orderBy = " ";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter:
filter = "NAME = ?"
+ " ";
searchParams = new Object[] { criteria.get ("name") };
Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_industry " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, maxRows, truncateExtra);
return results;
}
else if (searchType.equals (BO_Industry.SEARCH_BY_VALUE))
{
// Local scope for transformed variables
{
}
String orderBy = " ";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter:
filter = "VALUE = ?"
+ " ";
searchParams = new Object[] { criteria.get ("value") };
Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_industry " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, maxRows, truncateExtra);
return results;
}
else
{
BaseBusinessClass[] resultsArray = super.find(searchType, allPSets, criteria, context, sqlMgr);
Vector results = new Vector ();
for (int x = 0 ; x < resultsArray.length ; ++x)
{
if (resultsArray[x] instanceof BO_Industry)
{
results.add (resultsArray[x]);
}
else
{
// Ignore
}
}
resultsArray = new BaseBusinessClass[results.size ()];
results.copyInto (resultsArray);
return resultsArray;
}
}
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{
PersistentSet tl_industryPSet = allPSets.getPersistentSet(objectID, "tl_industry", PersistentSetStatus.FETCHED);
// Object Modified
tl_industryPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created
tl_industryPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
tl_industryPSet.setAttrib(BO_Industry.FIELD_Name, HELPER_Name.getFromRS(dummyName, r, "NAME"));
tl_industryPSet.setAttrib(BO_Industry.FIELD_Value, HELPER_Value.getFromRS(dummyValue, r, "VALUE"));
tl_industryPSet.setAttrib(BO_Industry.FIELD_Description, HELPER_Description.getFromRS(dummyDescription, r, "DESCRIPTION"));
tl_industryPSet.setAttrib(BO_Industry.FIELD_SortOrder, HELPER_SortOrder.getFromRS(dummySortOrder, r, "SORT_ORDER"));
tl_industryPSet.setAttrib(BO_Industry.FIELD_Disabled, HELPER_Disabled.getFromRS(dummyDisabled, r, "DISABLED"));
}
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet tl_industryPSet = allPSets.getPersistentSet(objectID, "tl_industry");
if (tl_industryPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_industryPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
executeStatement (sqlMgr,
"INSERT INTO {PREFIX}tl_industry " +
" (NAME, VALUE, DESCRIPTION, SORT_ORDER, DISABLED, Object_id, Object_LAST_UPDATED_DATE, Object_CREATED_DATE) " +
"VALUES " +
" (?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_Name.getForSQL(dummyName, tl_industryPSet.getAttrib (BO_Industry.FIELD_Name))).listEntry (HELPER_Value.getForSQL(dummyValue, tl_industryPSet.getAttrib (BO_Industry.FIELD_Value))).listEntry (HELPER_Description.getForSQL(dummyDescription, tl_industryPSet.getAttrib (BO_Industry.FIELD_Description))).listEntry (HELPER_SortOrder.getForSQL(dummySortOrder, tl_industryPSet.getAttrib (BO_Industry.FIELD_SortOrder))).listEntry (HELPER_Disabled.getForSQL(dummyDisabled, tl_industryPSet.getAttrib (BO_Industry.FIELD_Disabled))) .listEntry (objectID.longID ()).toList().toArray());
tl_industryPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
}
/*
* IMPORTANT!!!! XSL Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2 rev3 [oneit.objstore.BusinessObjectTemplate.xsl]
*
* Version: 1.0
* Vendor: Apache Software Foundation (Xalan XSLTC)
* Vendor URL: http://xml.apache.org/xalan-j
*/
package performa.orm.types;
import java.io.*;
import java.util.*;
import oneit.appservices.config.*;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.attributes.*;
import oneit.objstore.rdbms.filters.*;
import oneit.objstore.parser.*;
import oneit.objstore.validator.*;
import oneit.objstore.utils.*;
import oneit.utils.*;
import oneit.utils.filter.Filter;
import oneit.utils.transform.*;
import oneit.utils.parsers.FieldException;
import oneit.appservices.dbenums.*;
public abstract class BaseBO_Industry extends AbstractEnumeratedBO
{
// Reference instance for the object
public static final BO_Industry REFERENCE_BO_Industry = new BO_Industry ();
// Reference instance for the object
public static final BO_Industry DUMMY_BO_Industry = new DummyBO_Industry ();
// Static constants corresponding to field names
public static final String FIELD_Disabled = "Disabled";
// Static constants corresponding to searches
public static final String SEARCH_ALL = "ALL";
public static final String SEARCH_BY_NAME = "BY_NAME";
public static final String SEARCH_BY_VALUE = "BY_VALUE";
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper<BO_Industry> HELPER_Disabled = DefaultAttributeHelper.INSTANCE;
// Private attributes corresponding to business object data
private boolean _Disabled;
// Private attributes corresponding to single references
// Private attributes corresponding to multiple references
// Map of maps of metadata
private static final Map ATTRIBUTES_METADATA_BO_Industry = new HashMap ();
// Arrays of validators for each attribute
private static final AttributeValidator[] FIELD_Disabled_Validators;
// Arrays of behaviour decorators
private static final BO_IndustryBehaviourDecorator[] BO_Industry_BehaviourDecorators;
static
{
try
{
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
FIELD_Disabled_Validators = (AttributeValidator[])setupAttribMetaData_Disabled(validatorMapping).toArray (new AttributeValidator[0]);
REFERENCE_BO_Industry.initialiseReference ();
DUMMY_BO_Industry.initialiseReference ();
BO_Industry_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(BO_Industry.class).toArray(new BO_IndustryBehaviourDecorator[0]);
}
catch (RuntimeException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
throw e;
}
}
// Meta Info setup
private static List setupAttribMetaData_Disabled(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "DISABLED");
metaInfo.put ("name", "Disabled");
metaInfo.put ("type", "boolean");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for BO_Industry.Disabled:", metaInfo);
ATTRIBUTES_METADATA_BO_Industry.put (FIELD_Disabled, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(BO_Industry.class, "Disabled", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for BO_Industry.Disabled:", validators);
return validators;
}
// END OF STATIC METADATA DEFINITION
// This constructor should not be called
protected BaseBO_Industry ()
{
}
protected BBCBehaviourDecorator[] getBehaviours()
{
return BO_Industry_BehaviourDecorators;
}
// Initialise the attributes
protected void _initialiseNewObjAttributes (ObjectTransaction transaction) throws StorageException
{
super._initialiseNewObjAttributes (transaction);
_Disabled = (boolean)(HELPER_Disabled.initialise (_Disabled));
}
// Initialise the associations
protected void _initialiseAssociations ()
{
super._initialiseAssociations ();
}
// Initialise the associations
protected BaseBusinessClass initialiseReference ()
{
super.initialiseReference ();
return this;
}
/**
* Get the attribute Disabled
*/
public boolean getDisabled ()
{
assertValid();
boolean valToReturn = _Disabled;
for (BO_IndustryBehaviourDecorator bhd : BO_Industry_BehaviourDecorators)
{
valToReturn = bhd.getDisabled ((BO_Industry)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preDisabledChange (boolean newDisabled) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postDisabledChange () throws FieldException
{
}
public FieldWriteability getWriteability_Disabled ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute Disabled. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setDisabled (boolean newDisabled) throws FieldException
{
boolean oldAndNewIdentical = HELPER_Disabled.compare (_Disabled, newDisabled);
try
{
for (BO_IndustryBehaviourDecorator bhd : BO_Industry_BehaviourDecorators)
{
newDisabled = bhd.setDisabled ((BO_Industry)this, newDisabled);
oldAndNewIdentical = HELPER_Disabled.compare (_Disabled, newDisabled);
}
if (FIELD_Disabled_Validators.length > 0)
{
Object newDisabledObj = HELPER_Disabled.toObject (newDisabled);
if (newDisabledObj != null)
{
int loopMax = FIELD_Disabled_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_BO_Industry.get (FIELD_Disabled);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_Disabled_Validators[v].checkAttribute (this, FIELD_Disabled, metadata, newDisabledObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_Disabled () != FieldWriteability.FALSE, "Field Disabled is not writeable");
preDisabledChange (newDisabled);
markFieldChange (FIELD_Disabled);
_Disabled = newDisabled;
postFieldChange (FIELD_Disabled);
postDisabledChange ();
}
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getSingleAssocs()
{
List result = super.getSingleAssocs ();
return result;
}
public BaseBusinessClass getSingleAssocReferenceInstance (String assocName)
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else
{
return super.getSingleAssocReferenceInstance (assocName);
}
}
public String getSingleAssocBackReference(String assocName)
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else
{
return super.getSingleAssocBackReference (assocName);
}
}
public BaseBusinessClass getSingleAssoc (String assocName) throws StorageException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else
{
return super.getSingleAssoc (assocName);
}
}
public BaseBusinessClass getSingleAssoc (String assocName, Get getType) throws StorageException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else
{
return super.getSingleAssoc (assocName, getType);
}
}
public Long getSingleAssocID (String assocName) throws StorageException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else
{
return super.getSingleAssocID (assocName);
}
}
public void setSingleAssoc (String assocName, BaseBusinessClass newValue) throws StorageException, FieldException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else
{
super.setSingleAssoc (assocName, newValue);
}
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getMultiAssocs()
{
List result = super.getMultiAssocs ();
return result;
}
/**
* Get the reference instance for the multi assoc name.
*/
public BaseBusinessClass getMultiAssocReferenceInstance(String attribName)
{
return super.getMultiAssocReferenceInstance(attribName);
}
public String getMultiAssocBackReference(String attribName)
{
return super.getMultiAssocBackReference(attribName);
}
/**
* Get the assoc count for the multi assoc name.
*/
public int getMultiAssocCount(String attribName) throws StorageException
{
return super.getMultiAssocCount(attribName);
}
/**
* Get the assoc at a particular index
*/
public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException
{
return super.getMultiAssocAt(attribName, index);
}
/**
* Add to a multi assoc by attribute name
*/
public void addToMultiAssoc(String attribName, BaseBusinessClass newElement) throws StorageException
{
super.addToMultiAssoc(attribName, newElement);
}
/**
* Remove from a multi assoc by attribute name
*/
public void removeFromMultiAssoc(String attribName, BaseBusinessClass oldElement) throws StorageException
{
super.removeFromMultiAssoc(attribName, oldElement);
}
protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements)
{
super.__loadMultiAssoc(attribName, elements);
}
protected boolean __isMultiAssocLoaded (String attribName)
{
return super.__isMultiAssocLoaded(attribName);
}
public void onDelete ()
{
try
{
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
super.onDelete ();
}
public BO_Industry newInstance ()
{
return new BO_Industry ();
}
public BO_Industry referenceInstance ()
{
return REFERENCE_BO_Industry;
}
public BO_Industry getInTransaction (ObjectTransaction t) throws StorageException
{
return getBO_IndustryByID (t, getObjectID());
}
public BaseBusinessClass dummyInstance ()
{
return DUMMY_BO_Industry;
}
public String getBaseSetName ()
{
return "tl_industry";
}
/**
* This is where an object returns the Persistent sets that will
* store it into the database.
* The should be entered into allSets
*/
public void getPersistentSets (PersistentSetCollection allSets)
{
ObjectStatus myStatus = getStatus ();
PersistentSetStatus myPSetStatus = myStatus.getPSetStatus();
ObjectID myID = getID();
super.getPersistentSets (allSets);
PersistentSet tl_industryPSet = allSets.getPersistentSet (myID, "tl_industry", myPSetStatus);
tl_industryPSet.setAttrib (FIELD_ObjectID, myID);
tl_industryPSet.setAttrib (FIELD_Disabled, HELPER_Disabled.toObject (_Disabled)); //
}
/**
* Sets the objects state based on Persistent sets.
*/
public void setFromPersistentSets (ObjectID objectID, PersistentSetCollection allSets)
{
super.setFromPersistentSets (objectID, allSets);
PersistentSet tl_industryPSet = allSets.getPersistentSet (objectID, "tl_industry");
_Disabled = (boolean)(HELPER_Disabled.fromObject (_Disabled, tl_industryPSet.getAttrib (FIELD_Disabled))); //
}
public void setAttributesFrom (BaseBusinessClass other, MultiException e)
{
super.setAttributesFrom (other, e);
if (other instanceof BO_Industry)
{
BO_Industry otherBO_Industry = (BO_Industry)other;
try
{
setDisabled (otherBO_Industry.getDisabled ());
}
catch (FieldException ex)
{
e.addException (ex);
}
}
}
/**
* Set the attributes in this to copies of the attributes in source.
*/
public void copyAttributesFrom (BaseBusinessClass source)
{
super.copyAttributesFrom (source);
if (source instanceof BaseBO_Industry)
{
BaseBO_Industry sourceBO_Industry = (BaseBO_Industry)(source);
_Disabled = sourceBO_Industry._Disabled;
}
}
/**
* Set the associations in this to copies of the attributes in source.
*/
public void copySingleAssociationsFrom (BaseBusinessClass source, boolean linkToGhosts)
{
super.copySingleAssociationsFrom (source, linkToGhosts);
if (source instanceof BaseBO_Industry)
{
BaseBO_Industry sourceBO_Industry = (BaseBO_Industry)(source);
}
}
/**
* Set the associations in this to copies of the attributes in source.
*/
public void copyAssociationsFrom (BaseBusinessClass source, boolean linkToGhosts)
{
super.copyAssociationsFrom (source, linkToGhosts);
if (source instanceof BaseBO_Industry)
{
BaseBO_Industry sourceBO_Industry = (BaseBO_Industry)(source);
}
}
public void validate (ValidationContext context)
{
super.validate (context);
}
/**
* Subclasses must override this to read in their attributes
*/
protected void readExternalData(Map<String, Object> vals) throws IOException, ClassNotFoundException
{
super.readExternalData(vals);
_Disabled = (boolean)(HELPER_Disabled.readExternal (_Disabled, vals.get(FIELD_Disabled))); //
}
/**
* Subclasses must override this to write out their attributes
*/
protected void writeExternalData(Map<String, Object> vals) throws IOException
{
super.writeExternalData(vals);
vals.put (FIELD_Disabled, HELPER_Disabled.writeExternal (_Disabled));
}
public void compare (BaseBusinessClass other, AttributeChangeListener listener) throws StorageException
{
super.compare (other, listener);
if (other instanceof BaseBO_Industry)
{
BaseBO_Industry otherBO_Industry = (BaseBO_Industry)(other);
if (!HELPER_Disabled.compare(this._Disabled, otherBO_Industry._Disabled))
{
listener.notifyFieldChange(this, other, FIELD_Disabled, HELPER_Disabled.toObject(this._Disabled), HELPER_Disabled.toObject(otherBO_Industry._Disabled));
}
// Compare single assocs
// Compare multiple assocs
}
}
public void visitTransients (AttributeVisitor visitor) throws StorageException
{
super.visitAttributes (visitor);
}
public void visitAttributes (AttributeVisitor visitor) throws StorageException
{
super.visitAttributes (visitor);
visitor.visitField(this, FIELD_Disabled, HELPER_Disabled.toObject(getDisabled()));
}
public void visitAssociations (AssociationVisitor visitor, AssociatedScope scope) throws StorageException
{
super.visitAssociations (visitor, scope);
}
public static BO_Industry createBO_Industry (ObjectTransaction transaction) throws StorageException
{
BO_Industry result = new BO_Industry ();
result.initialiseNewObject (transaction);
return result;
}
public static BO_Industry getBO_IndustryByID (ObjectTransaction transaction, Long objectID) throws StorageException
{
return (BO_Industry)(transaction.getObjectByID (REFERENCE_BO_Industry, objectID));
}
public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Disabled))
{
return filter.matches (getDisabled ());
}
else
{
return super.testFilter (attribName, filter);
}
}
public static SearchALL SearchByALL () { return new SearchALL (); }
public static class SearchALL extends SearchObject<BO_Industry>
{
public BO_Industry[]
search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_BO_Industry, SEARCH_ALL, criteria);
Set<BO_Industry> typedResults = new LinkedHashSet <BO_Industry> ();
for (BaseBusinessClass bbcResult : results)
{
BO_Industry aResult = (BO_Industry)bbcResult;
typedResults.add (aResult);
}
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new BO_Industry[0]);
}
}
public static BO_Industry[]
searchALL (ObjectTransaction transaction) throws StorageException
{
return SearchByALL ()
.search (transaction);
}
public static SearchBY_NAME SearchByBY_NAME () { return new SearchBY_NAME (); }
public static class SearchBY_NAME extends SearchObject<BO_Industry>
{
public SearchBY_NAME byName (String name)
{
by ("name", name);
return this;
}
public BO_Industry[]
search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_BO_Industry, SEARCH_BY_NAME, criteria);
Set<BO_Industry> typedResults = new LinkedHashSet <BO_Industry> ();
for (BaseBusinessClass bbcResult : results)
{
BO_Industry aResult = (BO_Industry)bbcResult;
typedResults.add (aResult);
}
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new BO_Industry[0]);
}
}
public static BO_Industry[]
searchBY_NAME (ObjectTransaction transaction, String name) throws StorageException
{
return SearchByBY_NAME ()
.byName (name)
.search (transaction);
}
public static SearchBY_VALUE SearchByBY_VALUE () { return new SearchBY_VALUE (); }
public static class SearchBY_VALUE extends SearchObject<BO_Industry>
{
public SearchBY_VALUE byValue (String value)
{
by ("value", value);
return this;
}
public BO_Industry[]
search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_BO_Industry, SEARCH_BY_VALUE, criteria);
Set<BO_Industry> typedResults = new LinkedHashSet <BO_Industry> ();
for (BaseBusinessClass bbcResult : results)
{
BO_Industry aResult = (BO_Industry)bbcResult;
typedResults.add (aResult);
}
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new BO_Industry[0]);
}
}
public static BO_Industry[]
searchBY_VALUE (ObjectTransaction transaction, String value) throws StorageException
{
return SearchByBY_VALUE ()
.byValue (value)
.search (transaction);
}
public Object getAttribute (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Disabled))
{
return HELPER_Disabled.toObject (getDisabled ());
}
else
{
return super.getAttribute (attribName);
}
}
public AttributeHelper getAttributeHelper (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Disabled))
{
return HELPER_Disabled;
}
else
{
return super.getAttributeHelper (attribName);
}
}
public void setAttribute (String attribName, Object attribValue) throws FieldException
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Disabled))
{
setDisabled ((boolean)(HELPER_Disabled.fromObject (_Disabled, attribValue)));
}
else
{
super.setAttribute (attribName, attribValue);
}
}
public boolean isWriteable (String fieldName)
{
return getWriteable (fieldName) == FieldWriteability.TRUE;
}
public FieldWriteability getWriteable (String fieldName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (fieldName.equals (FIELD_Disabled))
{
return getWriteability_Disabled ();
}
else
{
return super.getWriteable (fieldName);
}
}
public void putUnwriteable (Set<String> fields)
{
if (getWriteability_Disabled () != FieldWriteability.TRUE)
{
fields.add (FIELD_Disabled);
}
super.putUnwriteable (fields);
}
public List<AbstractAttribute> getAttributes ()
{
List result = super.getAttributes ();
result.add(HELPER_Disabled.getAttribObject (getClass (), _Disabled, false, FIELD_Disabled));
return result;
}
public Map getAttributeMetadata (String attribute)
{
if (ATTRIBUTES_METADATA_BO_Industry.containsKey (attribute))
{
return (Map)ATTRIBUTES_METADATA_BO_Industry.get (attribute);
}
else
{
return super.getAttributeMetadata (attribute);
}
}
public Object getAttributeMetadata (String attribute, String metadata)
{
if (ATTRIBUTES_METADATA_BO_Industry.containsKey (attribute))
{
return ((Map)ATTRIBUTES_METADATA_BO_Industry.get (attribute)).get(metadata);
}
else
{
return super.getAttributeMetadata (attribute, metadata);
}
}
public void preCommit (boolean willBeStored) throws Exception
{
super.preCommit(willBeStored);
if(willBeStored)
{
}
}
public oneit.servlets.objstore.binary.BinaryContentHandler getBinaryContentHandler(String attribName)
{
return super.getBinaryContentHandler(attribName);
}
public static class BO_IndustryBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<BO_Industry>
{
/**
* Get the attribute Disabled
*/
public boolean getDisabled (BO_Industry obj, boolean original)
{
return original;
}
/**
* Change the value set for attribute Disabled.
* May modify the field beforehand
* Occurs before validation.
*/
public boolean setDisabled (BO_Industry obj, boolean newDisabled) throws FieldException
{
return newDisabled;
}
}
public ORMPipeLine pipes()
{
return new BO_IndustryPipeLineFactory<BO_Industry, BO_Industry> ((BO_Industry)this);
}
/**
* Use this instead of pipes() to get rid of type casting.
*/
public BO_IndustryPipeLineFactory<BO_Industry, BO_Industry> pipelineBO_Industry()
{
return (BO_IndustryPipeLineFactory<BO_Industry, BO_Industry>) pipes();
}
public static BO_IndustryPipeLineFactory<BO_Industry, BO_Industry> pipesBO_Industry(Collection<BO_Industry> items)
{
return REFERENCE_BO_Industry.new BO_IndustryPipeLineFactory<BO_Industry, BO_Industry> (items);
}
public static BO_IndustryPipeLineFactory<BO_Industry, BO_Industry> pipesBO_Industry(BO_Industry[] _items)
{
return pipesBO_Industry(Arrays.asList (_items));
}
public static BO_IndustryPipeLineFactory<BO_Industry, BO_Industry> pipesBO_Industry()
{
return pipesBO_Industry((Collection)null);
}
public class BO_IndustryPipeLineFactory<From extends BaseBusinessClass, Me extends BO_Industry> extends AbstractEnumeratedBOPipeLineFactory<From, Me>
{
public <Prev> BO_IndustryPipeLineFactory (PipeLine<From, Prev> pipeLine, Pipe<Prev, Me> nextPipe)
{
super (pipeLine, nextPipe);
}
public BO_IndustryPipeLineFactory (From seed)
{
super(seed);
}
public BO_IndustryPipeLineFactory (Collection<From> seed)
{
super(seed);
}
public PipeLine<From, ? extends Object> to(String name)
{
if (name.equals ("Disabled"))
{
return toDisabled ();
}
return super.to(name);
}
public PipeLine<From, Boolean> toDisabled () { return pipe(new ORMAttributePipe<Me, Boolean>(FIELD_Disabled)); }
}
public boolean isTransientAttrib(String attribName)
{
return super.isTransientAttrib(attribName);
}
public boolean isTransientSingleReference(String assocName)
{
return super.isTransientSingleReference(assocName);
}
}
class DummyBO_Industry extends BO_Industry
{
// Default constructor primarily to support Externalisable
public DummyBO_Industry()
{
super();
}
public void assertValid ()
{
}
}
package performa.orm.types;
import java.util.*;
import oneit.utils.*;
/**
* This class was generated using constGen.bat.
* DO NOT MODIFY THIS CODE.
* Edit the associated .xml file, and regenerate this file
* constGen (directory) (file minus extension)
* e.g. constGen C:\...\sql FieldType
*/
public class HiringTeamType extends AbstractEnumerated
{
public static final EnumeratedFactory FACTORY_HiringTeamType = new HiringTeamTypeFactory();
public static final HiringTeamType T1 = new HiringTeamType ("T1", "T1", "T1", false);
private static final HiringTeamType[] allHiringTeamTypes =
new HiringTeamType[] { T1};
private static HiringTeamType[] getAllHiringTeamTypes ()
{
return allHiringTeamTypes;
}
private HiringTeamType (String name, String value, String description, boolean disabled)
{
super (name, value, description, disabled);
}
public static final Comparator COMPARE_BY_POSITION = new CompareEnumByPosition (allHiringTeamTypes);
static
{
defineAdditionalData ();
}
public boolean isEqual (HiringTeamType other)
{
return this.name.equals (other.name);
}
public Enumeration getAllInstances ()
{
return HiringTeamType.getAll ();
}
private Object readResolve() throws java.io.ObjectStreamException
{
return HiringTeamType.forName (this.name);
}
public EnumeratedFactory getFactory ()
{
return FACTORY_HiringTeamType;
}
public static HiringTeamType forName (String name)
{
if (name == null) { return null; }
HiringTeamType[] all = getAllHiringTeamTypes();
int enumIndex = AbstractEnumerated.getIndexForName (all, name);
return all[enumIndex];
}
public static HiringTeamType forValue (String value)
{
if (value == null) { return null; }
HiringTeamType[] all = getAllHiringTeamTypes();
int enumIndex = AbstractEnumerated.getIndexForValue (getAllHiringTeamTypes (), value);
return all[enumIndex];
}
public static java.util.Enumeration getAll ()
{
return AbstractEnumerated.getAll (getAllHiringTeamTypes());
}
public static HiringTeamType[] getHiringTeamTypeArray ()
{
return (HiringTeamType[])getAllHiringTeamTypes().clone ();
}
public static void defineAdditionalData ()
{
}
static class HiringTeamTypeFactory implements EnumeratedFactory
{
public AbstractEnumerated getForName (String name)
{
return HiringTeamType.forName (name);
}
public AbstractEnumerated getForValue (String name)
{
return HiringTeamType.forValue (name);
}
public Enumeration getAll ()
{
return HiringTeamType.getAll ();
}
}
public Map getAdditionalAttributes ()
{
Map attribs = new HashMap ();
return attribs;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<CONSTANT package="performa.orm.types" name="HiringTeamType">
<VALUE name="T1" value="T1" description="T1"/>
</CONSTANT>
</ROOT>
\ No newline at end of file
package performa.orm.types;
import java.util.*;
import oneit.utils.*;
import oneit.appservices.dbenums.*;
/**
* This class was generated using constGen.bat.
* DO NOT MODIFY THIS CODE.
* Edit the associated .xml file, and regenerate this file
* constGen (directory) (file minus extension)
* e.g. constGen C:\...\sql FieldType
*/
public class Industry extends oneit.appservices.dbenums.AbstractEnumeratedDBConstant
{
public static final EnumeratedFactory FACTORY_Industry = new IndustryFactory();
public static final oneit.logging.LoggingArea LOG_Industry = oneit.logging.LoggingArea.createLoggingArea(DB_ENUM, "Industry");
private static Industry[] allIndustrys;
private static boolean isStaticDBEnum = false;
private static boolean reloadRegistered = false;
private static boolean reloadRequired = false;
public static boolean isMaintainable()
{
return !isStaticDBEnum;
}
public static boolean isReloadable()
{
return true;
}
public static void reloadOnNextGet()
{
reloadRequired = true;
}
public static String getReloadCheckTable()
{
return "tl_industry";
}
private static synchronized Industry[] getAllIndustrys ()
{
if (allIndustrys == null)
{
// look in general config for a static override
oneit.appservices.dbenums.DBEnumStaticOptions staticOverride = (oneit.appservices.dbenums.DBEnumStaticOptions)oneit.appservices.config.ConfigMgr.getConfigObject("CONFIG.GLOBAL", "DBEnumStaticOverride:performa.orm.types.Industry", null);
if(staticOverride != null)
{
// if there are items in the DB, email a SYSTEMERROR, since this is likely to cause major confusion/or is a sign of an error condition
oneit.objstore.ObjectTransaction transaction = getTransaction ();
BO_Industry[] boInstances;
try
{
boInstances = BO_Industry.searchALL (transaction);
if(boInstances.length > 0)
{
oneit.logging.LogMgr.log (LOG_Industry, oneit.logging.LogLevel.BUSINESS1, "DB Enumerated Type performa.orm.types.Industry conflict: Either delete entries in tl_industry database table or remove the entries for performa.orm.types.Industry from CONFIG.GLOBAL:DBEnumStaticOverrides");
}
}
// allow the situation when the table does not even exist
catch(Exception e)
{
oneit.logging.LogMgr.log (LOG_Industry, oneit.logging.LogLevel.TRACE, e, "DB Enumerated Type performa.orm.types.Industry, could not load values from DB table. This is not a problem, since the enum is loading from config.");
}
finally
{
transaction.releaseResources();
}
// Load the static items.
allIndustrys = new Industry[staticOverride.getLength()];
oneit.objstore.BaseBusinessClass referenceObj = BO_Industry.REFERENCE_BO_Industry;
for(int staticIndex=0; staticIndex < staticOverride.getLength(); staticIndex++)
{
String name = staticOverride.getName(staticIndex);
String value = staticOverride.getValue(staticIndex);
String description = staticOverride.getDescription(staticIndex);
boolean disabled = staticOverride.getDisabled(staticIndex);
allIndustrys[staticIndex] = new Industry(name, value, description, disabled);
allIndustrys[staticIndex].SortOrder = staticOverride.getPrimitiveLong(referenceObj, "SortOrder", staticIndex, 0);
}
// set a flag so we can determine that this DBEnum has been loaded statically
// this should be used to disable access to screens which manipulate the BO.
isStaticDBEnum = true;
}
else
{
if(isReloadable() && !reloadRegistered)
{
DBEnumReloader.getDBEnumReloader().registerDBEnum(Industry.class);
reloadRegistered = true;
}
allIndustrys = loadFromDatabase();
}
}
else if(reloadRequired)
{
reloadRequired = false;
reloadFromDatabase();
}
return allIndustrys;
}
private static Industry[] loadFromDatabase()
{
Industry[] newIndustrys = new Industry[0];
oneit.objstore.ObjectTransaction transaction = getTransaction ();
BO_Industry[] boInstances;
try
{
oneit.logging.LogMgr.log (LOG_Industry, oneit.logging.LogLevel.DEBUG1, "Staring search to populate instances");
boInstances = BO_Industry.searchALL (transaction);
oneit.logging.LogMgr.log (LOG_Industry, oneit.logging.LogLevel.DEBUG1, "Instances returned:", new Integer (boInstances.length));
newIndustrys = new Industry[boInstances.length];
for (int boIndex = 0 ; boIndex < boInstances.length ; ++boIndex)
{
BO_Industry bo = boInstances[boIndex];
boolean disabled = bo.getDisabled ();
newIndustrys[boIndex] = new Industry (bo.getName (), bo.getValue (), bo.getDescription (), disabled);
newIndustrys[boIndex].SortOrder = bo.getSortOrder(); //
}
java.util.Arrays.sort (newIndustrys);
transaction.commit();
transaction.commitResources();
return newIndustrys;
}
catch (Exception e)
{
throw new oneit.utils.NestedException (e);
}
finally
{
transaction.releaseResources();
}
}
private static void reloadFromDatabase()
{
if(!isReloadable())
{
return;
}
// get the existing ones in a map, by value
Industry[] reloadedItems = loadFromDatabase();
Map existingItemsByValue = CollectionUtils.group(allIndustrys,
new ObjectTransform[] {AbstractEnumerated.TRANSFORM_TO_VALUE},
new Comparator[] { null},
CollectionUtils.GROUP_DONT_COMPARE_CHILDREN);
List newItemsList = new ArrayList();
for(int i=0; i < reloadedItems.length; i++)
{
List oldVerionList = (List)existingItemsByValue.remove(reloadedItems[i].getValue());
Industry oldVersion = (oldVerionList == null || oldVerionList.isEmpty()) ? null : (Industry)oldVerionList.iterator().next();
if(oldVersion != null)
{
oldVersion.disabled = reloadedItems[i].disabled;
oldVersion.description = reloadedItems[i].description;
oldVersion.SortOrder = reloadedItems[i].SortOrder;
newItemsList.add(oldVersion);
}
else
{
newItemsList.add(reloadedItems[i]);
}
}
// add any old ones which have not been covered
// There should not be any, since deletion is not allowed
// but we need to make sure...
for(Iterator it=existingItemsByValue.entrySet().iterator(); it.hasNext(); )
{
newItemsList.add(it.next());
}
allIndustrys = (Industry[])newItemsList.toArray(new Industry[0]);
oneit.logging.LogMgr.log(LOG_Industry, oneit.logging.LogLevel.PROCESSING1, "Completed Reload for Industry");
}
public BO_Industry getIndustryBO (oneit.objstore.ObjectTransaction objTran)
{
BO_Industry[] theBOs = BO_Industry.searchBY_VALUE (objTran, getValue());
if (theBOs.length >= 1)
{
return theBOs[0];
}
else
{
throw new IllegalArgumentException ("No such Industry value:" + getValue ());
}
}
private transient long SortOrder;
private Industry (String name, String value, String description, boolean disabled)
{
super (name, value, description, disabled);
}
public long getSortOrder()
{
return SortOrder;
}
public static final Comparator COMPARE_BY_POSITION = new CompareEnumByPosition (allIndustrys);
static
{
defineAdditionalData ();
}
public boolean isEqual (Industry other)
{
return this.name.equals (other.name);
}
public Enumeration getAllInstances ()
{
return Industry.getAll ();
}
private Object readResolve() throws java.io.ObjectStreamException
{
return Industry.forName (this.name);
}
public EnumeratedFactory getFactory ()
{
return FACTORY_Industry;
}
public static Industry forName (String name)
{
if (name == null) { return null; }
Industry[] all = getAllIndustrys();
int enumIndex = AbstractEnumerated.getIndexForName (all, name);
return all[enumIndex];
}
public static Industry forValue (String value)
{
if (value == null) { return null; }
Industry[] all = getAllIndustrys();
int enumIndex = AbstractEnumerated.getIndexForValue (getAllIndustrys (), value);
return all[enumIndex];
}
public static java.util.Enumeration getAll ()
{
return AbstractEnumerated.getAll (getAllIndustrys());
}
public static Industry[] getIndustryArray ()
{
return (Industry[])getAllIndustrys().clone ();
}
public static void defineAdditionalData ()
{
}
static class IndustryFactory implements EnumeratedFactory
{
public AbstractEnumerated getForName (String name)
{
return Industry.forName (name);
}
public AbstractEnumerated getForValue (String name)
{
return Industry.forValue (name);
}
public Enumeration getAll ()
{
return Industry.getAll ();
}
}
public Map getAdditionalAttributes ()
{
Map attribs = new HashMap ();
attribs.put ("SortOrder", ArrayFormatter.toObject(getSortOrder()));
return attribs;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<DB_ENUM name="Industry" package="performa.orm.types" table="tl_industry" supportsDisabled="true" reloadable="true">
</DB_ENUM>
</ROOT>
package performa.orm.types;
import java.util.*;
import oneit.utils.*;
/**
* This class was generated using constGen.bat.
* DO NOT MODIFY THIS CODE.
* Edit the associated .xml file, and regenerate this file
* constGen (directory) (file minus extension)
* e.g. constGen C:\...\sql FieldType
*/
public class RoleType extends AbstractEnumerated
{
public static final EnumeratedFactory FACTORY_RoleType = new RoleTypeFactory();
public static final RoleType ADMIN = new RoleType ("ADMIN", "ADMIN", "Admin", false);
public static final RoleType STANDARD = new RoleType ("STANDARD", "STANDARD", "Standard", false);
private static final RoleType[] allRoleTypes =
new RoleType[] { ADMIN,STANDARD};
private static RoleType[] getAllRoleTypes ()
{
return allRoleTypes;
}
private RoleType (String name, String value, String description, boolean disabled)
{
super (name, value, description, disabled);
}
public static final Comparator COMPARE_BY_POSITION = new CompareEnumByPosition (allRoleTypes);
static
{
defineAdditionalData ();
}
public boolean isEqual (RoleType other)
{
return this.name.equals (other.name);
}
public Enumeration getAllInstances ()
{
return RoleType.getAll ();
}
private Object readResolve() throws java.io.ObjectStreamException
{
return RoleType.forName (this.name);
}
public EnumeratedFactory getFactory ()
{
return FACTORY_RoleType;
}
public static RoleType forName (String name)
{
if (name == null) { return null; }
RoleType[] all = getAllRoleTypes();
int enumIndex = AbstractEnumerated.getIndexForName (all, name);
return all[enumIndex];
}
public static RoleType forValue (String value)
{
if (value == null) { return null; }
RoleType[] all = getAllRoleTypes();
int enumIndex = AbstractEnumerated.getIndexForValue (getAllRoleTypes (), value);
return all[enumIndex];
}
public static java.util.Enumeration getAll ()
{
return AbstractEnumerated.getAll (getAllRoleTypes());
}
public static RoleType[] getRoleTypeArray ()
{
return (RoleType[])getAllRoleTypes().clone ();
}
public static void defineAdditionalData ()
{
}
static class RoleTypeFactory implements EnumeratedFactory
{
public AbstractEnumerated getForName (String name)
{
return RoleType.forName (name);
}
public AbstractEnumerated getForValue (String name)
{
return RoleType.forValue (name);
}
public Enumeration getAll ()
{
return RoleType.getAll ();
}
}
public Map getAdditionalAttributes ()
{
Map attribs = new HashMap ();
return attribs;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<CONSTANT package="performa.orm.types" name="RoleType">
<VALUE name="ADMIN" value="ADMIN" description="Admin"/>
<VALUE name="STANDARD" value="STANDARD" description="Standard"/>
</CONSTANT>
</ROOT>
\ No newline at end of file
package performa.orm.types;
import java.util.*;
import oneit.utils.*;
/**
* This class was generated using constGen.bat.
* DO NOT MODIFY THIS CODE.
* Edit the associated .xml file, and regenerate this file
* constGen (directory) (file minus extension)
* e.g. constGen C:\...\sql FieldType
*/
public class TimeZone extends AbstractEnumerated
{
public static final EnumeratedFactory FACTORY_TimeZone = new TimeZoneFactory();
public static final TimeZone T1 = new TimeZone ("T1", "T1", "T1", false);
private static final TimeZone[] allTimeZones =
new TimeZone[] { T1};
private static TimeZone[] getAllTimeZones ()
{
return allTimeZones;
}
private TimeZone (String name, String value, String description, boolean disabled)
{
super (name, value, description, disabled);
}
public static final Comparator COMPARE_BY_POSITION = new CompareEnumByPosition (allTimeZones);
static
{
defineAdditionalData ();
}
public boolean isEqual (TimeZone other)
{
return this.name.equals (other.name);
}
public Enumeration getAllInstances ()
{
return TimeZone.getAll ();
}
private Object readResolve() throws java.io.ObjectStreamException
{
return TimeZone.forName (this.name);
}
public EnumeratedFactory getFactory ()
{
return FACTORY_TimeZone;
}
public static TimeZone forName (String name)
{
if (name == null) { return null; }
TimeZone[] all = getAllTimeZones();
int enumIndex = AbstractEnumerated.getIndexForName (all, name);
return all[enumIndex];
}
public static TimeZone forValue (String value)
{
if (value == null) { return null; }
TimeZone[] all = getAllTimeZones();
int enumIndex = AbstractEnumerated.getIndexForValue (getAllTimeZones (), value);
return all[enumIndex];
}
public static java.util.Enumeration getAll ()
{
return AbstractEnumerated.getAll (getAllTimeZones());
}
public static TimeZone[] getTimeZoneArray ()
{
return (TimeZone[])getAllTimeZones().clone ();
}
public static void defineAdditionalData ()
{
}
static class TimeZoneFactory implements EnumeratedFactory
{
public AbstractEnumerated getForName (String name)
{
return TimeZone.forName (name);
}
public AbstractEnumerated getForValue (String name)
{
return TimeZone.forValue (name);
}
public Enumeration getAll ()
{
return TimeZone.getAll ();
}
}
public Map getAdditionalAttributes ()
{
Map attribs = new HashMap ();
return attribs;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<CONSTANT package="performa.orm.types" name="TimeZone">
<VALUE name="T1" value="T1" description="T1"/>
</CONSTANT>
</ROOT>
\ No newline at end of file
......@@ -25,7 +25,7 @@
</oneit:button>
</div>
<div class="off-name">
<span class="austr-post">Australia Post</span> by <oneit:toString value="<%= SecUserToNameTransform.INSTANCE.transform(job.getSecUser()) %>" mode="EscapeHTML"/><span class="ex-management">&bull;&nbsp;
<span class="austr-post">Australia Post</span> by <oneit:toString value="<%= job.getCompanyUser() %>" mode="EscapeHTML" nullValue=""/><span class="ex-management">&bull;&nbsp;
<oneit:toString value="<%= job.getLevel() %>" mode="EscapeHTML" />
</span>
</div>
......
......@@ -46,7 +46,8 @@
<div class="form-page-area">
<div class="create-job">
<%
Job[] jobs = Job.SearchByAll().andSecUser(new EqualsFilter<>(SecUser.getTXUser(transaction))).search(transaction);
SecUser txUser = SecUser.getTXUser(process.getTransaction());
Job[] jobs = Job.SearchByAll().andCompanyUser(new EqualsFilter<>(txUser.getExtension(CompanyUser.REFERENCE_CompanyUser))).search(transaction);
if(jobs.length > 0)
{
......
......@@ -28,8 +28,10 @@
if(jobs==null)
{
SecUser txUser = SecUser.getTXUser(objTran);
jobs = Job.SearchByAll().andJobStatus(new EqualsFilter<>(jobStatus))
.andSecUser(new EqualsFilter(SecUser.getTXUser(transaction)))
.andCompanyUser(new EqualsFilter<>(txUser.getExtension(CompanyUser.REFERENCE_CompanyUser)))
.search(transaction);
process.setAttribute(jobListName, jobs);
......
......@@ -9,7 +9,7 @@
//TODO: filter with Client;
SecUser secUser = SecUser.getTXUser(transaction);
Job[] jobs = Job.SearchByAll().andJobStatus(new EqualsFilter<>(JobStatus.OPEN))
.andSecUser(new EqualsFilter(secUser))
.andCompanyUser(new EqualsFilter(secUser.getExtension(CompanyUser.REFERENCE_CompanyUser)))
.search(transaction);
Article jobsArticle = WebUtils.getArticleByShortCut(transaction, WebUtils.JOBS);
......@@ -68,7 +68,7 @@
<div class="dash-count c-gray">
<%
Job[] filledJobs = Job.SearchByAll().andJobStatus(new EqualsFilter<>(JobStatus.FILLED))
.andSecUser(new EqualsFilter(SecUser.getTXUser(transaction)))
.andCompanyUser(new EqualsFilter<>(secUser.getExtension(CompanyUser.REFERENCE_CompanyUser)))
.search(transaction);
int filledCount = filledJobs != null ? filledJobs.length : 0;
......
......@@ -8,7 +8,7 @@
<%
ORMProcessState process = (ORMProcessState)ProcessDecorator.getDefaultProcess(request);
String adminUserID = (String) process.getAttribute("adminUserID"); //request.getParameter("id");
String companyUserID = (String) process.getAttribute("companyUserID"); //request.getParameter("id");
String forgotpasswordCode = (String) process.getAttribute("forgotpasswordCode"); //request.getParameter("key");
SecUser user = (SecUser) process.getAttribute("SecUser");
Article home = WebUtils.getArticleByShortCut(process.getTransaction(), WebUtils.ADMIN_HOME);
......@@ -16,8 +16,8 @@
if(request.getParameter("id")!=null)
{
adminUserID = request.getParameter("id");
process.setAttribute("adminUserID", adminUserID);
companyUserID = request.getParameter("id");
process.setAttribute("companyUserID", companyUserID);
}
if(request.getParameter("key")!=null)
......@@ -26,13 +26,13 @@
process.setAttribute("forgotpasswordCode", forgotpasswordCode);
}
if(StringUtils.subBlanks(adminUserID) != null)
if(StringUtils.subBlanks(companyUserID) != null)
{
AdminUser adminUser = AdminUser.getAdminUserForForgotPassword(process.getTransaction(), adminUserID, forgotpasswordCode);
CompanyUser companyUser = CompanyUser.getCompanyUserForForgotPassword(process.getTransaction(), companyUserID, forgotpasswordCode);
if(adminUser != null)
if(companyUser != null)
{
user = adminUser.getUser();
user = companyUser.getUser();
// if(StringUtils.subBlanks(forgotpasswordCode) != null)
// {
......
......@@ -17,7 +17,7 @@
<MAP code="TestInput" class="performa.orm.TestInput"/>
<MAP code="JobApplication" class="performa.orm.JobApplication"/>
<MAP code="Candidate" class="performa.orm.Candidate"/>
<MAP code="AdminUser" class="performa.orm.AdminUser"/>
<MAP code="CompanyUser" class="performa.orm.CompanyUser"/>
</NODE>
</OBJECTS>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au">
<NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.RedefineTableOperation">
<tableName factory="String">tl_job</tableName>
<column name="client_id" type="Long" length="11" nullable="true"/>
<column name="company_user_id" type="Long" length="11" nullable="true"/>
</NODE>
</NODE>
</OBJECTS>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au">
<NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.RedefineTableOperation">
<tableName factory="String">oneit_sec_user_extension</tableName>
<column name="role_type" type="String" nullable="true" length="200"/>
<column name="company_id" type="Long" length="11" nullable="true"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="oneit_sec_user_extension" indexName="idx_oneit_sec_user_extension_company_id" isUnique="false">
<column name="company_id"/>
</NODE>
</NODE>
</OBJECTS>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">tl_client</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="object_type" type="String" nullable="false" length="30"/>
<column name="company_name" type="String" nullable="false" length="100"/>
<column name="company_logo" type="BLOB" nullable="true"/>
<column name="email" type="String" nullable="true" length="100"/>
<column name="contact_name" type="String" nullable="true" length="100"/>
<column name="contact_surname" type="String" nullable="true" length="100"/>
<column name="phone" type="String" nullable="true" length="30"/>
<column name="state" type="String" nullable="true" length="200"/>
<column name="country" type="String" nullable="true" length="200"/>
<column name="post_code" type="String" nullable="true" length="10"/>
<column name="company_id" type="Long" length="11" nullable="true"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_client" indexName="idx_tl_client_company_id" isUnique="false"><column name="company_id"/></NODE>
</NODE></OBJECTS>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">tl_company</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="object_type" type="String" nullable="false" length="30"/>
<column name="company_name" type="String" nullable="false" length="100"/>
<column name="hiring_team_type" type="String" nullable="true" length="200"/>
<column name="industry" type="String" nullable="true" length="200"/>
<column name="time_zone" type="String" nullable="true" length="200"/>
<column name="added_by_user_id" type="Long" length="11" nullable="false"/>
</NODE>
</NODE></OBJECTS>
\ No newline at end of file
-- @AutoRun
UPDATE oneit_sec_user_extension SET object_type='CompanyUser' WHERE object_type='AdminUser';
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment