@@ -0,0 +1,3262 @@
+package org.slc.sli.api.security.context.resolver;%0A%0Aimport org.slc.sli.api.client.constants.EntityNames;%0Aimport org.slc.sli.api.client.constants.v1.ParameterConstants;%0Aimport org.slc.sli.api.security.context.AssociativeContextHelper;%0Aimport org.slc.sli.api.security.context.traversal.graph.NodeFilter;%0Aimport org.slc.sli.domain.Entity;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.beans.factory.annotation.Value;%0Aimport org.springframework.stereotype.Component;%0A%0Aimport java.text.DateFormat;%0Aimport java.text.ParseException;%0Aimport java.text.SimpleDateFormat;%0Aimport java.util.ArrayList;%0Aimport java.util.Calendar;%0Aimport java.util.Date;%0Aimport java.util.List;%0A%0A/**%0A * Filters the entity by a given date%0A *%0A * @author jcole%0A *%0A */%0A@Component%0Apublic class NodeDateFilter extends NodeFilter %7B%0A%0A    @Autowired%0A    private AssociativeContextHelper helper;%0A%0A    DateFormat formatter = new SimpleDateFormat(%22yyyy-MM-dd%22);%0A%0A    private String entityName;%0A    private String referenceId;%0A    private String endDateString;%0A    private String filterDateParam;%0A%0A    public void setParameters (String entityName, String referenceId, String endDateString, String filterDateParam) %7B%0A        this.entityName = entityName;%0A        this.referenceId = referenceId;%0A        this.endDateString = endDateString;%0A        this.filterDateParam = filterDateParam;%0A    %7D%0A%0A    @Override%0A    public List%3CString%3E filterIds(List%3CString%3E toResolve) %7B%0A        Calendar calendar = Calendar.getInstance();%0A        calendar.setTimeInMillis(System.currentTimeMillis());%0A        List%3CString%3E returnIds = new ArrayList%3CString%3E();%0A%0A        if (entityName != null && referenceId != null && endDateString != null && filterDateParam != null) %7B%0A            //get the filter date%0A            String formattedEndDateString = helper.getFilterDate(endDateString, calendar);%0A%0A            if (!toResolve.isEmpty()) %7B%0A                //get the entities%0A                Iterable%3CEntity%3E referenceEntities = helper.getReferenceEntities(entityName,%0A                        referenceId, toResolve);%0A%0A                for (Entity entity : referenceEntities) %7B%0A                    String filterDateString = (String) entity.getBody().get(filterDateParam);%0A%0A                    if (isResolvable(filterDateString, formattedEndDateString)) %7B%0A                        returnIds.add((String) entity.getBody().get(referenceId));%0A                    %7D%0A                %7D%0A            %7D%0A        %7D%0A%0A        return returnIds;%0A    %7D%0A%0A    /**%0A     * Compares two given dates%0A     * @param filterDate%0A     * @param formattedEndDateString%0A     * @return%0A     */%0A    protected boolean isResolvable(String filterDateString, String formattedEndDateString) %7B%0A        Date filterDate = null, endDate = null;%0A        boolean retValue = true;%0A%0A        try %7B%0A            if (filterDateString != null && !filterDateString.equals(%22%22)) %7B%0A                filterDate = formatter.parse(filterDateString);%0A                endDate = formatter.parse(formattedEndDateString);%0A%0A                if (filterDate.before(endDate)) %7B%0A                    retValue = false;%0A                %7D%0A            %7D%0A%0A        %7D catch (ParseException e) %7B%0A            retValue = false;%0A        %7D%0A%0A        return retValue;%0A    %7D%0A%0A%7D%0A

add nodeDateFilter