Commit 0bad6dee by Nilu

moving roles of users to hiring team level.

parent e9e5f289
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<column name="object_id" type="Long" nullable="false" length="11"/> <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_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/> <column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="role_type" type="String" nullable="true" length="200"/>
<column name="hiring_team_id" type="Long" length="11" nullable="true"/> <column name="hiring_team_id" type="Long" length="11" nullable="true"/>
<column name="company_user_id" type="Long" length="11" nullable="true"/> <column name="company_user_id" type="Long" length="11" nullable="true"/>
</NODE> </NODE>
......
...@@ -8,6 +8,7 @@ CREATE TABLE tl_company_user_hiring_team_link ( ...@@ -8,6 +8,7 @@ CREATE TABLE tl_company_user_hiring_team_link (
object_last_updated_date datetime DEFAULT getdate() NOT NULL , object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL object_created_date datetime DEFAULT getdate() NOT NULL
, ,
role_type varchar(200) NULL,
hiring_team_id numeric(12) NULL, hiring_team_id numeric(12) NULL,
company_user_id numeric(12) NULL company_user_id numeric(12) NULL
); );
......
...@@ -9,6 +9,7 @@ CREATE TABLE tl_company_user_hiring_team_link ( ...@@ -9,6 +9,7 @@ CREATE TABLE tl_company_user_hiring_team_link (
object_last_updated_date date DEFAULT SYSDATE NOT NULL , object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL object_created_date date DEFAULT SYSDATE NOT NULL
, ,
role_type varchar2(200) NULL,
hiring_team_id number(12) NULL, hiring_team_id number(12) NULL,
company_user_id number(12) NULL company_user_id number(12) NULL
); );
......
...@@ -9,6 +9,7 @@ CREATE TABLE tl_company_user_hiring_team_link ( ...@@ -9,6 +9,7 @@ CREATE TABLE tl_company_user_hiring_team_link (
object_last_updated_date timestamp DEFAULT NOW() NOT NULL , object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL object_created_date timestamp DEFAULT NOW() NOT NULL
, ,
role_type varchar(200) NULL,
hiring_team_id numeric(12) NULL, hiring_team_id numeric(12) NULL,
company_user_id numeric(12) NULL company_user_id numeric(12) NULL
); );
......
...@@ -15,6 +15,7 @@ import oneit.servlets.process.SaveFP; ...@@ -15,6 +15,7 @@ import oneit.servlets.process.SaveFP;
import oneit.utils.BusinessException; import oneit.utils.BusinessException;
import oneit.utils.MultiException; import oneit.utils.MultiException;
import performa.orm.Company; import performa.orm.Company;
import performa.orm.CompanyUserHiringTeamLink;
import performa.orm.HiringTeam; import performa.orm.HiringTeam;
import performa.utils.StripeUtils; import performa.utils.StripeUtils;
...@@ -56,6 +57,11 @@ public class AddHiringTeamFP extends SaveFP ...@@ -56,6 +57,11 @@ public class AddHiringTeamFP extends SaveFP
hiringTeam.setCompany(company); hiringTeam.setCompany(company);
hiringTeam.setManageOwnBilling(company.getManageOwnBilling()); hiringTeam.setManageOwnBilling(company.getManageOwnBilling());
CompanyUserHiringTeamLink link = CompanyUserHiringTeamLink.createCompanyUserHiringTeamLink(objTran);
link.setCompanyUser(company.getOwner());
link.setHiringTeam(hiringTeam);
if(hiringTeam.getManageOwnBilling()) if(hiringTeam.getManageOwnBilling())
{ {
hiringTeam.setBilledByTeam(null); hiringTeam.setBilledByTeam(null);
......
...@@ -26,6 +26,8 @@ import oneit.utils.filter.Filter; ...@@ -26,6 +26,8 @@ import oneit.utils.filter.Filter;
import oneit.utils.transform.*; import oneit.utils.transform.*;
import oneit.utils.parsers.FieldException; import oneit.utils.parsers.FieldException;
import performa.orm.types.*;
public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass
...@@ -38,6 +40,7 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass ...@@ -38,6 +40,7 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass
// Static constants corresponding to field names // Static constants corresponding to field names
public static final String FIELD_Role = "Role";
public static final String SINGLEREFERENCE_HiringTeam = "HiringTeam"; public static final String SINGLEREFERENCE_HiringTeam = "HiringTeam";
public static final String BACKREF_HiringTeam = ""; public static final String BACKREF_HiringTeam = "";
public static final String SINGLEREFERENCE_CompanyUser = "CompanyUser"; public static final String SINGLEREFERENCE_CompanyUser = "CompanyUser";
...@@ -48,9 +51,11 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass ...@@ -48,9 +51,11 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass
// Static constants corresponding to attribute helpers // Static constants corresponding to attribute helpers
private static final EnumeratedAttributeHelper<CompanyUserHiringTeamLink, RoleType> HELPER_Role = new EnumeratedAttributeHelper<CompanyUserHiringTeamLink, RoleType> (RoleType.FACTORY_RoleType);
// Private attributes corresponding to business object data // Private attributes corresponding to business object data
private RoleType _Role;
// Private attributes corresponding to single references // Private attributes corresponding to single references
...@@ -65,6 +70,7 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass ...@@ -65,6 +70,7 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass
private static final Map ATTRIBUTES_METADATA_CompanyUserHiringTeamLink = new HashMap (); private static final Map ATTRIBUTES_METADATA_CompanyUserHiringTeamLink = new HashMap ();
// Arrays of validators for each attribute // Arrays of validators for each attribute
private static final AttributeValidator[] FIELD_Role_Validators;
// Arrays of behaviour decorators // Arrays of behaviour decorators
...@@ -82,6 +88,7 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass ...@@ -82,6 +88,7 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass
setupAssocMetaData_HiringTeam(); setupAssocMetaData_HiringTeam();
setupAssocMetaData_CompanyUser(); setupAssocMetaData_CompanyUser();
FIELD_Role_Validators = (AttributeValidator[])setupAttribMetaData_Role(validatorMapping).toArray (new AttributeValidator[0]);
REFERENCE_CompanyUserHiringTeamLink.initialiseReference (); REFERENCE_CompanyUserHiringTeamLink.initialiseReference ();
...@@ -126,6 +133,26 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass ...@@ -126,6 +133,26 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass
} }
// 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 CompanyUserHiringTeamLink.Role:", metaInfo);
ATTRIBUTES_METADATA_CompanyUserHiringTeamLink.put (FIELD_Role, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(CompanyUserHiringTeamLink.class, "Role", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for CompanyUserHiringTeamLink.Role:", validators);
return validators;
}
// END OF STATIC METADATA DEFINITION // END OF STATIC METADATA DEFINITION
...@@ -153,6 +180,7 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass ...@@ -153,6 +180,7 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass
super._initialiseNewObjAttributes (transaction); super._initialiseNewObjAttributes (transaction);
_Role = (RoleType)(HELPER_Role.initialise (_Role));
} }
...@@ -181,6 +209,104 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass ...@@ -181,6 +209,104 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass
/**
* Get the attribute Role
*/
public RoleType getRole ()
{
assertValid();
RoleType valToReturn = _Role;
for (CompanyUserHiringTeamLinkBehaviourDecorator bhd : CompanyUserHiringTeamLink_BehaviourDecorators)
{
valToReturn = bhd.getRole ((CompanyUserHiringTeamLink)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 (CompanyUserHiringTeamLinkBehaviourDecorator bhd : CompanyUserHiringTeamLink_BehaviourDecorators)
{
newRole = bhd.setRole ((CompanyUserHiringTeamLink)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_CompanyUserHiringTeamLink.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 ();
}
}
/** /**
...@@ -721,6 +847,7 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass ...@@ -721,6 +847,7 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass
PersistentSet tl_company_user_hiring_team_linkPSet = allSets.getPersistentSet (myID, "tl_company_user_hiring_team_link", myPSetStatus); PersistentSet tl_company_user_hiring_team_linkPSet = allSets.getPersistentSet (myID, "tl_company_user_hiring_team_link", myPSetStatus);
tl_company_user_hiring_team_linkPSet.setAttrib (FIELD_ObjectID, myID); tl_company_user_hiring_team_linkPSet.setAttrib (FIELD_ObjectID, myID);
tl_company_user_hiring_team_linkPSet.setAttrib (FIELD_Role, HELPER_Role.toObject (_Role)); //
_HiringTeam.getPersistentSets (allSets); _HiringTeam.getPersistentSets (allSets);
_CompanyUser.getPersistentSets (allSets); _CompanyUser.getPersistentSets (allSets);
...@@ -737,6 +864,7 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass ...@@ -737,6 +864,7 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass
PersistentSet tl_company_user_hiring_team_linkPSet = allSets.getPersistentSet (objectID, "tl_company_user_hiring_team_link"); PersistentSet tl_company_user_hiring_team_linkPSet = allSets.getPersistentSet (objectID, "tl_company_user_hiring_team_link");
_Role = (RoleType)(HELPER_Role.fromObject (_Role, tl_company_user_hiring_team_linkPSet.getAttrib (FIELD_Role))); //
_HiringTeam.setFromPersistentSets (objectID, allSets); _HiringTeam.setFromPersistentSets (objectID, allSets);
_CompanyUser.setFromPersistentSets (objectID, allSets); _CompanyUser.setFromPersistentSets (objectID, allSets);
...@@ -754,6 +882,15 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass ...@@ -754,6 +882,15 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass
{ {
CompanyUserHiringTeamLink otherCompanyUserHiringTeamLink = (CompanyUserHiringTeamLink)other; CompanyUserHiringTeamLink otherCompanyUserHiringTeamLink = (CompanyUserHiringTeamLink)other;
try
{
setRole (otherCompanyUserHiringTeamLink.getRole ());
}
catch (FieldException ex)
{
e.addException (ex);
}
} }
} }
...@@ -769,6 +906,7 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass ...@@ -769,6 +906,7 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass
{ {
BaseCompanyUserHiringTeamLink sourceCompanyUserHiringTeamLink = (BaseCompanyUserHiringTeamLink)(source); BaseCompanyUserHiringTeamLink sourceCompanyUserHiringTeamLink = (BaseCompanyUserHiringTeamLink)(source);
_Role = sourceCompanyUserHiringTeamLink._Role;
} }
} }
...@@ -823,6 +961,7 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass ...@@ -823,6 +961,7 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass
{ {
super.readExternalData(vals); super.readExternalData(vals);
_Role = (RoleType)(HELPER_Role.readExternal (_Role, vals.get(FIELD_Role))); //
_HiringTeam.readExternalData(vals.get(SINGLEREFERENCE_HiringTeam)); _HiringTeam.readExternalData(vals.get(SINGLEREFERENCE_HiringTeam));
_CompanyUser.readExternalData(vals.get(SINGLEREFERENCE_CompanyUser)); _CompanyUser.readExternalData(vals.get(SINGLEREFERENCE_CompanyUser));
...@@ -836,6 +975,7 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass ...@@ -836,6 +975,7 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass
{ {
super.writeExternalData(vals); super.writeExternalData(vals);
vals.put (FIELD_Role, HELPER_Role.writeExternal (_Role));
vals.put (SINGLEREFERENCE_HiringTeam, _HiringTeam.writeExternalData()); vals.put (SINGLEREFERENCE_HiringTeam, _HiringTeam.writeExternalData());
vals.put (SINGLEREFERENCE_CompanyUser, _CompanyUser.writeExternalData()); vals.put (SINGLEREFERENCE_CompanyUser, _CompanyUser.writeExternalData());
...@@ -851,6 +991,10 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass ...@@ -851,6 +991,10 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass
BaseCompanyUserHiringTeamLink otherCompanyUserHiringTeamLink = (BaseCompanyUserHiringTeamLink)(other); BaseCompanyUserHiringTeamLink otherCompanyUserHiringTeamLink = (BaseCompanyUserHiringTeamLink)(other);
if (!HELPER_Role.compare(this._Role, otherCompanyUserHiringTeamLink._Role))
{
listener.notifyFieldChange(this, other, FIELD_Role, HELPER_Role.toObject(this._Role), HELPER_Role.toObject(otherCompanyUserHiringTeamLink._Role));
}
// Compare single assocs // Compare single assocs
_HiringTeam.compare (otherCompanyUserHiringTeamLink._HiringTeam, listener); _HiringTeam.compare (otherCompanyUserHiringTeamLink._HiringTeam, listener);
...@@ -875,6 +1019,7 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass ...@@ -875,6 +1019,7 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass
{ {
super.visitAttributes (visitor); super.visitAttributes (visitor);
visitor.visitField(this, FIELD_Role, HELPER_Role.toObject(getRole()));
visitor.visitAssociation (_HiringTeam); visitor.visitAssociation (_HiringTeam);
visitor.visitAssociation (_CompanyUser); visitor.visitAssociation (_CompanyUser);
...@@ -918,6 +1063,10 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass ...@@ -918,6 +1063,10 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass
{ {
throw new RuntimeException ("Game over man!!"); throw new RuntimeException ("Game over man!!");
} }
else if (attribName.equals (FIELD_Role))
{
return filter.matches (getRole ());
}
else if (attribName.equals (SINGLEREFERENCE_HiringTeam)) else if (attribName.equals (SINGLEREFERENCE_HiringTeam))
{ {
return filter.matches (getHiringTeam ()); return filter.matches (getHiringTeam ());
...@@ -957,6 +1106,12 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass ...@@ -957,6 +1106,12 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass
} }
public SearchAll andRole (QueryFilter<RoleType> filter)
{
filter.addFilter (context, "tl_company_user_hiring_team_link.role_type", "Role");
return this;
}
public SearchAll andHiringTeam (QueryFilter<HiringTeam> filter) public SearchAll andHiringTeam (QueryFilter<HiringTeam> filter)
{ {
filter.addFilter (context, "tl_company_user_hiring_team_link.hiring_team_id", "HiringTeam"); filter.addFilter (context, "tl_company_user_hiring_team_link.hiring_team_id", "HiringTeam");
...@@ -1004,6 +1159,10 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass ...@@ -1004,6 +1159,10 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass
{ {
throw new RuntimeException ("Game over man!!"); throw new RuntimeException ("Game over man!!");
} }
else if (attribName.equals (FIELD_Role))
{
return HELPER_Role.toObject (getRole ());
}
else else
{ {
return super.getAttribute (attribName); return super.getAttribute (attribName);
...@@ -1017,6 +1176,10 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass ...@@ -1017,6 +1176,10 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass
{ {
throw new RuntimeException ("Game over man!!"); throw new RuntimeException ("Game over man!!");
} }
else if (attribName.equals (FIELD_Role))
{
return HELPER_Role;
}
else else
{ {
return super.getAttributeHelper (attribName); return super.getAttributeHelper (attribName);
...@@ -1030,6 +1193,10 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass ...@@ -1030,6 +1193,10 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass
{ {
throw new RuntimeException ("Game over man!!"); throw new RuntimeException ("Game over man!!");
} }
else if (attribName.equals (FIELD_Role))
{
setRole ((RoleType)(HELPER_Role.fromObject (_Role, attribValue)));
}
else else
{ {
super.setAttribute (attribName, attribValue); super.setAttribute (attribName, attribValue);
...@@ -1050,6 +1217,10 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass ...@@ -1050,6 +1217,10 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass
{ {
throw new RuntimeException ("Game over man!!"); throw new RuntimeException ("Game over man!!");
} }
else if (fieldName.equals (FIELD_Role))
{
return getWriteability_Role ();
}
else if (fieldName.equals (SINGLEREFERENCE_HiringTeam)) else if (fieldName.equals (SINGLEREFERENCE_HiringTeam))
{ {
return getWriteability_HiringTeam (); return getWriteability_HiringTeam ();
...@@ -1068,6 +1239,11 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass ...@@ -1068,6 +1239,11 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass
public void putUnwriteable (Set<String> fields) public void putUnwriteable (Set<String> fields)
{ {
if (getWriteability_Role () != FieldWriteability.TRUE)
{
fields.add (FIELD_Role);
}
super.putUnwriteable (fields); super.putUnwriteable (fields);
} }
...@@ -1077,6 +1253,7 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass ...@@ -1077,6 +1253,7 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass
List result = super.getAttributes (); List result = super.getAttributes ();
result.add(HELPER_Role.getAttribObject (getClass (), _Role, false, FIELD_Role));
return result; return result;
} }
...@@ -1127,6 +1304,24 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass ...@@ -1127,6 +1304,24 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass
public static class CompanyUserHiringTeamLinkBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<CompanyUserHiringTeamLink> public static class CompanyUserHiringTeamLinkBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<CompanyUserHiringTeamLink>
{ {
/**
* Get the attribute Role
*/
public RoleType getRole (CompanyUserHiringTeamLink obj, RoleType original)
{
return original;
}
/**
* Change the value set for attribute Role.
* May modify the field beforehand
* Occurs before validation.
*/
public RoleType setRole (CompanyUserHiringTeamLink obj, RoleType newRole) throws FieldException
{
return newRole;
}
} }
...@@ -1179,6 +1374,10 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass ...@@ -1179,6 +1374,10 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass
public PipeLine<From, ? extends Object> to(String name) public PipeLine<From, ? extends Object> to(String name)
{ {
if (name.equals ("Role"))
{
return toRole ();
}
if (name.equals ("HiringTeam")) if (name.equals ("HiringTeam"))
{ {
return toHiringTeam (); return toHiringTeam ();
...@@ -1192,6 +1391,8 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass ...@@ -1192,6 +1391,8 @@ public abstract class BaseCompanyUserHiringTeamLink extends BaseBusinessClass
return super.to(name); return super.to(name);
} }
public PipeLine<From, RoleType> toRole () { return pipe(new ORMAttributePipe<Me, RoleType>(FIELD_Role)); }
public HiringTeam.HiringTeamPipeLineFactory<From, HiringTeam> toHiringTeam () { return toHiringTeam (Filter.ALL); } public HiringTeam.HiringTeamPipeLineFactory<From, HiringTeam> toHiringTeam () { return toHiringTeam (Filter.ALL); }
public HiringTeam.HiringTeamPipeLineFactory<From, HiringTeam> toHiringTeam (Filter<HiringTeam> filter) public HiringTeam.HiringTeamPipeLineFactory<From, HiringTeam> toHiringTeam (Filter<HiringTeam> filter)
......
...@@ -8,6 +8,7 @@ import oneit.logging.LogLevel; ...@@ -8,6 +8,7 @@ import oneit.logging.LogLevel;
import oneit.logging.LogMgr; import oneit.logging.LogMgr;
import oneit.logging.LoggingArea; import oneit.logging.LoggingArea;
import oneit.objstore.*; import oneit.objstore.*;
import oneit.objstore.rdbms.filters.EqualsFilter;
import oneit.security.SecUser; import oneit.security.SecUser;
import oneit.security.jsp.SecUserToNameTransform; import oneit.security.jsp.SecUserToNameTransform;
import oneit.utils.*; import oneit.utils.*;
......
...@@ -4,8 +4,12 @@ ...@@ -4,8 +4,12 @@
<BUSINESSCLASS name="CompanyUserHiringTeamLink" package="performa.orm"> <BUSINESSCLASS name="CompanyUserHiringTeamLink" package="performa.orm">
<IMPORT value="performa.orm.types.*"/>
<TABLE name="tl_company_user_hiring_team_link" tablePrefix="object"> <TABLE name="tl_company_user_hiring_team_link" tablePrefix="object">
<ATTRIB name="Role" type="RoleType" dbcol="role_type" mandatory="false" attribHelper="EnumeratedAttributeHelper"/>
<SINGLEREFERENCE name="HiringTeam" type="HiringTeam" dbcol="hiring_team_id" backreferenceName="Users" /> <SINGLEREFERENCE name="HiringTeam" type="HiringTeam" dbcol="hiring_team_id" backreferenceName="Users" />
<SINGLEREFERENCE name="CompanyUser" type="CompanyUser" dbcol="company_user_id" backreferenceName="HiringTeams" /> <SINGLEREFERENCE name="CompanyUser" type="CompanyUser" dbcol="company_user_id" backreferenceName="HiringTeams" />
......
...@@ -14,6 +14,7 @@ import oneit.sql.*; ...@@ -14,6 +14,7 @@ import oneit.sql.*;
import oneit.utils.resource.*; import oneit.utils.resource.*;
import oneit.utils.*; import oneit.utils.*;
import oneit.utils.threading.*; import oneit.utils.threading.*;
import performa.orm.types.*;
...@@ -26,19 +27,22 @@ public class CompanyUserHiringTeamLinkPersistenceMgr extends ObjectPersistenceMg ...@@ -26,19 +27,22 @@ public class CompanyUserHiringTeamLinkPersistenceMgr extends ObjectPersistenceMg
private static final LoggingArea CompanyUserHiringTeamLinkPersistence = LoggingArea.createLoggingArea(ObjectPersistenceMgr.OBJECT_PERSISTENCE, "CompanyUserHiringTeamLink"); private static final LoggingArea CompanyUserHiringTeamLinkPersistence = LoggingArea.createLoggingArea(ObjectPersistenceMgr.OBJECT_PERSISTENCE, "CompanyUserHiringTeamLink");
// Private attributes corresponding to business object data // Private attributes corresponding to business object data
private RoleType dummyRole;
// Static constants corresponding to attribute helpers // Static constants corresponding to attribute helpers
private static final EnumeratedAttributeHelper HELPER_Role = new EnumeratedAttributeHelper (RoleType.FACTORY_RoleType);
public CompanyUserHiringTeamLinkPersistenceMgr () public CompanyUserHiringTeamLinkPersistenceMgr ()
{ {
dummyRole = (RoleType)(HELPER_Role.initialise (dummyRole));
} }
private String SELECT_COLUMNS = "{PREFIX}tl_company_user_hiring_team_link.object_id as id, {PREFIX}tl_company_user_hiring_team_link.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_company_user_hiring_team_link.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_company_user_hiring_team_link.hiring_team_id, {PREFIX}tl_company_user_hiring_team_link.company_user_id, 1 AS commasafe "; private String SELECT_COLUMNS = "{PREFIX}tl_company_user_hiring_team_link.object_id as id, {PREFIX}tl_company_user_hiring_team_link.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_company_user_hiring_team_link.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_company_user_hiring_team_link.role_type, {PREFIX}tl_company_user_hiring_team_link.hiring_team_id, {PREFIX}tl_company_user_hiring_team_link.company_user_id, 1 AS commasafe ";
private String SELECT_JOINS = ""; private String SELECT_JOINS = "";
public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
...@@ -89,6 +93,7 @@ public class CompanyUserHiringTeamLinkPersistenceMgr extends ObjectPersistenceMg ...@@ -89,6 +93,7 @@ public class CompanyUserHiringTeamLinkPersistenceMgr extends ObjectPersistenceMg
// Check for persistent sets already prefetched // Check for persistent sets already prefetched
if (false || !tl_company_user_hiring_team_linkPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) || if (false || !tl_company_user_hiring_team_linkPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!tl_company_user_hiring_team_linkPSet.containsAttrib(CompanyUserHiringTeamLink.FIELD_Role)||
!tl_company_user_hiring_team_linkPSet.containsAttrib(CompanyUserHiringTeamLink.SINGLEREFERENCE_HiringTeam)|| !tl_company_user_hiring_team_linkPSet.containsAttrib(CompanyUserHiringTeamLink.SINGLEREFERENCE_HiringTeam)||
!tl_company_user_hiring_team_linkPSet.containsAttrib(CompanyUserHiringTeamLink.SINGLEREFERENCE_CompanyUser)) !tl_company_user_hiring_team_linkPSet.containsAttrib(CompanyUserHiringTeamLink.SINGLEREFERENCE_CompanyUser))
{ {
...@@ -180,10 +185,10 @@ public class CompanyUserHiringTeamLinkPersistenceMgr extends ObjectPersistenceMg ...@@ -180,10 +185,10 @@ public class CompanyUserHiringTeamLinkPersistenceMgr extends ObjectPersistenceMg
{ {
int rowsUpdated = executeStatement (sqlMgr, int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}tl_company_user_hiring_team_link " + "UPDATE {PREFIX}tl_company_user_hiring_team_link " +
"SET hiring_team_id = ? , company_user_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " + "SET role_type = ?, hiring_team_id = ? , company_user_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE tl_company_user_hiring_team_link.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ", "WHERE tl_company_user_hiring_team_link.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (SQLManager.CheckNull((Long)(tl_company_user_hiring_team_linkPSet.getAttrib (CompanyUserHiringTeamLink.SINGLEREFERENCE_HiringTeam)))).listEntry (SQLManager.CheckNull((Long)(tl_company_user_hiring_team_linkPSet.getAttrib (CompanyUserHiringTeamLink.SINGLEREFERENCE_CompanyUser)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray()); CollectionUtils.listEntry (HELPER_Role.getForSQL(dummyRole, tl_company_user_hiring_team_linkPSet.getAttrib (CompanyUserHiringTeamLink.FIELD_Role))).listEntry (SQLManager.CheckNull((Long)(tl_company_user_hiring_team_linkPSet.getAttrib (CompanyUserHiringTeamLink.SINGLEREFERENCE_HiringTeam)))).listEntry (SQLManager.CheckNull((Long)(tl_company_user_hiring_team_linkPSet.getAttrib (CompanyUserHiringTeamLink.SINGLEREFERENCE_CompanyUser)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1) if (rowsUpdated != 1)
{ {
...@@ -439,6 +444,7 @@ public class CompanyUserHiringTeamLinkPersistenceMgr extends ObjectPersistenceMg ...@@ -439,6 +444,7 @@ public class CompanyUserHiringTeamLinkPersistenceMgr extends ObjectPersistenceMg
// Object Created // Object Created
tl_company_user_hiring_team_linkPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE")); tl_company_user_hiring_team_linkPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
tl_company_user_hiring_team_linkPSet.setAttrib(CompanyUserHiringTeamLink.FIELD_Role, HELPER_Role.getFromRS(dummyRole, r, "role_type"));
tl_company_user_hiring_team_linkPSet.setAttrib(CompanyUserHiringTeamLink.SINGLEREFERENCE_HiringTeam, r.getObject ("hiring_team_id")); tl_company_user_hiring_team_linkPSet.setAttrib(CompanyUserHiringTeamLink.SINGLEREFERENCE_HiringTeam, r.getObject ("hiring_team_id"));
tl_company_user_hiring_team_linkPSet.setAttrib(CompanyUserHiringTeamLink.SINGLEREFERENCE_CompanyUser, r.getObject ("company_user_id")); tl_company_user_hiring_team_linkPSet.setAttrib(CompanyUserHiringTeamLink.SINGLEREFERENCE_CompanyUser, r.getObject ("company_user_id"));
...@@ -458,10 +464,10 @@ public class CompanyUserHiringTeamLinkPersistenceMgr extends ObjectPersistenceMg ...@@ -458,10 +464,10 @@ public class CompanyUserHiringTeamLinkPersistenceMgr extends ObjectPersistenceMg
{ {
executeStatement (sqlMgr, executeStatement (sqlMgr,
"INSERT INTO {PREFIX}tl_company_user_hiring_team_link " + "INSERT INTO {PREFIX}tl_company_user_hiring_team_link " +
" ( hiring_team_id, company_user_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " + " (role_type, hiring_team_id, company_user_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " + "VALUES " +
" ( ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")", " (?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils .listEntry (SQLManager.CheckNull((Long)(tl_company_user_hiring_team_linkPSet.getAttrib (CompanyUserHiringTeamLink.SINGLEREFERENCE_HiringTeam)))).listEntry (SQLManager.CheckNull((Long)(tl_company_user_hiring_team_linkPSet.getAttrib (CompanyUserHiringTeamLink.SINGLEREFERENCE_CompanyUser)))) .listEntry (objectID.longID ()).toList().toArray()); CollectionUtils.listEntry (HELPER_Role.getForSQL(dummyRole, tl_company_user_hiring_team_linkPSet.getAttrib (CompanyUserHiringTeamLink.FIELD_Role))) .listEntry (SQLManager.CheckNull((Long)(tl_company_user_hiring_team_linkPSet.getAttrib (CompanyUserHiringTeamLink.SINGLEREFERENCE_HiringTeam)))).listEntry (SQLManager.CheckNull((Long)(tl_company_user_hiring_team_linkPSet.getAttrib (CompanyUserHiringTeamLink.SINGLEREFERENCE_CompanyUser)))) .listEntry (objectID.longID ()).toList().toArray());
tl_company_user_hiring_team_linkPSet.setStatus (PersistentSetStatus.PROCESSED); tl_company_user_hiring_team_linkPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
process.setAttribute("UserSortOption", userSortOpt); process.setAttribute("UserSortOption", userSortOpt);
Collection<HiringTeam> sortedHiringTeams = Utils.getHiringTeamsSorted(company.getHiringTeamsSet(), userSortOpt); Collection<HiringTeam> sortedHiringTeams = Utils.getHiringTeamsSorted(Arrays.asList(Utils.getHiringTeamsByUser(comUser)), userSortOpt);
%> %>
<oneit:form name="listHiringTeams" method="post" enctype="multipart/form-data"> <oneit:form name="listHiringTeams" method="post" enctype="multipart/form-data">
......
...@@ -141,6 +141,9 @@ ...@@ -141,6 +141,9 @@
for(CompanyUser companyUser : sortedCompanyUsers) for(CompanyUser companyUser : sortedCompanyUsers)
{ {
SecUser user = companyUser.getUser(); SecUser user = companyUser.getUser();
oneit.utils.filter.Filter<CompanyUserHiringTeamLink> filter = CompanyUserHiringTeamLink.SearchByAll().andHiringTeam(new EqualsFilter<>(hiringTeam));
CompanyUserHiringTeamLink link = companyUser.pipelineCompanyUser().toHiringTeams(filter).val();
%> %>
<div class="user-list-row" id="<%= companyUser.getID() %>"> <div class="user-list-row" id="<%= companyUser.getID() %>">
<div class="m-user-left"> <div class="m-user-left">
...@@ -188,7 +191,7 @@ ...@@ -188,7 +191,7 @@
</div> </div>
<div class="m-user-right"> <div class="m-user-right">
<oneit:ormEnum obj="<%= companyUser %>" attributeName="Role" cssClass="form-control user-role" enums="<%= Arrays.asList(new RoleType[]{RoleType.ADMIN, RoleType.STANDARD}) %>"/> <oneit:ormEnum obj="<%= link %>" attributeName="Role" cssClass="form-control user-role" enums="<%= Arrays.asList(new RoleType[]{RoleType.ADMIN, RoleType.STANDARD, RoleType.OWNER}) %>"/>
</div> </div>
<oneit:button name="save" value="Save" cssClass="<%= "save-user" + companyUser.getID().toString() + " hidden"%>" <oneit:button name="save" value="Save" cssClass="<%= "save-user" + companyUser.getID().toString() + " hidden"%>"
...@@ -253,6 +256,9 @@ ...@@ -253,6 +256,9 @@
for(CompanyUser companyUser : sortedDisabledUsers) for(CompanyUser companyUser : sortedDisabledUsers)
{ {
SecUser user = companyUser.getUser(); SecUser user = companyUser.getUser();
oneit.utils.filter.Filter<CompanyUserHiringTeamLink> filter = CompanyUserHiringTeamLink.SearchByAll().andHiringTeam(new EqualsFilter<>(hiringTeam));
CompanyUserHiringTeamLink link = companyUser.pipelineCompanyUser().toHiringTeams(filter).val();
%> %>
<div class="user-list-row disabled" id="<%= companyUser.getID() %>"> <div class="user-list-row disabled" id="<%= companyUser.getID() %>">
<div class="m-user-left"> <div class="m-user-left">
...@@ -279,7 +285,7 @@ ...@@ -279,7 +285,7 @@
</oneit:button> </oneit:button>
</div> </div>
<div class="m-user-right"> <div class="m-user-right">
<oneit:ormEnum obj="<%= companyUser %>" attributeName="Role" cssClass="form-control user-role" enums="<%= Arrays.asList(new RoleType[]{RoleType.ADMIN, RoleType.STANDARD}) %>"/> <oneit:ormEnum obj="<%= link %>" attributeName="Role" cssClass="form-control user-role" enums="<%= Arrays.asList(new RoleType[]{RoleType.ADMIN, RoleType.STANDARD}) %>"/>
</div> </div>
......
<?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_company_user_hiring_team_link</tableName>
<column name="role_type" type="String" nullable="true" length="200"/>
</NODE>
</NODE>
</OBJECTS>
\ No newline at end of file
UPDATE tl_company_user_hiring_team_link
SET role_type= oneit_sec_user_extension.role_type
FROM oneit_sec_user_extension
WHERE tl_company_user_hiring_team_link.company_user_id = oneit_sec_user_extension.object_id;
\ 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