Commit 306aba4c by chenith Committed by Harsh Shah

Added Job Application sort options to HT003.

parent 92abda34
package performa.orm.types;
import java.util.*;
import oneit.utils.*;
/**
* This class was generated using constGen.bat.
* DO NOT MODIFY THIS CODE.
* Edit the associated .xml file, and regenerate this file
* constGen (directory) (file minus extension)
* e.g. constGen C:\...\sql FieldType
*/
public class AppSortOption extends AbstractEnumerated
{
public static final EnumeratedFactory FACTORY_AppSortOption = new AppSortOptionFactory();
public static final AppSortOption RANK = new AppSortOption ("RANK", "RANK", "Rank", false);
public static final AppSortOption NEWEST = new AppSortOption ("NEWEST", "NEWEST", "Newest", false);
public static final AppSortOption OLDEST = new AppSortOption ("OLDEST", "OLDEST", "Oldest", false);
public static final AppSortOption ALPHA_A_Z = new AppSortOption ("ALPHA_A_Z", "ALPHA_A_Z", "A-Z", false);
public static final AppSortOption ALPHA_Z_A = new AppSortOption ("ALPHA_Z_A", "ALPHA_Z_A", "Z-A", false);
private static final AppSortOption[] allAppSortOptions =
new AppSortOption[] { RANK,NEWEST,OLDEST,ALPHA_A_Z,ALPHA_Z_A};
private static AppSortOption[] getAllAppSortOptions ()
{
return allAppSortOptions;
}
private AppSortOption (String name, String value, String description, boolean disabled)
{
super (name, value, description, disabled);
}
public static final Comparator COMPARE_BY_POSITION = new CompareEnumByPosition (allAppSortOptions);
static
{
defineAdditionalData ();
}
public boolean isEqual (AppSortOption other)
{
return this.name.equals (other.name);
}
public Enumeration getAllInstances ()
{
return AppSortOption.getAll ();
}
private Object readResolve() throws java.io.ObjectStreamException
{
return AppSortOption.forName (this.name);
}
public EnumeratedFactory getFactory ()
{
return FACTORY_AppSortOption;
}
public static AppSortOption forName (String name)
{
if (name == null) { return null; }
AppSortOption[] all = getAllAppSortOptions();
int enumIndex = AbstractEnumerated.getIndexForName (all, name);
return all[enumIndex];
}
public static AppSortOption forValue (String value)
{
if (value == null) { return null; }
AppSortOption[] all = getAllAppSortOptions();
int enumIndex = AbstractEnumerated.getIndexForValue (getAllAppSortOptions (), value);
return all[enumIndex];
}
public static java.util.Enumeration getAll ()
{
return AbstractEnumerated.getAll (getAllAppSortOptions());
}
public static AppSortOption[] getAppSortOptionArray ()
{
return (AppSortOption[])getAllAppSortOptions().clone ();
}
public static void defineAdditionalData ()
{
}
static class AppSortOptionFactory implements EnumeratedFactory
{
public AbstractEnumerated getForName (String name)
{
return AppSortOption.forName (name);
}
public AbstractEnumerated getForValue (String name)
{
return AppSortOption.forValue (name);
}
public Enumeration getAll ()
{
return AppSortOption.getAll ();
}
}
public Map getAdditionalAttributes ()
{
Map attribs = new HashMap ();
return attribs;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<CONSTANT package="performa.orm.types" name="AppSortOption">
<VALUE name="RANK" value="RANK" description="Rank"/>
<VALUE name="NEWEST" value="NEWEST" description="Newest"/>
<VALUE name="OLDEST" value="OLDEST" description="Oldest"/>
<VALUE name="ALPHA_A_Z" value="ALPHA_A_Z" description="A-Z"/>
<VALUE name="ALPHA_Z_A" value="ALPHA_Z_A" description="Z-A"/>
</CONSTANT>
</ROOT>
\ No newline at end of file
...@@ -3,7 +3,6 @@ package performa.utils; ...@@ -3,7 +3,6 @@ package performa.utils;
import java.util.*; import java.util.*;
import oneit.objstore.ObjectTransaction; import oneit.objstore.ObjectTransaction;
import oneit.objstore.rdbms.filters.GreaterThanEqualFilter; import oneit.objstore.rdbms.filters.GreaterThanEqualFilter;
import oneit.objstore.rdbms.filters.LessThanEqualFilter;
import oneit.objstore.rdbms.filters.LessThanFilter; import oneit.objstore.rdbms.filters.LessThanFilter;
import oneit.security.*; import oneit.security.*;
import oneit.utils.Tuple; import oneit.utils.Tuple;
...@@ -14,6 +13,7 @@ import oneit.objstore.utils.*; ...@@ -14,6 +13,7 @@ import oneit.objstore.utils.*;
import oneit.utils.*; import oneit.utils.*;
import oneit.utils.filter.CollectionFilter; import oneit.utils.filter.CollectionFilter;
import oneit.utils.filter.Filter; import oneit.utils.filter.Filter;
import performa.orm.types.AppSortOption;
/** /**
* *
...@@ -120,6 +120,7 @@ public class Utils ...@@ -120,6 +120,7 @@ public class Utils
new Comparator[]{comparator}); new Comparator[]{comparator});
} }
public static int getClosingSoonJobCount(Job[] jobs) public static int getClosingSoonJobCount(Job[] jobs)
{ {
Filter<Job> filter = Job.SearchByAll() Filter<Job> filter = Job.SearchByAll()
...@@ -130,4 +131,42 @@ public class Utils ...@@ -130,4 +131,42 @@ public class Utils
return closingSoonJobs.length; return closingSoonJobs.length;
} }
//to sort application list
public static List<JobApplication> getApplicationsSorted(JobApplication[] applications, AppSortOption appSortOption)
{
ObjectTransform transform = JobApplication.pipesJobApplication().toObjectCreated();
Comparator comparator = CollectionUtils.DEFAULT_COMPARATOR;
if(appSortOption==AppSortOption.OLDEST)
{
transform = JobApplication.pipesJobApplication().toSubmittedDate();
comparator = CollectionUtils.DEFAULT_COMPARATOR;
}
else if(appSortOption==AppSortOption.NEWEST)
{
transform = JobApplication.pipesJobApplication().toSubmittedDate();
comparator = CollectionUtils.reverse(CollectionUtils.DEFAULT_COMPARATOR);
}
// TODO : sort by rank
// else if(appSortOption==AppSortOption.RANK)
// {
// transform = JobApplication.pipesJobApplication().toSubmittedDate();
// comparator = CollectionUtils.reverse(CollectionUtils.DEFAULT_COMPARATOR);
// }
else if(appSortOption==AppSortOption.ALPHA_A_Z)
{
transform = JobApplication.pipesJobApplication().toCandidate().toUser().toFirstName();
comparator = CollectionUtils.CASE_INSENSITIVE_COMPARATOR;
}
else if(appSortOption==AppSortOption.ALPHA_Z_A)
{
transform = JobApplication.pipesJobApplication().toCandidate().toUser().toFirstName();
comparator = CollectionUtils.reverse(CollectionUtils.CASE_INSENSITIVE_COMPARATOR);
}
return ObjstoreUtils.sort( Arrays.asList(applications),
new ObjectTransform[]{transform},
new Comparator[]{comparator});
}
} }
...@@ -9,10 +9,44 @@ ...@@ -9,10 +9,44 @@
<% <%
Job job = (Job) process.getAttribute("Job"); Job job = (Job) process.getAttribute("Job");
if(job==null && request.getParameter("JobID")!=null)
{
job = Job.getJobByID(transaction, Long.parseLong(request.getParameter("JobID")));
process.setAttribute("Job", job);
}
Debug.assertion(job != null, "Job is null in admin portal view applicants"); Debug.assertion(job != null, "Job is null in admin portal view applicants");
String applicationPage = WebUtils.getSamePageInRenderMode(request, WebUtils.VIEW_APPLICATION); String applicationPage = WebUtils.getSamePageInRenderMode(request, WebUtils.VIEW_APPLICATION);
int closingInDays = DateDiff.getDateDiff(Calendar.DATE, DateDiff.getToday(), job.getApplyBy()); int closingInDays = DateDiff.getDateDiff(Calendar.DATE, DateDiff.getToday(), job.getApplyBy());
AppSortOption appSortOpt = (AppSortOption) process.getAttribute("AppSortOption");
if(request.getParameter("AppSortOption") != null)
{
appSortOpt = AppSortOption.forName((String) request.getParameter("AppSortOption"));
}
if(appSortOpt == null)
{
appSortOpt = AppSortOption.RANK;
}
JobApplication[] applications = (JobApplication[]) process.getAttribute("JobApplications");
if(application==null)
{
applications = JobApplication.SearchByAll()
.andJob(new EqualsFilter<>(job))
.andApplicationStatus(new NotEqualsFilter<>(ApplicationStatus.DRAFT))
.search(transaction);
process.setAttribute("JobApplications", applications);
}
List<JobApplication> sortedApplications = applications!=null ? Utils.getApplicationsSorted(applications, appSortOpt) : new ArrayList<JobApplication>();
process.setAttribute("AppSortOption", appSortOpt);
%> %>
<script type="text/javascript"> <script type="text/javascript">
...@@ -36,7 +70,7 @@ ...@@ -36,7 +70,7 @@
<% <%
int index = 0; int index = 0;
for(JobApplication jobApplication : job.getSubmittedApplications()) for(JobApplication jobApplication : sortedApplications)
{ {
%> %>
<div class="appl-c-box application-row" onClick='gotoEditApplication("<%= jobApplication.getID() %>")'> <div class="appl-c-box application-row" onClick='gotoEditApplication("<%= jobApplication.getID() %>")'>
...@@ -98,10 +132,18 @@ ...@@ -98,10 +132,18 @@
</div> </div>
<div class="appli-shorting-dropdown"> <div class="appli-shorting-dropdown">
<span class="appli-order-label">order by</span> <span class="appli-order-label">order by</span>
<select class="form-control"> <select class="form-control" onChange="location=this.value">
<option>Rank</option> <%
<option>Alphabetical (A-Z)</option> for (AppSortOption sortOption : AppSortOption.getAppSortOptionArray())
<option>Alphabetical (Z-A)</option> {
String optionLink = applicationPage + "&JobID=" + job.getID() + "&AppSortOption=" + sortOption.getName() ;
%>
<option <%= (appSortOpt != null && appSortOpt == sortOption ? "selected" : "" )%> value="<%= optionLink %>">
<oneit:toString value="<%= sortOption.getDescription() %>" mode="EscapeHTML"/>
</option>
<%
}
%>
</select> </select>
</div> </div>
</div> </div>
...@@ -110,7 +152,7 @@ ...@@ -110,7 +152,7 @@
<% <%
int j = 0; int j = 0;
for(JobApplication jobApplication : job.getSubmittedApplications()) for(JobApplication jobApplication : sortedApplications)
{ {
String jobMatch = FormatUtils.stringify(jobApplication.getJobMatchPercentage(), "PercentageWholeNumber", "0"); String jobMatch = FormatUtils.stringify(jobApplication.getJobMatchPercentage(), "PercentageWholeNumber", "0");
String culture = FormatUtils.stringify(jobApplication.getCulturePercentage(), "PercentageWholeNumber", "0"); String culture = FormatUtils.stringify(jobApplication.getCulturePercentage(), "PercentageWholeNumber", "0");
......
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