Skip to content
2 changes: 1 addition & 1 deletion src/main/java/uk/ac/cam/cl/dtg/isaac/api/EventsFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ eventId, new Date(), currentUser.getGivenName(),
if (schoolId != null) {
School school = schoolListReader.findSchoolById(schoolId);
if (null != school) {
resultRow.add(school.getName());
resultRow.add(school.getSchoolName());
} else {
resultRow.add(schoolId);
}
Expand Down
191 changes: 130 additions & 61 deletions src/main/java/uk/ac/cam/cl/dtg/isaac/dos/users/School.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,19 @@
*
*/
public class School {
private String urn;
private String name;
private String postcode;
private String schoolId;
private String countryCode;
private String schoolName;
private String town;
private String postalCode;
private Boolean excluded;
private Boolean closed;

/**
* Enum to represent where this school object was created.
*/
public enum SchoolDataSource {
GOVERNMENT_UK, GOVERNMENT_IE, GOVERNMENT_SCO, GOVERNMENT_WAL, GOVERNMENT_NI, USER_ENTERED;
GOVERNMENT_UK, GOVERNMENT_IE, GOVERNMENT_SCT, GOVERNMENT_SCT_IND, GOVERNMENT_WLS, GOVERNMENT_NIR, USER_ENTERED;

@Override
public String toString() {
Expand All @@ -48,90 +51,156 @@ public School() {

/**
* Full constructor.
*
* @param urn
* - unique id
* @param name
* - name of the school.
* @param postcode
* -postcode of the school
* @param dataSource
* -dataSource of this information
*
* @param schoolId
* - unique school ID
* @param countryCode
* - country code for the school
* @param schoolName
* - name of the school
* @param town
* - name of the town where the school is located
* @param postalCode
* - postal code of the school
* @param excluded
* - whether the school is excluded when searching for schools by name
* @param closed
* - whether the school is closed
* @param dataSource
* - data source of this information
*/
public School(final String urn, final String name, final String postcode, final Boolean closed, final SchoolDataSource dataSource) {
this.urn = urn;
this.name = name;
this.postcode = postcode;
this.dataSource = dataSource;
public School(final String schoolId, final String countryCode, final String schoolName, final String town,
final String postalCode, final Boolean excluded, final Boolean closed, final SchoolDataSource dataSource) {
this.schoolId = schoolId;
this.countryCode = countryCode;
this.schoolName = schoolName;
this.town = town;
this.postalCode = postalCode;
this.excluded = excluded;
this.closed = closed;
this.dataSource = dataSource;
}

/**
* Gets the urn.
*
* @return the urn
* Gets the school ID.
*
* @return the school ID
*/
public String getUrn() {
return urn;
public String getSchoolId() {
return schoolId;
}

/**
* Sets the urn.
*
* @param urn
* the urn to set
* Sets the school ID.
*
* @param schoolId
* the school ID to set
*/
public void setUrn(final String urn) {
this.urn = urn;
public void setSchoolId(final String schoolId) {
this.schoolId = schoolId;
}

/**
* Gets the name.
*
* @return the name
* Gets the country code.
*
* @return the country code
*/
public String getName() {
return name;
public String getCountryCode() {
return countryCode;
}

/**
* Sets the name.
*
* @param name
* the name to set
* Sets the country code.
*
* @param countryCode
* the country code to set
*/
public void setName(final String name) {
this.name = name;
public void setCountryCode(final String countryCode) {
this.countryCode = countryCode;
}

/**
* Gets the postcode.
*
* @return the postcode
* Gets the school name.
*
* @return the school name
*/
public String getPostcode() {
return postcode;
public String getSchoolName() {
return schoolName;
}

/**
* Sets the postcode.
*
* @param postcode
* the postcode to set
* Sets the school name.
*
* @param schoolName
* the school name to set
*/
public void setPostcode(final String postcode) {
this.postcode = postcode;
public void setSchoolName(final String schoolName) {
this.schoolName = schoolName;
}

/**
* Gets the town.
*
* @return the town
*/
public String getTown() {
return town;
}

/**
* Sets the town.
*
* @param town
* the town to set
*/
public void setTown(final String town) {
this.town = town;
}

/**
* Gets the postal code.
*
* @return the postal code
*/
public String getPostalCode() {
return postalCode;
}

/**
* Sets the postal code.
*
* @param postalCode
* the postal code to set
*/
public void setPostalCode(final String postalCode) {
this.postalCode = postalCode;
}

/**
* Gets the excluded status.
*
* @return whether the school is excluded when searching for schools by name
*/
public Boolean getExcluded() {
return excluded;
}

/**
* Sets the excluded status.
*
* @param excluded
* whether the school should be excluded when searching for schools by name
*/
public void setExcluded(final Boolean excluded) {
this.excluded = excluded;
}

/**
* Gets the closed status.
*
* @return whether the school is closed
*/
public Boolean isClosed() {
public Boolean getClosed() {
return closed;
}

Expand All @@ -146,19 +215,19 @@ public void setClosed(final Boolean closed) {
}

/**
* Gets the verifiedSchool.
* Gets the data source for the school information.
*
* @return the verifiedSchool
* @return the data source
*/
public SchoolDataSource getDataSource() {
return dataSource;
}

/**
* Sets the dataSource.
* Sets the data source for the school information.
*
* @param dataSource
* the dataSource to set
* the data source to set
*/
public void setDataSource(final SchoolDataSource dataSource) {
this.dataSource = dataSource;
Expand All @@ -168,7 +237,7 @@ public void setDataSource(final SchoolDataSource dataSource) {
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((urn == null) ? 0 : urn.hashCode());
result = prime * result + ((schoolId == null) ? 0 : schoolId.hashCode());
return result;
}

Expand All @@ -184,18 +253,18 @@ public boolean equals(final Object obj) {
return false;
}
School other = (School) obj;
if (urn == null) {
if (other.urn != null) {
if (schoolId == null) {
if (other.schoolId != null) {
return false;
}
} else if (!urn.equals(other.urn)) {
} else if (!schoolId.equals(other.schoolId)) {
return false;
}
return true;
}

@Override
public String toString() {
return "School [urn=" + urn + ", name=" + name + ", postcode=" + postcode + "]";
return "School [id=" + schoolId + ", name=" + schoolName + ", postcode=" + postalCode + "]";
}
}
14 changes: 7 additions & 7 deletions src/main/java/uk/ac/cam/cl/dtg/segue/api/AdminFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -806,8 +806,8 @@ public Response getContentProblems(@Context final HttpServletRequest request,
* - if searching by school other field.
* @param postcode
* - if searching by postcode.
* @param schoolURN
* - if searching by school by the URN.
* @param schoolId
* - if searching for school by ID.
* @param emailVerificationStatus
* - if searching by email verification status
* @return a userDTO or a segue error response
Expand All @@ -822,7 +822,7 @@ public Response findUsers(@Context final HttpServletRequest httpServletRequest,
@QueryParam("schoolOther") @Nullable final String schoolOther,
@QueryParam("postcode") @Nullable final String postcode,
@QueryParam("postcodeRadius") @Nullable final String postcodeRadius,
@QueryParam("schoolURN") @Nullable final String schoolURN,
@QueryParam("schoolId") @Nullable final String schoolId,
@QueryParam("emailVerificationStatus") @Nullable final EmailVerificationStatus emailVerificationStatus) {

RegisteredUserDTO currentUser;
Expand All @@ -839,7 +839,7 @@ public Response findUsers(@Context final HttpServletRequest httpServletRequest,
&& (null == familyName || familyName.isEmpty())
&& (null == schoolOther || schoolOther.isEmpty())
&& (null == email || email.isEmpty())
&& (null == schoolURN || schoolURN.isEmpty())
&& (null == schoolId || schoolId.isEmpty())
&& (null == postcode || postcode.isEmpty())) {
return new SegueErrorResponse(Status.FORBIDDEN, "You do not have permission to do wildcard searches.")
.toResponse();
Expand Down Expand Up @@ -885,8 +885,8 @@ public Response findUsers(@Context final HttpServletRequest httpServletRequest,
userPrototype.setSchoolOther(schoolOther);
}

if (null != schoolURN) {
userPrototype.setSchoolId(schoolURN);
if (null != schoolId) {
userPrototype.setSchoolId(schoolId);
}

if (null != emailVerificationStatus) {
Expand Down Expand Up @@ -915,7 +915,7 @@ public Response findUsers(@Context final HttpServletRequest httpServletRequest,
if (userDTO.getSchoolId() != null) {
School school = this.schoolReader.findSchoolById(userDTO.getSchoolId());
if (school != null) {
String schoolPostCode = school.getPostcode();
String schoolPostCode = school.getPostalCode();
if (null == schoolPostCode || schoolPostCode.isEmpty()) {
continue;
}
Expand Down
21 changes: 9 additions & 12 deletions src/main/java/uk/ac/cam/cl/dtg/segue/api/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -509,18 +509,15 @@ public enum EventFilterOption {
public static final String ID_SEPARATOR = "|";
public static final String ESCAPED_ID_SEPARATOR = "\\" + ID_SEPARATOR;

// School List loading - raw data
public static final String SCHOOL_URN_FIELDNAME = "URN";
public static final String SCHOOL_ESTABLISHMENT_NAME_FIELDNAME = "EstablishmentName";
public static final String SCHOOL_POSTCODE_FIELDNAME = "Postcode";
public static final String SCHOOL_DATA_SOURCE_FIELDNAME = "DataSource";
public static final String SCHOOL_CLOSED_FIELDNAME = "Closed";

// School List loading POJO fields
public static final String SCHOOL_URN_FIELDNAME_POJO = "urn";
public static final String SCHOOL_ESTABLISHMENT_NAME_FIELDNAME_POJO = "name";
public static final String SCHOOL_POSTCODE_FIELDNAME_POJO = "postcode";
public static final String SCHOOL_CLOSED_FIELDNAME_POJO = "closed";
// School List loading
public static final String SCHOOL_ID_FIELDNAME = "schoolId";
public static final String SCHOOL_COUNTRY_CODE_FIELDNAME = "countryCode";
public static final String SCHOOL_NAME_FIELDNAME = "schoolName";
public static final String SCHOOL_TOWN_FIELDNAME = "town";
public static final String SCHOOL_POSTCODE_FIELDNAME = "postalCode";
public static final String SCHOOL_EXCLUDED_FIELDNAME = "excluded";
public static final String SCHOOL_CLOSED_FIELDNAME = "closed";
public static final String SCHOOL_DATA_SOURCE_FIELDNAME = "dataSource";

// User School Reporting

Expand Down
Loading
Loading