Commit 0466906a by chenith

J006 updated.

parent 62614537
......@@ -26,9 +26,12 @@ public class SaveJobFP extends SaveFP
@Override
public SuccessfulResult processForm(ORMProcessState process, SubmissionDetails submission, Map params) throws BusinessException, StorageException
{
HttpServletRequest request = submission.getRequest();
Job job = process.getAttribute("Job") != null ? (Job) process.getAttribute("Job") : (Job) request.getAttribute("Job");
JobStatus status = (JobStatus) request.getAttribute("JobStatus");
HttpServletRequest request = submission.getRequest();
Job job = process.getAttribute("Job") != null ? (Job) process.getAttribute("Job") : (Job) request.getAttribute("Job");
JobStatus status = (JobStatus) request.getAttribute("JobStatus");
SecUser secUser = SecUser.getTXUser(process.getTransaction());
CompanyUser companyUser = secUser.getExtension(CompanyUser.REFERENCE_CompanyUser);
Company company = companyUser.getCompany();
LogMgr.log(Job.LOG, LogLevel.PROCESSING1,"In SaveJobFP saving job : ", job );
......@@ -49,6 +52,7 @@ public class SaveJobFP extends SaveFP
if(status == JobStatus.OPEN)
{
job.setJobStatus(status);
company.setPaymentPlan(company.getSelectedPaymentPlan());
LogMgr.log(Job.LOG, LogLevel.PROCESSING1,"Job status changed as Open. ", job );
}
......@@ -67,8 +71,8 @@ public class SaveJobFP extends SaveFP
// restarting process as custom attributes needs to be updated to intercom
completeProcessRestartAndRestoreAttribs(process, request);
SecUser secUser = SecUser.getTXUser(process.getTransaction());
CompanyUser companyUser = secUser.getExtension(CompanyUser.REFERENCE_CompanyUser);
secUser = SecUser.getTXUser(process.getTransaction());
companyUser = secUser.getExtension(CompanyUser.REFERENCE_CompanyUser);
// Update company in intercom
if(companyUser.getCompany() != null)
......
......@@ -63,6 +63,7 @@ public abstract class BaseCompany extends BaseBusinessClass
public static final String FIELD_RoleType = "RoleType";
public static final String FIELD_IsLogoDeleted = "IsLogoDeleted";
public static final String FIELD_CompletedProfile = "CompletedProfile";
public static final String FIELD_PaymentJobCount = "PaymentJobCount";
public static final String SINGLEREFERENCE_AddedByUser = "AddedByUser";
public static final String SINGLEREFERENCE_PaymentPlan = "PaymentPlan";
public static final String MULTIPLEREFERENCE_Users = "Users";
......@@ -94,6 +95,7 @@ public abstract class BaseCompany extends BaseBusinessClass
private static final EnumeratedAttributeHelper<Company, RoleType> HELPER_RoleType = new EnumeratedAttributeHelper<Company, RoleType> (RoleType.FACTORY_RoleType);
private static final DefaultAttributeHelper<Company> HELPER_IsLogoDeleted = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<Company> HELPER_CompletedProfile = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<Company> HELPER_PaymentJobCount = DefaultAttributeHelper.INSTANCE;
// Private attributes corresponding to business object data
......@@ -116,6 +118,7 @@ public abstract class BaseCompany extends BaseBusinessClass
private RoleType _RoleType;
private Boolean _IsLogoDeleted;
private Boolean _CompletedProfile;
private Integer _PaymentJobCount;
// Private attributes corresponding to single references
......@@ -138,6 +141,7 @@ public abstract class BaseCompany extends BaseBusinessClass
private static final AttributeValidator[] FIELD_RoleType_Validators;
private static final AttributeValidator[] FIELD_IsLogoDeleted_Validators;
private static final AttributeValidator[] FIELD_CompletedProfile_Validators;
private static final AttributeValidator[] FIELD_PaymentJobCount_Validators;
private static final AttributeValidator[] FIELD_CompanyName_Validators;
private static final AttributeValidator[] FIELD_CompanyLogo_Validators;
private static final AttributeValidator[] FIELD_HiringTeamType_Validators;
......@@ -176,6 +180,7 @@ public abstract class BaseCompany extends BaseBusinessClass
FIELD_RoleType_Validators = (AttributeValidator[])setupAttribMetaData_RoleType(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_IsLogoDeleted_Validators = (AttributeValidator[])setupAttribMetaData_IsLogoDeleted(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_CompletedProfile_Validators = (AttributeValidator[])setupAttribMetaData_CompletedProfile(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_PaymentJobCount_Validators = (AttributeValidator[])setupAttribMetaData_PaymentJobCount(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_CompanyName_Validators = (AttributeValidator[])setupAttribMetaData_CompanyName(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_CompanyLogo_Validators = (AttributeValidator[])setupAttribMetaData_CompanyLogo(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_HiringTeamType_Validators = (AttributeValidator[])setupAttribMetaData_HiringTeamType(validatorMapping).toArray (new AttributeValidator[0]);
......@@ -368,6 +373,23 @@ public abstract class BaseCompany extends BaseBusinessClass
}
// Meta Info setup
private static List setupAttribMetaData_PaymentJobCount(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("name", "PaymentJobCount");
metaInfo.put ("type", "Integer");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Company.PaymentJobCount:", metaInfo);
ATTRIBUTES_METADATA_Company.put (FIELD_PaymentJobCount, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(Company.class, "PaymentJobCount", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Company.PaymentJobCount:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_CompanyName(Map validatorMapping)
{
Map metaInfo = new HashMap ();
......@@ -674,6 +696,7 @@ public abstract class BaseCompany extends BaseBusinessClass
_RoleType = (RoleType)(RoleType.STANDARD);
_IsLogoDeleted = (Boolean)(Boolean.FALSE);
_CompletedProfile = (Boolean)(Boolean.FALSE);
_PaymentJobCount = (Integer)(HELPER_PaymentJobCount.initialise (_PaymentJobCount));
}
......@@ -2569,6 +2592,104 @@ public abstract class BaseCompany extends BaseBusinessClass
}
}
/**
* Get the attribute PaymentJobCount
*/
public Integer getPaymentJobCount ()
{
assertValid();
Integer valToReturn = _PaymentJobCount;
for (CompanyBehaviourDecorator bhd : Company_BehaviourDecorators)
{
valToReturn = bhd.getPaymentJobCount ((Company)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void prePaymentJobCountChange (Integer newPaymentJobCount) 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 postPaymentJobCountChange () throws FieldException
{
}
public FieldWriteability getWriteability_PaymentJobCount ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute PaymentJobCount. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setPaymentJobCount (Integer newPaymentJobCount) throws FieldException
{
boolean oldAndNewIdentical = HELPER_PaymentJobCount.compare (_PaymentJobCount, newPaymentJobCount);
try
{
for (CompanyBehaviourDecorator bhd : Company_BehaviourDecorators)
{
newPaymentJobCount = bhd.setPaymentJobCount ((Company)this, newPaymentJobCount);
oldAndNewIdentical = HELPER_PaymentJobCount.compare (_PaymentJobCount, newPaymentJobCount);
}
if (FIELD_PaymentJobCount_Validators.length > 0)
{
Object newPaymentJobCountObj = HELPER_PaymentJobCount.toObject (newPaymentJobCount);
if (newPaymentJobCountObj != null)
{
int loopMax = FIELD_PaymentJobCount_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_Company.get (FIELD_PaymentJobCount);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_PaymentJobCount_Validators[v].checkAttribute (this, FIELD_PaymentJobCount, metadata, newPaymentJobCountObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_PaymentJobCount () != FieldWriteability.FALSE, "Field PaymentJobCount is not writeable");
prePaymentJobCountChange (newPaymentJobCount);
markFieldChange (FIELD_PaymentJobCount);
_PaymentJobCount = newPaymentJobCount;
postFieldChange (FIELD_PaymentJobCount);
postPaymentJobCountChange ();
}
}
/**
......@@ -3510,6 +3631,7 @@ public abstract class BaseCompany extends BaseBusinessClass
_RoleType = sourceCompany._RoleType;
_IsLogoDeleted = sourceCompany._IsLogoDeleted;
_CompletedProfile = sourceCompany._CompletedProfile;
_PaymentJobCount = sourceCompany._PaymentJobCount;
}
}
......@@ -3587,6 +3709,7 @@ public abstract class BaseCompany extends BaseBusinessClass
_RoleType = (RoleType)(HELPER_RoleType.readExternal (_RoleType, vals.get(FIELD_RoleType))); //
_IsLogoDeleted = (Boolean)(HELPER_IsLogoDeleted.readExternal (_IsLogoDeleted, vals.get(FIELD_IsLogoDeleted))); //
_CompletedProfile = (Boolean)(HELPER_CompletedProfile.readExternal (_CompletedProfile, vals.get(FIELD_CompletedProfile))); //
_PaymentJobCount = (Integer)(HELPER_PaymentJobCount.readExternal (_PaymentJobCount, vals.get(FIELD_PaymentJobCount))); //
_AddedByUser.readExternalData(vals.get(SINGLEREFERENCE_AddedByUser));
_PaymentPlan.readExternalData(vals.get(SINGLEREFERENCE_PaymentPlan));
_Users.readExternalData(vals.get(MULTIPLEREFERENCE_Users));
......@@ -3621,6 +3744,7 @@ public abstract class BaseCompany extends BaseBusinessClass
vals.put (FIELD_RoleType, HELPER_RoleType.writeExternal (_RoleType));
vals.put (FIELD_IsLogoDeleted, HELPER_IsLogoDeleted.writeExternal (_IsLogoDeleted));
vals.put (FIELD_CompletedProfile, HELPER_CompletedProfile.writeExternal (_CompletedProfile));
vals.put (FIELD_PaymentJobCount, HELPER_PaymentJobCount.writeExternal (_PaymentJobCount));
vals.put (SINGLEREFERENCE_AddedByUser, _AddedByUser.writeExternalData());
vals.put (SINGLEREFERENCE_PaymentPlan, _PaymentPlan.writeExternalData());
vals.put (MULTIPLEREFERENCE_Users, _Users.writeExternalData());
......@@ -3714,6 +3838,7 @@ public abstract class BaseCompany extends BaseBusinessClass
visitor.visitField(this, FIELD_RoleType, HELPER_RoleType.toObject(getRoleType()));
visitor.visitField(this, FIELD_IsLogoDeleted, HELPER_IsLogoDeleted.toObject(getIsLogoDeleted()));
visitor.visitField(this, FIELD_CompletedProfile, HELPER_CompletedProfile.toObject(getCompletedProfile()));
visitor.visitField(this, FIELD_PaymentJobCount, HELPER_PaymentJobCount.toObject(getPaymentJobCount()));
}
......@@ -4080,6 +4205,10 @@ public abstract class BaseCompany extends BaseBusinessClass
{
return HELPER_CompletedProfile.toObject (getCompletedProfile ());
}
else if (attribName.equals (FIELD_PaymentJobCount))
{
return HELPER_PaymentJobCount.toObject (getPaymentJobCount ());
}
else
{
return super.getAttribute (attribName);
......@@ -4169,6 +4298,10 @@ public abstract class BaseCompany extends BaseBusinessClass
{
return HELPER_CompletedProfile;
}
else if (attribName.equals (FIELD_PaymentJobCount))
{
return HELPER_PaymentJobCount;
}
else
{
return super.getAttributeHelper (attribName);
......@@ -4258,6 +4391,10 @@ public abstract class BaseCompany extends BaseBusinessClass
{
setCompletedProfile ((Boolean)(HELPER_CompletedProfile.fromObject (_CompletedProfile, attribValue)));
}
else if (attribName.equals (FIELD_PaymentJobCount))
{
setPaymentJobCount ((Integer)(HELPER_PaymentJobCount.fromObject (_PaymentJobCount, attribValue)));
}
else
{
super.setAttribute (attribName, attribValue);
......@@ -4370,6 +4507,10 @@ public abstract class BaseCompany extends BaseBusinessClass
{
return getWriteability_CompletedProfile ();
}
else if (fieldName.equals (FIELD_PaymentJobCount))
{
return getWriteability_PaymentJobCount ();
}
else
{
return super.getWriteable (fieldName);
......@@ -4475,6 +4616,11 @@ public abstract class BaseCompany extends BaseBusinessClass
fields.add (FIELD_CompletedProfile);
}
if (getWriteability_PaymentJobCount () != FieldWriteability.TRUE)
{
fields.add (FIELD_PaymentJobCount);
}
super.putUnwriteable (fields);
}
......@@ -4503,6 +4649,7 @@ public abstract class BaseCompany extends BaseBusinessClass
result.add(HELPER_RoleType.getAttribObject (getClass (), _RoleType, false, FIELD_RoleType));
result.add(HELPER_IsLogoDeleted.getAttribObject (getClass (), _IsLogoDeleted, false, FIELD_IsLogoDeleted));
result.add(HELPER_CompletedProfile.getAttribObject (getClass (), _CompletedProfile, false, FIELD_CompletedProfile));
result.add(HELPER_PaymentJobCount.getAttribObject (getClass (), _PaymentJobCount, false, FIELD_PaymentJobCount));
return result;
}
......@@ -4913,6 +5060,24 @@ public abstract class BaseCompany extends BaseBusinessClass
return newCompletedProfile;
}
/**
* Get the attribute PaymentJobCount
*/
public Integer getPaymentJobCount (Company obj, Integer original)
{
return original;
}
/**
* Change the value set for attribute PaymentJobCount.
* May modify the field beforehand
* Occurs before validation.
*/
public Integer setPaymentJobCount (Company obj, Integer newPaymentJobCount) throws FieldException
{
return newPaymentJobCount;
}
}
......@@ -4997,6 +5162,10 @@ public abstract class BaseCompany extends BaseBusinessClass
{
return toCompletedProfile ();
}
if (name.equals ("PaymentJobCount"))
{
return toPaymentJobCount ();
}
if (name.equals ("CompanyName"))
{
return toCompanyName ();
......@@ -5075,6 +5244,8 @@ public abstract class BaseCompany extends BaseBusinessClass
public PipeLine<From, Boolean> toCompletedProfile () { return pipe(new ORMAttributePipe<Me, Boolean>(FIELD_CompletedProfile)); }
public PipeLine<From, Integer> toPaymentJobCount () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_PaymentJobCount)); }
public PipeLine<From, String> toCompanyName () { return pipe(new ORMAttributePipe<Me, String>(FIELD_CompanyName)); }
public PipeLine<From, BinaryContent> toCompanyLogo () { return pipe(new ORMAttributePipe<Me, BinaryContent>(FIELD_CompanyLogo)); }
......@@ -5160,6 +5331,11 @@ public abstract class BaseCompany extends BaseBusinessClass
return true;
}
if(CollectionUtils.equals(attribName, "PaymentJobCount"))
{
return true;
}
return super.isTransientAttrib(attribName);
}
......
......@@ -3,6 +3,8 @@ package performa.orm;
import oneit.logging.LoggingArea;
import oneit.objstore.ObjectStatus;
import oneit.objstore.ValidationContext;
import oneit.objstore.rdbms.filters.EqualsFilter;
import oneit.objstore.rdbms.filters.IsNotNullFilter;
import oneit.security.SecUser;
import oneit.utils.CollectionUtils;
import oneit.utils.StringUtils;
......@@ -75,11 +77,29 @@ public class Company extends BaseCompany
}
public PaymentPlan getSelectedPaymentPlan()
{
if(getPaymentJobCount()!=null)
{
PaymentPlan[] plans = PaymentPlan.SearchByAll()
.andActiveJobCount(new EqualsFilter<>(getPaymentJobCount()))
.search(getTransaction());
if(plans.length>0)
{
return plans[0];
}
}
return null;
}
public Double getPaymentPlanAmount()
{
if(getPaymentPlan()!=null)
if(getSelectedPaymentPlan()!=null)
{
return getPaymentPlan().getAmount();
return getSelectedPaymentPlan().getAmount();
}
return null;
......
......@@ -17,6 +17,7 @@
<TRANSIENT name="RoleType" type="RoleType" defaultValue="RoleType.STANDARD" attribHelper="EnumeratedAttributeHelper"/>
<TRANSIENT name="IsLogoDeleted" type="Boolean" defaultValue="Boolean.FALSE"/>
<TRANSIENT name="CompletedProfile" type="Boolean" defaultValue="Boolean.FALSE"/>
<TRANSIENT name="PaymentJobCount" type="Integer"/>
<TABLE name="tl_company" tablePrefix="object">
......
......@@ -519,4 +519,12 @@ public class Utils
return SecUserToNameTransform.INSTANCE.transform(companyUser.getUser());
}
}
public static PaymentPlan[] getPaymentPlansForJobs(ObjectTransaction objTran)
{
return PaymentPlan.SearchByAll()
.andActiveJobCount(new IsNotNullFilter<>())
.search(objTran);
}
}
\ No newline at end of file
......@@ -6043,4 +6043,8 @@ input{
font-family: "Usual-Light";
font-size: 12px;
font-style: italic;
}
.payment-paln-count{
width: 75px;
}
\ No newline at end of file
......@@ -6,10 +6,26 @@
<oneit:dynIncluded>
<%
Job job = (Job) process.getAttribute("Job");
SecUser loggedInUser = SecUser.getTXUser(transaction);
CompanyUser companyUser = loggedInUser.getExtension(CompanyUser.REFERENCE_CompanyUser);
Company company = companyUser.getCompany();
Job job = (Job) process.getAttribute("Job");
SecUser loggedInUser = SecUser.getTXUser(transaction);
CompanyUser companyUser = loggedInUser.getExtension(CompanyUser.REFERENCE_CompanyUser);
Company company = companyUser.getCompany();
PaymentPlan[] plans = Utils.getPaymentPlansForJobs(transaction);
Integer maxCount = 0;
Integer minCount = 0;
Integer curCount = company.getPaymentPlan()!=null ? company.getPaymentPlan().getActiveJobCount() : 0;
if(company.getPaymentPlan()!=null && company.getPaymentJobCount()==null)
{
company.setPaymentJobCount(company.getPaymentPlan().getActiveJobCount());
}
if(plans.length>0)
{
Collection<Integer> jCounts = PaymentPlan.pipesPaymentPlan(plans).toActiveJobCount().vals();
maxCount = Collections.max(jCounts);
minCount = Collections.min(jCounts);
}
Debug.assertion(company != null , "Invalid company in admin portal my company");
......@@ -40,17 +56,18 @@
<p>Hire for any role, save up to $995.00 / mo</p>
</div>
<div class="a-label-row payment-type-row">
<div class="col-md-1 col-sm-1 col-xs-1 text-right">
<div class="col-md-2 col-sm-2 col-xs-2 text-right">
</div>
<div class="col-md-2 col-sm-2 col-xs-2 text-right">
<div class="active-jobs-per-mont">
Active Jobs Per Month
</div>
</div>
<div class="col-md-3 col-sm-3 col-xs-3">
<tagfile:ormsingleasso_select obj="<%= company %>" assocName="PaymentPlan" options="<%= PaymentPlan.searchAll(transaction) %>"/>
<div class="col-md-2 col-sm-2 col-xs-2">
<oneit:ormInput type="number" obj="<%= company %>" attributeName="PaymentJobCount"
min="<%= minCount %>" max="<%= maxCount %>" step="1" cssClass="form-control payment-paln-count"/>
</div>
<div class="col-md-5 col-sm-5 col-xs-5 text-right">
<div class="col-md-4 col-sm-4 col-xs-4 text-right">
<oneit:recalcClass htmlTag="span" classScript="company.getPaymentPlanAmount()!=null ? 'show': 'hide'" company="<%= company %>">
<div >
<span class="payment-amt text-right">
......@@ -64,7 +81,7 @@
</div>
</oneit:recalcClass>
</div>
<div class="col-md-1 col-sm-1 col-xs-1 text-right">
<div class="col-md-2 col-sm-2 col-xs-2 text-right">
</div>
</div>
<div class="a-label-row text-center">
......
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