Skip to content

Commit

Permalink
Merge pull request #18 from TAMULib/vireo_undergrad_sprint1
Browse files Browse the repository at this point in the history
Vireo undergrad sprint1
  • Loading branch information
jmicah committed Sep 23, 2014
2 parents 1cd1128 + 83db8aa commit 9209d9c
Show file tree
Hide file tree
Showing 40 changed files with 878 additions and 317 deletions.
2 changes: 0 additions & 2 deletions app/controllers/AbstractVireoController.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ public static void handleError(Throwable throwable) {
errorLog.logError(throwable, request);
}



/**
* Return true if the string is either null or only consists of whitespace.
*
Expand Down
32 changes: 20 additions & 12 deletions app/controllers/FilterTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import org.tdl.vireo.search.SearchResult;
import org.tdl.vireo.state.State;

import org.tdl.vireo.search.Semester;

import play.Logger;
import play.libs.F.Promise;
import play.modules.spring.Spring;
Expand All @@ -59,7 +61,6 @@ public class FilterTab extends AbstractVireoController {
public static ExportService exportService = Spring.getBeanOfType(ExportService.class);
public static AssignService assignService = Spring.getBeanOfType(AssignService.class);
public static CommentService commentService = Spring.getBeanOfType(CommentService.class);


// Store the cookie and session names in an easy to lookup two dimensional
// array, so that modifySearch() and modifyFilter() can be easily coded to
Expand All @@ -68,24 +69,22 @@ public class FilterTab extends AbstractVireoController {
// submission list's active filter. Or easily switch that to lookup the same
// name for the action log.
public final static String[][] NAMES = {
{
{
"SubmissionFilter",
"SubmissionDirection",
"SubmissionOrderBy",
"SubmissionOffset",
"SubmissionColumns",
"SubmissionFacets",
"SubmissionResultsPerPage",
},
"SubmissionResultsPerPage", },
{
"ActionLogFilter",
"ActionLogDirection",
"ActionLogOrderBy",
"ActionLogOffset",
"ActionLogColumns",
"ActionLogFacets",
"ActionLogResultsPerPage"
}
"ActionLogResultsPerPage" }
};

// Static index lookups into the NAMES array for name sets.
Expand All @@ -108,8 +107,7 @@ public class FilterTab extends AbstractVireoController {
public static void listRedirect() {
list();
}



/**
* List page
*
Expand Down Expand Up @@ -337,8 +335,7 @@ public static void log() {
}
} else {
facets = getDefaultFacets(ACTION_LOG);
}

}

// Add all search orders to the view
for (SearchOrder order : SearchOrder.values())
Expand Down Expand Up @@ -923,10 +920,15 @@ protected static void doAddFilterParameter(SearchFilter activeFilter) {
EmbargoType embargo = settingRepo.findEmbargoType(embargoId);
activeFilter.addEmbargoType(embargo);

} else if ("semester".equals(type)) {
} else if ("graduationSemester".equals(type)) {
Integer year = params.get("year",Integer.class);
Integer month = params.get("month",Integer.class);
activeFilter.addGraduationSemester(year, month);

} else if ("programDate".equals(type)) {
Integer year = params.get("year",Integer.class);
Integer month = params.get("month",Integer.class);
activeFilter.addProgramDate(year, month);

} else if ("degree".equals(type)) {
activeFilter.addDegree(value);
Expand Down Expand Up @@ -1104,10 +1106,15 @@ protected static void doRemoveFilterParamater(SearchFilter activeFilter) {
EmbargoType embargo = settingRepo.findEmbargoType(embargoId);
activeFilter.removeEmbargoType(embargo);

} else if ("semester".equals(type)) {
} else if ("graduationSemester".equals(type)) {
Integer year = params.get("year",Integer.class);
Integer month = params.get("month",Integer.class);
activeFilter.removeGraduationSemester(year, month);

} else if ("programDate".equals(type)) {
Integer year = params.get("year",Integer.class);
Integer month = params.get("month",Integer.class);
activeFilter.removeProgramDate(year, month);

} else if ("degree".equals(type)) {
activeFilter.removeDegree(value);
Expand Down Expand Up @@ -1192,6 +1199,7 @@ protected static List<SearchFacet> getDefaultFacets(int type) {
facets.add(SearchFacet.STATE);
facets.add(SearchFacet.ASSIGNEE);
facets.add(SearchFacet.GRADUATION_SEMESTER);
facets.add(SearchFacet.PROGRAM_DATE);
}

return facets;
Expand Down
7 changes: 5 additions & 2 deletions app/controllers/ViewTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ public static void updateJSON(Long subId, String field, String value){
String gradMonth = new DateFormatSymbols().getMonths()[submission.getGraduationMonth()];

currentValue = gradMonth + " " + submission.getGraduationYear().toString();

//Program Date
} else if("programDate".equals(field)){

Expand Down Expand Up @@ -1215,7 +1216,8 @@ protected static List<String> parseGraduation(String graduation){
String[] strings = graduation.split(" ");

if(strings.length != 2 || strings[1].length() != 4)
throw new IllegalArgumentException("The graduation date "+graduation+" is invalid. The format must be 'May 2013'.");
throw new IllegalArgumentException("The graduation date "+graduation+
" is invalid. The format must be 'May 2013'.");

for(int i = 0; i < strings.length; i++) {
String item = strings[i];
Expand Down Expand Up @@ -1244,7 +1246,8 @@ protected static List<String> parseProgramDate(String rawProgramDate){
String[] strings = rawProgramDate.split(" ");

if(strings.length != 2 || strings[1].length() != 4)
throw new IllegalArgumentException("The program date "+rawProgramDate+" is invalid. The format must be 'May 2013'.");
throw new IllegalArgumentException("The program date "+rawProgramDate+
" is invalid. The format must be 'May 2013'.");

for(int i = 0; i < strings.length; i++) {
String item = strings[i];
Expand Down
22 changes: 3 additions & 19 deletions app/controllers/settings/ApplicationSettingsTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,6 @@ public static void reorderDepositLocationsJSON(String depositLocationIds) {
}



/**
* Search the current list of members and generate. This action is designed
* to be invoked from an AJAX call but does not produce JSON. Instead it
Expand Down Expand Up @@ -723,8 +722,7 @@ public static void updatePersonRole(String personId, int role) {

if (newRole.ordinal() > context.getPerson().getRole().ordinal())
throw new IllegalArgumentException("Unable to set a user's role to a higher level that the current user.");



String[] parts = personId.split("_");
Long id = Long.valueOf(parts[1]);
Person updated = personRepo.findPerson(id);
Expand All @@ -746,8 +744,6 @@ public static void updatePersonRole(String personId, int role) {

renderTemplate("SettingTabs/listMembers.include",reviewers,updated);



} catch (RuntimeException re) {
Logger.error(re,"Unable to update person's role");
String error = re.getMessage();
Expand All @@ -756,17 +752,6 @@ public static void updatePersonRole(String personId, int role) {
}













/**
* Validate the current semester string which must be of the format: month
* year.
Expand Down Expand Up @@ -822,6 +807,8 @@ protected static String submitTestItem(DepositLocation location) {
sub.setDocumentType("Test Document Type");
sub.setGraduationMonth(new Date().getMonth());
sub.setGraduationYear(new Date().getYear()+1900);
sub.setProgramMonth(new Date().getMonth());
sub.setProgramYear(new Date().getYear()+1900);

CommitteeMember member = sub.addCommitteeMember("Test", "Advisor", null).save();
member.addRole("Chair");
Expand All @@ -840,7 +827,4 @@ protected static String submitTestItem(DepositLocation location) {
sub.delete();
}
}



}
21 changes: 10 additions & 11 deletions app/controllers/settings/ConfigurableSettingsTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static void configurableSettings() {
List<DocumentType> docTypes = settingRepo.findAllDocumentTypes();
List<CommitteeMemberRoleType> roleTypes = settingRepo.findAllCommitteeMemberRoleTypes();
List<GraduationMonth> gradMonths = settingRepo.findAllGraduationMonths();
List<ProgramMonth> programMonths = settingRepo.findAllProgramMonths();
List<ProgramMonth> proMonths = settingRepo.findAllProgramMonths();

Locale locales[] = Locale.getAvailableLocales();
List<Locale> localeLanguages = new ArrayList<Locale>(Arrays.asList(locales));
Expand All @@ -89,7 +89,7 @@ public static void configurableSettings() {
embargos,

// Sortable lists
colleges, programs, departments, majors, degrees, docTypes, roleTypes, gradMonths, programMonths, languages,
colleges, programs, departments, majors, degrees, docTypes, roleTypes, gradMonths, proMonths, languages,

// Locales
localeLanguages);
Expand Down Expand Up @@ -182,7 +182,6 @@ public static void bulkAdd(String modelType, String bulkAdd) {

}
saveModelOrder(models);


// Redirect back the configurable setting tab.
if ("college".equals(modelType)) {
Expand Down Expand Up @@ -1614,10 +1613,10 @@ public static void addGraduationMonthJSON(String name) {
// ////////////////////////////////////////////

/**
* Create a new GraduationMonth. The id of the new month will be returned.
* Create a new ProgramMonth. The id of the new month will be returned.
*
* @param name
* The name of the new graduation month
* The name of the new program month
*/
@Security(RoleType.MANAGER)
public static void addProgramMonthJSON(String name) {
Expand Down Expand Up @@ -1703,7 +1702,7 @@ public static void editGraduationMonthJSON(String graduationMonthId, String name
* returned.
*
* @param programMonthId
* The id of the month to be edited, in the form "graduationMonth_id"
* The id of the month to be edited, in the form "programMonth_id"
* @param name
* The new name of the month
*/
Expand Down Expand Up @@ -1767,10 +1766,10 @@ public static void removeGraduationMonthJSON(String graduationMonthId) {


/**
* Remove an existing graduation month
* Remove an existing program month
*
* @param programMonthId
* The id of the graduation month to be removed of the form "graduationMonth_id"
* The id of the program month to be removed of the form "programMonth_id"
*/
@Security(RoleType.MANAGER)
public static void removeProgramMonthJSON(String programMonthId) {
Expand Down Expand Up @@ -1805,7 +1804,7 @@ public static void removeAllGraduationMonths() {
}

/**
* Remove all existing graduation months
* Remove all existing program months
*
*/
@Security(RoleType.MANAGER)
Expand Down Expand Up @@ -1847,11 +1846,11 @@ public static void reorderGraduationMonthsJSON(String graduationMonthIds) {
}

/**
* Reorder a list of graduation months.
* Reorder a list of program months.
*
* @param programMonthIds
* An ordered list of ids in the form:
* "graduationMonth_1,graduationMonth_3,graduationMonth_2"
* "programMonth_1,programMonth_3,programMonth_2"
*/
@Security(RoleType.MANAGER)
public static void reorderProgramMonthsJSON(String programMonthIds) {
Expand Down
60 changes: 57 additions & 3 deletions app/controllers/submit/DocumentInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.tdl.vireo.model.DocumentType;
import org.tdl.vireo.model.EmbargoType;
import org.tdl.vireo.model.GraduationMonth;
import org.tdl.vireo.model.ProgramMonth;
import org.tdl.vireo.model.Language;
import org.tdl.vireo.model.NameFormat;
import org.tdl.vireo.model.RoleType;
Expand Down Expand Up @@ -235,6 +236,12 @@ public static void documentInfo(Long subId) {

if (isFieldEnabled(GRADUATION_DATE) && sub.getGraduationYear() != null)
degreeYear = sub.getGraduationYear().toString();

if (isFieldEnabled(PROGRAM_DATE) && sub.getProgramMonth() != null)
programMonth = sub.getProgramMonth().toString();

if (isFieldEnabled(PROGRAM_DATE) && sub.getProgramYear() != null)
programYear = sub.getProgramYear().toString();

if (isFieldEnabled(DEFENSE_DATE) && sub.getDefenseDate() != null)
defenseDate = sub.getDefenseDate();
Expand Down Expand Up @@ -350,7 +357,7 @@ public static void documentInfo(Long subId) {

renderTemplate("Submit/documentInfo.html", subId, stickies,

title, degreeMonth, degreeYear, defenseDate, docType, abstractText, keywords,
title, degreeMonth, degreeYear, programMonth, programYear, defenseDate, docType, abstractText, keywords,
subjectPrimary, subjectSecondary, subjectTertiary, docLanguage, committeeSlots,
committee, chairEmail, publishedMaterialFlag, publishedMaterial, embargo);
}
Expand All @@ -376,6 +383,13 @@ public static boolean verify(Submission sub) {

if (!isValidDegreeYear(sub.getGraduationYear()))
validation.addError("degreeYear", "Please select a degree year");

// Program Date (month & year)
if (!isValidProgramMonth(sub.getProgramMonth()))
validation.addError("programMonth", "Please select a program month");

if (!isValidProgramYear(sub.getProgramYear()))
validation.addError("programYear", "Please select a program year");

// Defense Date
Date now = new Date();
Expand Down Expand Up @@ -495,6 +509,47 @@ protected static boolean isValidDegreeYear(Integer degreeYear) {

return false;
}

/**
* @param programMonth
* The month of the program
* @return True if the name is a valid program month.
*/
protected static boolean isValidProgramMonth(Integer programMonth) {
if (programMonth == null) {
if (isFieldRequired(PROGRAM_DATE))
return false;
return true;
}

for (ProgramMonth month : settingRepo.findAllProgramMonths()) {
if (programMonth == month.getMonth()) {
return true;
}
}
return false;
}

/**
* @param programYear
* The year of the program
* @return True if the name is a valid program year.
*/
protected static boolean isValidProgramYear(Integer programYear) {
if (programYear == null) {
if (isFieldRequired(PROGRAM_DATE))
return false;
return true;
}

for (Integer y : getProgramYears()) {
if (programYear.equals(y)) {
return true;
}
}

return false;
}

/**
*
Expand All @@ -519,8 +574,7 @@ protected static boolean isValidDocType(String docType) {

return false;
}



/**
* Determine if the provided roles are valid for this given degree level of the submission.
*
Expand Down
1 change: 1 addition & 0 deletions app/org/tdl/vireo/email/VireoEmail.java
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ public interface VireoEmail {
* LAST_NAME
* DOCUMENT_TITLE
* GRAD_SEMESTER
* PROGRAM_DATE
* SUBMISSION_STATUS
* SUBMISSION_STATUS_ASSIGNED_TO
*
Expand Down
Loading

0 comments on commit 9209d9c

Please sign in to comment.