Skip to content
Browse files

CLC-90 Add department code to class page feed

  • Loading branch information...
1 parent 17f0473 commit dccd60ec2c8a7fa4a632ee3102928afa0a38cf44 @raydavis committed Sep 4, 2012
View
1 src/main/java/edu/berkeley/calcentral/daos/ClassPagesDao.java
@@ -26,6 +26,7 @@ public ClassPage getBaseClassPage(int year, String term, String courseID) {
+ " bci.TERM_YR || bci.TERM_CD || bci.COURSE_CNTL_NUM classid, " //ignoring course control num permissions issues for now.
+ " '' info_last_updated, "
+ " bci.COURSE_TITLE classtitle, "
+ + " bci.DEPT_NAME department, "
+ " bci.CATALOG_DESCRIPTION description "
+ " FROM BSPACE_COURSE_INFO_VW bci "
+ " WHERE bci.TERM_YR = :year AND bci.TERM_CD = :term AND bci.COURSE_CNTL_NUM = :courseID";
View
13 src/main/java/edu/berkeley/calcentral/domain/ClassPage.java
@@ -10,11 +10,12 @@
private String info_last_updated;
private ClassPageCourseInfo courseinfo;
private String classtitle;
+ private String department;
private String description;
- private List<ClassPageInstructor> instructors;
+ private List<ClassPageInstructor> instructors;
private List<ClassPageSchedule> schedule;
- private List<ClassPageSection> sections;
-
+ private List<ClassPageSection> sections;
+
public String getClassId() {
return classid;
}
@@ -27,6 +28,9 @@ public ClassPageCourseInfo getCourseinfo() {
public String getClasstitle() {
return classtitle;
}
+ public String getDepartment() {
+ return department;
+ }
public String getDescription() {
return description;
}
@@ -51,6 +55,9 @@ public void setCourseinfo(ClassPageCourseInfo courseinfo) {
public void setClasstitle(String classtitle) {
this.classtitle = classtitle;
}
+ public void setDepartment(String department) {
+ this.department = department;
+ }
public void setDescription(String description) {
this.description = description;
}
View
4 src/main/java/edu/berkeley/calcentral/services/ClassPagesService.java
@@ -45,7 +45,6 @@
@Produces({MediaType.APPLICATION_JSON})
@Path("{ccc}")
public Map<String, Object> getClassInfoMap(@PathParam("ccc") String ccc) {
-
ClassPage classPage;
Map<String, Object> returnObject = Maps.newHashMap();
try {
@@ -54,13 +53,14 @@
returnObject.put("info_last_updated", classPage.getInfo_last_updated());
returnObject.put("courseinfo", classPage.getCourseinfo());
returnObject.put("classtitle", classPage.getClasstitle());
+ returnObject.put("department", classPage.getDepartment());
returnObject.put("description", classPage.getDescription());
returnObject.put("instructors", classPage.getInstructors());
returnObject.put("schedule", classPage.getSchedule());
returnObject.put("sections", classPage.getSections());
} catch (Exception e) {
//TODO: Change this to use whatever final exception handling scheme, instead of swallowing the exception.
- LOGGER.error(Throwables.getStackTraceAsString(e));
+ LOGGER.error(e.getMessage(), e);
}
return returnObject;
}
View
35 src/test/java/edu/berkeley/calcentral/services/ClassPagesServiceTest.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Sakai Foundation (SF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The SF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package edu.berkeley.calcentral.services;
+
+import edu.berkeley.calcentral.DatabaseAwareTest;
+import edu.berkeley.calcentral.domain.ClassPage;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class ClassPagesServiceTest extends DatabaseAwareTest {
+ @Autowired
+ private ClassPagesService classPagesService;
+
+ @Test
+ public void getDepartment() throws Exception {
+ ClassPage classPage = classPagesService.getClassInfo("2012D7308");
+ assertNotNull(classPage);
+ assertEquals("BIOLOGY", classPage.getDepartment());
+ }
+}

0 comments on commit dccd60e

Please sign in to comment.
Something went wrong with that request. Please try again.