Commit 50eaff10 by Nilu

J007 adding short url to share. creating short url for existing jobs via a batch

parent 10d141aa
......@@ -26,6 +26,7 @@
<column name="level_id" type="Long" length="11" nullable="false"/>
<column name="client_id" type="Long" length="11" nullable="true"/>
<column name="company_user_id" type="Long" length="11" nullable="true"/>
<column name="shortened_url_id" type="Long" length="11" nullable="true"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_job" indexName="idx_tl_job_client_id" isUnique="false"><column name="client_id"/></NODE>
......
<?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_shortened_url</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="code" type="String" nullable="false" length="8"/>
<column name="url_link" type="CLOB" nullable="false"/>
</NODE>
</NODE></OBJECTS>
\ No newline at end of file
......@@ -25,7 +25,8 @@ CREATE TABLE tl_job (
country varchar(200) NULL,
level_id numeric(12) NOT NULL,
client_id numeric(12) NULL,
company_user_id numeric(12) NULL
company_user_id numeric(12) NULL,
shortened_url_id numeric(12) NULL
);
......
-- DROP TABLE tl_shortened_url;
CREATE TABLE tl_shortened_url (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
code varchar(8) NOT NULL,
url_link text NOT NULL
);
ALTER TABLE tl_shortened_url ADD
CONSTRAINT PK_tl_shortened_url PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
......@@ -26,7 +26,8 @@ CREATE TABLE tl_job (
country varchar2(200) NULL,
level_id number(12) NOT NULL,
client_id number(12) NULL,
company_user_id number(12) NULL
company_user_id number(12) NULL,
shortened_url_id number(12) NULL
);
......
-- DROP TABLE tl_shortened_url;
CREATE TABLE tl_shortened_url (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
code varchar2(8) NOT NULL,
url_link clob NOT NULL
);
ALTER TABLE tl_shortened_url ADD
CONSTRAINT PK_tl_shortened_url PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
......@@ -26,7 +26,8 @@ CREATE TABLE tl_job (
country varchar(200) NULL,
level_id numeric(12) NOT NULL,
client_id numeric(12) NULL,
company_user_id numeric(12) NULL
company_user_id numeric(12) NULL,
shortened_url_id numeric(12) NULL
);
......
-- @AutoRun
-- drop table tl_shortened_url;
CREATE TABLE tl_shortened_url (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
code varchar(8) NOT NULL,
url_link text NOT NULL
);
ALTER TABLE tl_shortened_url ADD
CONSTRAINT pk_tl_shortened_url PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
package performa.batch;
import oneit.appservices.batch.ORMBatch;
import oneit.logging.LogLevel;
import oneit.logging.LogMgr;
import oneit.logging.LoggingArea;
import oneit.objstore.ObjectTransaction;
import oneit.objstore.StorageException;
import oneit.objstore.rdbms.filters.IsNullFilter;
import oneit.utils.parsers.FieldException;
import performa.orm.Job;
public class URLShortnerBatch extends ORMBatch
{
public static LoggingArea URL_SHORTNER_BATCH = LoggingArea.createLoggingArea("URLShortnerBatch");
@Override
public void run(ObjectTransaction ot) throws StorageException, FieldException
{
LogMgr.log (URL_SHORTNER_BATCH, LogLevel.DEBUG2, "RUNNING URL Shortner Batch");
Job[] jobs = Job.SearchByAll()
.andShortenedURL(new IsNullFilter<>())
.search(ot);
for (Job job : jobs)
{
job.createShortenedURL();
LogMgr.log(URL_SHORTNER_BATCH, LogLevel.DEBUG2, "Setting Shortned URL to job : ", job);
}
}
}
\ No newline at end of file
......@@ -14,6 +14,7 @@ import oneit.servlets.process.SaveFP;
import oneit.utils.BusinessException;
import oneit.utils.DateDiff;
import performa.orm.Job;
import performa.orm.ShortenedURL;
import performa.orm.types.JobStatus;
......@@ -29,12 +30,17 @@ public class SaveJobFP extends SaveFP
Job oldJob = (Job) job.getEarliestBackup();
if(oldJob != null && oldJob.getJobStatus() == JobStatus.DRAFT)
if(oldJob != null && oldJob.getJobStatus() == JobStatus.DRAFT && job.getJobStatus() == JobStatus.OPEN)
{
job.setJobStatus(JobStatus.OPEN);
job.setApplyBy(DateDiff.add(DateDiff.getToday(), Calendar.DATE, 30));
job.setOpenDate(new Date());
}
if(job.getJobStatus() == JobStatus.OPEN && job.getShortenedURL() == null)
{
job.createShortenedURL();
}
return super.processForm(process, submission, params);
}
}
\ No newline at end of file
......@@ -79,6 +79,7 @@ public abstract class BaseJob extends BaseBusinessClass
public static final String SINGLEREFERENCE_Client = "Client";
public static final String BACKREF_Client = "";
public static final String SINGLEREFERENCE_CompanyUser = "CompanyUser";
public static final String SINGLEREFERENCE_ShortenedURL = "ShortenedURL";
public static final String MULTIPLEREFERENCE_JobApplications = "JobApplications";
public static final String BACKREF_JobApplications = "";
public static final String MULTIPLEREFERENCE_AssessmentCriterias = "AssessmentCriterias";
......@@ -161,6 +162,7 @@ public abstract class BaseJob extends BaseBusinessClass
private SingleAssociation<Job, Level> _Level;
private SingleAssociation<Job, Client> _Client;
private SingleAssociation<Job, CompanyUser> _CompanyUser;
private SingleAssociation<Job, ShortenedURL> _ShortenedURL;
// Private attributes corresponding to multiple references
......@@ -227,6 +229,7 @@ public abstract class BaseJob extends BaseBusinessClass
setupAssocMetaData_Level();
setupAssocMetaData_Client();
setupAssocMetaData_CompanyUser();
setupAssocMetaData_ShortenedURL();
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]);
......@@ -395,6 +398,20 @@ public abstract class BaseJob extends BaseBusinessClass
// Meta Info setup
private static void setupAssocMetaData_ShortenedURL()
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "shortened_url_id");
metaInfo.put ("name", "ShortenedURL");
metaInfo.put ("type", "ShortenedURL");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Job.ShortenedURL:", metaInfo);
ATTRIBUTES_METADATA_Job.put (SINGLEREFERENCE_ShortenedURL, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static List setupAttribMetaData_Email(Map validatorMapping)
{
Map metaInfo = new HashMap ();
......@@ -983,6 +1000,7 @@ public abstract class BaseJob extends BaseBusinessClass
_Level = new SingleAssociation<Job, Level> (this, SINGLEREFERENCE_Level, null, Level.REFERENCE_Level, "tl_job");
_Client = new SingleAssociation<Job, Client> (this, SINGLEREFERENCE_Client, Client.MULTIPLEREFERENCE_Jobs, Client.REFERENCE_Client, "tl_job");
_CompanyUser = new SingleAssociation<Job, CompanyUser> (this, SINGLEREFERENCE_CompanyUser, null, CompanyUser.REFERENCE_CompanyUser, "tl_job");
_ShortenedURL = new SingleAssociation<Job, ShortenedURL> (this, SINGLEREFERENCE_ShortenedURL, null, ShortenedURL.REFERENCE_ShortenedURL, "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);
......@@ -1001,6 +1019,7 @@ public abstract class BaseJob extends BaseBusinessClass
_Level = new SingleAssociation<Job, Level> (this, SINGLEREFERENCE_Level, null, Level.REFERENCE_Level, "tl_job");
_Client = new SingleAssociation<Job, Client> (this, SINGLEREFERENCE_Client, Client.MULTIPLEREFERENCE_Jobs, Client.REFERENCE_Client, "tl_job");
_CompanyUser = new SingleAssociation<Job, CompanyUser> (this, SINGLEREFERENCE_CompanyUser, null, CompanyUser.REFERENCE_CompanyUser, "tl_job");
_ShortenedURL = new SingleAssociation<Job, ShortenedURL> (this, SINGLEREFERENCE_ShortenedURL, null, ShortenedURL.REFERENCE_ShortenedURL, "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);
......@@ -3783,6 +3802,8 @@ public abstract class BaseJob extends BaseBusinessClass
result.add("CompanyUser");
result.add("ShortenedURL");
return result;
}
......@@ -3812,6 +3833,9 @@ public abstract class BaseJob extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_CompanyUser))
{
return _CompanyUser.getReferencedType ();
}else if (assocName.equals (SINGLEREFERENCE_ShortenedURL))
{
return _ShortenedURL.getReferencedType ();
}
else
{
......@@ -3835,6 +3859,9 @@ public abstract class BaseJob extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_CompanyUser))
{
return null ;
}else if (assocName.equals (SINGLEREFERENCE_ShortenedURL))
{
return null ;
}
else
{
......@@ -3867,6 +3894,9 @@ public abstract class BaseJob extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_CompanyUser))
{
return getCompanyUser ();
}else if (assocName.equals (SINGLEREFERENCE_ShortenedURL))
{
return getShortenedURL ();
}
else
{
......@@ -3899,6 +3929,9 @@ public abstract class BaseJob extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_CompanyUser))
{
return getCompanyUser (getType);
}else if (assocName.equals (SINGLEREFERENCE_ShortenedURL))
{
return getShortenedURL (getType);
}
else
{
......@@ -3931,6 +3964,9 @@ public abstract class BaseJob extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_CompanyUser))
{
return getCompanyUserID ();
}else if (assocName.equals (SINGLEREFERENCE_ShortenedURL))
{
return getShortenedURLID ();
}
else
{
......@@ -3963,6 +3999,9 @@ public abstract class BaseJob extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_CompanyUser))
{
setCompanyUser ((CompanyUser)(newValue));
}else if (assocName.equals (SINGLEREFERENCE_ShortenedURL))
{
setShortenedURL ((ShortenedURL)(newValue));
}
else
{
......@@ -4551,6 +4590,100 @@ public abstract class BaseJob extends BaseBusinessClass
}
/**
* Get the reference ShortenedURL
*/
public ShortenedURL getShortenedURL () throws StorageException
{
assertValid();
try
{
return (ShortenedURL)(_ShortenedURL.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in Job:", this.getObjectID (), ", was trying to get ShortenedURL:", getShortenedURLID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _ShortenedURL.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public ShortenedURL getShortenedURL (Get getType) throws StorageException
{
assertValid();
return _ShortenedURL.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getShortenedURLID ()
{
assertValid();
if (_ShortenedURL == null)
{
return null;
}
else
{
return _ShortenedURL.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 preShortenedURLChange (ShortenedURL newShortenedURL) 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 postShortenedURLChange () throws FieldException
{
}
public FieldWriteability getWriteability_ShortenedURL ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference ShortenedURL. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setShortenedURL (ShortenedURL newShortenedURL) throws StorageException, FieldException
{
if (_ShortenedURL.wouldReferencedChange (newShortenedURL))
{
assertValid();
Debug.assertion (getWriteability_ShortenedURL () != FieldWriteability.FALSE, "Assoc ShortenedURL is not writeable");
preShortenedURLChange (newShortenedURL);
_ShortenedURL.set (newShortenedURL);
postShortenedURLChange ();
}
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getMultiAssocs()
......@@ -5106,6 +5239,7 @@ public abstract class BaseJob extends BaseBusinessClass
_Level.getPersistentSets (allSets);
_Client.getPersistentSets (allSets);
_CompanyUser.getPersistentSets (allSets);
_ShortenedURL.getPersistentSets (allSets);
}
......@@ -5138,6 +5272,7 @@ public abstract class BaseJob extends BaseBusinessClass
_Level.setFromPersistentSets (objectID, allSets);
_Client.setFromPersistentSets (objectID, allSets);
_CompanyUser.setFromPersistentSets (objectID, allSets);
_ShortenedURL.setFromPersistentSets (objectID, allSets);
}
......@@ -5353,6 +5488,7 @@ public abstract class BaseJob extends BaseBusinessClass
_Level.copyFrom (sourceJob._Level, linkToGhosts);
_Client.copyFrom (sourceJob._Client, linkToGhosts);
_CompanyUser.copyFrom (sourceJob._CompanyUser, linkToGhosts);
_ShortenedURL.copyFrom (sourceJob._ShortenedURL, linkToGhosts);
}
}
......@@ -5428,6 +5564,7 @@ public abstract class BaseJob extends BaseBusinessClass
_Level.readExternalData(vals.get(SINGLEREFERENCE_Level));
_Client.readExternalData(vals.get(SINGLEREFERENCE_Client));
_CompanyUser.readExternalData(vals.get(SINGLEREFERENCE_CompanyUser));
_ShortenedURL.readExternalData(vals.get(SINGLEREFERENCE_ShortenedURL));
_JobApplications.readExternalData(vals.get(MULTIPLEREFERENCE_JobApplications));
_AssessmentCriterias.readExternalData(vals.get(MULTIPLEREFERENCE_AssessmentCriterias));
_CultureCriterias.readExternalData(vals.get(MULTIPLEREFERENCE_CultureCriterias));
......@@ -5476,6 +5613,7 @@ public abstract class BaseJob extends BaseBusinessClass
vals.put (SINGLEREFERENCE_Level, _Level.writeExternalData());
vals.put (SINGLEREFERENCE_Client, _Client.writeExternalData());
vals.put (SINGLEREFERENCE_CompanyUser, _CompanyUser.writeExternalData());
vals.put (SINGLEREFERENCE_ShortenedURL, _ShortenedURL.writeExternalData());
vals.put (MULTIPLEREFERENCE_JobApplications, _JobApplications.writeExternalData());
vals.put (MULTIPLEREFERENCE_AssessmentCriterias, _AssessmentCriterias.writeExternalData());
vals.put (MULTIPLEREFERENCE_CultureCriterias, _CultureCriterias.writeExternalData());
......@@ -5560,6 +5698,7 @@ public abstract class BaseJob extends BaseBusinessClass
_Level.compare (otherJob._Level, listener);
_Client.compare (otherJob._Client, listener);
_CompanyUser.compare (otherJob._CompanyUser, listener);
_ShortenedURL.compare (otherJob._ShortenedURL, listener);
// Compare multiple assocs
......@@ -5617,6 +5756,7 @@ public abstract class BaseJob extends BaseBusinessClass
visitor.visitAssociation (_Level);
visitor.visitAssociation (_Client);
visitor.visitAssociation (_CompanyUser);
visitor.visitAssociation (_ShortenedURL);
visitor.visitAssociation (_JobApplications);
visitor.visitAssociation (_AssessmentCriterias);
visitor.visitAssociation (_CultureCriterias);
......@@ -5652,6 +5792,10 @@ public abstract class BaseJob extends BaseBusinessClass
{
visitor.visit (_CompanyUser);
}
if (scope.includes (_ShortenedURL))
{
visitor.visit (_ShortenedURL);
}
if (scope.includes (_JobApplications))
{
visitor.visit (_JobApplications);
......@@ -5761,6 +5905,10 @@ public abstract class BaseJob extends BaseBusinessClass
{
return filter.matches (getCompanyUser ());
}
else if (attribName.equals (SINGLEREFERENCE_ShortenedURL))
{
return filter.matches (getShortenedURL ());
}
else
{
return super.testFilter (attribName, filter);
......@@ -5900,6 +6048,12 @@ public abstract class BaseJob extends BaseBusinessClass
return this;
}
public SearchAll andShortenedURL (QueryFilter<ShortenedURL> filter)
{
filter.addFilter (context, "tl_job.shortened_url_id", "ShortenedURL");
return this;
}
public Job[]
search (ObjectTransaction transaction) throws StorageException
{
......@@ -6071,6 +6225,12 @@ public abstract class BaseJob extends BaseBusinessClass
return this;
}
public SearchJobKey andShortenedURL (QueryFilter<ShortenedURL> filter)
{
filter.addFilter (context, "tl_job.shortened_url_id", "ShortenedURL");
return this;
}
public Job search (ObjectTransaction transaction) throws StorageException
{
......@@ -6236,6 +6396,12 @@ public abstract class BaseJob extends BaseBusinessClass
return this;
}
public SearchCompany andShortenedURL (QueryFilter<ShortenedURL> filter)
{
filter.addFilter (context, "tl_job.shortened_url_id", "ShortenedURL");
return this;
}
public Job[]
search (ObjectTransaction transaction) throws StorageException
{
......@@ -6738,6 +6904,10 @@ public abstract class BaseJob extends BaseBusinessClass
{
return getWriteability_CompanyUser ();
}
else if (fieldName.equals (SINGLEREFERENCE_ShortenedURL))
{
return getWriteability_ShortenedURL ();
}
else if (fieldName.equals (FIELD_Email))
{
return getWriteability_Email ();
......@@ -7743,6 +7913,10 @@ public abstract class BaseJob extends BaseBusinessClass
{
return toCompanyUser ();
}
if (name.equals ("ShortenedURL"))
{
return toShortenedURL ();
}
return super.to(name);
......@@ -7840,6 +8014,12 @@ public abstract class BaseJob extends BaseBusinessClass
{
return CompanyUser.REFERENCE_CompanyUser.new CompanyUserPipeLineFactory<From, CompanyUser> (this, new ORMSingleAssocPipe<Me, CompanyUser>(SINGLEREFERENCE_CompanyUser, filter));
}
public ShortenedURL.ShortenedURLPipeLineFactory<From, ShortenedURL> toShortenedURL () { return toShortenedURL (Filter.ALL); }
public ShortenedURL.ShortenedURLPipeLineFactory<From, ShortenedURL> toShortenedURL (Filter<ShortenedURL> filter)
{
return ShortenedURL.REFERENCE_ShortenedURL.new ShortenedURLPipeLineFactory<From, ShortenedURL> (this, new ORMSingleAssocPipe<Me, ShortenedURL>(SINGLEREFERENCE_ShortenedURL, filter));
}
public JobApplication.JobApplicationPipeLineFactory<From, JobApplication> toJobApplications () { return toJobApplications(Filter.ALL); }
public JobApplication.JobApplicationPipeLineFactory<From, JobApplication> toJobApplications (Filter<JobApplication> filter)
......@@ -8053,6 +8233,20 @@ class DummyJob extends Job
return CompanyUser.DUMMY_CompanyUser.getObjectID();
}
public ShortenedURL getShortenedURL () throws StorageException
{
return (ShortenedURL)(ShortenedURL.DUMMY_ShortenedURL);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getShortenedURLID ()
{
return ShortenedURL.DUMMY_ShortenedURL.getObjectID();
}
public int getJobApplicationsCount () throws StorageException
{
return 0;
......
/*
* 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;
public abstract class BaseShortenedURL extends BaseBusinessClass
{
// Reference instance for the object
public static final ShortenedURL REFERENCE_ShortenedURL = new ShortenedURL ();
// Reference instance for the object
public static final ShortenedURL DUMMY_ShortenedURL = new DummyShortenedURL ();
// Static constants corresponding to field names
public static final String FIELD_Code = "Code";
public static final String FIELD_UrlLink = "UrlLink";
// Static constants corresponding to searches
public static final String SEARCH_all = "all";
public static final String SEARCH_ByCode = "ByCode";
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper<ShortenedURL> HELPER_Code = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<ShortenedURL> HELPER_UrlLink = DefaultAttributeHelper.INSTANCE;
// Private attributes corresponding to business object data
private String _Code;
private String _UrlLink;
// Private attributes corresponding to single references
// Private attributes corresponding to multiple references
// Map of maps of metadata
private static final Map ATTRIBUTES_METADATA_ShortenedURL = new HashMap ();
// Arrays of validators for each attribute
private static final AttributeValidator[] FIELD_Code_Validators;
private static final AttributeValidator[] FIELD_UrlLink_Validators;
// Arrays of behaviour decorators
private static final ShortenedURLBehaviourDecorator[] ShortenedURL_BehaviourDecorators;
static
{
try
{
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
FIELD_Code_Validators = (AttributeValidator[])setupAttribMetaData_Code(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_UrlLink_Validators = (AttributeValidator[])setupAttribMetaData_UrlLink(validatorMapping).toArray (new AttributeValidator[0]);
REFERENCE_ShortenedURL.initialiseReference ();
DUMMY_ShortenedURL.initialiseReference ();
ShortenedURL_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(ShortenedURL.class).toArray(new ShortenedURLBehaviourDecorator[0]);
}
catch (RuntimeException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
throw e;
}
}
// Meta Info setup
private static List setupAttribMetaData_Code(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "code");
metaInfo.put ("length", "8");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "Code");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for ShortenedURL.Code:", metaInfo);
ATTRIBUTES_METADATA_ShortenedURL.put (FIELD_Code, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(ShortenedURL.class, "Code", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for ShortenedURL.Code:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_UrlLink(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "url_link");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "UrlLink");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for ShortenedURL.UrlLink:", metaInfo);
ATTRIBUTES_METADATA_ShortenedURL.put (FIELD_UrlLink, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(ShortenedURL.class, "UrlLink", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for ShortenedURL.UrlLink:", validators);
return validators;
}
// END OF STATIC METADATA DEFINITION
// This constructor should not be called
protected BaseShortenedURL ()
{
}
protected BBCBehaviourDecorator[] getBehaviours()
{
return ShortenedURL_BehaviourDecorators;
}
// Initialise the attributes
protected void _initialiseNewObjAttributes (ObjectTransaction transaction) throws StorageException
{
super._initialiseNewObjAttributes (transaction);
_Code = (String)(HELPER_Code.initialise (_Code));
_UrlLink = (String)(HELPER_UrlLink.initialise (_UrlLink));
}
// Initialise the associations
protected void _initialiseAssociations ()
{
super._initialiseAssociations ();
}
// Initialise the associations
protected BaseBusinessClass initialiseReference ()
{
super.initialiseReference ();
return this;
}
/**
* Get the attribute Code
*/
public String getCode ()
{
assertValid();
String valToReturn = _Code;
for (ShortenedURLBehaviourDecorator bhd : ShortenedURL_BehaviourDecorators)
{
valToReturn = bhd.getCode ((ShortenedURL)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 preCodeChange (String newCode) 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 postCodeChange () throws FieldException
{
}
public FieldWriteability getWriteability_Code ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute Code. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setCode (String newCode) throws FieldException
{
boolean oldAndNewIdentical = HELPER_Code.compare (_Code, newCode);
try
{
for (ShortenedURLBehaviourDecorator bhd : ShortenedURL_BehaviourDecorators)
{
newCode = bhd.setCode ((ShortenedURL)this, newCode);
oldAndNewIdentical = HELPER_Code.compare (_Code, newCode);
}
BusinessObjectParser.assertFieldCondition (newCode != null, this, FIELD_Code, "mandatory");
if (FIELD_Code_Validators.length > 0)
{
Object newCodeObj = HELPER_Code.toObject (newCode);
if (newCodeObj != null)
{
int loopMax = FIELD_Code_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_ShortenedURL.get (FIELD_Code);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_Code_Validators[v].checkAttribute (this, FIELD_Code, metadata, newCodeObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_Code () != FieldWriteability.FALSE, "Field Code is not writeable");
preCodeChange (newCode);
markFieldChange (FIELD_Code);
_Code = newCode;
postFieldChange (FIELD_Code);
postCodeChange ();
}
}
/**
* Get the attribute UrlLink
*/
public String getUrlLink ()
{
assertValid();
String valToReturn = _UrlLink;
for (ShortenedURLBehaviourDecorator bhd : ShortenedURL_BehaviourDecorators)
{
valToReturn = bhd.getUrlLink ((ShortenedURL)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 preUrlLinkChange (String newUrlLink) 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 postUrlLinkChange () throws FieldException
{
}
public FieldWriteability getWriteability_UrlLink ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute UrlLink. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setUrlLink (String newUrlLink) throws FieldException
{
boolean oldAndNewIdentical = HELPER_UrlLink.compare (_UrlLink, newUrlLink);
try
{
for (ShortenedURLBehaviourDecorator bhd : ShortenedURL_BehaviourDecorators)
{
newUrlLink = bhd.setUrlLink ((ShortenedURL)this, newUrlLink);
oldAndNewIdentical = HELPER_UrlLink.compare (_UrlLink, newUrlLink);
}
BusinessObjectParser.assertFieldCondition (newUrlLink != null, this, FIELD_UrlLink, "mandatory");
if (FIELD_UrlLink_Validators.length > 0)
{
Object newUrlLinkObj = HELPER_UrlLink.toObject (newUrlLink);
if (newUrlLinkObj != null)
{
int loopMax = FIELD_UrlLink_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_ShortenedURL.get (FIELD_UrlLink);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_UrlLink_Validators[v].checkAttribute (this, FIELD_UrlLink, metadata, newUrlLinkObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_UrlLink () != FieldWriteability.FALSE, "Field UrlLink is not writeable");
preUrlLinkChange (newUrlLink);
markFieldChange (FIELD_UrlLink);
_UrlLink = newUrlLink;
postFieldChange (FIELD_UrlLink);
postUrlLinkChange ();
}
}
/**
* 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 ShortenedURL newInstance ()
{
return new ShortenedURL ();
}
public ShortenedURL referenceInstance ()
{
return REFERENCE_ShortenedURL;
}
public ShortenedURL getInTransaction (ObjectTransaction t) throws StorageException
{
return getShortenedURLByID (t, getObjectID());
}
public BaseBusinessClass dummyInstance ()
{
return DUMMY_ShortenedURL;
}
public String getBaseSetName ()
{
return "tl_shortened_url";
}
/**
* 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_shortened_urlPSet = allSets.getPersistentSet (myID, "tl_shortened_url", myPSetStatus);
tl_shortened_urlPSet.setAttrib (FIELD_ObjectID, myID);
tl_shortened_urlPSet.setAttrib (FIELD_Code, HELPER_Code.toObject (_Code)); //
tl_shortened_urlPSet.setAttrib (FIELD_UrlLink, HELPER_UrlLink.toObject (_UrlLink)); //
}
/**
* Sets the objects state based on Persistent sets.
*/
public void setFromPersistentSets (ObjectID objectID, PersistentSetCollection allSets)
{
super.setFromPersistentSets (objectID, allSets);
PersistentSet tl_shortened_urlPSet = allSets.getPersistentSet (objectID, "tl_shortened_url");
_Code = (String)(HELPER_Code.fromObject (_Code, tl_shortened_urlPSet.getAttrib (FIELD_Code))); //
_UrlLink = (String)(HELPER_UrlLink.fromObject (_UrlLink, tl_shortened_urlPSet.getAttrib (FIELD_UrlLink))); //
}
public void setAttributesFrom (BaseBusinessClass other, MultiException e)
{
super.setAttributesFrom (other, e);
if (other instanceof ShortenedURL)
{
ShortenedURL otherShortenedURL = (ShortenedURL)other;
try
{
setCode (otherShortenedURL.getCode ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setUrlLink (otherShortenedURL.getUrlLink ());
}
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 BaseShortenedURL)
{
BaseShortenedURL sourceShortenedURL = (BaseShortenedURL)(source);
_Code = sourceShortenedURL._Code;
_UrlLink = sourceShortenedURL._UrlLink;
}
}
/**
* 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 BaseShortenedURL)
{
BaseShortenedURL sourceShortenedURL = (BaseShortenedURL)(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 BaseShortenedURL)
{
BaseShortenedURL sourceShortenedURL = (BaseShortenedURL)(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);
_Code = (String)(HELPER_Code.readExternal (_Code, vals.get(FIELD_Code))); //
_UrlLink = (String)(HELPER_UrlLink.readExternal (_UrlLink, vals.get(FIELD_UrlLink))); //
}
/**
* Subclasses must override this to write out their attributes
*/
protected void writeExternalData(Map<String, Object> vals) throws IOException
{
super.writeExternalData(vals);
vals.put (FIELD_Code, HELPER_Code.writeExternal (_Code));
vals.put (FIELD_UrlLink, HELPER_UrlLink.writeExternal (_UrlLink));
}
public void compare (BaseBusinessClass other, AttributeChangeListener listener) throws StorageException
{
super.compare (other, listener);
if (other instanceof BaseShortenedURL)
{
BaseShortenedURL otherShortenedURL = (BaseShortenedURL)(other);
if (!HELPER_Code.compare(this._Code, otherShortenedURL._Code))
{
listener.notifyFieldChange(this, other, FIELD_Code, HELPER_Code.toObject(this._Code), HELPER_Code.toObject(otherShortenedURL._Code));
}
if (!HELPER_UrlLink.compare(this._UrlLink, otherShortenedURL._UrlLink))
{
listener.notifyFieldChange(this, other, FIELD_UrlLink, HELPER_UrlLink.toObject(this._UrlLink), HELPER_UrlLink.toObject(otherShortenedURL._UrlLink));
}
// 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_Code, HELPER_Code.toObject(getCode()));
visitor.visitField(this, FIELD_UrlLink, HELPER_UrlLink.toObject(getUrlLink()));
}
public void visitAssociations (AssociationVisitor visitor, AssociatedScope scope) throws StorageException
{
super.visitAssociations (visitor, scope);
}
public static ShortenedURL createShortenedURL (ObjectTransaction transaction) throws StorageException
{
ShortenedURL result = new ShortenedURL ();
result.initialiseNewObject (transaction);
return result;
}
public static ShortenedURL getShortenedURLByID (ObjectTransaction transaction, Long objectID) throws StorageException
{
return (ShortenedURL)(transaction.getObjectByID (REFERENCE_ShortenedURL, objectID));
}
public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Code))
{
return filter.matches (getCode ());
}
else if (attribName.equals (FIELD_UrlLink))
{
return filter.matches (getUrlLink ());
}
else
{
return super.testFilter (attribName, filter);
}
}
public static Searchall SearchByall () { return new Searchall (); }
public static class Searchall extends SearchObject<ShortenedURL>
{
public Searchall andObjectID (QueryFilter<Long> filter)
{
filter.addFilter (context, "tl_shortened_url.object_id", FIELD_ObjectID);
return this;
}
public Searchall andObjectCreated (QueryFilter<Date> filter)
{
filter.addFilter (context, "tl_shortened_url.object_created_date", FIELD_ObjectCreated);
return this;
}
public Searchall andObjectLastModified (QueryFilter<Date> filter)
{
filter.addFilter (context, "tl_shortened_url.object_last_updated_date", FIELD_ObjectLastModified);
return this;
}
public Searchall andCode (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_shortened_url.code", "Code");
return this;
}
public Searchall andUrlLink (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_shortened_url.url_link", "UrlLink");
return this;
}
public ShortenedURL[]
search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_ShortenedURL, SEARCH_all, criteria);
Set<ShortenedURL> typedResults = new LinkedHashSet <ShortenedURL> ();
for (BaseBusinessClass bbcResult : results)
{
ShortenedURL aResult = (ShortenedURL)bbcResult;
typedResults.add (aResult);
}
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new ShortenedURL[0]);
}
}
public static ShortenedURL[]
searchall (ObjectTransaction transaction) throws StorageException
{
return SearchByall ()
.search (transaction);
}
public abstract boolean filterByCode(String Code) throws StorageException;
public static SearchByCode SearchByByCode () { return new SearchByCode (); }
public static class SearchByCode extends SearchObject<ShortenedURL>
{
public SearchByCode byCode (String Code)
{
by ("Code", Code);
return this;
}
public SearchByCode andObjectID (QueryFilter<Long> filter)
{
filter.addFilter (context, "tl_shortened_url.object_id", FIELD_ObjectID);
return this;
}
public SearchByCode andObjectCreated (QueryFilter<Date> filter)
{
filter.addFilter (context, "tl_shortened_url.object_created_date", FIELD_ObjectCreated);
return this;
}
public SearchByCode andObjectLastModified (QueryFilter<Date> filter)
{
filter.addFilter (context, "tl_shortened_url.object_last_updated_date", FIELD_ObjectLastModified);
return this;
}
public SearchByCode andCode (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_shortened_url.code", "Code");
return this;
}
public SearchByCode andUrlLink (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_shortened_url.url_link", "UrlLink");
return this;
}
public ShortenedURL[]
search (ObjectTransaction transaction) throws StorageException
{
String Code = (String)criteria.get ("Code");
BaseBusinessClass[] results = super.search (transaction, REFERENCE_ShortenedURL, SEARCH_ByCode, criteria);
Set<ShortenedURL> typedResults = new LinkedHashSet <ShortenedURL> ();
for (BaseBusinessClass bbcResult : results)
{
ShortenedURL aResult = (ShortenedURL)bbcResult;
// Check in case in memory objects should be excluded
if (!aResult.filterByCode(Code) || !filterAndsInMemory (aResult))
{
continue;
}
typedResults.add (aResult);
}
// Check in memory objects for matches
for (BaseBusinessClass bbcInMemory : transaction.getObjectsToStore ())
{
if (bbcInMemory instanceof ShortenedURL)
{
ShortenedURL aInMemory = (ShortenedURL)bbcInMemory;
if (!aInMemory.filterByCode(Code) || !filterAndsInMemory (aInMemory))
{
continue;
}
typedResults.add (aInMemory);
}
}
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new ShortenedURL[0]);
}
}
public static ShortenedURL[]
searchByCode (ObjectTransaction transaction, String Code) throws StorageException
{
return SearchByByCode ()
.byCode (Code)
.search (transaction);
}
public Object getAttribute (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Code))
{
return HELPER_Code.toObject (getCode ());
}
else if (attribName.equals (FIELD_UrlLink))
{
return HELPER_UrlLink.toObject (getUrlLink ());
}
else
{
return super.getAttribute (attribName);
}
}
public AttributeHelper getAttributeHelper (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Code))
{
return HELPER_Code;
}
else if (attribName.equals (FIELD_UrlLink))
{
return HELPER_UrlLink;
}
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_Code))
{
setCode ((String)(HELPER_Code.fromObject (_Code, attribValue)));
}
else if (attribName.equals (FIELD_UrlLink))
{
setUrlLink ((String)(HELPER_UrlLink.fromObject (_UrlLink, 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_Code))
{
return getWriteability_Code ();
}
else if (fieldName.equals (FIELD_UrlLink))
{
return getWriteability_UrlLink ();
}
else
{
return super.getWriteable (fieldName);
}
}
public void putUnwriteable (Set<String> fields)
{
if (getWriteability_Code () != FieldWriteability.TRUE)
{
fields.add (FIELD_Code);
}
if (getWriteability_UrlLink () != FieldWriteability.TRUE)
{
fields.add (FIELD_UrlLink);
}
super.putUnwriteable (fields);
}
public List<AbstractAttribute> getAttributes ()
{
List result = super.getAttributes ();
result.add(HELPER_Code.getAttribObject (getClass (), _Code, true, FIELD_Code));
result.add(HELPER_UrlLink.getAttribObject (getClass (), _UrlLink, true, FIELD_UrlLink));
return result;
}
public Map getAttributeMetadata (String attribute)
{
if (ATTRIBUTES_METADATA_ShortenedURL.containsKey (attribute))
{
return (Map)ATTRIBUTES_METADATA_ShortenedURL.get (attribute);
}
else
{
return super.getAttributeMetadata (attribute);
}
}
public Object getAttributeMetadata (String attribute, String metadata)
{
if (ATTRIBUTES_METADATA_ShortenedURL.containsKey (attribute))
{
return ((Map)ATTRIBUTES_METADATA_ShortenedURL.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 ShortenedURLBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<ShortenedURL>
{
/**
* Get the attribute Code
*/
public String getCode (ShortenedURL obj, String original)
{
return original;
}
/**
* Change the value set for attribute Code.
* May modify the field beforehand
* Occurs before validation.
*/
public String setCode (ShortenedURL obj, String newCode) throws FieldException
{
return newCode;
}
/**
* Get the attribute UrlLink
*/
public String getUrlLink (ShortenedURL obj, String original)
{
return original;
}
/**
* Change the value set for attribute UrlLink.
* May modify the field beforehand
* Occurs before validation.
*/
public String setUrlLink (ShortenedURL obj, String newUrlLink) throws FieldException
{
return newUrlLink;
}
}
public ORMPipeLine pipes()
{
return new ShortenedURLPipeLineFactory<ShortenedURL, ShortenedURL> ((ShortenedURL)this);
}
/**
* Use this instead of pipes() to get rid of type casting.
*/
public ShortenedURLPipeLineFactory<ShortenedURL, ShortenedURL> pipelineShortenedURL()
{
return (ShortenedURLPipeLineFactory<ShortenedURL, ShortenedURL>) pipes();
}
public static ShortenedURLPipeLineFactory<ShortenedURL, ShortenedURL> pipesShortenedURL(Collection<ShortenedURL> items)
{
return REFERENCE_ShortenedURL.new ShortenedURLPipeLineFactory<ShortenedURL, ShortenedURL> (items);
}
public static ShortenedURLPipeLineFactory<ShortenedURL, ShortenedURL> pipesShortenedURL(ShortenedURL[] _items)
{
return pipesShortenedURL(Arrays.asList (_items));
}
public static ShortenedURLPipeLineFactory<ShortenedURL, ShortenedURL> pipesShortenedURL()
{
return pipesShortenedURL((Collection)null);
}
public class ShortenedURLPipeLineFactory<From extends BaseBusinessClass, Me extends ShortenedURL> extends BaseBusinessClass.ORMPipeLine<From, Me>
{
public <Prev> ShortenedURLPipeLineFactory (PipeLine<From, Prev> pipeLine, Pipe<Prev, Me> nextPipe)
{
super (pipeLine, nextPipe);
}
public ShortenedURLPipeLineFactory (From seed)
{
super(seed);
}
public ShortenedURLPipeLineFactory (Collection<From> seed)
{
super(seed);
}
public PipeLine<From, ? extends Object> to(String name)
{
if (name.equals ("Code"))
{
return toCode ();
}
if (name.equals ("UrlLink"))
{
return toUrlLink ();
}
return super.to(name);
}
public PipeLine<From, String> toCode () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Code)); }
public PipeLine<From, String> toUrlLink () { return pipe(new ORMAttributePipe<Me, String>(FIELD_UrlLink)); }
}
public boolean isTransientAttrib(String attribName)
{
return super.isTransientAttrib(attribName);
}
public boolean isTransientSingleReference(String assocName)
{
return super.isTransientSingleReference(assocName);
}
}
class DummyShortenedURL extends ShortenedURL
{
// Default constructor primarily to support Externalisable
public DummyShortenedURL()
{
super();
}
public void assertValid ()
{
}
}
......@@ -2,6 +2,7 @@ package performa.orm;
import java.util.*;
import oneit.logging.LoggingArea;
import oneit.net.LoopbackHTTP;
import oneit.objstore.*;
import oneit.objstore.cloning.AssocCopyingRule;
import oneit.objstore.cloning.BusinessCopyHelper;
......@@ -499,4 +500,43 @@ public class Job extends BaseJob
return Arrays.asList(new JobStatus[]{JobStatus.OPEN, JobStatus.COMPLETE, JobStatus.FILLED});
}
private String getURL()
{
return LoopbackHTTP.getRemoteAccessURL("/ApplicantPortal-ApplyJob.htm?" + "id=" + getID() + "&key=" + getRandomKey());
}
public void createShortenedURL() throws StorageException, FieldException
{
ShortenedURL shortenedURL = ShortenedURL.createShortenedURL(getTransaction());
shortenedURL.setUrlLink(getURL());
shortenedURL.setCode(generateUniqueCode());
setShortenedURL(shortenedURL);
}
private String generateUniqueCode()
{
String randomString;
while (true)
{
randomString = RandomStringGen.getRandomStringGen().generateAlphaNum(6);
ShortenedURL[] searchByCode = ShortenedURL.searchByCode(getTransaction(), randomString);
if (searchByCode.length == 0)
{
return randomString;
}
}
}
public String getShortenedUrlLink()
{
return LoopbackHTTP.getRemoteAccessURL("/j/" + (getShortenedURL() != null ? getShortenedURL().getCode() : ""));
}
}
\ No newline at end of file
......@@ -50,6 +50,7 @@
<SINGLEREFERENCE name="Level" type="Level" dbcol="level_id" mandatory="true"/>
<SINGLEREFERENCE name="Client" type="Client" dbcol="client_id" backreferenceName="Jobs"/>
<SINGLEREFERENCE name="CompanyUser" type="CompanyUser" dbcol="company_user_id" />
<SINGLEREFERENCE name="ShortenedURL" type="ShortenedURL" dbcol="shortened_url_id" />
</TABLE>
......
......@@ -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.client_id, {PREFIX}tl_job.company_user_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, {PREFIX}tl_job.shortened_url_id, 1 AS commasafe ";
private String SELECT_JOINS = "";
public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
......@@ -154,7 +154,8 @@ public class JobPersistenceMgr extends ObjectPersistenceMgr
!tl_jobPSet.containsAttrib(Job.FIELD_Country)||
!tl_jobPSet.containsAttrib(Job.SINGLEREFERENCE_Level)||
!tl_jobPSet.containsAttrib(Job.SINGLEREFERENCE_Client)||
!tl_jobPSet.containsAttrib(Job.SINGLEREFERENCE_CompanyUser))
!tl_jobPSet.containsAttrib(Job.SINGLEREFERENCE_CompanyUser)||
!tl_jobPSet.containsAttrib(Job.SINGLEREFERENCE_ShortenedURL))
{
// We will need to retrieve it
idsToFetch.add (id.longValue());
......@@ -234,10 +235,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 = ? , client_id = ? , company_user_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 = ? , shortened_url_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_Client)))).listEntry (SQLManager.CheckNull((Long)(tl_jobPSet.getAttrib (Job.SINGLEREFERENCE_CompanyUser)))).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 (SQLManager.CheckNull((Long)(tl_jobPSet.getAttrib (Job.SINGLEREFERENCE_ShortenedURL)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1)
{
......@@ -622,6 +623,7 @@ public class JobPersistenceMgr extends ObjectPersistenceMgr
tl_jobPSet.setAttrib(Job.SINGLEREFERENCE_Level, r.getObject ("level_id"));
tl_jobPSet.setAttrib(Job.SINGLEREFERENCE_Client, r.getObject ("client_id"));
tl_jobPSet.setAttrib(Job.SINGLEREFERENCE_CompanyUser, r.getObject ("company_user_id"));
tl_jobPSet.setAttrib(Job.SINGLEREFERENCE_ShortenedURL, r.getObject ("shortened_url_id"));
}
......@@ -638,10 +640,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, client_id, company_user_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, shortened_url_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_Client)))).listEntry (SQLManager.CheckNull((Long)(tl_jobPSet.getAttrib (Job.SINGLEREFERENCE_CompanyUser)))) .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 (SQLManager.CheckNull((Long)(tl_jobPSet.getAttrib (Job.SINGLEREFERENCE_ShortenedURL)))) .listEntry (objectID.longID ()).toList().toArray());
tl_jobPSet.setStatus (PersistentSetStatus.PROCESSED);
}
......
package performa.orm;
import oneit.objstore.StorageException;
import oneit.utils.CollectionUtils;
public class ShortenedURL extends BaseShortenedURL
{
private static final long serialVersionUID = 0L;
// This constructor should not be called
public ShortenedURL ()
{
// Do not add any code to this, always put it in initialiseNewObject
}
@Override
public boolean filterByCode(String code) throws StorageException
{
return CollectionUtils.equals(code, getCode());
}
}
\ No newline at end of file
<?xml version="1.0"?>
<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='http://www.oneit.com.au/schemas/5.2/BusinessObject.xsd'>
<BUSINESSCLASS name="ShortenedURL" package="performa.orm">
<TABLE name="tl_shortened_url" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="Code" type="String" dbcol="code" mandatory="true" length="8"/>
<ATTRIB name="UrlLink" type="String" dbcol="url_link" mandatory="true" />
</TABLE>
<SEARCH type="all" paramFilter="object_id is not null" orderBy="object_created_date desc">
</SEARCH>
<SEARCH type="ByCode" paramFilter="object_id is not NULL" checkTXObjects="TRUE">
<PARAM name="Code" type="String" paramFilter="trim(code) = ${Code}"/>
</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.*;
/**
* IMPORTANT!!!! Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2[oneit.objstore.PersistenceMgrTemplate.xsl]
*/
public class ShortenedURLPersistenceMgr extends ObjectPersistenceMgr
{
private static final LoggingArea ShortenedURLPersistence = LoggingArea.createLoggingArea(ObjectPersistenceMgr.OBJECT_PERSISTENCE, "ShortenedURL");
// Private attributes corresponding to business object data
private String dummyCode;
private String dummyUrlLink;
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper HELPER_Code = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_UrlLink = DefaultAttributeHelper.INSTANCE;
public ShortenedURLPersistenceMgr ()
{
dummyCode = (String)(HELPER_Code.initialise (dummyCode));
dummyUrlLink = (String)(HELPER_UrlLink.initialise (dummyUrlLink));
}
private String SELECT_COLUMNS = "{PREFIX}tl_shortened_url.object_id as id, {PREFIX}tl_shortened_url.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_shortened_url.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_shortened_url.code, {PREFIX}tl_shortened_url.url_link, 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, ShortenedURL.REFERENCE_ShortenedURL);
if (objectToReturn instanceof ShortenedURL)
{
LogMgr.log (ShortenedURLPersistence, 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 ShortenedURL");
}
}
PersistentSet tl_shortened_urlPSet = allPSets.getPersistentSet(id, "tl_shortened_url", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched
if (false || !tl_shortened_urlPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!tl_shortened_urlPSet.containsAttrib(ShortenedURL.FIELD_Code)||
!tl_shortened_urlPSet.containsAttrib(ShortenedURL.FIELD_UrlLink))
{
// We will need to retrieve it
idsToFetch.add (id.longValue());
}
else
{
LogMgr.log (ShortenedURLPersistence, LogLevel.DEBUG2, "Persistent set preloaded id:", id);
/* Non Polymorphic */
ShortenedURL result = new ShortenedURL ();
result.setFromPersistentSets(id, allPSets);
context.addRetrievedObject(result);
results.add (result);
}
}
if (idsToFetch.size () > 0)
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_shortened_url " +
"WHERE " + SELECT_JOINS + "{PREFIX}tl_shortened_url.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_shortened_urlPSet = allPSets.getPersistentSet(objectID, "tl_shortened_url");
if (tl_shortened_urlPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_shortened_urlPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}tl_shortened_url " +
"SET code = ?, url_link = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE tl_shortened_url.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_Code.getForSQL(dummyCode, tl_shortened_urlPSet.getAttrib (ShortenedURL.FIELD_Code))).listEntry (HELPER_UrlLink.getForSQL(dummyUrlLink, tl_shortened_urlPSet.getAttrib (ShortenedURL.FIELD_UrlLink))).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_shortened_url 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_shortened_url", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ());
LogMgr.log (ShortenedURLPersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "tl_shortened_url");
}
else
{
String errorMsg = "Attempt to update nonexistent row in table:tl_shortened_url for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (ShortenedURLPersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
tl_shortened_urlPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
else
{
LogMgr.log (ShortenedURLPersistence, 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_shortened_urlPSet = allPSets.getPersistentSet(objectID, "tl_shortened_url");
LogMgr.log (ShortenedURLPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (tl_shortened_urlPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_shortened_urlPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsDeleted = executeStatement (sqlMgr,
"DELETE " +
"FROM {PREFIX}tl_shortened_url " +
"WHERE tl_shortened_url.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_shortened_url WHERE object_id = ?",
new Object[] { objectID.longID() });
if (r.next ())
{
throw new ConcurrentUpdateConflictException (obj, "tl_shortened_url");
}
else
{
String errorMsg = "Attempt to delete nonexistent row in table:tl_shortened_url for row:" + objectID;
LogMgr.log (ShortenedURLPersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
tl_shortened_urlPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
public ResultSet executeSearchQueryall (SQLManager sqlMgr) throws SQLException
{
throw new RuntimeException ("NOT implemented: executeSearchQueryall");
}
public ResultSet executeSearchQueryByCode (SQLManager sqlMgr, String Code) throws SQLException
{
throw new RuntimeException ("NOT implemented: executeSearchQueryByCode");
}
public BaseBusinessClass[] loadQuery (PersistentSetCollection allPSets, SQLManager sqlMgr, RDBMSPersistenceContext context, String query, Object[] params, Integer maxRows, boolean truncateExtra) throws SQLException, StorageException
{
LinkedHashMap<ObjectID, ShortenedURL> results = new LinkedHashMap ();
ResultSet r = executeQuery (sqlMgr, query, params);
while (r.next())
{
ThreadUtils.checkInterrupted ();
ObjectID objectID = new ObjectID (ShortenedURL.REFERENCE_ShortenedURL.getObjectIDSpace (), r.getLong ("id"));
ShortenedURL 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, ShortenedURL.REFERENCE_ShortenedURL);
if (cachedElement instanceof ShortenedURL)
{
LogMgr.log (ShortenedURLPersistence, LogLevel.TRACE, "Cache hit for id:", objectID);
resultElement = (ShortenedURL)cachedElement;
}
else
{
throw new StorageException ("Cache collision for id:" + objectID + " with object " + cachedElement + "while fetching a ShortenedURL");
}
}
else
{
PersistentSet tl_shortened_urlPSet = allPSets.getPersistentSet(objectID, "tl_shortened_url", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID);
resultElement = new ShortenedURL ();
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 (ShortenedURLPersistence, 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_shortened_url " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
return results;
}
else if (searchType.equals (ShortenedURL.SEARCH_all))
{
// Local scope for transformed variables
{
}
String orderBy = " ORDER BY object_created_date desc";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter: object_id is not null
String preFilter = "(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_shortened_url " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, maxRows, truncateExtra);
return results;
}
else if (searchType.equals (ShortenedURL.SEARCH_ByCode))
{
// Local scope for transformed variables
{
}
String orderBy = " ";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter: object_id is not NULL
String preFilter = "(object_id is not NULL)"
+ " ";
if (criteria.containsKey("Code"))
{
preFilter += " AND (trim(code) = ${Code}) ";
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}tl_shortened_url " + 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_shortened_urlPSet = allPSets.getPersistentSet(objectID, "tl_shortened_url", PersistentSetStatus.FETCHED);
// Object Modified
tl_shortened_urlPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created
tl_shortened_urlPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
tl_shortened_urlPSet.setAttrib(ShortenedURL.FIELD_Code, HELPER_Code.getFromRS(dummyCode, r, "code"));
tl_shortened_urlPSet.setAttrib(ShortenedURL.FIELD_UrlLink, HELPER_UrlLink.getFromRS(dummyUrlLink, r, "url_link"));
}
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet tl_shortened_urlPSet = allPSets.getPersistentSet(objectID, "tl_shortened_url");
if (tl_shortened_urlPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_shortened_urlPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
executeStatement (sqlMgr,
"INSERT INTO {PREFIX}tl_shortened_url " +
" (code, url_link, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " +
" (?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_Code.getForSQL(dummyCode, tl_shortened_urlPSet.getAttrib (ShortenedURL.FIELD_Code))).listEntry (HELPER_UrlLink.getForSQL(dummyUrlLink, tl_shortened_urlPSet.getAttrib (ShortenedURL.FIELD_UrlLink))) .listEntry (objectID.longID ()).toList().toArray());
tl_shortened_urlPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
}
package performa.utils;
import oneit.appservices.config.ConfigMgr;
import oneit.components.InitialisationParticipant;
import oneit.components.ParticipantInitialisationContext;
import oneit.logging.LogLevel;
import oneit.logging.LogMgr;
import oneit.logging.LoggingArea;
import oneit.objstore.ObjectTransaction;
import oneit.objstore.services.TransactionServicesFactory;
import oneit.servlets.utils.BaseHttpServletRequest;
import oneit.servlets.utils.BaseHttpServletResponse;
import oneit.servlets.utils.decorator.ServletDecorator;
import oneit.servlets.utils.decorator.ServletDecoratorConfig;
import oneit.utils.BusinessException;
import oneit.utils.InitialisationException;
import performa.orm.ShortenedURL;
public class ShortenedURLDecorator implements ServletDecorator, InitialisationParticipant
{
public static final LoggingArea LOG = LoggingArea.createLoggingArea("ShortenedURLFilter");
public static final String JOB_URL_PREFIX = "/j/";
@Override
public void processRequest(ServletDecoratorConfig config, BaseHttpServletRequest request, BaseHttpServletResponse response) throws Exception
{
String pathInfo = request.getServletPath();
LogMgr.log(LOG, LogLevel.PROCESSING1, "ShortenedURLFilter.doFilter: ", pathInfo);
if (pathInfo != null && pathInfo.contains(JOB_URL_PREFIX))
{
int lastIndex = pathInfo.lastIndexOf("/");
String shortcut = pathInfo.substring(lastIndex+1);
try
{
TransactionServicesFactory servicesFactory = (TransactionServicesFactory) ConfigMgr.getConfigObject(ConfigMgr.GLOBAL_CONFIG_SYSTEM, "TransactionServices");
ObjectTransaction objTran = new ObjectTransaction (servicesFactory);
ShortenedURL[] shortURL = ShortenedURL.searchByCode(objTran, shortcut);
if(shortURL != null && shortURL.length > 0)
{
request.setAttribute("DecoratorFilter.TERMINATE", "Yes");
response.sendRedirect(shortURL[0].getUrlLink());
}
}
catch (Exception e)
{
LogMgr.log(LOG, LogLevel.BUSINESS2, e, "Problem find the shorted url");
throw new BusinessException("Something went wrong. Please contact Admin");
}
}
config.forwardRequest(request, response);
}
@Override
public void init(ParticipantInitialisationContext context) throws InitialisationException
{
}
}
\ No newline at end of file
......@@ -1467,23 +1467,33 @@ span.rate-label {
margin-right: 8px;
}
.share-link {
width: 30.578%;
width: 40%;
background: url(../images/link-icon.png) no-repeat ;
height: 100px;
text-align: left;
background-position: left 20px center;
padding: 30px 0 20px 60px;
}
.copy-link{
font-size: 11px;
color: #9b9b9b;
}
.share-btn {
width: 13.002%;
width: 12%;
background-color: #efefef;
}
.linkdin-icon {
width: 13.6%;
width: 12%;
}
.facebook-icon {
width: 13.73%;
width: 12%;
}
.shape-icon{
width: 14.73%;
width: 12%;
}
.more-icon {
width: 14.3%;
width: 12%;
}
.goto-job-btn{
display: inline-block;
......
<?xml version="1.0"?>
<OBJECTS name="AdminPortal">
<NODE name="DecoratorFilter::performa">
<DECORATOR factory="Participant" class="performa.utils.ShortenedURLDecorator"/>
</NODE>
<NODE name="dynamic_content_form_client" factory="Participant">
<INHERITS factory="Named" nodename="dynamic_content_form"/>
......
......@@ -128,6 +128,15 @@
</TASK>
<TASK factory="Participant" class="oneit.appservices.batch.DefaultTask" lockName="performa">
<RUN class="performa.batch.URLShortnerBatch" factory="Participant"/>
<WHEN factory="MetaComponent" component="BatchSchedule" selector="performa.runbatch">
<NODE name="schedule" class="oneit.appservices.batch.NeverSchedule">
</NODE>
</WHEN>
</TASK>
</NODE>
......
......@@ -13,8 +13,9 @@
Debug.assertion(job != null, "Job is null in admin portal create job");
String url = LoopbackHTTP.getRemoteAccessURL("/ApplicantPortal-ApplyJob.htm?" + "id=" + job.getID() + "&key=" + job.getRandomKey());
String nextPage = WebUtils.getSamePageInRenderMode(request, WebUtils.VIEW_APPLICANTS);
String url = job.getShortenedUrlLink();
boolean fromJob = request.getParameter("fromJob") != null ? Boolean.parseBoolean(request.getParameter("fromJob")) : false;
String nextPage = WebUtils.getSamePageInRenderMode(request, (fromJob ? "Page" : WebUtils.VIEW_APPLICANTS));
%>
<script>
......@@ -43,7 +44,12 @@
<div class="form-page-area">
<div class="job-share-icon">
<ul>
<li class="share-link" onclick="copyToClipboard()"><a href="#"><img src="images/link-icon.png" /> Copy link to clipboard</a></li>
<li class="share-link" onclick="copyToClipboard()">
<a class="linked-col" href="#">
<div><%= url %></div>
<span class="copy-link">(Copy link to clipboard)</span>
</a>
</li>
<li class="share-btn"><a href="#">Share</a></li>
<li class="linkdin-icon"><a href="#"><img src="images/linkedin-icon.png" /></a></li>
<li class="facebook-icon"><a href="#"><img src="images/facebook-icon.png"/></a></li>
......@@ -55,11 +61,15 @@
This job will be open for 30 days until&nbsp;<oneit:toString value="<%= job.getApplyBy() %>" mode="PerformaDate"/>.
</p>
<div class="text-center">
<oneit:button value="Go to Job" name="gotoPage" cssClass="btn btn-primary largeBtn"
<oneit:button value="<%= "Go to Job" + (fromJob ? "s" : "")%>" name="gotoPage" cssClass="btn btn-primary largeBtn"
requestAttribs='<%= CollectionUtils.mapEntry("nextPage", nextPage).toMap() %>'/>
</div>
<div class="space-55"></div>
</div>
</div>
<style>
.job-share-icon li a.linked-col {line-height: 20px;}
</style>
</oneit:form>
</oneit:dynIncluded>
......@@ -6,11 +6,12 @@
<oneit:dynIncluded>
<%
Job job = (Job) process.getAttribute("Job");
String nextPage = WebUtils.getSamePageInRenderMode(request, WebUtils.CREATED_JOB);
String nextPage = WebUtils.getSamePageInRenderMode(request, WebUtils.CREATED_JOB) + "&fromJob=true";
String firstPage = WebUtils.getSamePageInRenderMode(request, WebUtils.CREATE_JOB);
String secondPage = WebUtils.getSamePageInRenderMode(request, WebUtils.ASSESSMENT_CRITERIA);
String thirdPage = WebUtils.getSamePageInRenderMode(request, WebUtils.WORKPLACE_CULTURE);
String fourthPage = WebUtils.getSamePageInRenderMode(request, WebUtils.JOB_MATCH);
String fifthPage = WebUtils.getSamePageInRenderMode(request, WebUtils.JOB_REVIEW);
Article jobsArticle = WebUtils.getArticleByShortCut(transaction, WebUtils.JOBS);
String jobsPage = jobsArticle.getLink(request, CollectionUtils.mapEntry("cms.rm", WebUtils.VIEW_APPLICANTS).toMap());
......@@ -214,6 +215,7 @@
<oneit:button value="Open this job" name="saveJob" cssClass="btn btn-primary btn-green top-margin-25 largeBtn"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
.mapEntry ("fromPage", fifthPage)
.mapEntry ("restartProcess", Boolean.TRUE)
.mapEntry ("attribNamesToRestore", Collections.singleton("Job"))
.toMap() %>" />
......
<?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="shortened_url_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.DefineTableOperation">
<tableName factory="String">tl_shortened_url</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="code" type="String" nullable="false" length="8"/>
<column name="url_link" type="CLOB" nullable="false"/>
</NODE>
</NODE>
</OBJECTS>
\ No newline at end of file
Run URLShortnerBatch - this will add URL shortner to existing jobs.
\ 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